Boot floppy without BIOS disk services
Posted: Sat Dec 07, 2019 3:11 pm
Over at Stack Overflow, someone asked about loading additional sectors from a floppy without using the BIOS disk services. Well, curiosity got me and I had to try. (Actual code is here)
The trick wasn't to simply read more sectors from the disk, this would have been easy. The trick was to do it without assuming anything about the hardware. Granted, I have to assume the first controller and the first drive on the controller, but other than this, all remaining must be not assumed.
For example:
- I reset the controller
- Receive/Send all four Sense Interrupts
- Send the Specify command
- Seek to Cylinder 0
- Set up the DMA, and finally:
- Read a sector from the disk
All within the first 512 bytes, all without using the BIOS disk services.
I had to try it, and found out that it is actually possible. The current code needs a little work. For example, I currently don't wait 2 seconds for the disk to spin up, but it should already be spinning since the BIOS just loaded the first sector. The code needs to be cleaned up a little and a more accurate delay needs to be found, but it does show that it can be done.
It runs on Bochs and QEMU just fine. (So that you don't have to build it, the 1.44meg image is available on the github link shown above.)
It was a fun little experiment and I thought others here might be interested in seeing it.
Ben
- http://www.fysnet.net/osdesign_book_series.htm
The trick wasn't to simply read more sectors from the disk, this would have been easy. The trick was to do it without assuming anything about the hardware. Granted, I have to assume the first controller and the first drive on the controller, but other than this, all remaining must be not assumed.
For example:
- I reset the controller
- Receive/Send all four Sense Interrupts
- Send the Specify command
- Seek to Cylinder 0
- Set up the DMA, and finally:
- Read a sector from the disk
All within the first 512 bytes, all without using the BIOS disk services.
I had to try it, and found out that it is actually possible. The current code needs a little work. For example, I currently don't wait 2 seconds for the disk to spin up, but it should already be spinning since the BIOS just loaded the first sector. The code needs to be cleaned up a little and a more accurate delay needs to be found, but it does show that it can be done.
It runs on Bochs and QEMU just fine. (So that you don't have to build it, the 1.44meg image is available on the github link shown above.)
It was a fun little experiment and I thought others here might be interested in seeing it.
Ben
- http://www.fysnet.net/osdesign_book_series.htm