Page 1 of 1
Smaller ISR/IRQ Registration in the IDT
Posted: Thu Mar 06, 2008 8:05 pm
by jzgriffin
Would it be possible to cut down on the number of idt_set_gate lines from Bran's tutorial? For example, instead of passing (unsigned)isr30, you would pass (unsigned)((isr1 - isr0) * idx)? Is it possible?
Posted: Thu Mar 06, 2008 10:48 pm
by alkot
Yes, you can do that. But you have to be sure that handlers with and without pushing error code are the same size. You could possibly repeat code for all handlers with macroses if your assembler allows it.
So instead of passing (unsigned)isr30 you would pass (unsigned)isr0+(unsigned)(isr1-isr0)*30
Posted: Fri Mar 07, 2008 1:09 am
by jzgriffin
Cool, thanks. I try to keep as little stuff hard-coded apart from #define's as possible, to simplify future expansion. This will really help. There should be something like this in the wiki, shouldn't there?
Posted: Fri Mar 07, 2008 12:40 pm
by jzgriffin
My new kernel is in C++, and, well, here's a snippet from my code, it's self explanatory:
Code: Select all
// error: ISO C++ forbids using pointer to a function in subtraction
// Workaround for C++?
//for(int idx = 0; idx <= INTERRUPT_CNT; idx++) {
// IDT.SetGate(idx, (unsigned)((Interrupt1 - Interrupt0) * idx), 0x08,
// 0x8E);
//}
Posted: Sat Mar 08, 2008 8:12 am
by JamesM
Good God, that is one ugly hack. I'm glad the C++ compiler pulled that as an error not as a warning, because it's unbelievably unsafe!