Changeset 30ab05f in mainline
- Timestamp:
- 2006-02-27T20:33:36Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d87c3f3
- Parents:
- 02f441c0
- Files:
-
- 1 added
- 1 deleted
- 9 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
arch/sparc64/Makefile.inc
r02f441c0 r30ab05f 58 58 CONFIG_ASID_FIFO = y 59 59 60 ## Compile with support for framebuffer. 61 # 62 60 63 CONFIG_FB = y 64 65 ## Compile with support for i8042 controller. 66 # 67 68 CONFIG_I8042 = y 61 69 62 70 ARCH_SOURCES = \ -
arch/sparc64/include/console.h
r02f441c0 r30ab05f 31 31 32 32 extern void kofwinput(void *arg); 33 extern void kkbdpoll(void *arg); 33 34 extern void ofw_sparc64_console_init(void); 34 35 extern void standalone_sparc64_console_init(void); -
arch/sparc64/include/drivers/i8042.h
r02f441c0 r30ab05f 27 27 */ 28 28 29 #ifndef __sparc64_KEYBOARD_H__ 30 #define __sparc64_KEYBOARD_H__ 29 #ifndef __sparc64_I8042_H__ 30 #define __sparc64_I8042_H__ 31 32 #include <arch/types.h> 31 33 32 34 #define KBD_PHYS_ADDRESS 0x1fff8904000ULL 33 35 #define KBD_VIRT_ADDRESS 0x00000d00000ULL 34 36 37 #define STATUS_REG 4 38 #define COMMAND_REG 4 39 #define DATA_REG 6 40 41 static inline void i8042_data_write(__u8 data) 42 { 43 ((__u8 *)(KBD_VIRT_ADDRESS))[DATA_REG] = data; 44 } 45 46 static inline __u8 i8042_data_read(void) 47 { 48 return ((volatile __u8 *)(KBD_VIRT_ADDRESS))[DATA_REG]; 49 } 50 51 static inline __u8 i8042_status_read(void) 52 { 53 return ((volatile __u8 *)(KBD_VIRT_ADDRESS))[STATUS_REG]; 54 } 55 56 static inline void i8042_command_write(__u8 command) 57 { 58 ((__u8 *)(KBD_VIRT_ADDRESS))[COMMAND_REG] = command; 59 } 60 35 61 #endif -
arch/sparc64/include/interrupt.h
r02f441c0 r30ab05f 35 35 #define IVT_FIRST 1 36 36 37 /* Dummy macros. */ 38 #define IRQ_KBD 2 39 #define VECTOR_KBD IRQ_KBD 40 41 #define trap_virtual_enable_irqs(x) 42 #define trap_virtual_eoi() 43 37 44 extern void interrupt_register(int n, const char *name, iroutine f); 38 45 -
arch/sparc64/src/console.c
r02f441c0 r30ab05f 32 32 #include <genarch/fb/fb.h> 33 33 #include <arch/drivers/fb.h> 34 #include <arch/drivers/keyboard.h> 34 #include <arch/drivers/i8042.h> 35 #include <genarch/i8042/i8042.h> 35 36 #include <genarch/ofw/ofw.h> 36 37 #include <console/chardev.h> … … 40 41 #include <proc/thread.h> 41 42 #include <synch/mutex.h> 43 44 #define KEYBOARD_POLL_PAUSE 50000 /* 50ms */ 42 45 43 46 static void ofw_sparc64_putchar(chardev_t *d, const char ch); … … 74 77 stdin = NULL; 75 78 fb_init(FB_VIRT_ADDRESS, FB_X_RES, FB_Y_RES, FB_COLOR_DEPTH/8); 79 i8042_init(); 76 80 } 77 81 … … 156 160 chardev_push_character(&ofw_sparc64_console, ch); 157 161 } 158 thread_usleep( 25000);162 thread_usleep(KEYBOARD_POLL_PAUSE); 159 163 } 160 164 } 165 166 /** Kernel thread for polling keyboard. 167 * 168 * @param arg Ignored. 169 */ 170 void kkbdpoll(void *arg) 171 { 172 while (1) { 173 i8042_poll(); 174 thread_usleep(KEYBOARD_POLL_PAUSE); 175 } 176 } -
arch/sparc64/src/mm/tlb.c
r02f441c0 r30ab05f 43 43 44 44 #include <arch/drivers/fb.h> 45 #include <arch/drivers/ keyboard.h>45 #include <arch/drivers/i8042.h> 46 46 47 47 char *context_encoding[] = { -
arch/sparc64/src/sparc64.c
r02f441c0 r30ab05f 62 62 panic("cannot create kofwinput\n"); 63 63 thread_ready(t); 64 65 /* 66 * Create thread that polls keyboard. 67 */ 68 t = thread_create(kkbdpoll, NULL, TASK, 0); 69 if (!t) 70 panic("cannot create kkbdpoll\n"); 71 thread_ready(t); 64 72 } 65 73 -
arch/sparc64/src/start.S
r02f441c0 r30ab05f 102 102 nop 103 103 104 wrpr %r0, 0, %pil 105 104 106 call main_bsp 105 107 nop -
genarch/include/i8042/i8042.h
r02f441c0 r30ab05f 46 46 47 47 extern void i8042_init(void); 48 extern void i8042_poll(void); 48 49 49 50 #endif -
genarch/src/i8042/i8042.c
r02f441c0 r30ab05f 53 53 /* 54 54 * 60 Write 8042 Command Byte: next data byte written to port 60h is 55 * placed in 8042 command register. Format:55 * placed in 8042 command register. Format: 56 56 * 57 57 * |7|6|5|4|3|2|1|0|8042 Command Byte … … 74 74 #define SPECIAL '?' 75 75 #define KEY_RELEASE 0x80 76 77 /** 78 * These codes read from i8042 data register are silently ignored. 79 */ 80 #define IGNORE_CODE 0x7f 76 81 77 82 static void key_released(__u8 sc); … … 262 267 263 268 static void i8042_interrupt(int n, void *stack); 269 static void i8042_wait(void); 264 270 265 271 /** Initialize i8042. */ … … 267 273 { 268 274 exc_register(VECTOR_KBD, "i8042_interrupt", i8042_interrupt); 269 while (i8042_status_read() & i8042_WAIT_MASK) { 270 /* wait */ 271 } 275 i8042_wait(); 272 276 i8042_command_write(i8042_SET_COMMAND); 273 while (i8042_status_read() & i8042_WAIT_MASK) { 274 /* wait */ 275 } 277 i8042_wait(); 276 278 i8042_data_write(i8042_COMMAND); 279 i8042_wait(); 277 280 278 281 trap_virtual_enable_irqs(1<<IRQ_KBD); … … 296 299 else 297 300 key_pressed(x); 301 } 302 303 /** Wait until the controller reads its data. */ 304 void i8042_wait(void) { 305 while (i8042_status_read() & i8042_WAIT_MASK) { 306 /* wait */ 307 } 298 308 } 299 309 … … 503 513 ; 504 514 x = i8042_data_read(); 505 if (x & KEY_RELEASE) 506 key_released(x ^ KEY_RELEASE); 507 else 508 active_read_key_pressed(x); 515 if (x != IGNORE_CODE) { 516 if (x & KEY_RELEASE) 517 key_released(x ^ KEY_RELEASE); 518 else 519 active_read_key_pressed(x); 520 } 509 521 } 510 522 return ch; 511 523 } 524 525 /** Poll for key press and release events. 526 * 527 * This function can be used to implement keyboard polling. 528 */ 529 void i8042_poll(void) 530 { 531 __u8 x; 532 533 while (((x = i8042_status_read() & i8042_BUFFER_FULL_MASK))) { 534 x = i8042_data_read(); 535 if (x != IGNORE_CODE) { 536 if (x & KEY_RELEASE) 537 key_released(x ^ KEY_RELEASE); 538 else 539 key_pressed(x); 540 } 541 } 542 }
Note:
See TracChangeset
for help on using the changeset viewer.