I am trying to write a basic keyboard driver and I am only getting one keypress that prints the character correctly onto the screen and I do not see any output on the screen for subsequent keypresses..its like the system becomes unresponsive. Please help.
Code: Select all
SET_IDT_ENTRY(idt[33],keyboard);Code: Select all
void keyboard(){
asm( "cli;"
"call keyboard_handler;"
"iret;");
}Code: Select all
char kbdus[] =
{
0, 27, '1', '2', '3', '4', '5', '6', '7', '8', /* 9 */
'9', '0', '-', '=', '\b', /* Backspace */
'\t', /* Tab */
'q', 'w', 'e', 'r', /* 19 */
't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', /* Enter key */
0, /* 29 - Control */
'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', /* 39 */
'\'', '`', 0, /* Left shift */
'\\', 'z', 'x', 'c', 'v', 'b', 'n', /* 49 */
'm', ',', '.', '/', 0, /* Right shift */
'*',
0, /* Alt */
' ', /* Space bar */
0, /* Caps lock */
0, /* 59 - F1 key ... > */
0, 0, 0, 0, 0, 0, 0, 0,
0, /* < ... F10 */
0, /* 69 - Num lock*/
0, /* Scroll Lock */
0, /* Home key */
0, /* Up Arrow */
0, /* Page Up */
'-',
0, /* Left Arrow */
0,
0, /* Right Arrow */
'+',
0, /* 79 - End key*/
0, /* Down Arrow */
0, /* Page Down */
0, /* Insert Key */
0, /* Delete Key */
0, 0, 0,
0, /* F11 Key */
0, /* F12 Key */
0, /* All other keys are undefined */
};Code: Select all
void keyboard_handler(long exceptionNum)
{
outportb_1(0x20,0x20);
int a;
uint32_t scancode;
uint8_t keychar;
scancode = inportb_1(0x60);
a = inportb_1(0x61);
// check if a key was just released
if(!(scancode & 0x0080)) //key pressed
{
keychar = kbdus[scancode];
putch(keychar);
}
outportb_1(0x61, a|0x80);
outportb_1(0x61,a);
send_eoi(1);
asm("sti;");
}
Code: Select all
void keyboard_init(void)
{
printf("Initializing Keyboard... \n");
enable_irq(1);
}Code: Select all
pic_init();
keyboard_init();
enable_irq(2);//slave pic

