Smaller ISR/IRQ Registration in the IDT

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
jzgriffin
Member
Member
Posts: 190
Joined: Tue Sep 26, 2006 1:40 pm
Libera.chat IRC: Nokurn
Location: Ontario, CA, USA
Contact:

Smaller ISR/IRQ Registration in the IDT

Post 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?
alkot
Posts: 13
Joined: Tue Nov 06, 2007 5:10 am

Post 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
jzgriffin
Member
Member
Posts: 190
Joined: Tue Sep 26, 2006 1:40 pm
Libera.chat IRC: Nokurn
Location: Ontario, CA, USA
Contact:

Post 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?
jzgriffin
Member
Member
Posts: 190
Joined: Tue Sep 26, 2006 1:40 pm
Libera.chat IRC: Nokurn
Location: Ontario, CA, USA
Contact:

Post 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);
	//}
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post 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!
Post Reply