summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/powerpc/psim/console
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1998-04-14 19:49:13 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1998-04-14 19:49:13 +0000
commit89611889fe6e255dec90a5157a4f25c0f65057b4 (patch)
tree2facca64edc8503b3149c8157a43fb6674e4523f /c/src/lib/libbsp/powerpc/psim/console
parentChanged arc to archive. (diff)
downloadrtems-89611889fe6e255dec90a5157a4f25c0f65057b4.tar.bz2
new files
Diffstat (limited to 'c/src/lib/libbsp/powerpc/psim/console')
-rw-r--r--c/src/lib/libbsp/powerpc/psim/console/Makefile.in59
-rw-r--r--c/src/lib/libbsp/powerpc/psim/console/console.c184
-rw-r--r--c/src/lib/libbsp/powerpc/psim/console/consupp.s33
3 files changed, 276 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/powerpc/psim/console/Makefile.in b/c/src/lib/libbsp/powerpc/psim/console/Makefile.in
new file mode 100644
index 0000000000..125410e1c6
--- /dev/null
+++ b/c/src/lib/libbsp/powerpc/psim/console/Makefile.in
@@ -0,0 +1,59 @@
+#
+# $Id$
+#
+
+@SET_MAKE@
+srcdir = @srcdir@
+VPATH = @srcdir@
+RTEMS_ROOT = @top_srcdir@
+PROJECT_ROOT = @PROJECT_ROOT@
+
+PGM=${ARCH}/console.rel
+
+# C source names, if any, go here -- minus the .c
+C_PIECES=console
+C_FILES=$(C_PIECES:%=%.c)
+C_O_FILES=$(C_PIECES:%=${ARCH}/%.o)
+
+H_FILES=
+
+# Assembly source names, if any, go here -- minus the .s
+S_PIECES=consupp
+S_FILES=$(S_PIECES:%=%.s)
+S_O_FILES=$(S_FILES:%.s=${ARCH}/%.o)
+
+SRCS=$(C_FILES) $(CC_FILES) $(H_FILES) $(S_FILES)
+OBJS=$(C_O_FILES) $(CC_O_FILES) $(S_O_FILES)
+
+include $(RTEMS_ROOT)/make/custom/$(RTEMS_BSP).cfg
+include $(RTEMS_ROOT)/make/leaf.cfg
+
+#
+# (OPTIONAL) Add local stuff here using +=
+#
+
+DEFINES +=
+CPPFLAGS +=
+CFLAGS +=
+
+LD_PATHS +=
+LD_LIBS +=
+LDFLAGS +=
+
+#
+# Add your list of files to delete here. The config files
+# already know how to delete some stuff, so you may want
+# to just run 'make clean' first to see what gets missed.
+# 'make clobber' already includes 'make clean'
+#
+
+CLEAN_ADDITIONS +=
+CLOBBER_ADDITIONS +=
+
+${PGM}: ${SRCS} ${OBJS}
+ $(make-rel)
+
+all: ${ARCH} $(SRCS) $(PGM)
+
+# the .rel file built here will be put into libbsp.a by ../wrapup/Makefile
+install: all
diff --git a/c/src/lib/libbsp/powerpc/psim/console/console.c b/c/src/lib/libbsp/powerpc/psim/console/console.c
new file mode 100644
index 0000000000..a4a9e7175e
--- /dev/null
+++ b/c/src/lib/libbsp/powerpc/psim/console/console.c
@@ -0,0 +1,184 @@
+/*
+ * This file contains the hardware specific portions of the TTY driver
+ * for the serial ports on the erc32.
+ *
+ * COPYRIGHT (c) 1989-1997.
+ * On-Line Applications Research Corporation (OAR).
+ * Copyright assigned to U.S. Government, 1994.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <bsp.h>
+#include <rtems/libio.h>
+#include <stdlib.h>
+#include <assert.h>
+
+
+/*
+ * console_outbyte_polled
+ *
+ * This routine transmits a character using polling.
+ */
+
+void console_outbyte_polled(
+ int port,
+ char ch
+)
+{
+ outbyte( ch );
+}
+
+/*
+ * console_inbyte_nonblocking
+ *
+ * This routine polls for a character.
+ */
+
+int console_inbyte_nonblocking(
+ int port
+)
+{
+ char c;
+
+ c = inbyte();
+ if (!c)
+ return -1;
+ return c;
+}
+
+/*
+ * DEBUG_puts
+ *
+ * This should be safe in the event of an error. It attempts to insure
+ * that no TX empty interrupts occur while it is doing polled IO. Then
+ * it restores the state of that external interrupt.
+ *
+ * Input parameters:
+ * string - pointer to debug output string
+ *
+ * Output parameters: NONE
+ *
+ * Return values: NONE
+ */
+
+void DEBUG_puts(
+ char *string
+)
+{
+ char *s;
+
+ /* XXX should disable interrupts around this if interrupt driven */
+
+ for ( s = string ; *s ; s++ )
+ console_outbyte_polled( 0, *s );
+
+ console_outbyte_polled( 0, '\r' );
+ console_outbyte_polled( 0, '\n' );
+}
+
+
+/*
+ * Console Termios Support Entry Points
+ *
+ */
+
+int console_write_support (int minor, char *buf, int len)
+{
+ int nwrite = 0;
+
+ while (nwrite < len) {
+ console_outbyte_polled( minor, *buf++ );
+ nwrite++;
+ }
+ return nwrite;
+}
+
+/*
+ * Console Device Driver Entry Points
+ *
+ */
+
+rtems_device_driver console_initialize(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *arg
+)
+{
+ rtems_status_code status;
+
+ rtems_termios_initialize();
+
+ /*
+ * Register Device Names
+ */
+
+ status = rtems_io_register_name( "/dev/console", major, 0 );
+ if (status != RTEMS_SUCCESSFUL)
+ rtems_fatal_error_occurred(status);
+
+ return RTEMS_SUCCESSFUL;
+}
+
+rtems_device_driver console_open(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
+{
+ rtems_status_code sc;
+
+ assert( minor <= 1 );
+ if ( minor > 2 )
+ return RTEMS_INVALID_NUMBER;
+
+ sc = rtems_termios_open (major, minor, arg,
+ NULL,
+ NULL,
+ console_inbyte_nonblocking,
+ console_write_support,
+ 0);
+
+ return RTEMS_SUCCESSFUL;
+}
+
+rtems_device_driver console_close(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
+{
+ return rtems_termios_close (arg);
+}
+
+rtems_device_driver console_read(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
+{
+ return rtems_termios_read (arg);
+}
+
+rtems_device_driver console_write(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
+{
+ return rtems_termios_write (arg);
+}
+
+rtems_device_driver console_control(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
+{
+ return rtems_termios_ioctl (arg);
+}
+
diff --git a/c/src/lib/libbsp/powerpc/psim/console/consupp.s b/c/src/lib/libbsp/powerpc/psim/console/consupp.s
new file mode 100644
index 0000000000..bb9e834fc6
--- /dev/null
+++ b/c/src/lib/libbsp/powerpc/psim/console/consupp.s
@@ -0,0 +1,33 @@
+/*
+ * Adapted from the mvme-inbyte.S and mvme-outbyte.S files in libgloss.
+ * These should work on all targets using the ppcbug monitor.
+ *
+ * Copyright (c) 1995 Cygnus Support
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include "ppc-asm.h"
+
+ .file "support.s"
+ .text
+FUNC_START(outbyte)
+ li r10,0x20
+ sc
+ blr
+FUNC_END(outbyte)
+
+ .text
+FUNC_START(inbyte)
+ li r10,0x0
+ sc
+ blr
+FUNC_END(inbyte)