⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ide.h

📁 (USB TO IDE)89s52和d12做的移动硬盘 适当修改USB.C可用于其他USB开发
💻 H
📖 第 1 页 / 共 2 页
字号:
 - nHS3 through nHS0 are the one's complement of the binary coded address of 
   the currently selected head. For example, if nHS3 through nHS0 are 1100b, 
   respectively, head 3 is selected. nHS3 is the most significant bit. 
 - nDS1 is the drive select bit for drive 1. When drive 1 is selected and 
   active, nDS1=0. 
 - nDS0 is the drive select bit for drive 0. When drive 0 is selected and 
   active, nDS0=0.

  NOTE: Care should be used when interpreting these bits, as they do not 
        always represent the expected status of drive operations at the 
        instant the status was put into this register. This is because of the 
        use of cacheing, translate mode and the Drive 0/Drive 1 concept with 
        each drive having its own embedded controller. 

*/


/*
7.2.8  Drive/Head Register

This register contains the drive and head numbers. The contents of this 
register define the number of heads minus 1, when executing an Initialize 
Drive Parameters command. 

         7       6       5       4       3       2       1       0 
     +-------+-------+-------+-------+-------+-------+-------+-------+
     |   1   |   L   |   1   |  DRV  |  HS3  |  HS2  |  HS1  |  HS0  | 
     +-------+-------+-------+-------+-------+-------+-------+-------+

 - L is the binary encoded address mode select. When L=0, addressing is by CHS 
   mode. When L=1, addressing is by LBA mode. 
 - DRV is the binary encoded drive select number. When DRV=0, Drive 0 is 
   selected. When DRV=1, Drive 1 is selected.
 - If L=0, HS3 through HS0 contain the binary coded address of the head to be 
   selected e.g. if HS3 through HS0 are 0011b, respectively, head 3 will be 
   selected. HS3 is the most significant bit. At command completion, these 
   bits are updated to reflect the currently selected head. 
   If L=1, HS3 through HS0 contain bits 24-27 of the LBA. At command 
   completion, these bits are updated to reflect the current LBA bits 24-27. 
*/


/*
7.2.9  Error Register 

This register contains status from the last command executed by the drive or a 
Diagnostic Code. 

At the completion of any command except Execute Drive Diagnostic, the contents 
of this register are valid when ERR=1 in the Status Register. 

Following a power on, a reset, or completion of an Execute Drive Diagnostic 
command, this register contains a Diagnostic Code (see Table 9-2). 

         7       6       5       4       3       2       1       0 
     +-------+-------+-------+-------+-------+-------+-------+-------+
     | BBK   |  UNC  |  MC   |  IDNF |  MCR  | ABRT  | TK0NF |  AMNF |
     +-------+-------+-------+-------+-------+-------+-------+-------+

 - BBK (Bad Block Detected) indicates a bad block mark was detected in the 
   requested sector's ID field. 
 - UNC (Uncorrectable Data Error) indicates an uncorrectable data error has 
   been encountered. 
 - MC (Media Changed) indicates that the removable media has been changed i.e. 
   there has been a change in the ability to access the media.
 - IDNF (ID Not Found) indicates the requested sector's ID field could not be 
   found. 
 - ABRT (Aborted Command) indicates the requested command has been aborted due 
   to a drive status error (Not Ready, Write Fault, etc.) or because the 
   command code is invalid. 
 - MCR (Media Change Requested) indicates that the release latch on a 
   removable media drive has been pressed. This means that the user wishes to 
   remove the media and requires an action of some kind e.g. have software 
   issue a Media Eject or Door Unlock command. 
 - TK0NF (Track 0 Not Found) indicates track 0 has not been found during a 
   Recalibrate command. 
 - AMNF (Address Mark Not Found) indicates the data address mark has not been 
   found after finding the correct ID field. 
*/


