forked from Imagelibrary/rtems
updated to format of 3.6.0 console drivers
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* This file contains the Force CPU386 console IO package.
|
* This file contains the i386ex console IO package.
|
||||||
*
|
*
|
||||||
* COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
|
* COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
|
||||||
* On-Line Applications Research Corporation (OAR).
|
* On-Line Applications Research Corporation (OAR).
|
||||||
@@ -14,12 +14,11 @@
|
|||||||
|
|
||||||
#define F386_INIT
|
#define F386_INIT
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <bsp.h>
|
||||||
#include <stdio.h> /* to be removed */
|
#include <rtems/libio.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <rtems.h>
|
|
||||||
#include "console.h"
|
|
||||||
#include "bsp.h"
|
|
||||||
#include "../startup/80386ex.h"
|
#include "../startup/80386ex.h"
|
||||||
|
|
||||||
/* console_cleanup
|
/* console_cleanup
|
||||||
@@ -41,12 +40,6 @@ void console_cleanup( void )
|
|||||||
|
|
||||||
inport_byte( RBR0, ignored );
|
inport_byte( RBR0, ignored );
|
||||||
|
|
||||||
/* inport_byte( RBR0, ignored );
|
|
||||||
* inport_byte( RBR0, ignored );
|
|
||||||
* inport_byte( RBR0, ignored );
|
|
||||||
* inport_byte( RBR0, ignored );
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* console_initialize
|
/* console_initialize
|
||||||
@@ -63,18 +56,29 @@ void console_cleanup( void )
|
|||||||
rtems_device_driver console_initialize(
|
rtems_device_driver console_initialize(
|
||||||
rtems_device_major_number major,
|
rtems_device_major_number major,
|
||||||
rtems_device_minor_number minor,
|
rtems_device_minor_number minor,
|
||||||
void *arg,
|
void *arg
|
||||||
rtems_id self,
|
|
||||||
rtems_unsigned32 *status
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
rtems_status_code status;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* flush the console now and at exit. Just in case.
|
* flush the console now and at exit. Just in case.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
console_cleanup();
|
console_cleanup();
|
||||||
|
|
||||||
|
status = rtems_io_register_name(
|
||||||
|
"/dev/console",
|
||||||
|
major,
|
||||||
|
(rtems_device_minor_number) 0
|
||||||
|
);
|
||||||
|
|
||||||
|
if (status != RTEMS_SUCCESSFUL)
|
||||||
|
rtems_fatal_error_occurred(status);
|
||||||
|
|
||||||
atexit( console_cleanup );
|
atexit( console_cleanup );
|
||||||
|
|
||||||
|
return RTEMS_SUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -173,48 +177,104 @@ void outbyte(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* __read -- read bytes from the serial port. Ignore fd, since
|
* Open entry point
|
||||||
* we only have stdin.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int __read(
|
rtems_device_driver console_open(
|
||||||
int fd,
|
rtems_device_major_number major,
|
||||||
char *buf,
|
rtems_device_minor_number minor,
|
||||||
int nbytes
|
void * arg
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int i = 0;
|
return RTEMS_SUCCESSFUL;
|
||||||
|
|
||||||
for (i = 0; i < nbytes; i++) {
|
|
||||||
*(buf + i) = inbyte();
|
|
||||||
if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) {
|
|
||||||
(*(buf + i++)) = '\n';
|
|
||||||
(*(buf + i)) = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* __write -- write bytes to the serial port. Ignore fd, since
|
* Close entry point
|
||||||
* stdout and stderr are the same. Since we have no filesystem,
|
|
||||||
* open will only return an error.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int __write(
|
rtems_device_driver console_close(
|
||||||
int fd,
|
rtems_device_major_number major,
|
||||||
char *buf,
|
rtems_device_minor_number minor,
|
||||||
int nbytes
|
void * arg
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int i;
|
return RTEMS_SUCCESSFUL;
|
||||||
|
}
|
||||||
for (i = 0; i < nbytes; i++) {
|
|
||||||
if (*(buf + i) == '\n') {
|
/*
|
||||||
outbyte ('\r');
|
* read bytes from the serial port. We only have stdin.
|
||||||
}
|
*/
|
||||||
outbyte (*(buf + i));
|
|
||||||
}
|
rtems_device_driver console_read(
|
||||||
return (nbytes);
|
rtems_device_major_number major,
|
||||||
|
rtems_device_minor_number minor,
|
||||||
|
void * arg
|
||||||
|
)
|
||||||
|
{
|
||||||
|
rtems_libio_rw_args_t *rw_args;
|
||||||
|
char *buffer;
|
||||||
|
int maximum;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
rw_args = (rtems_libio_rw_args_t *) arg;
|
||||||
|
|
||||||
|
buffer = rw_args->buffer;
|
||||||
|
maximum = rw_args->count;
|
||||||
|
|
||||||
|
for (count = 0; count < maximum; count++) {
|
||||||
|
buffer[ count ] = inbyte();
|
||||||
|
if (buffer[ count ] == '\n' || buffer[ count ] == '\r') {
|
||||||
|
buffer[ count++ ] = '\n';
|
||||||
|
buffer[ count ] = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rw_args->bytes_moved = count;
|
||||||
|
return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* write bytes to the serial port. Stdout and stderr are the same.
|
||||||
|
*/
|
||||||
|
|
||||||
|
rtems_device_driver console_write(
|
||||||
|
rtems_device_major_number major,
|
||||||
|
rtems_device_minor_number minor,
|
||||||
|
void * arg
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int count;
|
||||||
|
int maximum;
|
||||||
|
rtems_libio_rw_args_t *rw_args;
|
||||||
|
char *buffer;
|
||||||
|
|
||||||
|
rw_args = (rtems_libio_rw_args_t *) arg;
|
||||||
|
|
||||||
|
buffer = rw_args->buffer;
|
||||||
|
maximum = rw_args->count;
|
||||||
|
|
||||||
|
for (count = 0; count < maximum; count++) {
|
||||||
|
if ( buffer[ count ] == '\n') {
|
||||||
|
outbyte('\r');
|
||||||
|
}
|
||||||
|
outbyte( buffer[ count ] );
|
||||||
|
}
|
||||||
|
|
||||||
|
rw_args->bytes_moved = maximum;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* IO Control entry point
|
||||||
|
*/
|
||||||
|
|
||||||
|
rtems_device_driver console_control(
|
||||||
|
rtems_device_major_number major,
|
||||||
|
rtems_device_minor_number minor,
|
||||||
|
void * arg
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return RTEMS_SUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user