Switched to termios callback structure.

This commit is contained in:
Joel Sherrill
1998-05-04 12:40:21 +00:00
parent f35abd4863
commit 55951bc1e6
3 changed files with 67 additions and 40 deletions

View File

@@ -190,17 +190,22 @@ rtems_device_driver console_open(
) )
{ {
rtems_status_code sc; rtems_status_code sc;
static const rtems_termios_callbacks pollCallbacks = {
NULL, /* firstOpen */
NULL, /* lastClose */
console_inbyte_nonblocking, /* pollRead */
console_write_support, /* write */
NULL, /* setAttributes */
NULL, /* stopRemoteTx */
NULL, /* startRemoteTx */
0 /* outputUsesInterrupts */
};
assert( minor <= 1 ); assert( minor <= 1 );
if ( minor > 2 ) if ( minor > 2 )
return RTEMS_INVALID_NUMBER; return RTEMS_INVALID_NUMBER;
sc = rtems_termios_open (major, minor, arg, sc = rtems_termios_open (major, minor, arg, &pollCallbacks );
NULL,
NULL,
console_inbyte_nonblocking,
console_write_support,
0);
return RTEMS_SUCCESSFUL; return RTEMS_SUCCESSFUL;
} }

View File

@@ -18,6 +18,10 @@
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
/* external prototypes for monitor interface routines */
void outbyte( char );
char inbyte( void );
/* /*
* console_outbyte_polled * console_outbyte_polled
@@ -87,9 +91,10 @@ void DEBUG_puts(
* *
*/ */
int console_write_support (int minor, char *buf, int len) int console_write_support (int minor, const void *bufarg, int len)
{ {
int nwrite = 0; int nwrite = 0;
const char *buf = bufarg;
while (nwrite < len) { while (nwrite < len) {
console_outbyte_polled( minor, *buf++ ); console_outbyte_polled( minor, *buf++ );
@@ -131,17 +136,23 @@ rtems_device_driver console_open(
) )
{ {
rtems_status_code sc; rtems_status_code sc;
static const rtems_termios_callbacks pollCallbacks = {
NULL, /* firstOpen */
NULL, /* lastClose */
console_inbyte_nonblocking, /* pollRead */
console_write_support, /* write */
NULL, /* setAttributes */
NULL, /* stopRemoteTx */
NULL, /* startRemoteTx */
0 /* outputUsesInterrupts */
};
assert( minor <= 1 ); assert( minor <= 1 );
if ( minor > 2 ) if ( minor > 2 )
return RTEMS_INVALID_NUMBER; return RTEMS_INVALID_NUMBER;
sc = rtems_termios_open (major, minor, arg, sc = rtems_termios_open (major, minor, arg, &pollCallbacks );
NULL,
NULL,
console_inbyte_nonblocking,
console_write_support,
0);
return RTEMS_SUCCESSFUL; return RTEMS_SUCCESSFUL;
} }

View File

@@ -423,6 +423,27 @@ rtems_device_driver console_open(
rtems_status_code sc; rtems_status_code sc;
#if defined(CONSOLE_USE_INTERRUPTS) #if defined(CONSOLE_USE_INTERRUPTS)
rtems_libio_open_close_args_t *args = arg; rtems_libio_open_close_args_t *args = arg;
static const rtems_termios_callbacks intrCallbacks = {
NULL, /* firstOpen */
NULL, /* lastClose */
NULL, /* pollRead */
console_write_support, /* write */
NULL, /* setAttributes */
NULL, /* stopRemoteTx */
NULL, /* startRemoteTx */
0 /* outputUsesInterrupts */
};
#else
static const rtems_termios_callbacks pollCallbacks = {
NULL, /* firstOpen */
NULL, /* lastClose */
console_inbyte_nonblocking, /* pollRead */
console_write_support, /* write */
NULL, /* setAttributes */
NULL, /* stopRemoteTx */
NULL, /* startRemoteTx */
0 /* outputUsesInterrupts */
};
#endif #endif
assert( minor <= 1 ); assert( minor <= 1 );
@@ -430,21 +451,11 @@ rtems_device_driver console_open(
return RTEMS_INVALID_NUMBER; return RTEMS_INVALID_NUMBER;
#if defined(CONSOLE_USE_INTERRUPTS) #if defined(CONSOLE_USE_INTERRUPTS)
sc = rtems_termios_open (major, minor, arg, sc = rtems_termios_open (major, minor, arg, &intrCallbacks);
NULL,
NULL,
NULL,
console_write_support,
0);
console_termios_data[ minor ] = args->iop->data1; console_termios_data[ minor ] = args->iop->data1;
#else #else
sc = rtems_termios_open (major, minor, arg, sc = rtems_termios_open (major, minor, arg, &pollCallbacks);
NULL,
NULL,
console_inbyte_nonblocking,
console_write_support,
0);
#endif #endif
return RTEMS_SUCCESSFUL; return RTEMS_SUCCESSFUL;