Detecting if an Interrupt was triggered by an IRQ, Exception

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
Perica
Member
Member
Posts: 454
Joined: Sat Nov 25, 2006 12:50 am

Detecting if an Interrupt was triggered by an IRQ, Exception

Post by Perica »

..
Last edited by Perica on Sun Dec 03, 2006 9:02 pm, edited 2 times in total.
Chris Giese

Re:Detecting if an Interrupt was triggered by an IRQ, Except

Post by Chris Giese »

If you have a syscall software interrupt, use a ring 3 gate for it (access byte = 0xEE), but make every other gate ring 0 (access byte = 0x8E). User code (running at ring 3) that tries to use an illegal INT instruction will cause a general protection fault instead.
Perica
Member
Member
Posts: 454
Joined: Sat Nov 25, 2006 12:50 am

Re:Detecting if an Interrupt was triggered by an IRQ, Except

Post by Perica »

..
Last edited by Perica on Sun Dec 03, 2006 9:02 pm, edited 1 time in total.
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:Detecting if an Interrupt was triggered by an IRQ, Except

Post by distantvoices »

If i were you, perica, I wouldn't care about THIS detection stuff. You as the developer take care of which Interrupts are triggered by what.

The IRQ-Lines of the pics trigger int - commands which refer to IDT entries you tell them to refer to.

Further more it is your task to HIDE hardware interrupts from other layers of the OS as much as possible: only the hardware drivers are to meddle with them.

Exceptions... where they come from, this is also known. I emphase KNOWN, becouse you program it.

The software interrupts: These are called by runtime library, so You als know where they come from. You sy how it works, and the computer does it. Chris Giese is right. Work with ring 3 -> ring 0 transitions through call gates/int gates. I suppose this way: have segments for code/data for the kernel, and segments for code/data for user programs - so called user space.

stay safe and don't get confused with this detection stuff.
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Detecting if an Interrupt was triggered by an IRQ, Except

Post by Pype.Clicker »

Perica Senjak wrote:
Chris Giese wrote: If you have a syscall software interrupt, use a ring 3 gate for it (access byte = 0xEE), but make every other gate ring 0 (access byte = 0x8E). User code (running at ring 3) that tries to use an illegal INT instruction will cause a general protection fault instead.
I don't think that would work, since Ring 3 Code can acess an Interrupt executing at Ring 0 (Am i right?);
No. You're wrong. It *will* work.
The level at which the IRQ handler will be running is defined by the RPL for the code segment in your interrupt descriptor. The Descriptor Priviledge Level of the interrupt gate (as the task gate, the fault gate, etc). Tells the processor the requested level in order to call the interrupt by software. So if the DPL field of INT 0x0E is 1, only code at level 0 or 1 will be able to issue a INT 0x0E interrupt. Any other code that try to do this will be intercepted by the CPU and trigger a General Protection Fault.

If you don't believe me, check the Intel Manual ...
Post Reply