Hardware - IDE-BUS: description of the IDE bus and HDD commands.

ZX Format #08
IDE-BUS.            
                               
music by MIDISOFT              
Information provided by V. Eliseev.        
________________________________
                               
   Dfor those who want more details
to get acquainted with the work of the hard drive, we bring
Here's a description of the IDE bus and HDD commands.      
                               
+--------+----------+--------+-----------------------------+
| Contact| Direction | Signal | Function |
+--------+----------+--------+------------------------------+
|  1 | Out | Reset | - Host reset  |
|  3 |I/O | HD7 | Host data bus 7  |
|  5 |I/O | HDb | Host data bus b  |
|  7 | I/O | HDS    | Host data bus 5               |
|  9     |   I/O    | HDЧ    | Host data bus 4               |
| 11     |   I/O    | HDЗ    | Host data bus 3               |
| 13     |   I/O    | HD2    | Host data bus 2               |
| 15     |   I/O    | HD1    | Host data bus 1               |
| 17     |   I/O    | HDO    | Host data bus 0               |
| 19     |    -     | Ground |                               |
| 21     |   In     | DMARQ  | DMA Request                   |
| 23     |   Out    | -IOW   |- Host I/O Write              |
| 25     |   Out    | -IOR   | - Host I/O Read               |
| 27     |   In     | IOCHRDY|                               |
| 29     |   Out    | DMACK  | - DMA Acnowelege              |
| 31     |   In     | IRQ    | - Host interrupt request      |
| 33     |   Out    | HA1    | Host adress bus 1             |
| 35     |   Out    | HAO    | Host adress bus 0             |
| 37     |   Out    | -CSO   | - Host chip select 0          |
| 39     |   I/O    | -ACTIV | - Drive active                |
+--------+----------+--------+-------------------------------+
|  2     |    -     | Ground |                               |
|  4     |   I/O    | HD8    | Host data bus 8               |
|  б     |   I/O    | HD9    | Host data bus 9               |
|  8     |   I/O    | HD10   | Host data bus 10              |
| 10     |   I/O    | HD11   | Host data bus 11              |
| 12     |   I/O    | HD12   | Host data bus 12              |
| 14     |   I/O    | HD13   | Host data bus 13              |
| 1б     |   I/O    | HD14   | Host data bus 14              |
| 18     |   I/O    | HD15   | Host data bus 15              |
| 20     |    -     | Key    |                               |
| 22     |    -     | Ground |                               |
| 24     |    -     | Ground |                               |
| 2б     |    -     | Ground |                               |
| 28     |   Out    | ALE    |                               |
| 30     |    -     | Ground |                               |
| 32     |   In     | -HIO1б | - Host 1б-bit I/O chip select |
| 34     |   I/O    | -PDIAG |                               |
| 3б     |   Out    | HA2    | - Host adress bus 2           |
| 38     |   Out    | -CS1 | - Host chip select 1  |
| 40 | - | Ground |                               |
+--------+----------+--------+------------------------------+
                               
 1.  Signals whose source is
main machine (HOST), are weekends
mi, and the source of which is NMD -
input.                                
 2.  Signals active at low level
are marked with the prefix "-".                 
                               
 Below is a description of the signals        
 IDE interface.                        
                               
 -RESET  - reset signal from the main machine
us.                                      
                               
 Host data bus 0-15 - 16 bit two-
directional data bus. Low 8 bits,
HDO-HD7, used to access re-
histram.  All 16 bits are used to transfer
data transfer.                           
Ground  -  Ground connections between NMD and
main machine.                         
 KEY - Key. Used for privilege
cable orientation                        
 -IOW - Recording strobe, trailing edge
which data on HDO-HD15 lines is fixed
are registered in NMD registers.                  
 -IOR - Reading strobe, low level co-
which allows the transfer of data from the re-
ructpob NMD to the host machine data bus
us. Falling edge -IOR captures data from
NMD to the main machine.                   
 IRQ - Host machine interrupt signal.
