Changeset 607c5f9 in mainline
- Timestamp:
- 2005-11-23T00:16:03Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a83a802
- Parents:
- 2677758
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/amd64/src/amd64.c
r2677758 r607c5f9 103 103 void arch_post_smp_init(void) 104 104 { 105 trap_virtual_enable_irqs(1<<IRQ_KBD); 105 106 } 106 107 -
arch/ia32/src/drivers/i8042.c
r2677758 r607c5f9 36 36 #include <synch/spinlock.h> 37 37 #include <typedefs.h> 38 #include <console/chardev.h> 39 #include <console/console.h> 38 40 39 41 /** … … 55 57 static volatile int keyflags; /**< Tracking of multiple keypresses. */ 56 58 static volatile int lockflags; /**< Tracking of multiple keys lockings. */ 59 60 static void i8042_suspend(void); 61 static void i8042_resume(void); 62 63 static chardev_t kbrd; 64 static chardev_operations_t ops = { 65 .suspend = i8042_suspend, 66 .resume = i8042_resume 67 }; 57 68 58 69 /** Primary meaning of scancodes. */ … … 221 232 trap_register(VECTOR_KBD, i8042_interrupt); 222 233 spinlock_initialize(&keylock); 234 chardev_initialize(&kbrd, &ops); 235 stdin = &kbrd; 223 236 } 224 237 … … 293 306 if (shift) 294 307 map = sc_secondary_map; 295 putchar(map[sc]);308 chardev_push_character(&kbrd, map[sc]); 296 309 break; 297 310 } 298 311 spinlock_unlock(&keylock); 299 312 } 313 314 /* Called from getc(). */ 315 void i8042_resume(void) 316 { 317 } 318 319 /* Called from getc(). */ 320 void i8042_suspend(void) 321 { 322 } -
arch/mips32/src/drivers/keyboard.c
r2677758 r607c5f9 37 37 #include <typedefs.h> 38 38 39 static void keyboard_enable(void); 40 static void keyboard_disable(void); 41 39 42 static chardev_t kbrd; 40 41 static void keyboard_enable(void); 43 static chardev_operations_t ops = { 44 .resume = keyboard_enable, 45 .suspend = keyboard_disable 46 }; 42 47 43 48 /** Initialize keyboard subsystem. */ … … 45 50 { 46 51 cp0_unmask_int(KEYBOARD_IRQ); 47 chardev_initialize(&kbrd, keyboard_enable);52 chardev_initialize(&kbrd, &ops); 48 53 stdin = &kbrd; 49 54 } 50 55 51 /** Process keyboard interrupt. 52 * 53 * This function is called directly from the interrupt handler. 54 * It feeds the keyboard buffer with characters read. When the buffer 55 * is full, it simply masks the keyboard interrupt signal. 56 */ 56 /** Process keyboard interrupt. */ 57 57 void keyboard(void) 58 58 { 59 59 char ch; 60 60 61 spinlock_lock(&kbrd.lock);62 kbrd.counter++;63 if (kbrd.counter == CHARDEV_BUFLEN - 1) {64 /* buffer full => disable keyboard interrupt */65 cp0_mask_int(KEYBOARD_IRQ);66 }67 68 61 ch = *((char *) KEYBOARD_ADDRESS); 69 putchar(ch); 70 kbrd.buffer[kbrd.index++] = ch; 71 kbrd.index = kbrd.index % CHARDEV_BUFLEN; /* index modulo size of buffer */ 72 waitq_wakeup(&kbrd.wq, WAKEUP_FIRST); 73 spinlock_unlock(&kbrd.lock); 62 chardev_push_character(&kbrd, ch); 74 63 } 75 64 … … 79 68 cp0_unmask_int(KEYBOARD_IRQ); 80 69 } 70 71 /* Called from getc(). */ 72 void keyboard_disable(void) 73 { 74 cp0_mask_int(KEYBOARD_IRQ); 75 } -
generic/include/console/chardev.h
r2677758 r607c5f9 35 35 #include <synch/spinlock.h> 36 36 37 #define CHARDEV_BUFLEN 1037 #define CHARDEV_BUFLEN 512 38 38 39 typedef void (* ready_func_t)(void); 39 /* Character device operations interface. */ 40 struct chardev_operations { 41 void (* suspend)(void); /**< Suspend pushing characters. */ 42 void (* resume)(void); /**< Resume pushing characters. */ 43 }; 44 45 typedef struct chardev_operations chardev_operations_t; 40 46 41 47 /** Character input device. */ … … 46 52 count_t counter; 47 53 index_t index; 48 ready_func_t ready_func; /**< Function to re-enable input from the device. */54 chardev_operations_t *op; /**< Implementation of chardev operations. */ 49 55 }; 50 56 51 extern void chardev_initialize(chardev_t *chardev, ready_func_t r); 57 extern void chardev_initialize(chardev_t *chardev, chardev_operations_t *op); 58 void chardev_push_character(chardev_t *chardev, __u8 ch); 52 59 53 60 #endif /* __CHARDEV_H__ */ -
generic/src/console/chardev.c
r2677758 r607c5f9 28 28 29 29 #include <console/chardev.h> 30 #include <putchar.h> 30 31 #include <synch/waitq.h> 31 32 #include <synch/spinlock.h> 32 33 33 /** Initialize character device. */ 34 void chardev_initialize(chardev_t *chardev, ready_func_t r) 34 /** Initialize character device. 35 * 36 * @param chardev Character device. 37 * @param op Implementation of character device operations. 38 */ 39 void chardev_initialize(chardev_t *chardev, chardev_operations_t *op) 35 40 { 36 41 waitq_initialize(&chardev->wq); … … 38 43 chardev->counter = 0; 39 44 chardev->index = 0; 40 chardev-> ready_func = r;45 chardev->op = op; 41 46 } 47 48 /** Push character read from input character device. 49 * 50 * @param chardev Character device. 51 * @param ch Character being pushed. 52 */ 53 void chardev_push_character(chardev_t *chardev, __u8 ch) 54 { 55 spinlock_lock(&chardev->lock); 56 chardev->counter++; 57 if (chardev->counter == CHARDEV_BUFLEN - 1) { 58 /* buffer full => disable device interrupt */ 59 chardev->op->suspend(); 60 } 61 62 putchar(ch); 63 chardev->buffer[chardev->index++] = ch; 64 chardev->index = chardev->index % CHARDEV_BUFLEN; /* index modulo size of buffer */ 65 waitq_wakeup(&chardev->wq, WAKEUP_FIRST); 66 spinlock_unlock(&chardev->lock); 67 } -
generic/src/console/console.c
r2677758 r607c5f9 83 83 interrupts_restore(ipl); 84 84 85 chardev-> ready_func();85 chardev->op->resume(); 86 86 87 87 return ch;
Note:
See TracChangeset
for help on using the changeset viewer.