What to do for Interrupts?

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
OSMAN

What to do for Interrupts?

Post by OSMAN »

Hi.

When the interrupts are on, and an interrupt is coming, what should I do?
What are the ports the interrupts are coming from?
When an int. interrupts the kernel, what is the address of the table (or is it in PIC) where the CPU checks the address to jump to resume executing?

Is the PIC (or whatever Interrupt Circuit was it) the thing where this interrupt ID-table exists?

If all this is wrong, tell me what's right.

Can I do all this whith outportb() and inportb() of the asm?

As you see, I'm just at the beginning, but try to be patient; I've got to start somewhere!

(By the way, where is the list of all the ports?)
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re:What to do for Interrupts?

Post by Brendan »

Hi,
OSMAN wrote:When the interrupts are on, and an interrupt is coming, what should I do?
Nothing - wait until it arrives!
OSMAN wrote:What are the ports the interrupts are coming from?
The interrupt doesn't come from ports, it comes from a device. Each device uses different IO ports (if any), one or more IRQs (if any) and one or more memory regions (if any).

To figure out which of these resources correspond to a particular device you'd need to first figure out what devices are present, and then figure out what resources each device is currently configured to use. For example, the resources used by a PCI sound card normally depend on everything else that's in the computer (it's resources can't be pre-determined).

For some legacy devices you can just assume (like the PIT, PIC, etc). For everything else you need to scan buses, and/or examine plug & play information from the BIOS, and/or rely on ACPI information.
OSMAN wrote:When an int. interrupts the kernel, what is the address of the table (or is it in PIC) where the CPU checks the address to jump to resume executing?
The address of the code that the CPU uses to handle an interrupt is determined by the IVT ("Interrupt Vector Table", which is only used in real mode) or the IDT ("Interrupt Descriptor Table", which isn't used in real mode).
OSMAN wrote:Is the PIC (or whatever Interrupt Circuit was it) the thing where this interrupt ID-table exists?
The "Programmable Interrupt Controller" doesn't contain the IVT or IDT (these tables exist in RAM). Instead it determines which interrupt number to use for each it's input lines. The PIC input lines are connected to other devices, so that if a device wants attention it puts a signal on it's "interrupt output line" which is connected to one of the PIC's input lines, then the PIC decides if the input should be ignored. If it's not ignored, the PIC then works out what interrupt number to send to the CPU.
OSMAN wrote:Can I do all this whith outportb() and inportb() of the asm?
Definately not. At an absolute minimum you could get by with several small routines in inline assembly (as long as you let other people do some of the tricky bits for you, like using GRUB instead of switching to protected mode yourself).
OSMAN wrote:(By the way, where is the list of all the ports?)
There is no "list of all ports" as they vary, but there is a good partial list of IO ports that have fixed/common usage (and a list of common memory locations, common real mode interrupts, common CMOS locations, etc). To get this set of lists, go here:
http://www.cs.cmu.edu/afs/cs/user/ralf/ ... files.html

After you've downloaded it all and got it ready you should have a text file called "PORTS.LST" which is best viewed with one of the utilities designed for the purpose (I prefer "rbilview.exe" on Windows, but that's just me).


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Post Reply