Interruption is possible when the device is selected
swarm, and the main machine installs
-IEN bit in the Fixed Disk Register (address
3F6).  When no device is selected or
-IEN is not active, this output is in
high impedance state. IRQ set
is supplied by the drive microcontroller.
IRQ is reset to zero during operations
reading the host machine from the status register
tion or during a write operation in Command Re-
gister. Line with threestates.       
DAO,DA1,DA2 - Address lines used
to select a register in the task file.      
 -CSO - Crystal selection 0, decoding signal
controlled from the bus of the main machine. Using
Used to select registers with lower ad-
pecamu in the task file.                   
 -CS1 - Crystal selection 1, decoding signal
controlled from the bus of the main machine. Using
Used to select registers with higher ad-
pecamu in the task file.                   
 -HIO16  -  Signal from the NMD, informing
main machine, which is a 16-bit register
data is selected and that the NMD is ready to accept or
transmit a 16-bit data word. Line with
three states.                       
 -ACTIVE - Line from NMD, used for
turning on the LED when the main machine
does not access the disk.          
 DMARQ - Direct memory access request.
 -DMACK  - Request confirmation signal
RAP.                                     
                               
Note.                              
                               
 1. DMARQ and DMACK signals are reserved
for future use.             
                               
Required signal timing relationships 
           in the IDE interface:            
                               
