This commit is contained in:
Anatoliy Belyanskiy 2023-08-21 00:37:36 +10:00
parent 64c3057bce
commit 2facbb273e
2 changed files with 210 additions and 89 deletions

View File

@ -1,63 +1,127 @@
;Table 9 - Command codes and parameters
;|-------|-----------------------------------|------|---------|-------------------------
;| | | | | Parameters used |
;| | | | Command |-------------------------
;| Class | Command name | type | code | FR | SC | SN | CY | DH |
;|-------| ----------------------------------|------|---------|----|----|----|--- |----|
;| 1 | Acknowledge media change | O | #DB | | | | | D |
;| 1 | Boot - post-boot | O | #DC | | | | | D |
;| 1 | Boot - pre-boot | O | #DD | | | | | D |
;| 1 | Check power mode | O | #98 #E5 | | y | | | D |
;| 1 | Door lock | O | #DE | | | | | D |
;| 1 | Door unlock | O | #DF | | | | | D |
;| 1 | Execute drive diagnostic | M | #90 | | | | | D* |
;| 2 | Format track | M | #50 | * | y | | y | y |
;| 1 | Identify drive | O | #EC | | | | | D |
;| 1 | Idle | O | #97 #E3 | | y | | | D |
;| 1 | Idle immediate | O | #95 #E1 | | | | | D |
;| 1 | Initialize drive parameters | M | #91 | | y | | | y |
;| 1 | NOP | O | #00 | | | | | y |
;| 1 | Read buffer | O | #E4 | | | | | D |
;| 1 | Read DMA (w/retry) | O | #C8 | | y | y | y | y |
;| 1 | Read DMA (w/o retry) | O | #C9 | | 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 | #C4 | | 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 | #1x | | | | | D |
;| 1 | Seek | M | #7x | | | y | y | y |
;| 1 | Set features | O | #EF | y | | | | D |
;| 1 | Set multiple mode | O | #C6 | | y | | | D |
;| 1 | Sleep | O | #99 #E6 | | | | | D |
;| 1 | Standby | O | #96 #E2 | | y | | | D |
;| 1 | Standby immediate | O | #94 #E0 | | | | | D |
;| 2 | Write buffer | O | #E8 | | | | | D |
;| 3 | Write DMA (w/retry) | O | #CA | | y | y | y | y |
;| 3 | Write DMA (w/o retry) | O | #CB | | 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 | #C5 | * | y | y | y | y |
;| 3 | Write same | O | #E9 | 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 | #3C | * | y | y | y | y |
;| | Vendor unique | V | #9A | | | | | |
;| | Vendor unique | V | #C0-#C3 | | | | | |
;| | Vendor unique | V | #8x | | | | | |
;| | Vendor unique | V | #F0-#FF | | | | | |
;| | 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.10)
;
; The drive shall implement all mandatory commands as identified by an M, and may
; implement the optional commands identified by an O. V - a Vendor Specific command code.
; ATA-2 commands ************************ ; ATA-2 commands ************************
ATA_EXECUTE_DEVICE_DIAGNOSTIC equ 0x90 ATA_EXECUTE_DEVICE_DIAGNOSTIC EQU #90
ATA_IDENTIFY_DEVICE equ 0xec ATA_IDENTIFY_DEVICE EQU #EC
ATA_INITIALIZE_DEVICE_PARAMETERS equ 0x91 ATA_INITIALIZE_DEVICE_PARAMETERS EQU #91
ATA_READ_SECTORS equ 0x20 ; WITH RETRY ATA_READ_SECTORS EQU #20 ; WITH RETRY
ATA_READ_VERIFY_SECTORS equ 0x40 ; WITH RETRY ATA_READ_VERIFY_SECTORS EQU #40 ; WITH RETRY
; equ 0x70-0x7f ; EQU #70-#7f
ATA_SEEK equ 0x70 ATA_SEEK EQU #70
ATA_WRITE_SECTORS equ 0x30 ; WITH RETRY ATA_WRITE_SECTORS EQU #30 ; WITH RETRY
; ****** additional commands ************ ; ****** additional commands ************
ATA_ACKNOWLEDGE_MEDIA_CHANGE equ 0xdb ATA_ACKNOWLEDGE_MEDIA_CHANGE EQU #db
ATA_POST_BOOT equ 0xdc ATA_POST_BOOT EQU #dc
ATA_PRE_BOOR equ 0xdd ATA_PRE_BOOT EQU #dd
ATA_CHECK_POWER_MODE equ 0x98 ATA_CHECK_POWER_MODE EQU #98
ATA_CHECK_POWER_MODE2 equ 0xe5 ATA_CHECK_POWER_MODE2 EQU #e5
ATA_DOOR_LOCK equ 0xde ATA_DOOR_LOCK EQU #de
ATA_DOOR_UNLOCK equ 0xdf ATA_DOOR_UNLOCK EQU #df
ATA_DOWNLOAD_MICROCODE equ 0x92 ATA_DOWNLOAD_MICROCODE EQU #92
ATA_IDLE equ 0x97 ATA_IDLE EQU #97
ATA_IDLE2 equ 0xe3 ATA_IDLE2 EQU #e3
ATA_IDLE_IMMENDIATE equ 0x95 ATA_IDLE_IMMEDIATE EQU #95
ATA_IDLE_IMMENDIATE2 equ 0xe1 ATA_IDLE_IMMEDIATE2 EQU #e1
ATA_MEDIA_EJECT equ 0xed ATA_MEDIA_EJECT EQU #ed
ATA_NOP equ 0x00 ATA_NOP EQU #00
ATA_READ_BUFFER equ 0xe4 ATA_READ_BUFFER EQU #e4
ATA_READ_DMA equ 0xc8 ATA_READ_DMA EQU #c8
ATA_READ_LONG equ 0x22 ATA_READ_LONG EQU #22
ATA_READ_MULTIPLE equ 0xc4 ATA_READ_MULTIPLE EQU #c4
; equ 0x10-0x1f ; EQU #10-#1f
ATA_RECALIBRATE equ 0x10 ATA_RECALIBRATE EQU #10
ATA_SET_FEATURES equ 0xef ATA_SET_FEATURES EQU #ef
ATA_SET_MULTIPLE_MODE equ 0xc6 ATA_SET_MULTIPLE_MODE EQU #c6
ATA_SLEEP equ 0x99 ATA_SLEEP EQU #99
ATA_SLEEP2 equ 0xe6 ATA_SLEEP2 EQU #e6
ATA_STANDBY equ 0x96 ATA_STANDBY EQU #96
ATA_STANDBY2 equ 0xe2 ATA_STANDBY2 EQU #e2
ATA_STANDBY_IMMENDIATE equ 0x94 ATA_STANDBY_IMMEDIATE EQU #94
ATA_STANDBY2_IMMENDIATE equ 0xe0 ATA_STANDBY2_IMMEDIATE EQU #e0
ATA_WRITE_BUFFER equ 0xe8 ATA_WRITE_BUFFER EQU #e8
ATA_WRITE_DMA equ 0xca ATA_WRITE_DMA EQU #ca
ATA_WRITE_LONG equ 0x32 ATA_WRITE_LONG EQU #32
ATA_WRITE_MULTIPLE equ 0xc5 ATA_WRITE_MULTIPLY EQU #c5
ATA_WRITE_SAME equ 0xe9 ATA_WRITE_SAME EQU #e9
ATA_WRITE_VERIFY equ 0x3c ATA_WRITE_VERIFY EQU #3c
; **** device specific commands ************* ; **** device specific commands *************
; TODO remap command ; !TODO remap command
ATA_FORMAT_TRACK equ 0x50 ATA_FORMAT_TRACK EQU #50
; command modificators ; command modificators
; for ATA_READ_SECTORS, ATA_WRITE_SECTORS, ATA_VERIFY_SECTORS, ; for ATA_READ_SECTORS, ATA_WRITE_SECTORS, ATA_VERIFY_SECTORS,
; ATA_READ_DMA, ATA_WRITE_DMA, ATA_READ_LONG, ATA_WRITE_LONG ; ATA_READ_DMA, ATA_WRITE_DMA, ATA_READ_LONG, ATA_WRITE_LONG
ATA_WITHOUT_RETRY equ 0x01 ATA_WITHOUT_RETRY EQU #01
@ -66,51 +130,51 @@ ATA_WITHOUT_RETRY equ 0x01
; command registers ; command registers
ATA_DATA_REG equ 0 ; ATA_DATA_REG EQU 0
ATA_ERROR_REG equ 1 ; ATA_ERROR_REG EQU 1
ATA_FEATURES_REG equ 1 ; ATA_FEATURES_REG EQU 1
ATA_SECTOR_COUNT equ 2 ; ATA_SECTOR_COUNT EQU 2
ATA_SECTOR_NUMBER equ 3 ; ATA_SECTOR_NUMBER EQU 3
ATA_CYLINDER_LOW equ 4 ; ATA_CYLINDER_LOW EQU 4
ATA_CYLINDER_HIGH equ 5 ; ATA_CYLINDER_HIGH EQU 5
ATA_DEVICE_HEAD equ 6 ; ATA_DEVICE_HEAD EQU 6
ATA_STATUS equ 7 ; ATA_STATUS EQU 7
ATA_COMMAND equ 7 ; ATA_COMMAND EQU 7
; control registers ; control registers
ATA_ALTERNATE_STATUS equ 0x16 ; ATA_ALTERNATE_STATUS EQU #16
ATA_DEVICE_CONTROL equ 0x16 ; ATA_DEVICE_CONTROL EQU #16
ATA_DRIVE_ADDRESS equ 0x17 ; ATA_DRIVE_ADDRESS EQU #17
; status register bits ; status register bits
ATA_BUSY equ 0x80 ; ATA_BUSY EQU #80
ATA_READY equ 0x40 ; ATA_READY EQU #40
ATA_FAULT equ 0x20 ; ATA_FAULT EQU #20
ATA_SEEK_COMPLETE equ 0x10 ; ATA_SEEK_COMPLETE EQU #10
ATA_DATA_REQUEST equ 0x08 ; ATA_DATA_REQUEST EQU #08
ATA_CORRECTED_DATA equ 0x04 ; ATA_CORRECTED_DATA EQU #04
ATA_INDEX equ 0x02 ; ATA_INDEX EQU #02
ATA_ERROR equ 0x01 ; ATA_ERROR EQU #01
; device/head register bits ; device/head register bits
ATA_LBA equ 0x40 ; ATA_LBA EQU #40
ATA_DEVICE equ 0x10 ; ATA_DEVICE EQU #10
; device control register bits ; device control register bits
ATA_SOFT_RESET equ 0x04 ; ATA_SOFT_RESET EQU #04
ATA_INTERRUPT_DISABLE equ 0x02 ; ATA_INTERRUPT_DISABLE EQU #02
; error register bits ; error register bits
ATA_UNCORRECTABLE equ 0x40 ; ATA_UNCORRECTABLE EQU #40
ATA_MEDIA_CHANGED equ 0x20 ; ATA_MEDIA_CHANGED EQU #20
ATA_ID_NOT_FOUND equ 0x10 ; ATA_ID_NOT_FOUND EQU #10
ATA_ABORTED equ 0x08 ; ATA_ABORTED EQU #08
ATA_MEDIA_CHANGE_REQUESTED equ 0x04 ; ATA_MEDIA_CHANGE_REQUESTED EQU #04
ATA_TRACK_0_NOT_FOUND equ 0x02 ; ATA_TRACK_0_NOT_FOUND EQU #02
ATA_ADDERSS_MARK_NOT_FOUND equ 0x01 ; ATA_ADDERSS_MARK_NOT_FOUND EQU #01
; ;

