add directory study
This commit is contained in:
BIN
study/sabre/os/files/Disk/82077AA_FloppyControllerDatasheet.pdf
Normal file
BIN
study/sabre/os/files/Disk/82077AA_FloppyControllerDatasheet.pdf
Normal file
Binary file not shown.
476
study/sabre/os/files/Disk/CDROM.txt
Normal file
476
study/sabre/os/files/Disk/CDROM.txt
Normal file
@@ -0,0 +1,476 @@
|
||||
|
||||
CD-ROM Technical Summary
|
||||
From Plastic Pits to "Fantasia"
|
||||
|
||||
Andy Poggio
|
||||
March 1988
|
||||
|
||||
|
||||
Abstract
|
||||
|
||||
This summary describes how information is encoded on Compact Disc (CD)
|
||||
beginning with the physical pits and going up through higher levels of
|
||||
data encoding to the structured multimedia information that is
|
||||
possible with programs like HyperCard. This discussion is much
|
||||
broader than any single standards document, e.g. the CD-Audio Red
|
||||
Book, while omitting much of the detail needed only by drive
|
||||
manufacturers.
|
||||
|
||||
|
||||
Salient Characteristics
|
||||
|
||||
1. High information density -- With the density achievable using
|
||||
optical encoding, the CD can contain some 540 megabytes of data on a
|
||||
disc less than five inches in diameter.
|
||||
|
||||
2. Low unit cost -- Because CDs are manufactured by a well-developed
|
||||
process similar to that used to stamp out LP records, unit cost in
|
||||
large quantities is less than two dollars.
|
||||
|
||||
3. Read only medium -- CD-ROM is read only; it cannot be written on
|
||||
or erased. It is an electronic publishing, distribution, and access
|
||||
medium; it cannot replace magnetic disks.
|
||||
|
||||
4. Modest random access performance -- Due to optical read head mass
|
||||
and data encoding methods, random access ("seek time") performance of
|
||||
CD is better than floppies but not as good as magnetic hard disks.
|
||||
|
||||
5. Robust, removable medium -- The CD itself is comprised mostly of,
|
||||
and completely coated by, durable plastic. This fact and the data
|
||||
encoding method allow the CD to be resistant to scratches and other
|
||||
handling damage. Media lifetime is expected to be long, well beyond
|
||||
that of magnetic media such as tape. In addition, the optical servo
|
||||
scanning mechanism allows CDs to be removed from their drives.
|
||||
|
||||
6. Multimedia storage -- Because all CD data is stored digitally, it
|
||||
is inherently multimedia in that it can store text, images, graphics,
|
||||
sound, and any other information expressed in digital form. Its only
|
||||
limit in this area is the rate at which data can be read from the
|
||||
disc, currently about 150 KBytes/second. This is sufficient for all
|
||||
but uncompressed, full motion color video.
|
||||
|
||||
|
||||
CD Data Hierarchy
|
||||
|
||||
Storing data on a CD may be thought of as occurring through a data
|
||||
encoding hierarchy with each level built upon the previous one. At
|
||||
the lowest level, data is physically stored as pits on the disc. It
|
||||
is actually encoded by several low-level mechanisms to provide high
|
||||
storage density and reliable data recovery. At the next level, it
|
||||
organized into tracks which may be digital audio or CD-ROM. The High
|
||||
Sierra specification then defines a file system built on CD-ROM
|
||||
tracks. Finally, applications like HyperCard specify a content format
|
||||
for files.
|
||||
|
||||
|
||||
The Physical Medium
|
||||
|
||||
The Compact Disc itself is a thin plastic disk some 12 cm. in
|
||||
diameter. Information is encoded in a plastic-encased spiral track
|
||||
contained on the top of the disk. The spiral track is read optically
|
||||
by a noncontact head which scans approximately radially as the disk
|
||||
spins just above it. The spiral is scanned at a constant linear
|
||||
velocity thus assuring a constant data rate. This requires the disc
|
||||
to rotate at a decreasing rate as the spiral is scanned from its
|
||||
beginning near the center of the disc to its end near the disc
|
||||
circumference.
|
||||
|
||||
The spiral track contains shallow depressions, called pits, in a
|
||||
reflective layer. Binary information is encoded by the lengths of
|
||||
these pits and the lengths of the areas between them, called land.
|
||||
During reading, a low power laser beam from the optical head is
|
||||
focused on the spiral layer and is reflected back into the head. Due
|
||||
to the optical characteristics of the plastic disc and the wavelength
|
||||
of light used, the quantity of reflected light varies depending on
|
||||
whether the beam is on land or on a pit. The modulated, reflected
|
||||
light is converted to a radio frequency, raw data signal by a
|
||||
photodetector in the optical head.
|
||||
|
||||
|
||||
Low-level Data Encoding
|
||||
|
||||
To ensure accurate recovery, the disc data must be encoded to optimize
|
||||
the analog-to-digital conversion process that the radio frequency
|
||||
signal must undergo. Goals of the low level data encoding include:
|
||||
|
||||
1. High information density. This requires encoding that makes the
|
||||
best possible use of the high, but limited, resolution of the laser
|
||||
beam and read head optics.
|
||||
|
||||
2. Minimum intersymbol interference. This requires making the
|
||||
minimum run length, i.e. the minimum number of consecutive zero bits
|
||||
or one bits, as large as possible.
|
||||
|
||||
3. Self-clocking. To avoid a separate timing track, the data should
|
||||
be encoded so as to allow the clock signal to be regenerated from the
|
||||
data signal. This requires limiting the maximum run length of the
|
||||
data so that data transitions will regenerate the clock.
|
||||
|
||||
4. Low digital sum value (the number of one bits minus the number of
|
||||
zero bits). This minimizes the low frequency and DC content of the
|
||||
data signal which permits optimal servo system operation.
|
||||
|
||||
A straightforward encoding would be to simply to encode zero bits as
|
||||
land and one bits as pits. However, this does not meet goal (1) as
|
||||
well as the encoding scheme actually used. The current CD scheme
|
||||
encodes one bits as transitions from pit to land or land to pit and
|
||||
zero bits as constant pit or constant land.
|
||||
|
||||
To meet goals (2) to (4), it is not possible to encode arbitrary
|
||||
binary data. For example, the integer 0 expressed as thirty-two bits
|
||||
of zero would have too long a run length to satisfy goal (3). To
|
||||
accommodate these goals, each eight-bit byte of actual data is encoded
|
||||
as fourteen bits of channel data. There are many more combinations of
|
||||
fourteen bits (16,384) than there are of eight bits (256). To encode
|
||||
the eight-bit combinations, 256 combinations of fourteen bits are
|
||||
chosen that meet the goals. This encoding is referred to as
|
||||
Eight-to-Fourteen Modulation (EFM) coding.
|
||||
|
||||
If fourteen channel bits were concatenated with another set of
|
||||
fourteen channel bits, once again the above goals may not be met. To
|
||||
avoid this possibility, three merging bits are included between each
|
||||
set of fourteen channel bits. These merging bits carry no information
|
||||
but are chosen to limit run length, keep data signal DC content low,
|
||||
etc. Thus, an eight bit byte of actual data is encoded into a total
|
||||
of seventeen channel bits: fourteen EFM bits and three merging bits.
|
||||
|
||||
To achieve a reliable self-clocking system, periodic synchronization
|
||||
is necessary. Thus, data is broken up into individual frames each
|
||||
beginning with a synchronization pattern. Each frame also contains
|
||||
twenty-four data bytes, eight error correction bytes, a control and
|
||||
display byte (carrying the subcoding channels), and merging bits
|
||||
separating them all. Each frame is arranged as follows:
|
||||
|
||||
Sync Pattern 24 + 3 channel bits
|
||||
Control and Display byte 14 + 3
|
||||
Data bytes 12 * (14 + 3)
|
||||
Error Correction bytes 4 * (14 + 3)
|
||||
Data bytes 12 * (14 + 3)
|
||||
Error Correction bytes 4 * (14 + 3)
|
||||
|
||||
TOTAL 588 channel bits
|
||||
|
||||
Thus, 192 actual data bits (24 bytes) are encoded as 588 channel bits.
|
||||
|
||||
Editorial: A CD physically has a single spiral track about 3 miles
|
||||
long. CDs spin at about 500 RPM when reading near the center down to
|
||||
about 250 RPM when reading near the circumference.
|
||||
|
||||
Disc with a 'c' or disk with a 'k'? A usage has emerged for these
|
||||
terms: disk is used for eraseable disks (e.g. magnetic disks) while
|
||||
disc is used for read-only (e.g. CD-ROM discs). One would presumably
|
||||
call a frisbee a disc.
|
||||
|
||||
|
||||
First Level Error Correction
|
||||
|
||||
Data errors can arise from production defects in the disk itself,
|
||||
defects arising from subsequent damage to the disk, or jarring during
|
||||
reading. A significant characteristic of these errors is that they
|
||||
often occur in long bursts. This could be due, for example, to a
|
||||
relatively wide mark on the disc that is opaque to the laser beam used
|
||||
to read the disc. A system with two logical components called the
|
||||
Cross Interleave Reed-Solomon Coding (CIRC) is employed for error
|
||||
correction. The cross interleave component breaks up the long error
|
||||
bursts into many short errors; the Reed-Solomon component provides the
|
||||
error correction.
|
||||
|
||||
As each frame is read from the disc, it is first decoded from fourteen
|
||||
channel bits (the three merging bits are ignored) into eight-bit data
|
||||
bytes. Then, the bytes from each frame (twenty-four data bytes and
|
||||
eight error correction bytes) are passed to the first Reed-Solomon
|
||||
decoder which uses four of the error correction bytes and is able to
|
||||
correct one byte in error out of the 32. If there are no
|
||||
uncorrectable errors, the data is simply passed along. If there are
|
||||
errors, the data is marked as being in error at this stage of
|
||||
decoding.
|
||||
|
||||
The twenty-four data bytes and four remaining error correction bytes
|
||||
are then passed through unequal delays before going through another
|
||||
Reed-Solomon decoder. These unequal delays result in an interleaving
|
||||
of the data that spreads long error bursts among many different passes
|
||||
through the second decoder. The delays are such that error bursts up
|
||||
to 450 bytes long can be completely corrected. The second
|
||||
Reed-Solomon decoder uses the last four error correction bytes to
|
||||
correct any remaining errors in the twenty-four data bytes. At this
|
||||
point, the data goes through a de-interleaving process to restore the
|
||||
correct byte order.
|
||||
|
||||
|
||||
Subcoding Channels and Blocks
|
||||
|
||||
The eight-bit control and display byte in each frame carries the
|
||||
subcoding channels. A subcoding block consists of 98 subcoding bytes,
|
||||
and thus 98 of the 588-bit frames. A block then can contain 2352
|
||||
bytes of data. Seventy-five blocks are read each second. With this
|
||||
information, it is now straightforward to calculate that the CD data
|
||||
rate is in fact correct for CD digital audio (CD-DA):
|
||||
|
||||
Required CD digital audio data rate: 44.1 K samples per second * 16
|
||||
bits per sample * 2 channels = 1,411,200 bits/sec.
|
||||
|
||||
CD data rate: 8 bits per byte * 24 bytes per frame * 98 frames per
|
||||
subcoding block * 75 subcoding blocks per second = 1,411,200 bits/sec.
|
||||
|
||||
The eight subcoding channels are labeled P through W and are encoded
|
||||
one bit for each channel in a control and display byte. Channel P is
|
||||
used as a simple music track separator. Channel Q is used for control
|
||||
purposes and encodes information like track number, track type, and
|
||||
location (minute, second, and frame number). During the lead-in track
|
||||
of the disc, channel Q encodes a table of contents for the disk giving
|
||||
track number and starting location. Standards have been proposed that
|
||||
would use the remaining channels for line graphics and ASCII character
|
||||
strings, but these are seldom used.
|
||||
|
||||
|
||||
Track Types
|
||||
|
||||
Tracks can have two types as specified in the control bit field of
|
||||
subchannel Q. The first type is CD digital audio (CD-DA) tracks. The
|
||||
two-channel audio is sampled at 44.1 Khz with sixteen bit linear
|
||||
sampling encoded as twos complement numbers. The sixteen bit samples
|
||||
are separated into two eight-bit bytes; the bytes from each channel
|
||||
alternate on the disc. Variations for audio tracks include
|
||||
pre-emphasis and four track recording.
|
||||
|
||||
The other type of track specified by the subchannel Q control bit
|
||||
field is the data track. These must conform to the CD-ROM standard
|
||||
described below. In general, a disc can have a mix of CD digital
|
||||
audio tracks and a CD-ROM track, but the CD-ROM track must come first.
|
||||
|
||||
Editorial: This first level error correction (the only type used for
|
||||
CD Audio data) is extremely powerful. The CD specification allows for
|
||||
discs to have up to 220 raw errors per second. Every one of these
|
||||
errors is (almost always) perfectly corrected by the CIRC scheme for a
|
||||
net error rate of zero. For example, our tests using Apple's CD-ROM
|
||||
drive (which also plays audio) show that raw error rates are around
|
||||
50-100 per second these days. Of course, these are perfectly
|
||||
corrected, meaning that the original data is perfectly recovered. We
|
||||
have tested flawed discs with raw rates up to 300 per second. Net
|
||||
errors on all of these discs? Zero! I would expect a typical audio
|
||||
CD player to perform similarly. Thus I expect this raw error rate to
|
||||
have no audible consequences.
|
||||
|
||||
So why did I say "almost always" corrected above? Because a
|
||||
sufficiently bad flaw may produce uncorrectable errors. These very
|
||||
unusual errors are "concealed" by the player rather than corrected.
|
||||
Note that this concealment is likely to be less noticeable than even a
|
||||
single scratch on an LP. Such a flaw might be a really opaque finger
|
||||
smudge; CDs do merit careful handling. On the two (and only two)
|
||||
occasions I have found these, I simply sprayed on a little Windex
|
||||
glass cleaner and wiped it off using radial strokes. This restored
|
||||
the CDs to zero net errors.
|
||||
|
||||
One can argue about the quality of the process of conversion of analog
|
||||
music to and from digital representation, but in the digital domain
|
||||
CDs are really very, very good.
|
||||
|
||||
|
||||
CD-ROM Data Tracks
|
||||
|
||||
Each CD-ROM data track is divided into individually addressable blocks
|
||||
of 2352 data bytes, i.e. one subcoding block or 98 frames. A header
|
||||
in each block contains the block address and the mode of the block.
|
||||
The block address is identical to the encoding of minute, second, and
|
||||
frame number in subcode channel Q. The modes defined in the CD-ROM
|
||||
specification are:
|
||||
|
||||
Mode 0 -- all data bytes are zero.
|
||||
|
||||
Mode 1 -- (CD-ROM Data):
|
||||
Sync Field - 12 bytes
|
||||
Header Field - 4
|
||||
User Data Field - 2048
|
||||
Error Detection Code - 4
|
||||
Reserved - 8
|
||||
Error Correction - 276
|
||||
|
||||
Mode 2 -- (CD Audio or Other Data):
|
||||
Sync Field - 12 bytes
|
||||
Header Field - 4
|
||||
User Data Field - 2048
|
||||
Auxiliary Data Field - 288
|
||||
|
||||
Thus, mode 1 defines separately addressable, physical 2K byte data
|
||||
blocks making CD-ROM look at this level very similar to other digital
|
||||
mass storage devices.
|
||||
|
||||
|
||||
Second Level Error Correction
|
||||
|
||||
An uncorrected error in audio data typically results in a brief, often
|
||||
inaudible click during listening at worst. An uncorrected error in
|
||||
other kinds of data, for example program code, may render a CD
|
||||
unusable. For this reason, CD-ROM defines a second level of error
|
||||
detection and error correction (EDC/ECC) for mode 1 data. The
|
||||
information for the EDC/ECC occupies most of the auxiliary data field.
|
||||
|
||||
The error detection code is a cyclic redundancy check (CRC) on the
|
||||
sync, header, and user data. It occupies the first four bytes of the
|
||||
auxiliary data field and provides a very high probability that
|
||||
uncorrected errors will be detected. The error correction code is
|
||||
essentially the same as the first level error correction in that
|
||||
interleaving and Reed-Solomon coding are used. It occupies the final
|
||||
276 bytes of the auxiliary data field.
|
||||
|
||||
Editorial: This extra level of error correction for CD-ROM blocks is
|
||||
one of the many reasons that CD-ROM drives are much more expensive
|
||||
than consumer audio players. To perform this error correction quickly
|
||||
requires substantial extra computing power (sometimes a dedicated
|
||||
microprocessor) in the drive.
|
||||
|
||||
This is also one reason that consumer players like the Magnavoxes
|
||||
which claim to be CD-ROM compatible (with their digital output jack on
|
||||
the back) are useless for that purpose. They have no way of dealing
|
||||
with the CD-ROM error correction. They also have no way for a
|
||||
computer to tell them where to seek.
|
||||
|
||||
Another reason that CD-ROM drives are more expensive is that they are
|
||||
built to be a computer peripheral rather than a consumer device, i.e.
|
||||
like a combination race car/truck rather than a family sedan. One
|
||||
story, probably apocryphal but not far from the truth, has it that a
|
||||
major Japanese manufacturer tested some consumer audio players to
|
||||
simulate computer use: they made them seek (move the optical head)
|
||||
from the inside of the CD to the outside and back again. These are
|
||||
called maximum seeks. The story says they managed to do this for
|
||||
about 24 hours before they broke down. A CD-ROM drive needs to be
|
||||
several orders of magnitude more robust. Fast and strong don't come
|
||||
cheap.
|
||||
|
||||
|
||||
The High Sierra File System Standard
|
||||
|
||||
Built on top of the addressable 2K blocks that the CD-ROM
|
||||
specification defines, the next higher level of data encoding is a
|
||||
file system that permits logical organization of the data on the CD.
|
||||
This can be a native file system like the Macintosh Hierarchical File
|
||||
System (HFS). Another alternative is the High Sierra (also known as
|
||||
the ISO 9660) file standard, recently approved by the National
|
||||
Information Standards Organization (NISO) and the International
|
||||
Standards Organization (ISO), which defines a file system carefully
|
||||
tuned to CD characteristics. In particular:
|
||||
|
||||
1. CDs have modest seek time and high capacity. As a result, the
|
||||
High Sierra standard makes tradeoffs that reduce the number of seeks
|
||||
needed to read a file at the expense of space efficiency.
|
||||
|
||||
2. CDs are read-only. Thus, concerns like space allocation, file
|
||||
deletion, and the like are not addressed in the specification.
|
||||
|
||||
For High Sierra file systems, each individual CD is a volume. Several
|
||||
CDs may be grouped together in a volume set and there is a mechanism
|
||||
for subsequent volumes in a set to update preceding ones. Volumes can
|
||||
contain standard file structures, coded character set file structures
|
||||
for character encoding other than ASCII, or boot records. Boot
|
||||
records can contain either data or program code that may be needed by
|
||||
systems or applications.
|
||||
|
||||
|
||||
High Sierra Directories and Files
|
||||
|
||||
The file system is a hierarchical one in which directories may contain
|
||||
files or other directories. Each volume has a root directory which
|
||||
serves as an ancestor to all other directories or files in the volume.
|
||||
This dictates an overall tree structure for the volume.
|
||||
|
||||
A typical disadvantage in hierarchical systems is that to read a file
|
||||
(which must be a leaf of the hierarchy tree) given its full path name,
|
||||
it is necessary to begin at the root directory and search through each
|
||||
of its ancestral directories until the entry for the file is found.
|
||||
For example, given the path name
|
||||
|
||||
Wine Regions:America:California:Mendocino
|
||||
|
||||
three directories (the first three components of the path name) would
|
||||
need to be searched. Typically, a separate seek would be required for
|
||||
each directory. This would result in relatively poor performance.
|
||||
|
||||
To avoid this, High Sierra specifies that each volume contain a path
|
||||
table in addition to its directories and files. The path table
|
||||
describes the directory hierarchy in a compact form that may be cached
|
||||
in computer memory for optimum performance. The path table contains
|
||||
entries for the volume's directories in a breadth-first order;
|
||||
directories with a common parent are listed in lexicographic order.
|
||||
Each entry contains only the location of the directory it describes,
|
||||
its name, and the location in the path table of its parent. This
|
||||
mechanism allows any directory to be accessed with only a single CD
|
||||
seek.
|
||||
|
||||
Directories contain more detailed information than the path table.
|
||||
Each directory entry contains:
|
||||
|
||||
Directory or file location.
|
||||
File length.
|
||||
Date and time of creation.
|
||||
Name of the file.
|
||||
Flags:
|
||||
Whether the entry is for a file or a directory.
|
||||
Whether or not it is an associated file.
|
||||
Whether or not it has records.
|
||||
Whether or not it has read protection.
|
||||
Whether or not it has subsequent extents.
|
||||
Interleave structure of the file.
|
||||
|
||||
Interleaving may be used, for example, to meet realtime requirements
|
||||
for multiple files whose contents must be presented simultaneously.
|
||||
This would happen if a file containing graphic images were interleaved
|
||||
with a file containing compressed sound that describes the images.
|
||||
|
||||
Files themselves are recorded in contiguous (or interleaved) blocks on
|
||||
the disc. The read-only nature of CD permits this contiguous
|
||||
recording in a straightforward manner. A file may also be recorded in
|
||||
a series of noncontiguous extents with a directory entry for each
|
||||
extent.
|
||||
|
||||
The specification does not favor any particular computer architecture.
|
||||
In particular all significant, multibyte numbers are recorded twice,
|
||||
once with the most significant byte first and once with the least
|
||||
significant byte first.
|
||||
|
||||
|
||||
Multimedia Information
|
||||
|
||||
Using the file system are applications that create and portray
|
||||
multimedia information. While it is true that a CD can store anything
|
||||
that a magnetic disk can store (and usually much more of it), CDs will
|
||||
be used more for storing information than for storing programs. It is
|
||||
the very large storage capacity of CDs coupled with their low cost
|
||||
that opens up the possibilities for interactive, multimedia
|
||||
information to be used in a multitude of ways.
|
||||
|
||||
Programs like HyperCard, with it's ease of authoring and broad
|
||||
extensibility, are very useful for this purpose. Hypercard stacks,
|
||||
with related information such as color images and sound, can be easily
|
||||
and inexpensively stored on CDs despite their possibly very large
|
||||
size.
|
||||
|
||||
Editorial: The High Sierra file system gets its name from the location
|
||||
of the first meeting on it: the High Sierra Hotel at Lake Tahoe. It
|
||||
is much more commonly referred to as ISO 9660, though the two
|
||||
specifications are slightly different.
|
||||
|
||||
It has gotten very easy and inexpensive to make a CD-ROM disc (or
|
||||
audio CD). For example, you can now take a Macintosh hard disk and
|
||||
send it with $1500 to one of several CD pressers. They will send you
|
||||
back your hard disk and 100 CDs with exactly the same content as
|
||||
what's on your disk. This is the easy way to make CDs with capacity
|
||||
up to the size of your hard disk (Apple's go up to 160 megabytes).
|
||||
True, this is not a full CD but CDs don't need to be full. If you
|
||||
have just 10 megabytes and need 100 copies, CDs may be the best way to
|
||||
go.
|
||||
|
||||
If you are buying a CD-ROM drive, there are several factors you might
|
||||
consider in making your choice. Two factors NOT to consider are
|
||||
capacity and data rate. The capacity of all CD-ROM drives is
|
||||
determined solely by the CD they are reading. Though you will see a
|
||||
range of numbers in manufacturers' specs (e.g. 540, 550, 600, and 650
|
||||
Mbytes), any drive can read any disc and so they are all fundamentally
|
||||
the same. All CD-ROM drives read data at a net 150 Kbytes/sec for
|
||||
CD-ROM data. Other data rates you may see may include error
|
||||
correction data (not included in the net rate) or may be a mode 2 data
|
||||
rate (faster than mode 1). All drives will be the same in all of
|
||||
these specs.
|
||||
|
||||
|
||||
End of article.
|
||||
|
||||
2415
study/sabre/os/files/Disk/CHSTranslation.txt
Normal file
2415
study/sabre/os/files/Disk/CHSTranslation.txt
Normal file
File diff suppressed because it is too large
Load Diff
28
study/sabre/os/files/Disk/DOSSector2PhysicalSector.txt
Normal file
28
study/sabre/os/files/Disk/DOSSector2PhysicalSector.txt
Normal file
@@ -0,0 +1,28 @@
|
||||
From nntp.teleport.com!newsfeed.direct.ca!hunter.premier.net!news.mathworks.com!newsfeed.internetmci.com!vixen.cso.uiuc.edu!prairienet.org!dkrull Sun Aug 11 14:38:51 1996
|
||||
Path: nntp.teleport.com!newsfeed.direct.ca!hunter.premier.net!news.mathworks.com!newsfeed.internetmci.com!vixen.cso.uiuc.edu!prairienet.org!dkrull
|
||||
From: dkrull@prairienet.org (Don Krull)
|
||||
Newsgroups: comp.lang.asm.x86
|
||||
Subject: Re: DOS Sector => Physical Sector
|
||||
Date: 5 Aug 1996 11:41:54 GMT
|
||||
Organization: University of Illinois at Urbana
|
||||
Lines: 14
|
||||
Message-ID: <4u4mm2$2kn@vixen.cso.uiuc.edu>
|
||||
References: <4tiluk$d8c@josie.abo.fi>
|
||||
Reply-To: dkrull@prairienet.org (Don Krull)
|
||||
NNTP-Posting-Host: firefly.prairienet.org
|
||||
|
||||
|
||||
In a previous article, bhallstr@abo.fi asks:
|
||||
|
||||
> Does anyone have a formula for converting DOS Sectors to
|
||||
> Physical Sectors (Head, Cylinder, Sector) such as used in
|
||||
> INT 13h?
|
||||
|
||||
DOS_sector_num = BIOS_sector_num - 1 + Head_num*Sectors_per_track
|
||||
+ Track_num*Sectors_per_track*Total_heads
|
||||
|
||||
BIOS_sector_num = 1 + (DOS_sector_num MOD Sectors_per_track)
|
||||
|
||||
Don
|
||||
--
|
||||
|
||||
BIN
study/sabre/os/files/Disk/DeviceBaySpecsV0.90.pdf
Normal file
BIN
study/sabre/os/files/Disk/DeviceBaySpecsV0.90.pdf
Normal file
Binary file not shown.
410
study/sabre/os/files/Disk/FLOPPY.TXT
Normal file
410
study/sabre/os/files/Disk/FLOPPY.TXT
Normal file
@@ -0,0 +1,410 @@
|
||||
NEC <20>PD765 - Floppy Disk Controller - 8272A
|
||||
|
||||
PS/2 FDC Diskette Status Register A at 3F0h
|
||||
|
||||
<09>7<EFBFBD>6<EFBFBD>5<EFBFBD>4<EFBFBD>3<EFBFBD>2<EFBFBD>1<EFBFBD>0<EFBFBD> 3F0h PS/2 Disk Status Register A (read-only)
|
||||
<20> <20> <20> <20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD> direction
|
||||
<20> <20> <20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> write protect
|
||||
<20> <20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> index
|
||||
<20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> head 1 select
|
||||
<20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> track 0
|
||||
<20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> step
|
||||
<20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> second drive installed
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> interrupt pending
|
||||
|
||||
PS/2 FDC Diskette Status Register B at 3F1h
|
||||
|
||||
<09>7<EFBFBD>6<EFBFBD>5<EFBFBD>4<EFBFBD>3<EFBFBD>2<EFBFBD>1<EFBFBD>0<EFBFBD> 3F1h PS/2 Disk Status Register B (read-only)
|
||||
<20> <20> <20> <20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD> motor enable 0
|
||||
<20> <20> <20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD> motor enable 1
|
||||
<20> <20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD> write enable
|
||||
<20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD> read data (toggles w/positive transition in -RD DATA)
|
||||
<20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD> write data (toggles w/positive transition in WR DATA)
|
||||
<20> <20> <20><><EFBFBD><EFBFBD><EFBFBD> drive select
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> reserved
|
||||
|
||||
FDC Digital Output Register at 3F2h (all systems)
|
||||
|
||||
<09>7<EFBFBD>6<EFBFBD>5<EFBFBD>4<EFBFBD>3<EFBFBD>2<EFBFBD>1<EFBFBD>0<EFBFBD> port 3F2h (write only)
|
||||
<20> <20> <20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> floppy drive select (0=A, 1=B, 2=floppy C, ...)
|
||||
<20> <20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1 = FDC enable, 0 = hold FDC at reset
|
||||
<20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1 = DMA & I/O interface enabled (reserved PS/2)
|
||||
<20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1 = turn floppy drive A motor on
|
||||
<20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1 = turn floppy drive B motor on
|
||||
<20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1 = turn floppy drive C motor on; (reserved PS/2)
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1 = turn floppy drive D motor on; (reserved PS/2)
|
||||
|
||||
- used to control drive motors, drive selection, and feature enable
|
||||
- PS/2 only uses bit 0 for floppy drive select; bit 1 is reserved
|
||||
- PS/2 only uses bits 5 & 4 for motor enable; bits 7&6 are reserved
|
||||
- all DOR bits are cleared during controller reset
|
||||
|
||||
FDC Main Status Register at 3F4h (all systems)
|
||||
|
||||
<09>7<EFBFBD>6<EFBFBD>5<EFBFBD>4<EFBFBD>3<EFBFBD>2<EFBFBD>1<EFBFBD>0<EFBFBD> port 3F4h (read only)
|
||||
<20> <20> <20> <20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD> floppy drive 0 in seek mode/busy
|
||||
<20> <20> <20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> floppy drive 1 in seek mode/busy
|
||||
<20> <20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> floppy drive 2 in seek mode/busy (reserved PS/2)
|
||||
<20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> floppy drive 3 in seek mode/busy (reserved PS/2)
|
||||
<20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FDC read or write command in progress
|
||||
<20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FDC is in non-DMA mode
|
||||
<20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> I/O direction; 1 = FDC to CPU; 0 = CPU to FDC
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> data reg ready for I/O to/from CPU (request for master)
|
||||
|
||||
FDC Command Status Register 0 at 3F5h (all systems)
|
||||
|
||||
<09>7<EFBFBD>6<EFBFBD>5<EFBFBD>4<EFBFBD>3<EFBFBD>2<EFBFBD>1<EFBFBD>0<EFBFBD> Command Status Register 0 at port 3F5h
|
||||
<20> <20> <20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> unit selected at interrupt (0=A, 1=B, 2=...)
|
||||
<20> <20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> head number at interrupt (head 0 or 1)
|
||||
<20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> not ready on read/write or SS access to head 1
|
||||
<20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> equipment check (see note)
|
||||
<20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> set to 1 when FDD completes a seek command
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> last command status (see below)
|
||||
|
||||
Bits
|
||||
76 Last Command Status
|
||||
00 command terminated successfully
|
||||
01 command execution started but terminated abnormally
|
||||
10 invalid command issued
|
||||
11 command terminated abnormally due to a change in state of
|
||||
the Ready Signal from the FDC (reserved on PS/2)
|
||||
|
||||
- equipment check can occur if FDD signals a fault or track zero is
|
||||
not found after 77 steps on a recalibrate command
|
||||
- PS/2 only uses bits 1-0 for drive (values are 01b and 10b)
|
||||
|
||||
FDC Command Status Register 1 at 3F5h (all systems)
|
||||
|
||||
<09>7<EFBFBD>6<EFBFBD>5<EFBFBD>4<EFBFBD>3<EFBFBD>2<EFBFBD>1<EFBFBD>0<EFBFBD> Command Status Register 1 at port 3F5h
|
||||
<20> <20> <20> <20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD> FDC cannot find ID address mark (see reg 2)
|
||||
<20> <20> <20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> write protect detected during write
|
||||
<20> <20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FDC cannot find sector ID
|
||||
<20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> unused (always zero)
|
||||
<20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> over-run; FDC not serviced in reasonable time
|
||||
<20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> data error (CRC) in ID field or data field
|
||||
<20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> unused (always zero)
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> end of cylinder; sector# greater than sectors/track
|
||||
|
||||
- bit 0 of Status Register 1 and bit 4 of Status Register 2 are
|
||||
related and mimic each other
|
||||
|
||||
FDC Command Status Register 2 at 3F5h (all systems)
|
||||
|
||||
<09>7<EFBFBD>6<EFBFBD>5<EFBFBD>4<EFBFBD>3<EFBFBD>2<EFBFBD>1<EFBFBD>0<EFBFBD> Command Status Register 2 at port 3F5h
|
||||
<20> <20> <20> <20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD> missing address mark in data field
|
||||
<20> <20> <20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> bad cylinder, ID not found and Cyl Id=FFh
|
||||
<20> <20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> scan command failed, sector not found in cylinder
|
||||
<20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> scan command equal condition satisfied
|
||||
<20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> wrong cylinder detected
|
||||
<20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> CRC error detected in sector data
|
||||
<20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> sector with deleted data address mark detected
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> unused (always zero)
|
||||
|
||||
- bit 0 of Status Register 1 and bit 4 of Status Register 2 are
|
||||
related and mimic each other
|
||||
|
||||
FDC Command Status Register 3 at 3F5h (FDD status, all systems)
|
||||
|
||||
<09>7<EFBFBD>6<EFBFBD>5<EFBFBD>4<EFBFBD>3<EFBFBD>2<EFBFBD>1<EFBFBD>0<EFBFBD> Floppy Disk Drive Status at port 3F5h
|
||||
<20> <20> <20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FDD unit selected status (0=A, 1=B, 2=...)
|
||||
<20> <20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FDD side head select status (0=head 0, 1=head 1)
|
||||
<20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FDD two sided status signal
|
||||
<20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FDD track zero status signal
|
||||
<20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FDD ready status signal
|
||||
<20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FDD write protect status signal
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FDD fault status signal
|
||||
|
||||
PS/2 FDC Digital Input Register at 3F7h
|
||||
|
||||
<09>7<EFBFBD>6<EFBFBD>5<EFBFBD>4<EFBFBD>3<EFBFBD>2<EFBFBD>1<EFBFBD>0<EFBFBD> 3F7h PS/2 Digital Input Register (read only)
|
||||
<20> <20> <20> <20> <20> <20> <20> <20><><EFBFBD><EFBFBD> high density select
|
||||
<20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> reserved
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> diskette change
|
||||
|
||||
PS/2 FDC Configuration Control Register at 3F7h
|
||||
|
||||
<09>7<EFBFBD>6<EFBFBD>5<EFBFBD>4<EFBFBD>3<EFBFBD>2<EFBFBD>1<EFBFBD>0<EFBFBD> 3F7h PS/2 Config. Control Register (write only)
|
||||
<20> <20> <20> <20> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD> DRC1, DRC0 (see below)
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> reserved
|
||||
|
||||
DRC1 DRC0
|
||||
0 0 500000 bit per second mode
|
||||
0 1 reserved
|
||||
1 0 250000 bit per second mode
|
||||
1 1 reserved
|
||||
|
||||
|
||||
- Digital Input Register is used to sense the state of the
|
||||
(-diskette change) and the (-high density select) signals
|
||||
- Configuration Control Register is used to set the transfer rate
|
||||
|
||||
|
||||
FDC Programming Considerations
|
||||
|
||||
Three phases of command execution:
|
||||
|
||||
1. Command phase; commands are sent from the CPU to the FDC via
|
||||
port 3F5h; bit 6 of the Status Register at 3F4h must be zero
|
||||
2. Execution phase; FDC executes instruction & generates INT 6
|
||||
3. Result phase; status and other information is available to CPU;
|
||||
INT 6 sets bit 7 of BIOS Data Area location 40:3E which can
|
||||
be polled for completion status
|
||||
|
||||
|
||||
Example of a read operation:
|
||||
|
||||
1. turn disk motor on and set delay time for drive spin up
|
||||
2. perform seek operation; wait for disk interrupt
|
||||
3. prepare DMA chip to move data to memory
|
||||
4. send read command and wait for transfer complete interrupt
|
||||
5. read status information
|
||||
6. turn disk motor off
|
||||
|
||||
|
||||
Floppy Diskette Controller Operations (15 commands)
|
||||
|
||||
Read Data D7 D6 D5 D4 D3 D2 D1 D0
|
||||
|
||||
command byte 0: MT MF SK 0 0 1 1 0
|
||||
command byte 1: ? ? ? ? ? HD US1 US0
|
||||
command byte 2: cylinder number
|
||||
command byte 3: head number
|
||||
command byte 4: sector number
|
||||
command byte 5: bytes per sector
|
||||
command byte 6: end of track (last sector in track)
|
||||
command byte 7: gap 3 length
|
||||
command byte 8: data length (if cmd byte 5==0)
|
||||
result byte 0: status register 0
|
||||
result byte 1: status register 1
|
||||
result byte 2: status register 2
|
||||
result byte 3: cylinder number
|
||||
result byte 4: head number
|
||||
result byte 5: sector number
|
||||
result byte 6: bytes per sector
|
||||
|
||||
Read Deleted Data D7 D6 D5 D4 D3 D2 D1 D0
|
||||
|
||||
command byte 0: MT MF SK 0 1 1 0 0
|
||||
command byte 1: ? ? ? ? ? HD US1 US0
|
||||
command byte 2: cylinder number
|
||||
command byte 3: head number
|
||||
command byte 4: sector number
|
||||
command byte 5: bytes per sector
|
||||
command byte 6: end of track (last sector in track)
|
||||
command byte 7: gap 3 length
|
||||
command byte 8: data length (if cmd byte 5==0)
|
||||
result byte 0: status register 0
|
||||
result byte 1: status register 1
|
||||
result byte 2: status register 2
|
||||
result byte 3: cylinder number
|
||||
result byte 4: head number
|
||||
result byte 5: sector number
|
||||
result byte 6: bytes per sector
|
||||
|
||||
Write Data D7 D6 D5 D4 D3 D2 D1 D0
|
||||
|
||||
command byte 0: MT MF 0 0 0 1 0 1
|
||||
command byte 1: ? ? ? ? ? HD US1 US0
|
||||
command byte 2: cylinder number
|
||||
command byte 3: head number
|
||||
command byte 4: sector number
|
||||
command byte 5: bytes per sector
|
||||
command byte 6: end of track (last sector in track)
|
||||
command byte 7: gap 3 length
|
||||
command byte 8: data length (if cmd byte 5==0)
|
||||
result byte 0: status register 0
|
||||
result byte 1: status register 1
|
||||
result byte 2: status register 2
|
||||
result byte 3: cylinder number
|
||||
result byte 4: head number
|
||||
result byte 5: sector number
|
||||
result byte 6: bytes per sector
|
||||
|
||||
Write Deleted Data D7 D6 D5 D4 D3 D2 D1 D0
|
||||
|
||||
command byte 0: MT MF 0 0 1 0 0 1
|
||||
command byte 1: ? ? ? ? ? HD US1 US0
|
||||
command byte 2: cylinder number
|
||||
command byte 3: head number
|
||||
command byte 4: sector number
|
||||
command byte 5: bytes per sector
|
||||
command byte 6: end of track (last sector in track)
|
||||
command byte 7: gap 3 length
|
||||
command byte 8: data length (if cmd byte 5==0)
|
||||
result byte 0: status register 0
|
||||
result byte 1: status register 1
|
||||
result byte 2: status register 2
|
||||
result byte 3: cylinder number
|
||||
result byte 4: head number
|
||||
result byte 5: sector number
|
||||
result byte 6: bytes per sector
|
||||
|
||||
Read a Track D7 D6 D5 D4 D3 D2 D1 D0
|
||||
(Diagnostic)
|
||||
command byte 0: 0 MF SK 0 0 0 1 0
|
||||
command byte 1: ? ? ? ? ? HD US1 US0
|
||||
command byte 2: cylinder number
|
||||
command byte 3: head number
|
||||
command byte 4: sector number
|
||||
command byte 5: bytes per sector
|
||||
command byte 6: end of track (last sector in track)
|
||||
command byte 7: gap 3 length
|
||||
command byte 8: data length (if cmd byte 5==0)
|
||||
result byte 0: status register 0
|
||||
result byte 1: status register 1
|
||||
result byte 2: status register 2
|
||||
result byte 3: cylinder number
|
||||
result byte 4: head number
|
||||
result byte 5: sector number
|
||||
result byte 6: bytes per sector
|
||||
|
||||
Read ID D7 D6 D5 D4 D3 D2 D1 D0
|
||||
|
||||
command byte 0: 0 MF 0 0 1 0 1 0
|
||||
command byte 1: ? ? ? ? ? HD US1 US0
|
||||
result byte 0: status register 0
|
||||
result byte 1: status register 1
|
||||
result byte 2: status register 2
|
||||
result byte 3: cylinder number
|
||||
result byte 4: head number
|
||||
result byte 5: sector number
|
||||
result byte 6: bytes per sector
|
||||
|
||||
Format a Track D7 D6 D5 D4 D3 D2 D1 D0
|
||||
(Write Sector IDs)
|
||||
command byte 0: 0 MF 0 0 1 1 0 1
|
||||
command byte 1: ? ? ? ? ? HD US1 US0
|
||||
command byte 2: bytes per sector
|
||||
command byte 3: sectors per track
|
||||
command byte 4: gap 3 length
|
||||
command byte 5: filler pattern to write in each byte
|
||||
result byte 0: status register 0
|
||||
result byte 1: status register 1
|
||||
result byte 2: status register 2
|
||||
result byte 3: cylinder number
|
||||
result byte 4: head number
|
||||
result byte 5: sector number
|
||||
result byte 6: bytes per sector
|
||||
|
||||
Scan Equal D7 D6 D5 D4 D3 D2 D1 D0
|
||||
|
||||
command byte 0: MT MF SK 1 0 0 0 1
|
||||
command byte 1: ? ? ? ? ? HD US1 US0
|
||||
command byte 2: cylinder number
|
||||
command byte 3: head number
|
||||
command byte 4: sector number
|
||||
command byte 5: bytes per sector
|
||||
command byte 6: end of track (last sector in track)
|
||||
command byte 7: gap 3 length
|
||||
command byte 8: scan test (1=scan contiguous, 2=scan alternate)
|
||||
result byte 0: status register 0
|
||||
result byte 1: status register 1
|
||||
result byte 2: status register 2
|
||||
result byte 3: cylinder number
|
||||
result byte 4: head number
|
||||
result byte 5: sector number
|
||||
result byte 6: bytes per sector
|
||||
|
||||
Scan Low or Equal D7 D6 D5 D4 D3 D2 D1 D0
|
||||
|
||||
command byte 0: MT MF SK 1 1 0 0 1
|
||||
command byte 1: ? ? ? ? ? HD US1 US0
|
||||
command byte 2: cylinder number
|
||||
command byte 3: head number
|
||||
command byte 4: sector number
|
||||
command byte 5: bytes per sector
|
||||
command byte 6: end of track (last sector in track)
|
||||
command byte 7: gap 3 length
|
||||
command byte 8: scan test (1=scan contiguous, 2=scan alternate)
|
||||
result byte 0: status register 0
|
||||
result byte 1: status register 1
|
||||
result byte 2: status register 2
|
||||
result byte 3: cylinder number
|
||||
result byte 4: head number
|
||||
result byte 5: sector number
|
||||
result byte 6: bytes per sector
|
||||
|
||||
Scan High or Equal D7 D6 D5 D4 D3 D2 D1 D0
|
||||
|
||||
command byte 0: MT MF SK 1 1 1 0 1
|
||||
command byte 1: ? ? ? ? ? HD US1 US0
|
||||
command byte 2: cylinder number
|
||||
command byte 3: head number
|
||||
command byte 4: sector number
|
||||
command byte 5: bytes per sector
|
||||
command byte 6: end of track (last sector in track)
|
||||
command byte 7: gap 3 length
|
||||
command byte 8: scan test (1=scan contiguous, 2=scan alternate)
|
||||
result byte 0: status register 0
|
||||
result byte 1: status register 1
|
||||
result byte 2: status register 2
|
||||
result byte 3: cylinder number
|
||||
result byte 4: head number
|
||||
result byte 5: sector number
|
||||
result byte 6: bytes per sector
|
||||
|
||||
Recalibrate D7 D6 D5 D4 D3 D2 D1 D0
|
||||
|
||||
command byte 0: 0 0 0 0 0 1 1 1
|
||||
command byte 1: ? ? ? ? ? 0 US1 US0
|
||||
returns nothing
|
||||
|
||||
Sense Interrupt D7 D6 D5 D4 D3 D2 D1 D0
|
||||
Status
|
||||
command byte 0: 0 0 0 0 1 0 0 0
|
||||
result byte 0: status register 0
|
||||
result byte 1: present cylinder number
|
||||
|
||||
Specify Step & D7 D6 D5 D4 D3 D2 D1 D0
|
||||
Head Load
|
||||
command byte 0: 0 0 0 0 0 0 1 1
|
||||
command byte 1: step rate time <20> head unload time
|
||||
command byte 2: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>head load time<6D><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ND
|
||||
returns nothing
|
||||
|
||||
Sense Drive D7 D6 D5 D4 D3 D2 D1 D0
|
||||
Status
|
||||
command byte 0: 0 0 0 0 0 1 0 0
|
||||
command byte 1: ? ? ? ? ? HD US1 US0
|
||||
result byte 0: status register 3
|
||||
|
||||
Seek D7 D6 D5 D4 D3 D2 D1 D0
|
||||
|
||||
command byte 0: 0 0 0 0 1 1 1 1
|
||||
command byte 1: ? ? ? ? ? HD US1 US0
|
||||
command byte 2: new cylinder number
|
||||
returns nothing
|
||||
|
||||
<20>PD765 Version D7 D6 D5 D4 D3 D2 D1 D0
|
||||
|
||||
command byte 0: ? ? ? 1 0 0 0 0
|
||||
result byte 0: status register 0
|
||||
90h = <20>PD765B; 80h = <20>PD765A or <20>PD765A-2
|
||||
|
||||
Invalid Command
|
||||
|
||||
result byte 0: status register 0 (value of 80h)
|
||||
|
||||
|
||||
Key to Abbreviations
|
||||
HD = Head Number Selected SK = SKip Deleted-data address mark
|
||||
MT = Multi-Track US0 = drive select bit 0
|
||||
MF = MFM mode US1 = drive select bit 1
|
||||
ND = Non-DMA mode
|
||||
|
||||
Head Load Time = 2 to 254ms in 2ms increments
|
||||
Head Unload Time = 16 to 240ms in 16ms increments
|
||||
Step Rate Time = 1 to 16ms in 1ms increments
|
||||
|
||||
|
||||
- PS/2 systems use the 8272A diskette controller which is software
|
||||
and port compatible with the NEC <20>PD765
|
||||
- accessed through ports 3F0h-3F7h; NEC <20>PD765 is accessed through
|
||||
ports 3F2h, 3F4h and 3F5h; the 8272A uses ports 3F0h, 3F1h,
|
||||
3F2h, 3F4h, 3F5h and 3F7h
|
||||
- data, command and status registers are all accessed through
|
||||
port 3F5h a register stack with one address presented to the bus
|
||||
- bit 7 of BIOS Data Area byte 40:3E can be polled to determine
|
||||
if a disk operation has completed; this bit is set by the
|
||||
interrupt handler when the operation has completed; it should
|
||||
be reset before continuing on with the next FDC operation
|
||||
16
study/sabre/os/files/Disk/FloppyMediaIDs.txt
Normal file
16
study/sabre/os/files/Disk/FloppyMediaIDs.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
These are from the Gospel according to Saint Peter:
|
||||
|
||||
Format Size Cyls Heads Sec/Trk FATs Sec/FAT Sec/Root Media
|
||||
160K 5 1/4 40 1 8 2 ? ? FE
|
||||
180K 5 1/4 40 1 9 2 ? 4 FC
|
||||
320K 5 1/4 40 2 8 2 ? ? FF
|
||||
360K 5 1/4 40 2 9 2 4 7 FD
|
||||
1.2M 5 1/4 80 2 15 2 14 14 F9
|
||||
720K 3 1/2 80 2 9 2 6 7 F9
|
||||
1.44M 3 1/2 80 2 18 2 18 14 F0
|
||||
2.88M 3 1/2 80 2 36 2 ? ? ?
|
||||
|
||||
Does anybody have the straight poop on the 2.88M variety? (I could
|
||||
care less about the double-density, 5 1/4" formats.)
|
||||
|
||||
raster@indirect.com
|
||||
14
study/sabre/os/files/Disk/FloppySerialNumbers.txt
Normal file
14
study/sabre/os/files/Disk/FloppySerialNumbers.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
>Does anyone know how DOS generates serial-numbers for floppies?
|
||||
|
||||
Here are the details of the volume serial number:
|
||||
|
||||
The first part of the serial number is equal to the sum of the time
|
||||
(seconds and hundredths of a second) and the date (month and day); The
|
||||
second part of the serial number is equal to the sum of the time (hours
|
||||
and minutes) and date (year), where all numbers are in hex. For
|
||||
example, if the diskette is formatted at 8:32:43.65 on 7/21/1991, the
|
||||
first part of the serial number will be 2B41+0715, or 3256; the second
|
||||
part of the serial number will be 0820+07C7, or 0FE7.
|
||||
|
||||
Hope that this is of some help.
|
||||
Ray
|
||||
298
study/sabre/os/files/Disk/HDTECH01.txt
Normal file
298
study/sabre/os/files/Disk/HDTECH01.txt
Normal file
@@ -0,0 +1,298 @@
|
||||
From: datarec@inforamp.net (Nicholas Majors)
|
||||
Subject: Chapter 1 - Technicians' Guide to Hard Disks (REPOST)
|
||||
Date: 25 Mar 1995 18:45:09 GMT
|
||||
|
||||
|
||||
========================================================================
|
||||
Chapter 1 - TECHNICIANS' GUIDE TO PC HARD DISK SUBSYSTEMS
|
||||
========================================================================
|
||||
copyright (c) 1992, 1995
|
||||
|
||||
Nicholas Majors,
|
||||
|
||||
DATA RECOVERY LABS
|
||||
(division of Data Recovery Services Inc) Voice : 1-416-510-6990
|
||||
1315 Lawrence Avenue East - Unit 502 FAX : 1-416-510-6992
|
||||
Don Mills, Ontario, Canada M3A 3R3 Email : datarec@the-wire.com
|
||||
========================================================================
|
||||
|
||||
INTRODUCTION :
|
||||
|
||||
This booklet (now electronic) is published as a service of Data
|
||||
Recovery Labs. Its purpose is to provide the fundamental knowledge of
|
||||
concepts and terminology that is necessary to deal with the
|
||||
complexities of hard disk subsystems. It is not a technical reference
|
||||
guide and should not replace original documentation made available by
|
||||
manufacturers.
|
||||
|
||||
Every day we meet and deal with technicians and support personnel who
|
||||
install, upgrade and maintain hard drives, without knowing exactly
|
||||
what they are and how they work. Gaining a working knowledge of disk
|
||||
subsystems is not a simple task and requires much study - and -
|
||||
experience. Don't expect any book, training course, or manual to make
|
||||
you into an expert. However, if you read and understand most of this
|
||||
material, you will be off to a fine start.
|
||||
|
||||
The principal author is Nick Majors. He has been in the industry
|
||||
since 1979, designing and developing hardware and operating system
|
||||
enhancements and performance tools. He is an experienced machine
|
||||
language programmer and has provided technical training to support
|
||||
personnel for some of Canada's leading banks, corporations, government
|
||||
departments and PC service organizations. He is Manager of Technical
|
||||
Services for Data Recovery Labs which he founded in 1989.
|
||||
|
||||
While this booklet deals primarily with PC and PC compatible
|
||||
platforms, there is much information to benefit support personnel with
|
||||
other hardware platforms.
|
||||
|
||||
Every effort has been made to ensure accuracy, but misprints and
|
||||
ambiguities may still remain, so please use caution.
|
||||
|
||||
========================================================================
|
||||
HISTORY AND OVERVIEW :
|
||||
|
||||
The original IBM PC, introduced in 1981, did not support any type of
|
||||
hard drive. Program code in the BIOS did not recognize any such
|
||||
device and early versions of DOS precluded mass storage by limiting
|
||||
the maximum number of directory entries. This is not surprising when
|
||||
you consider that the original 4.77 MHz PC came with 16 K of RAM,
|
||||
expandable to 64 K on the motherboard. Even floppy drives and a disk
|
||||
operating system were options to upgrade the built in cassette
|
||||
recorder port and ROM basic.
|
||||
|
||||
To utilize a hard drive in a PC requires:
|
||||
|
||||
- a Hardware IRQ (interrupt request)
|
||||
- I/O port addresses for the controller
|
||||
- a DMA channel (now optional)
|
||||
- low level program code
|
||||
- a physical interface to the bus (expansion slot or built-in)
|
||||
- operating system support
|
||||
- sufficient power and cooling
|
||||
|
||||
After DOS 2 introduced the sub-directory system and support for mass
|
||||
storage devices, companies started selling hard drives for the PC.
|
||||
These were external cabinets that contained the disk itself, a
|
||||
controller card, and a dedicated power supply (since the PC's 63.5 watts
|
||||
were insufficient). Migrating from other architectures, these units
|
||||
connected to the PC through cabling to an 8 bit adapter card that
|
||||
plugged into an available expansion slot. These subsystems were
|
||||
configured to use one of the available IRQ's, DMA channels, a range of
|
||||
I/O ports, and program code that was made available through a device
|
||||
driver loaded into memory after startup (booting from a floppy).
|
||||
|
||||
In 1983, the IBM XT (eXTended) was unveiled with its built-in 10 MB
|
||||
fixed disk. IBM worked with a company (Xebec, I think) to take the
|
||||
controller components normally located in the external cabinet and
|
||||
build them right onto a bus interface card, creating what we commonly
|
||||
call the "hard disk controller".
|
||||
|
||||
Program code was provided by a ROM chip on the controller card which
|
||||
supplemented subroutines in the BIOS, and the internal power supply
|
||||
was upgraded to 135 watts to provide power for the internally mounted
|
||||
drive.
|
||||
|
||||
The XT design utilized :
|
||||
|
||||
- IRQ 5
|
||||
- I/O port addresses 320-32f
|
||||
- DMA channel 3
|
||||
- Program Code from adapter ROM at c8000
|
||||
- DOS 2.0 or higher
|
||||
|
||||
Several companies started manufacturing and selling similar
|
||||
drive/controller packages with various improvements including higher
|
||||
capacities, superior performance and built-in floppy controller
|
||||
components on the same card (to save an expansion slot). These third
|
||||
party subsystems could even be added to an original PC, so long as the
|
||||
internal power supply was also upgraded.
|
||||
|
||||
In 1984, the IBM AT (Advanced Technology) brought a complete overhaul
|
||||
to hard disk systems. Program code was included in the motherboard ROM
|
||||
BIOS, eliminating the need for a ROM chip on the new 16 bit controller
|
||||
card, and a higher quality drive improved access times. The system
|
||||
included use of newly added higher IRQ's, eliminated the use of DMA
|
||||
for hard drives, and changed the range of I/O addresses.
|
||||
|
||||
The AT design utilized :
|
||||
|
||||
- IRQ 14
|
||||
- I/O port addresses 1f0-1f8
|
||||
- DMA channel - none
|
||||
- Program Code from motherboard ROM BIOS
|
||||
- DOS 2.0 or higher
|
||||
|
||||
Hardware configuration details for the AT, including hard disk
|
||||
parameters, were stored in a low power CMOS chip connected to a small
|
||||
battery, eliminating many of the motherboard configuration dip
|
||||
switches and jumpers. The battery allowed information to be
|
||||
maintained while the computer was turned off and information could be
|
||||
changed by running a setup program from disk.
|
||||
|
||||
The original AT supported 14 different drive types, recognizing
|
||||
specific hard disks ranging from 10 to 112 MB. Any drive with
|
||||
physical parameters that did not match one of these types needed a ROM
|
||||
extension on the controller card or a device driver loaded during
|
||||
boot-up.
|
||||
|
||||
DOS versions prior to 4.0 (or 3.31) did not support partitions larger
|
||||
than 32 MB no matter how big a drive was. This was because of sector
|
||||
numbering that could not exceed 16 bit values (up to 65,536 sectors).
|
||||
To make a larger partition required the use of special software like
|
||||
Ontrack's Disk Manager. This software was so popular that many drive
|
||||
manufacturers shipped it with their product. Unfortunately, while
|
||||
this offered one of the better solutions, it did pose compatibility
|
||||
problems for many disk utilities because, in effect, you had a non-DOS
|
||||
partition.
|
||||
|
||||
Many people opted instead to divide their drives into 32 MB partitions
|
||||
creating a C: D: E: etc. up to the physical capacity. Prior to DOS
|
||||
3.3, even this was not possible, because DOS did not recognize
|
||||
extended partitions!
|
||||
|
||||
The number of drive types supported by CMOS has expanded to over 40
|
||||
and most current BIOS's provide a user definable type to allow
|
||||
parameters to match any drive. Most PC's today still rely on this
|
||||
original CMOS drive type scheme to configure and control hard disks,
|
||||
though many architectures and BIOS's have changed how the information
|
||||
is stored and updated.
|
||||
|
||||
This inherently creates certain limiting factors, including a problem
|
||||
with more than two hard drives and BIOS/OS limits to recognizing more
|
||||
than 1024 cylinders, 16 heads and 63 sectors per track. Various
|
||||
technologies must be used to translate non-compliant physical
|
||||
geometries into logical parameters recognized by the system to
|
||||
maintain compatibility with operating system and utility programs that
|
||||
are tied to these limits.
|
||||
|
||||
With each sector holding 512 bytes of data this allows for drives no
|
||||
larger than 504 MB.
|
||||
(1024 X 16 X 63 = 1,032,192 sectors X 512 = 528,482,304 bytes)
|
||||
|
||||
To understand this limit, we have to examine how hard drives are
|
||||
accessed by a PC.
|
||||
|
||||
Primarily, I/O commands are sent to the controller via a range of
|
||||
reserved port addresses. This is a very complicated and tedious
|
||||
process and the ROM BIOS includes a subroutine (INT 13) to perform
|
||||
these tasks for you. The DOS operating system then has certain
|
||||
functions that further simplify the process. They include INT 25/26
|
||||
functions to read and write absolute sectors to the drive as well as
|
||||
higher level functions (INT 21) to Open files, Close files, Write data
|
||||
to files, etc. Most programs rely on these DOS functions to control
|
||||
access to hard drives and DOS in turn calls the INT 13 BIOS
|
||||
subroutines which do the actual I/O commands.
|
||||
|
||||
All of these subroutines are assembly language code that are loaded
|
||||
into memory from either your BIOS chip(s) or Operating System files at
|
||||
startup.
|
||||
|
||||
Assembly language routines store and manipulate values in registers
|
||||
within the CPU. The lowest common denominator for INTEL based PC's is
|
||||
16 bit registers. Any program or routine that wants to be backward
|
||||
compatible, must use these base registers whether run on an 8088 or a
|
||||
Pentium. This basic INT 13 is the backbone of PC compatibility and
|
||||
uses 16 bit registers in the following way:
|
||||
|
||||
DX - 8 bits for head number - 8 bits for drive number
|
||||
CX - 10 bits for cylinder number and 6 bits for sector number
|
||||
|
||||
The largest 10 bit number possible is 1023 hence the limit on cylinder
|
||||
numbers (from 0-1023) and the largest 6 bit number is 63 (from 1-63)
|
||||
allowing 63 sectors per track.
|
||||
|
||||
But note - the DX register allows a maximum of 255 heads, not the 16
|
||||
that original specifications called for. This is what allows various
|
||||
translation schemes to deal with drives up to 8 GB while remaining INT
|
||||
13 compatible.
|
||||
|
||||
If the DX register allows 8 bits for drive number, shouldn't it be
|
||||
able to control 255 drives instead of only two?
|
||||
|
||||
When the INT 13 sends commands to your controller, it must know the
|
||||
physical geometry of the drive in question. During initialization of
|
||||
the PC, values for disk types are read from CMOS and stored into an
|
||||
area of RAM called the BIOS DATA AREA. Pointers to those entries are
|
||||
stored in the Interrupt Vector Table (at addresses 0:104h and 0:118h).
|
||||
The table only reserved pointers for two drives, so even if your CMOS
|
||||
held more values, the standard routines wouldn't know how to deal with
|
||||
them.
|
||||
|
||||
Why were the INT 13 routines so limited? They were written at a time
|
||||
when 10 and 20 MB drives were the norm, and 120 MB was unbelievable.
|
||||
They were designed to communicate with a specific controller
|
||||
interface, the ST412/506 standard (WD1003 controller), and the specs
|
||||
for passing parameters included only 10 bits for cylinders number, 4
|
||||
bits for head number and a single bit for drive number.
|
||||
|
||||
Some of these limitations have been overcome in the past by replacing
|
||||
the PC's INT 13 sub- routines with code that could recognize and deal
|
||||
with different devices. That's why virtually all SCSI adapter cards
|
||||
include a ROM chip and you must set the drive type to ZERO. In
|
||||
effect, no standard drives installed for the motherboard BIOS to
|
||||
control.
|
||||
|
||||
NetWare and other advanced Operating Systems use the drive type only
|
||||
long enough to boot- up and then replace the INT 13 code with their
|
||||
own device drivers. You then need to load a different .DSK file
|
||||
written specifically for each type of controller.
|
||||
|
||||
In the past couple of years, many motherboard and controller BIOS's
|
||||
have been enhanced to deal with ever increasing demands, but the
|
||||
process of establishing new standards has led to continuing confusion
|
||||
and compatibility problems.
|
||||
|
||||
========================================================================
|
||||
END OF CHAPTER 1
|
||||
========================================================================
|
||||
|
||||
COMING SOON - CHAPTER 2 - Inside Hard Drives and Controllers :
|
||||
- Parts and Components
|
||||
- also suggestions for must reading material
|
||||
|
||||
========================================================================
|
||||
NOTICES & PERSONAL RANTS :
|
||||
========================================================================
|
||||
|
||||
INTERNET APOLOGIES : The original artiticle, offering this booklet, was
|
||||
posted Jan. 29, 1995. I have had lots of replies, BUT - all kinds of
|
||||
people insist on replying by follow-up articles instead of private
|
||||
Mail. This proved downright embarrassing! I only wanted E-MAIL
|
||||
responses. Sorry for the clutter!
|
||||
|
||||
DISTRIBUTION : Chapters 1-2 will be sent by E-Mail to some 2,700
|
||||
people who requested it and is being posted to various News groups.
|
||||
The work to maintain a mailing list is much more trouble than it's
|
||||
worth, therefore - future chapters will be posted to a select number of
|
||||
New Groups and Bulletin Boards.
|
||||
|
||||
Files can be obtained by ftp. Look for "hdtech??.txt"
|
||||
|
||||
ftp site: archive.umich.edu in /msdos/info/disk
|
||||
|
||||
mirror : wuarchive.wustl.edu in /systems/ibmpc/umich.edu/info/disk
|
||||
(Note - This mirror is not always up to date)
|
||||
|
||||
ftp site: ftp.wi.leidenuniv.nl in /pub/faqs
|
||||
|
||||
Also Daniel Tauritz has a home page with links to this document plus a
|
||||
number of hard drive FAQs:
|
||||
|
||||
http://www.wi.leidenuniv.nl/~dtauritz/ata.html
|
||||
|
||||
If anyone specifically requires E-mail, send me a note with "e-mail
|
||||
please" as the subject. I will be glad to accommodate them, assuming
|
||||
it's a manageable number. I cannot provide hard copy or S-Mail.
|
||||
|
||||
RIGHTS : This material is copyright (C) 1992,1995 by Nicholas Majors
|
||||
and Data Recovery Labs. Feel free to distribute it as either hard
|
||||
copy, electronically, or by BBS - with full copyright credit to both.
|
||||
|
||||
COMMENTS & CRITICISM : I look forward to receiving suggestions,
|
||||
improvements, additions, (and yes even compliments) to this material.
|
||||
Please bear in mind who this has been written for - tech support
|
||||
personnel, not end-users and not engineers or hardware designers.
|
||||
|
||||
========================================================================
|
||||
|
||||
|
||||
476
study/sabre/os/files/Disk/HDTECH02.txt
Normal file
476
study/sabre/os/files/Disk/HDTECH02.txt
Normal file
@@ -0,0 +1,476 @@
|
||||
From: datarec@inforamp.net (Nicholas Majors)
|
||||
Subject: Chapter 2 - Technicians' Guide to Hard Disks
|
||||
Date: 25 Mar 1995 18:40:54 GMT
|
||||
|
||||
|
||||
|
||||
========================================================================
|
||||
Chapter 2 - TECHNICIANS' GUIDE TO PC HARD DISK SUBSYSTEMS
|
||||
========================================================================
|
||||
copyright (c) 1992, 1995
|
||||
|
||||
Nicholas Majors,
|
||||
|
||||
DATA RECOVERY LABS
|
||||
(division of Data Recovery Services Inc) Voice : 1-416-510-6990
|
||||
1315 Lawrence Avenue East - Unit 502 FAX : 1-416-510-6992
|
||||
Don Mills, Ontario, Canada M3A 3R3 Email : datarec@the-wire.com
|
||||
========================================================================
|
||||
|
||||
Before we consider how to install, configure and maintain hard drives,
|
||||
we need a basic understanding of drive construction and design concepts.
|
||||
This chapter examines in some detail the parts and functional components
|
||||
of hard drive subsystems.
|
||||
|
||||
(Note : A number of acronyms are used throughout this chapter and the
|
||||
glossary for this booklet is not yet available. Therefore, I have
|
||||
attached a brief set of definitions for some of the terminology.)
|
||||
|
||||
HARD DRIVES AND CONTROLLERS:
|
||||
|
||||
A hard drive subsystem is comprised of the following components:
|
||||
|
||||
1. The Hard Disk, with one or more boards (PCB) attached.
|
||||
2. A Controller Mechanism, either on the hard disk PCB or on the bus
|
||||
adapter within the PC.
|
||||
3. Bus Adapter for interfacing the controller to the host PC.
|
||||
4. Cables and Connectors to link it all together.
|
||||
|
||||
========================================================================
|
||||
THE HARD DISK:
|
||||
|
||||
Within a sealed enclosure (Head Disk Assembly or HDA) are one or more
|
||||
rigid platters that are "fixed" or non-removable. These are coated
|
||||
with magnetically sensitized material and data can be written to and
|
||||
read from the surface by means of electromagnetic read/write heads.
|
||||
When powered up, the platters are constantly rotating (except for
|
||||
certain pre-programmed sleep modes) and the heads are moved back and
|
||||
forth across the surface to access different locations. This is a
|
||||
sealed unit which should not be opened, except by qualified personnel in
|
||||
a controlled, dust free environment.
|
||||
|
||||
The circuit board(s) attached to the outside of the HDA provide the
|
||||
electronics needed for physical control of the motors within the sealed
|
||||
unit. They interface the source of electrical power and control signals
|
||||
to the disk assembly through various connectors and cables. Most boards
|
||||
have some jumpers, dip switches and/or resistors that are used for
|
||||
configuration purposes.
|
||||
|
||||
Functionally, these PCB's are separate from the Hard Disk Controller,
|
||||
but many of the newer drives (IDE and SCSI) embed the controller chip
|
||||
directly onto this board (as opposed to having it on the Bus adapter).
|
||||
|
||||
INSIDE THE HDA - PARTS OF A HARD DISK:
|
||||
|
||||
1. Disk Platter(s), separated by spacers and held together by a clamp.
|
||||
2. Spindle shaft onto which platters are mounted.
|
||||
3. Spindle motor for rotating the platters.
|
||||
4. Electromagnetic read/write heads (usually, one per surface).
|
||||
5. Access arms or armatures from which the heads are suspended.
|
||||
6. Actuator for moving the arms (with heads attached).
|
||||
7. Preamplifier circuitry to maximize read/write signals.
|
||||
8. Air filter and pressure vent.
|
||||
|
||||
The Platters:
|
||||
|
||||
Most platters or disks are made of an aluminum alloy, though ceramic or
|
||||
glass platters can also be found. The diameter is normally 2 1/2", 3
|
||||
1/2" or 5 1/4" with a hole in the center for mounting onto the spindle
|
||||
shaft. Thickness of the media can vary from less than 1/32 of an inch
|
||||
to about 1/8 of an inch.
|
||||
|
||||
During manufacture the platters are coated with a magnetizable material.
|
||||
Older drives used a ferrite compound applied by squirting a solution
|
||||
onto the surface and rotating at high speeds to distribute the material
|
||||
by centrifugal force. This process left a rust colored ferrite layer
|
||||
which was then hardened, polished and coated with a lubricant.
|
||||
|
||||
Newer drives apply the magnetic layer by plating a thin metal film onto
|
||||
the surface through galvanization or sputtering. These surfaces have a
|
||||
shiny chrome-like appearance.
|
||||
|
||||
Spindle and Spindle Motors:
|
||||
|
||||
Most drives have several platters that are separated by disk spacers and
|
||||
clamped to a rotating spindle that turns the platters in unison. A
|
||||
direct drive, brushless spindle motor is built into the spindle or
|
||||
mounted directly below it. (Sometimes this motor is visible from outside
|
||||
of the sealed enclosure.) The spindle, and consequently the platters,
|
||||
are rotated at a constant speed, usually 3,600 RPM, though newer models
|
||||
have increased that to 4800, 5400, or 7,200.
|
||||
|
||||
The spindle motor receives control signals through a closed loop
|
||||
feedback system that stabilizes to a constant rotation speed. Control
|
||||
signals come from information written onto the surface(s) during
|
||||
manufacture or with older drives, from physical sensors.
|
||||
|
||||
Read/Write Heads:
|
||||
|
||||
Since both sides of each platter are coated to provide separate
|
||||
surfaces, there is normally one electromagnetic read/write head for each
|
||||
side of each platter. Therefore, a drive with 4 platters would have 8
|
||||
sides and 8 heads. Some drives use one side as a dedicated surface for
|
||||
control signals leaving an odd number (5,7,etc.) of heads for actual
|
||||
use.
|
||||
|
||||
Each head is mounted onto the end of an access arm and these arms (one
|
||||
per surface) are moved in unison under the control of a single actuator
|
||||
mechanism. When one head is over track 143, all the heads on all other
|
||||
sides should be at the same location over their respective surfaces.
|
||||
|
||||
Generally speaking, only one of the heads is active at any given time.
|
||||
There are some drives that can read or write from two or more heads at a
|
||||
time, but while this has been common with main frame drives, it
|
||||
represents a major design change for personal computers and the
|
||||
technology is not yet widely used.
|
||||
|
||||
The spinning disk(s) create an air cushion over which the heads float.
|
||||
Depending on design, this air buffer ranges from 2 to 15 microns. By
|
||||
contrast, a smoke particle or finger print is about 30 microns in size!
|
||||
|
||||
The heads are not supposed to come into contact with the surface during
|
||||
rotation. Only when powered off should the heads come to rest on the
|
||||
surface, but this should be over a specific area of the surface,
|
||||
reserved for that purpose. Most drives built since the late 1980's
|
||||
employ an automatic parking feature which moves the heads to this
|
||||
designated region and may even lock the heads there until powered up.
|
||||
|
||||
Head Actuators:
|
||||
|
||||
The head actuator is the positioning mechanism used to move the arms and
|
||||
consequently the heads, back and forth over the surface. Once again,
|
||||
earlier drives used a different method than is now common.
|
||||
|
||||
Originally, head positioning was controlled by a stepper motor that
|
||||
rotated in either direction by reacting to stepper pulses and moving the
|
||||
head assembly back and forth by means of a "rack and pinion" or by
|
||||
spooling and unspooling a band attached to the actuator arms. Each
|
||||
pulse moved the assembly over the surface in predefined steps or
|
||||
detents. Each step represented a track location and data was expected
|
||||
to be under the head. This design, still used for floppy drives, is not
|
||||
suitable for current drive densities and is prone to alignment problems
|
||||
caused by friction, wear and tear, heat deformation, and lack of
|
||||
feedback information needed for correcting positioning error.
|
||||
|
||||
The more common voice coil actuator controls the movement of a coil
|
||||
toward or away from a permanent magnet based upon the amount of current
|
||||
flowing through it. The armatures are attached to this coil and move in
|
||||
and out over the surface with it. This is a very precise method, but
|
||||
also very sensitive. Any variation in the current can cause the head
|
||||
assembly to change position and there are no pre-defined positions.
|
||||
Inherently this is an analog system, with the exact amount of movement
|
||||
controlled by the exact amount of current applied.
|
||||
|
||||
The actual position of the coil is determined by servo (or indexing)
|
||||
information, which is written to the drive by the manufacturer.
|
||||
Location is adjusted to different tracks by reading and reacting to
|
||||
these control signals.
|
||||
|
||||
Internal Electronics:
|
||||
|
||||
There is surprisingly little circuitry found within the sealed HDA.
|
||||
There are electrical and control wires for the spindle and head actuator
|
||||
motors and the head assembly has flex cables with a preamplifier chip
|
||||
often built onto it. This chip takes pulses from the heads (as close to
|
||||
the source as possible) and cleans up and amplifies these signals before
|
||||
transmission to components outside of the housing.
|
||||
|
||||
Air Filtering and Ventilation:
|
||||
|
||||
Minor wear of internal components and occasional contact of the heads
|
||||
with the surface can cause microscopic particles to be loosened within
|
||||
the HDA. A permanent air filter is mounted within the air stream to
|
||||
remove these particles before they can cause damage to delicate
|
||||
mechanisms.
|
||||
|
||||
Most drives also have a small vent to allow for minor air exchange from
|
||||
outside of the housing. This allows for equalization of air pressure so
|
||||
drives can be used in different environments without risk of imploding
|
||||
or exploding.
|
||||
|
||||
========================================================================
|
||||
CONTROLLERS AND BUS ADAPTERS:
|
||||
|
||||
The hard disk controller provides the logical link between a hard disk
|
||||
unit and the program code within the host computer. It reacts to
|
||||
requests from the computer by sending seek, read, write, and control
|
||||
signals to the drive and must interpret and control the flow of data.
|
||||
|
||||
Data moving to and from the drive includes sector ID's, positioning
|
||||
information and timing or clock signals. The controller must encode,
|
||||
decode and separate this control information from actual data written to
|
||||
or read from the drive.
|
||||
|
||||
Also, data is sent to and from the drive serially, in bit format, but
|
||||
the CPU wants to recieve at least a byte (8 bits) at a time. The
|
||||
controller must take bits (8 - 16 - or 32 at a time) and assemble them
|
||||
into bytes, words, and doublewords that can be transferred to/from the
|
||||
computer.
|
||||
|
||||
"OUR INDUSTRY MUST LOVE STANDARDS - WE HAVE THOUSANDS OF THEM!"
|
||||
|
||||
And so it is with hard disk controllers.
|
||||
|
||||
Controllers can be categorized in several different ways, by :
|
||||
|
||||
Basic computer design (PC/XT vs AT-286-386-486,etc)
|
||||
- as mentioned in the first chapter, standard AT controllers use
|
||||
different I/O addresses, IRQ and employ PIO as opposed to DMA.
|
||||
|
||||
Bus Architecture (8-16 bit ISA, 32 bit MCA/EISA/VLB/PCI, etc.)
|
||||
- The adapter must be designed to interface with and use features of
|
||||
available expansion spots in the host computer.
|
||||
|
||||
Controller Card vs Adapter
|
||||
- The expansion board that plugs into the PC is commonly referred to
|
||||
as a controller card, but for many drives (primarily IDE and SCSI)
|
||||
the controller mechanism is built directly onto the drive PCB and
|
||||
the expansion board in the PC (or built into motherboard) is
|
||||
actually a Host/Bus adapter.
|
||||
|
||||
TROUBLESHOOTING TIP - If the BIOS reports "HDD CONTROLLER FAILURE" don't
|
||||
assume the problem is with your AT/IO board. It might well be the drive
|
||||
PCB that has failed.
|
||||
|
||||
Controller/Drive Interface
|
||||
- Both drive and controller must communicate in the same 'language'
|
||||
and several different standards for electrical properties and
|
||||
logical meaning of signals have been established. These
|
||||
include ST506/412, ESDI, SCSI, IDE(ATA/XTA) and EIDE(ATA2).
|
||||
|
||||
Data Encoding Method
|
||||
- Determines how densely data can be packed onto a track. MFM
|
||||
encoding is sufficient for only 17 x 512 byte sectors per track.
|
||||
RLL permits up to 27 and variations of ARLL allow 34 or more
|
||||
sectors per track. This recording density is a major determinant
|
||||
of storage capacity, and with rotation speed and interleave are
|
||||
critical factors for true data transfer capability.
|
||||
|
||||
Support for Translation
|
||||
- Some controllers present different logical parameters to the PC
|
||||
than the actual physical geometry of the drive.
|
||||
|
||||
Need for ROM Extension or Software Device Driver
|
||||
- Additional program code is used to provide support for hard drives
|
||||
when none exists (as in PC/XTs), to implement translation schemes
|
||||
(as in ST506/RLL and ESDI designs), allow for non-standard devices
|
||||
or features (SCSI), or for a combination of these (EIDE).
|
||||
|
||||
|
||||
Below is a quick list of the major combinations that have been used in
|
||||
PCs past and present. While I am sure many others could be added, these
|
||||
are the ones I have come across over the years.
|
||||
|
||||
------------------------------------------------------------------------
|
||||
Computer Bus Connection Interface Encoding Translate ROM
|
||||
------------------------------------------------------------------------
|
||||
PC/XT 8 bit ISA Controller ST506/412 MFM NO YES
|
||||
PC/XT 8 bit ISA Controller ST506/412 RLL OPTION YES
|
||||
AT 16 bit ISA Controller ST506/412 MFM NO NO
|
||||
AT 16 bit MCA Controller ST506/412 MFM NO NO
|
||||
AT 16 bit ISA Controller ST506/412 RLL OPTION YES
|
||||
AT 16 bit MCA Controller ST506/412 RLL YES YES
|
||||
AT 16 bit ISA Controller * ESDI (10 Mbps) RLL OPTION YES
|
||||
AT 16 bit ISA Controller * ESDI (24 Mbps) ARLL OPTION YES
|
||||
AT 16 bit MCA Controller ** ESDI (PS/2) RLL,ARLL YES YES
|
||||
PC/XT 8 bit ISA Adapter SCSI RLL YES YES
|
||||
AT 16 bit ISA Adapter SCSI RLL,ARLL YES YES
|
||||
AT ?? bit MCA Adapter *** SCSI RLL,ARLL YES YES
|
||||
AT 32 bit EISA Adapter SCSI RLL,ARLL YES YES
|
||||
AT 32 bit VLB Adapter SCSI RLL,ARLL YES YES
|
||||
AT 32 bit PCI Adapter SCSI RLL,ARLL YES YES
|
||||
PC/XT 8 bit ISA Adapter IDE / XTA RLL OPTION YES
|
||||
AT 16 Bit ISA Adapter IDE / ATA RLL,ARLL OPTION NO
|
||||
AT 32 Bit VLB Adapter EIDE / ATA2 ARLL OPTION YES
|
||||
AT 32 Bit PCI Adapter EIDE / ATA2 ARLL OPTION YES
|
||||
|
||||
* ESDI drives have some of the controller logic built onto
|
||||
the hard drive PCB and some on the controller card.
|
||||
** PS/2 ESDI uses the same physical interface as other ESDI
|
||||
devices, but supports additional features specific to their
|
||||
implementation.
|
||||
*** 16 bit? 32 bit? Who knows? I have never been sure.
|
||||
------------------------------------------------------------------------
|
||||
|
||||
Not to mention hundreds of other combinations to support different
|
||||
interleaves, track buffers, hardware caching, bus mastering, error
|
||||
correction schemes, SCSI I-II-III, optional floppy control, ESDI to SCSI
|
||||
converters, ST506 to SCSI converters (etc., etc., etc.).
|
||||
|
||||
So, what does all this mean to you?
|
||||
|
||||
Specifically, don't be surprised if the drive you have in your left
|
||||
hand, does not work correctly with the controller / adapter you have in
|
||||
your right hand. Also, if controllers are changed it may affect
|
||||
performance as well as the ability to access previously recorded data.
|
||||
|
||||
========================================================================
|
||||
END OF CHAPTER 2
|
||||
========================================================================
|
||||
|
||||
How to deal with some of this confusion will be addressed in
|
||||
CHAPTER 3 - Installing and Configuring Hard Drives.
|
||||
|
||||
========================================================================
|
||||
ADDITIONAL READING MATERIAL:
|
||||
========================================================================
|
||||
|
||||
I have always had difficulty finding appropriate reading material to
|
||||
recommend, but there are a few sources that I consider a must for
|
||||
technicians and support personnel.
|
||||
|
||||
First, a number of Internet Newsgroups have exceptional FAQ's
|
||||
(Frequently Asked Questions) which are updated and posted on a regular
|
||||
basis. These include:
|
||||
|
||||
"YET ANOTHER ATA-2/FAST-ATA/EIDE FAQ"
|
||||
by John Wehman and Peter Herweijer
|
||||
Newsgroup : comp.sys.ibm.hardware.storage
|
||||
|
||||
"BIOS TYPES"
|
||||
by Hale Landis
|
||||
Newsgroup : comp.sys.ibm.hardware.storage
|
||||
|
||||
"SCSI FAQ - 2 Parts"
|
||||
by Gary A. Field
|
||||
Newsgroup : comp.periphs.scsi
|
||||
|
||||
While bookstores are full of titles, most of them simply provide a
|
||||
rehash of basics. The following two books are an important part of my
|
||||
library because they cover much more than the usual:
|
||||
|
||||
"THE INDISPENSABLE PC HARDWARE BOOK" by Hans-Peter Messmer (1994)
|
||||
Addison-Wesley Publishing Company,
|
||||
ISBN - 0-201-62424-9
|
||||
|
||||
"THE UNDOCUMENTED PC" by Frank Van Gilluwe (1994)
|
||||
Addison-Wesley Publishing Company,
|
||||
ISBN - 0-201-62277-7
|
||||
|
||||
Other books well worth the read include:
|
||||
|
||||
"THE HARD DISK SURVIVAL GUIDE" by Mark Minasi (1991)
|
||||
Sybex Inc.,
|
||||
ISBN - 0-89588-799-1
|
||||
A little dated, but full of useful information. Hopefully there is a
|
||||
revised and updated version.
|
||||
|
||||
"OFFICIAL SPINRITE II AND HARD DISK COMPANION" by J. M. Goodman, (1990)
|
||||
IDG Books Worldwide, Inc.,
|
||||
ISBN - 878058-08-8
|
||||
Current advances are not covered, but great explanation of drive basics.
|
||||
|
||||
"HARD DRIVE BIBLE" by Martin Bodo (1993)
|
||||
Corporate Systems Center (CSC)
|
||||
My copy is the sixth edition from April, 1993. The first 50 pages of
|
||||
the book should be of interest (though not always clearly organized).
|
||||
The balance of the book (150 pages) is a listing of drive types and
|
||||
jumper settings. It's quite good, but keeping something like that
|
||||
updated is virtually impossible.
|
||||
|
||||
WARNING - DO NOT BUY - "The Data Recovery Bible" by Pamela Kane.
|
||||
Poorly organized material, most of which has nothing to do with data
|
||||
recovery. Waste of a good title if you ask me!
|
||||
|
||||
========================================================================
|
||||
ACRONYM DEFINITIONS:
|
||||
========================================================================
|
||||
|
||||
IRQ (Interrupt Request) - Lines on the bus used to signal hardware
|
||||
interrupts.
|
||||
|
||||
I/O (Input Output) - Peripherals accessible by the CPU through registers
|
||||
at specific I/O addresses (or I/O ports).
|
||||
|
||||
PIO (Programmed Input Output) - Exchange of data between memory and
|
||||
peripherals by means of Input Output commands.
|
||||
|
||||
DMA (Dynamic Memory Access) - Transferring data directly between memory
|
||||
and peripherals without going through the CPU.
|
||||
|
||||
BUS ARCHITECTURES:
|
||||
|
||||
ISA (Industry Standard Architecture) - 8 bit and 16 bit expansion slots
|
||||
used by PC, XT, and AT designs. Often called IBM Standard Architecture.
|
||||
|
||||
EISA (Extended Industry Standard Architecture) - Developed by several
|
||||
independent manufacturers (Compaq, AST, Zenith, Tandy, etc.) to
|
||||
standardize 32 bit operation and combat IBM's MCA.
|
||||
|
||||
MCA (Micro Channel Architecture) - Expansion bus introduced by IBM in
|
||||
1987, used by some (but not all) PS/2 models.
|
||||
|
||||
PCI (Peripheral Component Interconnect) - High speed bus developed by
|
||||
Intel to support the demands of Pentium and 486 based computers.
|
||||
|
||||
VLB (VESA Local Bus) - High speed, 32 bit extension to the ISA bus
|
||||
promoted by the VESA (Video Electronics Standards Association).
|
||||
|
||||
DRIVE INTERFACES:
|
||||
|
||||
ST506/412 - Standard interface used on XT and AT drives and controllers.
|
||||
Originally developed by Seagate Technologies to support their ST506
|
||||
(5 MB) and ST412 (10 MB) drives. The entire controller mechanism is
|
||||
located on a controller card and communications between the drive and
|
||||
controller flow over 2 ribbon cables - one for drive control and one for
|
||||
data.
|
||||
|
||||
ESDI (Enhanced Small Device Interface) - Developed by Maxtor in the
|
||||
early 1980's as an upgrade and improvement to the ST506 design. While
|
||||
the drive does not have an embedded controller, one of the most critical
|
||||
functions ,encoding-decoding, is performed on the drive. This allows
|
||||
for faster communications and higher drive capacities. Uses the same
|
||||
cabling as ST506 interface, but carries different signals on each line.
|
||||
|
||||
SCSI (Small Computer System Interface) - Based on an original design by
|
||||
Shugart Associates, SCSI is not specifically a drive interface, but a
|
||||
method of allowing different devices to communicate with a PC. For hard
|
||||
drives the entire controller is built onto the drive PCB, allowing for
|
||||
very high speed transfers to and from the drive. Fully interpreted,
|
||||
parallel data is then transferred to and from the PC by way of a single
|
||||
cable through a bus interface that has configured the device as a hard
|
||||
drive.
|
||||
|
||||
IDE (Integrated Drive Electronics) - A technology pioneered by Compaq
|
||||
and Conner that embedded a controller onto the hard disk PCB while
|
||||
maintaining compatibility with the register level commands sent by the
|
||||
computer's INT 13 routines. IDE drives are configured and appear to the
|
||||
computer like standard ST506 drives.
|
||||
|
||||
ATA (AT Attachment) - Implementation of the IDE design with a 16 bit AT
|
||||
style controller on board the drive.
|
||||
|
||||
XTA (XT Attachment) - Rarely used implementation of IDE with an
|
||||
integrated 8 bit XT controller.
|
||||
|
||||
ATA-2 - Enhancement to the AT Attachment standard to provide for
|
||||
considerable performance improvement and more sophisticated drive
|
||||
identification.
|
||||
|
||||
EIDE (Enhanced IDE) and FAST-ATA - Various implementations of the ATA-2
|
||||
standard as marketed by Western Digital (EIDE) and Seagate/Quantum
|
||||
(FAST-ATA).
|
||||
|
||||
DATA ENCODING SCHEMES
|
||||
|
||||
MFM (Modified Frequency Modulation) - Common technique used to encode
|
||||
the magnetic fluxes recorded on a drive into data. Still used on floppy
|
||||
drives and most original XT and AT systems. Notice that most drive
|
||||
types supported by the motherboard BIOS have 17 sectors per track. This
|
||||
is the standard density for MFM encoding.
|
||||
|
||||
RLL (Run Length Limited) - Encoding method that allows 50% more
|
||||
information to be recorded on a track than MFM. Accomplished by
|
||||
recording larger representations for every byte, but able to pack them
|
||||
more tightly onto the surface, because of fewer actual flux changes.
|
||||
Often called 2,7 RLL because the recording scheme involves patterns with
|
||||
no more than 7 successive zeros and no less than two.
|
||||
|
||||
ARLL (Advanced Run Length Limited) - More complex yet powerful
|
||||
derivatives of the RLL scheme. Include 1,7 and 3,9 encoding. Most
|
||||
every new drive made today uses some form of RLL or ARLL encoding.
|
||||
|
||||
========================================================================
|
||||
|
||||
|
||||
|
||||
200
study/sabre/os/files/Disk/HD_PORTS.asm
Normal file
200
study/sabre/os/files/Disk/HD_PORTS.asm
Normal file
@@ -0,0 +1,200 @@
|
||||
|
||||
; Reading the harddisk using ports!
|
||||
; +-------------------------------+ by qark
|
||||
;
|
||||
;
|
||||
; This took me months to get working but I finally managed it.
|
||||
;
|
||||
; This code only works for the 286+ so you must detect for 8088's somewhere
|
||||
; in your code.
|
||||
;
|
||||
; Technical Information on the ports:
|
||||
; Port Read/Write Misc
|
||||
; ------ ------------ -------------------------------------------------
|
||||
; 1f0 r/w data register, the bytes are written/read here
|
||||
; 1f1 r error register (look these values up yourself)
|
||||
; 1f2 r/w sector count, how many sectors to read/write
|
||||
; 1f3 r/w sector number, the actual sector wanted
|
||||
; 1f4 r/w cylinder low, cylinders is 0-1024
|
||||
; 1f5 r/w cylinder high, this makes up the rest of the 1024
|
||||
; 1f6 r/w drive/head
|
||||
; bit 7 = 1
|
||||
; bit 6 = 0
|
||||
; bit 5 = 1
|
||||
; bit 4 = 0 drive 0 select
|
||||
; = 1 drive 1 select
|
||||
; bit 3-0 head select bits
|
||||
; 1f7 r status register
|
||||
; bit 7 = 1 controller is executing a command
|
||||
; bit 6 = 1 drive is ready
|
||||
; bit 5 = 1 write fault
|
||||
; bit 4 = 1 seek complete
|
||||
; bit 3 = 1 sector buffer requires servicing
|
||||
; bit 2 = 1 disk data read corrected
|
||||
; bit 1 = 1 index - set to 1 each revolution
|
||||
; bit 0 = 1 previous command ended in an error
|
||||
; 1f7 w command register
|
||||
; commands:
|
||||
; 50h format track
|
||||
; 20h read sectors with retry
|
||||
; 21h read sectors without retry
|
||||
; 22h read long with retry
|
||||
; 23h read long without retry
|
||||
; 30h write sectors with retry
|
||||
; 31h write sectors without retry
|
||||
; 32h write long with retry
|
||||
; 33h write long without retry
|
||||
;
|
||||
; Most of these should work on even non-IDE hard disks.
|
||||
; This code is for reading, the code for writing is the next article.
|
||||
|
||||
|
||||
|
||||
mov dx,1f6h ;Drive and head port
|
||||
mov al,0a0h ;Drive 0, head 0
|
||||
out dx,al
|
||||
|
||||
mov dx,1f2h ;Sector count port
|
||||
mov al,1 ;Read one sector
|
||||
out dx,al
|
||||
|
||||
mov dx,1f3h ;Sector number port
|
||||
mov al,1 ;Read sector one
|
||||
out dx,al
|
||||
|
||||
mov dx,1f4h ;Cylinder low port
|
||||
mov al,0 ;Cylinder 0
|
||||
out dx,al
|
||||
|
||||
mov dx,1f5h ;Cylinder high port
|
||||
mov al,0 ;The rest of the cylinder 0
|
||||
out dx,al
|
||||
|
||||
mov dx,1f7h ;Command port
|
||||
mov al,20h ;Read with retry.
|
||||
out dx,al
|
||||
still_going:
|
||||
in al,dx
|
||||
test al,8 ;This means the sector buffer requires
|
||||
;servicing.
|
||||
jz still_going ;Don't continue until the sector buffer
|
||||
;is ready.
|
||||
|
||||
mov cx,512/2 ;One sector /2
|
||||
mov di,offset buffer
|
||||
mov dx,1f0h ;Data port - data comes in and out of here.
|
||||
rep insw
|
||||
|
||||
; ------
|
||||
|
||||
mov ax,201h ;Read using int13h then compare buffers.
|
||||
mov dx,80h
|
||||
mov cx,1
|
||||
mov bx,offset buffer2
|
||||
int 13h
|
||||
|
||||
mov cx,512
|
||||
mov si,offset buffer
|
||||
mov di,offset buffer2
|
||||
repe cmpsb
|
||||
jne failure
|
||||
mov ah,9
|
||||
mov dx,offset readmsg
|
||||
int 21h
|
||||
jmp good_exit
|
||||
failure:
|
||||
mov ah,9
|
||||
mov dx,offset failmsg
|
||||
int 21h
|
||||
good_exit:
|
||||
mov ax,4c00h ;Exit the program
|
||||
int 21h
|
||||
|
||||
readmsg db 'The buffers match. Hard disk read using ports.$'
|
||||
failmsg db 'The buffers do not match.$'
|
||||
|
||||
buffer db 512 dup ('V')
|
||||
buffer2 db 512 dup ('L')
|
||||
|
||||
|
||||
|
||||
|
||||
;
|
||||
; Writing to the hard disk using the ports! by qark
|
||||
; +---------------------------------------+
|
||||
;
|
||||
; The only differences between reading and writing using the ports is
|
||||
; that 30h is sent to the command register, and instead of INSW you
|
||||
; OUTSW.
|
||||
;
|
||||
; I chose to write to sector 2 because some idiot would trash their MBR
|
||||
; by running this.
|
||||
;
|
||||
|
||||
mov dx,1f6h ;Drive and head port
|
||||
mov al,0a0h ;Drive 0, head 0
|
||||
out dx,al
|
||||
|
||||
mov dx,1f2h ;Sector count port
|
||||
mov al,1 ;Write one sector
|
||||
out dx,al
|
||||
|
||||
mov dx,1f3h ;Sector number port
|
||||
mov al,2 ;Wrote to sector two
|
||||
out dx,al
|
||||
|
||||
mov dx,1f4h ;Cylinder low port
|
||||
mov al,0 ;Cylinder 0
|
||||
out dx,al
|
||||
|
||||
mov dx,1f5h ;Cylinder high port
|
||||
mov al,0 ;The rest of the cylinder 0
|
||||
out dx,al
|
||||
|
||||
mov dx,1f7h ;Command port
|
||||
mov al,30h ;Write with retry.
|
||||
out dx,al
|
||||
oogle:
|
||||
in al,dx
|
||||
test al,8 ;Wait for sector buffer ready.
|
||||
jz oogle
|
||||
|
||||
mov cx,512/2 ;One sector /2
|
||||
mov si,offset buffer
|
||||
mov dx,1f0h ;Data port - data comes in and out of here.
|
||||
rep outsw ;Send it.
|
||||
|
||||
; ------------
|
||||
|
||||
mov ax,201h ;We'll read in sector 2 using
|
||||
mov bx,offset buffer2 ;int13h and see if we are successful.
|
||||
mov cx,2
|
||||
mov dx,80h
|
||||
int 13h
|
||||
|
||||
mov cx,512
|
||||
mov si,offset buffer
|
||||
mov di,offset buffer2
|
||||
repe cmpsb ;Compare the buffers.
|
||||
jne failure
|
||||
|
||||
mov ah,9
|
||||
mov dx,offset write_msg
|
||||
int 21h
|
||||
jmp w_exit
|
||||
failure:
|
||||
mov ah,9
|
||||
mov dx,offset fail
|
||||
int 21h
|
||||
|
||||
w_exit:
|
||||
mov ax,4c00h ;Exit the program
|
||||
int 21h
|
||||
|
||||
write_msg db 'Sector two written to using the ports.$'
|
||||
fail db 'Writing using ports failed.$'
|
||||
|
||||
buffer db 512 dup ('A')
|
||||
buffer2 db 512 dup ('D')
|
||||
|
||||
|
||||
1111
study/sabre/os/files/Disk/IDE-tech.html
Normal file
1111
study/sabre/os/files/Disk/IDE-tech.html
Normal file
File diff suppressed because it is too large
Load Diff
378
study/sabre/os/files/Disk/IDEHDC.asm
Normal file
378
study/sabre/os/files/Disk/IDEHDC.asm
Normal file
@@ -0,0 +1,378 @@
|
||||
; ========================================================================== ;
|
||||
; IDEHDC.asm ;
|
||||
; Direct disk I/O module for IDE disk controllers. ;
|
||||
; Written by Alan Martin. ;
|
||||
; Note - this code doesn't use interrupts! ;
|
||||
; ========================================================================== ;
|
||||
idehdc segment use16 'CODE' ; Direct disk I/O code segment.
|
||||
; Initialize segment.
|
||||
assume cs:idehdc ; Initial segment assumptions.
|
||||
.386 ; Assume 386+ code is valid.
|
||||
|
||||
; Stack addressing equates.
|
||||
_ax equ word ptr bp+001Ch ; Saved AX value.
|
||||
_al equ byte ptr bp+001Ch ; Saved AL value.
|
||||
_ah equ byte ptr bp+001Dh ; Saved AH value.
|
||||
_bx equ word ptr bp+0010h ; Saved BX value.
|
||||
_bl equ byte ptr bp+0010h ; Saved BL value.
|
||||
_bh equ byte ptr bp+0011h ; Saved BH value.
|
||||
_cx equ word ptr bp+0018h ; Saved CX value.
|
||||
_cl equ byte ptr bp+0018h ; Saved CL value.
|
||||
_ch equ byte ptr bp+0019h ; Saved CH value.
|
||||
_dx equ word ptr bp+0014h ; Saved DX value.
|
||||
_dl equ byte ptr bp+0014h ; Saved DL value.
|
||||
_dh equ byte ptr bp+0015h ; Saved DH value.
|
||||
|
||||
delay macro x ; Long delay (for 400ns transition).
|
||||
local @loop ; Local labels.
|
||||
push cx ; Save CX.
|
||||
mov cx,x ; Get repeat count.
|
||||
@loop: loop @loop ; Loop X times.
|
||||
pop cx ; Restore CX.
|
||||
endm ; End of DELAY macro.
|
||||
|
||||
hdcwait macro ; Wait for HDC to finish commands.
|
||||
local @loop,@ok,@err ; Local labels.
|
||||
push ax ecx dx ; Save registers.
|
||||
mov ecx,00040000h ; 1s delay on 486DX-50.
|
||||
mov dx,01F7h ; HDC status register.
|
||||
in al,dx ; Read status.
|
||||
test al,80h ; Is the HDC busy?
|
||||
jz @ok ; If not, end immediately.
|
||||
@loop: in al,dx ; Read status.
|
||||
delay 000Ah ; 50-100 clock delay.
|
||||
test al,80h ; Is the HDC busy?
|
||||
jz @ok ; If not, end loop.
|
||||
loopd @loop ; Otherwise, continue.
|
||||
pop dx ecx ax ; Restore registers.
|
||||
stc ; Set CF.
|
||||
jmp @err ; Exit with error.
|
||||
@ok: pop dx ecx ax ; Restore registers.
|
||||
clc ; Clear CF.
|
||||
@err:
|
||||
endm ; End of HDCWAIT macro.
|
||||
|
||||
; ------------------------------------------ ;
|
||||
; IOREAD - Read sectors through direct I/O. ;
|
||||
; Input.: AX=cylinder number ;
|
||||
; BH=head number; BL=sector number ;
|
||||
; CH=# of sectors; CL=drive (0 or 1) ;
|
||||
; DS:DX->buffer for sectors ;
|
||||
; Output: CF=0 (OK) or 1 (Error) ;
|
||||
; AL=error code or 0 if no error. ;
|
||||
; AH=device error code if applicable.;
|
||||
; Errors: AL=0 - No error. ;
|
||||
; 1 - Controller busy or absent. ;
|
||||
; 2 - Drive not ready. ;
|
||||
; 3 - Drive not ready for read. ;
|
||||
; 4 - Device error: ;
|
||||
; AH, bit 0: Address mark not found. ;
|
||||
; 1: Track 0 not found. ;
|
||||
; 2: Write fault. ;
|
||||
; 4: Sector not found. ;
|
||||
; 6: Error in data. ;
|
||||
; 7: Sector marked bad. ;
|
||||
; Note: There may be errors if a read is ;
|
||||
; across a cylinder (or sometimes even ;
|
||||
; a head) boundary. ;
|
||||
; ------------------------------------------ ;
|
||||
ioread proc far ; Read sectors through direct I/O.
|
||||
pushad ; Save all registers.
|
||||
mov bp,sp ; Address the stack.
|
||||
push ds es ; Save segments.
|
||||
in al,0A1h ; Get PIC 2 mask.
|
||||
push ax ; Save it.
|
||||
or al,40h ; Disable IRQ 14.
|
||||
out 0A1h,al ; Set PIC 2 mask.
|
||||
hdcwait ; Wait for HDC not busy.
|
||||
jnc ir_ok0 ; Continue if not busy.
|
||||
mov al,01h ; Error 1: Controller busy...
|
||||
mov [_al],al ; .
|
||||
jmp ir_err ; ...done.
|
||||
ir_ok0:mov al,[_bh] ; Get head number.
|
||||
mov ah,[_cl] ; Get drive number.
|
||||
and ax,010Fh ; Mask out extra bits.
|
||||
shl ah,04h ; Adjust AH.
|
||||
or al,ah ; Combine data.
|
||||
or al,0A0h ; Set 512 bytes + ECC.
|
||||
mov dx,01F6h ; Write drive/head numbers...
|
||||
out dx,al ; ...done.
|
||||
hdcwait ; Wait for HDC not busy.
|
||||
jnc ir_ok1 ; Continue if not busy.
|
||||
mov al,01h ; Error 1: Controller busy...
|
||||
mov [_al],al ; .
|
||||
jmp ir_err ; ...done.
|
||||
ir_ok1:mov ecx,000C0000h ; 3s delay.
|
||||
mov dx,01F7h ; HDC status register.
|
||||
ir_l1: in al,dx ; Read status.
|
||||
test al,40h ; Drive ready?
|
||||
jnz ir_ok2 ; Continue if so.
|
||||
loopd ir_l1 ; Loop for 3s.
|
||||
mov al,02h ; Error 2: Drive not ready...
|
||||
mov [_al],al ; .
|
||||
jmp ir_err ; ...done.
|
||||
ir_ok2:test al,10h ; Drive ready for read?
|
||||
jnz ir_ok3 ; Continue if so.
|
||||
loopd ir_l1 ; Loop for 3s.
|
||||
mov al,03h ; Error 3: Cannot read data...
|
||||
mov [_al],al ; .
|
||||
jmp ir_err ; ...done.
|
||||
ir_ok3:mov al,10h ; Set to >8 heads...
|
||||
mov dx,03F6h ; .
|
||||
out dx,ax ; ...done.
|
||||
mov dx,01F2h ; Write read parameters...
|
||||
mov al,[_ch] ; .
|
||||
out dx,al ; .
|
||||
inc dx ; .
|
||||
mov al,[_bl] ; .
|
||||
out dx,al ; .
|
||||
inc dx ; .
|
||||
mov al,[_al] ; .
|
||||
out dx,al ; .
|
||||
inc dx ; .
|
||||
mov al,[_ah] ; .
|
||||
out dx,al ; .
|
||||
inc dx ; .
|
||||
mov al,[_bh] ; .
|
||||
mov ah,[_cl] ; .
|
||||
and ax,010Fh ; .
|
||||
shl ah,04h ; .
|
||||
or al,ah ; .
|
||||
or al,0A0h ; .
|
||||
out dx,al ; ...done.
|
||||
mov dx,01F1h ; Write Precompensation = 0...
|
||||
xor al,al ; .
|
||||
out dx,al ; ...done.
|
||||
hdcwait ; Wait for HDC not busy.
|
||||
jnc ir_ok4 ; Continue if not busy.
|
||||
mov al,01h ; Error 1: Controller busy...
|
||||
mov [_al],al ; .
|
||||
jmp ir_err ; ...done.
|
||||
ir_ok4:xor cx,cx ; Get sector count...
|
||||
mov cl,[_ch] ; ...done.
|
||||
push ds ; Put DS in ES...
|
||||
pop es ; ...done.
|
||||
mov di,[_dx] ; Get offset.
|
||||
mov dx,01F7h ; Send read command...
|
||||
mov al,20h ; .
|
||||
out dx,al ; ...done.
|
||||
ir_l2: mov dx,01F7h ; Get status port.
|
||||
delay 000Ah ; Delay for >400ns.
|
||||
in al,dx ; Get status.
|
||||
test al,80h ; Busy?
|
||||
jnz ir_l2 ; Loop if so.
|
||||
test al,29h ; Loop if no change...
|
||||
jz ir_l2 ; ...done.
|
||||
test al,08h ; Ready for data?
|
||||
jnz ir_rda ; If so, read it.
|
||||
test al,21h ; Error in command?
|
||||
jnz ir_dev ; If so, return device error.
|
||||
jmp ir_l2 ; Continue loop.
|
||||
ir_rda:push cx ; Save CX.
|
||||
mov cx,0100h ; Repeat count.
|
||||
mov dx,01F0h ; 16-bit transfer port.
|
||||
rep insw ; Read data.
|
||||
pop cx ; Restore CX.
|
||||
loop ir_l2 ; Loop until done.
|
||||
mov al,12h ; Deactivate controller...
|
||||
mov dx,03F6h ; .
|
||||
out dx,ax ; ...done.
|
||||
mov al,00h ; No error - return 0...
|
||||
mov [_al],al ; ...done.
|
||||
pop ax ; Reset PIC 2 mask...
|
||||
out 0A1h,al ; ...done.
|
||||
clc ; No error: CF=0.
|
||||
pop es ds ; Restore segments.
|
||||
popad ; Restore all registers.
|
||||
ret ; Return (far).
|
||||
ir_dev:mov al,04h ; Error 4: Device fault...
|
||||
mov [_al],al ; ...done.
|
||||
mov dx,01F1h ; Get error code...
|
||||
in al,dx ; .
|
||||
mov [_ah],al ; ...done.
|
||||
mov dx,01F6h ; Recalibrate head...
|
||||
mov al,[_bh] ; .
|
||||
mov ah,[_cl] ; .
|
||||
and ax,010Fh ; .
|
||||
shl ah,04h ; .
|
||||
or al,ah ; .
|
||||
or al,0A0h ; .
|
||||
out dx,al ; .
|
||||
inc dx ; .
|
||||
mov al,10h ; .
|
||||
out dx,al ; ...done.
|
||||
hdcwait ; Wait for HDC not busy.
|
||||
mov al,12h ; Deactivate controller...
|
||||
mov dx,03F6h ; .
|
||||
out dx,ax ; ...done.
|
||||
ir_err:pop ax ; Reset PIC 2 mask...
|
||||
out 0A1h,al ; ...done.
|
||||
stc ; Error: CF=1.
|
||||
pop es ds ; Restore segments.
|
||||
popad ; Restore all registers.
|
||||
ret ; Return (far).
|
||||
ioread endp ; End of IOREAD procedure.
|
||||
|
||||
; ------------------------------------------ ;
|
||||
; IOWRITE - Write sectors through direct I/O.;
|
||||
; Input.: AX=cylinder number ;
|
||||
; BH=head number; BL=sector number ;
|
||||
; CH=# of sectors; CL=drive (0 or 1) ;
|
||||
; DS:DX->buffer for sectors ;
|
||||
; Output: CF=0 (OK) or 1 (Error) ;
|
||||
; AL=error code or 0 if no error. ;
|
||||
; AH=device error code if applicable.;
|
||||
; Errors: AL=0 - No error. ;
|
||||
; 1 - Controller busy or absent. ;
|
||||
; 2 - Drive not ready. ;
|
||||
; 3 - Drive not ready for write. ;
|
||||
; 4 - Device error: ;
|
||||
; AH, bit 0: Address mark not found. ;
|
||||
; 1: Track 0 not found. ;
|
||||
; 2: Write fault. ;
|
||||
; 4: Sector not found. ;
|
||||
; 6: Error in data. ;
|
||||
; 7: Sector marked bad. ;
|
||||
; Note: There may be errors if a write is ;
|
||||
; across a cylinder (or sometimes even ;
|
||||
; a head) boundary. ;
|
||||
; ------------------------------------------ ;
|
||||
iowrite proc far ; Write sectors through direct I/O.
|
||||
pushad ; Save all registers.
|
||||
mov bp,sp ; Address the stack.
|
||||
push ds es ; Save segments.
|
||||
in al,0A1h ; Get PIC 2 mask.
|
||||
push ax ; Save it.
|
||||
or al,40h ; Disable IRQ 14.
|
||||
out 0A1h,al ; Set PIC 2 mask.
|
||||
hdcwait ; Wait for HDC not busy.
|
||||
jnc iw_ok0 ; Continue if not busy.
|
||||
mov al,01h ; Error 1: Controller busy...
|
||||
mov [_al],al ; .
|
||||
jmp iw_err ; ...done.
|
||||
iw_ok0:mov al,[_bh] ; Get head number.
|
||||
mov ah,[_cl] ; Get drive number.
|
||||
and ax,010Fh ; Mask out extra bits.
|
||||
shl ah,04h ; Adjust AH.
|
||||
or al,ah ; Combine data.
|
||||
or al,0A0h ; Set 512 bytes + ECC.
|
||||
mov dx,01F6h ; Write drive/head numbers...
|
||||
out dx,al ; ...done.
|
||||
hdcwait ; Wait for HDC not busy.
|
||||
jnc iw_ok1 ; Continue if not busy.
|
||||
mov al,01h ; Error 1: Controller busy...
|
||||
mov [_al],al ; .
|
||||
jmp iw_err ; ...done.
|
||||
iw_ok1:mov ecx,000C0000h ; 3s delay.
|
||||
mov dx,01F7h ; HDC status register.
|
||||
iw_l1: in al,dx ; Read status.
|
||||
test al,40h ; Drive ready?
|
||||
jnz iw_ok2 ; Continue if so.
|
||||
loopd iw_l1 ; Loop for 3s.
|
||||
mov al,02h ; Error 2: Drive not ready...
|
||||
mov [_al],al ; .
|
||||
jmp iw_err ; ...done.
|
||||
iw_ok2:test al,10h ; Drive ready for write?
|
||||
jnz iw_ok3 ; Continue if so.
|
||||
loopd iw_l1 ; Loop for 3s.
|
||||
mov al,03h ; Error 3: Cannot write...
|
||||
mov [_al],al ; .
|
||||
jmp iw_err ; ...done.
|
||||
iw_ok3:mov al,10h ; Set to >8 heads...
|
||||
mov dx,03F6h ; .
|
||||
out dx,ax ; ...done.
|
||||
mov dx,01F2h ; Write write parameters...
|
||||
mov al,[_ch] ; .
|
||||
out dx,al ; .
|
||||
inc dx ; .
|
||||
mov al,[_bl] ; .
|
||||
out dx,al ; .
|
||||
inc dx ; .
|
||||
mov al,[_al] ; .
|
||||
out dx,al ; .
|
||||
inc dx ; .
|
||||
mov al,[_ah] ; .
|
||||
out dx,al ; .
|
||||
inc dx ; .
|
||||
mov al,[_bh] ; .
|
||||
mov ah,[_cl] ; .
|
||||
and ax,010Fh ; .
|
||||
shl ah,04h ; .
|
||||
or al,ah ; .
|
||||
or al,0A0h ; .
|
||||
out dx,al ; ...done.
|
||||
mov dx,01F1h ; Write Precompensation = 0...
|
||||
xor al,al ; .
|
||||
out dx,al ; ...done.
|
||||
hdcwait ; Wait for HDC not busy.
|
||||
jnc iw_ok4 ; Continue if not busy.
|
||||
mov al,01h ; Error 1: Controller busy...
|
||||
mov [_al],al ; .
|
||||
jmp iw_err ; ...done.
|
||||
iw_ok4:xor cx,cx ; Get sector count...
|
||||
mov cl,[_ch] ; ...done.
|
||||
mov si,[_dx] ; Get offset.
|
||||
mov dx,01F7h ; Send write command...
|
||||
mov al,30h ; .
|
||||
out dx,al ; ...done.
|
||||
iw_l2: mov dx,01F7h ; Get status port.
|
||||
delay 000Ah ; Delay for >400ns.
|
||||
in al,dx ; Get status.
|
||||
test al,80h ; Busy?
|
||||
jnz iw_l2 ; Loop if so.
|
||||
test al,29h ; Loop if no change...
|
||||
jz iw_l2 ; ...done.
|
||||
test al,08h ; Ready for data?
|
||||
jnz iw_wda ; If so, write it.
|
||||
test al,21h ; Error in command?
|
||||
jnz iw_dev ; If so, return device error.
|
||||
jmp iw_l2 ; Continue loop.
|
||||
iw_wda:push cx ; Save CX.
|
||||
mov cx,0100h ; Repeat count.
|
||||
mov dx,01F0h ; 16-bit transfer port.
|
||||
rep outsw ; Write data.
|
||||
pop cx ; Restore CX.
|
||||
loop iw_l2 ; Loop until done.
|
||||
mov al,12h ; Deactivate controller...
|
||||
mov dx,03F6h ; .
|
||||
out dx,ax ; ...done.
|
||||
mov al,00h ; No error - return 0...
|
||||
mov [_al],al ; ...done.
|
||||
pop ax ; Reset PIC 2 mask...
|
||||
out 0A1h,al ; ...done.
|
||||
clc ; No error: CF=0.
|
||||
pop es ds ; Restore segments.
|
||||
popad ; Restore all registers.
|
||||
ret ; Return (far).
|
||||
iw_dev:mov al,04h ; Error 4: Device fault...
|
||||
mov [_al],al ; ...done.
|
||||
mov dx,01F1h ; Get error code...
|
||||
in al,dx ; .
|
||||
mov [_ah],al ; ...done.
|
||||
mov dx,01F6h ; Recalibrate head...
|
||||
mov al,[_bh] ; .
|
||||
mov ah,[_cl] ; .
|
||||
and ax,010Fh ; .
|
||||
shl ah,04h ; .
|
||||
or al,ah ; .
|
||||
or al,0A0h ; .
|
||||
out dx,al ; .
|
||||
inc dx ; .
|
||||
mov al,10h ; .
|
||||
out dx,al ; ...done.
|
||||
hdcwait ; Wait for HDC not busy.
|
||||
mov al,12h ; Deactivate controller...
|
||||
mov dx,03F6h ; .
|
||||
out dx,ax ; ...done.
|
||||
iw_err:pop ax ; Reset PIC 2 mask...
|
||||
out 0A1h,al ; ...done.
|
||||
stc ; Error: CF=1.
|
||||
pop es ds ; Restore segments.
|
||||
popad ; Restore all registers.
|
||||
ret ; Return (far).
|
||||
iowrite endp ; End of IOWRITE procedure.
|
||||
|
||||
; Clean up segment.
|
||||
assume nothing ; Remove segment assumptions.
|
||||
idehdc ends ; End of direct I/O segment.
|
||||
; ========================================================================== ;
|
||||
BIN
study/sabre/os/files/Disk/IDEInterrogate.zip
Normal file
BIN
study/sabre/os/files/Disk/IDEInterrogate.zip
Normal file
Binary file not shown.
2767
study/sabre/os/files/Disk/MSCDEX21.txt
Normal file
2767
study/sabre/os/files/Disk/MSCDEX21.txt
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,112 @@
|
||||
<STYLE MEDIA="screen">
|
||||
#bodytext { font-family: Verdana, Arial, Helvetica;font-size: 9pt; line-height: 125%;}
|
||||
</STYLE>
|
||||
<STYLE MEDIA="print">
|
||||
#bodytext {display: all; margin-left: 90px; margin-right: 20px; font-family: Times; font-size: 11pt; line-height: 112%;}
|
||||
</STYLE>
|
||||
|
||||
<FONT FACE="Verdana, Arial, Helvetica" SIZE=1><blockquote><div id="bodytext">
|
||||
<!-- XXXXXXXXXXXXXXXXX PAGE TITLE: XXXXXXXXXXXXXXXXXXXXX -->
|
||||
<h3 class=main>Media Status Notification Support Specification for SCSI and ATAPI Devices, Version 0.1</h3>
|
||||
<!-- XXXXXXXXXXXXXXXXX START TOC: XXXXXXXXXXXXXXXXXXXXXX -->
|
||||
<DL class=contents>
|
||||
<DT class=contents><B>Contents:</B></DT>
|
||||
<DD class=contents><a class=contents href="#Introduction">Introduction</a></DD>
|
||||
<DD class=contents><a class=contents href="#Enabling">Enabling and Disabling Media Status Notification Support</a></DD>
|
||||
<DD class=contents><a class=contents href="#Returning">Returning Media Status</a></DD>
|
||||
<DD class=contents><a class=contents href="#Reporting">Reporting Media Status Changes</a></DD>
|
||||
<DD class=contents><a class=contents href="#SCSI">SCSI Compatibility Considerations</a></DD>
|
||||
</DL>
|
||||
<!-- XXXXXXXXXXXXXXX START CONTENT: XXXXXXXXXXXXXXXXXXXX -->
|
||||
<h3><A NAME="Introduction"></A>Introduction</h3>
|
||||
|
||||
<P>A major shortcoming of removable media devices on PC platforms is their inability to report to the host when the user attempts to eject the medium. Currently most removable media devices just eject the medium when the user presses the Eject button, and potentially any data the operating system has not saved to the device is lost. Various volume tracking and locking schemes reduce this risk, but do not eliminate it. Ideally, devices will have a means of communicating to the host that the user wants to eject the medium or has inserted a new medium.</P>
|
||||
|
||||
<P>This specification defines a protocol for providing this function for SCSI ATA and ATAPI devices. The support is enabled using a new SCSI command, ENABLE MEDIA STATUS, and the media status is retrieved using a new SCSI ATA command, GET MEDIA STATUS. </P>
|
||||
|
||||
<P>Because it is difficult for a SCSI target to asynchronously interrupt the host due to lack of industry support for Asynchronous Event Notification, the GET MEDIA STATUS command is not completed by the target until a media status change occurs. If tagged command queuing is not supported by the target and/or the host, a means of polling the target for status changes is also specified.
|
||||
Note that in some controllers the unused words in the ID Drive data are returned as 0FFFFh. Thus it may be better if the Status Notification support was returned as a 2 bit field, where 00b, 11b are both defined as drive not supporting Status notification.</P>
|
||||
|
||||
<h3><A NAME="Enabling"></A>Enabling and Disabling Media Status Notification Support</h3>
|
||||
|
||||
<P>To maintain compatibility with existing BIOS implementations and operating systems, the target must assume that the host does shall not enableimplement Media Status Notification support until the ENABLE MEDIA STATUS command is issued by the host, as described in this section.</P>
|
||||
|
||||
<P>When the host enables the support using the ENABLE MEDIA STATUS command, the target shallmust respond as described in this specification. When the host disables this featuresupport, the target must default to normal operating modes. A SCSI bus reset, bus device reset or power on condition must also cause the target to return to normal operating modes.</P>
|
||||
|
||||
<P><b>ENABLE MEDIA STATUS Command</b></P>
|
||||
|
||||
<P>The ENABLE MEDIA STATUS command requests that the SCSI Target enable or disable Media Status Notification. If Media Status Notification is not supported, the target shall return CHECK CONDITION (Sense Key 05 ILLEGAL REQUEST, Sense Code 24 INVALID FIELD IN COMMAND PACKET).
|
||||
</P>
|
||||
<P>
|
||||
<img src="scsienbl.gif" width=573 height=260 border=0></P>
|
||||
|
||||
<P>An Enable bit of one indicates that the target shall enable Media Status Notification. If the target currently has Media Status Notification enabled, the target shall return CHECK CONDITION (Sense Key 05 ILLEGAL REQUEST, Sense Code 4E OVERLAPPED COMMANDS ATTEMPTED).</P>
|
||||
|
||||
<P>An Enable bit of zero indicates that the target shall disable Media Status Notification.</P>
|
||||
|
||||
<h3><A NAME="Returning"></A>Returning Media Status</h3>
|
||||
|
||||
<P>The media status information is returned when the host issues the GET MEDIA STATUS command described below.</P>
|
||||
|
||||
<P><b>GET MEDIA STATUS Command</b></P>
|
||||
|
||||
<P>The ENABLE MEDIA STATUS command requests that the SCSI Target report media status changes. If Media Status Notification is not supported or not enabled, the target shall return CHECK CONDITION (Sense Key 05 ILLEGAL REQUEST, Sense Code 24 INVALID FILED IN COMMAND PACKET).</P>
|
||||
|
||||
<P>
|
||||
<img src="scsigetm.gif" width=572 height=260 border=0></P>
|
||||
|
||||
<P>This command has two modes of operation. If the Immed bit is set to one, and if the state of the target is normal (that is, medium not inserted, Eject button not pushed), the GET MEDIA STATUS command shall return good status. If the state of the target has changed, a CHECK CONDITION command shall be returned, and the subsequent REQUEST SENSE command shall return the appropriate keys as defined in the Reporting Media Status Changes section below.</P>
|
||||
|
||||
<P>If the Immed bit is set to zero (and the target supports tagged command queuing) and if the state of the target is normal (that is, medium in the target, medium not changed, Eject button not pushed), the GET MEDIA STATUS command shall be queued by the target until the status of the medium changes, or some error condition occurs. If the state of the target has changed, a CHECK CONDITION command shall be returned, and the subsequent REQUEST SENSE command shall return the appropriate keys as defined in the Reporting Media Status Changes section below.</P>
|
||||
|
||||
<P>If the Immed bit is set to zero and the target DOES NOT support tagged command queuing, the target shall return CHECK CONDITION (Sense Key 05 ILLEGAL REQUEST, Sense Code 24 INVALID FIELD IN COMMAND PACKET).</P>
|
||||
|
||||
<h3><A NAME="Reporting"></A>Reporting Media Status Changes</h3>
|
||||
|
||||
<P>When a media status change has been detected, the GET MEDIA STATUS command shall return CHECK CONDITION. The target shall return the following sense data:</P>
|
||||
|
||||
<P>Sense Key 06 (UNIT ATTENTION)</P>
|
||||
|
||||
<P>Sense Code E0 (MEDIA STATUS CHANGE)</P>
|
||||
|
||||
<P>Additional Sense Code Qualifier:</P>
|
||||
|
||||
<P><b>00 - EJREQ </b></P>
|
||||
|
||||
<P>This Qualifier indicates that the user has attempted to eject the medium. Usually this Qualifier will be set when the user presses the Eject button on the target. If theThe target is capable of preventing removal of the media, the target shallmust not allow the medium to be ejected until an EJECT command is received from the host. This Qualifier shallmust not be set again in response to the GET MEDIA STATUS command until the user subsequently releases the button and presses it again.</P>
|
||||
<P><b>01 - NEWMED</b></P>
|
||||
<P>This Qualifier indicates that a medium has been newly inserted in the target. The Qualifier must not be set for more than one invocation of the GET MEDIA STATUS command, until the user removes or reinserts the medium. In other words, when the user inserts a new medium in the target, and a GET MEDIA STATUS command is issued, the target will set this Qualifier. The next GET MEDIA STATUS command must not result in this Qualifier being set again unless the medium has been removed and reinserted.</P>
|
||||
<P>All other Qualifiers are reserved.</P>
|
||||
|
||||
<h3><A NAME="SCSI"></A>SCSI Compatibility Considerations</h3>
|
||||
|
||||
<P>SCSI commands must be processed exactly the same as they would be if Media Status Notification was not enabled. When the GET MEDIA STATUS command is received by the SCSI target, the status changed error codes must be reported as described in "Returning Media Status" earlier in this specification. However, the state of the bits must not be cleared by any other SCSI command. The insertion of a new medium must be reported independently with both the GET MEDIA STATUS and other SCSI commands. For example, if the user inserts a new medium and the target is accessed with an SCSI command, the CHECK CONDITION with UNIT ATTENTION must be reported, but the target must also report the NEMED error when it receives the next GET MEDIA STATUS command. The behavior must be the same if, after the medium is inserted, the GET MEDIA STATUS command is received before the next SCSI command.</P>
|
||||
<P>When the user presses the Eject button on the target, the SCSI commands must not be affected, but the EJREQ status must be reported when the first GET MEDIA STATUS command is received after the button is pressed, (it is reported only once after each button press). The SCSI target must continue to operate as normal. If the host determines that it is safe to eject the medium, an SCSI EJECT command shall be issued to the target by the host, at which time the target shall eject the medium.</P>
|
||||
|
||||
<P><TABLE WIDTH=78% BORDER=1 CELLPADDING=5 CELLSPACING=0>
|
||||
<TR VALIGN=TOP BGCOLOR="#80AADD">
|
||||
<TD colspan=3><FONT FACE="Arial" SIZE=2><B>Revision Record</B></FONT></TD></TR>
|
||||
<TR VALIGN=TOP>
|
||||
<TD><FONT FACE="Arial" SIZE=2><b>Edition</b></FONT></TD>
|
||||
<TD><FONT FACE="Arial" SIZE=2>Date Published</FONT></TD>
|
||||
<TD><FONT FACE="Arial" SIZE=2>Revised Comments</FONT></TD></TR>
|
||||
<TR VALIGN=TOP>
|
||||
<TD><FONT FACE="Arial" SIZE=2>0.1</FONT></TD>
|
||||
<TD><FONT FACE="Arial" SIZE=2>March 1996</FONT></TD>
|
||||
<TD><FONT FACE="Arial" SIZE=2>First Draft Version</FONT></TD></TR>
|
||||
</TABLE></P>
|
||||
<P>Send comments to <A HREF="mailto:billpa@microsoft.com">billpa@microsoft.com</A>.</P>
|
||||
|
||||
|
||||
<!-- XXXXXXXXXXXXXXXX END CONTENT XXXXXXXXXXXXXXXXXXXXXX -->
|
||||
</div></blockquote></font>
|
||||
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH=92% BORDER=0>
|
||||
<TR><TD WIDTH=60></TD><TD></TD></TR><TR><TD></TD><TD valign=top>
|
||||
<hr size="1" color="#441100" noshade WIDTH="100%">
|
||||
<FONT FACE="Verdana, Arial, Helvetica" SIZE=1><p>
|
||||
<!-- ENTER CHANGE OF DATE -->
|
||||
<q class=date>File Date: July 7, 1998<br>
|
||||
<!--COPYRIGHT STATEMENT--><A STYLE="color:#001144" STYLE="text-decoration:underline;" HREF="/misc/cpyright.htm">© 1999 Microsoft Corporation. All rights reserved. Terms of Use.</A></q><BR></FONT>
|
||||
<!--COPYRIGHT STATEMENT END--></TD></TR></table>
|
||||
</BODY>
|
||||
</HTML>
|
||||
1028
study/sabre/os/files/Disk/SecureDeletion.html
Normal file
1028
study/sabre/os/files/Disk/SecureDeletion.html
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
712
study/sabre/os/files/Disk/cdromfaq.txt
Normal file
712
study/sabre/os/files/Disk/cdromfaq.txt
Normal file
@@ -0,0 +1,712 @@
|
||||
From marcj@nando.net Wed Mar 1 17:51:03 1995
|
||||
From: marcj@nando.net (MarcJ)
|
||||
Newsgroups: comp.os.msdos.programmer
|
||||
Subject: CD-ROM FAQ
|
||||
Date: 19 Feb 1995 23:18:50 -0500
|
||||
Organization: NandO -- The News & Observer online service
|
||||
NNTP-Posting-Host: parsifal.nando.net
|
||||
|
||||
In recognition of a number of questions I've seen recently asking
|
||||
questions on programming CD-ROMs...
|
||||
|
||||
CD-ROM programming FAQ Version 1.00
|
||||
|
||||
Copyright (C) 1995 by Marcus W. Johnson. All rights reserved. This
|
||||
article is not in the public domain, but it may be redistributed so
|
||||
long as this notice, the acknowledgments, and the information on
|
||||
obtaining the latest copy of this list are retained and no fee is
|
||||
charged. The code fragments may be used freely; credit would be
|
||||
polite.
|
||||
|
||||
------- Table of Contents --------------------------------------------
|
||||
|
||||
Section 0 - Availability
|
||||
0.01. How can I get the latest copy of this FAQ?
|
||||
Section 1 - MSCDEX Status
|
||||
1.01. How do I know if MSCDEX is installed?
|
||||
1.02. How do I determine the MSCDEX version?
|
||||
Section 2 - CD-ROM Existence
|
||||
2.01. How many CD-ROMs are present?
|
||||
2.02. Which drives are CD-ROMs?
|
||||
2.03. How do I get the name of the CD-ROM device driver?
|
||||
Section 3 - Drive Interface
|
||||
3.01. How do I open the door?
|
||||
3.02. How do I close the door?
|
||||
3.03. How do I unlock the door?
|
||||
3.04. How do I lock the door?
|
||||
3.05. How do I reset the drive?
|
||||
3.06. How do I get drive status?
|
||||
Section 4 - Drive Capacity
|
||||
4.01. What sector size is supported?
|
||||
4.02. How many sectors are on the disk?
|
||||
4.03. How much data is on the disk?
|
||||
Section 5 - Volume Table of Contents
|
||||
5.01. How do I get the abstract file name?
|
||||
5.02. How do I get the bibliography file name?
|
||||
5.03. How do I get the copyright file name?
|
||||
5.04. How do I read the Volume Table of Contents (VTOC)?
|
||||
Section 6 - Audio
|
||||
6.01. How do I find out how many tracks are on a CD?
|
||||
6.02. What are Red Book and HSG formats?
|
||||
6.03. How can I determine where a particular track starts?
|
||||
6.04. How do I play audio?
|
||||
6.05. How do I pause audio playback?
|
||||
6.06. How do I resume audio playback?
|
||||
|
||||
======================================================================
|
||||
Section 0 - Administration
|
||||
----------------------------------------------------------------------
|
||||
0.01. How can I get the latest copy of this FAQ?
|
||||
|
||||
The FAQ is published monthly in comp.os.msdos.programming and
|
||||
alt.msdos.programmer.
|
||||
----------------------------------------------------------------------
|
||||
0.02. Where did this information come from?
|
||||
|
||||
Ralf Brown's interrupt list
|
||||
"MS-DOS Extensions", by Ray Duncan, Microsoft Press
|
||||
My personal research for "PC-Programmer's Guide to Low-Level
|
||||
Functions and Interrupts", Sams
|
||||
The mention of particular books or programs must not be construed
|
||||
to reflect unfavorably on any that are not mentioned.
|
||||
----------------------------------------------------------------------
|
||||
0.03. How accurate is this information?
|
||||
|
||||
I have personally tested the code fragments in this FAQ, and
|
||||
they appear to work as advertised, but there is no warranty on
|
||||
the code or on the techniques described in this article.
|
||||
As testing may not have been perfect, and machines and
|
||||
configurations vary, it is possible that the fragments will not
|
||||
work for you.
|
||||
Please send corrections to marcj@nando.net.
|
||||
======================================================================
|
||||
Section 1 - MSCDEX Status
|
||||
======================================================================
|
||||
1.01. How do I know if MSCDEX is installed?
|
||||
|
||||
Call the MSCDEX installation check function. Here's code that
|
||||
performs the check:
|
||||
|
||||
mov AX,0DADAH
|
||||
push AX
|
||||
mov AX,01100H
|
||||
int 2FH
|
||||
pop BX
|
||||
cmp BX,0ADADH
|
||||
jne not_installed
|
||||
cmp AL,0FFH
|
||||
jne not_installed
|
||||
;
|
||||
; MSCDEX is installed
|
||||
;
|
||||
----------------------------------------------------------------------
|
||||
1.02. How do I determine the MSCDEX version?
|
||||
|
||||
Call the MSCDEX version check function. Here's code that gets
|
||||
the version:
|
||||
|
||||
mov AX,150CH
|
||||
int 2FH
|
||||
;
|
||||
; BH holds the major version
|
||||
; BL holds the minor version
|
||||
; Prior to MSCDEX version 2.0, the version returned is 0.0 (BX =
|
||||
; 0)
|
||||
;
|
||||
======================================================================
|
||||
Section 2 - CD-ROM Existence
|
||||
======================================================================
|
||||
2.01. How many CD-ROMs are present?
|
||||
|
||||
Ask MSCDEX. Here's code that gives the count of CD-ROMs
|
||||
installed and the drive letter of the first one:
|
||||
|
||||
mov AX,1500H
|
||||
xor BX,BX
|
||||
int 2FH
|
||||
;
|
||||
; BX will hold the number of CD-ROMs
|
||||
; CL will hold the first CD-ROM's drive; 0 = A:, 1 = B:, and so
|
||||
; on
|
||||
;
|
||||
|
||||
A problem with this method, BTW, is that it conflicts with DOS
|
||||
4.0's GRAPHICS.COM.
|
||||
----------------------------------------------------------------------
|
||||
2.02. Which drives are CD-ROMs?
|
||||
|
||||
There are two ways to find out. Both ways require MSCDEX version
|
||||
2 (see question 1.02, How do I determine the MSCDEX version?).
|
||||
The first way gives a list of all CD-ROM drives; the second
|
||||
verifies whether a specific drive is a CD-ROM.
|
||||
|
||||
Method 1: (get list of CD-ROMs)
|
||||
This method requires a block of memory; the size, in bytes, must
|
||||
be at least the number of drives returned by function 1500H (see
|
||||
question 2.01, How many CD-ROMs are present?).
|
||||
|
||||
mov AX,150DH
|
||||
les BX,LetterArray
|
||||
int 2FH
|
||||
;
|
||||
; each byte in LetterArray will contain a drive value (0 = A:, 1
|
||||
; = B:, etc.)
|
||||
;
|
||||
|
||||
Method 2: (is a specified drive a CD-ROM?)
|
||||
|
||||
mov AX,150BH
|
||||
mov CX,Drive ; 0 = A:, 1 = B:, and so on
|
||||
int 2FH
|
||||
or AX,AX
|
||||
jz not_cd_rom
|
||||
cmp BX,0ADADH
|
||||
jne not_cd_rom
|
||||
;
|
||||
; the drive is a CD-ROM
|
||||
;
|
||||
----------------------------------------------------------------------
|
||||
2.03. How do I get the name of the CD-ROM device driver?
|
||||
|
||||
First, you need to know how many CD-ROMs you have (see question
|
||||
2.01, How many CD-ROMs are present?). You need a block of memory
|
||||
whose size, in bytes, is 5 times the number of CD-ROMs present.
|
||||
This code will fill that array:
|
||||
|
||||
mov AX,1501H
|
||||
les BX,DriverArray
|
||||
int 2FH
|
||||
|
||||
Each 5-byte element in the array consists of the drive's subunit
|
||||
number (a CD-ROM device driver may support several drives as
|
||||
subunits), followed by the address of the drive's device driver.
|
||||
The filename is 10 bytes into the device driver. The filename is
|
||||
at most 8 bytes long, and if less than 8 bytes, is terminated by
|
||||
a space (20H).
|
||||
======================================================================
|
||||
Section 3 - Drive Interface
|
||||
======================================================================
|
||||
3.01. How do I open the door?
|
||||
|
||||
First, you need the name of the device driver (see question 2.03,
|
||||
How do I get the name of the CD-ROM device driver?). Open the
|
||||
file for read/write and obtain the file handle (DOS function 3DH
|
||||
will suffice).
|
||||
|
||||
Once you have the file handle, you need a one byte block of
|
||||
memory. Call DOS IOCTL function 4403H, as shown here:
|
||||
|
||||
mov BX,FileHandle
|
||||
mov Command,0
|
||||
lds DX,Command
|
||||
mov CX,1
|
||||
mov AX,4403H
|
||||
int 21H
|
||||
jc error
|
||||
cmp AX,1
|
||||
jne write_error
|
||||
;
|
||||
; door should be open
|
||||
;
|
||||
|
||||
On error (carry set), AX will hold an error code: 0001H (invalid
|
||||
function), 0005H (access denied), 0006H (invalid handle), or
|
||||
000DH (invalid data).
|
||||
----------------------------------------------------------------------
|
||||
3.02. How do I close the door?
|
||||
|
||||
First, you need the name of the device driver (see question 2.03,
|
||||
How do I get the name of the CD-ROM device driver?). Open the
|
||||
file for read/write and obtain the file handle (DOS function 3DH
|
||||
will suffice).
|
||||
|
||||
Once you have the file handle, you need a one byte block of
|
||||
memory. Call DOS IOCTL function 4403H, as shown here:
|
||||
|
||||
mov BX,FileHandle
|
||||
mov Command,5
|
||||
lds DX,Command
|
||||
mov CX,1
|
||||
mov AX,4403H
|
||||
int 21H
|
||||
jc error
|
||||
cmp AX,1
|
||||
jne write_error
|
||||
;
|
||||
; door should be closed
|
||||
;
|
||||
|
||||
On error (carry set), AX will hold an error code: 0001H (invalid
|
||||
function), 0005H (access denied), 0006H (invalid handle), or
|
||||
000DH (invalid data).
|
||||
|
||||
The drive should be reset after closing the door before
|
||||
accessing the drive (see question 3.05, How do I reset the
|
||||
drive?).
|
||||
----------------------------------------------------------------------
|
||||
3.03. How do I unlock the door?
|
||||
|
||||
First, you need the name of the device driver (see question 2.03,
|
||||
How do I get the name of the CD-ROM device driver?). Open the
|
||||
file for read/write and obtain the file handle (DOS function 3DH
|
||||
will suffice).
|
||||
|
||||
Once you have the file handle, you need a two-byte block of
|
||||
memory. Call DOS IOCTL function 4403H, as shown here:
|
||||
|
||||
mov BX,FileHandle
|
||||
mov Command,1
|
||||
mov Command+1,0
|
||||
lds DX,Command
|
||||
mov CX,2
|
||||
mov AX,4403H
|
||||
int 21H
|
||||
jc error
|
||||
cmp AX,2
|
||||
jne write_error
|
||||
;
|
||||
; door should be unlocked
|
||||
;
|
||||
|
||||
On error (carry set), AX will hold an error code: 0001H (invalid
|
||||
function), 0005H (access denied), 0006H (invalid handle), or
|
||||
000DH (invalid data).
|
||||
|
||||
The drive should be reset after unlocking the door before
|
||||
accessing the drive (see question 3.05, How do I reset the
|
||||
drive?).
|
||||
----------------------------------------------------------------------
|
||||
3.04. How do I lock the door?
|
||||
|
||||
First, you need the name of the device driver (see question 2.03,
|
||||
How do I get the name of the CD-ROM device driver?). Open the
|
||||
file for read/write and obtain the file handle (DOS function 3DH
|
||||
will suffice).
|
||||
|
||||
Once you have the file handle, you need a two-byte block of
|
||||
memory. Call DOS IOCTL function 4403H, as shown here:
|
||||
|
||||
mov BX,FileHandle
|
||||
mov Command,1
|
||||
mov Command+1,1
|
||||
lds DX,Command
|
||||
mov CX,2
|
||||
mov AX,4403H
|
||||
int 21H
|
||||
jc error
|
||||
cmp AX,2
|
||||
jne write_error
|
||||
;
|
||||
; door should be locked
|
||||
;
|
||||
|
||||
On error (carry set), AX will hold an error code: 0001H (invalid
|
||||
function), 0005H (access denied), 0006H (invalid handle), or
|
||||
000DH (invalid data).
|
||||
|
||||
The drive should be reset after locking the door before
|
||||
accessing the drive (see question 3.05, How do I reset the
|
||||
drive?).
|
||||
----------------------------------------------------------------------
|
||||
3.05. How do I reset the drive?
|
||||
|
||||
First, you need the name of the device driver (see question 2.03,
|
||||
How do I get the name of the CD-ROM device driver?). Open the
|
||||
file for read/write and obtain the file handle (DOS function 3DH
|
||||
will suffice).
|
||||
|
||||
Once you have the file handle, you need a one-byte block of
|
||||
memory. Call DOS IOCTL function 4403H, as shown here:
|
||||
|
||||
mov BX,FileHandle
|
||||
mov Command,2
|
||||
lds DX,Command
|
||||
mov CX,1
|
||||
mov AX,4403H
|
||||
int 21H
|
||||
jc error
|
||||
cmp AX,1
|
||||
jne write_error
|
||||
;
|
||||
; drive should be reset
|
||||
;
|
||||
|
||||
On error (carry set), AX will hold an error code: 0001H (invalid
|
||||
function), 0005H (access denied), 0006H (invalid handle), or
|
||||
000DH (invalid data).
|
||||
----------------------------------------------------------------------
|
||||
3.06. How do I get drive status?
|
||||
|
||||
First, you need the name of the device driver (see question 2.03,
|
||||
How do I get the name of the CD-ROM device driver?). Open the
|
||||
file for read/write and obtain the file handle (DOS function 3DH
|
||||
will suffice).
|
||||
|
||||
Once you have the file handle, you need a five-byte block of
|
||||
memory. Call DOS IOCTL function 4402H, as shown here:
|
||||
|
||||
mov BX,FileHandle
|
||||
mov Command,6
|
||||
lds DX,Command
|
||||
mov CX,5
|
||||
mov AX,4402H
|
||||
int 21H
|
||||
jc error
|
||||
cmp AX,5
|
||||
jne read_error
|
||||
;
|
||||
; The word at offset 1 of the five-byte block of memory contains
|
||||
; status
|
||||
; bit 10 is set if audio is playing
|
||||
; bit 9 is set if Red Book and HSG addressing are both
|
||||
; supported
|
||||
; bit 8 is set if audio channel control is supported
|
||||
; bit 7 is set if prefetch requests are supported
|
||||
; bit 5 is set if interleaving is supported
|
||||
; bit 4 is set if audio/video track playback is supported
|
||||
; bit 3 is set if the CD-ROM is writable
|
||||
; bit 2 is set if raw and cooked read is supported
|
||||
; bit 1 is set if the door is unlocked
|
||||
; bit 0 is set if the door is open
|
||||
;
|
||||
|
||||
On error (carry set), AX will hold an error code: 0001H (invalid
|
||||
function), 0005H (access denied), 0006H (invalid handle), or
|
||||
000DH (invalid data).
|
||||
|
||||
The drive should be reset after checking drive status before
|
||||
accessing the drive (see question 3.05, How do I reset the
|
||||
drive?).
|
||||
======================================================================
|
||||
Section 4 - Drive Capacity
|
||||
======================================================================
|
||||
4.01. What sector size is supported?
|
||||
|
||||
First, you need the name of the device driver (see question 2.03,
|
||||
How do I get the name of the CD-ROM device driver?). Open the
|
||||
file for read/write and obtain the file handle (DOS function 3DH
|
||||
will suffice).
|
||||
|
||||
Once you have the file handle, you need a four-byte block of
|
||||
memory. Call DOS IOCTL function 4402H, as shown here:
|
||||
|
||||
mov BX,FileHandle
|
||||
mov Command,7
|
||||
lds DX,Command
|
||||
mov CX,4
|
||||
mov AX,4402H
|
||||
int 21H
|
||||
jc error
|
||||
cmp AX,4
|
||||
jne read_error
|
||||
;
|
||||
; The byte at offset 1 of the four-byte block of memory contains
|
||||
; raw/cooked status (0 = cooked, 1 = raw)
|
||||
; The word at offset 2 of the four-byte block of memory contains
|
||||
; the sector size
|
||||
|
||||
On error (carry set), AX will hold an error code: 0001H (invalid
|
||||
function), 0005H (access denied), 0006H (invalid handle), or
|
||||
000DH (invalid data).
|
||||
|
||||
The drive should be reset after getting the sector size before
|
||||
accessing the drive (see question 3.05, How do I reset the
|
||||
drive?).
|
||||
----------------------------------------------------------------------
|
||||
4.02. How many sectors are on the disk?
|
||||
|
||||
First, you need the name of the device driver (see question 2.03,
|
||||
How do I get the name of the CD-ROM device driver?). Open the
|
||||
file for read/write and obtain the file handle (DOS function 3DH
|
||||
will suffice).
|
||||
|
||||
Once you have the file handle, you need a five-byte block of
|
||||
memory. Call DOS IOCTL function 4402H, as shown here:
|
||||
|
||||
mov BX,FileHandle
|
||||
mov Command,8
|
||||
lds DX,Command
|
||||
mov CX,5
|
||||
mov AX,4402H
|
||||
int 21H
|
||||
jc error
|
||||
cmp AX,5
|
||||
jne read_error
|
||||
;
|
||||
; The dword at offset 1 of the five-byte block of memory
|
||||
; contains the number of sectors
|
||||
|
||||
On error (carry set), AX will hold an error code: 0001H (invalid
|
||||
function), 0005H (access denied), 0006H (invalid handle), or
|
||||
000DH (invalid data).
|
||||
|
||||
The drive should be reset after getting the number of sectors
|
||||
before accessing the drive (see question 3.05, How do I reset
|
||||
the drive?).
|
||||
----------------------------------------------------------------------
|
||||
4.03. How much data is on the disk?
|
||||
|
||||
See question 4.01, What sector size is supported?, and question
|
||||
4.02, How many sectors are on the disk?. Take the product of the
|
||||
two values returned. The conventional DOS functions don't work
|
||||
reliably.
|
||||
======================================================================
|
||||
Section 5 - Volume Table of Contents
|
||||
======================================================================
|
||||
5.01. How do I get the abstract file name?
|
||||
|
||||
You need a 38-byte block of memory to hold the abstract file
|
||||
name. This code will fill that block:
|
||||
|
||||
les BX,Buffer
|
||||
mov CX,Drive ; must be in format 0 = A:, 1 = B:, etc.
|
||||
mov AX,1503H
|
||||
int 2FH
|
||||
jc error
|
||||
;
|
||||
; buffer is filled with the abstract file name.
|
||||
;
|
||||
|
||||
The file name is nul-terminated.
|
||||
|
||||
The drive should be reset after getting the abstract file name
|
||||
before accessing the drive (see question 3.05, How do I reset
|
||||
the drive?).
|
||||
----------------------------------------------------------------------
|
||||
5.02. How do I get the bibliography file name?
|
||||
|
||||
You need a 38-byte block of memory to hold the bibliography file
|
||||
name. This code will fill that block:
|
||||
|
||||
les BX,Buffer
|
||||
mov CX,Drive ; must be in format 0 = A:, 1 = B:, etc.
|
||||
mov AX,1504H
|
||||
int 2FH
|
||||
jc error
|
||||
;
|
||||
; buffer is filled with the bibliography file name.
|
||||
;
|
||||
|
||||
The file name is nul-terminated.
|
||||
|
||||
The drive should be reset after getting the bibliography file
|
||||
name before accessing the drive (see question 3.05, How do I
|
||||
reset the drive?).
|
||||
----------------------------------------------------------------------
|
||||
5.03. How do I get the copyright file name?
|
||||
|
||||
You need a 38-byte block of memory to hold the copyright file
|
||||
name. This code will fill that block:
|
||||
|
||||
les BX,Buffer
|
||||
mov CX,Drive ; must be in format 0 = A:, 1 = B:, etc.
|
||||
mov AX,1502H
|
||||
int 2FH
|
||||
jc error
|
||||
;
|
||||
; buffer is filled with the copyright file name.
|
||||
;
|
||||
|
||||
The file name is nul-terminated.
|
||||
|
||||
The drive should be reset after getting the copyright file name
|
||||
before accessing the drive (see question 3.05, How do I reset
|
||||
the drive?).
|
||||
----------------------------------------------------------------------
|
||||
5.04. How do I read the Volume Table of Contents (VTOC)?
|
||||
|
||||
The VTOC is read in 2048-byte blocks. This code fills a VTOC
|
||||
block:
|
||||
|
||||
les BX,Buffer
|
||||
mov CX,Drive ; must be in format 0 = A:, 1 = B:, etc.
|
||||
mov DX,BlockNumber ; 0 for the first block
|
||||
mov AX,1505H
|
||||
int 2FH
|
||||
jc error
|
||||
;
|
||||
; block is filled
|
||||
;
|
||||
; AX contains the descriptor type for this block:
|
||||
; 0001H = standard volume descriptor
|
||||
; 00FFH = volume descriptor terminator
|
||||
;
|
||||
|
||||
On error, AX will hold an error value: 000FH (invalid drive) or
|
||||
0015H (drive not ready).
|
||||
======================================================================
|
||||
Section 6 - Audio
|
||||
======================================================================
|
||||
6.01. How do I find out how many tracks are on a CD?
|
||||
|
||||
First, you need the name of the device driver (see question
|
||||
2.03, How do I get the name of the CD-ROM device driver?). Open
|
||||
the file for read/write and obtain the file handle (DOS function
|
||||
3DH will suffice).
|
||||
|
||||
Once you have the file handle, you need a seven-byte block of
|
||||
memory. Call DOS IOCTL function 4402H, as shown here:
|
||||
|
||||
mov BX,FileHandle
|
||||
mov Command,0AH
|
||||
lds DX,Command
|
||||
mov CX,7
|
||||
mov AX,4402H
|
||||
int 21H
|
||||
jc error
|
||||
cmp AX,7
|
||||
jne read_error
|
||||
;
|
||||
; The byte at offset 1 of the seven-byte block of memory is the
|
||||
; number of the first track
|
||||
; The byte at offset 2 of the seven-byte block of memory is the
|
||||
; number of the last track
|
||||
; The dword at offset 4 of the seven-byte block of memory is the
|
||||
; start address of the first track in Red Book format
|
||||
|
||||
On error (carry set), AX will hold an error code: 0001H (invalid
|
||||
function), 0005H (access denied), 0006H (invalid handle), or
|
||||
000DH (invalid data).
|
||||
----------------------------------------------------------------------
|
||||
6.02. What are Red Book and HSG formats?
|
||||
|
||||
Both are ways of encoding frame information. An audio frame is
|
||||
1/75 second of audio. HSG encodes frame information into a
|
||||
double word: minute multiplied by 4500, plus second multiplied
|
||||
by 75, plus frame, minus 150. Red Book encodes frame information
|
||||
into a four-byte data structure:
|
||||
Byte 0: frame number
|
||||
Byte 1: second
|
||||
Byte 2: minute
|
||||
Byte 3: unused
|
||||
----------------------------------------------------------------------
|
||||
6.03. How can I determine where a particular track starts?
|
||||
|
||||
First, you need the name of the device driver (see question
|
||||
2.03, How do I get the name of the CD-ROM device driver?). Open
|
||||
the file for read/write and obtain the file handle (DOS function
|
||||
3DH will suffice).
|
||||
|
||||
Once you have the file handle, you need an eight-byte block of
|
||||
memory. Call DOS IOCTL function 4402H, as shown here:
|
||||
|
||||
mov BX,FileHandle
|
||||
mov Command,0BH
|
||||
mov Command+1,TrackNumber
|
||||
lds DX,Command
|
||||
mov CX,8
|
||||
mov AX,4402H
|
||||
int 21H
|
||||
jc error
|
||||
cmp AX,8
|
||||
jne read_error
|
||||
;
|
||||
; The dword at offset 2 of the eight-byte block of memory is the
|
||||
; start address of the specified track in Red Book format
|
||||
; The word at offset 6 of the eight-byte block of memory is the
|
||||
; track control information. Bits 15-12 are used:
|
||||
; 0xxx: Two audio channels, no pre-emphasis, digital copy not
|
||||
; permitted
|
||||
; 1xxx: Two audio channels, with pre-emphasis, digital copy not
|
||||
; permitted
|
||||
; 2xxx: Two audio channels, no pre-emphasis, digital copy
|
||||
; permitted
|
||||
; 3xxx: Two audio channels, with pre-emphasis, digital copy
|
||||
; permitted
|
||||
; 4xxx: Data track, digital copy not permitted
|
||||
; 6xxx: Data track, digital copy permitted
|
||||
; 8xxx: Four audio channels, no pre-emphasis, digital copy not
|
||||
; permitted
|
||||
; 9xxx: Four audio channels, with pre-emphasis, digital copy not
|
||||
; permitted
|
||||
; Axxx: Four audio channels, no pre-emphasis, digital copy
|
||||
; permitted
|
||||
; Bxxx: Four audio channels, with pre-emphasis, digital copy
|
||||
; permitted
|
||||
|
||||
On error (carry set), AX will hold an error code: 0001H (invalid
|
||||
function), 0005H (access denied), 0006H (invalid handle), or
|
||||
000DH (invalid data).
|
||||
----------------------------------------------------------------------
|
||||
6.04. How do I play audio?
|
||||
|
||||
For starters, you need MSCDEX Version 2.1 or greater (see
|
||||
question 1.02, How do I determine the MSCDEX version?).
|
||||
|
||||
You also need the subunit number for the drive containing the
|
||||
audio CD (see question 2.03, How do I get the name of the CD-ROM
|
||||
device driver?)
|
||||
|
||||
You also need to know what frame you want to start with (see
|
||||
question 6.03, How can I determine where a particular track
|
||||
starts?), and how many frames you want to play.
|
||||
|
||||
Now, you need a 22-byte block of memory. Write 22 (16H) to the
|
||||
first byte. Write the subunit number to the second byte. Write
|
||||
84H to the third byte. Write 0 to the byte at offset 0DH (this
|
||||
sets up HSG addressing). Convert the starting frame number to
|
||||
HSG format and write the 4-byte result to the dword at offset
|
||||
0EH. Finally, write the frame count to the dword at offset 12H.
|
||||
|
||||
To play the CD as instructed, execute this code:
|
||||
|
||||
les BX,Buffer
|
||||
mov CX,Drive ; must be in format 0 = A:, 1 = B:, etc.
|
||||
mov AX,1510H
|
||||
int 2FH
|
||||
;
|
||||
; status is in the word at offset 3 of the buffer. Look for bit
|
||||
; 8 set (done), and watch out for bit 15 set (error).
|
||||
;
|
||||
----------------------------------------------------------------------
|
||||
6.05. How do I pause audio playback?
|
||||
|
||||
For starters, you need MSCDEX Version 2.1 or greater (see
|
||||
question 1.02, How do I determine the MSCDEX version?).
|
||||
|
||||
You also need the subunit number for the drive containing the
|
||||
audio CD (see question 2.03, How do I get the name of the CD-ROM
|
||||
device driver?)
|
||||
|
||||
Now, you need a 13-byte block of memory. Write 13 (0DH) to the
|
||||
first byte. Write the subunit number to the second byte. Write
|
||||
85H to the third byte.
|
||||
|
||||
To pause the CD, execute this code:
|
||||
|
||||
les BX,Buffer
|
||||
mov CX,Drive ; must be in format 0 = A:, 1 = B:, etc.
|
||||
mov AX,1510H
|
||||
int 2FH
|
||||
;
|
||||
; status is in the word at offset 3 of the buffer. Look for bit
|
||||
; 8 set (done), and watch out for bit 15 set (error).
|
||||
;
|
||||
----------------------------------------------------------------------
|
||||
6.06. How do I resume audio playback?
|
||||
|
||||
For starters, you need MSCDEX Version 2.1 or greater (see
|
||||
question 1.02, How do I determine the MSCDEX version?).
|
||||
|
||||
You also need the subunit number for the drive containing the
|
||||
audio CD (see question 2.03, How do I get the name of the CD-ROM
|
||||
device driver?)
|
||||
|
||||
Now, you need a 13-byte block of memory. Write 13 (0DH) to the
|
||||
first byte. Write the subunit number to the second byte. Write
|
||||
88H to the third byte.
|
||||
|
||||
To resume, execute this code:
|
||||
|
||||
les BX,Buffer
|
||||
mov CX,Drive ; must be in format 0 = A:, 1 = B:, etc.
|
||||
mov AX,1510H
|
||||
int 2FH
|
||||
;
|
||||
; status is in the word at offset 3 of the buffer. Look for bit
|
||||
; 8 set (done), and watch out for bit 15 set (error).
|
||||
;
|
||||
|
||||
|
||||
|
||||
|
||||
7
study/sabre/os/files/Disk/index.html
Normal file
7
study/sabre/os/files/Disk/index.html
Normal file
@@ -0,0 +1,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;url=/Linux.old/sabre/os/articles">
|
||||
</head>
|
||||
<body lang="zh-CN">
|
||||
</body>
|
||||
</html>
|
||||
BIN
study/sabre/os/files/Disk/scsienbl.gif
Normal file
BIN
study/sabre/os/files/Disk/scsienbl.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.3 KiB |
BIN
study/sabre/os/files/Disk/scsigetm.gif
Normal file
BIN
study/sabre/os/files/Disk/scsigetm.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.1 KiB |
Reference in New Issue
Block a user