Extended CHS ECHS by swenthomasovelil


									                           Extended CHS (ECHS) / Large Mode

Cylinder-head-sector, also known as CHS, was an early method for giving addresses to
each physical block of data on a hard disk drive. In the case of floppy drives, for which
the same exact diskette medium can be truly low-level formatted to different capacities,
this is still true. Though CHS values no longer have a direct physical relationship to the
data stored on disks, pseudo CHS values which can be translated by disk electronics

Extended CHS, also called ECHS or large mode in some BIOS’s, uses BIOS translation
to get around the 504 MiB size barriers inherent in standard CHS mode. It's kind of
amusing to realize this, but the BIOS translation that is usually used to get around the 504
MiB barriers is not a great innovation of any sort. In fact, it's basically a hack. : It's a trick
that is employed to get around a problem.

The idea behind translation is as follows. Recall that the 504 MiB barrier is a
combination of the limitations of the IDE/ATA standard and the BIOS Int 13h routines,
due to the different limits they place on the numbers of cylinders, heads and sectors
allowed for a drive. This table shows how the 504 MiB barrier comes about:

                        Maximum        Maximum        Maximum           Maximum
                        Cylinders       Heads          Sectors          Capacity

     IDE/ATA              65,536          16             256             128 GiB

   BIOS Int 13h           1,024           256             63             7.88 GiB

                          1,024           16              63             504 MiB
 (Smaller of Each)

As you can see, the IDE/ATA standard allows for many more cylinders than the BIOS
does, and the BIOS allows for many more heads than IDE/ATA does. (In practice, no
IDE/ATA hard disk ever specifies more than 63 logical sectors--despite the theoretical
limit of 256--for the exact reason that the BIOS's limit is 63. If they did go over 63, this
would confuse matters even more). Again, remember that these are logical disk
parameters, not physical ones.

BIOS translation works by having the BIOS act as a "middleman" of sorts between the
IDE/ATA hard disk and the standard BIOS Int 13h, and by taking advantage of the fact
that one standard allows more heads than the other but fewer cylinders. The BIOS takes
the logical geometry that the hard disk specifies according to the IDE/ATA standard, and
translates it into an equivalent geometry that will "fit" into the maximums allowed by the
BIOS Int 13h standard. This is done by dividing the number of logical cylinders by an
integer, and then multiplying the number of logical heads by the same number. The
technique is sometimes called bit shift translation (since the multiplication and division is
done by shifting the cylinder and head bits).

This is hard to understand, so here is an example (you may find referring to the table
immediately below helpful when reading this). Let's take the case of a 3.1 GB Western
Digital Caviar hard drive, AC33100. This drive actually has a capacity of 2.95 binary
GB, and logical geometry of 6,136 cylinders, 16 heads and 63 sectors. This is well within
the bounds of the IDE/ATA limitations, but exceeds the BIOS limit of 1,024 cylinders.
The BIOS picks a translation factor such that dividing the logical number of cylinders by
this number will produce a number of cylinders below 1,024. Usually one of 2, 4, 8, or 16
are selected; in this case the optimal number is 8. The BIOS then divides the number of
cylinders by 8 and multiplies the number of heads by 8. This results in a translated
geometry of 767 cylinders, 128 heads and 63 sectors. The capacity is of course
unchanged, and the new geometry fits quite nicely into the BIOS limits:

                             Cylinders         Heads         Sectors      Capacity

    IDE/ATA Limits            65,536             16            256        128 GiB

   Hard Disk Logical
                               6,136             16            63         2.95 GiB

BIOS Translation Factor     divide by 8     multiply by 8       --           --

    BIOS Translated
                                767             128            63         2.95 GiB

  BIOS Int 13h Limits          1,024            256            63         7.88 GiB

The BIOS presents the translated geometry to the operating system and application, and
as far as basically every piece of software in the PC is concerned, the hard disk really has
767 cylinders, 128 heads and 63 sectors. Whenever the operating system or an
application wants to use BIOS Int13h calls, they use this geometry. The BIOS, when it
executes its disk access routines, translates back to the real logical geometry used by the
hard disk before sending its request to the disk. The result is that everyone is happy, and
there is a minor amount of extra work for the BIOS to do, but not very much.

Extended CHS or large mode are important to understand, but in practice are not that
frequently used. Instead, LBA mode is more popular; it is similar in concept but does the
translation differently. It is described in the next section.
                            Logical Block Addressing (LBA)

Regular addressing of IDE/ATA drives is done by specifying a cylinder, head and sector
address where the data that is required resides. Extended CHS addressing adds a
translation step that changes the way the geometry appears in order to break the 504 MiB
barrier, but the addressing is still done in terms of cylinder, head and sector numbers
(they are just translated one or more times before they get to the actual disk itself).

In contrast, logical block addressing or LBA involves a totally new way of addressing
sectors. Instead of referring to a cylinder, head and sector number, each sector is instead
assigned a unique "sector number". In essence, the sectors are numbered 0, 1, 2, etc. up to
(N-1), where N is the number of sectors on the disk. An analogy would be as follows.
Your address (assuming you live in the U.S. and have a regular address) is composed of a
street number, street name, city name and state name. This is similar to how conventional
CHS addressing works. Instead however, let's say that every house in the U.S. were given
a unique identifying number. This would be more how LBA works.

In order for LBA to work, it must be supported by the BIOS and operating system, but
since it is also a new way of talking to the hard disk, the disk must support it as well. All
newer hard disks do in fact support LBA, and when autodetected by a BIOS supporting
LBA, will be set up to use that mode.

A drive using LBA is not subject to the 504 MiB disk size barrier, however there has
been a great deal of confusion regarding LBA and what it does. In particular, a lot of
people think that it is the LBA addressing that "gets around the 504 MiB barrier". Strictly
speaking, this is inaccurate. It isn't the LBA that is getting around the barrier, because
LBA is just a different way of addressing the same geometry; if you were still limited to
1,024 cylinders, 16 heads and 63 sectors, you would still have logical sectors numbered
0, 1, 2, etc. up to 1,032,191, and you would still be stuck with 504 MiB.

The reason that setting a drive's mode to LBA will get around the 504 MiB barrier is that
in virtually every case, LBA mode automatically enables geometry translation as well.
This translation is still required because the software calling the BIOS Int 13h routines
knows nothing about LBA. It is the translation that is what really gets around the barrier,
but of course all of this happens transparently to the user.

When LBA is turned on, the BIOS will enable geometry translation. This translation may
be done in the same way that it is done in Extended CHS or large mode, or it may be
done using a different algorithm called LBA-assist translation. The translated geometry is
still what is presented to the operating system for use in Int 13h calls. The difference
between LBA and ECHS is that when using ECHS the BIOS translates the parameters
used by these calls from the translated geometry to the drive's logical geometry. With
LBA, it translates from the translated geometry directly into a logical block (sector)
LBA has in recent years become the dominant form of hard disk addressing. Since the 8.4
GB limit of the Int13h interface was reached, it became impossible to express the
geometry of large hard disks using cylinder, head and sector numbers, translated or not,
while remaining below the Int13h limits of 1,024 cylinders, 256 heads and 63 sectors.
Therefore, modern drives are no longer specified in terms of classical geometry, but
rather in terms of their total number of user data sectors and addressed using LBA. See
here for more on this.

To top