OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Mar 29, 2024 4:42 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: How to find if an interrupt generated by the program or not?
PostPosted: Wed Sep 20, 2017 10:24 am 
Offline
Member
Member
User avatar

Joined: Sat May 20, 2017 1:25 am
Posts: 51
Location: PCI bus: 3, slot: 9, function: 5
Is there an fast way to find if an interrupt has been generated by the program, the cpu or the LOCAL APIC?
I thought to "pop" the first stack value and test if the point that the value points (program EIP) is equal to 0xCD (int instruction in binary).
Do there exist also a way to block code that runs on ring 3 execute the specific interrupt (if do to generate #GP)?

_________________
How people react when a new update of your OS is coming:
Linux user: Cool, more free stuff!
Mac user: Ooh I have to pay!
Windows user: Ah not again!


Top
 Profile  
 
 Post subject: Re: How to find if an interrupt generated by the program or
PostPosted: Wed Sep 20, 2017 12:36 pm 
Offline
Member
Member

Joined: Thu May 17, 2007 1:27 pm
Posts: 999
If you're using the local APIC, you can check its ISR register to see if the interrupt is hardware generated. You can also do that for the legacy PIC, however it is not advisable to do so, as reads from the PIC need to go through the system bus and chipset and are much slower than reads from the APIC.

Checking the instruction is not sound as an hardware IRQ might trigger at an "int" instruction boundary.

The IDT has bits that determine the privilege level that is require to invoke each vector using the "int" instruction. The CPU itself only generates faults (i.e. vector number < 32).

_________________
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], DotBot [Bot] and 107 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group