Can we save BIOS IDT and BIOS memory early on boot?
Can we save BIOS IDT and BIOS memory early on boot?
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.
Re: Can we save BIOS IDT and BIOS memory early on boot?
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.
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!