Can we save BIOS IDT and BIOS memory early on boot?

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
nergzd723
Posts: 10
Joined: Thu Oct 24, 2019 7:01 am

Can we save BIOS IDT and BIOS memory early on boot?

Post by nergzd723 »

Can we save BIOS IDT and BIOS memory early on boot just not to lose it after going to protected mode?So then to execute bios interrupts we'll need to just load BIOS IDT and copy its memory area back to place, then return to real mode and issue an interrupt.
nullplan
Member
Member
Posts: 1794
Joined: Wed Aug 30, 2017 8:24 am

Re: Can we save BIOS IDT and BIOS memory early on boot?

Post by nullplan »

You can, or you can just ensure you don't clobber those areas in the first place. Calling a BIOS function to do something is a very bad way to do it, though. Going back to real mode means disabling your OS and passing control back to the BIOS. If you are using paging, you will have to disable that as well, so now you need an additional identity-mapped page within the first 1MB of address space. You're giving up control of the system. If an interrupt happens in that time that you actually need, you will miss it. You will need to reset all hardware into PC-compatible mode (i.e. disable APIC, map the PIC back to interrupts 8-F and 70h-77h or whatever it was).

Alternatively to that, if you are writing a 32-bit OS, you can just use VM8086 mode to run the BIOS interrupt. It is a bit more work. Or, if you are writing a 64-bit OS, or you don't like VM8086 mode, you can interpret all the opcodes you need. Whatever works for you. Though all of these seem more work to me than to just write a driver yourself.
Carpe diem!
Post Reply