9

A small preface: the XT wire HDD interface had limits of 1024 cylinders, 16 heads and 63 sectors. But the BIOS calls (int 13h with AH = 02, 03, 08) provided different limits: 1024 cylinders (CL[7:6]<<8|CH), 256 heads (DH) and 63 sectors (CL[5:0]). Later, again, the on-the-wire sizes invented with ATA were 65536 cylinders, 16 heads and 255 sectors. As result, reaching the maximum common size (1024x16x63, 504MiB/528MB) BIOSes had to invent a geometry translation level.

(The question is updated here, thanks to answerers. I missed that the XT interface was more limited, so added it later. But this does not change the body of wondering.)

Seeing it in retrospect, the strangest thing here is the head limit. This was the time of extremely outrush hardware development, with rates much higher than nowadays. But I canʼt imagine a disk device with 128 magnetic plates: this is impossible both from the current viewpoint and from the technical level of the 1970-80s. (The most radical HDD Iʼve observed was a 6ʺ 10GB disk produced in 1996 with 14 plates. Most others have up to 4 plates.) Instead, it was much easier to imagine more sectors per track; thousands wouldnʼt have been unreasonable.

So, the question: why (and by whom) were these limits selected during development of the IBM PC BIOS? What factors have led to this irrational decision?

(PS: There are more strangenesses here: fitting to 24 bits instead of 28; sector addresses starting with 1 instead of 0. But I can imagine rational reasons for them, unlike this head number range.)

NB: from the book "IBM PC XT technical reference", first edition (Jan 83), page A-84 (BIOS listings, int 13h): retyping by me:

REGISTERS USED FOR FIXED DISK OPERATIONS
(DH) - HEAD NUMBER (0-7 ALLOWED, NOT VALUE CHECKED)
(CH) - CYLINDER NUMBER (0-1023 ALLOWED, NOT VALUE CHECKED)(SEE CL)
(CL) - SECTOR NUMBER (1-17, NOT VALUE CHECKED)
NOTE: HIGH 2 BITS OF CYLINDER NUMBER ARE PLACED
IN THE HIGH 2 BITS OF THE CL REGISTER
(10 BITS TOTAL)

As geometry translation came into effect after 1990, I donʼt see any relation with it.


Seems getting a first step to the solution: as @StephenKitt suggested, in the head number byte, the upper 4 bits were reserved for the drive number in floppy and XT HDD variants, but became free in the AT variant. Then BIOS started "automatically" assuming the head number was expandable to 8 bits due to the available room. Tangled, but, at least just for me, looks pretty plausible. Thanks to @Justme as well for pointing out the XT interface details.

I am uncertain more details could be found out here.

7
  • 6
    If memory serves, it was originally just CL = sector, CH = cylinder, DH = head. Then they ran out of cylinders, so they "stole" a couple bits from CL as upper bits for the cylinder. They could have stolen bits from DH for more cylinders, but about then somebody had the bright idea of virtualizing it with a translation layer, so which bits in which register were supposed to be for head/cylinder/sector no longer really mattered. Commented Oct 21 at 7:26
  • Damn, @JerryCoffin, that's the answer. And it was very interesting. I didn't know about the translation layer. I always wondered how they could keep packing all that address space into those cylinder parameters! Post it as the answer. Commented Oct 21 at 7:52
  • @JerryCoffin Iʼve got PC XT technical reference Jan83 edition. It already lists the same scheme as later - 2 bits for high cylinder number stolen from sector number (CH). This was almost ten years before the first translation would got needed. So I guess relation to geometry translation is not relevant here.
    – Netch
    Commented Oct 21 at 7:53
  • I saw the specifications for putting the last two bits of cylinder in the top two bits of DH; but most systems went the other way and remapped the geometry.
    – Joshua
    Commented Oct 21 at 17:08
  • 1
    "I canʼt imagine a disk device with 128 magnetic plates". The head count per plate is not necessarily limited to two. Fixed-head disks with many heads per plate were a thing.
    – John Doty
    Commented Oct 21 at 17:58

2 Answers 2

11

The API dates back to the original IBM PC, and its floppy disk support. Quoting the 5150’s BIOS listing:

REGISTERS FOR READ/WRITE/VERIFY/FORMAT
(DL) - DRIVE NUMBER (0-3 ALLOWED, VALUE CHECKED)
(DH) - HEAD NUMBER (0-1 ALLOWED, NOT VALUE CHECKED)
(CH) - TRACK NUMBER (0-39, NOT VALUE CHECKED)
(CL) - SECTOR NUMBER (1-8, NOT VALUE CHECKED)

This mapped neatly to the drive interface, which had eight data lines, and transmitted head, track/cylinder, and sector/record numbers one at a time using all eight lines.

When hard disk support was added in the XT, more than 255 cylinders were needed: supported drive types used either 306 or 375 cylinders. To preserve the existing API as far as possible, the extra bits needed were stolen from the sector number. This matches the hardware interface: the controller expects the drive number (one bit), the head number (five bits), the two high cylinder bits, the sector number (six bits), and the eight low cylinder bits, in that order (see page 1-185 if the April 1983 PC XT Technical Reference).

