Add keyboard driver.
This commit is contained in:
parent
250372de4b
commit
2ebc32c21c
24
drivers/keyboard.c
Normal file
24
drivers/keyboard.c
Normal file
@ -0,0 +1,24 @@
|
||||
#include "keyboard.h"
|
||||
#include "../cpu/isr.h"
|
||||
#include "../console.h"
|
||||
#include "port.h"
|
||||
|
||||
static const char sc_ascii[] = {
|
||||
'?', '?', '1', '2', '3', '4', '5', '6',
|
||||
'7', '8', '9', '0', '-', '=', '?', '?', 'Q', 'W', 'E', 'R', 'T', 'Y',
|
||||
'U', 'I', 'O', 'P', '[', ']', '?', '?', 'A', 'S', 'D', 'F', 'G',
|
||||
'H', 'J', 'K', 'L', ';', '\'', '`', '?', '\\', 'Z', 'X', 'C', 'V',
|
||||
'B', 'N', 'M', ',', '.', '/', '?', '?', '?', ' ',
|
||||
};
|
||||
|
||||
static void interrupt_handler(registers_t *r) {
|
||||
uint8_t scancode = port_byte_in(0x60);
|
||||
if (scancode < sizeof(sc_ascii)) {
|
||||
char string[] = {sc_ascii[scancode], '\0'};
|
||||
printk(string);
|
||||
}
|
||||
}
|
||||
|
||||
void init_keyboard() {
|
||||
register_interrupt_handler(IRQ1, interrupt_handler);
|
||||
}
|
||||
3
drivers/keyboard.h
Normal file
3
drivers/keyboard.h
Normal file
@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
void init_keyboard();
|
||||
Loading…
x
Reference in New Issue
Block a user