how are ISRs invoked in this OS project?

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
fairy21
Posts: 2
Joined: Thu Mar 21, 2024 3:41 am
Libera.chat IRC: fairy21

how are ISRs invoked in this OS project?

Post by fairy21 »

Hello,

I follow along a tutorial on writing an operating system. Currently I do not understand how the interrupt routines are called. By that I mean the

Code: Select all

HandleInterruptRequest 0x??
- functions are mapped in the

Code: Select all

interrupstubs.s
file but I do not see any place in the

Code: Select all

kernel.cpp
-

Code: Select all

kernelMain()
where they are called as a response to an interrupt. Neither is the interrupt number pushed into the

Code: Select all

(interruptnumber)
-variable in the

Code: Select all

interrupstubs.s
code.
Does an interrupt automatically issue an IRQ to the CPU? but how is the interrupt number then fetched from the PIC-buffer and placed in the

Code: Select all

(interruptnumber)
variable? how is the ISR then called when it is nowhere done in this code?

This is the video series on the tutorial https://www.youtube.com/watch?v=SQBBetL ... tingSystem
This is the source code after a bit of recfarctoring https://github.com/AlgorithMan-de/wyoos ... 8fbddfb687

Thank you for taking the time to answer!
Octocontrabass
Member
Member
Posts: 5560
Joined: Mon Mar 25, 2013 7:01 pm

Re: how are ISRs invoked in this OS project?

Post by Octocontrabass »

fairy21 wrote:Does an interrupt automatically issue an IRQ to the CPU?
Other way around. When enabled, an interrupt request (IRQ) will interrupt the CPU.
fairy21 wrote:but how is the interrupt number then fetched from the PIC-buffer and placed in the

Code: Select all

(interruptnumber)
variable?
It isn't. The CPU fetches the interrupt vector from the PIC and then jumps to the address in the IDT entry for that vector. Each IDT entry contains a different address, and all of those addresses point to little code snippets that place a different value in that variable before jumping to the int_bottom label. The author of this code has chosen to use values that are equal to the interrupt vector, but they could have used any values. (By the way, you can't do multiprocessing if you use a variable like this. It's better to push the number directly onto the stack.)
fairy21 wrote:how is the ISR then called when it is nowhere done in this code?
The addresses of the ISRs are written into the IDT so the CPU can call them in response to an interrupt.

Be careful with tutorials, they tend to be buggy.
Post Reply