From 1c0b8d759fefe9323d215267363c2041a4af7558 Mon Sep 17 00:00:00 2001 From: Jennifer Averett Date: Fri, 18 Nov 2011 20:11:08 +0000 Subject: 2011-11-18 Jennifer Averett PR 1925 * Makefile.am, preinstall.am, console/serial_mouse_config.c, include/bsp.h, start/start.S: Converted 1386 console to the libchip style console * console/conscfg.c, console/console_control.c, console/printk_support.c, console/vgacons.c, console/vgacons.h: New files. --- c/src/lib/libbsp/i386/pc386/ChangeLog | 10 ++ c/src/lib/libbsp/i386/pc386/Makefile.am | 11 +- c/src/lib/libbsp/i386/pc386/console/conscfg.c | 163 +++++++++++++++++ .../libbsp/i386/pc386/console/console_control.c | 65 +++++++ .../lib/libbsp/i386/pc386/console/printk_support.c | 57 ++++++ .../i386/pc386/console/serial_mouse_config.c | 30 ++-- c/src/lib/libbsp/i386/pc386/console/vgacons.c | 200 +++++++++++++++++++++ c/src/lib/libbsp/i386/pc386/console/vgacons.h | 45 +++++ c/src/lib/libbsp/i386/pc386/include/bsp.h | 2 + c/src/lib/libbsp/i386/pc386/preinstall.am | 8 + c/src/lib/libbsp/i386/pc386/start/start.S | 5 - 11 files changed, 571 insertions(+), 25 deletions(-) create mode 100644 c/src/lib/libbsp/i386/pc386/console/conscfg.c create mode 100644 c/src/lib/libbsp/i386/pc386/console/console_control.c create mode 100644 c/src/lib/libbsp/i386/pc386/console/printk_support.c create mode 100644 c/src/lib/libbsp/i386/pc386/console/vgacons.c create mode 100644 c/src/lib/libbsp/i386/pc386/console/vgacons.h (limited to 'c') diff --git a/c/src/lib/libbsp/i386/pc386/ChangeLog b/c/src/lib/libbsp/i386/pc386/ChangeLog index 212915c9c7..ad9ce33ba1 100644 --- a/c/src/lib/libbsp/i386/pc386/ChangeLog +++ b/c/src/lib/libbsp/i386/pc386/ChangeLog @@ -1,3 +1,13 @@ +2011-11-18 Jennifer Averett + + PR 1925 + * Makefile.am, preinstall.am, console/serial_mouse_config.c, + include/bsp.h, start/start.S: Converted 1386 console to the libchip + style console + * console/conscfg.c, console/console_control.c, + console/printk_support.c, console/vgacons.c, console/vgacons.h: New + files. + 2011-10-17 Ralf Corsépius * ne2000/ne2000.c: Remove unused var "stat". diff --git a/c/src/lib/libbsp/i386/pc386/Makefile.am b/c/src/lib/libbsp/i386/pc386/Makefile.am index 1cc760e821..9a0e9423d9 100644 --- a/c/src/lib/libbsp/i386/pc386/Makefile.am +++ b/c/src/lib/libbsp/i386/pc386/Makefile.am @@ -68,16 +68,21 @@ libbsp_a_SOURCES += clock/ckinit.c clock/todcfg.c ../../shared/tod.c libbsp_a_SOURCES += ../../shared/clockdrv_shell.h include_rtemsdir = $(includedir)/rtems -include_rtems_HEADERS = console/keyboard.h console/kd.h console/ps2_drv.h +include_rtems_HEADERS = console/keyboard.h console/kd.h console/ps2_drv.h \ + ../../shared/console_private.h console/vgacons.h include_HEADERS += ../../i386/shared/comm/i386_io.h # console -libbsp_a_SOURCES += console/console.c console/inch.c console/outch.c \ +libbsp_a_SOURCES += console/inch.c console/outch.c \ console/defkeymap.c console/fb_vga.c console/keyboard.c \ console/pc_keyb.c console/ps2_mouse.c \ console/vgainit.c console/vt.c console/videoAsm.S \ console/kbd_parser.c console/serial_mouse_config.c \ - ../../i386/shared/comm/uart.c ../../i386/shared/comm/tty_drv.c + ../../i386/shared/comm/uart.c ../../i386/shared/comm/tty_drv.c \ + ../../shared/console.c ../../shared/console_select.c \ + ../../shared/console_read.c ../../shared/console_write.c \ + console/console_control.c console/conscfg.c console/printk_support.c \ + console/vgacons.c # gdb libbsp_a_SOURCES += ../../i386/shared/comm/i386-stub.c \ diff --git a/c/src/lib/libbsp/i386/pc386/console/conscfg.c b/c/src/lib/libbsp/i386/pc386/console/conscfg.c new file mode 100644 index 0000000000..fdd768fa0b --- /dev/null +++ b/c/src/lib/libbsp/i386/pc386/console/conscfg.c @@ -0,0 +1,163 @@ +/* + * This file contains the libchip configuration information + * to instantiate the libchip driver for the VGA console + * and serial ports on a PC. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#include /* write */ + +#include +#include +#include +#include "vgacons.h" +#include +#include + +#define VGA_CONSOLE_FUNCTIONS &vgacons_fns +#if 0 +#define COM_CONSOLE_FUNCTIONS &ns16550_fns_polled +#else +#define COM_CONSOLE_FUNCTIONS &ns16550_fns +#endif + +/* + * Base IO for UART + */ +#define COM1_BASE_IO 0x3F8 +#define COM2_BASE_IO 0x3E8 +#define COM3_BASE_IO 0x2F8 +#define COM4_BASE_IO 0x2E8 + +#define CLOCK_RATE (115200 * 16) + +uint8_t com_get_register(uint32_t addr,uint8_t i) +{ + register uint8_t val; + + inport_byte( (addr + i),val ); + return val; +} + +void com_set_register(uint32_t addr,uint8_t i, uint8_t val) +{ + outport_byte( (addr+i),val ); +} + +console_tbl Console_Configuration_Ports[] = { + { + "/dev/vgacons", /* sDeviceName */ + VGA_CONSOLE, /* deviceType */ + VGA_CONSOLE_FUNCTIONS, /* pDeviceFns */ + vgacons_probe, /* deviceProbe */ + NULL, /* pDeviceFlow */ + 16, /* ulMargin */ + 8, /* ulHysteresis */ + (void *) NULL, /* NULL */ /* pDeviceParams */ + 0x00000000, /* ulCtrlPort1 */ + 0x00000000, /* ulCtrlPort2 */ + 0x00000000, /* ulDataPort */ + NULL, /* getRegister */ + NULL, /* setRegister */ + NULL,/* unused */ /* getData */ + NULL,/* unused */ /* setData */ + 0X0, /* ulClock */ + 0x0 /* ulIntVector -- base for port */ + }, + { + "/dev/com1", /* sDeviceName */ + SERIAL_NS16550, /* deviceType */ + COM_CONSOLE_FUNCTIONS, /* pDeviceFns */ + NULL, /* deviceProbe, assume it is there */ + NULL, /* pDeviceFlow */ + 16, /* ulMargin */ + 8, /* ulHysteresis */ + (void *) 9600, /* Baud Rate */ /* pDeviceParams */ + COM1_BASE_IO, /* ulCtrlPort1 */ + 0x00000000, /* ulCtrlPort2 */ + COM1_BASE_IO, /* ulDataPort */ + com_get_register, /* getRegister */ + com_set_register, /* setRegister */ + NULL,/* unused */ /* getData */ + NULL,/* unused */ /* setData */ + CLOCK_RATE, /* ulClock */ + BSP_UART_COM1_IRQ /* ulIntVector -- base for port */ + }, + { + "/dev/com2", /* sDeviceName */ + SERIAL_NS16550, /* deviceType */ + COM_CONSOLE_FUNCTIONS, /* pDeviceFns */ + NULL, /* deviceProbe, assume it is there */ + NULL, /* pDeviceFlow */ + 16, /* ulMargin */ + 8, /* ulHysteresis */ + (void *) 9600, /* Baud Rate */ /* pDeviceParams */ + COM2_BASE_IO, /* ulCtrlPort1 */ + 0x00000000, /* ulCtrlPort2 */ + COM2_BASE_IO, /* ulDataPort */ + com_get_register, /* getRegister */ + com_set_register, /* setRegister */ + NULL,/* unused */ /* getData */ + NULL,/* unused */ /* setData */ + CLOCK_RATE, /* ulClock */ + BSP_UART_COM2_IRQ /* ulIntVector -- base for port */ + }, + + { + "/dev/com3", /* sDeviceName */ + SERIAL_NS16550, /* deviceType */ + COM_CONSOLE_FUNCTIONS, /* pDeviceFns */ + NULL, /* deviceProbe, assume it is there */ + NULL, /* pDeviceFlow */ + 16, /* ulMargin */ + 8, /* ulHysteresis */ + (void *) 9600, /* Baud Rate */ /* pDeviceParams */ + COM3_BASE_IO, /* ulCtrlPort1 */ + 0x00000000, /* ulCtrlPort2 */ + COM3_BASE_IO, /* ulDataPort */ + com_get_register, /* getRegister */ + com_set_register, /* setRegister */ + NULL,/* unused */ /* getData */ + NULL,/* unused */ /* setData */ + CLOCK_RATE, /* ulClock */ + BSP_UART_COM3_IRQ /* ulIntVector -- base for port */ + }, + + { + "/dev/com4", /* sDeviceName */ + SERIAL_NS16550, /* deviceType */ + COM_CONSOLE_FUNCTIONS, /* pDeviceFns */ + NULL, /* deviceProbe, assume it is there */ + NULL, /* pDeviceFlow */ + 16, /* ulMargin */ + 8, /* ulHysteresis */ + (void *) 9600, /* Baud Rate */ /* pDeviceParams */ + COM4_BASE_IO, /* ulCtrlPort1 */ + 0x00000000, /* ulCtrlPort2 */ + COM4_BASE_IO, /* ulDataPort */ + com_get_register, /* getRegister */ + com_set_register, /* setRegister */ + NULL,/* unused */ /* getData */ + NULL,/* unused */ /* setData */ + CLOCK_RATE, /* ulClock */ + BSP_UART_COM4_IRQ /* ulIntVector -- base for port */ + }, + +}; + +/* + * Define a variable that contains the number of statically configured + * console devices. + */ +unsigned long Console_Configuration_Count = \ + (sizeof(Console_Configuration_Ports)/sizeof(console_tbl)); diff --git a/c/src/lib/libbsp/i386/pc386/console/console_control.c b/c/src/lib/libbsp/i386/pc386/console/console_control.c new file mode 100644 index 0000000000..ea765744b1 --- /dev/null +++ b/c/src/lib/libbsp/i386/pc386/console/console_control.c @@ -0,0 +1,65 @@ +/* + * This file is an extension of the generic console driver + * shell used by all console drivers using libchip, it contains + * the console_control routine, This bsp needs its own version + * of this method to handle the keyboard and mouse as a single + * device. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include "keyboard.h" +#include "../../../shared/console_private.h" + +/* + * console_control + * + * this routine uses the termios driver to process io + */ +rtems_device_driver console_control( + rtems_device_major_number major, + rtems_device_minor_number minor, + void * arg +) +{ + rtems_libio_ioctl_args_t *args = arg; + + switch (args->command) { + default: + if( vt_ioctl( args->command, (unsigned long)args->buffer ) != 0 ) + return rtems_termios_ioctl (arg); + break; + + case MW_UID_REGISTER_DEVICE: + printk( "SerialMouse: reg=%s\n", args->buffer ); + register_kbd_msg_queue( args->buffer, 0 ); + break; + + case MW_UID_UNREGISTER_DEVICE: + unregister_kbd_msg_queue( 0 ); + break; + } + + args->ioctl_return = 0; + return RTEMS_SUCCESSFUL; +} diff --git a/c/src/lib/libbsp/i386/pc386/console/printk_support.c b/c/src/lib/libbsp/i386/pc386/console/printk_support.c new file mode 100644 index 0000000000..4e478ebaa5 --- /dev/null +++ b/c/src/lib/libbsp/i386/pc386/console/printk_support.c @@ -0,0 +1,57 @@ +/* + * This file contains a stub for the required printk support. + * It is NOT functional!!! + * + * This driver uses the termios pseudo driver. + */ + +/* + * COPYRIGHT (c) 1989-2007. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#include +#include +#include +#include +#include +#include + +BSP_output_char_function_type BSP_output_char = _IBMPC_outch; +BSP_polling_getchar_function_type BSP_poll_char = BSP_wait_polled_input; + +rtems_device_minor_number BSPPrintkPort = 0; + +int ns16550_inbyte_nonblocking_polled( + int minor +); + +void BSP_com_outch(char ch) +{ + console_tbl *cptr; + + cptr = &Console_Configuration_Ports[BSPPrintkPort]; + + return cptr->pDeviceFns->deviceWritePolled( BSPPrintkPort, ch ); +} + +int BSP_com_inch( void ) +{ + int result; + console_tbl *cptr; + + cptr = &Console_Configuration_Ports[BSPPrintkPort]; + + do { + result = ns16550_inbyte_nonblocking_polled( BSPPrintkPort ); + } while (result == -1); + + return result; +} + diff --git a/c/src/lib/libbsp/i386/pc386/console/serial_mouse_config.c b/c/src/lib/libbsp/i386/pc386/console/serial_mouse_config.c index 31dc65f594..fb08bafc9a 100644 --- a/c/src/lib/libbsp/i386/pc386/console/serial_mouse_config.c +++ b/c/src/lib/libbsp/i386/pc386/console/serial_mouse_config.c @@ -1,5 +1,5 @@ /* - * COPYRIGHT (c) 1989-2007. + * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -16,35 +16,31 @@ #include #include +#include "libchip/serial.h" +#include "../../../shared/console_private.h" + /* select which serial port the mouse is connected to */ -/* XXX - Hook these somewhere */ -#ifdef SERIAL_MOUSE_COM1 - #define SERIAL_MOUSE_COM 1 -#elif defined(SERIAL_MOUSE_COM2) - #define SERIAL_MOUSE_COM 2 +#if defined(SERIAL_MOUSE_COM2) + #define MOUSE_DEVICE "/dev/com2" #else - /* Select Default to be COM1 */ - #define SERIAL_MOUSE_COM 1 + #define MOUSE_DEVICE "/dev/com1" #endif -extern int BSPConsolePort; +static const char *SerialMouseDevice = MOUSE_DEVICE; bool bsp_get_serial_mouse_device( const char **name, const char **type ) { - #ifdef SERIAL_MOUSE_COM2 - *name = "/dev/ttyS2"; - #else - *name = "/dev/ttyS1"; - #endif - + const char *consname; + + *name = SerialMouseDevice; *type = "ms"; /* Check if this port is not been used as console */ - /* XXX configure the serial port, take boot args additionally */ - if ( BSPConsolePort == SERIAL_MOUSE_COM ) { + consname = Console_Port_Tbl[ Console_Port_Minor ]->sDeviceName; + if ( !strcmp(MOUSE_DEVICE, consname) ) { printk( "SERIAL MOUSE: port selected as console.(%s)\n", *name ); rtems_fatal_error_occurred( -1 ); } diff --git a/c/src/lib/libbsp/i386/pc386/console/vgacons.c b/c/src/lib/libbsp/i386/pc386/console/vgacons.c new file mode 100644 index 0000000000..c613f34c82 --- /dev/null +++ b/c/src/lib/libbsp/i386/pc386/console/vgacons.c @@ -0,0 +1,200 @@ +/* + * This file contains the termios TTY driver for the i386 + * vga. + * + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static int isr_is_on(const rtems_irq_connect_data *irq) +{ + return BSP_irq_enabled_at_i8259s(irq->name); +} + +static rtems_irq_connect_data keyboard_isr_data = { + BSP_KEYBOARD, + keyboard_interrupt, + 0, + NULL, + NULL, + isr_is_on +}; + +/* + * vgacons_init + * + * This function initializes the VGA console to a quiecsent state. + */ +VGACONS_STATIC void vgacons_init(int minor) +{ + /* + * Note: We do not initialize the KBD interface here since + * it was initialized regardless of whether the + * vga is available or not. Therefore it is initialized + * in bsp_start. + */ +} + +/* + * vgacons_open + * + * This function opens a port for communication. + * + * Default state is 9600 baud, 8 bits, No parity, and 1 stop bit. + */ +VGACONS_STATIC int vgacons_open( + int major, + int minor, + void *arg +) +{ + return RTEMS_SUCCESSFUL; +} + +/* + * vgacons_close + * + * This function shuts down the requested port. + */ +VGACONS_STATIC int vgacons_close( + int major, + int minor, + void *arg +) +{ + return(RTEMS_SUCCESSFUL); +} + +/* + * vgacons_write_polled + * + * This routine polls out the requested character. + */ +VGACONS_STATIC void vgacons_write_polled( + int minor, + char c +) +{ + _IBMPC_outch( c ); + if( c == '\n') + _IBMPC_outch( '\r' ); /* LF = LF + CR */ +} + +/* + * vgacons_write_support_polled + * + * Console Termios output entry point when using polled output. + * + */ +VGACONS_STATIC ssize_t vgacons_write_support_polled( + int minor, + const char *buf, + size_t len +) +{ + int nwrite = 0; + + /* + * poll each byte in the string out of the port. + */ + while (nwrite < len) { + vgacons_write_polled(minor, *buf++); + nwrite++; + } + + /* + * return the number of bytes written. + */ + return nwrite; +} + +/* + * vgacons_inbyte_nonblocking_polled + * + * Console Termios polling input entry point. + */ +VGACONS_STATIC int vgacons_inbyte_nonblocking_polled( + int minor +) +{ + if( rtems_kbpoll() ) { + int c = getch(); + return c; + } + + return -1; +} + +/* + * vgacons_set_attributes + * + * This function sets the UART channel to reflect the requested termios + * port settings. + */ +VGACONS_STATIC int vgacons_set_attributes( + int minor, + const struct termios *t +) +{ + return 0; +} + +bool vgacons_probe( + int minor +) +{ + int status; + static bool firstTime = true; + + if ((*(unsigned char*) NB_MAX_ROW_ADDR == 0) && + (*(unsigned short*)NB_MAX_COL_ADDR == 0)) { + return false; + } + + /* + * If there is a video card, let's assume there is also a keyboard. + * The means that we need the ISR installed in case someone wants to + * use the Keyboard or PS2 Mouse. With Microwindows, the console + * can be COM1 and you can still use the mouse/VGA for graphics. + */ + if ( firstTime ) { + status = BSP_install_rtems_irq_handler(&keyboard_isr_data); + if (!status) { + printk("Error installing keyboard interrupt handler!\n"); + rtems_fatal_error_occurred(status); + } + } + firstTime = false; + + return true; +} + +console_fns vgacons_fns = +{ + libchip_serial_default_probe, /* deviceProbe */ + vgacons_open, /* deviceFirstOpen */ + vgacons_close, /* deviceLastClose */ + vgacons_inbyte_nonblocking_polled, /* deviceRead */ + vgacons_write_support_polled, /* deviceWrite */ + vgacons_init, /* deviceInitialize */ + vgacons_write_polled, /* deviceWritePolled */ + vgacons_set_attributes, /* deviceSetAttributes */ + FALSE, /* deviceOutputUsesInterrupts */ +}; diff --git a/c/src/lib/libbsp/i386/pc386/console/vgacons.h b/c/src/lib/libbsp/i386/pc386/console/vgacons.h new file mode 100644 index 0000000000..cd3a92f761 --- /dev/null +++ b/c/src/lib/libbsp/i386/pc386/console/vgacons.h @@ -0,0 +1,45 @@ +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _VGACONS_H_ +#define _VGACONS_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define VGACONS_STATIC + +/* + * This is the ASCII for "PC" in the upper word and 0386 + * in the lower which should be unique enough to + * distinguish this type of serial device from others. + */ + +#define VGA_CONSOLE 0x80670386 + +#define VGACONS_UART0 0 +#define VGACONS_UART1 1 + +bool vgacons_probe( int minor ); + +/* + * Driver function table + */ +extern console_fns vgacons_fns; + +#ifdef __cplusplus +} +#endif + +#endif /* _VGACONS_H_ */ diff --git a/c/src/lib/libbsp/i386/pc386/include/bsp.h b/c/src/lib/libbsp/i386/pc386/include/bsp.h index 65cb7003fd..8d8223da63 100644 --- a/c/src/lib/libbsp/i386/pc386/include/bsp.h +++ b/c/src/lib/libbsp/i386/pc386/include/bsp.h @@ -201,6 +201,8 @@ void i386_stub_glue_init_breakin(void); void set_debug_traps(void); void breakpoint(void); +#define BSP_MAXIMUM_DEVICES 6 + #ifdef __cplusplus } #endif diff --git a/c/src/lib/libbsp/i386/pc386/preinstall.am b/c/src/lib/libbsp/i386/pc386/preinstall.am index e90004b512..9a2cbc0ffc 100644 --- a/c/src/lib/libbsp/i386/pc386/preinstall.am +++ b/c/src/lib/libbsp/i386/pc386/preinstall.am @@ -119,6 +119,14 @@ $(PROJECT_INCLUDE)/rtems/ps2_drv.h: console/ps2_drv.h $(PROJECT_INCLUDE)/rtems/$ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/ps2_drv.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/ps2_drv.h +$(PROJECT_INCLUDE)/rtems/console_private.h: ../../shared/console_private.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) + $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/console_private.h +PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/console_private.h + +$(PROJECT_INCLUDE)/rtems/vgacons.h: console/vgacons.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) + $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/vgacons.h +PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/vgacons.h + $(PROJECT_INCLUDE)/i386_io.h: ../../i386/shared/comm/i386_io.h $(PROJECT_INCLUDE)/$(dirstamp) $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/i386_io.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/i386_io.h diff --git a/c/src/lib/libbsp/i386/pc386/start/start.S b/c/src/lib/libbsp/i386/pc386/start/start.S index 8d4a5d6ca7..e6a14be6de 100644 --- a/c/src/lib/libbsp/i386/pc386/start/start.S +++ b/c/src/lib/libbsp/i386/pc386/start/start.S @@ -209,11 +209,6 @@ SYM (zero_bss): +---------------------------------------------------------------------*/ call checkCPUtypeSetCr0 -/*---------------------------------------------------------------------+ -| Redirect printk (and console) port if desired -+---------------------------------------------------------------------*/ - call SYM(BSP_console_select) - #ifdef __SSE__ call SYM(enable_sse) #endif -- cgit v1.2.3