Changeset 8513ad7 in mainline
- Timestamp:
- 2006-10-17T19:18:49Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4874c2d
- Parents:
- e60293d
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/sparc64/src/console.c
re60293d r8513ad7 106 106 107 107 #ifdef CONFIG_Z8530 108 if (kbd_type == KBD_Z8530) 108 if (kbd_type == KBD_Z8530) { 109 /* 110 * The z8530 driver is interrupt-driven. 111 */ 109 112 return; 113 } 110 114 #endif 111 115 … … 124 128 void arch_grab_console(void) 125 129 { 130 switch (kbd_type) { 126 131 #ifdef CONFIG_Z8530 127 if (kbd_type == KBD_Z8530)132 case KBD_Z8530: 128 133 z8530_grab(); 134 break; 129 135 #endif 136 #ifdef CONFIG_NS16550 137 case KBD_NS16550: 138 ns16550_grab(); 139 break; 140 #endif 141 default: 142 break; 143 } 130 144 } 131 145 … … 135 149 void arch_release_console(void) 136 150 { 151 switch (kbd_type) { 137 152 #ifdef CONFIG_Z8530 138 if (kbd_type == KBD_Z8530)153 case KBD_Z8530: 139 154 z8530_release(); 155 break; 140 156 #endif 157 #ifdef CONFIG_NS16550 158 case KBD_NS16550: 159 ns16550_release(); 160 break; 161 #endif 162 default: 163 break; 164 } 141 165 } 142 166 -
kernel/genarch/src/kbd/ns16550.c
re60293d r8513ad7 39 39 #include <genarch/kbd/scanc.h> 40 40 #include <genarch/kbd/scanc_sun.h> 41 #include <arch/drivers/kbd.h> 41 42 #include <arch/drivers/ns16550.h> 42 43 #include <ddi/irq.h> 43 #include < arch/interrupt.h>44 #include <ipc/irq.h> 44 45 #include <cpu.h> 45 46 #include <arch/asm.h> … … 49 50 #include <console/console.h> 50 51 #include <interrupt.h> 52 #include <arch/interrupt.h> 51 53 #include <sysinfo/sysinfo.h> 54 #include <synch/spinlock.h> 52 55 53 56 #define LSR_DATA_READY 0x01 … … 58 61 /** Structure for ns16550's IRQ. */ 59 62 static irq_t ns16550_irq; 63 64 static ipc_notif_cfg_t saved_notif_cfg; 60 65 61 66 /* … … 73 78 }; 74 79 75 void ns16550_interrupt(int n, istate_t *istate); 76 void ns16550_wait(void); 80 void ns16550_interrupt(void); 77 81 78 82 /** Initialize keyboard and service interrupts using kernel routine */ 79 83 void ns16550_grab(void) 80 84 { 81 /* TODO */ 85 ns16550_ier_write(&ns16550, IER_ERBFI); /* enable receiver interrupt */ 86 87 while (ns16550_lsr_read(&ns16550) & LSR_DATA_READY) 88 (void) ns16550_rbr_read(&ns16550); 89 90 if (ns16550_irq.notif_cfg.answerbox) { 91 saved_notif_cfg = ns16550_irq.notif_cfg; 92 ns16550_irq.notif_cfg.answerbox = NULL; 93 ns16550_irq.notif_cfg.code = NULL; 94 ns16550_irq.notif_cfg.method = 0; 95 ns16550_irq.notif_cfg.counter = 0; 96 } 82 97 } 83 98 … … 85 100 void ns16550_release(void) 86 101 { 87 /* TODO */ 102 if (saved_notif_cfg.answerbox) 103 ns16550_irq.notif_cfg = saved_notif_cfg; 88 104 } 89 105 … … 96 112 void ns16550_init(devno_t devno, inr_t inr, uintptr_t vaddr) 97 113 { 98 ns16550_grab();99 114 chardev_initialize("ns16550_kbd", &kbrd, &ops); 100 115 stdin = &kbrd; … … 111 126 112 127 sysinfo_set_item_val("kbd", NULL, true); 128 sysinfo_set_item_val("kbd.type", NULL, KBD_NS16550); 113 129 sysinfo_set_item_val("kbd.devno", NULL, devno); 114 130 sysinfo_set_item_val("kbd.inr", NULL, inr); 115 131 sysinfo_set_item_val("kbd.address.virtual", NULL, vaddr); 116 132 117 ns16550_ier_write(&ns16550, IER_ERBFI); /* enable receiver interrupt */ 118 119 while (ns16550_lsr_read(&ns16550) & LSR_DATA_READY) 120 (void) ns16550_rbr_read(&ns16550); 121 } 122 123 /** Process ns16550 interrupt. 124 * 125 * @param n Interrupt vector. 126 * @param istate Interrupted state. 127 */ 128 void ns16550_interrupt(int n, istate_t *istate) 129 { 130 /* TODO */ 131 } 132 133 /** Wait until the controller reads its data. */ 134 void ns16550_wait(void) 135 { 133 ns16550_grab(); 134 } 135 136 /** Process ns16550 interrupt. */ 137 void ns16550_interrupt(void) 138 { 139 /* TODO 140 * 141 * ns16550 works in the polled mode so far. 142 */ 136 143 } 137 144 … … 171 178 void ns16550_poll(void) 172 179 { 173 uint8_t x; 180 ipl_t ipl; 181 182 ipl = interrupts_disable(); 183 spinlock_lock(&ns16550_irq.lock); 184 185 if (ns16550_lsr_read(&ns16550) & LSR_DATA_READY) { 186 if (ns16550_irq.notif_cfg.answerbox) { 187 /* 188 * Send IPC notification. 189 */ 190 ipc_irq_send_notif(&ns16550_irq); 191 spinlock_unlock(&ns16550_irq.lock); 192 interrupts_restore(ipl); 193 return; 194 } 195 } 196 197 spinlock_unlock(&ns16550_irq.lock); 198 interrupts_restore(ipl); 174 199 175 200 while (ns16550_lsr_read(&ns16550) & LSR_DATA_READY) { 201 uint8_t x; 202 176 203 x = ns16550_rbr_read(&ns16550); 177 204 if (x != IGNORE_CODE) { … … 186 213 irq_ownership_t ns16550_claim(void) 187 214 { 188 /* TODO */ 189 return IRQ_ACCEPT; 215 return (ns16550_lsr_read(&ns16550) & LSR_DATA_READY); 190 216 } 191 217 192 218 void ns16550_irq_handler(irq_t *irq, void *arg, ...) 193 219 { 194 panic("Not yet implemented .\n");220 panic("Not yet implemented, ns16550 works in polled mode.\n"); 195 221 } 196 222 -
kernel/genarch/src/kbd/z8530.c
re60293d r8513ad7 125 125 126 126 sysinfo_set_item_val("kbd", NULL, true); 127 sysinfo_set_item_val("kbd.type", NULL, KBD_Z8530); 127 128 sysinfo_set_item_val("kbd.devno", NULL, devno); 128 129 sysinfo_set_item_val("kbd.inr", NULL, inr); -
uspace/kbd/arch/sparc64/src/kbd.c
re60293d r8513ad7 47 47 #define KBD_ALL_KEYS_UP 0x7f 48 48 49 /** Top-half pseudocode for z8530. */ 49 50 irq_cmd_t z8530_cmds[] = { 50 { CMD_MEM_READ_1, 0, 0, 1 } 51 { 52 CMD_MEM_READ_1, 53 0, /**< Address. Will be patched in run-time. */ 54 0, /**< Value. Not used. */ 55 1 /**< Arg 1 will contain the result. */ 56 } 51 57 }; 52 58 … … 56 62 }; 57 63 64 /** Top-half pseudocode for ns16550. */ 65 irq_cmd_t ns16550_cmds[] = { 66 { 67 CMD_MEM_READ_1, 68 0, /**< Address. Will be patched in run-time. */ 69 0, /**< Value. Not used. */ 70 1 /**< Arg 1 will contain the result. */ 71 } 72 }; 73 74 irq_code_t ns16550_kbd = { 75 1, 76 ns16550_cmds 77 }; 78 79 #define KBD_Z8530 1 80 #define KBD_NS16550 2 81 58 82 int kbd_arch_init(void) 59 83 { 60 z8530_cmds[0].addr = (void *) sysinfo_value("kbd.address.virtual") + 6; 61 ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &z8530_kbd); 84 int type = sysinfo_value("kbd.type"); 85 switch (type) { 86 case KBD_Z8530: 87 z8530_cmds[0].addr = (void *) sysinfo_value("kbd.address.virtual") + 6; 88 ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &z8530_kbd); 89 break; 90 case KBD_NS16550: 91 ns16550_cmds[0].addr = (void *) sysinfo_value("kbd.address.virtual"); 92 ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &ns16550_kbd); 93 break; 94 default: 95 break; 96 } 62 97 return 0; 63 98 }
Note:
See TracChangeset
for help on using the changeset viewer.