The updated controller interface suggests that the choice wasn’t as simple as “head or sector” when looking for extra bits for the cylinder. The floppy disk controller used three bits in one byte before the cylinder number to encode the head number (one bit) and the drive selection (two bits). With hard drives, the number of heads increased, and the byte was restructured but still served the same purpose: select the drive and head. There were two unused bits which could have been used for the cylinder, but perhaps it was felt safer to keep some spare capacity there to increase the number of supported drives at some point.

In this way, the same BIOS service API could be used for floppy disks and hard disks, without changing any floppy disk code.

Incidentally, the relevant hardware “standard” isn’t ATA, it’s ST-412 since that’s what the XT used.

4
  • 2
    Well, the important thing in your answer is that ATA geometry came later than XT. I missed this initially. But all this doesnʼt answer why XT developers stole bits from the sector number, which was much more plausible to grow, than from the head number. Your supposition about CH + CL looks weird because cylinder hadn't got a contiguous range of bits in CX.
    – Netch
    Commented Oct 21 at 8:47
  • 3
    Right, it was only based on proximity in the register. The controller interface is more important, see my updated answer. Commented Oct 21 at 9:13
  • I will also add here that I agree that the interface comes from how the values are communicated to the Xebec-made XT disk controller MCU, which was adaptable to any protocol. But was it IBM who told Xebec they wanted this specific protocol, or did Xebec suggest it or have it already implemented in another host controller and IBM started to use it. Hard to know.
    – Justme
    Commented Oct 21 at 16:30
  • @Justme indeed, this just moves the question further down the stack, it doesn’t identify the underlying reasoning (beyond speculation about the roles attached to each byte). Commented Oct 21 at 17:54
8

Short version : The reason why cylinder and sector are combined the way they are into single word in register CX is that the Xebec hard drive controller chipset used on XT hard drive controller card wants the cylinder and sector in that format natively as two bytes, so it was easiest to use the same exact format on the hard drive BIOS INT13h interface. It has nothing to do with any geometry translation that might be required in the future.

The IBM PC 5150 BIOS was developed when the machine only had provision for floppies and no hard drives.

In the first BIOS revision the inputs to the diskette subsystem INT 13h were head number in DH, track/cylinder number in CH, and sector number in CL.

The values were not checked to be within range, but it was documented that head numbers were only 0 and 1, track number from 0 to 39 for 40 tracks, and sector number being from 1 to 8.

The first hard drives appeared later on IBM 5160 PC/XT and the first drives were 10MB, with parameters of 306 cylinders, 4 heads, and 17 sectors per track. The XT hard drive adapter had a separate hard disk BIOS which hooked the INT 13H to provide hard disk as drive 80h and as a fallback for other drives called the motherboard BIOS for handling floppies. But as 306 does not fit to 8 bits for cylinders in CH, it is clear that in this scenario the CL and CH were already used together for combined cylinder/head. The XT drive register interface supported 32 heads, 64 sectors, and 1024 cylinders based on bits reserved for them. The drive controller registers use the format where head number is one byte, and the cylinder high bits are shared with sector number. So the controller hardware defined the new usage for combined cyl/sector in CX, as it was the easiest to use same format. The documented interface uses 17 sectors, 1024 cylinders, and 8 heads, even though all 8 bits are reserved for head number.

ATA was not invented yet as it came with the PC/AT, as ATA stands for AT Attachment. The BIOS interface did not change from XT, but as hardware interface, the first ATA version limited drive head count to 16, cylinder value to 1024 even if whole word register is reserved for it, and sectors can be up to 255 as whole byte is reserved for it. Later ATA standards expanded to more cylinders, but head count did not change.

It took years before hard drives exceeded the combined BIOS cylinder and ATA head limit of 504MiB and CHS translation was needed to present a virtual geometry with less than 1024 cylinders while expanding the head count above 16, or LBA.

6
  • Well, the important thing in your answer is that ATA geometry came later than XT. I missed this initially. But all this doesnʼt answer why XT developers stole bits from the sector number, which was much more plausible to grow, than from the head number.
    – Netch
    Commented Oct 21 at 8:46
  • @Netch The XT hard drive controller wants the sector and cylinder bytes to be written in that format. I will add that to the answer.
    – Justme
    Commented Oct 21 at 9:00
  • So do you mean this was from hardware designers which selected the simplest way they saw, but BIOS guys avoided then to repack the values?
    – Netch
    Commented Oct 21 at 9:04
  • 1
    @Netch Sort of. I mean they use Xebec chipset as hard drive controller, and the Xebec chipset wants the sector and cylinder data in that specific two byte format, and hard drive BIOS then uses that same two-byte format to avoid conversion/repacking of the values. Less moving data around that way, more moving data around if done in other way.
    – Justme
    Commented Oct 21 at 9:19
  • 1
    @Netch actually, these answers might not answer your question - I simply stated the Xebec controller used this notation for writing CHS data, but why the notation is like that is still unknown. The Xebec controller has it's own Z80 CPU which made it an easily adaptable hard drive interface for any machine, so the protocol between BIOS and the Z80 code could have been anything. Maybe it existed in same form already in some other machine and it fit the BIOS interface without modifications, maybe IBM engineers asked Xebec how to best adapt their current BIOS API, who knows.
    – Justme
    Commented Oct 21 at 15:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .