SSD and LBA Disk Access - multiple boot issues
I've been working on preparing MS-DOS for SSD storage in preparation for moving my own machine to SSD, and have started developing the necessary tools to do so.
What comes up as follows:
- The physical sector size is 4096 bytes.
- int13 CHS access always presents 512 byte per sector on hard disks, no matter what
- I found that int13 LBA access sometimes emulates 512 bytes per sector and this is BIOS specific.
So far, I've only been able to find a way to lay out the FAT filesystem properly on the disk without encountering alignment issues requires putting the real value into bsBytesPerSec. I pulled up the FreeDOS bootloader to make sure that my tools don't end up being completely incompatible with FreeDOS, and found the following issues:
-
The FAT12/FAT16 boot sector will fail if disk access as emulated by BIOS doesn't match the logical sector size. Quote from Wikipedia on this entry: "Bytes per logical sector; the most common value is 512. Some operating systems don't support other sector sizes. For simplicity and maximum performance, the logical sector size is often identical to a disk's physical sector size, but can be larger or smaller in some scenarios." Hard disks on CHS will always show 512 bytes per sector no matter the underlying size. Hard disks on LBA might show the actual size or might show 512 bytes per sector. Info: https://stackoverflow.com/questions/62483420/int-13h-effective-sector-size SYS.COM currently raises an error trying to prepare such a disk for booting, as it should.
-
The FAT12 boot sector blows up on 1024 bytes per sector floppy disks. This is the only case where CHS isn't 512 bytes per sector.
-
Both FAT32 boot sectors blow up for the same reason. Fixing the FAT32 CHS boot sector is essentially trivial because we can assume the real value is 512 and just do a div instruction to get number of sectors to read. If CHS emulation is in place, which is the only way the size isn't 512, then you may assume multi-sector read works!
I currently don't know if MS-DOS can handle these either. I do know that Linux has no trouble with such filesystems.
Commentary on SYS.COM's code for patching boot sectors:
SYS.COM has hardcoded patch offsets that need manual updating. I have found in my coding a very easy way to avoid having to do this is to embed the offsets into reserved regions in the asm file so that they themselves are at fixed offsets. Since you have several "free" slots in the BPB that will be overwritten with data later, you can generate your patch offsets in the ASM file and store them where the BPB goes. SYS can then read them out of there after selecting boot image but before applying the BPB to it. You may find this easier to maintain.