From 5aaabf189d36a30dfc927c6b28b31b20128711c2 Mon Sep 17 00:00:00 2001 From: Carlos Date: Fri, 20 Mar 2015 16:42:19 +0100 Subject: [PATCH] lesson 20 finished: timer + keyboard --- 20-interrupts-timer/README.md | 3 +++ 20-interrupts-timer/cpu/timer.c | 2 +- 20-interrupts-timer/drivers/keyboard.c | 9 ++++++--- 20-interrupts-timer/kernel/kernel.c | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/20-interrupts-timer/README.md b/20-interrupts-timer/README.md index fbc05e9..fba50d5 100644 --- a/20-interrupts-timer/README.md +++ b/20-interrupts-timer/README.md @@ -34,3 +34,6 @@ created with the definitions. `keyboard.c` also has a long table to translate scancodes to ASCII keys. For the time being, we will only implement a simple subset of the US keyboard. You can read more [about scancodes here](http://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html) + +I don't know about you, but I'm thrilled! We are very close to building a simple shell. +In the next chapter, we will expand a little bit on keyboard input diff --git a/20-interrupts-timer/cpu/timer.c b/20-interrupts-timer/cpu/timer.c index 8092a9d..76314dc 100644 --- a/20-interrupts-timer/cpu/timer.c +++ b/20-interrupts-timer/cpu/timer.c @@ -9,7 +9,7 @@ static void timer_callback(registers_t regs) { tick++; kprint("Tick: "); - char *tick_ascii; + char tick_ascii[256]; int_to_ascii(tick, tick_ascii); kprint(tick_ascii); kprint("\n"); diff --git a/20-interrupts-timer/drivers/keyboard.c b/20-interrupts-timer/drivers/keyboard.c index c8fd3a3..8d1dec8 100644 --- a/20-interrupts-timer/drivers/keyboard.c +++ b/20-interrupts-timer/drivers/keyboard.c @@ -197,11 +197,14 @@ void print_letter(u8 scancode) { break; default: /* 'keuyp' event corresponds to the 'keydown' + 0x80 - * it may still be a scancode we haven't implemented yet */ - if (scancode - 0x80 <= 0x39) { + * it may still be a scancode we haven't implemented yet, or + * maybe a control/escape sequence */ + if (scancode <= 0x7f) { + kprint("Unknown key down"); + } else if (scancode <= 0x39 + 0x80) { kprint("key up "); print_letter(scancode - 0x80); - } else kprint("Unknown"); + } else kprint("Unknown key up"); break; } } diff --git a/20-interrupts-timer/kernel/kernel.c b/20-interrupts-timer/kernel/kernel.c index 70a1d13..d3b6a98 100644 --- a/20-interrupts-timer/kernel/kernel.c +++ b/20-interrupts-timer/kernel/kernel.c @@ -6,7 +6,7 @@ void main() { isr_install(); asm volatile("sti"); -// init_timer(50); + init_timer(50); /* Comment out the timer IRQ handler to read * the keyboard IRQs easier */ init_keyboard();