Page 1 of 1

Interrupt Handling

Posted: Sun Jun 19, 2005 11:00 pm
by telephone
I am very new to the OS Development arena, and am running into an issue with interrupts. Are there any good articles or samples dealing specifically with interrupt handling that aren't Linux based? As I am trying to learn from the ground up, I am certainly not interested in looking at some bloated code...

Thanks for the help!

Re: Interrupt Handling

Posted: Mon Jun 20, 2005 11:00 pm
by ManOfSteel
Hello,
Are there any good articles or samples dealing specifically with interrupt handling that aren't Linux based?
What do you mean exactly by "interrupt handling"? Calling and using interrupts? Programming interrupts in 16-bits real mode? Programming interrupts in 32-bits protected mode?
1. For the first one, it may depend on the language you use. For example, if you use assembler you are directly able to call the interrupts that already exist on your operating system using the instruction "int" followed by the interrupt number. You can check Ralph Brown Interrupt List for a complete list of interrupts (MS-DOS, BIOS, ...)
2. For the second, you will have to program the IVT (interrupt vector table) which is located at real-mode address 0.
3. For the third, you will have to program the IDT (interrup descriptor table) which can be located anywhere in your protected-mode address space. You may also try to reprogram your PIC (programmable interrupt controller) if you want (and need).
You should check the Bona Fide OSDev (http://www.osdever.net/) documents and tutorials pages in general and the document "Interrupts, Exceptions, and IDTs" in particular. If they are down you can go to Intel's website and download their programming documents ("software programming" and "system programming"). You may also find what you need with a simple google search hopefully.

Re: Interrupt Handling

Posted: Mon Jun 20, 2005 11:00 pm
by telephone
Well I have been playing with several pieces of sample C kernel code.

Basically, this is a C 32bit protected kernel. I need to figure out the best way to accept input from the keyboard.. but have found no simple examples that don't involve massive amounts of error handling or broad support.. I just want to get input from the keyboard!!

Re: Interrupt Handling

Posted: Mon Jun 20, 2005 11:00 pm
by carbonBased
You should just be able to define a handler for the keyboard interrupt (IRQ 1). Depending on where (or if) you've remapped the PIC this interrupt can be in various different locations.

Upon the interrupt, all your service handler has to do is read from (iirc) port 0x60.

That should be enough to get the base up and running.

--Jeff