home *** CD-ROM | disk | FTP | other *** search
/ ftp.pasteur.org/FAQ/ / ftp-pasteur-org-FAQ.zip / FAQ / pc-hardware-faq / enhanced-IDE / part2 < prev   
Encoding:
Internet Message Format  |  2000-01-25  |  41.8 KB

  1. Path: senator-bedfellow.mit.edu!bloom-beacon.mit.edu!news-out.cwix.com!newsfeed.cwix.com!newsfeed.tli.de!newsfeed2.news.nl.uu.net!sun4nl!sci.kun.nl!not-for-mail
  2. From: pieterh@sci.kun.nl (Maintainer)
  3. Newsgroups: comp.sys.ibm.pc.hardware.storage,comp.sys.ibm.pc.hardware.misc,comp.answers,news.answers
  4. Subject: Enhanced IDE/Fast-ATA/ATA-2 FAQ [2 of 2]
  5. Followup-To: poster
  6. Date: 24 Jan 2000 10:58:49 GMT
  7. Organization: University of Nijmegen, The Netherlands
  8. Lines: 956
  9. Approved: news-answers-request@MIT.EDU
  10. Message-ID: <86hb99$70h$1@wnnews.sci.kun.nl>
  11. NNTP-Posting-Host: wn4.sci.kun.nl
  12. X-Trace: wnnews.sci.kun.nl 948711529 7185 131.174.8.3 (24 Jan 2000 10:58:49 GMT)
  13. X-Complaints-To: usenet@sci.kun.nl
  14. NNTP-Posting-Date: 24 Jan 2000 10:58:49 GMT
  15. Summary: This FAQ addresses issues surrounding Enhanced IDE, ATA-2,
  16.     ATAPI and Enhanced BIOSes. It includes practical questions,
  17.     background information and lists of net resources.
  18. Precedence: bulk
  19. Xref: senator-bedfellow.mit.edu comp.sys.ibm.pc.hardware.storage:202952 comp.sys.ibm.pc.hardware.misc:148802 comp.answers:39388 news.answers:175808
  20.  
  21. Name: Yet Another Enhanced IDE/Fast-ATA/ATA-2 FAQ
  22. Version: 1.92
  23. Archive-name: pc-hardware-faq/enhanced-IDE/part2
  24. Posting-Frequency: Monthly (the 24th)
  25. Last-modified: 1998/01/23
  26. URL: http://come.to/eide
  27. Maintained-by: Peter den Haan <pieterh@sci.kun.nl>
  28.  
  29.   10.  ATA: harddisks
  30.   10.1.  How does ATA(-2) work?
  31.   10.2.  What are PIO modes?
  32.   10.3.  What are DMA modes?
  33.   10.4.  How are the ATA(-2,PI) I/O ports assigned?
  34.   10.5.  What does an ATA-2 interface do?
  35.   10.6.  What is Block mode?
  36.   10.7.  What is LBA?
  37.   10.8.  How does security work?
  38.   10.9.  What is S.M.A.R.T.?
  39.   10.10.  What is PRML?
  40.   10.11.  What are MR heads?
  41.  
  42.   11.  ATAPI: CD-ROMs and tapes
  43.   11.1.  How does ATAPI differ from, and coexist with, ATA(-2)?
  44.   11.2.  What's so special about the secondary port?
  45.  
  46.   12.  The EBIOS: translation
  47.   12.1.  Why translation?
  48.   12.2.  How does translation work?
  49.   12.3.  I'd like to know how translation works in detail.
  50.   12.4.  What is in the Enhanced Disk Parameter Table?
  51.   12.5.  How many types of translating/Enhanced BIOSes are there?
  52.  
  53.   13.  Software details
  54.   13.1.  Details on OnTrack Disk Manager
  55.   13.2.  How does Windows' 32-bit disk access work?
  56.  
  57.   14.  Hacker's resource guides
  58.   14.1.  The hacker's documentation guide
  59.   14.2.  The hacker's net.resource guide
  60.  
  61.  
  62.   10.  ATA: harddisks
  63.  
  64.   This and the following sections of the FAQ are intended to provide
  65.   additional background information for the curious. The answers here
  66.   differ wildly in the depth in which they treat the material; pick and
  67.   read at will. It's a FAQ, not a book.
  68.  
  69.  
  70.   10.1.  How does ATA(-2) work?
  71.  
  72.   To understand the basic concepts of advanced ATA drives, one first
  73.   needs to understand the basics of drive technology. Basically, when
  74.   the operating system needs data to be either read or written to
  75.   secondary storage (the hard disk), the BIOS gets the command, and
  76.   passes that command to the drive. For operating systems other than
  77.   DOS, the BIOS is usually replaced by the operating system's own I/O
  78.   subsystem; the principle remains the same.
  79.  
  80.   How the command is passed, interpreted, and responded to, forms the
  81.   basis for Advanced ATA. In a nutshell, there are seven registers that
  82.   the BIOS writes to/reads from to create a command. An eighth register
  83.   is used to read and write data. The signals that create these reads
  84.   and writes are controlled by the BIOS, but their timing is determined
  85.   by the interface hardware, and ATA specifications dictate how fast
  86.   these signals can be asserted or deasserted. There are currently 4
  87.   modes of Programmed Input/Output (PIO) and 4 modes of Direct Memory
  88.   Access (DMA). The numbers all of you have been reading about are only
  89.   a small portion of these specifications, but they are the ones that
  90.   marketing can tout best. These "transfer rates" are a result of the
  91.   specification that controls how fast the I/O Read and Write cycle time
  92.   of the data register can operate at.
  93.  
  94.  
  95.   10.2.  What are PIO modes?
  96.  
  97.   The PIO mode determines how fast data is transferred to and from the
  98.   drive. In the slowest possible mode, PIO mode 0, the data cycle time
  99.   can not exceed 600 nanoseconds. In a single cycle, 16 bits are
  100.   transferred in or out of the drive. In a single sector, there are 256
  101.   words (16 bits = 1 word); 2048 sectors make up a megabyte. So,
  102.   mathematically,
  103.  
  104.   1 cycle      1 sector       1 megabyte             2000
  105.   --------     ---------     ------------     =     ------     = 3.3MB/s
  106.    600ns       256 words     2048 sectors           600ns
  107.  
  108.  
  109.   So, the theoretical transfer rate of PIO Mode 0 (600ns cycle time) is
  110.   3.3 megabytes per second.
  111.  
  112.   Here are the rest of the PIO modes, with their respective transfer
  113.   rates:
  114.  
  115.      PIO mode     Cycle time   transfer rate
  116.                   (ns)            (MB/s)
  117.  
  118.          0           600            3.3         ATA
  119.          1           383            5.2         ATA
  120.  
  121.          2           240            8.3         ATA
  122.          3           180           11.1         ATA-2, IORDY required
  123.          4           120           16.6         ATA-2, IORDY required
  124.          5            90           22.2         vaporware
  125.  
  126.  
  127.   The first three, PIO modes 0 to 2, are old modes also present in the
  128.   old ATA standard. The others (PIO 3 and 4) are ATA-2 specific and use
  129.   IORDY hardware flow control. This means the drive can use the IORDY
  130.   line to slow down the interface when necessary. Interfaces without
  131.   proper IORDY support may cause data corruption in the fast PIO modes;
  132.   in that you're stuck with the slower modes, and typically half the
  133.   bandwidth.
  134.  
  135.   When interrogated with an Identify Drive command, a harddisk returns,
  136.   among other things, information about the PIO and DMA modes it is
  137.   capable of using.
  138.  
  139.  
  140.   10.3.  What are DMA modes?
  141.  
  142.   DMA or Direct Memory Access means that the data is transferred
  143.   directly between drive and memory without using the CPU as an
  144.   intermediary, in contrast to PIO. In true multitasking operating
  145.   systems like OS/2 or Linux, DMA leaves the CPU free to do something
  146.   useful during disk transfers. In a DOS/Windows environment the CPU
  147.   will have to wait for the transfer to finish anyway, so in these cases
  148.   DMA isn't terribly useful.
  149.  
  150.   There are two distinct types of direct memory access: third-party DMA
  151.   and first-party or busmastering DMA. Third-party DMA relies on the DMA
  152.   controller on the system's mainboard to perform the complex task of
  153.   arbitration, grabbing the system bus and transferring the data. In the
  154.   case of first-party DMA, all this is done by logic on the interface
  155.   card itself. Of course, this adds considerably to the complexity and
  156.   the price of a busmastering interface.
  157.  
  158.   Unfortunately, the DMA controller on ISA systems is ancient and slow,
  159.   and out of the question for use with a modern harddisk. VLB cards
  160.   cannot be used as DMA targets at all and can only do busmastering DMA.
  161.   It is only on EISA- and PCI-based interfaces that non-busmastering DMA
  162.   is viable: EISA type 'B' DMA will transfer 4MB/s, PCI type 'F' DMA
  163.   between 6 and 8MB/s.
  164.  
  165.   Today, all modern chipsets, including the ubiquitous Triton chipsets,
  166.   incorporate a busmastering DMA capable ATA interface. Efforts to
  167.   standardize the DMA hardware will ensure stable and reliable software
  168.   support.
  169.  
  170.   Anyway, the DMA modes supported are:
  171.  
  172.           DMA Mode      Cycle time   transfer rate
  173.           Single word    (ns)           (MB/s)
  174.  
  175.               0            960            2.1         ATA
  176.               1            480            4.2         ATA
  177.               2            240            8.3         ATA
  178.            Multiword
  179.               0            480            4.2         ATA
  180.               1            150           13.3         ATA-2
  181.               2            120           16.6         ATA-2
  182. !           DMA/16         120           16.6         Ultra-ATA
  183. !           DMA/33          60           33.3         Ultra-ATA
  184.  
  185.  
  186.   The single word DMA modes are hardly useful and are obsoleted in
  187.   ATA-3.  Note that some older interfaces are able to use these DMA
  188.   modes as a way to communicate with the drive, without actually doing
  189.   direct memory access at all. In these cases, the DMA modes are just
  190.   used as glorified PIO modes.
  191.  
  192.  
  193.   10.4.  How are the ATA(-2,PI) I/O ports assigned?
  194.  
  195.   The registers of the primary ATA channel occupy the following I/O
  196.   addresses (in hexadecimal notation):
  197.  
  198.      Register      Read Function             Write Function
  199.  
  200.      01F0h         Read Data                 Write Data
  201.                    (16 Bits)                 (16 bits)
  202.      01F1h         Error register            Set Features Data
  203.      01F2h         Status of sector          Write sector count
  204.                    count                     for command setup
  205.      01F3h         Location of starting      Write sector start
  206.                    sector                    for command setup
  207.      01F4h         Location of Cyl-low       Write cyl-low location
  208.                                              for command setup
  209.      01F5h         Location of Cyl-high      Write cyl-high location
  210.                                              for command setup
  211.      01F6h         Head/device selection     Write device selection
  212.                                              and head selection for
  213.                                              command setup
  214.      01F7h         Device Status             Device command
  215.  
  216.      03F6h         Alternate Status          Device Control
  217.      03F7h         Drive Address
  218.  
  219.  
  220.   Note that the floppy disk controller's disk change flag shares 03F7h
  221.   which makes life difficult for designers that want to implement disk
  222.   and floppy controllers separately. From this point of view it may come
  223.   as no surprise that some of the problems in the CMD640x and RZ1000
  224.   'EIDE' interface chips touched upon elsewhere in this FAQ are floppy
  225.   related.
  226.  
  227.   There is no reason why there can't be a large number of interfaces
  228.   like this one. There is a de facto standard for four of these ports:
  229.  
  230.     Interface number     CS0-decode    CS1-decode    IRQ number
  231.  
  232.             1            01F0h-01F7h   03F6h-03F7h    14
  233.             2            0170h-0177h   0376h-0377h    15 or 10
  234.             3            01E8h-01EFh   03EEh-03EFh    12 or 11
  235.             4            0168h-016Fh   036Eh-036Fh    10 or 9
  236.  
  237.  
  238.   Only the first two enjoy really widespread support; for the secondary
  239.   port, IRQ15 is the most commonly used interrupt by far. Potential BIOS
  240.   support for arbitrary extra ports is found only in the Phoenix
  241.   specification.
  242.  
  243.  
  244.   10.5.  What does an ATA-2 interface do?
  245.  
  246.   Interfaces have come a long way since the ordinary ISA IDE consisting
  247.   of little more than a simple buffer. ATA-2 boards have to support at
  248.   least PIO modes 0 and 3, usually support many more modes, and will
  249.   have to ensure that the correct timing is used at the ATA interface
  250.   for each of these modes. Since the timing specifications are quite
  251.   complicated, a great deal of flexibility is necessary to implement the
  252.   ATA-2 standard correctly.
  253.                                |<------------ t0 ------------------------>|
  254.                          __________________________________________       |
  255.   Address Valid *1 _____/                                          \________
  256.                         |<-t1->|<----------- t2 ----------->|<-t9->|      |
  257.                         |      |____________________________|<---t2i----->|_
  258.   DIOR-/DIOW-      ____________/                            \_____________/
  259.                         |      |                            |      |
  260.                         |      |                    ________|__  ->|   |<-t8
  261.   Write Data    *2 --------------------------------<___________>------------
  262.                         |      |                   |<--t3-->|  |       |
  263.                         |      |                          ->|t4|<-     |
  264.                         |      |                     _______|___ ____  |
  265.   Read Data     *2 ---------------------------------<___________X____>------
  266.                       ->|t7|<- |                    |     ->|t6 |<-  | |
  267.                         |  | ->| tA |<-             |<-t5-->|<-t6Z-->|
  268.                         |  |___________________________________________|
  269.   IOCS16-          ________/        |               |                  \____
  270.                                     |             ->|tRd|<-            |
  271.                    _________________|___________________|___________________
  272.   IORDY            XXXXXXXXXXXXXXXXX____________________/
  273.                                     |<-------tB-------->|
  274.     *1 Device Address consists of signals CS0-, CS1- and DA2-0
  275.     *2 Data consists of DD0-15 (16-bit) or DD0-7 (8-bit)
  276.  
  277.  
  278. !
  279. !
  280.   The above figure defines the relationships between the interface
  281.   signals for both 8-bit and 16-bit PIO data transfers.
  282.  
  283.   In this diagram, t0 denotes the read/write cycle time, the most
  284.   significant determining parameter for PIO mode throughput. As you can
  285.   see, there is a lot more to the various PIO and DMA modes than this
  286.   read/write cycle time only. To design a low-cost interface that fully
  287.   adheres to the ATA-2 specification is quite a challenge. The common
  288.   approach is to make the timing completely software programmable;
  289.   unfortunately, the way ATA cards are programmed has not been
  290.   standardized and differs radically between cards.  The consequence is
  291.   that you will typically need interface-specific drivers for each and
  292.   every operating system used in order to profit from the fast transfer
  293.   modes.
  294.  
  295.  
  296.  
  297.   10.6.  What is Block mode?
  298.  
  299.   Multiple Read/Write commands (reduces Interrupts to host processor).
  300.  
  301.   Besides the obvious transfer increase, Fast-ATA and many other drives
  302.   allow for Read/Write Multiple commands, which increase the number of
  303.   sectors passed without intervening interrupts. This lessens the host's
  304.   overhead, as every interrupt causes the CPU to do a context switch,
  305.   check the device and set up the data transfer (or perform the transfer
  306.   itself in the case of PIO).
  307.  
  308.   The Read Multiple Command (0C4h) and the Write Multiple Command (0C5h)
  309.   are drive-level commands that can transfer multiple sectors of data
  310.   without asserting the IRQ line of the drive, signaling the processor
  311.   that a drive operation is pending.
  312.  
  313.   The IRQ line is asserted when:
  314.  
  315.   o  A read command has been issued, and the requested data is in the
  316.      drive's buffer, ready to be taken by the host.
  317.  
  318.  
  319.   o  A write command has been issued, and the data has transferred to
  320.      the drive's buffer. If write caching is disabled, the IRQ won't be
  321.      asserted until the data has been completely written to the media.
  322.  
  323.   During normal reads and writes, the interrupt can constantly bother
  324.   the CPU, and depending on the processor and the task at hand (multi-
  325.   tasking OS, Unix, etc), there can be long delays in having the CPU
  326.   service the drive. The advent of Read/Write Multiple allows many
  327.   sectors (from 2 up to as many as 128) to be transferred in one go,
  328.   completing the task in as much as 30% faster times.
  329.  
  330.   On single-tasking operating systems like DOS, any improvement over a
  331.   few percent usually indicates bad buffer cache management on the part
  332.   of the drive.
  333.  
  334.   Warning: some old drives have a buggy block mode implementation and
  335.   may corrupt data.
  336.  
  337.   A final remark: the block size that is optimal for drive throughput
  338.   doesn't have to be the best for system performance! For example, the
  339.   DOS FAT filesystem tends to favor a block size equal to the cluster
  340.   size. Do not trust low level benchmarks when tweaking the block size,
  341.   but use an application level benchmark suite instead.
  342.  
  343.  
  344.  
  345.   10.7.  What is LBA?
  346.  
  347.   LBA is a means of linearly addressing sectors addresses, beginning at
  348.   sector 1 of head 0, cylinder 0 as LBA 0, and proceeding on to the last
  349.   physical sector on the drive, which, for instance, on a standard 540
  350.   Meg drive would be LBA 1,065,456. This is new in ATA-2, but has always
  351.   been the one and only addressing mode in SCSI. Note that LBA does not
  352.   allow you to address more sectors than CHS style addressing would.
  353.  
  354.   LBA reduces CPU overhead in OSs that use LBA internally, but on the
  355.   other hand takes a little more time when ordinary CHS based BIOS calls
  356.   are used (eg. DOS). Beware that depending on the way LBA is
  357.   implemented in the harddisk firmware, the overhead on the part of the
  358.   drive may increase.
  359.  
  360.  
  361.   10.8.  How does security work?
  362.  
  363.   Security mode implements a simple password protection scheme. Security
  364.   can affect just write operations, or both reads and writes. Non-data
  365.   operations (such as Identify Device) can always be executed regardless
  366.   of the security status.
  367.  
  368.   There are two security levels: High and Maximum. If the user password
  369.   is lost and High level security is set, the drive can still be
  370.   unlocked with the Master password.  At Maximum level, there is no way
  371.   to unlock the drive without erasing all user data.
  372.  
  373.   After a number of incorrect passwords the drive will reject further
  374.   passwords until a powerdown or hard reset. This makes guessing the
  375.   password by brute force very difficult.
  376.  
  377.  
  378.   10.9.  What is S.M.A.R.T.?
  379.  
  380.   S.M.A.R.T. or Self Monitoring Analysis and Reporting Technology allows
  381.   the drive to report about certain types of degradation or impending
  382.   failure. This allows the operating system to take the necessary
  383.   precautions and warn the user. The OEM release 2 of Win95 and the next
  384.   OS/2 version (Merlin) will be SMART aware.
  385.   The utility of this feature will initially be quite limited, though,
  386.   because many failure modes (including the infamous Monday morning
  387.   failure) can't be sensed in advance.
  388.  
  389.   At present only few utilities exist to examine the S.M.A.R.T. status
  390.   of a drive. These include Micro House EZ-S.M.A.R.T. and Symantec
  391.   S.M.A.R.T. Doctor.
  392.  
  393.  
  394.   10.10.  What is PRML?
  395.  
  396.   The Partial Response Maximum Likelihood or PRML read channel is
  397.   quickly replacing the ordinary peak detection channel as a mass market
  398.   technology. Briefly, where a peak detection channel uses a
  399.   comparatively simple analogue technique to extract the digital data
  400.   from the signal picked up by the read head, a PRML channel digitizes
  401.   the signal and employs digital processing techniques to reconstruct
  402.   the data. Thanks to these DSP techniques a PRML channel can still work
  403.   reliably on very closely packed data where the distinction between
  404.   individual bits tends to blur. The end result is a faster, higher
  405.   capacity drive.
  406.  
  407.   For a more thorough discussion of this topic, take a look at Quantum's
  408.   excellent white papers <http://www.quantum.com/products/whitepapers/>.
  409.  
  410.  
  411.  
  412.   10.11.  What are MR heads?
  413.  
  414.   Magnetoresistive or MR drive heads are quickly replacing the old
  415.   inductive heads in all sections of the harddrive market. For more
  416.   information, see for example
  417.   <http://www.seagate.com/new/sep96/mr_techp.shtml>.
  418.  
  419.  
  420.  
  421.   11.  ATAPI: CD-ROMs and tapes
  422.  
  423.   11.1.  How does ATAPI differ from, and coexist with, ATA(-2)?
  424.  
  425.   For the sake of compatibility with non-ATAPI aware software that might
  426.   mistake an ATAPI device for a harddrive, the device pretends it isn't
  427.   there until it's waken up by a special sequence of commands. Once
  428.   activated, it uses a command protocol that radically differs from that
  429.   used by harddisks.
  430.  
  431.   The reason is that the ATA command and register set is not adequate to
  432.   support some CD-ROM command structures. Therefore, only a minimum of
  433.   traditional ATA commands are supported by ATAPI devices.  For most of
  434.   their functions, these devices rely on the ATAPI Transport Protocol
  435.   using packets of at least 12 bytes sent, as data, through the Data
  436.   Register. These packet commands have been derived from the SCSI
  437.   command set; this makes it reasonably easy to rewrite existing SCSI
  438.   CD-ROM and tape drivers for ATAPI hardware.
  439.  
  440.   Beware that non-ATAPI aware 'intelligent' controllers, mainly caching
  441.   controllers, will be mightily confused by packet commands.
  442.   Traditionally, the data register is only used to transport 512-byte
  443.   sectors; a 12-byte command packet is a completely different kind of
  444.   animal and should be treated in a different way by the (intelligent)
  445.   controller.
  446.  
  447.  
  448.   11.2.  What's so special about the secondary port?
  449.  
  450.   Nothing, in principle. A secondary IDE port has been reserved in the
  451.   PC I/O map for ages (base address 0170h, IRQ 15), and adapters that
  452.   could be configured as secondary have been available for quite some
  453.   time, even though BIOS support was lacking. So while it is a part of
  454.   EIDE, there is actually nothing new about this feature, except that
  455.   the possibility of connecting tape drives and CD-ROMs to the ATA
  456.   adapter has transformed four device support from a luxury into a
  457.   necessity.
  458.  
  459.   Actually, there is another reason to provide a secondary port for
  460.   ATAPI devices. There are a number of advanced hardware features for
  461.   harddisk interfaces, such as prefetch buffers and write behind, that
  462.   may get in the way of ATAPI compatibility. This means that if the
  463.   software drivers of an intelligent ATA-2 port are not ATAPI-aware, or
  464.   simply don't work as they should, you may run into sticky problems.
  465.   Especially if you have an ATAPI CD-ROM that doesn't support PIO mode 3
  466.   transfers, a secondary port that provides only basic ATA features is a
  467.   good way to avoid a lot of headaches.
  468.  
  469.   Finally, an ATAPI device on the primary port will cause Windows
  470.   FastDisk drivers that aren't ATAPI aware to fail.
  471.  
  472.   Nothing prevents you from defining more ports like the primary and the
  473.   secondary one; in addition to these two, the tertiary and quaternary
  474.   one are semi-standard. See section 10.4 for the port and IRQ
  475.   assignments of all these ports.
  476.  
  477.  
  478.  
  479.   12.  The EBIOS: translation
  480.  
  481.  
  482.   12.1.  Why translation?
  483.  
  484.   Both the 'int13' software interface used by the BIOS to communicate
  485.   with the outside and the Cylinder/Head/Sector (CHS) fields in the
  486.   partition table reserve
  487.  
  488.   o  10 bits for the cylinder field, for a total of up to 1024
  489.      cylinders;
  490.  
  491.   o  8 bits for the head field, good for up to 256 heads;
  492.  
  493.   o  6 bits for the sector field, which gives a maximum of 63 sectors
  494.      since for historic reasons the sector field starts at sector 1, not
  495.      0.
  496.  
  497.      The maximum disk capacity accessible through the traditional int13
  498.      interface is therefore 8GB (1024*256*63 sectors of 512 bytes). In
  499.      some books, you may encounter references to 12-bit cylinder
  500.      numbers; this extension (using the upper two bits of the sector
  501.      field) was never widely implemented and isn't supported anywhere.
  502.  
  503.   Now IDE disks have their own set of limitations; these disks, no
  504.   matter if they're ATA/IDE or ATA-2/EIDE, use
  505.  
  506.   o  16 bits for the cylinder field, giving 65536 cylinders;
  507.  
  508.   o  4 bits for the head field, or only 16 heads at most;
  509.  
  510.   o  8 bits for the sector field.
  511.  
  512.      This is good for a maximum disk capacity of 128GB. However, combine
  513.      this with the BIOS limitations and you suddenly can't see more than
  514.      the first 1024 cylinders of the IDE disk, which makes for a limit
  515.      of just 504MB or 528 million bytes. This is unacceptable today. In
  516.      the long term, the BIOS limit of 8GB is just as unacceptable, but
  517.      as a short term solution it is desirable to get the maximum out of
  518.      the standard int13 interface with IDE drives. This is where
  519.      translation comes in.
  520.  
  521.  
  522.   12.2.  How does translation work?
  523.  
  524.   There are roughly three ways today's BIOSes can handle translation:
  525.   standard CHS addressing, Extended CHS addressing, and LBA addressing.
  526.   Translation does NOT automatically imply LBA, as you will see.
  527.  
  528.   o  Standard CHS: no translation at all :-(
  529.  
  530.      Communication between drive, BIOS and operating system goes like
  531.      this:
  532.  
  533.  
  534.  
  535.           +-------- DRIVE --------+    +- BIOS --+    +---- OS ----+
  536.           |                       |    |         |    |   & APPS   |
  537.           |   physical      T1   logical        logical            |
  538.           | geometry used  ====> geometry ----> geometry           |
  539.           |internally only        (CHS)           (CHS)            |
  540.           |                       |    |         |    |            |
  541.           +-----------------------+    +---------+    +------------+
  542.  
  543.  
  544.  
  545.  
  546.      There is only one translation step, T1, which is internal to the
  547.      drive ('universal translation'). The drive's actual, physical
  548.      geometry is completely invisible from the outside---the Cylinders,
  549.      Heads and Sectors printed on the label for use in the BIOS setup
  550.      have nothing to do with the physical geometry! The logical
  551.      geometry, used throughout, is subject to both IDE's limitation to
  552.      16 heads and to the BIOS' limitation of 1024 cylinders, which gives
  553.      the (in)famous 504MB limitation.
  554.  
  555.  
  556.   o  Extended CHS
  557.  
  558.  
  559.  
  560.           +-------- DRIVE --------+    +- BIOS --+    +---- OS ----+
  561.           |                       |    |         |    |   & APPS   |
  562.           |   physical      T1   logical   T2  translated          |
  563.           | geometry used  ====> geometry ====> geometry           |
  564.           |internally only        (CHS)           (CHS)            |
  565.           |                       |    |         |    |            |
  566.           +-----------------------+    +---------+    +------------+
  567.  
  568.  
  569.  
  570.  
  571.      Logical geometry is used to communicate between the drive and the
  572.      BIOS, while a different, translated geometry is used to communicate
  573.      between the BIOS and everything else.
  574.  
  575.      There is an additional translation step, T2, performed by the BIOS.
  576.      This procedure breaks the 504MB barrier because the geometries used
  577.      are not subjected to the BIOS and IDE limitations simultaneously:
  578.      the logical geometry is subject to IDE's 16 head limitation, but
  579.      not to the 1024 cylinder limitation. For the translated geometry,
  580.      it is just the reverse.
  581.      Most BIOSes denote extended CHS translation with 'Large'. Note that
  582.      the geometry usually entered in the BIOS setup is the logical
  583.      geometry, not the translated one. In case of doubt, consult the
  584.      BIOS manual.
  585.  
  586.  
  587.   o  Logical Block Addressing (LBA)
  588.  
  589.      Here, the logical geometry is dispensed with entirely and replaced
  590.      by a single, large, linear block number. This makes far more sense
  591.      than using a logical geometry that is completely fake anyway.
  592.  
  593.  
  594.  
  595.           +-------- DRIVE --------+    +- BIOS --+    +---- OS ----+
  596.           |                       |    |         |    |   & APPS   |
  597.           |   physical      T1    linear   T2  translated          |
  598.           | geometry used  ====> block no.====> geometry           |
  599.           |internally only        (LBA)           (CHS)            |
  600.           |                       |    |         |    |            |
  601.           +-----------------------+    +---------+    +------------+
  602.  
  603.  
  604.  
  605.  
  606.      This breaks the 504MB barrier in essentially the same way as
  607.      extended CHS does. Conceptually, using a single linear number to
  608.      address a sector on the harddisk is simpler than a CHS style
  609.      address, but it takes more CPU cycles and is sometimes slower on
  610.      the drive side as well. The differences are pretty insignificant
  611.      either way.
  612.  
  613.      A translating BIOS can be implemented via the system BIOS or on-
  614.      board controller BIOS. Basically, this takes the drive's logical
  615.      default geometry, and if the cylinder count is beyond 1024, will
  616.      divide the cylinder count by an appropriate factor and multiply the
  617.      heads by the same. For instance, let's take a 540 Meg drive: it has
  618.      1057 cylinders, 16 heads, and 63 sectors per track. Well, the int13
  619.      interface used by the BIOS to talk with the world can only handle
  620.      1024 cylinders, but it can address up to 255 heads. So, the x-
  621.      lating BIOS will pass to the OS, via int13 calls, the geometry 528
  622.      cylinders (1057/2 (approx)) and 32 heads (16*2). Then, when the OS
  623.      makes a request to the drive, the BIOS will re-translate the
  624.      request to the original order, or to an LBA number if LBA is
  625.      enabled. This allows for capacities of up to 8 gigabytes.
  626.  
  627.   A final word about the 8GB capacity limit, which is inherent in the
  628.   int13 interface and cannot be solved without ditching the traditional
  629.   calls. To that purpose, the IBM/Microsoft int13 extensions document
  630.   specifies a new interface between the BIOS and the operating system or
  631.   applications. These extended int13 calls are made in terms of LBA
  632.   addresses and can handle huge disks. Note that the BIOS is required to
  633.   translate these LBA addresses back to CHS if the drive doesn't support
  634.   LBA---exactly the reverse of the translation process outlined above.
  635.  
  636.  
  637.   12.3.  I'd like to know how translation works in detail.
  638.  
  639.   You asked for it :-)
  640.  
  641.   If a drive is less than 504MB, it should have a logical geometry, as
  642.   reported in Identify Device words 53-58, of 1024 or less cylinders, 16
  643.   or less heads and 63 or less sectors. Such a drive can be addressed
  644.   directly without invoking this algorithm.  For drives over 504MB, the
  645.   CHS address received by the BIOS from DOS must be converted to an
  646.   Extended CHS address, or an LBA address. We'll assume ECHS for now.
  647.   First, during BIOS setup, the BIOS must determine the value of N. This
  648.   value is used to convert the drive's geometry to a geometry that the
  649.   BIOS can support at the int13 interface. This interface requires that
  650.   Cyl be less than or equal to 1024. The number of cylinders (Identify
  651.   Device word 1) is divided by N while the number of heads (Identify
  652.   Device word 3) is multiplied by N. N must be 2, 4, 8,..., a power of
  653.   2.
  654.  
  655.   Second, in most translating BIOSes, the following algorithm is used
  656.   whenever INT 13H is called to perform a read or write:
  657.  
  658.  
  659.  
  660.        eCyl    = ( Cyl * N) + ( Head / dHead ); /* head DIV dHead */
  661.        eHead   = ( Head % dHead );              /* head MOD dHead */
  662.        eSector = Sector;                        /* used as is     */
  663.  
  664.  
  665.  
  666.  
  667.   By way of example, assume the drive's geometry is 2000 cylinders, 16
  668.   heads and 63 sectors (these numbers are in Identify Words 1, 3, and 6)
  669.   and that the BIOS determines the value of N to be 2. The BIOS reports
  670.   to DOS that the drive has 1000 cylinders, 32 heads and 63 sectors when
  671.   int13 ah=08h function is called. This is 2016000 sectors.
  672.  
  673.         Cyl/Head/Sector   eCyl/eHead/eSector         LBA
  674.  
  675.             0/0/1                0/0/1                  0
  676.               :                    :                    :
  677.            500/0/1              1000/0/1            1008000
  678.           500/15/63            1000/15/63         1009007
  679.            500/16/1             1001/0/1            1009008
  680.           500/31/63            1001/15/63         1010015
  681.            501/0/1              1002/0/1            1010016
  682.               :                    :                    :
  683.           999/31/63            1999/15/63         2015999
  684.  
  685.  
  686.   Note the following about this algorithm: The physical ordering of
  687.   sectors on the drive is unaffected---sector n is followed by sector
  688.   n+1 for all CHS and Extended CHS and LBA addresses. This is the only
  689.   sane way of implementing translation, but unfortunately NOT ALL BIOSES
  690.   DO IT THIS WAY. This means that changing translation modes may be a
  691.   dangerous thing to do.
  692.  
  693.  
  694.   12.4.  What is in the Enhanced Disk Parameter Table?
  695.  
  696.   In a standard BIOS, the Fixed Disk Parameter Table (FDPT) contains
  697.   information about the geometry of the harddisk(s). It more or less
  698.   contains the same information as the drive type entry in the CMOS
  699.   setup. A program that wants to use the harddisk on a low level,
  700.   bypassing DOS, normally uses the BIOS' int13 functions to achieve
  701.   this.
  702.  
  703.   The Enhanced fixed Disk Parameter Table (EDPT) is an extension of the
  704.   ordinary FDPT that makes use of undefined fields to provide
  705.   information about the translation mode used. It uses a magic number
  706.   (A0 in byte 3) and a checksum (in byte 15) to ensure that software
  707.   cannot mistake random data for an EDPT. This practice is more or less
  708.   standard across various flavors of translating BIOSes, with differing
  709.   magic numbers.
  710.  
  711.   On top of this, the Phoenix Enhanced BIOS standard specifies a number
  712.   of extended int13 functions and a 16 byte FDPT extension. The latter
  713.   contains detailed information about the current PIO or DMA type, block
  714.   mode used, LBA or (E)CHS addressing, 32 bit transfer mode, media type
  715.   (removable, CD-ROM), control port base and IRQ. In other words, it
  716.   covers all new features of the ATA family and is flexible enough to
  717.   accommodate more than four devices, nonstandard port addresses and
  718.   IRQs. Proper support of all this is important to achieve any degree of
  719.   Plug'n'Play functionality with ATA hardware. The WD EIDE BIOS lacks
  720.   all these features.
  721.  
  722.  
  723.   12.5.  How many types of translating/Enhanced BIOSes are there?
  724.  
  725.   Too many. See question 12.4 for a discussion of some of the
  726.   differences between a Phoenix EBIOS and a WD EBIOS. For a more
  727.   exhaustive discussion of BIOS types, Hale Landis' effort is
  728.   indispensable---see the resource guide below.
  729.  
  730.  
  731.  
  732.   13.  Software details
  733.  
  734.  
  735.   13.1.  Details on OnTrack Disk Manager
  736.  
  737.   Disk Manager 6.x and above is a piece of software that performs the
  738.   translation necessary to access harddisks of more than 1024 cylinders
  739.   with DOS/Windows. This is achieved by installing a Dynamic Drive
  740.   Overlay (DDO) to translate drive parameters. The driver provides only
  741.   the basic translation functions, without EDPT or extended int13 calls.
  742.   Of course, this is less of an issue in a software driver than in a
  743.   system BIOS.
  744.  
  745.   If Disk Manager (DM) is used to format only the slave drive, the DDO
  746.   can be installed in the config.sys as an ordinary device driver
  747.   (device=dmdrvr.bin). On the other hand, using DM on the master drive
  748.   isn't quite that easy from a technical point of view. Since you must
  749.   boot DOS from the master drive, and you must load the DDO before you
  750.   can access the drive, the only option is to load it very early during
  751.   the boot process, even before the operating system itself. Changes are
  752.   made to the Master Boot Record (MBR) to accomplish this 'pre-boot
  753.   loading'.
  754.  
  755.   This scheme works fine, but has a few drawbacks.
  756.  
  757.   o  First, DDO as a pre-boot loader has implications for floppy boots.
  758.      If you boot directly from a floppy, DDO does not have a chance to
  759.      boot and the partition does not make sense. This can be remedied by
  760.      having a line in the config.sys on the floppy which reads
  761.      "device=dmdrvr.bin". You can also watch for the press spacebar to
  762.      boot from floppy message when booting from the hard drive.
  763.  
  764.   o  The second drawback is that operating system installations
  765.      routinely overwrite the MBR with their own boot code. The DDO is no
  766.      longer loaded and your partition will be inaccessible until you let
  767.      Disk Manager write a new MBR.
  768.  
  769.   o  Third, a nonstandard partitioning scheme is used whereby the data
  770.      is offset by one track. This is completely transparent as long as
  771.      the drive is accessed through the DDO; however, many operating
  772.      systems want to replace the DDO by their own disk routines and will
  773.      have to be aware of this scheme.
  774.  
  775.      Windows 95 will support Disk Manager 6.x and above 'out of the
  776.      box', as will new versions of OS/2 Warp, Windows NT 3.5.1 and Linux
  777.      1.3.x. IBM and Microsoft have created fixes that allow older
  778.      versions of OS/2, Warp and Windows NT to work with Disk Manager.
  779.   o  Fourth, corruption of the DDO sector will result in a DDO Integrity
  780.      Error.  While it is fairly easy to re-write the DDO sector (use the
  781.      dmcfig.exe utility on your DM diskette), this is is a sign of a
  782.      bigger problem (eg. virus) rather than a problem in
  783.      itself---contact Ontrack tech support (tech@ontrack.com) for
  784.      assistance.
  785.  
  786.   An advantage of formatting the master drive with DM instead of loading
  787.   the DDO from config.sys is that you can use Windows for Workgroups'
  788.   32-bit file access on both drives---if you use dmdrvr.bin, the slave
  789.   drive is restricted to 16-bit file access.
  790.  
  791.   The 6.x versions of Disk Manager have some additional disadvantages
  792.   which are corrected in version 7:
  793.  
  794.   o  They are not fully compatible with the device drivers of most VLB
  795.      ATA(-2) interfaces; also, ATAPI CD-ROM and tape devices on the
  796.      chain are not supported.
  797.  
  798.   o  A final concern is disk utilities. If the utility in question goes
  799.      directly to the hardware, without going through the DD overlay, it
  800.      can potentially be destructive. Ontrack's policy on this is to
  801.      refer compatibility questions to the manufacturer of the utility as
  802.      they cannot possibly maintain compatibility charts for all versions
  803.      of all utilities.
  804.  
  805.   You can find more information on the various versions of Disk Manager
  806.   on OnTrack's www site <http://www.ontrack.com>.
  807.  
  808.  
  809.   13.2.  How does Windows' 32-bit disk access work?
  810.  
  811.   32-bit disk access (32BDA), also known as FastDisk, is a set of
  812.   protected-mode drivers that direct int13 calls to the hard disk
  813.   controller through a protected mode interface. For the latter the hard
  814.   disk controller has to supply an appropriate virtual device driver
  815.   (VxD).
  816.  
  817.   Windows ships with one such driver built in: *wdctrl.  Unfortunately,
  818.   this device only supports controllers that are strictly compatible
  819.   with the WD1003 standard; this excludes SCSI, ATA-2, LBA or CHS
  820.   translation, disks with more than 1024 cylinders and even some
  821.   commonplace features of ATA such as block mode. If it detects one of
  822.   these during the initialization phase it will refuse to load. In
  823.   today's computers, this means that *wdctrl will rarely do the job and
  824.   an external VxD must be used.
  825.  
  826.   32BDA has two advantages over disk access through the BIOS. First,
  827.   since the FastDisk VxD is re-entrant, it enables Windows to use
  828.   virtual memory for DOS sessions. Using virtual memory without 32BDA
  829.   could create a deadlock situation if a page fault is generated during
  830.   the execution of BIOS routines. Since the BIOS is not re-entrant, it
  831.   is not possible to use a BIOS call to read the page from disk until
  832.   the first BIOS call has terminated; on the other hand, this BIOS
  833.   thread must remain suspended until the swapped out page has been read.
  834.  
  835.   So 32BDA enables Windows to manage memory much more efficiently with
  836.   one or more DOS sessions open.
  837.  
  838.   The second advantage of 32-bit disk access is that it saves two
  839.   (relatively slow) switches between virtual and protected mode per disk
  840.   I/O call. Take, for instance, a disk read performed by a DOS
  841.   application. In the absence of 32BDA, each such call causes the
  842.   following sequence of events:
  843.  
  844.  
  845.    1     Application     calls INT21 to read from disk
  846.    2     Windows         traps the call, switches to protected mode
  847.    3     Windows         switches to real mode, returns to DOS
  848.    4     DOS             makes int13 call to BIOS disk routines
  849.    5     Windows         traps the call, switches to protected mode
  850.    6     Windows         switches to real mode, returns to BIOS
  851.    7     BIOS            acts upon int13 call and does the read
  852.    8     Windows         traps the return from int13, switches to PM
  853.    9     Windows         switches to RM, returns the result to DOS
  854.   10     DOS             receives the result, passes on to application
  855.   11     Windows         traps the return from DOS, switches to PM
  856.   12     Windows         switches to RM, returns result to application
  857.   13     Application     receives the result from the INT21 call
  858.  
  859.  
  860.   Using 32-bit disk access replaces steps 6 to 8 by a single call to the
  861.   FastDisk VxD. This removes two mode switches, resulting in a usually
  862.   small disk performance improvement. (Steps 3-11 also apply to native
  863.   Windows applications).
  864.  
  865.  
  866.   14.  Hacker's resource guides
  867.  
  868.  
  869.   14.1.  The hacker's documentation guide
  870.  
  871.   Unfortunately, this lists consistently eludes being entirely up to
  872.   date, but it should get you started.
  873.  
  874.   o  AT Attachment Interface for Disk Drives, ANSI X3.221-1994, Approved
  875.      May 12, 1994.
  876.  
  877.   o  AT Attachment Interface with Extensions (ATA-2), ANSI ASC
  878.      X3.279-1996, revision 3, proposed American National Standard 948D.
  879.  
  880.   o  AT Attachment-3 Interface (ATA-3), ANSI ASC X3.298-199x.
  881.  
  882.   o  AT Attachment-4 Interface (ATA-4), X3T13 draft.
  883.  
  884.   o  ATA packet Interface for CD-ROMs, SFF-8020, Revision 1.2, June 13
  885.      1994.
  886.  
  887.   o  Western Digital Enhanced IDE Implementation Guide, by Western
  888.      Digital Corporation, revision 5.0.
  889.  
  890.   o  Fast ATA Sourcebook, Quantum Corporation, November 1994.
  891.  
  892.   o  Enhanced Disk Drive Specification, by Phoenix Technologies Ltd.,
  893.      version 1.1, January 95.
  894.  
  895.  
  896.   14.2.  The hacker's net.resource guide
  897.  
  898. ! Hale Landis (hlandis@ibm.net) has written a number of "how it works"
  899. ! documents dealing with boot sectors, MBRs and partition tables. These
  900. ! are available in a ZIP archive from
  901.   <ftp://fission.dt.wdc.com/pub/otherdocs/pc_systems/how_it_works/>.
  902.   Also, he has an extensive description of BIOS types, invaluable for
  903.   programmers, a "Facts and Fiction" series that dispels a couple of
  904.   common myths, and more. These, together with the How It Works
  905.   documents (in case you cannot FTP) are available from his mail server;
  906.   to get started, send an e-mail message
  907.  
  908.  
  909.  
  910.  
  911.   ______________________________________________________________________
  912.   To: hiw@sugs.tware.com
  913.  
  914.   help
  915.   end
  916.   ______________________________________________________________________
  917.  
  918.  
  919.  
  920.   This server, like the WD FTP site (in /pub/standards) has a copy of
  921.   the ATA-2 standard as well.
  922.  
  923.   <ftp://fission.dt.wdc.com/>, a Western Digital FTP site, contains
  924.   loads of material pertaining to the SFF Committee, the ATA, ATA-2 and
  925.   ATAPI standards, the Phoenix Enhanced BIOS spec, and archives of the
  926.   various reflectors (mailing lists, such as the ATA-2 and ATAPI lists).
  927.   Look in /pub/standards/; the SFF stuff is in
  928.   /pub/standards/sff/specs/, the x3t13 in /pub/standards/x3t13/. The
  929.   mailing lists themselves can be accessed through majordomo@dt.wdc.com;
  930.   send a message
  931.  
  932.  
  933.   ______________________________________________________________________
  934.   To: majordomo@dt.wdc.com
  935.  
  936.   help
  937.   end
  938.   ______________________________________________________________________
  939.  
  940.  
  941.  
  942.   to get more information.
  943.  
  944.   <ftp://ftp.symbios.com/pub/standards/io> also contains information
  945.   about ATA, ATA-2, ATA-3, SCSI-2 and many more standards.
  946.   <ftp://www.ptltd.com/pub/phoenix_docs/> has many Phoenix specs such as
  947.   their Enhanced BIOS document.
  948.  
  949.   <ftp://hddtech.millcomm.com> Tech sheets (I really have to take a look
  950.   there someday).
  951.  
  952.   Other pointers are appreciated.
  953.  
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.  
  961.  
  962.  
  963.  
  964.  
  965.  
  966.  
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.  
  977.