Interrupts when switching back to real mode

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
pranavappu007
Member
Member
Posts: 91
Joined: Mon Apr 20, 2020 11:02 am

Interrupts when switching back to real mode

Post by pranavappu007 »

Hello, I am writing an OS for hobby an it doesn't support interrupts in 32-bit mode. However, I plan to implement exception handling, and maybe rewrite keyboard driver. But I'm loading my kernel from USB so using BIOS for it. I switch back to real mode for that.

But I have a doubt; If I set up a new IDT when switching to 32-bit mode, does returning to real mode automatically loads default address for BIOS IVT(00h)? If not, how to load it? Also, do I have to reload IDT(using lidt) when jumping back to 32-bit mode again?
A beginner developer/student. Likes to know stuff. Don't have an OS to put here.
alexfru
Member
Member
Posts: 1111
Joined: Tue Mar 04, 2014 5:27 am

Re: Interrupts when switching back to real mode

Post by alexfru »

pranavappu007 wrote:If I set up a new IDT when switching to 32-bit mode, does returning to real mode automatically loads default address for BIOS IVT(00h)?
No.
pranavappu007 wrote:If not, how to load it?
You use LIDT again.
pranavappu007 wrote:Also, do I have to reload IDT(using lidt) when jumping back to 32-bit mode again?
And again. Now is a good time for you to start reading the CPU documentation. The answers to most of your questions are there.
pranavappu007
Member
Member
Posts: 91
Joined: Mon Apr 20, 2020 11:02 am

Re: Interrupts when switching back to real mode

Post by pranavappu007 »

So I use lidt to load IVT and IDT. So just like IDT, you write the size of IVT which is 0x3FF and then address which is 0h and load with LIDT?
A beginner developer/student. Likes to know stuff. Don't have an OS to put here.
nullplan
Member
Member
Posts: 1790
Joined: Wed Aug 30, 2017 8:24 am

Re: Interrupts when switching back to real mode

Post by nullplan »

You know, reading the CPU documentation is actually really helpful here. It would tell you that the reset value for the IDTR has a base address of 0, yes, but a length of 65535. I have no idea how it would ever access anything past 0x3ff, since an interrupt vector is 4 bytes in real mode and there are at most 256 of those around, but that is the reset value. Indeed the CPU documentation would tell you that there is no IVT, the IVT is just what we call the IDT in real mode.
Carpe diem!
Post Reply