Index: c/src/lib/libbsp/i386/pc386/Makefile.am =================================================================== RCS file: /usr1/CVS/rtems/c/src/lib/libbsp/i386/pc386/Makefile.am,v retrieving revision 1.61 diff -u -r1.61 Makefile.am --- c/src/lib/libbsp/i386/pc386/Makefile.am 1 Aug 2011 13:41:37 -0000 1.61 +++ c/src/lib/libbsp/i386/pc386/Makefile.am 2 Nov 2011 13:36:47 -0000 @@ -68,16 +68,21 @@ 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 \ Index: c/src/lib/libbsp/i386/pc386/preinstall.am =================================================================== RCS file: /usr1/CVS/rtems/c/src/lib/libbsp/i386/pc386/preinstall.am,v retrieving revision 1.11 diff -u -r1.11 preinstall.am --- c/src/lib/libbsp/i386/pc386/preinstall.am 1 Aug 2011 13:41:37 -0000 1.11 +++ c/src/lib/libbsp/i386/pc386/preinstall.am 2 Nov 2011 13:36:47 -0000 @@ -119,6 +119,14 @@ $(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 Index: c/src/lib/libbsp/i386/pc386/console/conscfg.c =================================================================== RCS file: c/src/lib/libbsp/i386/pc386/console/conscfg.c diff -N c/src/lib/libbsp/i386/pc386/console/conscfg.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ c/src/lib/libbsp/i386/pc386/console/conscfg.c 2 Nov 2011 13:36:47 -0000 @@ -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: conscfg.c,v 1.15 2011/08/11 21:52:51 joel Exp $ + */ + +#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)); Index: c/src/lib/libbsp/i386/pc386/console/console_control.c =================================================================== RCS file: c/src/lib/libbsp/i386/pc386/console/console_control.c diff -N c/src/lib/libbsp/i386/pc386/console/console_control.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ c/src/lib/libbsp/i386/pc386/console/console_control.c 2 Nov 2011 13:36:47 -0000 @@ -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; +} Index: c/src/lib/libbsp/i386/pc386/console/printk_support.c =================================================================== RCS file: c/src/lib/libbsp/i386/pc386/console/printk_support.c diff -N c/src/lib/libbsp/i386/pc386/console/printk_support.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ c/src/lib/libbsp/i386/pc386/console/printk_support.c 2 Nov 2011 13:36:47 -0000 @@ -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: printk_support.c,v 1.2 2011/08/11 15:19:38 joel Exp $ + */ + +#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; +} + Index: c/src/lib/libbsp/i386/pc386/console/serial_mouse_config.c =================================================================== RCS file: /usr1/CVS/rtems/c/src/lib/libbsp/i386/pc386/console/serial_mouse_config.c,v retrieving revision 1.1 diff -u -r1.1 serial_mouse_config.c --- c/src/lib/libbsp/i386/pc386/console/serial_mouse_config.c 14 Mar 2011 14:57:00 -0000 1.1 +++ c/src/lib/libbsp/i386/pc386/console/serial_mouse_config.c 2 Nov 2011 13:36:47 -0000 @@ -1,12 +1,12 @@ /* - * COPYRIGHT (c) 1989-2007. + * 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: serial_mouse_config.c,v 1.1 2011/03/14 14:57:00 joel Exp $ + * $Id: serial_mouse_config.c,v 1.3 2011/08/11 15:19:38 joel Exp $ */ #include @@ -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 ); } Index: c/src/lib/libbsp/i386/pc386/console/vgacons.c =================================================================== RCS file: c/src/lib/libbsp/i386/pc386/console/vgacons.c diff -N c/src/lib/libbsp/i386/pc386/console/vgacons.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ c/src/lib/libbsp/i386/pc386/console/vgacons.c 2 Nov 2011 13:36:47 -0000 @@ -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: vgacons.c,v 1.1 2011/08/05 15:40:18 joel Exp $ + */ + +#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 */ +}; Index: c/src/lib/libbsp/i386/pc386/console/vgacons.h =================================================================== RCS file: c/src/lib/libbsp/i386/pc386/console/vgacons.h diff -N c/src/lib/libbsp/i386/pc386/console/vgacons.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ c/src/lib/libbsp/i386/pc386/console/vgacons.h 2 Nov 2011 13:36:47 -0000 @@ -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: vgacons.h,v 1.1 2011/08/05 15:40:18 joel Exp $ + */ + +#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_ */ Index: c/src/lib/libbsp/i386/pc386/include/bsp.h =================================================================== RCS file: /usr1/CVS/rtems/c/src/lib/libbsp/i386/pc386/include/bsp.h,v retrieving revision 1.48 diff -u -r1.48 bsp.h --- c/src/lib/libbsp/i386/pc386/include/bsp.h 11 Feb 2011 12:04:30 -0000 1.48 +++ c/src/lib/libbsp/i386/pc386/include/bsp.h 2 Nov 2011 13:36:47 -0000 @@ -201,6 +201,8 @@ void set_debug_traps(void); void breakpoint(void); +#define BSP_MAXIMUM_DEVICES 6 + #ifdef __cplusplus } #endif Index: c/src/lib/libbsp/i386/pc386/start/start.S =================================================================== RCS file: /usr1/CVS/rtems/c/src/lib/libbsp/i386/pc386/start/start.S,v retrieving revision 1.18 diff -u -r1.18 start.S --- c/src/lib/libbsp/i386/pc386/start/start.S 14 Jul 2011 15:07:21 -0000 1.18 +++ c/src/lib/libbsp/i386/pc386/start/start.S 2 Nov 2011 13:36:47 -0000 @@ -209,11 +209,6 @@ +---------------------------------------------------------------------*/ call checkCPUtypeSetCr0 -/*---------------------------------------------------------------------+ -| Redirect printk (and console) port if desired -+---------------------------------------------------------------------*/ - call SYM(BSP_console_select) - #ifdef __SSE__ call SYM(enable_sse) #endif Index: c/src/lib/libbsp/i386/shared/irq/irq.h =================================================================== RCS file: /usr1/CVS/rtems/c/src/lib/libbsp/i386/shared/irq/irq.h,v retrieving revision 1.17 diff -u -r1.17 irq.h --- c/src/lib/libbsp/i386/shared/irq/irq.h 14 Jul 2011 17:30:27 -0000 1.17 +++ c/src/lib/libbsp/i386/shared/irq/irq.h 2 Nov 2011 13:36:47 -0000 @@ -55,6 +55,8 @@ #define BSP_KEYBOARD 1 #define BSP_UART_COM2_IRQ 3 #define BSP_UART_COM1_IRQ 4 +#define BSP_UART_COM3_IRQ 5 +#define BSP_UART_COM4_IRQ 6 #define BSP_RT_TIMER1 8 #define BSP_RT_TIMER3 10 #define BSP_SMP_IPI 16