Below is the code I put in to my handler instead of my usual code, for debugging purposes.
Code: Select all
void _handle_keyboard() {
// Send EOI to PIC
send_eoi(KEYBOARD_IRQ_PIN);
// Read and print value from 60h
printf("%#x ", inb(KEYBOARD_IN_PORT));
printf("%#x\n", inb(KEYBOARD_IN_PORT));
}
Here is the code I use to initialize the keyboard. This is where I added commands to disable translation and set the scan code set when debugging (code not shown for those settings).
Code: Select all
// Initialization function
int init_keyboard() {
// Disable interrupts
uint32_t flags;
cli_and_save(flags);
// Route interrupts to handler
if(set_int(KEYBOARD_IRQ_PIN, _handle_keyboard)) return -1;
// Intialize state
device_state.r_shift = 0;
device_state.l_shift = 0;
device_state.caps = 0;
device_state.alt = 0;
device_state.status = FREE;
device_state.enable = ENABLED;
// Enable interrupts on the proper pin
enable_irq(KEYBOARD_IRQ_PIN);
// Restore flags, enable interrupts
restore_flags(flags);
sti();
return 0;
}