DixiumOS wrote:
sleephacker wrote:
Have you tried putting:
Code:
terminal_writechar("A", ...);
right at the start of your keyboard handler, or even inside the IRQ handler, just to make sure it actually gets called?
Are you sure the compiler doesn't do anything unexpected/undesired in your ISRs, such as changing the stack pointers (esp/ebp)?
I think the article about
ISRs might be of help.
Doesn't work...
Ugh, looks like I'll need to fix my IDT code.
If I could offer two pieces of advice: first, if you are using GCC for your compiler, and want to use a C function for an interrupt handler, use the
__attribute__ ((interrupt)) function attribute, rather than emitting an IRET manually. It does require a certain amount of GCC-specific and non-portable code, but since this is an interrupt handler that's hardly a concern. Take note that you will need a data structure for representing the interrupt frame, as explained in the GCC documents and the Intel manuals.
Second, you should be redirect all of the interrupt vectors to a single IDT entry rather than having several dozen which are repeating the same code. Indeed, I would recommend initializing the
entire IDT in this manner (with a default handler that issues a system initialization error message), and
then adding the actual entries you need, just as a backstop in case of a programming error.
Code:
void addisrfunctions(void) {
for (int i = 0; i < 256; i++) {
idt_set_gate(i, (unsigned)isr_default, 0x08, 0x8E);
}
// now that you have everything initialized, add the
// actual interrupt handlers to the vectors you want
}
Code:
__attribute__ ((interrupt)) void isr_default(struct interrupt_frame *frame) {
// for now, just put this as a stub that will panic
// the kernel, you can write a more elegant
// default handler later
terminal_clrscr();
terminal_writestring("Fatal error - unsupported interrupt", BLACK, WHITE, 0, 0);
panic(); // you will need to write this function, I guess
}
This is just off the top of my head; you'll need to work the details out as you you can.