summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/m68k/mvme162/console/console.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1995-09-11 19:35:39 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1995-09-11 19:35:39 +0000
commit3a4ae6c210bcc37754767966f1128ae23c77b6af (patch)
tree8804983e5b92bec788d548df13db7513118d351d /c/src/lib/libbsp/m68k/mvme162/console/console.c
parentnew file -- split from inlines (diff)
downloadrtems-3a4ae6c210bcc37754767966f1128ae23c77b6af.tar.bz2
The word "RTEMS" almost completely removed from the core.
Configuration Table Template file added and all tests modified to use this. All gvar.h and conftbl.h files removed from test directories. Configuration parameter maximum_devices added. Core semaphore and mutex handlers added and RTEMS API Semaphore Manager updated to reflect this. Initialization sequence changed to invoke API specific initialization routines. Initialization tasks table now owned by RTEMS Tasks Manager. Added user extension for post-switch. Utilized user extensions to implement API specific functionality like signal dispatching. Added extensions to the System Initialization Thread so that an API can register a function to be invoked while the system is being initialized. These are largely equivalent to the pre-driver and post-driver hooks. Added the Modules file oar-go32_p5, modified oar-go32, and modified the file make/custom/go32.cfg to look at an environment varable which determines what CPU model is being used. All BSPs updated to reflect named devices and clock driver's IOCTL used by the Shared Memory Driver. Also merged clock isr into main file and removed ckisr.c where possible. Updated spsize to reflect new and moved variables. Makefiles for the executive source and include files updated to show break down of files into Core, RTEMS API, and Neither. Header and inline files installed into subdirectory based on whether logically in the Core or a part of the RTEMS API.
Diffstat (limited to 'c/src/lib/libbsp/m68k/mvme162/console/console.c')
-rw-r--r--c/src/lib/libbsp/m68k/mvme162/console/console.c158
1 files changed, 123 insertions, 35 deletions
diff --git a/c/src/lib/libbsp/m68k/mvme162/console/console.c b/c/src/lib/libbsp/m68k/mvme162/console/console.c
index 0892f5f200..72595f3bce 100644
--- a/c/src/lib/libbsp/m68k/mvme162/console/console.c
+++ b/c/src/lib/libbsp/m68k/mvme162/console/console.c
@@ -21,10 +21,9 @@
#define M162_INIT
-#include <rtems.h>
-#include "console.h"
-#include "bsp.h"
-#include "ringbuf.h"
+#include <bsp.h>
+#include <rtems/libio.h>
+#include <ringbuf.h>
Ring_buffer_t Buffer[2];
@@ -54,12 +53,11 @@ rtems_isr C_Receive_ISR(rtems_vector_number vector)
rtems_device_driver console_initialize(
rtems_device_major_number major,
rtems_device_minor_number minor,
- void *arg,
- rtems_id self,
- rtems_unsigned32 *status
+ void *arg
)
{
int i;
+ rtems_status_code status;
/*
* Initialise receiver interrupts on both ports
@@ -79,7 +77,34 @@ rtems_device_driver console_initialize(
mcchip->gen_control = 2; /* MIEN */
mcchip->SCC_int_ctl = 0x13; /* SCC IEN, IPL3 */
- *status = RTEMS_SUCCESSFUL;
+ status = rtems_io_register_name(
+ "/dev/console",
+ major,
+ (rtems_device_minor_number) 0
+ );
+
+ if (status != RTEMS_SUCCESSFUL)
+ rtems_fatal_error_occurred(status);
+
+ status = rtems_io_register_name(
+ "/dev/tty00",
+ major,
+ (rtems_device_minor_number) 0
+ );
+
+ if (status != RTEMS_SUCCESSFUL)
+ rtems_fatal_error_occurred(status);
+
+ status = rtems_io_register_name(
+ "/dev/tty01",
+ major,
+ (rtems_device_minor_number) 0
+ );
+
+ if (status != RTEMS_SUCCESSFUL)
+ rtems_fatal_error_occurred(status);
+
+ return RTEMS_SUCCESSFUL;
}
/*
@@ -100,7 +125,7 @@ rtems_boolean char_ready(int port, char *ch)
* Block on char input
*/
-char char_wait(int port)
+char inbyte(int port)
{
unsigned char tmp_char;
@@ -113,7 +138,7 @@ char char_wait(int port)
* XON/XOFF flow control.
*/
-void char_put(int port, char ch)
+void outbyte(int port, char ch)
{
while (1) {
if (ZREAD0(port) & TX_BUFFER_EMPTY) break;
@@ -122,45 +147,108 @@ void char_put(int port, char ch)
}
/*
- * Map port A (1) to stdin, stdout, and stderr.
- * Map everything else to port B (0).
+ * Open entry point
+ */
+
+rtems_device_driver console_open(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
+{
+ return RTEMS_SUCCESSFUL;
+}
+
+/*
+ * Close entry point
+ */
+
+rtems_device_driver console_close(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
+{
+ return RTEMS_SUCCESSFUL;
+}
+
+/*
+ * read bytes from the serial port. We only have stdin.
*/
-int __read(int fd, char *buf, int nbytes)
+rtems_device_driver console_read(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
{
- int i, port;
+ rtems_libio_rw_args_t *rw_args;
+ char *buffer;
+ int maximum;
+ int count = 0;
+
+ rw_args = (rtems_libio_rw_args_t *) arg;
- if ( fd <= 2 ) port = 1;
- else port = 0;
+ buffer = rw_args->buffer;
+ maximum = rw_args->count;
- for (i = 0; i < nbytes; i++) {
- *(buf + i) = char_wait(port);
- if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) {
- (*(buf + i++)) = '\n';
- (*(buf + i)) = 0;
+ if ( minor > 1 )
+ return RTEMS_INVALID_NUMBER;
+
+ for (count = 0; count < maximum; count++) {
+ buffer[ count ] = inbyte( minor );
+ if (buffer[ count ] == '\n' || buffer[ count ] == '\r') {
+ buffer[ count++ ] = '\n';
+ buffer[ count ] = 0;
break;
}
}
- return (i);
+
+ rw_args->bytes_moved = count;
+ return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED;
}
/*
- * Map port A (1) to stdin, stdout, and stderr.
- * Map everything else to port B (0).
+ * write bytes to the serial port. Stdout and stderr are the same.
*/
-int __write(int fd, char *buf, int nbytes)
+rtems_device_driver console_write(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
{
- int i, port;
-
- if ( fd <= 2 ) port = 1;
- else port = 0;
-
- for (i = 0; i < nbytes; i++) {
- if (*(buf + i) == '\n') {
- char_put (port, '\r');
+ 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;
+
+ if ( minor > 1 )
+ return RTEMS_INVALID_NUMBER;
+
+ for (count = 0; count < maximum; count++) {
+ if ( buffer[ count ] == '\n') {
+ outbyte('\r', minor );
}
- char_put (port, *(buf + i));
+ outbyte( buffer[ count ], minor );
}
- return (nbytes);
+ return maximum;
+}
+
+/*
+ * IO Control entry point
+ */
+
+rtems_device_driver console_control(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
+{
+ return RTEMS_SUCCESSFUL;
}