Skip to content

Commit 5aaabf1

Browse files
committed
lesson 20 finished: timer + keyboard
1 parent 46094a0 commit 5aaabf1

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

20-interrupts-timer/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ created with the definitions.
3434
`keyboard.c` also has a long table to translate scancodes to ASCII keys. For the time
3535
being, we will only implement a simple subset of the US keyboard. You can read
3636
more [about scancodes here](http://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html)
37+
38+
I don't know about you, but I'm thrilled! We are very close to building a simple shell.
39+
In the next chapter, we will expand a little bit on keyboard input

20-interrupts-timer/cpu/timer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ static void timer_callback(registers_t regs) {
99
tick++;
1010
kprint("Tick: ");
1111

12-
char *tick_ascii;
12+
char tick_ascii[256];
1313
int_to_ascii(tick, tick_ascii);
1414
kprint(tick_ascii);
1515
kprint("\n");

20-interrupts-timer/drivers/keyboard.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,14 @@ void print_letter(u8 scancode) {
197197
break;
198198
default:
199199
/* 'keuyp' event corresponds to the 'keydown' + 0x80
200-
* it may still be a scancode we haven't implemented yet */
201-
if (scancode - 0x80 <= 0x39) {
200+
* it may still be a scancode we haven't implemented yet, or
201+
* maybe a control/escape sequence */
202+
if (scancode <= 0x7f) {
203+
kprint("Unknown key down");
204+
} else if (scancode <= 0x39 + 0x80) {
202205
kprint("key up ");
203206
print_letter(scancode - 0x80);
204-
} else kprint("Unknown");
207+
} else kprint("Unknown key up");
205208
break;
206209
}
207210
}

20-interrupts-timer/kernel/kernel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ void main() {
66
isr_install();
77

88
asm volatile("sti");
9-
// init_timer(50);
9+
init_timer(50);
1010
/* Comment out the timer IRQ handler to read
1111
* the keyboard IRQs easier */
1212
init_keyboard();

0 commit comments

Comments
 (0)