IBM PC-AT‎ > ‎Windows‎ > ‎Boot Process (detailed)‎ > ‎

Phase 2 - El Torito

If the BIOS hasn't choosen another device yet (or optical disc is the first device), and the device contains a CD/DVD/Blu-Ray, then the BIOS will read a special sector from the disc.  This is sector 17 of the last session on the disc.  Note that the CD file system uses 2 kiByte sectors, so this will be at byte offset 34816 (0x8800) in the last session.   In this sector it looks for the string "EL TORITO SPECIFICATION" at offset 7 within the sector.  If not found, the BIOS should continue by checking the next device in the boot order (see Phase 1).  If it is found, the 4-byte value (dword) at offset 71 (0x47) specifies the sector of the "boot catalog."  The BIOS must then read that sector to see if the disc is bootable.  (Very few discs have an El Torito sector that are not bootable!)  The vast majority of discs have no El Torito data at all.
Details of the El Torito specification may be read in this PDF file (which seems to be the original specification).  This wikipedia article also covers the topic in a less technical / easier-to-read manner.
The "boot catalog" contains a series of 32-byte entries (up to 64 per sector).  The first entry is called the validation entry; among other things it contains a checksum and the magic value 0x55, 0xAA.  The second entry is a section header which tells how many disk entries will follow, and a flag if this is the last section.  Most discs have only one section; at least I've never seen two or more on a disc.  The third entry is usually the first/default disk entry (in theory, the third entry could be an extended header entry).  It starts at byte offset 3*32 = 96.  Multiple disk entries may be listed, each with a language ID and optionally extra information.  The BIOS may choose the first/default item, or another one if the language (or optional extra data) is "more compatible".  This might be very popular in non-English countries, but I have never seen it actually used.  Slightly off topic, because the "boot catalog" is referenced by sector number in the El Torito sector, it need not be listed in the directory.  If it is in the directory, its name is undefined by the specification.
Whichever disk entry is selected by the BIOS, byte 0 (in the disk entry) is a flag: if it is zero, the disk is not bootable and the BIOS should return to Phase 1; if the byte contains 136 (0x88) then the disk entry is bootable; no other values are defined.  Slightly off topic, if the disk entry specifies no boot and the disk type (described below) is no emulation, then the BIOS device number of the CD will be next in sequence after the last hard drive; so if there is one hard drive (drive 128) then the CD would be drive 129.  Since by definition it is non-bootable, it really shouldn't be mentioned here, except that this is noticably different from the bootable no emulation entry described below.
At this point a disk entry has been selected and it is marked as bootable.  Byte 1 (in the disk entry) is another flag which tells what type of "disk image" to emulate (if any).  Value 0 indicates no emulation; the whole CD (or at least the last session) is accessed by sector via BIOS Interrupt 19 (0x13).  Values 1, 2, and 3, indicate 1200 kiByte, 1440 kiByte, and 2880 kiByte floppy disk images, respectively.  Value 4 indicates a hard disk image that can be any size within the capacity of the optical media.  Note the high 3 bits of this byte are miscellaneous flags, so any value greater/equal to 32 should be appropriately masked (I am not going to describe bitwise ANDing here).
The "disk image" (for values 1 to 4) will be a sector-exact copy of either a floppy disk or a hard drive (complete with partition table). You may be wondering why there would be two options ("floppy disk" and "hard drive") when a "hard drive" can be any size. If El Torito specifies a "floppy disk" then the BIOS will "mount" the image on drive 0 (Windows drive A); a "hard drive" will be mounted on drive 128 (Windows drive C).  The file to mount is specified by its starting sector (a dword) at byte offset 8 in the disk entry.  Like the "boot catalog", the file need not be listed in the directory because it is referenced by sector in the disk entry.
If the disk entry byte 1 has a value of zero, "no emulation", then instead of mounting a disk image, the BIOS will load arbitrary code from the CD (found in the sector specified at byte 8) and the disk will be given an arbitrary device number between 129 and 255.  This is very open-ended and too broad to discuss here (but note the arbitrary drive number may differ from the similar no boot / no emulation case described above).
Whatever type of emulation (if any), there are two more important values in the disk entry: a load segment and a sector count.  If load segment (a 2-byte word at offset 2) is zero, the traditional (for floppy and hard disks) segment value of 0x7c0 is used.  The initial number of sectors to read is stored in a 2-byte word at offset 6.  Traditionaly this is just 1 sector.  In any case, the value refers 512-byte sectors traditionaly used by floppies and hard disks (note that other values are possible with those media, but not with El Torito).
When using a disk image, some operating systems may remap drive letters.  This is particularly troublesome when using hard disk emulation with DOS or older versions of Windows.  The Win9x series has the most troubles, as they are built on DOS.  For floppy disk emulation, some BIOSes may "forget" the real floppy drive, if the computer actually has one... this is contrary to the specification which states the real floppy should be remapped to drive 1 (Windows drive B).

Now that the start of the disk image is known, the BIOS will treat that region of the optical disc just like a normal disk, except that it is read-only. There are some drives and optical media that allow real-time re-writing of data, but I have never seen a BIOS that allows this, and I don't know if El Torito can specifiy such a feature. Anyway, the first 512 bytes of that file (at least) will be loaded from the emulated disk. Proceed to Phase 3 if a hard disk or Phase 4 if a floppy disk.

© H2Obsession 2014