IO50-AD-R1 stands for MS-DOS 5.0 IO.SYS AlternateDrive Release 1.
== ABSTRACT ==
This is a MS-DOS 5.0 IO.SYS supporting alternate boot drives, such as any primary or logical partition.
== HOW TO USE ==
DOSbootI is required to choose the boot drive.
Just set byte 0FCh to F0h+drivenum in the DOSbootI volume boot record where drivenum = 0 for A:, 2 for C:, 3 for D:, etc.
Make sure that the "hidden sectors" fields of the VBR is properly set when booting from it. Typically, logical partitions use a "hidden sectors" field that is relative to the extended partition base. You should change it to make it relative to the base of the hard drive.
== STORY ==
Did you know MS-DOS can boot on another drive than C: ?
It can boot on A: when booting on floppy!
Consequently, MS-DOS implements the concept of "boot drive". It uses the media type byte (F8h for hard drive, F0h for 1440 KiB floppies, etc.) of the BPB to choose the boot drive A: or C:. This media type byte is passed in CH by the DOS volume boot record. DOSbootI makes it possible to pass any user-defined value in CH. DOSbootI could not re-use the media type byte at 15h in the BPB because non-standard values (e.g. F2h) confuses Windows NT.
IO50-AD.SYS contains two patches.
1) One very simple patch exploiting MS-DOS capability to choose the boot drive through CH.
2) Another much longer patch requires to make it work on logical partitions. MS-DOS uses brain-damaged data structures to access logical partitions, with, not only one 32 bits hidden sectors number, but another 16 bits hidden cylinders number that's added only for logical partitions. IO.SYS loads MSDOS.SYS with a non-standard simplier FAT driver that doesn't take in account this hidden cylinder number. That's especially stupid because actually, it uses sector numbers relative to the partition base and passes these numbers to a fully-functionnal driver. The "bug" lies in the computation of the address of cluster data area, just above the root directory, which is translated from the data that was first computed in the volume boot record by removing the number of hidden sectors.
This patch cleanly computes the data area offset without any dependency on hidden sectors, simply adding FatSize*FatsCount+ReservedSectorsCount+RootDirectorySize.
Due to code size inflation, more code than expected had to be modified.
Don't worry, this patch is local. It doesn't change the size of IO.SYS. Other binary patches can be applied.

== WARNING ==
This has not been extensively tested. It has just been tested on a qemu virtual machine with a 4MB virtual hard disk.
Use at your own risk!
This has been assembled with nasm. It generates some nasty bytes such as 31C0 for xor ax,ax while most assemblers output 33C0. Moreover, nasm tends to output instructions larger than required if not explicitly told to use byte instructions. I'm going to use tasm for next version.

== TODO ==
1) Rather than using F0h as the base for drive numbers, it would be better to
use F6h so that IO50-AD-R1 can boot on C with a conventionnal volume boot record. Currently, it requires DOSbootI or causes incompatibility with Windows NT.

2) Port to other MS-DOS versions.

3) Test with second hard drive (e.g. BIOS int 13 drive 81h).
