Rev 4342 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4342 | Rev 4343 | ||
---|---|---|---|
Line 136... | Line 136... | ||
136 | sysinfo_set_item_val("kbd.devno", NULL, devno); |
136 | sysinfo_set_item_val("kbd.devno", NULL, devno); |
137 | sysinfo_set_item_val("kbd.inr", NULL, inr); |
137 | sysinfo_set_item_val("kbd.inr", NULL, inr); |
138 | sysinfo_set_item_val("kbd.address.virtual", NULL, port); |
138 | sysinfo_set_item_val("kbd.address.virtual", NULL, port); |
139 | sysinfo_set_item_val("kbd.port", NULL, port); |
139 | sysinfo_set_item_val("kbd.port", NULL, port); |
140 | 140 | ||
141 | #ifdef CONFIG_NS16550_INTERRUPT_DRIVEN |
- | |
142 | /* Enable interrupts */ |
141 | /* Enable interrupts */ |
143 | ns16550_ier_write(&ns16550, IER_ERBFI); |
142 | ns16550_ier_write(&ns16550, IER_ERBFI); |
144 | ns16550_mcr_write(&ns16550, MCR_OUT2); |
143 | ns16550_mcr_write(&ns16550, MCR_OUT2); |
145 | #endif |
- | |
146 | 144 | ||
147 | uint8_t c; |
145 | uint8_t c; |
148 | // This switches rbr & ier to mode when accept baudrate constant |
146 | // This switches rbr & ier to mode when accept baudrate constant |
149 | c = ns16550_lcr_read(&ns16550); |
147 | c = ns16550_lcr_read(&ns16550); |
150 | ns16550_lcr_write(&ns16550, 0x80 | c); |
148 | ns16550_lcr_write(&ns16550, 0x80 | c); |
Line 196... | Line 194... | ||
196 | * |
194 | * |
197 | * This function can be used to implement keyboard polling. |
195 | * This function can be used to implement keyboard polling. |
198 | */ |
196 | */ |
199 | void ns16550_poll(void) |
197 | void ns16550_poll(void) |
200 | { |
198 | { |
201 | #ifndef CONFIG_NS16550_INTERRUPT_DRIVEN |
- | |
202 | ipl_t ipl; |
- | |
203 | - | ||
204 | ipl = interrupts_disable(); |
- | |
205 | spinlock_lock(&ns16550_irq.lock); |
- | |
206 | - | ||
207 | if (ns16550_lsr_read(&ns16550) & LSR_DATA_READY) { |
- | |
208 | if (ns16550_irq.notif_cfg.notify && ns16550_irq.notif_cfg.answerbox) { |
- | |
209 | /* |
- | |
210 | * Send IPC notification. |
- | |
211 | */ |
- | |
212 | ipc_irq_send_notif(&ns16550_irq); |
- | |
213 | spinlock_unlock(&ns16550_irq.lock); |
- | |
214 | interrupts_restore(ipl); |
- | |
215 | return; |
- | |
216 | } |
- | |
217 | } |
- | |
218 | - | ||
219 | spinlock_unlock(&ns16550_irq.lock); |
- | |
220 | interrupts_restore(ipl); |
- | |
221 | #endif |
- | |
222 | - | ||
223 | while (ns16550_lsr_read(&ns16550) & LSR_DATA_READY) { |
199 | while (ns16550_lsr_read(&ns16550) & LSR_DATA_READY) { |
224 | uint8_t x; |
200 | uint8_t x; |
225 | 201 | ||
226 | x = ns16550_rbr_read(&ns16550); |
202 | x = ns16550_rbr_read(&ns16550); |
227 | 203 | ||
Line 232... | Line 208... | ||
232 | key_pressed(x); |
208 | key_pressed(x); |
233 | } |
209 | } |
234 | } |
210 | } |
235 | } |
211 | } |
236 | 212 | ||
237 | irq_ownership_t ns16550_claim(void) |
213 | irq_ownership_t ns16550_claim(void *instance) |
238 | { |
214 | { |
239 | return (ns16550_lsr_read(&ns16550) & LSR_DATA_READY); |
215 | return (ns16550_lsr_read(&ns16550) & LSR_DATA_READY); |
240 | } |
216 | } |
241 | 217 | ||
242 | void ns16550_irq_handler(irq_t *irq, void *arg, ...) |
218 | void ns16550_irq_handler(irq_t *irq) |
243 | { |
219 | { |
244 | if (irq->notif_cfg.notify && irq->notif_cfg.answerbox) |
220 | if (irq->notif_cfg.notify && irq->notif_cfg.answerbox) |
245 | ipc_irq_send_notif(irq); |
221 | ipc_irq_send_notif(irq); |
246 | else |
222 | else |
247 | ns16550_interrupt(); |
223 | ns16550_interrupt(); |