Note. All tenses are given in HC. Address decoding. The main machine is addressed to the NMD, using using programmable I/O. When this register address has three address lines DAO-DA2 and choice of crystal -CSO or -CS1. Main machine data bus HD8-HD15 only allowed when signal is active -HIO16 and the host machine addresses the register data for data transfer. A set of registers accessible from the outside main machine, called task file (Task File). Table 4.3 shows the addresses and functions tions of registers. Table 4.3 +----+----+---+---+---+----+----+ |-CSO|-CS1|DA2|DA1|DAO| Read function | Recording function ||----+----+---+---+---+------------------+-------------------+ | 1 | 0 | 0 | X | X | высокий импеданс | не используется | | 1 | 0 | 1 | 0 | X | высокий импеданс | не используется | | 0 | 1 | 0 | 0 | 0 | Data Register | Data Register | | 0 | 1 | 0 | 0 | 1 | Еггог Register | не используется | | 0 | 1 | 0 | 1 | 0 | Sector Count | Sector Count | | 0 | 1 | 0 | 1 | 1 | Sector Number | Sector Number | | 0 | 1 | 1 | 0 | 0 | Cylinder Low | Cylinder Low || 0 | 1 | 1 | 0 | 1 | Cylinder High | Cylinder High | | 0 | 1 | 1 | 1 | 0 | SDH Register | SDH Register | | 0 | 1 | 1 | 1 | 1 | Status Register | Command Register | | 1 | 0 | 1 | 1 | 0 | Alternativ status|Fixed Disk Registr | | | | | | | Register | | | 1 | 0 | 1 | 1 | 1 | Digital Input | не используется | | | | | | | Register | | +----+----+---+---+---+------------------+-------------------+ Примечание. X - состояние безразлично. Описание регистров. Ниже дано описание регистров интерфей- са IDE.Unused bits in read registers are perceived as zeros, in write registers the state of these bits is indifferent. If bit is active, it is set to "1", if inactive, then set to "0". Data Register. Data register. Through this register data is hidden and written in commands reading and writing. Through this register, recording The sector rotation table is created in formatting command and data associated with the identification command. All data transmitted in 16-bit words, except error correction code (ECC) bytes. The data is stored on disk in the following sequence: leads: low byte first, then the high byte. Eggrog Register. The error register contains the status of the the last command executed by the NMD. Contents This register is only valid when the Status Register is set to bit 0 - ERR. After executing the diagnostic command (code 90) register contains the status code. The following describes the bits in the Error Register. 7 6 5 4 3 2 1 0 +---+---+---+----+---+----+----+----+ |BBK|UNC| - |IDNF| - |ABRT|TRKO|DMNF| +---+---+---+----+---+----+----+----+ BBK - Bad Block Mark - indicates that a bad mark has been found block in the required identifier field sectors. UNC - Uncorrectable Data Error - indicates that hekoppektu is taking place- Possible data error. IDNF - ID Field Not Found - indicates that the field was not detected ID of the required sector. ABRT - Abort - indicates that the required commandwas interrupted due to invalid co- yes commands, or unreadiness or errors NMD records. TRKO - Track 0 Not Found - indicates that track 0 is not detected during a recalibration command. DMNF - Data Adress Mark Not Found - indicates that the data address marker not found after ID required my sector. Sector Count. The sector counter determines the number data sectors for read/write command si. If the value in this register is 0, then the value of 256 sectors is determined. This counter decreases as you read recording/recording of each sector. Contents this register determines the number of sectors on the track when executing the Initia- command lize Drive Parameters. Sector Number. Sector number. This register contains numberinitial sector for any pre- stupid to NMD. When processing is completed, sec- torus and at the end of the command this register indicates calls for last correctly read sector or to the sector in which it occurred error. Cylinder Low Register of the lower digits of the ci number lindra contains the lower 8 digits on- initial cylinder number for any attitude towards NMD. When processing is complete sectors and at the end of the command this register changes and displays the current qi number lindra. Cylinder High Register of the most significant digits of the ci number lindra contains 3 senior digits cylinder number for any operation to NMD. When processing of the sector is completed and at the end of the command this register is changed and displays the current cylinder number. SDH Register 7 6 5 4 3 2 1 0 +---+---+---+---+---+---+---+---+ | 1 | 0 | 1 |DRV|HSЗ|HS2|HS1|HSO| +---+---+---+---+---+---+---+---+ DRV - Drive Select Number - 0 - selected NMD 0, 1 - selected NMD 1 HSЗ-HSO - binary coded selection number heads. Status Register This register contains information o condition of NMD. Contents of the change register Fires at the end of each command. EU- If the BSY bit is active, then the other bits are not are valid. Read by host machine this register confirms its receipt interrupts and resets the received interrupt tearing 7 6 5 4 3 2 1 0 +----+----+----+----+----+----+----+----+ |BSY |DRDY|DWF |DSC |DRQ|CORR|IDX |ERR | +----+----+----+----+----+----+----+----+ BSY - Busy - If this "busy" bit is active, then the mic The storage controller has access to registers of the task file, and the main machine no. Any reading by the main machine of the register reading the task file results in reading Status Register. DRDY - Drive Ready - Drive readiness indicator. DWF - Drive Write Fault - This bit indicates that the drive has a recording error occurred. DSC - Drive Seck Complete - This bit indicates that the heads are installed updated on the required track. DRQ - Data Request - Data request. Indicates thatNMD is ready to transmit a word or data byte data on the data bus. CORR - Corrected Data - NMD sets this bit to "1" if a data error occurred and this error was adjusted. IDX - Index - Index. This bit is active once per disk revolution. ERR - Error - Error bit. Indicates to the main machine what happened during the last operation error. The bits in the Error Register provide for additional information. Command Register. Command register. Home to this register the machine writes an 8-bit command code dy, which will be performed by the NMD. Command execution starts immediately after the registration has been made to the register writing Таблица 4.4 +-----------------------------------+---+--------------------+ | | К | Регистры | | Команда | о +----+----+----+-----+ | | д | SC | SN | CN | SDH | |-----------------------------------+---+----+----+----+-----+ |Recalibrate | 1X| | | | DRV | |Read Sector(s) (с повторами) | 20| V | V | V | V | |Read Sector(s) (без повторов) | 21| V | V | V | V | |Read Long (с повторами) | 22| V | V | V | V | |Read Long (без повторов) | 23| V | V | V | V | |Read Verify Sector(s)(с повторами) | 40| V | V | V | V | |Read Verify Sector(s)(без повторов)| 41| V | V | V | V | |Write Sector(s) (с повторами) | 30| V | V | V | V | |Write Sector(s) (без повторов) | 31| V | V | V | V | |Write Long (с повторами) | 32| V | V | V | V | |Write Long (без повторов) | 33| V | V | V | V | |Format Track | 50| V | | V | V | |Seek | 7X| | V | V | V | |Execute Drive Diagnostic | 90| | | | DRV | |Initialize Drive Parameters | 91| V | | | V | |Read Sector Buffer | E4| | | | DRV | |Write Sector Buffer | E8| | | | DRV | |Identify Drive | EC| | | | DRV | +-----------------------------------+---+----+----+----+-----+ Примечание. 1. X - означает, что значение битов без- различно; V - означает, что данный регистр ис- пользуется. Регистры: SC - Sector Count SN - Sector Number CN - Cylinder Low & High SDH - SDH Register DRV - means that in the SDH Register Only the DRV bit is used, all others bits are not valid. 2. Commands are given in hexadecimal system topic. 3. "With repetitions" means that in the command x Writes and Reads identifier search carried out for 10 index pulses owls, and “no repetitions” - for 2. Alternativ Status Register. Alternate status register crashes with Status Register, but is configured to other addresses. The only difference from Status Register iswhat reading this register does not lead to confirmation of pre- tearing or clearing the interrupt request. 7 6 5 4 3 2 1 0 +----+----+----+----+----+----+----+----+ |BSY |DRDY|DWF |DSC |DRQ |CORR|IDX |ERR | +----+----+----+----+----+----+----+----+ A description of the bits of this register is given in the description sania Status Register. Fixed Disk Register. This register is used for programming frame reset of NMD and for control of dis- interrupt solution. 7 6 5 4 3 2 1 0 +----+----+---+---+-------+----+----+---+ | 0 | 0 | 0 | 0 |HSЗEN=1|SRST|-IEN| 0 | +----+----+---+---+-------+----+----+---+ HSЗEN - Head Select 3 Enable - “1” is always written to this bit. SRST - Host Software Reset - soft reset - working out this bit leads to NMD reset. -IEN - Interrupt Enable - interrupt enable. When -IEN=0 and NMD is selected, then the production of pre- jerking on the IRQ output. When -IEN=1, then IRQ output to high impedance state. Digital Input Register. This register shows which NMD selected and which head is currently selected moment. 7 6 5 4 3 2 1 0 +----+----+----+----+----+----+----+----+ |HIZ |-WTG|-HSЗ|-HS2|-HS1|-HSO|-DS1|-DSO| +----+----+----+----+----+----+----+----+ HIZ - when this register is read, the output is DD7 is set to a state of high im- pedance. -WTG - Write Gate - NMD produces -WTG during commands records. (-HSЗ)-(-HSO) - Head Select - Binary's complement to the selected address heads. For example, if HSЗ-HSO=1010, then 5th head selected. -DS1,-DSO - Drive Select - Shows which of the two drives selected and active at this time. Description of commands. All commands are decoded from Command Register. To give a command, you must register load the corresponding registers in the file tasks, activate the enable bit tear -IEN and write the command code in Command Register. Execution of command on- starts after writing the command in Command Register. Recalibrate. This command moves the recording heads si/read to cylinder 0. Having received the command, NMD installs BSY and searches cylinder 0. Then the NMD waits for the end search, updates register state task file, clears BSY and generates interruption Table 4.7 shows the communication protocol for this command. Read Sector(s) These commands allow you to read from 1 up to 256 sectors of 512 bytes, starting from sector specified in Sector Number. If Sector Count = 0, then it will be read 256 sectors. Table 4.5 shows the exchange protocol for these commands. If the NMD is not on the selected horn, a search is carried out. If NMD is on- walks on the selected track, then is the search for an identifier for 2 in- dex pulses, for Read Sector(s) without repetitions and for 10, for Read Sector(s) with repetitions. If the ID is read correctly, then the data field synchronization byte must be found before the next impulse of the secto- ra, otherwise a DMNF error will be issued. Until the command completes, the file registers are dachas contain roomcylinder, head and sectors for last read sec- tora. If an error occurs, then read stops at the sector where this error occurs discovered. In this case, the file registers tasks contain the number of the cylinder, head and sector where the error occurred. Sector Co- unt contains the number of untransferred sectors. If this error was a hekoppek error- data, then this data will be accessible are difficult for the main machine to read, and Talent sectors will not be transferred. After the command completes successfully Sector Count = 0. If the Read Long command is executed, then NMD does not check ECC bytes to determine error in the data field. NMD returns to the main machine not only data, but also 7 error correction byte (ECC). Data Bytes are transmitted in 16-bit parcels, and the bytes ECC - 8-bit. Read Long commands are always single-sector teams. PROTOCOL FOR EXECUTING READ COMMANDS Table 4.5 +---+-----------+-----------------------------+ |STEP| MAIN MACHINE | NMD ||---+--------------------------+-----------------------------+ |1 | Проверка, что BSY=0 и | | | | DRDY=1 | | |2 | Запись в регистры: | | | | Sector Count | | | | Sector Number | | | | Cylinder Low | | | | Cylinder High | | | | SDH | | |3 | Record in CommandRegister | | |4 | |Sets BSY=1 | |5 | |Preparing for data transfer | | | |(loads data into the buffer | | | |data) | |b | |Sets DRQ=1,BSY=0 and | | | |generate IRQ | |7 | Reads Status Register | | |8 | |Resets IRQ | |9 | Reads a data block | | |10 | |Sets DRQ=0 | |11 | |If a multi-sector command, | | | |then return to step 4 | |12 | Ready for the next one | | | | command | | +---+-----------+----------------------------+ Note. This protocol is applicable to the following commands: Identify Drive Read Buffer Read Sector(s). Write Sector(s) These commands allow you to write from 1 up to 256 sectors of 512 bytes, starting from sector specified in Sector Number. If Sector Count = 0, then 256 will be written sectors. Table 4.6 shows the communication protocol for these commands. If the NMD is not on the selected horn, a search is carried out. If NMD is on- walks on the selected track, then is the search for an identifier for 2 in- dex pulses, for Write Sector(s) no repetitions and for 10, for Write Sec- tor(s) with repetitions. If the ID is not found, then IDNF error is set. PROTOCOL FOR EXECUTING RECORDING COMMANDS Таблица 4.6 +---+--------------------------+-----------------------------+ |ШАГ| ГЛАВНАЯ МАШИНА | НМД | |---+--------------------------+-----------------------------+ |1 | Проверка, что BSY=0 и | | | | DRDY=1 | | |2 | Запись в регистры: | | | | Sector Count | | | | Sector Number | | | | Cylinder Low | | | | Cylinder High | | | | SDH | | |3 | Запись в CommandRegister | | |4 | |Устанавливает DRQ=1 | |5 | Читает Status Register | | | | (DRQ=1)(необезательно) | | |б | Записывает блок данных | | | | в Data Register | | |7 | |Sets DRQ=0,BSY=1 | |8 | |Processing data | |9 | |Sets BSY=0, select- | | | |sets IRQ and sets | | | |DRQ=1, if transmitted | | | |one more data block | |10 | Reads Status Register | | | | (in response to IRQ) | | |11 | |Resets IRQ | |12 | |If a multi-sector command, | | | |then return to step 5 | |13 | Ready for the next one | | | | command | | +---+-----------+----------------------------+ Note: This protocol is applicable to the following commands: Format Track Write Buffer Write Sector(s). If the ID is read correctly, the data is recorded armed inbuffer, written to field sector data accompanied by internal generating ECC code. If it happened error while writing more than one sector, then recording stops at sector re where the error occurred and the task file contains the number of the cylinder, head and section where the error occurred. Upon completion command registers contain cylinder numbers ra, heads and sectors corresponding the last recorded sector. After the command completes successfully Sector Count = 0. It is necessary to take into account that NMD may remove additional blocks from the machine data to ensure high performance body recording. The Write Long command writes sends data and 7 bytes ECC directly from the buffer ra sector, while the NMD itself does not generate no ECC bytes. Data bytes are transmitted over 16-bit links, 8-bit ECC bytes. Teams Write Long is always single-sector commands. Read Verify Sector(s). This command is identical to Read Sector(s), except that the data is not transferred are given to the main machine. COMMAND EXECUTION PROTOCOL, HE USING TRANSMISSIONДАННЫХ Таблица 4.7 +---+--------------------------+-----------------------------+ |ШАГ| ГЛАВНАЯ МАШИНА | НМД | |---+--------------------------+-----------------------------+ |1 | Проверка, что BSY=0 и | | | | DRDY=1 | | |2 | Запись в регистры: | | | | Sector Count | | | | Sector Number | | | | Cylinder Low | | | | Cylinder High | | | | SDH | | |3 | Запись в CommandRegister | | |4 | |Устанавливает BSY=1 | |5 | |Выполняет действия соответ- | | | |ствующие команде | |б | |Устанавливает BSY=0 и | | | |вырабатывает IRQ | |7 | Reads Status Register | | |8 | |Resets IRQ | |9 | Ready for the next one | | | | command | | +---+-----------+----------------------------+ Note: This protocol is applicable to the following commands: Execute Drive Diagnostic Read Verify Sector(s) Recalibrate Seek Initialize Drive Parameters. Format Track. This command formats the track by given in the task file. Track address op- determined by the value in Cylindr High & Cy- linder Low Registers, and the number of sects ditch is defined in Sector Count. When you- the command is being processed, NMD installs DRQ bit and waits for input from the master machine 512 byte data format. When data received, NMD awaits DRQ, set enters BSY, starts executing commands yes. If the NMD is not at a given level, horn, starts searching for a track. When the NMD is on a given track, NMD starts formatting using data received from the host machine. Contents of data received from the heads- noy machine, are interpreted as follows way: Table 4.8 +-----------------+------------------+ |DD15-DDO8 | DDO7-DDO | +-----------------+------------------+ | первый сектор | +-----------------+------------------+ |номер сектора | дескриптор | +-----------------+------------------+ | последний сектор | +-----------------+------------------+ |номер сектора | дескриптор | +-----------------+------------------+ |оставшиеся байты записываются нулями| +------------------------------------+ Each sector is characterized by 16-bit in a word. DD15-DD8 contain the sec number tora. Typically the sector numbers follow order, starting from 1, to ensure sector editing 1:1. DD7-DDO contain descriptor number, where: 00H - sector formatting as good shego; 80H - formatting the sector as a flat xoro. Values other than 00 and 80 uhtepnpe- rated as good sectors. Table 4.6 shows the protocol for this command. Seek. This command initiates a search for horns and selects the head defined in task file. To run this command NMD does not have to be formatted van. NMD can generate interrupts up to complete the search. Table 4.7 shows the protocol for this command. Execute Drive Diagnostic. Perform diagnostics of NMD. After half- The execution of this command is carried out internally by the NMD. tion tests. After performing diagnostics in Error Register 8-bit code described below: code description 01 no errors 02 controller error 03 sector buffer error 05 microcontroller error Note: NMD can issue in chief car and other codes, the meanings of which ry are specified at the design stage. Table 4.7 shows the protocol for this command.Initialize Drive Parameters. Initialization of NMD parameters. Allow- The control machine cannot set the number sectors per track and the maximum number heads that should be emulated NMD. Upon receiving the command, the NMD will install BSY, saves these parameters, clears BSY and generate an interrupt. This command only uses re- hysteres Sector Count, which indicates maximum number of heads. DRV bit is off sets accordingly NMD 0 or NMD 1. Sec- tor Count and SDH Register are not checked for the correctness of this command. If they are not correct, there will be no error message be issued before any task is completed manda using these values. Table 4.7 shows the protocol for this command. Read Buffer. Reading a buffer. Allows the main machine do not read 512 bytes of data from the sec buffer torus NMD. Upon receipt of this command, NMD sets BSY, prepares buffer for a read operation, sets DRQ, waits for BSY, generates an interrupt. Head- The machine then reads the data bytes from this buffer.Table 4.6 shows the protocol for this command. Write Buffer. Write buffer. This command allows host machine overwrite contents NMD data buffer. Table 4.6 shows the protocol for this command. Identify Drive. Identify NMD. Allows head- receive information o from the NMD German Upon receipt of this command, the NMD installs sets BSY, writes to the data buffer formation, sets DRQ and generates interruption The main machine reads this information from the buffer. Structure of returned NMD information looks like this. Byte Contents 00-01 HEX ? 02-03 HEX количество цилиндров 04-0б HEX 0 07 HEX количество головок 08-09 HEX байт на дорожке OA-OB HEX байт на сектор 0C HEX 0 0D HEX секторов на дорожке 0E-13 HEX ? 14-27 ASCII Serial Number (конец со- общения 00h) 28 HEX 0 29-2D HEX ? 2E-35 ASCII Firmware Revision Зб-SD ASCII Model Number (конец со- общения 80h) В ячейках, где числа занимают два бай- та, информация располагается следующим образом: в младшей ячейке находится стар- ший байт числа, а в следующей ячейке младший байт этого числа. _______________________________

Share your thoughts about the article