Changeset 3cbb63a in rtems
- Timestamp:
- 08/30/00 08:15:30 (23 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- b459526
- Parents:
- fe602cf
- Location:
- c/src/lib/libbsp/i386/pc386
- Files:
-
- 17 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libbsp/i386/pc386/ChangeLog
rfe602cf r3cbb63a 1 2000-08-26 Rosimildo da Silva <rdasilva@connecttel.com> 2 3 * Major rework of the "/dev/console" driver. 4 * Added termios support for stdin ( keyboard ). 5 * Added ioctls() to support modes similar to Linux( XLATE, 6 RAW, MEDIUMRAW ). 7 * Added Keyboard mapping and handling of the keyboard's leds. 8 * Added Micro FrameBuffer driver ( "/dev/fb0" ) for bare VGA 9 controller ( 16 colors ). 10 * Added PS/2 and Serial mouse support for PC386 BSP. 11 * console/defkeymap.c: New file. 12 * console/fb_vga.c: New file. 13 * console/fb_vga.h: New file. 14 * console/i386kbd.h: New file. 15 * console/kd.h: New file. 16 * console/keyboard.c: New file. 17 * console/keyboard.h: New file. 18 * console/mouse_parser.c: New file. 19 * console/mouse_parser.h: New file. 20 * console/pc_keyb.c: New file. 21 * console/ps2_drv.h: New file. 22 * console/ps2_mouse.c: New file. 23 * console/ps2_mouse.h: New file. 24 * console/serial_mouse.c: New file. 25 * console/serial_mouse.h: New file. 26 * console/vgainit.c: New file. 27 * console/vt.c: New file. 28 * console/Makefile.am: Reflect new files. 29 * console/console.c, console/inch.c, console/outch.c: Console 30 functionality modifications. 31 * startup/Makefile.am: Pick up tty_drv.c and gdb_glue.c 32 1 33 2000-08-10 Joel Sherrill <joel@OARcorp.com> 2 34 -
c/src/lib/libbsp/i386/pc386/console/Makefile.am
rfe602cf r3cbb63a 9 9 PGM = $(ARCH)/console.rel 10 10 11 C_FILES = console.c inch.c outch.c 11 RTEMS_H_FILES = keyboard.h kd.h serial_mouse.h ps2_drv.h fb_vga.h 12 13 C_FILES = console.c inch.c outch.c defkeymap.c fb_vga.c keyboard.c \ 14 mouse_parser.c pc_keyb.c ps2_mouse.c serial_mouse.c vgainit.c vt.c 12 15 S_FILES = videoAsm.S 13 16 … … 16 19 include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg 17 20 include $(top_srcdir)/../../../../../../automake/lib.am 21 22 23 PREINSTALL_FILES = $(PROJECT_INCLUDE) \ 24 $(RTEMS_H_FILES:%.h=$(PROJECT_INCLUDE)/rtems/%.h) 18 25 19 26 # … … 24 31 $(make-rel) 25 32 33 $(PROJECT_INCLUDE)/rtems: 34 $(mkinstalldirs) $@ 35 36 $(PROJECT_INCLUDE)/rtems/%.h: %.h 37 $(INSTALL_DATA) $< $@ 38 26 39 # the .rel file built here will be put into libbsp.a by 27 40 # ../wrapup/Makefile 28 41 29 all-local: $( ARCH) $(console_rel_OBJECTS) $(PGM)42 all-local: $(PREINSTALL_FILES) $(ARCH) $(console_rel_OBJECTS) $(PGM) 30 43 31 44 .PRECIOUS: $(PGM) 32 45 33 EXTRA_DIST = console.c inch.c outch.c videoAsm.S46 EXTRA_DIST = $(C_FILES) $(RTEMS_H_FILES) $(S_FILES) 34 47 35 48 include $(top_srcdir)/../../../../../../automake/local.am -
c/src/lib/libbsp/i386/pc386/console/console.c
rfe602cf r3cbb63a 45 45 #include <libcpu/cpuModel.h> 46 46 47 #include <rtems/mw_uid.h> 48 #include "mouse_parser.h" 49 47 50 /* 48 51 * Possible value for console input/output : … … 66 69 67 70 extern BSP_polling_getchar_function_type BSP_poll_char; 71 extern int getch( void ); 72 extern void kbd_init( void ); 68 73 69 74 /*-------------------------------------------------------------------------+ 70 75 | External Prototypes 71 76 +--------------------------------------------------------------------------*/ 72 extern void _IBMPC_keyboard_isr(void); 73 extern rtems_boolean _IBMPC_scankey(char *); /* defined in 'inch.c' */ 77 extern void keyboard_interrupt(void); 74 78 extern char BSP_wait_polled_input(void); 75 79 extern void _IBMPC_initVideo(void); … … 80 84 static int isr_is_on(const rtems_irq_connect_data *); 81 85 86 extern int rtems_kbpoll( void ); 82 87 83 88 static rtems_irq_connect_data console_isr_data = {BSP_KEYBOARD, 84 _IBMPC_keyboard_isr,89 keyboard_interrupt, 85 90 isr_on, 86 91 isr_off, … … 104 109 return BSP_irq_enabled_at_i8259s(irq->name); 105 110 } 111 112 extern char _IBMPC_inch(void); 113 extern int rtems_kbpoll( void ); 114 115 static int 116 ibmpc_console_write(int minor, const char *buf, int len) 117 { 118 int count; 119 for (count = 0; count < len; count++) 120 { 121 _IBMPC_outch( buf[ count ] ); 122 if( buf[ count ] == '\n') 123 _IBMPC_outch( '\r' ); /* LF = LF + CR */ 124 } 125 return 0; 126 } 127 128 129 int kbd_poll_read( int minor ) 130 { 131 if( rtems_kbpoll() ) 132 { 133 int c = getch(); 134 return c; 135 } 136 return -1; 137 } 138 139 /* 140 static void* termios_ttyp_console = NULL; 141 void enq_key( char key ) 142 { 143 if( termios_ttyp_console ) 144 { 145 rtems_termios_enqueue_raw_characters(termios_ttyp_console, &key,1 ); 146 } 147 } 148 */ 106 149 107 150 void __assert (const char *file, int line, const char *msg) … … 145 188 rtems_status_code status; 146 189 190 191 /* Initialize the KBD interface */ 192 kbd_init(); 193 194 /* 195 * Set up TERMIOS 196 */ 197 rtems_termios_initialize (); 198 147 199 /* 148 200 * The video was initialized in the start.s code and does not need … … 150 202 */ 151 203 152 153 204 if(BSPConsolePort == BSP_CONSOLE_PORT_CONSOLE) 154 205 { … … 156 207 status = BSP_install_rtems_irq_handler(&console_isr_data); 157 208 158 209 if (!status) 159 210 { 160 211 printk("Error installing keyboard interrupt handler!\n"); … … 173 224 { 174 225 /* 175 * Set up TERMIOS176 */177 rtems_termios_initialize ();178 179 /*180 226 * Do device-specific initialization 181 227 */ 182 183 228 /* 9600-8-N-1 */ 184 229 BSP_uart_init(BSPConsolePort, 9600, 0); … … 187 232 /* Set interrupt handler */ 188 233 if(BSPConsolePort == BSP_UART_COM1) 189 {190 console_isr_data.name = BSP_UART_COM1_IRQ;191 234 { 235 console_isr_data.name = BSP_UART_COM1_IRQ; 236 console_isr_data.hdl = BSP_uart_termios_isr_com1; 192 237 193 }238 } 194 239 else 195 {240 { 196 241 assert(BSPConsolePort == BSP_UART_COM2); 197 console_isr_data.name = BSP_UART_COM2_IRQ; 198 console_isr_data.hdl = BSP_uart_termios_isr_com2; 199 } 200 242 console_isr_data.name = BSP_UART_COM2_IRQ; 243 console_isr_data.hdl = BSP_uart_termios_isr_com2; 244 } 201 245 status = BSP_install_rtems_irq_handler(&console_isr_data); 202 246 … … 270 314 NULL, /* firstOpen */ 271 315 console_last_close, /* lastClose */ 272 NULL, 316 NULL, /* pollRead */ 273 317 BSP_uart_termios_write_com1, /* write */ 274 318 conSetAttr, /* setAttributes */ … … 280 324 if(BSPConsolePort == BSP_CONSOLE_PORT_CONSOLE) 281 325 { 326 327 /* Let's set the routines for termios to poll the 328 * Kbd queue for data 329 */ 330 cb.pollRead = kbd_poll_read; 331 cb.outputUsesInterrupts = 0; 332 /* write the "echo" if it is on */ 333 cb.write = ibmpc_console_write; 334 335 cb.setAttributes = NULL; 282 336 ++console_open_count; 283 return RTEMS_SUCCESSFUL; 337 status = rtems_termios_open (major, minor, arg, &cb); 338 if(status != RTEMS_SUCCESSFUL) 339 { 340 printk("Error openning console device\n"); 341 } 342 return status; 284 343 } 285 344 … … 317 376 void *arg) 318 377 { 319 rtems_device_driver res = RTEMS_SUCCESSFUL; 320 321 if(BSPConsolePort != BSP_CONSOLE_PORT_CONSOLE) 322 { 323 res = rtems_termios_close (arg); 324 } 325 else { 326 if (--console_open_count == 0) { 327 console_last_close(major, minor, arg); 328 } 329 } 330 331 return res; 378 return rtems_termios_close (arg); 332 379 } /* console_close */ 333 380 … … 343 390 void *arg) 344 391 { 345 rtems_libio_rw_args_t *rw_args = (rtems_libio_rw_args_t *)arg; 346 char *buffer = rw_args->buffer; 347 int count, maximum = rw_args->count; 348 349 if(BSPConsolePort != BSP_CONSOLE_PORT_CONSOLE) 350 { 351 return rtems_termios_read (arg); 352 } 353 354 for (count = 0; count < maximum; count++) 355 { 356 /* Get character */ 357 buffer[count] = _IBMPC_inch_sleep(); 358 359 /* Echo character to screen */ 360 _IBMPC_outch(buffer[count]); 361 if (buffer[count] == '\r') 362 { 363 _IBMPC_outch('\n'); /* CR = CR + LF */ 364 } 365 366 if (buffer[count] == '\n' || buffer[count] == '\r') 367 { 368 /* What if this goes past the end of the buffer? We're hosed. [bhc] */ 369 buffer[count++] = '\n'; 370 buffer[count] = '\0'; 371 break; 372 } 373 } 374 375 rw_args->bytes_moved = count; 376 return ((count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED); 392 return rtems_termios_read( arg ); 377 393 } /* console_read */ 378 394 … … 390 406 rtems_libio_rw_args_t *rw_args = (rtems_libio_rw_args_t *)arg; 391 407 char *buffer = rw_args->buffer; 392 int count,maximum = rw_args->count;408 int maximum = rw_args->count; 393 409 394 410 if(BSPConsolePort != BSP_CONSOLE_PORT_CONSOLE) … … 397 413 } 398 414 399 for (count = 0; count < maximum; count++) 400 { 401 _IBMPC_outch(buffer[count]); 402 if (buffer[count] == '\n') 403 _IBMPC_outch('\r'); /* LF = LF + CR */ 404 } 405 415 /* write data to VGA */ 416 ibmpc_console_write( minor, buffer, maximum ); 406 417 rw_args->bytes_moved = maximum; 407 418 return RTEMS_SUCCESSFUL; … … 409 420 410 421 422 extern int vt_ioctl( unsigned int cmd, unsigned long arg); 411 423 412 424 /* … … 419 431 ) 420 432 { 421 if(BSPConsolePort != BSP_CONSOLE_PORT_CONSOLE) 422 { 423 return rtems_termios_ioctl (arg); 424 } 425 426 return RTEMS_SUCCESSFUL; 433 rtems_libio_ioctl_args_t *args = arg; 434 switch (args->command) 435 { 436 default: 437 if( vt_ioctl( args->command, (unsigned long)args->buffer ) != 0 ) 438 return rtems_termios_ioctl (arg); 439 break; 440 441 case MW_UID_REGISTER_DEVICE: 442 printk( "SerialMouse: reg=%s\n", args->buffer ); 443 register_kbd_msg_queue( args->buffer, 0 ); 444 break; 445 446 case MW_UID_UNREGISTER_DEVICE: 447 unregister_kbd_msg_queue( 0 ); 448 break; 449 } 450 args->ioctl_return = 0; 451 return RTEMS_SUCCESSFUL; 427 452 } 428 453 -
c/src/lib/libbsp/i386/pc386/console/inch.c
rfe602cf r3cbb63a 19 19 | With the following copyright notice: 20 20 | ************************************************************************** 21 | * COPYRIGHT (c) 1989-199 9.21 | * COPYRIGHT (c) 1989-1998. 22 22 | * On-Line Applications Research Corporation (OAR). 23 | * Copyright assigned to U.S. Government, 1994. 23 24 | * 24 25 | * The license and distribution terms for this file may be … … 36 37 | Constants 37 38 +--------------------------------------------------------------------------*/ 38 #define KBD_CTL 0x61 /* -------------------------------- */ 39 #define KBD_DATA 0x60 /* Ports for PC keyboard controller */ 40 #define KBD_STATUS 0x64 /* -------------------------------- */ 39 #define KBD_BUF_SIZE 256 41 40 42 #define KBD_BUF_SIZE 256 43 44 /*-------------------------------------------------------------------------+ 45 | Global Variables 46 +--------------------------------------------------------------------------*/ 47 static char key_map[] = 48 { 49 0,033,'1','2','3','4','5','6','7','8','9','0','-','=','\b','\t', 50 'q','w','e','r','t','y','u','i','o','p','[',']',015,0x80, 51 'a','s','d','f','g','h','j','k','l',';',047,0140,0x80, 52 0134,'z','x','c','v','b','n','m',',','.','/',0x80, 53 '*',0x80,' ',0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 54 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 55 0x80,0x80,0x80,'0',0177 56 }; /* Keyboard scancode -> character map with no modifiers. */ 57 58 static char shift_map[] = 59 { 60 0,033,'!','@','#','$','%','^','&','*','(',')','_','+','\b','\t', 61 'Q','W','E','R','T','Y','U','I','O','P','{','}',015,0x80, 62 'A','S','D','F','G','H','J','K','L',':',042,'~',0x80, 63 '|','Z','X','C','V','B','N','M','<','>','?',0x80, 64 '*',0x80,' ',0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 65 0x80,0x80,0x80,0x80,'7','8','9',0x80,'4','5','6',0x80, 66 '1','2','3','0',177 67 }; /* Keyboard scancode -> character map with SHIFT key modifier. */ 68 69 static char kbd_buffer[KBD_BUF_SIZE]; 41 static unsigned short kbd_buffer[KBD_BUF_SIZE]; 70 42 static rtems_unsigned16 kbd_first = 0; 71 43 static rtems_unsigned16 kbd_last = 0; … … 85 57 } /* rtemsReboot */ 86 58 87 /*-------------------------------------------------------------------------+88 | Function: _IBMPC_scankey89 | Description: This function can be called during a poll for input, or by90 | an ISR. Basically any time you want to process a keypress.91 | Global Variables: key_map, shift_map.92 | Arguments: outChar - character read in case of a valid reading,93 | otherwise unchanged.94 | Returns: TRUE in case a valid character has been read,95 | FALSE otherwise.96 +--------------------------------------------------------------------------*/97 rtems_boolean98 _IBMPC_scankey(char *outChar)99 {100 unsigned char inChar;101 static int alt_pressed = 0;102 static int ctrl_pressed = 0;103 static int shift_pressed = 0;104 static int caps_pressed = 0;105 static int extended = 0;106 107 *outChar = NULL; /* default value if we return FALSE */108 109 /* Read keyboard controller, toggle enable */110 inport_byte(KBD_CTL, inChar);111 outport_byte(KBD_CTL, inChar & ~0x80);112 outport_byte(KBD_CTL, inChar | 0x80);113 outport_byte(KBD_CTL, inChar & ~0x80);114 115 /* See if it has data */116 inport_byte(KBD_STATUS, inChar);117 if ((inChar & 0x01) == 0)118 return FALSE;119 120 /* Read the data. Handle nonsense with shift, control, etc. */121 inport_byte(KBD_DATA, inChar);122 123 if (extended)124 extended--;125 126 switch (inChar)127 {128 case 0xe0:129 extended = 2;130 return FALSE;131 break;132 133 case 0x38:134 alt_pressed = 1;135 return FALSE;136 break;137 case 0xb8:138 alt_pressed = 0;139 return FALSE;140 break;141 142 case 0x1d:143 ctrl_pressed = 1;144 return FALSE;145 break;146 case 0x9d:147 ctrl_pressed = 0;148 return FALSE;149 break;150 151 case 0x2a:152 if (extended)153 return FALSE;154 case 0x36:155 shift_pressed = 1;156 return FALSE;157 break;158 case 0xaa:159 if (extended)160 return FALSE;161 case 0xb6:162 shift_pressed = 0;163 return FALSE;164 break;165 166 case 0x3a:167 caps_pressed = 1;168 return FALSE;169 break;170 case 0xba:171 caps_pressed = 0;172 return FALSE;173 break;174 175 case 0x53:176 if (ctrl_pressed && alt_pressed)177 rtemsReboot(); /* ctrl+alt+del -> reboot */178 break;179 180 /*181 * Ignore unrecognized keys--usually arrow and such182 */183 default:184 if ((inChar & 0x80) || (inChar > 0x39))185 /* High-bit on means key is being released, not pressed */186 return FALSE;187 break;188 } /* switch */189 190 /* Strip high bit, look up in our map */191 inChar &= 0x7f;192 if (ctrl_pressed)193 {194 *outChar = key_map[inChar];195 *outChar &= 037;196 }197 else198 {199 *outChar = shift_pressed ? shift_map[inChar] : key_map[inChar];200 if (caps_pressed)201 {202 if (*outChar >= 'A' && *outChar <= 'Z')203 *outChar += 'a' - 'A';204 else if (*outChar >= 'a' && *outChar <= 'z')205 *outChar -= 'a' - 'A';206 }207 }208 209 return TRUE;210 } /* _IBMPC_scankey */211 212 /*-------------------------------------------------------------------------+213 | Function: _IBMPC_keyboard_isr214 | Description: Interrupt Service Routine for keyboard (0x01) IRQ.215 | Global Variables: kbd_buffer, kbd_first, kbd_last.216 | Arguments: vector - standard RTEMS argument - see documentation.217 | Returns: standard return value - see documentation.218 +--------------------------------------------------------------------------*/219 void _IBMPC_keyboard_isr()220 {221 if (_IBMPC_scankey(&kbd_buffer[kbd_last]))222 {223 /* Got one; save it if there is enough room in buffer. */224 unsigned int next = (kbd_last == kbd_end) ? 0 : kbd_last + 1;225 226 if (next != kbd_first)227 {228 kbd_last = next;229 }230 }231 } /* _IBMPC_keyboard_isr */232 59 233 60 234 /*-------------------------------------------------------------------------+ 235 | Function: _IBMPC_chrdy 236 | Description: Check keyboard ISR buffer and return character if not empty. 237 | Global Variables: kbd_buffer, kbd_first, kbd_last. 238 | Arguments: c - character read if keyboard buffer not empty, otherwise 239 | unchanged. 240 | Returns: TRUE if keyboard buffer not empty, FALSE otherwise. 241 +--------------------------------------------------------------------------*/ 242 rtems_boolean 243 _IBMPC_chrdy(char *c) 61 #define disable __asm__ __volatile__("cli") 62 #define enable __asm__ __volatile__("sti"); 63 /* 64 * Check if a key has been pressed. This is a non-destructive 65 * call, meaning, it keeps the key in the buffer. 66 */ 67 int rtems_kbpoll( void ) 244 68 { 245 /* FIX ME!!! It doesn't work without something like the following line. 246 Find out why! */ 247 printk(""); 69 int rc; 70 disable; 71 rc = ( kbd_first != kbd_last ) ? TRUE : FALSE; 72 enable; 73 return rc; 74 } 248 75 249 /* Check buffer our ISR builds */ 250 if (kbd_first != kbd_last) 76 int getch( void ) 77 { 78 int c; 79 while( kbd_first == kbd_last ) 251 80 { 252 *c = kbd_buffer[kbd_first]; 253 254 kbd_first = (kbd_first + 1) % KBD_BUF_SIZE; 255 return TRUE; 81 rtems_task_wake_after( 10 ); 256 82 } 257 else 258 return FALSE; 259 } /* _IBMPC_chrdy */ 260 261 262 /*-------------------------------------------------------------------------+ 263 | Function: _IBMPC_inch 264 | Description: Poll keyboard until a character is ready and return it. 265 | Global Variables: None. 266 | Arguments: None. 267 | Returns: character read from keyboard. 268 +--------------------------------------------------------------------------*/ 269 char 270 _IBMPC_inch(void) 271 { 272 char c; 273 while (!_IBMPC_chrdy(&c)) 274 continue; 275 276 return c; 277 } /* _IBMPC_inch */ 278 279 280 /* 281 * Routine that can be used before interrupt management is initialized. 282 */ 283 284 char 285 BSP_wait_polled_input(void) 286 { 287 char c; 288 while (!_IBMPC_scankey(&c)) 289 continue; 290 83 c = kbd_buffer[ kbd_first ]; 84 kbd_first = (kbd_first + 1) % KBD_BUF_SIZE; 291 85 return c; 292 86 } 293 87 294 /*-------------------------------------------------------------------------+ 295 | Function: _IBMPC_inch_sleep 296 | Description: If charcter is ready return it, otherwise sleep until 297 | it is ready 298 | Global Variables: None. 299 | Arguments: None. 300 | Returns: character read from keyboard. 301 +--------------------------------------------------------------------------*/ 302 char 303 _IBMPC_inch_sleep(void) 88 void add_to_queue( unsigned short b ) 304 89 { 305 char c; 306 rtems_interval ticks_per_second; 90 unsigned int next; 91 kbd_buffer[ kbd_last ] = b; 92 next = (kbd_last == kbd_end) ? 0 : kbd_last + 1; 93 if( next != kbd_first ) 94 { 95 kbd_last = next; 96 } 97 } 307 98 308 ticks_per_second = 0;309 310 for(;;)311 {312 if(_IBMPC_chrdy(&c))313 {314 return c;315 }316 317 if(ticks_per_second == 0)318 {319 rtems_clock_get(RTEMS_CLOCK_GET_TICKS_PER_SECOND,320 &ticks_per_second);321 }322 rtems_task_wake_after((ticks_per_second+24)/25);323 }324 325 return c;326 } /* _IBMPC_inch */327 328 329 330 331 332 -
c/src/lib/libbsp/i386/pc386/console/outch.c
rfe602cf r3cbb63a 180 180 #endif 181 181 } /* _IBMPC_initVideo */ 182 183 184 /* for old DOS compatibility n-curses type of applications */ 185 void gotoxy( int x, int y ) 186 { 187 row = x; 188 column = y; 189 wr_cursor(row * maxCol + column, ioCrtBaseAddr); 190 } 191 192 193 int whereX( void ) 194 { 195 return row; 196 } 197 198 int whereY( void ) 199 { 200 return column; 201 } 202 -
c/src/lib/libbsp/i386/pc386/startup/Makefile.am
rfe602cf r3cbb63a 11 11 C_FILES = bsplibc.c bsppost.c bspstart.c exit.c irq.c irq_init.c bootcard.c \ 12 12 main.c sbrk.c i386-stub.c i386-stub-glue.c uart.c pcibios.c \ 13 gnatinstallhandler.c 13 gnatinstallhandler.c gdb_glue.c tty_drv.c 14 14 15 C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o) 15 16
Note: See TracChangeset
for help on using the changeset viewer.