Clearing interruptions in a bootloader
Posted: Thu Nov 19, 2020 11:01 am
When building a bootloader, we have to clear all the interruptions. Why do we have to do such a thing ?
The Place to Start for Operating System Developers
http://f.osdev.org/
Be like the second timer of the old PIT and refresh my memory. Did the old 8088 have a different stack or did the author of that response actually get the wording wrong?
I am guessing that they meant that the register is incremented in the direction away from the first of the stack. In reality, the incremented and decremented words should be swapped, yes?"When a word is added to the stack, the SP register is first incremented by 2..."
"A POP Instruction...then the SP register is decremented by 2".
That would me an error in that publication, correct. The one place that things differed on the processors earlier than the 80286 was how PUSH SP operated. PUSH SP on >=80286 pushed the value of SP as it was before SP was decremented by 2 where as the processors < 80286 pushed the value of SP that it was after it was decremented by 2.BenLunt wrote:Be like the second timer of the old PIT and refresh my memory. Did the old 8088 have a different stack or did the author of that response actually get the wording wrong?I am guessing that they meant that the register is incremented in the direction away from the first of the stack. In reality, the incremented and decremented words should be swapped, yes?"When a word is added to the stack, the SP register is first incremented by 2..."
"A POP Instruction...then the SP register is decremented by 2".
You have to disable interrupts during a CPU mode switch, because there is no way to change CPU mode and load IDTR in a single instruction. Therefore there will be a time between setting CPU mode and setting the IDTR during which an incoming interrupt would be misinterpreted: Either you set the IDT first, then an interrupt during real mode would read the protected-mode IDT as a real-mode IVT, or you change mode first, then an interrupt during protected mode would read the real-mode IVT as an IDT. Neither way will work. So, in theory, you could prepare an IDT, change modes, load the IDTR, and interrupts would only be disabled for two instructions. Realistically, though, without the BIOS to support you, you will only be able to re-enable interrupts once you have enumerated all interrupt controllers and disabled all their interrupts, because otherwise you will get interrupts you don't know the meaning of. All of this requires far more code than you even need for a bootloader. So in short: Interrupts get disabled because it's easier.Scorpion197 wrote:When building a bootloader, we have to clear all the interruptions. Why do we have to do such a thing ?