home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 12 / CD_ASCQ_12_0294.iso / maj / 108 / chapter.008 < prev    next >
Text File  |  1994-01-19  |  86KB  |  1,609 lines

  1.  
  2.        **  Programmer's Technical Reference for MSDOS and the IBM PC **
  3.                 USA copyright TXG 392-616  ALL RIGHTS RESERVED
  4.      ──────────────────────────┤ DOSREF (tm) ├───────────────────────────
  5.                      ISBN 1-878830-02-3 (disk-based text)
  6.                     Copyright (c) 1987, 1994 Dave Williams
  7.                         ┌─────────────────────────────┐
  8.                         │ Shareware Version, 01/20/94 │
  9.                         │  Please Register Your Copy  │
  10.                         └─────────────────────────────┘
  11.  
  12.  
  13.                            C H A P T E R   E I G H T
  14.  
  15.  
  16.                              DOS DISK INFORMATION
  17.  
  18.  
  19.                                 C O N T E N T S
  20.  
  21. The DOS Area .......................................................... 8**1
  22. The Boot Record ....................................................... 8**2
  23. DOS File Allocation Table (FAT) ....................................... 8**3
  24.         Media Descriptor Byte ......................................... 8**4
  25.         12 Bit FATs ................................................... 8**5
  26.         16 Bit FATs ................................................... 8**6
  27. DOS Disk Directory .................................................... 8**8
  28. The Data Area ......................................................... 8**9
  29. Floppy Disk Types ..................................................... 8**10
  30. Hard Disk Layout ...................................................... 8**11
  31. System Initialization ................................................. 8**12
  32. Boot Record/Partition Table ........................................... 8**13
  33. Hard Disk Technical Information ....................................... 8**14
  34. Determining Hard Disk File Allocation ................................. 8**15
  35. BIOS Disk Functions ................................................... 8**16
  36.         00h  Reset
  37.         01h  Get Status
  38.         02h  Read Sectors
  39.         03h  Write Sectors
  40.         04h  Verify
  41.         05h  Format Track (floppy disk)
  42.         06h  Hard Disk - format track
  43.         07h  Hard Disk - format drive
  44.         08h  Read Drive Parameters
  45.         09h  Initialize Two Fixed Disk Base Tables
  46.         0Ah  Read Long (Hard disk)
  47.         0Bh  Write Long (Hard disk)
  48.         0Ch  Seek To Cylinder
  49.         0Dh  Alternate Hard Disk Reset
  50.         0Eh  Read Sector Buffer
  51.         0Fh  Write sector buffer
  52.         10h  Test For Drive Ready
  53.         11h  Recalibrate Drive
  54.         12h  Controller RAM Diagnostic
  55.         13h  Controller Drive Diagnostic
  56.         14h  Controller Internal Diagnostic
  57.         15h  Get Disk Type
  58.         16h  Get Disk Change Status (diskette)
  59.         17h  Set Disk Type for Format (diskette)
  60.         18h  Set Media Type For Format (diskette)
  61.         19h  Park Hard Disk Heads
  62.         1Ah  ESDI Hard Disk - Low Level Format
  63.         1Bh  ESDI Hard Disk - Get Manufacturing Header
  64.         1Ch  ESDI Hard Disk - Get Configuration
  65.  
  66.  
  67.  
  68.  
  69. THE DOS AREA├────────────────────────────────────────────────────────── 8**1
  70.  
  71.  All disks and diskettes formatted by DOS are created with a sector size of 512
  72. bytes. The DOS area (entire area for a diskette, DOS partition for hard disks)
  73. is formatted as follows:
  74.  
  75.         ┌────────────────────────────────────────────────────────────┐
  76.         │                       D O S   A R E A                      │
  77.         ├────────────────────────────────────────────────────────────┤
  78.         │ partition table          - variable size (hard disk only)  │
  79.         │ boot record              - 1 sector                        │
  80.         │ first copy of the FAT    - variable size                   │
  81.         │ second copy of the FAT   - same size as first copy         │
  82.         │ root directory           - variable size                   │
  83.         │ data area                - variable depending on disk size │
  84.         └────────────────────────────────────────────────────────────┘
  85.  
  86. The following sections describe each of the allocated areas:
  87.  
  88.  
  89.  
  90. THE BOOT RECORD├─────────────────────────────────────────────────────── 8**2
  91.  
  92.  The boot record resides on track 0, sector 1, side 0 of every diskette
  93. formatted by the DOS FORMAT program. For hard disks the boot record resides on
  94. the first sector of the DOS partition. It is put on all disks to provide an
  95. error message if you try to start up with a nonsystem disk in drive A:. If the
  96. disk is a system disk, the boot record contains a JMP instruction pointing to
  97. the first byte of the operating system.
  98.  
  99.  If the device is IBM compatible the first sector of the first FAT must be
  100. located at the same sector for all disk types. This is because the FAT sector
  101. is read before the disk type is actually determined.
  102.  
  103.  The information relating to the BPB for a particular media is kept in the 
  104. disk's boot sector.  The format of the boot sector is:
  105.  
  106. ┌──────────────────────────────────────────────────────────────────────────────┐
  107. │                        D O S   B O O T   R E C O R D                         │
  108. ├───┬───────┬──────────────────────────────────────────────────────────────────┤
  109. │00h│3 bytes│  JMP to executable code. For DOS 2.x, 3 byte near jump (0E9h).   │
  110. │   │       │  For DOS 3.x, 2 byte near jump (0EBh) followed by a NOP (90h)    │
  111. ├───┼───────┼──────────────────────────────────────────────────────────────────┤
  112. │03h│8 bytes│  optional OEM name and version  (such as IBM 2.1)                │
  113. ├───┼───────┼──────────────────────────────────────────────────────────────────┤
  114. │0Bh│2 bytes│  bytes per sector                                                │
  115. ├───┼───────┼─────┬────────────────────────────────────────────────────────────┤
  116. │0Dh│ byte  │     │  sectors per allocation unit (must be a power of 2)        │
  117. ├───┼───────┤     ├────────────────────────────────────────────────────────────┤
  118. │0Eh│2 bytes│  B  │  reserved sectors (starting at logical sector 0)           │
  119. │   │       │     │  01 for 1.x-3.31, 02 for 4.0+                              │
  120. ├───┼───────┤     ├────────────────────────────────────────────────────────────┤
  121. │10h│ byte  │     │  number of FATs                                            │
  122. ├───┼───────┤     ├────────────────────────────────────────────────────────────┤
  123. │11h│2 bytes│     │  maximum number of root directory entries                  │
  124. ├───┼───────┤  P  ├────────────────────────────────────────────────────────────┤
  125. │13h│2 bytes│     │  number of sectors in logical image (total number of       │
  126. │   │       │     │  sectors in media, including boot sector directories, etc.)│
  127. │   │       │     │  If logical disk size is geater than 32Mb, this value is 0 │
  128. │   │       │     │  and the actual size is reported at offset 26h (DOS 4.0+)  │
  129. ├───┼───────┤     ├────────────────────────────────────────────────────────────┤
  130. │15h│ byte  │  B  │  media descriptor byte                                     │
  131. ├───┼───────┤     ├────────────────────────────────────────────────────────────┤
  132. │16h│2 bytes│     │  number of sectors occupied by a single FAT                │
  133. ├───┼───────┼─────┴────────────────────────────────────────────────────────────┤
  134. │18h│2 bytes│  sectors per track                                               │
  135. ├───┼───────┼──────────────────────────────────────────────────────────────────┤
  136. │1Ah│2 bytes│  number of heads                                                 │
  137. ├───┼───────┼──────────────────────────────────────────────────────────────────┤
  138. │1Ch│2 bytes│  # of hidden sectors  (sectors before this volume) (1st part)    │
  139. └───┴───────┼──────────────────────────────────────────────────────────────────┤
  140.             │                EXTENDED BOOT RECORD (DOS 4.0+)                   │
  141. ┌───┬───────┼──────────────────────────────────────────────────────────────────┤
  142. │1Eh│2 bytes│  # of hidden sectors  (sectors before this volume) (2nd part)    │
  143. ├───┼───────┼──────────────────────────────────────────────────────────────────┤
  144. │20h│4 bytes│  # sectors in this disk (see offset 13h, if 0)                   │
  145. ├───┼───────┼──────────────────────────────────────────────────────────────────┤
  146. │24h│2 bytes│  physical drive number (max 2 for DOS 4, max 8 for DOS 5)        │
  147. ├───┼───────┼──────────────────────────────────────────────────────────────────┤
  148. │26h│ byte  │  extended boot record signature  (29h)                           │
  149. ├───┼───────┼──────────────────────────────────────────────────────────────────┤
  150. │27h│4 bytes│  volume serial number (assigned with a random function)          │
  151. ├───┼───────┼──────────────────────────────────────────────────────────────────┤
  152. │2Bh│11 byte│  volume label                                                    │
  153. ├───┼───────┼──────────────────────────────────────────────────────────────────┤
  154. │36h│7 bytes│  file system ID   (FAT12   ), (FAT16   ) etc.     ("reserved")   │
  155. └───┴───────┴──────────────────────────────────────────────────────────────────┘
  156.  
  157.  The three words at the end return information about the media. The number of
  158. heads is useful for supporting different multihead drives that have the same
  159. storage capacity but a different number of surfaces. The number of hidden
  160. sectors is useful for drive partitioning schemes.
  161.  
  162.  DOS 3.2 uses a table called the BIOS Parameter Block (BPB) to determine if a
  163. disk has a valid File Allocation Table. The BPB is located in the first sector
  164. of a floppy disk. Although the BPB is supposed to be on every formatted floppy
  165. disk, some earlier versions of DOS did not create a BPB and instead assumed that
  166. the FAT begins at the second sector of the disk and that the first FAT byte
  167. (Media Descriptor Byte) describes the disk format.
  168.  DOS 3.2 reads in the whole of the BPB and tries to use it - although strangely
  169. enough, it seems as if DOS is prepared to cope with a BPB that is more or less
  170. totally blank (it seems to ignore the descriptor byte and treat it as a DSDD
  171. 9-sector disk).
  172.  DOS 3.2 determines if a disk has a valid boot sector by examining the first
  173. byte of logical sector 0. If that byte it a jump instruction 0E9h, DOS 3.2
  174. assumes the rest of the sector is a valid boot sector with a BPB. If the first
  175. byte is not 0E9h DOS 3.2 behaves like previous versions, assumes the boot sector
  176. is invalid and uses the first byte of the FAT to determine the media type.
  177.  If the first byte on the disk happens to be 0E9h, but the disk does not have a
  178. BPB, DOS 3.2 will return a disk error message.
  179.  The real problems occur if some of the BPB data is valid and some isn't.
  180. Apparently some OEMs have assumed that DOS would continue to ignore the
  181. formatting data on the disk, and have failed to write much there during FORMAT
  182. except the media descriptor byte (or, worse, have allowed random junk to be
  183. written there). While this error is understandable, and perhaps even
  184. forgiveable, it remains their problem, not IBM's, since the BPB area has always
  185. been documented as containing the format information that IBM DOS 3.2 now
  186. requires to be there.
  187.  
  188.  When the BPB problems first became evident with DOS 3.2 a number of reports
  189. circulated claiming DOS looked for the letters "IBM" in the OEM ID field. This 
  190. was incorrect. IBM DOS 4.0 *did* check for the letters "IBM" and would refuse
  191. to recognize hard drives formatted under MSDOS 4.0. IBM corrected this with
  192. their 4.01 revision.
  193.  
  194.  
  195.  
  196. THE DOS FILE ALLOCATION TABLE (FAT)├─────────────────────────────────── 8**3
  197.  
  198.  The File Allocation Table, or FAT, has three main purposes:
  199.         1) to mark bad sectors on the media
  200.         2) to determine which sectors are free for use
  201.         3) to determine the physical location(s) of a file on the media.
  202.  
  203.  DOS uses one of two schemes for defining the File Allocation Table:
  204.         1) a 12-bit FAT, for DOS 1.x, 2.x, all floppies, and small hard disks
  205.         2) a 16-bit FAT, for DOS 3.x+ hard disks from 16.8 to 32Mb
  206.  
  207.  This section explains how DOS uses the FAT to convert the clusters of a file
  208. into logical sector numbers. It is recommended that system utilities use the
  209. DOS handle calls rather than interpreting the FAT, particularly since
  210. aftermarket disk partitioning or formatting software may have been used.
  211.  
  212.  The FAT is used by DOS to allocate disk space for files, one cluster at a time.
  213. In DOS 4.0, clusters are referred to as "allocation units." It means the same
  214. things; the smallest logical portion of a drive.
  215.  
  216.  The FAT consists of a 12 bit entry (1.5 bytes) for each cluster on the disk or
  217. a 16 bit (2 bytes) entry when a hard disk has more than 20740 sectors as is the
  218. case with fixed disks larger than 10Mb.
  219.  
  220.  The first two FAT entries map a portion of the directory; these FAT entries
  221. contain indicators of the size and format of the disk. The FAT can be in a 12
  222. or 16 bit format. DOS determines whether a disk has a 12 or 16 bit FAT by
  223. looking at the total number of allocation units on a disk. For all diskettes
  224. and hard disks with DOS partitions less than 20,740 sectors, the FAT uses a 12
  225. bit value to map a cluster. For larger partitions, DOS uses a 16 bit value.
  226.  
  227.  The second, third, and fourth bit applicable for 16 bit FAT bytes always
  228. contains 0FFFFh. The first byte is used as follows:
  229.  
  230.  
  231. Media Descriptor Byte ................................................. 8**4
  232.  
  233. ┌──────────────────────────────────────────────────────────────────────────────┐
  234. │                 M E D I A    D E S C R I P T O R    B Y T E                  │
  235. ├──────────┬──────────────────────────────────┬────────────────────────────────┤
  236. │hex value │              meaning             │         normally used          │
  237. ├──────────┼──────────────────────────────────┼────────────────────────────────┤
  238. │    00    │ hard disk                        │ 3.3+ extended DOS partition    │
  239. ├──────────┼──────────────────────────────────┼────────────────────────────────┤
  240. │    ED    │ double sided  9 sector 80 track  │ Tandy 2000 720k         (5¼)   │
  241. ├──────────┼──────────────────────────────────┼────────────────────────────────┤
  242. │    F0    │ double sided  18 sector diskette │ PS/2 1.44 meg DSHD             │
  243. ├──────────┼──────────────────────────────────┼────────────────────────────────┤
  244. │    F8    │ hard disk                        │ bootable hard disk at C:800    │
  245. ├──────────┼──────────────────────────────────┼────────────────────────────────┤
  246. │    F8    │ 720k floppy, 9 sector 80 track   │ Sanyo 55x, DS-DOS 2.11  (5¼)   │
  247. ├──────────┼──────────────────────────────────┼────────────────────────────────┤
  248. │    F9    │ double sided  15 sector diskette │ AT 1.2 meg DSHD                │
  249. │          │ double sided  9  sector diskette │ Convertible 720k DSQD          │
  250. ├──────────┼──────────────────────────────────┼────────────────────────────────┤
  251. │    FA    │ IBM Displaywriter System disk    │ 287k                           │
  252. │          │ Kodak "4 meg"  (Pelican)         │ 4.4 meg                 (5¼)   │
  253. ├──────────┼──────────────────────────────────┼────────────────────────────────┤
  254. │    FB    │ IBM Displaywriter System disk    │ 1 meg                   (5¼)   │
  255. │          │ Kodak "6 meg"  (Pelican)         │ 5.5 meg                 (5¼)   │
  256. ├──────────┼──────────────────────────────────┼────────────────────────────────┤
  257. │    FC    │ single sided  9  sector diskette │ DOS 2.0, 180k SSDD      (5¼)   │
  258. ├──────────┼──────────────────────────────────┼────────────────────────────────┤
  259. │    FD    │ double sided  9  sector diskette │ DOS 2.0, 360k DSDD      (5¼)   │
  260. ├──────────┼──────────────────────────────────┼────────────────────────────────┤
  261. │    FF    │ double sided 36  sector diskette │ Practidisk 2.88mb DSED  (3½)   │
  262. │          │ single sided  8  sector diskette │ DOS 1.0, 160k SSDD      (5¼)   │
  263. │          │ double sided  8  sector diskette │ DOS 1.1, 320k SSDD      (5¼)   │
  264. │          │ hard disk                        │ Sanyo 55x with DS-DOS 2.11     │
  265. ├──────────┴───────────┬──────────────────────┴────────────────────────────────┘
  266. │for 8 inch diskettes: │
  267. ├──────────┬───────────┴──────────────────────┬────────────────────────────────┐
  268. │    FD    │ double sided  26 sector diskette │ IBM 3740 format DSSD           │
  269. ├──────────┼──────────────────────────────────┼────────────────────────────────┤
  270. │    FE    │ single sided  26 sector diskette │ IBM 3740 format SSSD           │
  271. │          ├──────────────────────────────────┼────────────────────────────────┤
  272. │          │ double sided  8  sector diskette │ IBM 3740 format DSDD           │
  273. └──────────┴──────────────────────────────────┴────────────────────────────────┘
  274.  
  275.  
  276.  
  277. The third FAT entry begins mapping the data area (cluster 002).
  278.  
  279. NOTE: These values are provided as a reference. Therefore, programs should not
  280.       make use of these values.
  281.  
  282.  Each entry contains three hexadecimal characters for 12-bit FATs or four for
  283. 16-bit FATs.
  284.  
  285. The possible entries are:
  286.  
  287.    12-bit   |   16-bit
  288.             |
  289.       000h  |        0000h   if the cluster is unused and available
  290.  
  291.       0FF7h |        0FFF7h  bad cluster (if not part of the allocation chain)
  292.             |
  293. 0FF0h-0FF7h | 0FFF0h-0FFF7h  to indicate reserved clusters
  294.             |
  295. 0FF8h-0FFFh | 0FFF8h-0FFFFh  to indicate the last cluster of a file (EOF)
  296.             |
  297.        xxxH |         xxxxH  any other hexadecimal numbers are the cluster
  298.             |                number of the next cluster in the file. The
  299.             |                cluster number is the first cluster in the file
  300.             |                that is kept in the file's directory entry.
  301.  
  302.  The file allocation table always occupies the sector or sectors immediately
  303. following the boot record. If the FAT is larger than 1 sector, the sectors
  304. occupy consecutive sector numbers. Two copies of the FAT are written, one
  305. following the other, for integrity. The FAT is read into one of the DOS buffers
  306. whenever needed (open, allocate more space, etc).
  307.  
  308.  
  309.  
  310. 12 Bit File Allocation Table .......................................... 8**5
  311.  
  312. Obtain the starting cluster of the file from the directory entry.
  313.  
  314. Now, to locate each subsequent sector of the file:
  315.  
  316. 1. Multiply the cluster number just used by 1.5 (each FAT entry is 1.5
  317.    bytes long).
  318. 2. The whole part of the product is offset into the FAT, pointing to the entry
  319.    that maps the cluster just used. That entry contains the cluster number of
  320.    the next cluster in the file.
  321. 3. Use a MOV instruction to move the word at the calculated FAT into a register.
  322. 4. If the last cluster used was an even number, keep the low order 12 bits of
  323.    the register, otherwise, keep the high order 12 bits.
  324. 5. If the resultant 12 bits are (0FF8h-0FFFh) no more clusters are in the file.
  325.    Otherwise, the next 12 bits contain the cluster number of the next cluster in
  326.    the file.
  327.  
  328.   To convert the cluster to a logical sector number (relative sector, such as
  329. that used by int 25h and 26h and DEBUG):
  330.  
  331. 1. Subtract 2 from the cluster number
  332. 2. Multiply the result by the number of sectors per cluster.
  333. 3. Add the logical sector number of the beginning of the data area.
  334.  
  335. 12-bit FAT if DOS partition is smaller than 32,680 sectors (16.340 MB).
  336.  
  337.  
  338.  
  339. 16 Bit File Allocation Table .......................................... 8**6
  340.  
  341.  Obtain the starting cluster of the file from the directory entry. Now to
  342. locate each subsequent cluster of the file:
  343.  
  344. 1.  Multiply the cluster number used by 2 (each FAT entry is 2 bytes long).
  345. 2.  Use the MOV word instruction to move the word at the calculated FAT offset
  346.     into a register.
  347. 3.  If the resultant 16 bits are (0FF8h-0FFFFh) no more clusters are in the
  348.     file. Otherwise, the 16 bits contain the cluster number of the next cluster
  349.     in the file.
  350.  
  351.  
  352.  
  353.  
  354. DOS Disk Directory .................................................... 8**8
  355.  
  356.  The FORMAT command initially builds the root directory for all disks. Its
  357. location (logical sector number) and the maximum number of entries are
  358. available through the device driver interfaces.
  359.  
  360.  Since directories other than the root directory are actually files, there is
  361. no limit to the number of entries that they may contain.
  362.  
  363.  All directory entries are 32 bytes long, and are in the following format:
  364. ┌───────┬─────────┬────────────────────────────────────────────────────────────
  365. │offset │  size   │                  DISK DIRECTORY ENTRY
  366. ├───────┼─────────┼────────────────────────────────────────────────────────────
  367. │  00h  │ 8 bytes │ Filename
  368. │       ├─────────┴────────────────────────────────────────────────────────────
  369. │       │ The first byte of the filename indicates the file status.
  370. │       │ The file status byte may contain the following values:
  371. │       ├──────┬───────────────────────────────────────────────────────────────
  372. │       │  00h │ Directory entry has never been used. This is used to limit
  373. │       │      │ the length of directory searches, for performance reasons.
  374. │       │  05h │ Indicates that the first character of the filename actually
  375. │       │      │ has an 0EDh character.
  376. │       │ 0E5h │ Filename has been used but the file has been erased.
  377. │       │  2Eh │ This entry is for a directory. If the second byte is also
  378. │       │      │ 2Eh, the cluster field contains the cluster number of this
  379. │       │      │ directory's parent directory. (0000h if the parent directory
  380. │       │      │ is the root directory). Otherwise, bytes 00h-0Ah are all
  381. │       │      │ spaces and the cluster field contains the cluster number of
  382. │       │      │ the directory.
  383. │       ├──────┴───────────────────────────────────────────────────────────────
  384. │       │ Any other character is the first character of a filename. Filenames
  385. │       │ are left-aligned and if necessary padded with blanks.
  386. ├───────┼─────────┬────────────────────────────────────────────────────────────
  387. │  08h  │ 3 bytes │ Filename extension if any
  388. │       ├─────────┴────────────────────────────────────────────────────────────
  389. │       │ Three characters, left-aligned and padded with blanks if necessary.
  390. │       │ If there is no file extension, this field contains all blanks
  391. ├───────┼─────────┬────────────────────────────────────────────────────────────
  392. │  0Bh  │ 1 byte  │ File attributes
  393. │       ├─────────┴────────────────────────────────────────────────────────────
  394. │       │          The attribute byte is mapped as follows:
  395. │       ├─────┬───┬────────────────────────────────────────────────────────────
  396. │       │ hex │bit│                    meaning
  397. │       ├─────┼───┼────────────────────────────────────────────────────────────
  398. │       │ 00h │   │ (no bits set) normal; can be read or written without
  399. │       │     │   │ restriction
  400. │       │ 01h │ 0 │ file is marked read-only. An attempt to open the file for
  401. │       │     │   │ output using int 21h/fn 3Dh will fail and an error code
  402. │       │     │   │ will be returned. This value can be used with other values
  403. │       │     │   │ below.
  404. │       │ 02h │ 1 │ indicates a hidden file. The file is excluded from normal
  405. │       │     │   │ directory searches.
  406. │       │ 04h │ 2 │ indicates a system file. The file is excluded from normal
  407. │       │     │   │ directory searches.
  408. │       │ 08h │ 3 │ indicates that the entry contains the volume label in the
  409. │       │     │   │ first 11 bytes. The entry has no other usable information
  410. │       │     │   │ and may exist only in the root directory.
  411. │       │ 10h │ 4 │ indicates that the file is a subdirectory
  412. │       │ 20h │ 5 │ indicates an archive bit. This bit is set to on whenever
  413. │       │     │   │ the file is written to and closed. Used by BACKUP and
  414. │       │     │   │ RESTORE.
  415. │       │     │ 6 │ reserved, set to 0
  416. │       │     │ 7 │ reserved, set to 0
  417. │       ├─────┴───┴────────────────────────────────────────────────────────────
  418. │       │ note 1) Bits 6 and 7 may be used in OS/2.
  419. │       │ note 2) Attributes 08h and 10h cannot be changed using int21/43h.
  420. │       │ note 3) The system files IBMBIO.COM and IBMDOS.COM (or customized
  421. │       │         equivalent) are marked as read-only, hidden, and system
  422. │       │         files. Files can be marked hidden when they are created.
  423. │       │ note 4) Read-only, hidden, system and archive attributes may be
  424. │       │         changed with int21h/fn43h.
  425. ├───────┼─────────┬────────────────────────────────────────────────────────────
  426. │  0Ch  │ 10 bytes│ Reserved by DOS; value unknown
  427. ├───────┼─────────┼────────────────────────────────────────────────────────────
  428. │  16h  │ 2 bytes │ File timestamp
  429. │       ├─────────┴────────────────────────────────────────────────────────────
  430. │       │ These bytes contain the time when the file was created or last
  431. │       │  updated. The time is mapped in the bits as follows:
  432. │       ├───────────────────────────────┬───────────────────────────────┐
  433. │       │         B Y T E   16h         │         B Y T E   17h         │
  434. │       ├───────────────────────────────┼───────────────────────────────┤
  435. │       │ F   E   D   C   B   A   9   8 │ 7   6   5   4   3   2   1   0 │
  436. │       ├───────────────────┬───────────┴───────────┬───────────────────┤
  437. │       │ H   H   H   H   H │ M   M   M   M   M   M │ D   D   D   D   D │
  438. │       ├───────────────────┼───────────────────────┼───────────────────┤
  439. │       │ binary # hrs 0-23 │ binary # minutes 0-59 │ bin. # 2-sec incr │
  440. │       ├───────────────────┴───────────────────────┴───────────────────┘
  441. │       │ note: The time is stored with the least significant byte first.
  442. ├───────┼─────────┬────────────────────────────────────────────────────────────
  443. │  18h  │ 2 bytes │ File datestamp
  444. │       ├─────────┴────────────────────────────────────────────────────────────
  445. │       │ This area contains the date when the file was created or last
  446. │       │ updated. The mm/dd/yy are mapped in the bits as follows:
  447. │       ├───────────────────────────────┬───────────────────────────────┐
  448. │       │         B Y T E   18h         │         B Y T E   19h         │
  449. │       ├───────────────────────────────┼───────────────────────────────┤
  450. │       │ F   E   D   C   B   A   9   8 │ 7   6   5   4   3   2   1   0 │
  451. │       ├───────────────────────────┬───┴───────────┬───────────────────┤
  452. │       │ Y   Y   Y   Y   Y   Y   Y │ M   M   M   M │ D   D   D   D   D │
  453. │       ├───────────────────────────┼───────────────┼───────────────────┤
  454. │       │     0-119 (1980-2099)     │     1-12      │       1-31        │
  455. │       ├───────────────────────────┴───────────────┴───────────────────┘
  456. │       │ note: The date is stored with the least significant byte first.
  457. ├───────┼─────────┬────────────────────────────────────────────────────────────
  458. │  1Ah  │ 2 bytes │ First file cluster number
  459. │       ├─────────┴────────────────────────────────────────────────────────────
  460. │       │ * (reserved in DOS 2, documented in DOS 3+)
  461. │       │ This area contains the starting cluster number of the first cluster
  462. │       │ in the file. The first cluster for data space on all fixed disks and
  463. │       │ floppy disks is always cluster 002. The cluster number is stored
  464. │       │ with the least significant byte first.
  465. ├───────┼─────────┬────────────────────────────────────────────────────────────
  466. │  1Ch  │ 4 bytes │ File size
  467. │       ├─────────┴────────────────────────────────────────────────────────────
  468. │       │ This area contains the file size in bytes. The first word contains
  469. │       │ the low order part of the size. Both words are stored with the least
  470. │       │ significant byte first.
  471. └───────┴──────────────────────────────────────────────────────────────────────
  472.  
  473.  
  474.  
  475. The Data Area ......................................................... 8**9
  476.  
  477.  Allocation of space for a file (in the data area) is done only when needed
  478. (it is not preallocated). The space is allocated one cluser (unit allocation)
  479. at a time. A cluster is always one or more consecutive sector numbers, and all
  480. of the clusters in a file are "chained" together in the FAT.
  481.  
  482.  The clusters are arranged on disk to minimize head movement for multisided
  483. media. All of the space on a track (or cylinder) is allocated before moving
  484. on to the next track. This is accomplished by using the sequential sector
  485. numbers on the lowest-numbered head, then all the sector numbers on the next
  486. head, and so on until all sectors of all heads of the track are used. Then the
  487. next sector used will be sector 1 of head 0 on the next track.
  488.  
  489.  An interesting innovation that was introduced in MS-DOS 3.0: disk space that
  490. is freed by erasing a file is not re-used immediately, unlike earlier versions
  491. of DOS. Instead, free space is obtained from the area not yet used during the
  492. current session, until all of it is used up. Only then will space that is freed
  493. during the current session be re-used.
  494.  
  495.  This feature minimizes fragmentation of files, since never-before-used space
  496. is always contiguous. However, once any space has been freed by deleting a file,
  497. that advantage vanishes at the next system boot. The feature also greatly
  498. simplifies un-erasing files, provided that the need to do an un-erase is found
  499. during the same session and also provided that the file occupies contiguous
  500. clusters.
  501.  
  502.  However, when one is using programs which make extensive use of temporary
  503. files, each of which may be created and erased many times during a session,
  504. the feature becomes a nuisance; it forces the permanent files to move farther
  505. and farther into the inner tracks of the disk, thus increasing rather than
  506. decreasing the amount of fragmentation which occurs.
  507.  
  508.  The feature is implemented in DOS by means of a single 16-bit "last cluster
  509. used" (LCU) pointer for each physical disk drive; this pointer is a part of
  510. the physical drive table maintained by DOS. At boot time, the LCU pointer is
  511. zeroed. Each time another cluster is obtained from the free-space pool (the
  512. FAT), its number is written into the LCU pointer. Each time a fresh cluster
  513. is required, the FAT is searched to locate a free one; in older versions of
  514. DOS this search always began at Cluster 0000, but in 3.x it begins at the
  515. cluster pointed to by the LCU pointer.
  516.  
  517.  For hard disks, the size of the file allocation table and directory are
  518. determined when FORMAT initializes it and are based on the size of the DOS
  519. partition.
  520.  
  521.  
  522.  
  523. Floppy Disk Types ..................................................... 8**10
  524.  
  525. The following tables give the specifications for floppy disk formats:
  526.  
  527. IBM PC-DOS disk formats:
  528.                  # of      FAT size   DIR     total
  529.                  sides    (sectors)(entries) sectors
  530.                    │  sectors  │  DIR  │ sectors│
  531.                    │  /track   │sectors│/cluster│
  532.                    │     │     │   │   │   │    │
  533. ┌─────┬──┬───────┬─┴─┬───┴───┬─┴─┬─┴─┬─┴─┬─┴─┬──┴─┬────────────────────────────
  534. │ 160k│5¼│DOS 1.0│ 1 │ 8 (40)│ 1 │ 4 │ 64│ 1 │ 320│Original PC-0, 16k mbd
  535. │ 320k│5¼│DOS 1.1│ 2 │ 8 (40)│ 1 │ 7 │112│ 2 │ 360│PC-1, 64k mbd
  536. │ 180k│5¼│DOS 2.0│ 1 │ 9 (40)│ 2 │ 4 │ 64│ 1 │ 640│PC-2, 256k mbd
  537. │ 360k│5¼│DOS 2.0│ 2 │ 9 (40)│ 2 │ 7 │112│ 2 │ 720│PC/XT
  538. │ 1.2M│5¼│DOS 3.0│ 2 │15 (80)│ 7 │14 │224│ 1 │2400│PC/AT, PC/RT, XT/286
  539. │ 720k│3½│DOS 3.2│ 2 │ 9 (80)│ 3 │ 7 │112│ 2 │1440│Convertible, PS/2 25+
  540. │1.44M│3½│DOS 3.3│ 2 │18 (80)│ 9 │14 │224│ 1 │2880│PS/2 50+
  541. └─────┴──┴───────┴───┴───────┴───┴───┴───┴───┴────┴────────────────────────────
  542. various MS-DOS disk formats:
  543. ┌─────┬──┬───────┬─┴─┬───┴───┬─┴─┬─┴─┬─┴─┬─┴─┬──┴─┬────────────────────────────
  544. │ 200k│5¼│  *    │ 1 │10 (40)│   │   │   │   │    │
  545. │ 400k│5¼│  * ** │ 2 │10 (40)│   │   │   │   │    │
  546. │ 800k│5¼│  *    │ 2 │10 (80)│   │   │   │   │    │
  547. │ 720k│2 │       │   │       │   │   │   │   │    │Zenith SuperSport 2-inch
  548. │ 720k│5¼│DOS2.11│ 2 │ 9 (80)│ 3 │ 7 │112│ 2 │1440│Tandy 2000 (discontinued)
  549. │2.88M│3½│       │ 2 │36 (80)│   │   │   │   │5760│Practidisk 2.88mb floppy
  550. │2720k│5¼│  ***  │ 2 │17(192)│ 8 │   │272│ 4 │5440│Pelican (Kodak 3.3Mb)(disc.)
  551. │5570k│5¼│  ***  │ 2 │17(384)│ 8 │   │272│ 4 │10880Pelican (Kodak 6.6Mb)(disc.)
  552. └─────┴──┴───────┴───┴───────┴───┴───┴───┴───┴────┴────────────────────────────
  553. *   Michtron DS-DOS 2.11 Plus and one version of MS-DOS 3.11 (vendor unknown)
  554. **  TallTree JFormat program
  555. *** Pelican driver source calls for 2 sectors/cluster, Norton Utils reports 4.
  556. ┌─────┬──┬───────┬─┴─┬───┴───┬─┴─┬─┴─┬─┴─┬─┴─┬──┴─┬────────────────────────────
  557. │ 400k│5¼│DOS2.11│ 1 │10 (80)│   │   │   │   │ 800│DEC Rainbow  SS/HD   (disc.)
  558. │ 720k│5¼│DOS2.11│ 2 │variable number of sectors  │Victor 9000 PC   (discont'd)
  559. └─────┴──┴───────┴───┤per track, more sectors on  ├────────────────────────────
  560.                      │outer tracks than inner     │
  561.                      │tracks. Special DSDD drive. │
  562.                      └────────────────────────────┘
  563.  
  564.  Some oddball DOS versions specify "zero" heads in their data area. HP's
  565. single-sided disk format (16 256-byte sectors/track, model unknown) uses a
  566. zero-based parameter for the number of heads. Without special device driver
  567. software to "fix" this, these disks are basically unusable by normal DOS.
  568.  
  569.  A couple of people have reported that the IBM "Gearbox" industrial PC uses
  570. an 800k 3.5 inch floppy with 10 sectors and 80 tracks. I've been unable to
  571. confirm this.
  572.  
  573.  Files in the data area are not necessarily written sequentially. The data area
  574. space is allocated one cluster at a time, skipping over clusters already
  575. allocated. The first free cluster found is the next cluster allocated,
  576. regardless of its physical location on the disk. This permits the most efficient
  577. utilization of disk space because clusters freed by erasing files can be
  578. allocated for new files. Refer back to the description of the DOS FAT in this
  579. chapter for more information.
  580.  
  581.         SSDD    single sided, double density     (160-180k)     5¼
  582.         DSDD    double sided, double density     (320-360k)     5¼
  583.         DSQD    double sided, quad density       (720k)         5¼, 3½, 2
  584.         DSHD    double sided, high density       (1.2-1.44M)    5¼, 3½
  585.         DSED    double sided, extra high density (2.88M)        3½
  586.  
  587.  Much of the trouble with AT 1.2 meg drives has been through the inadverdent
  588. use of quad density disks in the high density drives. The high density disks
  589. use a higher-coercivity media than the quads, and quads are not completely
  590. reliable as 1.2Mb. Make sure you have the correct disk for your application.
  591.  
  592.  
  593. ROTATION SPEEDS:
  594.  
  595.         720k,   3½"    (unknown)  note: Zenith has discontinued 2" floppies
  596.  
  597.         720k,   3½"    300 RPM
  598.         1.44Mb, 3½"    300 RPM
  599.  
  600.         360k,   5¼"    300 RPM
  601.         720k,   5¼"    300 RPM
  602.         1.2mb,  5¼"    360 RPM   (even when reading 360k diskettes)
  603.  
  604.         all      8"    360 RPM
  605.  
  606.  The Victor 9000's 5¼" floppies could vary their rotational speed as required. 
  607. This allowed them to put 720k on a standard 360k floppy, using a constant 
  608. density throughout.
  609.  
  610.  The Central Point CopyIIPC Option Board emulates the Macintosh GCR recording 
  611. format by varying the data rate instead of the rotational speed.
  612.  
  613.  
  614.  
  615.  
  616. HARD DISK LAYOUT ...................................................... 8**11
  617.  
  618.  The DOS hard disk routines perform the following services:
  619.  
  620. 1) Allow multiple operating systems to be installed on the hard disk at the
  621.    same time.
  622.  
  623. 2) Allow a user-selected operating system to be started from the hard disk.
  624.  
  625.    I) In order to share the hard disk among operating systems, the disk may be
  626.       logically divided into 1 to 4 partitions. The space within a given
  627.       partition is contiguous, and can be dedicated to a specific operating
  628.       system. Each operating system may "own" only one partition in DOS versions
  629.       2.0 through 3.2. DOS 3.3 introduced the "Extended DOS Partition" which
  630.       allows multiple DOS partitions on the same hard disk. FDISK (or a
  631.       similar program from other DOS vendors) utility allows the user to select
  632.       the number, type, and size of each partition. The partition information is
  633.       kept in a partition table that is embedded in the master hard disk boot
  634.       record on the first sector of the disk. The format of this table varies
  635.       from version to version of DOS.
  636.  
  637.   II) An operating system must consider its partition to be the entire disk,
  638.       and must ensure that its functions and utilities do not access other
  639.       partitions on the disk.
  640.  
  641.  III) Each partition may contain a boot record on its first sector, and any
  642.       other programs or data that you choose, including a different operating
  643.       system. For example, the DOS FORMAT command may be used to format and
  644.       place a copy of DOS in the DOS partition in the same manner that a
  645.       diskette is formatted. You can use FDISK to designate a partition as
  646.       "active" (bootable). The master hard disk boot record causes that
  647.       partition's boot record to receive control when the system is
  648.       initialized. Additional disk partitions could be FORTH, UNIX, Pick,
  649.       CP/M-86, OS/2 HPFS, Concurrent DOS, Xenix, or the UCSD p-System.
  650.  
  651.  
  652.  
  653. SYSTEM INITIALIZATION ................................................. 8**12
  654.  
  655. The boot sequence is as follows:
  656.  
  657. 1. System initialization first attempts to load an operating system from
  658.    diskette drive A. If the drive is not ready or a read error occurs, it then
  659.    attempts to read a master hard disk boot record on the first sector of the
  660.    first hard disk in the system. If unsuccessful, or if no hard disk is
  661.    present, it invokes ROM BASIC in an IBM PC or displays a disk error
  662.    message on most compatibles.
  663.  
  664. 2. If initialization is successful, the master hard disk boot record is given
  665.    control and it examines the partition table embedded within it. If one of
  666.    the entries indicates an active (bootable) partition, its boot record is
  667.    read from the partition's first sector and given control.
  668.  
  669. 3. If none of the partitions is bootable, ROM BASIC is invoked on an IBM PC or
  670.     a disk error on most compatibles.
  671.  
  672. 4. If any of the boot indicators are invalid, or if more than one indicator is
  673.    marked as bootable, the message "INVALID PARTITION TABLE "is displayed and
  674.    the system stops.
  675.  
  676. 5. If the partition's boot record cannot be successfully read within five
  677.    retries due to read errors, the message "ERROR LOADING OPERATING SYSTEM"
  678.    appears and the system stops.
  679.  
  680. 6. If the partition's boot record does not contain a valid "signature", the
  681.    message "MISSING OPERATING SYSTEM" appears, and the system stops.
  682.  
  683. NOTE: When changing the size or location of any partition, you must ensure that
  684.       all existing data on the disk has been backed up. The partitioning program
  685.       will destroy the data on the disk.
  686.  
  687.  System programmers designing a utility to initialize/manage a hard disk must
  688. provide the following functions at a minimum:
  689.  
  690. 1. Write the master disk boot record/partition table to the disk's first
  691.    sector to initialize it.
  692.  
  693. 2. Perform partitioning of the disk - that is, create or update the partition
  694.    table information (all fields for the partition) when the user wishes
  695.    to create a partition. This may be limited to creating a partition for only
  696.    one type of operating system, but must allow repartitoning the entire disk,
  697.    or adding a partition without interfering with existing partitions (user's
  698.    choice).
  699.  
  700. 3. Provide a means for marking a user-specified partition as bootable and
  701.    resetting the bootable indicator bytes for all other partitions at the same
  702.    time.
  703.  
  704. 4. Such utilities should not change or move any partition information that
  705.    belongs to another operating system.
  706.  
  707.  
  708.  
  709.  
  710. BOOT RECORD/PARTITION TABLE ........................................... 8**13
  711.  
  712.  A boot record must be written on the first sector of all hard disks, and
  713. must contain the following:
  714.  
  715. 1. Code to load and give control to the boot record for one of four possible
  716.    operating systems.
  717.  
  718. 2. A partition table at the end of the boot record. Each table entry is 16
  719.    bytes long, and contains the starting and ending cylinder, sector, and head
  720.    for each of four possible partitions, as well as the number of sectors
  721.    preceding the partition and the number of sectors occupied by the partition.
  722.    The "boot indicator" byte is used by the boot record to determine if one of
  723.    the partitions contains a loadable operating system. FDISK initialization
  724.    utilities mark a user-selected partition as "bootable" by placing a value
  725.    of 80h in the corresponding partition's boot indicator (setting all other
  726.    partitions' indicators to 0 at the same time). The presence of the 80h tells
  727.    the standard boot routine to load the sector whose location is contained in
  728.    the following three bytes. That sector is the actual boot record for the
  729.    selected operating system, and it is responsible for the remainder of the
  730.    system's loading process (as it is from the diskette). All boot records are
  731.    loaded at absolute address 0:7C00.
  732.  
  733. The partition table with its offsets into the boot record is:
  734. ┌──────────┬──────────┬──────────┬────────┬────────────────────────────────────
  735. │  Offset  │  Offset  │  Offset  │        │
  736. │from Start│from Start│from Start│  Size  │ Description
  737. │ of Disk  │ of Entry │ of Disk  │        │                                   
  738. ├──────────┼──────────┼──────────┼────────┼────────────────────────────────────
  739. │          │    00h   │   0BEh   │ 1 byte │ boot indicator
  740. │          │    01h   │   0BFh   │ 1 byte │ beginning head
  741. │   1BEh   │    02h   │   0C0h   │ 1 byte │ beginning sector
  742. │ (part 1) │    03h   │   0C1h   │ 1 byte │ beginning cylinder
  743. │ 16 bytes │    04h   │   0C2h   │ 1 byte │ system indicator
  744. │          │    05h   │   0C3h   │ 1 byte │ ending head
  745. │          │    06h   │   0C4h   │ 1 byte │ ending sector
  746. │          │    07h   │   0C5h   │ 1 byte │ ending cylinder
  747. │          │    08h   │   0C6h   │ 4 bytes│ relative (starting) sector       
  748. │          │    0Ch   │   0DAh   │ 4 bytes│ number of sectors       
  749. ├──────────┼──────────┼──────────┼────────┼────────────────────────────────────
  750. │          │    00h   │   0DEh   │ 1 byte │ boot indicator
  751. │          │    01h   │   0DFh   │ 1 byte │ beginning head
  752. │   1CEh   │    02h   │   0E0h   │ 1 byte │ beginning sector
  753. │ (part 2) │    03h   │   0E1h   │ 1 byte │ beginning cylinder
  754. │ 16 bytes │    04h   │   0E2h   │ 1 byte │ system indicator
  755. │          │    05h   │   0E3h   │ 1 byte │ ending head
  756. │          │    06h   │   0E4h   │ 1 byte │ ending sector
  757. │          │    07h   │   0E5h   │ 1 byte │ ending cylinder
  758. │          │    08h   │   0E6h   │ 4 bytes│ relative (starting) sector       
  759. │          │    0Ch   │   0EAh   │ 4 bytes│ number of sectors       
  760. ├──────────┼──────────┼──────────┼────────┼────────────────────────────────────
  761. │          │    00h   │   0FEh   │ 1 byte │ boot indicator
  762. │          │    01h   │   0FFh   │ 1 byte │ beginning head
  763. │   1DEh   │    02h   │   0100h  │ 1 byte │ beginning sector
  764. │ (part 3) │    03h   │   0101h  │ 1 byte │ beginning cylinder
  765. │ 16 bytes │    04h   │   0102h  │ 1 byte │ system indicator
  766. │          │    05h   │   0103h  │ 1 byte │ ending head
  767. │          │    06h   │   0104h  │ 1 byte │ ending sector
  768. │          │    07h   │   0105h  │ 1 byte │ ending cylinder
  769. │          │    08h   │   0106h  │ 4 bytes│ relative (starting) sector       
  770. │          │    0Ch   │   010Ah  │ 4 bytes│ number of sectors       
  771. ├──────────┼──────────┼──────────┼────────┼────────────────────────────────────
  772. │          │    00h   │   010Eh  │ 1 byte │ boot indicator
  773. │          │    01h   │   011Fh  │ 1 byte │ beginning head
  774. │   1EEh   │    02h   │   0110h  │ 1 byte │ beginning sector
  775. │ (part 4) │    03h   │   0111h  │ 1 byte │ beginning cylinder
  776. │ 16 bytes │    04h   │   0112h  │ 1 byte │ system indicator
  777. │          │    05h   │   0113h  │ 1 byte │ ending head
  778. │          │    06h   │   0114h  │ 1 byte │ ending sector
  779. │          │    07h   │   0115h  │ 1 byte │ ending cylinder
  780. │          │    08h   │   0116h  │ 4 bytes│ relative (starting) sector       
  781. │          │    0Ch   │   011Ah  │ 4 bytes│ number of sectors       
  782. ├──────────┼──────────┴──────────┼────────┼────────────────────────────────────
  783. │   1FEh   │                     │ 2 bytes│ 055AAh signature
  784. └──────────┴─────────────────────┴────────┴────────────────────────────────────
  785.  
  786.  Boot indicator (boot ind): The boot indicator byte must contain 0 for a non-
  787. bootable partition or 80h for a bootable partition. Only one partition can be
  788. marked as bootable at a time.
  789.  
  790.  System Indicator (sys ind): The sys ind field contains an indicator of the
  791. operating system that "owns" the partition. IBM PC-DOS can only "own" one
  792. partition, though some versions of MSDOS allow all four partitions to be used
  793. by DOS.
  794.  
  795.  The system indicators are:
  796.  
  797.         ┌─────────────────────────────────────────────────────────────┐
  798.         │                 System Indicator  (sys ind)                 │
  799.         ├───────┬─────────────────────────────────────────────────────┤
  800.         │  00h  │  unknown or no partition defined                    │
  801.         ├───────┼─────────────────────────────────────────────────────┤
  802.         │  01h  │  DOS 12 bit FAT  (DOS 2.x all and 3.x+ under 16 Mb) │
  803.         │       │                  less than 4086 clusters            │
  804.         ├───────┼─────────────────────────────────────────────────────┤
  805.         │  02h  │  Xenix                                              │
  806.         ├───────┼─────────────────────────────────────────────────────┤
  807.         │  03h  │  Xenix                                              │
  808.         ├───────┼─────────────────────────────────────────────────────┤
  809.         │  04h  │  DOS 16 bit FAT  (DOS 3.0+. Not recognized by 2.x)  │
  810.         │       │                  less than 65,536 sectors           │
  811.         ├───────┼─────────────────────────────────────────────────────┤
  812.         │  05h  │  extended DOS partition, some 3.2 and all 3.3+      │
  813.         │       │  (pointer to further partition table)               │
  814.         ├───────┼─────────────────────────────────────────────────────┤
  815.         │  06h  │  Compaq DOS 3.31, DOS 4.0+ partitions over 32 megs  │
  816.         │       │  Digital Research DRDOS 3.4, 3.41 over 32 megs      │
  817.         ├───────┼─────────────────────────────────────────────────────┤
  818.         │  06h  │  PC-MOS/386 partitions over 32 megs (NOT compatible │
  819.         │       │  with the DR, Compaq, and MSDOS big partitions!     │
  820.         ├───────┼─────────────────────────────────────────────────────┤
  821.         │  07h  │  OS/2 High Performance File System                  │
  822.         ├───────┼─────────────────────────────────────────────────────┤
  823.         │  051h │  Ontrack Disk Manager "read/write" partitions       │
  824.         ├───────┼─────────────────────────────────────────────────────┤
  825.         │  0DBh │  DRI Concurrent DOS              (>32mb partitions?)│
  826.         │       │  DRI Concurrent CP/M?                               │
  827.         ├───────┼─────────────────────────────────────────────────────┤
  828.         │  0E4h │  Speedstor, small partitions (?) (under 1024cyl?)   │
  829.         ├───────┼─────────────────────────────────────────────────────┤
  830.         │  0F2h │  2nd DOS partition, some OEM customized DOS 3.2     │
  831.         ├───────┼─────────────────────────────────────────────────────┤
  832.         │  0F4h │  Speedstor, large partitions (?)                    │
  833.         ├───────┼─────────────────────────────────────────────────────┤
  834.         │  0FEh │  Speedstor, partitions >1024 cylinders              │
  835.         └───────┴─────────────────────────────────────────────────────┘
  836.  
  837.  There are ID bytes for proprietary formatting schemes. Some manufacturers
  838. (such as Zenith, Wyse, and Tandon) diddle with these system bytes to implement
  839. more than one DOS partition per disk.
  840.  
  841. note 1) Xenix doesn't like extended DOS partitions a'la DOS 3.3, limiting you
  842.         to a DOS partition of 32Mb. Xenix doesn't recognize DOS 4.0x at all,
  843.         so to use it you need to boot from a floppy. Early versions of OS/2
  844.         also have this problem.
  845.     2)  I have found one source listing Minix partitions as "40" and some
  846.         Unix partitions as "63".  I don't know if these are decimal or
  847.         hexadecimal figures.
  848.  
  849.  Cylinder (CYL) and Sector (S): The 1 byte fields labelled CYL contain the low
  850. order 8 bits of the cylinder number - the high order 2 bits are in the high
  851. order 2 bits of the sector (S) field. This corresponds with the ROM BIOS
  852. interrupt 13h (disk I/O) requirements, to allow for a 10 bit cylinder number.
  853.  
  854.  The fields are ordered in such a manner that only two MOV instructions are
  855. required to properly set up the DX and CX registers for a ROM BIOS call to
  856. load the appropriate boot record (hard disk booting is only possible from the
  857. first hard disk in the system, where a BIOS drive number of 80h corresponds
  858. to the boot indicator byte).
  859.  
  860.  All partitions are allocated in cylinder multiples and begin on sector 1,
  861. head 0, with the exception that the partition that is allocated at the beginning
  862. of the disk starts at sector 2, to account for the hard disk's master boot
  863. record.
  864.  
  865.  Relative (starting) Sector: The number of sectors preceding each partition
  866. on the disk is kept in this 4 byte field. This value is determined by counting
  867. the sectors beginning with cylinder 0, sector 1, head 0 of the disk, and
  868. incrementing the sector, head, and then track values up to the beginning of
  869. the partition. This, if the disk has 17 sectors per track and 4 heads, and the
  870. second partition begins at cylinder 1, sector 1, head 0, then the partition's
  871. starting relative sector is 68 (decimal) - there were 17 sectors on each of 4
  872. heads on 1 track allocated ahead of it. The field is stored with the least
  873. significant word first.
  874.  
  875.  Number of sectors (#sects): The number of sectors allocated to the partition
  876. is kept in the "# of sects" field. This is a 4 byte field stored least
  877. significant word first.
  878.  
  879.  Signature: The last 2 bytes of the boot record (55AAh) are used as a signature
  880. to identify a valid boot record. Both this record and the partition boot record
  881. are required to contain the signature at offset 1FEh.
  882.  
  883.  
  884.  
  885. HARD DISK TECHNICAL INFORMATION ....................................... 8**14
  886.  
  887.  Western Digital's hard disk installation manuals make the claim that MSDOS
  888. can support only 2 hard drives. This is entirely false, and their purpose for
  889. making the claim is unclear. DOS merely performs a function call pointed at
  890. the hard disk driver, which is normally in one of three locations; a ROM at
  891. absolute address C:800, the main BIOS ROM if the machine is an AT, or a device
  892. driver installed through the CONFIG.SYS file. Two hard disk controller cards
  893. can normally not reside in the same machine due to lack of interrupt
  894. arbitration. Perstor's ARLL controller and some cards marketed by Novell can
  895. coexist with other controllers. Perstor's technical department has had four
  896. controllers and eight hard disks in the same IBM XT functioning concurrently.
  897.  
  898.  A valid hard disk has a boot record arranged in the following manner:
  899.  
  900.         db      drive           ; 0 or 80h  (80h marks a bootable, active
  901.                                              partition)
  902.         db      head1           ; starting head
  903.         dw      trksec1         ; starting track/sector (CX value for INT 13)
  904.         db      system          ; SYS IND ID from table above
  905.         db      head2           ; ending head
  906.         dw      trksec2         ; ending track/sector
  907.         dd      sector1         ; absolute # of starting sector
  908.         dd      sector2         ; absolute # of last sector
  909.  
  910.  The master disk boot record invokes ROM BASIC if no indicator byte reflects a
  911. bootable system.
  912.  
  913.  When a partition's boot record is given control, it is passed its partition
  914. table entry address in the DS:SI registers.
  915.  
  916.  
  917.  
  918. DETERMINING HARD DISK ALLOCATION ...................................... 8**15
  919.  
  920. DOS determines disk allocation using the following formula:
  921.  
  922.                                          D * BPD
  923.                             TS - RS -  ───────────
  924.                                            BPS
  925.                       SPF = ──────────────────────────────
  926.                                         BPS * SPC
  927.                                  CF + ──────────────
  928.                                            BPC
  929. where:
  930.  
  931.      TS      Total number of sectors on the disk
  932.      RS      The number of sectors at the beginning of the disk that are
  933.              reserved for the boot record. DOS normally reserves 1 sector.
  934.      D       The number of directory entries in the root directory.
  935.      BPD     The number of bytes per directory entry. This is always 32.
  936.      BPS     The number of bytes per logical sector. Typically 512, but you can
  937.              specify a different number with VDISK.
  938.      CF      The number of FATS per disk. Usually 2. VDISK is 1.
  939.      SPF     The number of sectors per FAT. Maximum 64.
  940.      SPC     The number of sectors per allocation unit (cluster).
  941.      BPC     The number of bytes per FAT entry. BPC is 1.5 for 12 bit FATs.
  942.              2 for 16 bit FATS.
  943.  
  944.  
  945. To calculate the minimum partition size that will force a 16-bit FAT:
  946.  
  947.         CYL = (max clusters * 8)/(HEADS * SPT)
  948.  
  949. where:
  950.      CYL           number of cylinders on the disk
  951.      max clusters  4092 (maximum number of clusters for a 12 bit FAT)
  952.      HEADS         number of heads on the hard disk
  953.      SPT           sectors per track  (normally 17 on MFM)
  954.  
  955.  
  956.  DOS 2.0 through 3.3 limit partition sizes to 32 megabytes. The limit arises
  957. from the fact that DOS does things by sector number, and each sector is stored
  958. as a word. So the largest sector number DOS can count to is 64k. As each
  959. sector is 512 bytes long, 64k * .5k = 32Mb. The easiest way for an aftermarket
  960. disk handler to break the 32Mb barrier is probably to increase the sector size
  961. - with 2k sectors, maximum partiton size increases to 128Mb. However, the BIOS
  962. boot routines and IBMBIO.COM are hardwired for 512 byte sectors, so you won't
  963. be able to boot from a drive with oversize sectors. That's why Disk Manager
  964. formats a small boot partition by default.
  965.  
  966.  DOS 2.x uses a "first fit" algorithm when allocating file space on the hard
  967. disk. Each time an application requests disk space, it will scan from the
  968. beginning of the FAT until it finds a contiguous peice of storage large enough
  969. for the file.
  970.  
  971.  DOS 3.x+ keeps a pointer into the disk space, and begins its search from the
  972. point it last left off. This pointer is lost when the system is rebooted.
  973. This is called the "next fit" algorithm. It is faster than the first fit and
  974. helps minimize fragmentation.
  975.  
  976.  In either case, if the FCB function calls are used instead of the handle
  977. function calls, the file will be broken into pieces starting with the first
  978. available space on the disk.
  979.  
  980.  
  981.  
  982.  
  983. BIOS Disk Routines .................................................... 8**16
  984.  
  985. ┌─────────────────────────────────────────────────────────────────────────────┐
  986. │Interrupt 13h  Disk I/O - access the disk drives (floppy and hard disk)      │
  987. └─────────────────────────────────────────────────────────────────────────────┘
  988. (0:004Ch)    1) These calls do not try rereading disk if an error is returned.
  989.              2) In the IBM OS/2 Tech Ref Volume 1, page 7-33, under "DOS
  990.                 Environment Software Interrupt Support", it lists:
  991.                 13h  disk/diskette     for non-removable media only, these
  992.                                        functions are supported:
  993.                                        01h     read status
  994.                                        02h     read sectors
  995.                                        0Ah     read long
  996.                                        15h     read DASD (disk) type
  997.              3) On hard disk systems these calls may be vectored through the
  998.                 int 40h hard disk BIOS.
  999.  
  1000.  
  1001. Function 00h    Reset - reset the disk controller chip
  1002. entry   AH      00h
  1003.         DL      drive (if bit 7 is set both hard disks and floppy disks reset)
  1004.                 00h-7Fh  floppy disk
  1005.                 80h-0FFh hard disk
  1006. return  AH      status (see 01h below)
  1007. note 1) Forces controller chip to recalibrate read/write heads.
  1008.      2) Some systems (Sanyo 55x, Columbia MPC) this resets all drives.
  1009.      3) This function should be called after a failed floppy disk Read, Write,
  1010.         Verify, or Format request before retrying the operation.
  1011.      4) If called with DL >= 80h (i.e., selecting a hard drive), the floppy
  1012.         controller and then the hard disk controller are reset.
  1013.      5) Function 0Dh allows the hard disk controller to be reset without
  1014.         affecting the floppy controller.
  1015.  
  1016.  
  1017. Function 01h    Get Status of Disk System
  1018. entry   AH      01h
  1019.         DL      drive (hard disk if bit 7 set)
  1020.                 00h-7Fh  floppy disk
  1021.                 80h-0FFh hard disk
  1022. return  AH      00h
  1023.         AL      status of most recent disk operation
  1024.                 00h     successful completion, no errors
  1025.                 01h     bad command
  1026.                 02h     address mark not found
  1027.                 03h     tried to write on write-protected disk    (floppy only)
  1028.                 04h     sector not found
  1029.                 05h     reset failed                                (hard disk)
  1030.                 06h     diskette removed or changed               (floppy only)
  1031.                 07h     bad parameter table                         (hard disk)
  1032.                 08h     DMA overrun                               (floppy only)
  1033.                 09h     attempt to DMA across 64K boundary
  1034.                 0Ah     bad sector detected                         (hard disk)
  1035.                 0Bh     bad track detected                          (hard disk)
  1036.                 0Ch     unsupported track or media type not found (floppy disk)
  1037.                 0Dh     invalid number of sectors on format         (hard disk)
  1038.                 0Eh     control data address mark detected          (hard disk)
  1039.                 0Fh     DMA arbitration level out of range          (hard disk)
  1040.                 10h     uncorrectable CRC/EEC on read
  1041.                 11h     ECC corrected data error                    (hard disk)
  1042.                 20h     controller failure
  1043.                 40h     seek failed
  1044.                 80h     timeout
  1045.                 0AAh    drive not ready                             (hard disk)
  1046.                 0BBh    undefined error                             (hard disk)
  1047.                 0CCh    write fault                                 (hard disk)
  1048.                 0E0h    status error                                (hard disk)
  1049.                 0FFh    sense operation failed                      (hard disk)
  1050. note 1) For hard disks, error code 11h (ECC data error) indicates that a
  1051.         recoverable error was detected during a preceding int 13h fn 02h
  1052.         (Read Sector) call.
  1053.  
  1054.  
  1055. Function 02h    Read Sectors - read one or more sectors from diskette
  1056. entry   AH      02h
  1057.         AL      number of sectors to read
  1058.         BX      address of buffer (ES=segment)
  1059.         CH      track (cylinder) number (0-39 or 0-79 for floppies)
  1060.                 (for hard disk, bits 8,9 in high bits of CL)
  1061.         CL      sector number (1 to 18, not value checked)
  1062.         DH      head number (0 or 1)
  1063.         DL      drive (0=A, 1=B, etc.) (bit 7=0)  (drive 0-7)
  1064.                 00h-7Fh   floppy disk
  1065.                 80h-FF0h  hard disk
  1066.         ES:BX   address to store/fetch data  (buffer to fill)
  1067.        [0000:0078]  dword pointer to diskette parameters
  1068. return  CF      clear   successful
  1069.                         AL      number of sectors transferred
  1070.                 set     error
  1071.                         AH      status  (00h, 02h, 03h, 04h, 08h, 09h, 10h,
  1072.                                          0Ah, 20h, 40h, 80h)
  1073. note 1) Number of sectors begins with 1, not 0.
  1074.      2) Trying to read zero sectors is considered a programming error; results
  1075.         are not defined.
  1076.      3) For hard disks, the upper 2 bits of the 10-bit cylinder number are
  1077.         placed in the upper 2 bits of register CL.
  1078.      4) For hard disks, error code 11h indicates that a read error occurred
  1079.         that was corrected by the ECC algorithm; in this case, AL contains the
  1080.         burst length. The data read is good within the limits of the ECC code.
  1081.         If a multisector transfer was requested, the operation was terminated
  1082.         after the sector containing the read error.
  1083.      5) For floppy drives, an error may result from the drive motor being off
  1084.         at the time of the request. The BIOS does not automatically wait for
  1085.         the drive to come up to speed before attempting the read operation. The
  1086.         calling program should reset the floppy disk system with function 00h
  1087.         and retry the operation three times before assuming that the error
  1088.         results from some other cause.
  1089.  
  1090.  
  1091. Function 03h    Write Sectors - write from memory to disk
  1092. entry   AH      03h
  1093.         AL      number of sectors to write (1-8)
  1094.         CH      track number (for hard disk, bits 8,9 in high bits of CL)
  1095.         CL      beginning sector number
  1096.                 (if hard disk, high two bits are high bits of track #)
  1097.         DH      head number  (head 0=0)
  1098.         DL      drive number (0-7)
  1099.                 00h-7Fh   floppy disk
  1100.                 80h-FF0h  hard disk
  1101.         ES:BX   address of buffer for data
  1102. return  CF      clear   success
  1103.                         AL      number of sectors written
  1104.                 set     error
  1105.                         AH      status (see 01h above)
  1106. note 1) Number of sectors begins with 1, not 0.
  1107.      2) Trying to write zero sectors is considered a programming error; results
  1108.         are not defined.
  1109.      3) For hard disks, the upper 2 bits of the 10-bit cylinder number are
  1110.         placed in the upper 2 bits of register CL.
  1111.      4) For floppy drives, an error may result from the drive motor being off
  1112.         at the time of the request. The BIOS does not automatically wait for
  1113.         the drive to come up to speed before attempting the read operation. The
  1114.         calling program should reset the floppy disk system with function 00h
  1115.         and retry the operation three times before assuming that the error
  1116.         results from some other cause.
  1117.  
  1118.  
  1119. Function 04h    Verify - verify that a write operation was successful
  1120. entry   AH      04h
  1121.         AL      number of sectors to verify (1-8)
  1122.         CH      track number  (for hard disk, bits 8,9 in high bits of CL)
  1123.         CL      beginning sector number
  1124.         DH      head number
  1125.         DL      drive number (0-7)
  1126.         DL      drive number (0-7)
  1127.                 00h-7Fh   floppy disk
  1128.                 80h-FF0h  hard disk
  1129.         ES:BX   address of buffer for data
  1130. return  CF      set on error
  1131.                 AH      status (see 01h above)
  1132.         AL      number of sectors verified
  1133. note 1) With IBM PC, XT, and AT with ROM BIOS earlier than 11/15/85, ES:BX
  1134.         should point to a valid buffer.
  1135.      2) For hard disks, the upper 2 bits of the 10-bit cylinder number are
  1136.         placed in the upper 2 bits of register CL.
  1137.      3) This function can be used to test whether a readable media is in a
  1138.         floppy drive. An error may result from the drive motor being off at the
  1139.         time of the request since the BIOS does not automatically wait for the
  1140.         drive to come up to speed before attempting the verify operation. The
  1141.         requesting program should reset the floppy disk system with function
  1142.         00h and retry the operation three times before assuming that a readable
  1143.         disk is not present.
  1144.  
  1145.  
  1146. Function 05h    Format Track - write sector ID bytes for 1 track (floppy disk)
  1147. entry   AH      05h
  1148.         AL      number of sectors to create on this track
  1149.                 interleave (for XT hard disk only)
  1150.         CH      track (or cylinder) number (bits 8,9 in high bits of CL)
  1151.         CL      sector number
  1152.         DH      head number (0, 1)
  1153.         DL      drive number (0-3)
  1154.                 00h-7Fh   floppy disk
  1155.                 80h-0FFh  hard disk
  1156.         ES:BX   pointer to 4-byte address field (C-H-R-N) (except XT hard disk)
  1157.                 byte 1 = (C) cylinder or track
  1158.                 byte 2 = (H) head
  1159.                 byte 3 = (R) sector
  1160.                 byte 4 = (N) bytes/sector (0 = 128, 1 = 256, 2 = 512, 3 = 1024)
  1161. return  CF      set if error occurred
  1162.                 AH      status code (see 01h above)
  1163. note 1) Not valid for ESDI hard disks on PS/2.
  1164.      2) For floppy disks, the number of sectors per track is taken from the
  1165.         BIOS floppy disk parameter table whose address is stored in the vector
  1166.         for int 1Eh.
  1167.      3) When this function is used for floppies on ATs or the PS/2, it should
  1168.         be preceded by a call to int 13h/fn 17h to select the type of media to
  1169.         format.
  1170.      4) For hard disks, the upper 2 bits of the 10-bit cylinder number are
  1171.         placed in the upper 2 bits of CL.
  1172.      5) On the XT/286, AT, and PS/2 hard disks, ES:BX points to a 512-byte
  1173.         buffer containing byte pairs for each physical disk sector as follows:
  1174.         Byte  Contents
  1175.         0       00h     good sector
  1176.                 80h     bad sector
  1177.         1       sector number
  1178.         For example, to format a track with 17 sectors and an interleave of
  1179.         two, ES:BX would point to the following 34-byte array at the beginning
  1180.         of a 512-byte buffer:
  1181.         db      00h, 01h, 00h, 0Ah, 00h, 02h, 00h, 0Bh, 00h, 03h, 00h, 0Ch
  1182.         db      00h, 04h, 00h, 0Dh, 00h, 05h, 00h, 0Eh, 00h, 06h, 00h, 0Fh
  1183.         db      00h, 07h, 00h, 10h, 00h, 08h, 00h, 11h, 00h, 09h
  1184.  
  1185.  
  1186. Function 06h    Hard Disk - format track and set bad sector flags
  1187.                                                      (PC2, PC-XT, and Portable)
  1188. entry   AH      06h
  1189.         AL      interleave value (XT only)
  1190.         CH      cylinder number (bits 8,9 in high bits of CL)
  1191.         CL      sector number
  1192.         DH      head
  1193.         DL      drive (80h-0FFh for hard disk)
  1194.         ES:BX   512 byte format buffer
  1195.                 the first 2*(sectors/track) bytes contain f,n for each sector
  1196.                 f       00h     good sector
  1197.                         80h     bad sector
  1198.                 n       sector number
  1199. return  CF      error
  1200.                 AH      status code (see 01h above)
  1201.  
  1202.  
  1203. Function 07h    Hard Disk - format the drive starting at the desired track
  1204.                                                       (PC2, PC-XT and Portable)
  1205. entry   AH      07h
  1206.         AL      interleave value (XT only) (01h-10h)
  1207.         CH      cylinder number (bits 8,9 in high bits of CL) (00h-03FFh)
  1208.         CL      sector number
  1209.         DH      head number (0-7)
  1210.         DL      drive number (80h-0FFh, 80h=C, 81h=D,...)
  1211.         ES:BX   format buffer, size = 512 bytes
  1212.                 the first 2*(sectors/track) bytes contain f,n for each sector
  1213.                 f       00h     good sector
  1214.                         80h     bad sector
  1215.                 n       sector number
  1216. return  CF      set on error
  1217.         AH      status code (see 01h above)
  1218. note    Award AT BIOS routines are extended to handle more than 1024 cylinders.
  1219.         AL      number of sectors
  1220.         CH      cylinder numberm low 8 bits
  1221.         CL      sector number bits 0-5, bits 6-7 are high 2 cylinder bits
  1222.         DH      head number (bits 0-5) bits 6-7 are extended high cyls (>1024)
  1223.         DL      drive number (0-1 for diskette, 80h-81h for hard disk)
  1224.         ES:BX   transfer address
  1225.  
  1226.  
  1227. Function 08h    Read Drive Parameters                          (except PC, Jr)
  1228. entry   AH      08h
  1229.         DL      drive number
  1230.                 00h-7Fh   floppy disk
  1231.                 80h-0FFh  hard disk
  1232. return  CF      set on error
  1233.                 AH      status code (see above)
  1234.         BL      drive type  (AT/PS2 floppies only)
  1235.                 01h     if 360 Kb, 40 track, 5¼"
  1236.                 02h     if 1.2 Mb, 80 track, 5¼"
  1237.                 03h     if 720 Kb, 80 track, 3½"
  1238.                 04h     if 1.44 Mb, 80 track, 3½"
  1239.         CH      low 8 bits of maximum useable value for cylinder number
  1240.         CL bits 6-7     high-order 2 bits of maximum cylinder number
  1241.                 0-5     maximum sector number
  1242.         DH      maximum usable value for head number
  1243.         DL      number of consecutive acknowledging drives (0-2)
  1244.         ES:DI   pointer to drive parameter table
  1245. note 1) On the PC and PC/XT, this function is supported on hard disks only.
  1246.      2) The Columbia MPC supports functions 6-14 for its hard disk. It returns
  1247.         drive information, same as int 13 function 8, except that the BL and
  1248.         ES:DI values are omitted and AL <- burst length.
  1249.  
  1250.  
  1251. Function 09h    Initialize Two Fixed Disk Base Tables    (XT, AT, XT/286, PS/2)
  1252.                 (install nonstandard drive)
  1253. entry   AH      09h
  1254.         DL      80h-0FFh  hard disk number
  1255. return  CF      set on error
  1256.                 AH      status code (see 01h above)
  1257.                 For PC, XT hard disks, the disk parameter block format is:
  1258.                 00h-01h maximum number of cylinders
  1259.                 02h     maximum number of heads
  1260.                 03h-04h starting reduced write current cylinder
  1261.                 05h-06h starting write precompensation cylinder
  1262.                 07h     maximum ECC burst length
  1263.                 08h     drive options
  1264.                    bits 7       1       disable disk access retries
  1265.                         6       1       disable ECC retries
  1266.                         3-5     set to 0
  1267.                         0-2     drive option
  1268.                 09h     standard timeout value
  1269.                 0Ah     timeout value for format drive
  1270.                 0Bh     timeout value for check drive
  1271.                 0Ch-0Fh reserved
  1272.  
  1273.                 For AT and PS/2 hard disks:
  1274.                 00h-01h maximum number of cylinders
  1275.                 02h     maximum number of heads
  1276.                 03h-04h reserved
  1277.                 05h-06h starting write precompensation cylinder
  1278.                 07h     maximum ECC burst length
  1279.                 08h     drive options byte
  1280.                    bits 6-7     nonzero (10, 01, or 11) if retries disabled
  1281.                         5       1       if manufacturer's defect map present at
  1282.                                         maximum cylinder + 1
  1283.                         4       not used
  1284.                         3       1       if more than 8 heads
  1285.                         0-2     not used
  1286.                 09h-0Bh reserved
  1287.                 0Ch-0Dh landing zone cylinder
  1288.                 0Eh     sectors per track
  1289.                 0Fh     reserved
  1290. note 1) For the XT, int 41h must point to the Disk Parameter Block.
  1291.      2) For the AT and PS/2, int 41h points to table for drive 0 and int 46h
  1292.         points to table for drive 1.
  1293.      3) Initializes the hard disk controller for subsequent I/O operations
  1294.         using the values found in the BIOS disk parameter block(s).
  1295.      4) This function is supported on hard disks only.
  1296.  
  1297.  
  1298. Function 0Ah    Read Long   (Hard disk)                 (XT, AT, XT/286, PS/2)
  1299. entry   AH      0Ah
  1300.         CH      cylinder number (bits 8,9 in high bits of CL)
  1301.         CL      sector number (upper 2 bits of cyl # in upper 2 bits of CL)
  1302.         DH      head number
  1303.         DL      drive ID  (80h-0FFh hard disk)
  1304.         ES:BX   pointer to buffer to fill
  1305. return  CF      set on error
  1306.                 AH      status code (see 01h above)
  1307.         AL      number of sectors actually transferred
  1308. note 1) A "long" sector includes a 4 byte EEC (Extended Error Correction) code.
  1309.      2) Used for diagnostics only on PS/2 systems.
  1310.      3) This function is supported on fixed disks only.
  1311.      4) Unlike the normal Read Sector (02h) function, ECC errors are not
  1312.         automatically corrected. Multisector transfers are terminated after any
  1313.         sector with a read error.
  1314.  
  1315.  
  1316. Function 0Bh    Write Long                              (XT, AT, XT/286, PS/2)
  1317. entry   AH      0Bh
  1318.         AL      number of sectors
  1319.         CH      cylinder (bits 8,9 in high bits of CL)
  1320.         CL      sector number
  1321.         DH      head number
  1322.         DL      drive ID  (80h-0FFh hard disk)
  1323.         ES:BX   pointer to buffer containing data
  1324. return  CF      set on error
  1325.                 AH      status code (see 01h above)
  1326.         AL      number of sectors actually transferred
  1327. note 1) A "long" sector includes a 4 byte EEC (Extended Error Correction) code.
  1328.      2) Used for diagnostics only on PS/2 systems.
  1329.      3) Valid for hard disks only.
  1330.  
  1331.  
  1332. Function 0Ch    Seek To Cylinder                        (except PC, PCjr)
  1333. entry   AH      0Ch
  1334.         CH      lower 8 bits of cylinder
  1335.         CL      upper 2 bits of cylinder in bits 6-7
  1336.         DH      head number
  1337.         DL      drive number (0 or 1)  (80h-0FFh for hard disk)
  1338. return  CF      set on error
  1339.                 AH      status code (see 01h above)
  1340. note 1) Positions heads over a particular cylinder, but does not move any data.
  1341.      2) This function is supported on hard disks only.
  1342.      3) The upper 2 bits of the 10-bit cylinder number are placed in the upper
  1343.         2 bits of CL.
  1344.      4) The Read Sector, Read Sector Long, Write Sector, and Write Sector Long
  1345.         functions include an implied seek operation and need not be preceded by
  1346.         an explicit call to this function.
  1347.  
  1348.  
  1349. Function 0Dh    Alternate Hard Disk Reset                    (except PC, PCjr)
  1350. entry   AH      0Dh
  1351.         DL      hard drive number (80h-0FFh hard disk)
  1352. return  CF      set on error
  1353.                 AH      status code (see 01h above)
  1354. note 1) Not for PS/2 ESDI hard disks.
  1355.      2) Resets the hard disk controller, recalibrates attached drives (moves
  1356.         the read/write arm to cylinder 0), and prepares for subsequent disk I/O.
  1357.      3) This function is for hard disks only. It differs from fn 00h by not
  1358.         resetting the floppy disk controller.
  1359.  
  1360.  
  1361. Function 0Eh    Read Sector Buffer                         (XT, Portable, PS/2)
  1362. entry   AH      0Eh
  1363.         ES:BX   pointer to buffer
  1364. return  CF      set on error
  1365.                 AH      status code (see 01h above)
  1366.         AL      number of sectors actually transferred
  1367. note 1) Transfers controller's sector buffer. No data is read from the drive.
  1368.      2) Used for diagnostics only on PS/2 systems.
  1369.      3) This fn is supported by the XT's hard disk adapter only. It is "not
  1370.         defined" for hard disk adapters on the AT or PS/2.
  1371.  
  1372.  
  1373. Function 0Fh    Write sector buffer                          (XT, Portable)
  1374. entry   AH      0Fh
  1375.         ES:BX   pointer to buffer
  1376. return  CF      set if error
  1377.                 AH      status code (see 01h above)
  1378.         AL      number of sectors actually transferred
  1379. note 1) Should be called before formatting to initialize the controller's
  1380.         sector buffer.
  1381.      2) Used for diagnostics only on PS/2 systems.
  1382.      3) Transfers data from system RAM to the hard disk adapter's internal
  1383.         sector buffer.
  1384.      4) No data is written to the physical disk drive.
  1385.      5) This fn is for the XT hard disk controller only. It is "not defined"
  1386.         for AT or PS/2 controllers.
  1387.  
  1388.  
  1389. Function 10h    Test For Drive Ready                  (XT, AT, XT/286, PS/2)
  1390. entry   AH      10h
  1391.         DL      hard drive number 0 or 1 (80h-0FFh)
  1392. return  CF      set on error
  1393.                 AH      status code (see 01h above)
  1394. note 1) Tests whether the specified hard disk drive is operational and returns
  1395.         the drive's status.
  1396.      2) This function is supported on hard disks only.
  1397.      3) Perstor and Novell controllers allow more than one controller. Does
  1398.         not work for multiple Perstor controllers. (reports first two drives
  1399.         only).
  1400.      4) Does not work with network drives.
  1401.  
  1402.  
  1403. Function 11h    Recalibrate Drive                      (XT, AT, XT/286, PS/2)
  1404. entry   AH      11h
  1405.         DL      hard drive number (80h-0FFh hard disk)
  1406. return  CF      set on error
  1407.                 AH      status code (see 01h above)
  1408. note 1) Causes the HD controller to recalibrate itself for the specified drive,
  1409.         positioning the read/arm to cylinder 0, and returns the drive's status.
  1410.      2) This function is for hard disks only.
  1411.  
  1412.  
  1413. Function 12h    Controller RAM Diagnostics                (XT, Portable, PS/2)
  1414. entry   AH      12h
  1415. return  CF      set on error
  1416.                 AH      status code (see fn 01h above)
  1417. note 1) Used for diagnostics only on PS/2 systems.
  1418.      2) Makes the hard disk controller carry out a built-in diagnostic test on
  1419.         its internal sector buffer.
  1420.  
  1421.  
  1422. Function 13h    Controller Drive Diagnostic               (XT, Portable, PS/2)
  1423. entry   AH      13h
  1424. return  CF      set on error
  1425.                 AH      status code (see 01h above)
  1426. note 1) Used for diagnostics only on PS/2 systems.
  1427.      2) Causes HD controller to run internal diagnostic tests of the attached
  1428.         drive, indicating whether the test was passed by the returned status.
  1429.      3) This function is supported on XT HDs only.
  1430.  
  1431.  
  1432. Function 14h    Controller Internal Diagnostic               (AT, XT/286)
  1433. entry   AH      14h
  1434. return  CF      set on error
  1435.         AH      status code (see 01h above)
  1436. note 1) OEM is Western Digital 1003-WA2 hard/floppy combination controller
  1437.         in AT and XT/286.
  1438.      2) Used for diagnostics only in PS/2 systems.
  1439.      3) Causes HD controller to do a built-in diagnostic self-test, indicating
  1440.         whether the test was passed by the returned status.
  1441.      4) This function is supported on hard disks only.
  1442.  
  1443.  
  1444. Function 15h    Get Disk Type                                (except PC and XT)
  1445. entry   AH      15h
  1446.         DL      drive ID
  1447.                 00h-7Fh   floppy disk
  1448.                 80h-0FFh  fixed disk
  1449. return  CF      set on error
  1450.                 AH      error code (see 01h above)
  1451.         AH      disk type
  1452.                 00h     no drive is present
  1453.                 01h     diskette, no change detection present
  1454.                 02h     diskette, change detection present
  1455.                 03h     hard disk
  1456.                         CX:DX   number of 512-byte sectors
  1457. note 1) Returns a code indicating the type of disk referenced by the specified
  1458.         drive code.
  1459.      2) This function is not supported on the PC or XT.
  1460.  
  1461.  
  1462. Function 16h    Get Disk Change Status (diskette)      (except PC, XT, & Jr)
  1463. entry   AH      16h
  1464.         DL      drive to check
  1465. return  CF      set on error
  1466.         AH      disk change status
  1467.                 00h     no disk change
  1468.                 01h     disk changed
  1469.         DL      drive that had disk change (00h-07Fh floppy disk)
  1470. note    Returns the status of the change line, indicating whether the disk in
  1471.         the drive may have been replaced since the last disk access. If this
  1472.         function returns with CF set, the disk has not necessarily been
  1473.         changed; the change line can be activated by simply unlocking and
  1474.         relocking the disk drive door without removing the floppy disk.
  1475.  
  1476.  
  1477. Function 17h    Set Disk Type for Format (diskette)          (except PC and XT)
  1478. entry   AH      17h
  1479.         AL      00h     not used
  1480.                 01h     160, 180, 320, or 360Kb diskette in 360kb drive
  1481.                 02h     360Kb diskette in 1.2Mb drive
  1482.                 03h     1.2Mb diskette in 1.2Mb drive
  1483.                 04h     720Kb diskette in 720Kb drive
  1484.         DL      drive number (0-7)
  1485. return  CF      set on error
  1486.         AH      status of operation (see 01h above)
  1487. note 1) This function is probably enhanced for the PS/2 series to detect
  1488.         1.44 in 1.44 and 720k in 1.44.
  1489.      2) This function is not supported for floppy disks on the PC or XT.
  1490.      3) If the change line is active for the specified drive, it is reset.
  1491.      4) The BIOS sets the data rate for the specified drive and media type.
  1492.         The rate is 250k/sec for double-density media and 500k/sec for high
  1493.         density media. The proper hardware is required.
  1494.  
  1495.  
  1496. Function 18h    Set Media Type For Format  (diskette)   (AT, XT2, XT/286, PS/2)
  1497. entry   AH      18h
  1498.         CH      lower 8 bits of number of tracks
  1499.         CL      high 2 bits of number of tracks (6,7) sectors per track
  1500.                 (bits 0-5)
  1501.         DL      drive number (0-7)
  1502. return  CF      clear   no errors
  1503.         AH      00h      if requested combination supported
  1504.                 01h      if function not available
  1505.                 0Ch      if not suppported or drive type unknown
  1506.                 80h      if there is no media in the drive
  1507.         ES:DI   pointer to 11-byte disk parameter table for media type
  1508.         CF      set     error code (see 01h above)
  1509. note 1) A floppy disk must be present in the drive.
  1510.      2) This function should be called prior to formatting a disk with Int 13h
  1511.         Fn 05h so the BIOS can set the correct data rate for the media.
  1512.      3) If the change line is active for the specified drive, it is reset.
  1513.  
  1514.  
  1515. Function 19h    Park Hard Disk Heads                         (PS/2)
  1516. entry   AH      19h
  1517.         DL      drive number (80h-0FFh)
  1518. return  CF      set on error
  1519.                 AH      error code (see fn 01h)
  1520. note    This function is defined for PS/2 fixed disks only.
  1521.  
  1522.  
  1523. Function 1Ah    ESDI Hard Disk - Low Level Format                      (PS/2)
  1524. entry   AH      1Ah
  1525.         AL      Relative Block Address (RBA) defect table count
  1526.                 00h     no errors on disk
  1527.                 01h+    number of disk errors
  1528.         CL      format modifiers byte
  1529.            bits 0       ignore primary defect map
  1530.                 1       ignore secondary defect map
  1531.                 2       update secondary defect map
  1532.                 3       perform extended surface analysis
  1533.                 4       generate periodic interrupt after each cylinder format
  1534.                 5       reserved - must be 0
  1535.                 6       reserved - must be 0
  1536.                 7       reserved - must be 0
  1537.         DL      drive  (80h-0FFh)
  1538.         ES:BX   pointer to RBA defect table
  1539. return  CF      set on error
  1540.                 AH      error code (see fn 01h above)
  1541. note 1) Initializes disk sector and track address fields on a drive attached
  1542.         to the IBM "ESDI Fixed Disk Drive Adapter/A."
  1543.      2) If periodic interrupt selected, int 15h/fn 0Fh is called after each
  1544.         cylinder is formatted
  1545.      3) If bit 4 of CL is set, Int 15h, AH=0Fh, AL=phase code after each
  1546.         cylinder is formatted or analyzed. The phase code is defined as:
  1547.         0       reserved
  1548.         1       surface analysis
  1549.         2       formatting
  1550.      4) If bit 2 of CL is set, the drive's secondary defect map is updated to
  1551.         reflect errors found during surface analysis. If both bit 2 and bit 1
  1552.         are set, the secondary defect map is replaced.
  1553.      5) For an extended surface analysis, the disk should first be formatted by
  1554.         calling this function with bit 3 cleared and then analyzed by calling
  1555.         this function with bit 3 set.
  1556.  
  1557.  
  1558. Function 1Bh    ESDI Hard Disk - Get Manufacturing Header       (PS/2)
  1559. entry   AH      1Bh
  1560.         AL      number of record
  1561.         DL      drive
  1562.         ES:BX   pointer to buffer for manufacturing header (defect list)
  1563. return  CF      set on error
  1564.         AH      status
  1565. note    Manufacturing header format (Defect Map Record format) can be found
  1566.         in the "IBM 70Mb, 115Mb Fixed Disk Drives Technical Reference."
  1567.  
  1568.  
  1569. Function 1Ch    ESDI Hard Disk - Get Configuration                  (PS/2)
  1570. entry   AH      1Ch
  1571.         AL      0Ah     Get Device Configuration
  1572.                         DL      drive
  1573.                         ES:BX   pointer to buffer for device configuration
  1574.                                 (drive physical parameter)
  1575.                 0Bh     Get Adapter Configuration
  1576.                         ES:BX   pointer to buffer for adapter configuration
  1577.                 0Ch     Get POS Information
  1578.                         ES:BX   pointer to POS information
  1579.                 0Dh     unknown
  1580.                 0Eh     Translate RBA to ABA
  1581.                         CH      low 8 bits of cylinder number
  1582.                         CL      sector number, high two bits of cylinder number
  1583.                                 in bits 6 and 7
  1584.                         DH      head number
  1585.                         DL      drive number
  1586.                         ES:BX   pointer to ABA number
  1587.  
  1588. return  CF      set on error
  1589.                 AH      status (see 01h)
  1590. note 1) Device configuration format can be found in IBM ESDI Fixed Disk Drive
  1591.         Adapter/A Technical Reference.
  1592.      2) ABA (absolute block address) format can be found in IBM ESDI Adapter
  1593.         Technical Reference by using its Device Configuration Status Block.
  1594.  
  1595.  
  1596. Function 1Dh    IBMCACHE.SYS                                (PS/2 50+)
  1597. entry   AH      1Dh
  1598. other parameters unknown
  1599. note    IBMCACHE.SYS comes on the setup disk for MCA-bus PS/2 machines.
  1600.  
  1601.  
  1602. Function 20h    Western Digital HD SuperBIOS
  1603. entry   AH      20h
  1604. other parameters unknown
  1605. note    SuperBIOS may be purchased separately from Western Digital and added
  1606.         to standard HD controllers. SuperBIOS contains additional setup
  1607.         tables and parameters.
  1608.  
  1609.