Interrupts in pmode

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
david_d

Interrupts in pmode

Post by david_d »

I just started writing my own os. I have i small bootloader which kicks me into pmode and starts my kenrnel. I too have a simple printf() function. But how do i make a scanf() function? I know that i cant use bios functions in pmode.

Is there anything i have to todo beside setting up the IDT (IDTR, etc)?
Which interrupts are taken?
... and which interrupt is triggered when a key is pressed?

thanks
Tim

Re:Interrupts in pmode

Post by Tim »

To accept user input you will need to write a driver for the keyboard. To do that you'll need to install a handler for IRQ 1, which will mean setting up an IDT and remapping the hardware interrupts via the PIC so that they don't clash with Intel's reserved interrupts.
david_d

Re:Interrupts in pmode

Post by david_d »

So I just have to map interrupt 9 (IRQ01) to my own keyboard driver?
... so that they don't clash with Intel's reserved interrupts.
What do you mean by this? Are there some reserved interrupts which i cant use?
Which one are this?
Can i/(Do i have to) use Interrupt 9 for keyboard?
Tim

Re:Interrupts in pmode

Post by Tim »

Intel reserved interrupts 0 to 15 for its own use, for CPU exceptions, etc. However, when they designed the original PC BIOS, IBM put BIOS functions and hardware interrupt handlers on a lot of those interrupt numbers. A protected mode OS must be prepared to handle any of the first 16 exceptions, so you must program the PIC to move the IRQ handlers out of the way. This should be dealt with in any interrupt tutorial.
Post Reply