Changeset 15039b67 in mainline
- Timestamp:
- 2006-06-11T17:05:41Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f8d5b85
- Parents:
- 290c0db
- Files:
-
- 3 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
console/console.c
r290c0db r15039b67 37 37 #include <stdio.h> 38 38 39 40 #include <kbd.h>41 39 #include <fb.h> 42 40 #include <ipc/ipc.h> 41 #include <keys.h> 43 42 #include <ipc/fb.h> 44 43 #include <ipc/services.h> -
fb/ega.c
r290c0db r15039b67 50 50 #include <ipc/ns.h> 51 51 #include <ipc/services.h> 52 #include <libarch/ddi.h> 52 53 53 54 #include "ega.h" … … 71 72 #define EGA_STYLE(fg,bg) ((fg) > (bg) ? NORMAL_COLOR : INVERTED_COLOR) 72 73 73 typedef unsigned char u8;74 typedef unsigned short u16;75 typedef unsigned int u32;76 77 78 74 /* Allow only 1 connection */ 79 75 static int client_connected = 0; … … 84 80 85 81 static unsigned int style = NORMAL_COLOR; 86 87 static inline void outb(u16 port, u8 b)88 {89 asm volatile ("outb %0, %1\n" :: "a" (b), "d" (port));90 }91 92 static inline void outw(u16 port, u16 w)93 {94 asm volatile ("outw %0, %1\n" :: "a" (w), "d" (port));95 }96 97 static inline void outl(u16 port, u32 l)98 {99 asm volatile ("outl %0, %1\n" :: "a" (l), "d" (port));100 }101 102 static inline u8 inb(u16 port)103 {104 u8 val;105 106 asm volatile ("inb %1, %0 \n" : "=a" (val) : "d"(port));107 return val;108 }109 110 static inline u16 inw(u16 port)111 {112 u16 val;113 114 asm volatile ("inw %1, %0 \n" : "=a" (val) : "d"(port));115 return val;116 }117 118 static inline u32 inl(u16 port)119 {120 u32 val;121 122 asm volatile ("inl %1, %0 \n" : "=a" (val) : "d"(port));123 return val;124 }125 126 127 128 82 129 83 static void clrscr(void) … … 151 105 static void cursor_disable(void) 152 106 { 153 u8 stat; 107 uint8_t stat; 108 154 109 outb(EGA_IO_ADDRESS , 0xa); 155 110 stat=inb(EGA_IO_ADDRESS + 1); … … 160 115 static void cursor_enable(void) 161 116 { 162 u8 stat; 117 uint8_t stat; 118 163 119 outb(EGA_IO_ADDRESS , 0xa); 164 120 stat=inb(EGA_IO_ADDRESS + 1); -
kbd/arch/ia32/include/kbd.h
r290c0db r15039b67 28 28 29 29 /** @addtogroup kbdamd64 amd64 30 * @brief HelenOS ia32 / amd64 arch dependent parts of uspace keyboard handler.30 * @brief HelenOS ia32 / amd64 arch dependent parts of uspace keyboard and mouse handler. 31 31 * @ingroup kbd 32 32 * @{ … … 41 41 42 42 #include <key_buffer.h> 43 #include <ddi.h> 44 #include <libarch/ddi.h> 45 46 #define KBD_IRQ 1 47 #define MOUSE_IRQ 12 48 49 #define i8042_DATA 0x60 50 #define i8042_STATUS 0X64 51 52 53 typedef unsigned char u8; 54 typedef short u16; 55 56 static inline void i8042_data_write(u8 data) 57 { 58 outb(i8042_DATA, data); 59 } 60 61 static inline u8 i8042_data_read(void) 62 { 63 return inb(i8042_DATA); 64 } 65 66 static inline u8 i8042_status_read(void) 67 { 68 return inb(i8042_STATUS); 69 } 70 71 static inline void i8042_command_write(u8 command) 72 { 73 outb(i8042_STATUS, command); 74 } 43 75 44 76 int kbd_arch_init(void); 45 int kbd_arch_process(keybuffer_t *keybuffer, int scan_code);46 77 47 78 #endif -
kbd/arch/ia32/src/kbd.c
r290c0db r15039b67 39 39 #include <arch/kbd.h> 40 40 #include <ipc/ipc.h> 41 #include <unistd.h> 42 #include <kbd.h> 43 #include <keys.h> 44 45 /* Interesting bits for status register */ 46 #define i8042_OUTPUT_FULL 0x1 47 #define i8042_INPUT_FULL 0x2 48 #define i8042_MOUSE_DATA 0x20 49 50 /* Command constants */ 51 #define i8042_CMD_KBD 0x60 52 #define i8042_CMD_MOUSE 0xd4 53 54 /* Keyboard cmd byte */ 55 #define i8042_KBD_IE 0x1 56 #define i8042_MOUSE_IE 0x2 57 #define i8042_KBD_DISABLE 0x10 58 #define i8042_MOUSE_DISABLE 0x20 59 #define i8042_KBD_TRANSLATE 0x40 60 61 /* Mouse constants */ 62 #define MOUSE_OUT_INIT 0xf4 63 #define MOUSE_ACK 0xfa 64 41 65 42 66 #define SPECIAL 255 … … 232 256 }; 233 257 234 irq_cmd_t i8042_cmds[1] = { 235 { CMD_PORT_READ_1, (void *)0x60, 0 } 258 irq_cmd_t i8042_cmds[2] = { 259 { CMD_PORT_READ_1, (void *)0x64, 0, 1 }, 260 { CMD_PORT_READ_1, (void *)0x60, 0, 2 } 236 261 }; 237 262 238 263 irq_code_t i8042_kbd = { 239 1,264 2, 240 265 i8042_cmds 241 266 }; … … 355 380 } 356 381 382 383 static void wait_ready(void) { 384 while (i8042_status_read() & i8042_INPUT_FULL) 385 ; 386 } 387 357 388 /** Register uspace irq handler 358 389 * @return … … 360 391 int kbd_arch_init(void) 361 392 { 362 return !(ipc_register_irq(1, &i8042_kbd)); 393 int rc1, i; 394 int mouseenabled = 0; 395 396 iospace_enable(task_get_id(),(void *)i8042_DATA, 5); 397 /* Disable kbd, enable mouse */ 398 i8042_command_write(i8042_CMD_KBD); 399 wait_ready(); 400 i8042_command_write(i8042_CMD_KBD); 401 wait_ready(); 402 i8042_data_write(i8042_KBD_DISABLE); 403 wait_ready(); 404 405 /* Flush all current IO */ 406 while (i8042_status_read() & i8042_OUTPUT_FULL) 407 i8042_data_read(); 408 /* Initialize mouse */ 409 i8042_command_write(i8042_CMD_MOUSE); 410 wait_ready(); 411 i8042_data_write(MOUSE_OUT_INIT); 412 wait_ready(); 413 414 int mouseanswer = 0; 415 for (i=0;i < 1000; i++) { 416 int status = i8042_status_read(); 417 if (status & i8042_OUTPUT_FULL) { 418 int data = i8042_data_read(); 419 if (status & i8042_MOUSE_DATA) { 420 mouseanswer = data; 421 break; 422 } 423 } 424 usleep(1000); 425 } 426 if (mouseanswer == MOUSE_ACK) { 427 /* enable mouse */ 428 mouseenabled = 1; 429 430 ipc_register_irq(MOUSE_IRQ, &i8042_kbd); 431 } 432 /* Enable kbd */ 433 ipc_register_irq(KBD_IRQ, &i8042_kbd); 434 435 int newcontrol = i8042_KBD_IE | i8042_KBD_TRANSLATE; 436 if (mouseenabled) 437 newcontrol |= i8042_MOUSE_IE; 438 439 i8042_command_write(i8042_CMD_KBD); 440 wait_ready(); 441 i8042_data_write(newcontrol); 442 wait_ready(); 443 444 return 0; 363 445 } 364 446 365 int kbd_arch_process(keybuffer_t *keybuffer, int scan_code) 447 /** Process keyboard & mouse events */ 448 int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call) 366 449 { 367 if (scan_code != IGNORE_CODE) { 368 if (scan_code & KEY_RELEASE) 369 key_released(keybuffer, scan_code ^ KEY_RELEASE); 370 else 371 key_pressed(keybuffer, scan_code); 450 int status = IPC_GET_ARG1(*call); 451 452 if ((status & i8042_MOUSE_DATA)) { 453 ; 454 } else { 455 int scan_code = IPC_GET_ARG2(*call); 456 457 if (scan_code != IGNORE_CODE) { 458 if (scan_code & KEY_RELEASE) 459 key_released(keybuffer, scan_code ^ KEY_RELEASE); 460 else 461 key_pressed(keybuffer, scan_code); 462 } 372 463 } 373 464 return 1; -
kbd/arch/ia64/include/kbd.h
r290c0db r15039b67 42 42 43 43 int kbd_arch_init(void); 44 int kbd_arch_process(keybuffer_t *keybuffer, int scan_code);45 44 46 45 #endif -
kbd/arch/ia64/src/kbd.c
r290c0db r15039b67 38 38 #include <ipc/ipc.h> 39 39 #include <sysinfo.h> 40 #include <kbd.h> 41 #include <keys.h> 40 42 41 43 #define KEY_F1 0x504f1b … … 56 58 57 59 irq_cmd_t ski_cmds[1] = { 58 { CMD_IA64_GETCHAR, 0, 0 }60 { CMD_IA64_GETCHAR, 0, 0, 2 } 59 61 }; 60 62 … … 68 70 if(sysinfo_value("kbd")) { 69 71 ipc_register_irq(sysinfo_value("kbd.irq"), &ski_kbd); 70 return 1;72 return 0; 71 73 } 72 74 return 1; 73 75 } 74 76 … … 82 84 */ 83 85 84 int kbd_arch_process(keybuffer_t *keybuffer, i nt scan_code)86 int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call) 85 87 { 86 88 static unsigned long long buf=0; 87 89 static int count=0; 88 90 static int esc_count=0; 91 int scan_code = IPC_GET_ARG2(*call); 89 92 90 93 -
kbd/arch/mips32/include/kbd.h
r290c0db r15039b67 41 41 42 42 int kbd_arch_init(void); 43 int kbd_arch_process(keybuffer_t *keybuffer, int scan_code);44 43 45 44 #endif -
kbd/arch/mips32/src/kbd.c
r290c0db r15039b67 37 37 #include <ipc/ipc.h> 38 38 #include <sysinfo.h> 39 39 #include <kbd.h> 40 #include <keys.h> 40 41 41 42 #define MSIM_KEY_F1 0x504f1bL … … 71 72 72 73 irq_cmd_t msim_cmds[1] = { 73 { CMD_MEM_READ_1, (void *)0xB0000000, 0 }74 { CMD_MEM_READ_1, (void *)0xB0000000, 0, 2 } 74 75 }; 75 76 … … 86 87 msim=sysinfo_value("machine.msim"); 87 88 gxemul=sysinfo_value("machine.lgxemul"); 88 return 1;89 return 0; 89 90 } 90 91 … … 374 375 } 375 376 376 int kbd_arch_process(keybuffer_t *keybuffer, i nt scan_code)377 int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call) 377 378 { 378 379 int scan_code = IPC_GET_ARG2(*call); 379 380 static int esc_count=0; 380 381 -
kbd/arch/ppc32/include/kbd.h
r290c0db r15039b67 41 41 42 42 int kbd_arch_init(void); 43 int kbd_arch_process(keybuffer_t *keybuffer, int scan_code);44 43 45 44 #endif -
kbd/arch/ppc32/src/kbd.c
r290c0db r15039b67 38 38 #include <ipc/ipc.h> 39 39 #include <sysinfo.h> 40 #include <kbd.h> 41 #include <keys.h> 40 42 41 43 irq_cmd_t cuda_cmds[1] = { 42 { CMD_PPC32_GETCHAR, 0, 0 }44 { CMD_PPC32_GETCHAR, 0, 0, 2 } 43 45 }; 44 46 … … 182 184 int kbd_arch_init(void) 183 185 { 184 return (!ipc_register_irq(sysinfo_value("cuda.irq"), &cuda_kbd));186 return ipc_register_irq(sysinfo_value("cuda.irq"), &cuda_kbd); 185 187 } 186 188 187 189 188 int kbd_arch_process(keybuffer_t *keybuffer, i nt scan_code)190 int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call) 189 191 { 190 if (scan_code != -1) { 191 uint8_t scancode = (uint8_t) scan_code; 192 int param = IPC_GET_ARG2(*call); 193 194 if (param != -1) { 195 uint8_t scancode = (uint8_t) param; 192 196 193 197 if ((scancode & 0x80) != 0x80) { -
kbd/generic/kbd.c
r290c0db r15039b67 53 53 #include <key_buffer.h> 54 54 #include <async.h> 55 #include <keys.h> 55 56 56 57 #define NAME "KBD" … … 63 64 { 64 65 int chr; 65 66 66 67 if (cons_connected && phone2cons != -1) { 67 68 /* recode to ASCII - one interrupt can produce more than one code so result is stored in fifo */ 68 kbd_arch_process(&keybuffer, IPC_GET_ARG2(*call));69 kbd_arch_process(&keybuffer, call); 69 70 70 71 while (!keybuffer_empty(&keybuffer)) { … … 124 125 125 126 /* Initialize arch dependent parts */ 126 if (!(res = kbd_arch_init())) { 127 return -1; 128 }; 127 if (kbd_arch_init()) 128 return -1; 129 129 130 130 /* Initialize key buffer */ -
kbd/include/kbd.h
r290c0db r15039b67 38 38 #define __KBD_H__ 39 39 40 #define KBD_PUSHCHAR 102441 40 42 #define KBD_KEY_F1 0x3b 43 #define KBD_KEY_F2 0x3c 44 #define KBD_KEY_F3 0x3d 45 #define KBD_KEY_F4 0x3e 46 #define KBD_KEY_F5 0x3f 47 #define KBD_KEY_F6 0x40 48 #define KBD_KEY_F7 0x41 49 #define KBD_KEY_F8 0x42 50 #define KBD_KEY_F9 0x43 51 #define KBD_KEY_F10 0x44 52 #define KBD_KEY_F11 0x45 53 #define KBD_KEY_F12 0x46 41 int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call); 54 42 55 43 #endif -
klog/klog.c
r290c0db r15039b67 50 50 51 51 async_serialize_start(); 52 for (i=0; klog[i + IPC_GET_ARG 2(*call)] && i < IPC_GET_ARG3(*call); i++)53 putchar(klog[i + IPC_GET_ARG 2(*call)]);52 for (i=0; klog[i + IPC_GET_ARG1(*call)] && i < IPC_GET_ARG2(*call); i++) 53 putchar(klog[i + IPC_GET_ARG1(*call)]); 54 54 putchar('\n'); 55 55 async_serialize_end(); -
libc/generic/async.c
r290c0db r15039b67 449 449 { 450 450 /* Unrouted call - do some default behaviour */ 451 switch (IPC_GET_METHOD(*call)) { 452 case IPC_M_INTERRUPT: 451 if ((callid & IPC_CALLID_NOTIFICATION)) { 453 452 in_interrupt_handler = 1; 454 453 (*interrupt_received)(callid,call); 455 454 in_interrupt_handler = 0; 456 455 return; 456 } 457 458 switch (IPC_GET_METHOD(*call)) { 457 459 case IPC_M_CONNECT_ME_TO: 458 460 /* Open new connection with thread etc. */
Note:
See TracChangeset
for help on using the changeset viewer.