I'm planning to write a BIOS-based bootloader for PC systems already running DOS (MS-DOS, IBM PC DOS, FreeDOS, DR-DOS, EDR-DOS or SvarDOS). The bootloader will check that it is running in real mode, load a kernel image file to memory using DOS int 21h functions, restore interrupt vectors to BIOS defaults, explicitly reset some hardware (such as the PIC, the floppy controller, the HDD controller and the video display adapter), and jump to the operating system entry point. My question: How can the bootloader (as a DOS program) restore interrupt vectors to BIOS defaults?
One idea I had is adding a hook to BIOS reboot code at 0xffff:0, replacing the funcionality which loads the floppy boot sector or the HDD MBR with my own code which just jumps to the kernel image already loaded. Is this possible and practical?
The loadlin bootloader does something similar to my planned bootloader, but it doesn't restore the interrupt vectors (such as int 10h for video services, int 13h for disk services and int 16h for keyboard services, but also int 8 timer (IRQ0)), because loadlin loads Linux, and Linux doesn't need any BIOS interrupt vectors (because Linux doesn't call any BIOS services, and it installs its own handlers for each IRQ).
I know these workarounds (which don't meet the specification above):
- Run the bootloader before DOS is loaded, i.e. when the BIOS interrupt vectors are still in the interrupt vector table.
- Save the interrupt vectors to a file before DOS is loaded.
- Save the interrupt vectors to a file early in the DOS boot process. (biosintv.sys loaded from config.sys can do it, and loadlin can use the result.)
- Rewrite the kernel to be booted so that it doesn't need the BIOS interrupt vectors. (The Linux kernel works like this.)
- Temporarily modify a floppy boot sector, an HDD MBR or any files which are loaded when DOS boots, and then reboot by jumping to BIOS 0xffff:0.
- Hardcode the interrupt vector values of a specific BIOS version.
- Get the BIOS interrupt vectors by scanning the BIOS ROM image, recognizing patterns. (This technique is fragile, because it's BIOS-specific and BIOS-version-specific.)

Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.