/*
7.2.10  Features Register

This register is command specific and may be used to enable and disable 
features of the interface e.g. by the Set Features Command to enable and 
disable cacheing. 

This register may be ignored by some drives. 

Some hosts, based on definitions prior to the completion of this standard, set 
values in this register to designate a recommended Write Precompensation 
Cylinder value. 
*/


/*
7.2.11  Sector Count Register

This register contains the number of sectors of data requested to be 
transferred on a read or write operation between the host and the drive. If 
the value in this register is zero, a count of 256 sectors is specified. 

If this register is zero at command completion, the command was successful. If 
not successfully completed, the register contains the number of sectors which 
need to be transferred in order to complete the request.

The contents of this register may be defined otherwise on some commands e.g. 
Initialize Drive Parameters, Format Track or Write Same commands. 
*/


/*
7.2.12  Sector Number Register

This register contains the starting sector number for any disk data access for 
the subsequent command. The sector number may be from 1 to the maximum number 
of sectors per track. 

In LBA Mode this register contains Bits 0-7. At the end of the command, this 
register is updated to reflect the current LBA Bits 0-7.

See the command descriptions for contents of the register at command 
completion (whether successful or unsuccessful).
*/


/*
7.2.13  Status Register

This register contains the drive status. The contents of this register are 
updated at the completion of each command. When BSY is cleared, the other bits 
in this register shall be valid within 400 nsec. If BSY=1, no other bits in 
this register are valid. If the host reads this register when an interrupt is 
pending, it is considered to be the interrupt acknowledge. Any pending 
interrupt is cleared whenever this register is read. 

  NOTE: If Drive 1 is not detected as being present, Drive 0 clears the Drive 
        1 Status Register to 00h (indicating that the drive is Not Ready).

         7       6       5       4       3       2       1       0 
     +-------+-------+-------+-------+-------+-------+-------+-------+
     |  BSY  | DRDY  |  DWF  |  DSC  |  DRQ  | CORR  |  IDX  |  ERR  | 
     +-------+-------+-------+-------+-------+-------+-------+-------+

  NOTE: Prior to the definition of this standard, DRDY and DSC were unlatched 
        real time signals. 

 - BSY (Busy) is set whenever the drive has access to the Command Block 
   Registers. The host should not access the Command Block Register when 
   BSY=1. When BSY=1, a read of any Command Block Register shall return the 
   contents of the Status Register. This bit is set by the drive (which may be 
   able to respond at times when the media cannot be accessed) under the 
   following circumstances: 
   a) within 400 nsec after the negation of RESET- or after SRST has been set 
      in the Device Control Register. Following acceptance of a reset it is 
      recommended that BSY be set for no longer than 30 seconds by Drive 1 and 
      no longer than 31 seconds by Drive 0.
   b) within 400 nsec of a host write of the Command Register with a Read, 
      Read Long, Read Buffer, Seek, Recalibrate, Initialize Drive Parameters, 
      Read Verify, Identify Drive, or Execute Drive Diagnostic command. 
   c) within 5 usecs following transfer of 512 bytes of data during execution 
      of a Write, Format Track, or Write Buffer command, or 512 bytes of data 
      and the appropriate number of ECC bytes during the execution of a Write 
      Long command. 
 - DRDY (Drive Ready) indicates that the drive is capable of responding to a 
   command. When there is an error, this bit is not changed until the Status 
   Register is read by the host, at which time the bit again indicates the 
   current readiness of the drive. This bit shall be cleared at power on and 
   remain cleared until the drive is ready to accept a command. 
 - DWF (Drive Write Fault) indicates the current write fault status. When an 
   error occurs, this bit shall not be changed until the Status Register is 
   read by the host, at which time the bit again indicates the current write 
   fault status. 
 - DSC (Drive Seek Complete) indicates that the drive heads are settled over a 
   track. When an error occurs, this bit shall not be changed until the Status 
   Register is read by the host, at which time the bit again indicates the 
   current Seek Complete status. 
 - DRQ (Data Request) indicates that the drive is ready to transfer a word or 
   byte of data between the host and the drive.
 - CORR (Corrected Data) indicates that a correctable data error was 
   encountered and the data has been corrected. This condition does not 
   terminate a data transfer. 
 - IDX (Index) is set once per disk revolution. 
 - ERR (Error) indicates that an error occurred during execution of the 
   previous command. The bits in the Error Register have additional 
   information regarding the cause of the error. 
*/


