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.
[BITS 32]???; Protected Mode
[global setup_handlers]???; called by an extern function
[extern idt]
setup_handlers:
???; ok, let's just do it...
???; set up different interrupt handlers
???; all ISRs are defined in kernel/ints.asm
???; interrupts are still disabled (good)
???
???; IRQ1 (keyboard)
???extern int_irq1
???push ebx???; save
???push edx???; registers
???
???mov ebx, 0x21???; the interrupt number
???shl ebx, 3???; need to multiply by 8
???mov edx, [idt]???; address of IDT to edx
???mov [edx + ebx], dword int_irq1???; interrupt service routine
???pop edx???; restore
???pop ebx???; registers
???ret
Whatever5k wrote:I'm specially wondering, if the instructions
mov edx, [idt]???; address of IDT to edx
???mov [edx + ebx], dword int_irq1???; interrupt service routine
are correct. I think they are, but I need to be sure
OK, the code looks good but a IDT entry is 8 bytes long, this means that all you are putting in the entry is the handler address, which is only half of the entry. Also, the handler address is spread out in two places. This is what an entry looks like:
0:1 - Loword of the Handler Address
2:3 - GDT Descriptor to use for the Handler
4:5 - Attributes
6:7 - Hiword of the Handler Address
Yeah, I managed it...
But now, I have another problem: I want to create a function, that is called from a C function. This function sets up a new Interrupt Handler for a secified interrupt...
Look at the code:
The int_irq1 prints the message "IRQ1" on the screen...
When I link this and run bochs, there's no error message, but there's no "IRQ1" message printed if I press a key...
What is wrong?
Oh my god, it's terrible...
When I compile and link this and run bochs with GRUB, it sometimes work but sometimes not...
This is impossible!!!
I think it's GRUB who is wrong...because I overwrote GRUB once, and now had to install GRUB again...but I cannot really manage it..
I've copied stage1 and stage2 to /dev/floppy, but I think I have to do more...
HElp!