Rev 2227 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2227 | Rev 3829 | ||
---|---|---|---|
Line 234... | Line 234... | ||
234 | }; |
234 | }; |
235 | 235 | ||
236 | 236 | ||
237 | int cuda_get_scancode(void) |
237 | int cuda_get_scancode(void) |
238 | { |
238 | { |
- | 239 | if (cuda) { |
|
239 | uint8_t kind; |
240 | uint8_t kind; |
240 | uint8_t data[4]; |
241 | uint8_t data[4]; |
241 | 242 | ||
242 | receive_packet(&kind, 4, data); |
243 | receive_packet(&kind, 4, data); |
243 | 244 | ||
244 | if ((kind == PACKET_ADB) && (data[0] == 0x40) && (data[1] == 0x2c)) |
245 | if ((kind == PACKET_ADB) && (data[0] == 0x40) && (data[1] == 0x2c)) |
245 | return data[2]; |
246 | return data[2]; |
- | 247 | } |
|
246 | 248 | ||
247 | return -1; |
249 | return -1; |
248 | } |
250 | } |
249 | 251 | ||
250 | static void cuda_irq_handler(irq_t *irq, void *arg, ...) |
252 | static void cuda_irq_handler(irq_t *irq, void *arg, ...) |
Line 269... | Line 271... | ||
269 | 271 | ||
270 | 272 | ||
271 | /** Initialize keyboard and service interrupts using kernel routine */ |
273 | /** Initialize keyboard and service interrupts using kernel routine */ |
272 | void cuda_grab(void) |
274 | void cuda_grab(void) |
273 | { |
275 | { |
- | 276 | if (cuda) { |
|
274 | ipl_t ipl = interrupts_disable(); |
277 | ipl_t ipl = interrupts_disable(); |
275 | spinlock_lock(&cuda_irq.lock); |
278 | spinlock_lock(&cuda_irq.lock); |
276 | cuda_irq.notif_cfg.notify = false; |
279 | cuda_irq.notif_cfg.notify = false; |
277 | spinlock_unlock(&cuda_irq.lock); |
280 | spinlock_unlock(&cuda_irq.lock); |
278 | interrupts_restore(ipl); |
281 | interrupts_restore(ipl); |
- | 282 | } |
|
279 | } |
283 | } |
280 | 284 | ||
281 | 285 | ||
282 | /** Resume the former interrupt vector */ |
286 | /** Resume the former interrupt vector */ |
283 | void cuda_release(void) |
287 | void cuda_release(void) |
284 | { |
288 | { |
- | 289 | if (cuda) { |
|
285 | ipl_t ipl = interrupts_disable(); |
290 | ipl_t ipl = interrupts_disable(); |
286 | spinlock_lock(&cuda_irq.lock); |
291 | spinlock_lock(&cuda_irq.lock); |
287 | if (cuda_irq.notif_cfg.answerbox) |
292 | if (cuda_irq.notif_cfg.answerbox) |
288 | cuda_irq.notif_cfg.notify = true; |
293 | cuda_irq.notif_cfg.notify = true; |
289 | spinlock_unlock(&cuda_irq.unlock); |
294 | spinlock_unlock(&cuda_irq.unlock); |
290 | interrupts_restore(ipl); |
295 | interrupts_restore(ipl); |
- | 296 | } |
|
291 | } |
297 | } |
292 | 298 | ||
293 | 299 | ||
294 | void cuda_init(devno_t devno, uintptr_t base, size_t size) |
300 | void cuda_init(devno_t devno, uintptr_t base, size_t size) |
295 | { |
301 | { |
296 | cuda = (uint8_t *) hw_map(base, size); |
302 | cuda = (uint8_t *) hw_map(base, size); |
297 | 303 | ||
298 | chardev_initialize("cuda_kbd", &kbrd, &ops); |
304 | chardev_initialize("cuda_kbd", &kbrd, &ops); |
299 | stdin = &kbrd; |
305 | stdin = &kbrd; |
300 | 306 | ||
301 | irq_initialize(&cuda_irq); |
307 | irq_initialize(&cuda_irq); |
Line 304... | Line 310... | ||
304 | cuda_irq.claim = cuda_claim; |
310 | cuda_irq.claim = cuda_claim; |
305 | cuda_irq.handler = cuda_irq_handler; |
311 | cuda_irq.handler = cuda_irq_handler; |
306 | irq_register(&cuda_irq); |
312 | irq_register(&cuda_irq); |
307 | 313 | ||
308 | pic_enable_interrupt(CUDA_IRQ); |
314 | pic_enable_interrupt(CUDA_IRQ); |
309 | 315 | ||
310 | sysinfo_set_item_val("kbd", NULL, true); |
316 | sysinfo_set_item_val("kbd", NULL, true); |
311 | sysinfo_set_item_val("kbd.devno", NULL, devno); |
317 | sysinfo_set_item_val("kbd.devno", NULL, devno); |
312 | sysinfo_set_item_val("kbd.inr", NULL, CUDA_IRQ); |
318 | sysinfo_set_item_val("kbd.inr", NULL, CUDA_IRQ); |
313 | sysinfo_set_item_val("kbd.address.virtual", NULL, base); |
319 | sysinfo_set_item_val("kbd.address.virtual", NULL, base); |
314 | } |
320 | } |
Line 343... | Line 349... | ||
343 | "b 0\n" |
349 | "b 0\n" |
344 | ); |
350 | ); |
345 | } |
351 | } |
346 | 352 | ||
347 | void arch_reboot(void) { |
353 | void arch_reboot(void) { |
- | 354 | if (cuda) |
|
348 | send_packet(PACKET_CUDA, 1, CUDA_RESET); |
355 | send_packet(PACKET_CUDA, 1, CUDA_RESET); |
- | 356 | ||
349 | asm volatile ( |
357 | asm volatile ( |
350 | "b 0\n" |
358 | "b 0\n" |
351 | ); |
359 | ); |
352 | } |
360 | } |
353 | 361 |