View File

@ -1646,14 +1646,14 @@ Read:
ControlBit: ; 0000 0000 ; Bits for HardDrive.Read.Status ControlBit: ; 0000 0000 ; Bits for HardDrive.Read.Status
.Busy EQU 7;ÄÄÄÄÄÄÄÄÙ³³³ ³³³³ ; BSY .Busy EQU 7;ÄÄÄÄÄÄÄÄÙ³³³ ³³³³ ; BSY
.Ready EQU 6;ÄÄÄÄÄÄÄÄÄÙ³³ ³³³³ ; RDY .Ready EQU 6;ÄÄÄÄÄÄÄÄÄÙ³³ ³³³³ ; RDY
.Fault EQU 5;ÄÄÄÄÄÄÄÄÄÄ´³ ³³³³ .Fault EQU 5;ÄÄÄÄÄÄÄÄÄÄÙ³ ³³³³
.StreamErrror EQU .Fault;ÄÄÄÄÄÙ³ ³³³³ .SeekComplete EQU 4;ÄÄÄÄÄÄÄÄÄÄÄÙ ³³³³ .DeferredWriteError
.DeferredWriteError EQU 4;ÄÄÄÄÄÄÄÄÄÄÄÙ ³³³³
.DataRequest EQU 3;ÄÄÄÄÄÄÄÄÄÄÄÄÄÙ³³³ ; DRQ .DataRequest EQU 3;ÄÄÄÄÄÄÄÄÄÄÄÄÄÙ³³³ ; DRQ
.AlignmentError EQU 2;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ³³ .CorrectedData EQU 2;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ³³
.SenseDataAvailable EQU 1;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ³ .Index EQU 1;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ³ .SenseDataAvailable
.Error EQU 0;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ; Indicates an error occurred. Send a new command to clear it (or nuke it with a Software Reset). .Error EQU 0;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ; Indicates an error occurred. Send a new command to clear it (or nuke it with a Software Reset).
.CheckCondition EQU .Error; .CheckCondition EQU .Error;
.StreamError EQU .Fault;
/* /*
Bit Abbreviation Function Bit Abbreviation Function
0 ERR Indicates an error occurred. Send a new command to clear it (or nuke it with a Software Reset). 0 ERR Indicates an error occurred. Send a new command to clear it (or nuke it with a Software Reset).
@ -1676,11 +1676,68 @@ Device:
.CDROM EQU 2 .CDROM EQU 2
.NONE EQU #FF .NONE EQU #FF
ATA Drive:
.Master EQU #A0 .Master EQU #A0
.Slave EQU #B0 .Slave EQU #B0
ATA:
; ATA-2 commands ************************
.ExecuteDeviceDiagnostic EQU #90
.IdentifyDevice EQU #EC
.InitializeDeviceParameters EQU #91
.ReadSectorsWithRetry EQU #20
.ReadSectors EQU #21
.ReadVerifySectorsWithRetry EQU #40
.ReadVerifySectors EQU #41
.Seek EQU #70
.WriteSectorsWithRetry EQU #30
.WriteSectors EQU #31
; ****** additional commands ************
.AcknowledgeMediaChange EQU #db
.PostBoot EQU #dc
.PreBoot EQU #dd
.CheckPowerMode EQU #98
.CheckPowerMode2 EQU #e5
.DoorLock EQU #de
.DoorUnlock EQU #df
.DownloadMicrocode EQU #92
.Idle EQU #97
.Idle2 EQU #e3
.IdleImmediate EQU #95
.IdleImmediate2 EQU #e1
.MediaEject EQU #ed
.Nop EQU #00
.ReadBuffer EQU #e4
.ReadDMA EQU #c8
.ReadLong EQU #22
.ReadMultiple EQU #c4
.Recalibrate EQU #10
.SetFeatures EQU #ef
.SetMultipleMode EQU #c6
.Sleep EQU #99
.Sleep2 EQU #e6
.Standby EQU #96
.Standby2 EQU #e2
.StandbyImmediate EQU #94
.Standby2Immediate EQU #e0
.WriteBuffer EQU #e8
.WriteDMA EQU #ca
.WriteLong EQU #32
.WriteMultiple EQU #c5
.WriteSame EQU #e9
.WriteVerify EQU #3c
; **** device specific commands *************
.FormatTrack EQU #50
; command modificators:
; for ReadSectors, WriteSectors, ReadVerifySectors,
; ReadDMA, WriteDMA, ReadLong, WriteLong
.WithoutRetry EQU #01
; ATA
; .Master EQU #A0
; .Slave EQU #B0
ENDMODULE ENDMODULE
;-----------------------------------------------------------------------
;-----------------------------------------------------------------------;
; ;
/* /*