- The x86 BIOS: Its Limits and Capabilities
- 16- and 32-Bit Code
- The BIOS as Driver for DOS
- Modern Uses of the BIOS
- What BIOS Do You Have?
- Add-On Card BIOSs
- Video BIOSs
- Boot BIOSs for SCSI and Networking
- Additional BIOSs
- BIOS Updates
- EIDE and SCSI Hard Disk Handling
- Understanding CHS Geometry Limits
- Getting Around the 1024-Cylinder Limit
- Common BIOS Disk Utilities
- The Handoff to the OS
Understanding CHS Geometry Limits
The basic design of hard disks hasn't changed much since the early 1980s, although today's models are orders of magnitude higher in capacity and faster than those from two decades ago. The basic design of a hard disk is illustrated in Figure 3.3. Data are stored on magnetic coatings that cover one or more circular disk platters. To read or write data, the disk platters spin at high velocity (5400 to 10,000 rpm in typical drives today) and the read/write heads read the data off the disks. When a head remains stationary, it reads data from a ring-shaped portion of a platter. Because the platters are stacked on top one another, these ring-shaped areas themselves form a virtual cylinder.
Figure 3.3 Data on a hard disk can be addressed by cylinder (distance from the center), head (which platter and side), and sector (position within a cylinder).
Hard disks read and write data in discrete units of information, typically 512 bytes. Each such unit is known as a sector. On older drives, there were a fixed number of sectors per cylinder. Thus, it was natural to describe the layout of a hard disk in terms of three numbers: The cylinder (sometimes referred to as the track), the head, and the sector within a cylinder. This triplet of numbers is often referred to as the CHS address, as in cylinder 45, head 2, sector 11. On the simple hard drives of the early 1980s, using CHS addressing meant that the hard drives could use simple electronics; they did not need to decode some other addressing scheme into those three numbers. Both the PC's BIOS and assorted hard disk structures therefore express locations of data on a disk in terms of CHS addresses.
The CHS system is convenient for some very old drives, but most drives today, and even in the early 1990s, used a variable number of sectors per cylinder. This design allows more data to fit onto a disk because all other things being equal, more sectors can fit on outside cylinders than inside ones. Thus, IDE and EIDE hard drives actually lie to the computer about their geometriesthey make up geometries that allow for the correct data capacity and then quietly translate between their true capacities and what they tell the BIOS. Still, you can pretend that what an IDE drive reports to the BIOS is correct because the limits I'm about to discuss reside mostly in the BIOS, or at least in the communication between the hard disk and the computer.
Unfortunately, the PC's designers, in a day when 10MB hard disks were huge, didn't plan for hard disks as large as we have today. These programmers allocated 10 bits for the cylinder number (mirroring the size of a register in an early PC hard disk controller), 8 bits for the head number, and 6 bits for the sector number. There were two further limitations, though: First, early IDE drives themselves had limits (16, 4, and 8 bits, respectively), which effectively limited the head field to 4 bits. Second, although the sector number is 6 bits, it is numbered starting from 1 rather than 0, so one sector number is effectively lost (it's not lost from the disk itself; there's simply one fewer sector available per cylinder in the numbering scheme). Thus, there was an effective limit of 1024 (210) cylinders, 16 (24) heads, and 63 (261) sectors per cylinder. Multiply those values together, multiply the result by 512 bytes per sector, and convert to megabytes and you find that the limit on IDE hard drive size is 504MB.
In general, a megabyte in computer circles is 220 or 1,048,576 bytes. Hard drive manufacturers, however, tend to define a megabyte as 1,000,000 bytes, thus slightly inflating the apparent size of a disk for advertising purposes. (Similar differences exist for definitions of a kilobyte and a gigabyte.) I use the former definition exclusively throughout this book, but you should be aware of the difference. If you buy a hard disk that's advertised as being an 18.2GB unit, don't be surprised to see your disk partitioning software report it as 17.0GB. The disk manufacturer hasn't made a mistake, nor is this a difference between "formatted" and "unformatted" capacities, as some people seem to think; it's merely an artifact of differing definitions of what constitutes a kilobyte, a megabyte, or a gigabyte. Because of this difference, the 504MB limit is sometimes referred to as the 528MB limit. Some people mistakenly regularize the value as 512MB, which is inaccurate by any measure. n
SCSI hard disks work somewhat differently. Rather than use a CHS value, SCSI has always used a single linear address space. To interface with a PC's BIOS, though, SCSI host adapters translate the SCSI linear addressing mode into CHS values. Details differ from one SCSI host adapter to another, but most use five bits for the number of heads, and some begin numbering sectors from 0, leading to a 1GB capacity limit. Most adapters today provide options to raise these limits further, as described shortly.