/*
            TABLE 9-1:  COMMAND CODES AND PARAMETERS - Part 1 of 2
                                               +-------+-------------------+
  +-----+                                      |Command|  Parameters Used  |
  |Class|                                      | Code  |FR  SC  SN  CY  DH |
  +-----+----------------------------------+---+-------+---+---+---+---+---+
  |  1  | Acknowledge Media Chge           | O |  DBh  |   |   |   |   | D |
  |  1  | Boot - Post-Boot                 | O |  DCh  |   |   |   |   | D |
  |  1  | Boot - Pre-Boot                  | O |  DDh  |   |   |   |   | D |
  |  1  | Check Power Mode                 | O |98h E5h|   | y |   |   | D |
  |  1  | Door Lock                        | O |  DEh  |   |   |   |   | D |
  |  1  | Door Unlock                      | O |  DFh  |   |   |   |   | D |
  |  1  | Execute Drive Diagnostic         | M |  90h  |   |   |   |   | D*|
  |  2  | Format Track                     | M |  50h  | * | y |   | y | y |
  |  1  | Identify Drive                   | O |  ECh  |   |   |   |   | D |
  |  1  | Idle                             | O |97h E3h|   | y |   |   | D |
  |  1  | Idle Immediate                   | O |95h E1h|   |   |   |   | D |
  |  1  | Initialize Drive Parameters      | M |  91h  |   | y |   |   | y |
  |  1  | NOP                              | O |  00h  |   |   |   |   | y |
  |  1  | Read Buffer                      | O |  E4h  |   |   |   |   | D |
  |  1  | Read DMA (w/retry)               | O |  C8h  |   | y | y | y | y |
  |  1  | Read DMA (w/o retry)             | O |  C9h  |   | y | y | y | y |
  |  1  | Read Long (w/retry)              | M |  22   |   | y | y | y | y |
  |  1  | Read Long (w/o retry)            | M |  23   |   | y | y | y | y |
  |  1  | Read Multiple                    | O |  C4h  |   | y | y | y | y |
  |  1  | Read Sector(s) (w/retry)         | M |  20   |   | y | y | y | y |
  |  1  | Read Sector(s) (w/o retry)       | M |  21   |   | y | y | y | y |
  |  1  | Read Verify Sector(s) (w/retry)  | M |  40   |   | y | y | y | y |
  |  1  | Read Verify Sector(s) (w/o retry)| M |  41   |   | y | y | y | y |
  |  1  | Recalibrate                      | M |  1xh  |   |   |   |   | D |
  +-----+----------------------------------+---+-------+---+---+---+---+---+
            TABLE 9-1:  COMMAND CODES AND PARAMETERS - Part 2 of 2
                                               +-------+-------------------+
  +-----+                                      |Command|  Parameters Used  |
  |Class|                                      | Code  |FR  SC  SN  CY  DH |
  +-----+----------------------------------+---+-------+---+---+---+---+---+
  |  1  | Seek                             | M |  7xh  |   |   | y | y | y |
  |  1  | Set Features                     | O |  EFh  | y |   |   |   | D |
  |  1  | Set Multiple Mode                | O |  C6h  |   | y |   |   | D |
  |  1  | Sleep                            | O |99h E6h|   |   |   |   | D |
  |  1  | Standby                          | O |96h E2h|   | y |   |   | D |
  |  1  | Standby Immediate                | O |94h E0h|   |   |   |   | D |
  |  2  | Write Buffer                     | O |  E8h  |   |   |   |   | D |
  |  3  | Write DMA (w/retry)              | O |  CAh  |   | y | y | y | y |
  |  3  | Write DMA (w/o retry)            | O |  CBh  |   | y | y | y | y |
  |  2  | Write Long (w/retry)             | M |  32   | * | y | y | y | y |
  |  2  | Write Long (w/o retry)           | M |  33   | * | y | y | y | y |
  |  3  | Write Multiple                   | O |  C5h  | * | y | y | y | y |
  |  3  | Write Same                       | O |  E9h  | y | y | y | y | y |
  |  2  | Write Sector(s) (w/retry)        | M |  30   | * | y | y | y | y |
  |  2  | Write Sector(s) (w/o retry)      | M |  31   | * | y | y | y | y |
  |  3  | Write Verify                     | O |  3Ch  | * | y | y | y | y |
  |     | Vendor Unique                    | V |  9Ah  |   |   |   |   |   |
  |     | Vendor Unique                    | V | C0-C3h|   |   |   |   |   |
  |     | Vendor Unique                    | V |  8xh  |   |   |   |   |   |
  |     | Vendor Unique                    | V |F0h-FFh|   |   |   |   |   |
  |     | Reserved: All remaining codes    |   |       |   |   |   |   |   |
  +-----+----------------------------------+---+-------+---+---+---+---+---+
  |     | CY = Cylinder Registers         SC = Sector Count Register       |
  |     | DH = Drive/Head Register        SN = Sector Number Register      |
  |     | FR = Features Register (see command descriptions for use)        |
  |     | y - the register contains a valid parameter for this command.    |
  |     |     For the Drive/Head Register, y means both the drive and      |
  |     |     head parameters are used.                                    |
  |     | D - only the drive parameter is valid and not the head parameter.|
  |     | D* - Addressed to Drive 0 but both drives execute it.            |
  |     | * - Maintained for compatibility (see 7.2.9)                     |
  +-----+------------------------------------------------------------------+
*/
#define IDE_Acknowledge_Media_Change    0xDB
#define IDE_Boot_Post_Boot              0xDC
#define IDE_Boot_Pre_Boot               0xDD
#define IDE_Check_Power_Mode            0x98E5
#define IDE_Door_Lock                   0xDE
#define IDE_Door_Unlock                 0xDF
#define IDE_Execute_Drive_Diagnostic    0x90
#define IDE_Format_Track                0x50
#define IDE_Identify_Drive              0xEC
#define IDE_Idle                        0x97E3
#define IDE_Idle_Immediate              0x95E1
#define IDE_Initialize_Drive_parameters 0x91
#define IDE_NOP                         0x00
#define IDE_Read_Buffer                 0xE4
#define IDE_Read_DMA                    0xC8
#define IDE_Read_DMA_o                  0xC9
#define IDE_Read_Long                   0x22
#define IDE_Read_Long_o                 0x23
#define IDE_Read_Multiple               0xC4
#define IDE_Read_Sectors                0x20
#define IDE_Read_Sectors_o              0x21
#define IDE_Read_Verify_Sectors         0x40
#define IDE_Read_Verify_Sectors_o       0x41
#define IDE_Recalibrate                 0x10
#define IDE_Seek                        0x70
#define IDE_Set_Features                0xEF
#define IDE_Set_Multiple_Mode           0x96
#define IDE_Sleep                       0x99E6
#define IDE_Standby                     0x96E2
#define IDE_Standby_Immediate           0x94E0
#define IDE_Write_Buffer                0xE8
#define IDE_Write_DMA                   0xCA
#define IDE_Write_DMA_o                 0xCB
#define IDE_Write_Long                  0x32
#define IDE_Write_Long_o                0x33
#define IDE_Write_Multiple              0xC5
#define IDE_Write_Same                  0xE9
#define IDE_Write_Sectors               0x30
#define IDE_Write_Sectors_o             0x31
#define IDE_Write_Verify                0x3C

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -