Changeset 238 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Device/IDE
- Timestamp:
- Feb 5, 2012, 12:59:20 PM (13 years ago)
- google:author:
- aitotat@gmail.com
- Location:
- trunk/XTIDE_Universal_BIOS/Src/Device/IDE
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm
r218 r238 15 15 ; AL, BX, CX, DX 16 16 ;-------------------------------------------------------------------- 17 I deCommand_ResetMasterAndSlaveController:17 IDEDEVICE%+Command_ResetMasterAndSlaveController: 18 18 ; HSR0: Set_SRST 19 19 call AccessDPT_GetDeviceControlByteToAL 20 20 or al, FLG_DEVCONTROL_SRST | FLG_DEVCONTROL_nIEN ; Set Reset bit 21 mov dl, DEVICE_CONTROL_REGISTER_out 22 call IdeIO_OutputALtoIdeControlBlockRegisterInDL 21 OUTPUT_AL_TO_IDE_CONTROL_BLOCK_REGISTER DEVICE_CONTROL_REGISTER_out 23 22 mov ax, HSR0_RESET_WAIT_US 24 23 call Timer_DelayMicrosecondsFromAX … … 28 27 or al, FLG_DEVCONTROL_nIEN 29 28 and al, ~FLG_DEVCONTROL_SRST ; Clear reset bit 30 mov dl, DEVICE_CONTROL_REGISTER_out 31 call IdeIO_OutputALtoIdeControlBlockRegisterInDL 29 OUTPUT_AL_TO_IDE_CONTROL_BLOCK_REGISTER DEVICE_CONTROL_REGISTER_out 32 30 mov ax, HSR1_RESET_WAIT_US 33 31 call Timer_DelayMicrosecondsFromAX … … 35 33 ; HSR2: Check_status 36 34 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_MOTOR_STARTUP, FLG_STATUS_BSY) 37 jmp I deWait_PollStatusFlagInBLwithTimeoutInBH35 jmp IDEDEVICE%+Wait_PollStatusFlagInBLwithTimeoutInBH 38 36 39 37 … … 51 49 ; AL, BL, CX, DX, SI, DI, ES 52 50 ;-------------------------------------------------------------------- 53 I deCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH:51 IDEDEVICE%+Command_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH: 54 52 ; Create fake DPT to be able to use Device.asm functions 55 53 call FindDPT_ForNewDriveToDSDI … … 66 64 jnz SHORT .SkipLongWaitSinceDriveIsNotPrimaryMaster 67 65 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_MOTOR_STARTUP, FLG_STATUS_BSY) 68 call I deWait_PollStatusFlagInBLwithTimeoutInBH66 call IDEDEVICE%+Wait_PollStatusFlagInBLwithTimeoutInBH 69 67 .SkipLongWaitSinceDriveIsNotPrimaryMaster: 70 68 … … 100 98 ;-------------------------------------------------------------------- 101 99 ALIGN JUMP_ALIGN 102 I deCommand_OutputWithParameters:100 IDEDEVICE%+Command_OutputWithParameters: 103 101 push bx ; Store status register bits to poll 104 102 105 103 ; Select Master or Slave drive and output head number or LBA28 top bits 106 call I deCommand_SelectDrive104 call IDEDEVICE%+Command_SelectDrive 107 105 jc SHORT .DriveNotReady 108 106 … … 119 117 pop ds 120 118 .DoNotSetInterruptInServiceFlag: 121 mov dl, DEVICE_CONTROL_REGISTER_out 122 call IdeIO_OutputALtoIdeControlBlockRegisterInDL 119 OUTPUT_AL_TO_IDE_CONTROL_BLOCK_REGISTER DEVICE_CONTROL_REGISTER_out 123 120 124 121 ; Output Feature Number 125 mov dl, FEATURES_REGISTER_out126 122 mov al, [bp+IDEPACK.bFeatures] 127 call IdeIO_OutputALtoIdeRegisterInDL123 OUTPUT_AL_TO_IDE_REGISTER FEATURES_REGISTER_out 128 124 129 125 ; Output Sector Address High (only used by LBA48) … … 138 134 139 135 ; Output command 140 mov dl, COMMAND_REGISTER_out141 136 mov al, [bp+IDEPACK.bCommand] 142 call IdeIO_OutputALtoIdeRegisterInDL137 OUTPUT_AL_TO_IDE_REGISTER COMMAND_REGISTER_out 143 138 144 139 ; Wait until command completed 145 140 pop bx ; Pop status and timeout for polling 146 141 cmp bl, FLG_STATUS_DRQ ; Data transfer started? 147 je SHORT I deTransfer_StartWithCommandInAL142 je SHORT IDEDEVICE%+Transfer_StartWithCommandInAL 148 143 test BYTE [bp+IDEPACK.bDeviceControl], FLG_DEVCONTROL_nIEN 149 144 jz SHORT .WaitForIrqOrRdy 150 jmp I deWait_PollStatusFlagInBLwithTimeoutInBH145 jmp IDEDEVICE%+Wait_PollStatusFlagInBLwithTimeoutInBH 151 146 152 147 ALIGN JUMP_ALIGN 153 148 .WaitForIrqOrRdy: 154 jmp I deWait_IRQorStatusFlagInBLwithTimeoutInBH149 jmp IDEDEVICE%+Wait_IRQorStatusFlagInBLwithTimeoutInBH 155 150 156 151 .DriveNotReady: 157 152 pop bx ; Clean stack 158 ReturnSinceTimeoutWhenPollingBusy:153 IDEDEVICE%+ReturnSinceTimeoutWhenPollingBusy: 159 154 ret 160 155 … … 172 167 ;-------------------------------------------------------------------- 173 168 ALIGN JUMP_ALIGN 174 I deCommand_SelectDrive:169 IDEDEVICE%+Command_SelectDrive: 175 170 ; Wait until neither Master or Slave Drive is busy 176 171 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_BSY, FLG_STATUS_BSY) 177 172 cmp BYTE [bp+IDEPACK.bCommand], COMMAND_IDENTIFY_DEVICE 178 173 eCMOVE bh, TIMEOUT_IDENTIFY_DEVICE 179 call I deWait_PollStatusFlagInBLwithTimeoutInBH180 jc SHORT ReturnSinceTimeoutWhenPollingBusy174 call IDEDEVICE%+Wait_PollStatusFlagInBLwithTimeoutInBH 175 jc SHORT IDEDEVICE%+ReturnSinceTimeoutWhenPollingBusy 181 176 182 177 ; Select Master or Slave Drive 183 mov dl, DRIVE_AND_HEAD_SELECT_REGISTER184 178 mov al, [bp+IDEPACK.bDrvAndHead] 185 call IdeIO_OutputALtoIdeRegisterInDL179 OUTPUT_AL_TO_IDE_REGISTER DRIVE_AND_HEAD_SELECT_REGISTER 186 180 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRDY, FLG_STATUS_DRDY) 187 181 cmp BYTE [bp+IDEPACK.bCommand], COMMAND_IDENTIFY_DEVICE 188 182 eCMOVE bh, TIMEOUT_IDENTIFY_DEVICE 189 jmp I deWait_PollStatusFlagInBLwithTimeoutInBH183 jmp IDEDEVICE%+Wait_PollStatusFlagInBLwithTimeoutInBH 190 184 191 185 … … 203 197 ; AL, BX, DX 204 198 ;-------------------------------------------------------------------- 199 %ifdef ASSEMBLE_SHARED_IDE_DEVICE_FUNCTIONS 205 200 ALIGN JUMP_ALIGN 206 201 OutputSectorCountAndAddress: 207 mov dl, SECTOR_COUNT_REGISTER 208 call IdeIO_OutputALtoIdeRegisterInDL 202 OUTPUT_AL_TO_IDE_REGISTER SECTOR_COUNT_REGISTER 209 203 210 204 mov al, ah 211 mov dl, LBA_LOW_REGISTER 212 call IdeIO_OutputALtoIdeRegisterInDL 205 OUTPUT_AL_TO_IDE_REGISTER LBA_LOW_REGISTER 213 206 214 207 mov al, cl 215 mov dl, LBA_MIDDLE_REGISTER 216 call IdeIO_OutputALtoIdeRegisterInDL 208 OUTPUT_AL_TO_IDE_REGISTER LBA_MIDDLE_REGISTER 217 209 218 210 mov al, ch 219 mov dl,LBA_HIGH_REGISTER220 jmp IdeIO_OutputALtoIdeRegisterInDL 211 JUMP_TO_OUTPUT_AL_TO_IDE_REGISTER LBA_HIGH_REGISTER 212 %endif -
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeError.asm
r160 r238 18 18 ;-------------------------------------------------------------------- 19 19 ALIGN JUMP_ALIGN 20 I deError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL:20 IDEDEVICE%+Error_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL: 21 21 mov ah, al ; IDE Status Register to AH 22 mov dl, ERROR_REGISTER_in 23 call IdeIO_InputToALfromIdeRegisterInDL 22 INPUT_TO_AL_FROM_IDE_REGISTER ERROR_REGISTER_in 24 23 xchg al, ah ; Status Register now in AL, Error Register now in AH 25 24 … … 45 44 ; BX 46 45 ;-------------------------------------------------------------------- 46 %ifdef ASSEMBLE_SHARED_IDE_DEVICE_FUNCTIONS 47 47 ALIGN JUMP_ALIGN 48 48 GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX: … … 92 92 db RET_HD_BADSECTOR ; Bit7=BBK, Bad Block Detected 93 93 db RET_HD_STATUSERR ; When Error Register is zero 94 %endif -
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeIrq.asm
r233 r238 111 111 mov bl, FLGH_DPT_INTERRUPT_IN_SERVICE 112 112 call FindDPT_ToDSDIforFlagsHighInBL 113 mov dl, STATUS_REGISTER_in 114 call IdeIO_InputToALfromIdeRegisterInDL 113 INPUT_TO_AL_FROM_IDE_REGISTER STATUS_REGISTER_in 115 114 116 115 ; Clear Interrupt In-Service Flag from DPT -
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm
r223 r238 97 97 .WriteLastBlockToDrive: 98 98 mov cx, [bp+PIOVARS.wWordsLeft] 99 %ifdef USE_186 100 push CheckErrorsAfterTransferringLastBlock 101 jmp [bp+PIOVARS.fnXfer] ; Transfer possibly partial block 102 %else 99 103 call [bp+PIOVARS.fnXfer] ; Transfer possibly partial block 100 101 ; Check for errors in last block 102 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRDY) 103 call IdeWait_PollStatusFlagInBLwithTimeoutInBH 104 jmp SHORT ReturnWithTransferErrorInAH 104 jmp SHORT CheckErrorsAfterTransferringLastBlock 105 %endif 105 106 106 107 … … 155 156 ; Check for errors in last block 156 157 mov di, si ; DS:DI now points DPT 158 CheckErrorsAfterTransferringLastBlock: 157 159 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRDY) 158 160 call IdeWait_PollStatusFlagInBLwithTimeoutInBH -
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeWait.asm
r160 r238 16 16 ; AL, BX, CX, DX 17 17 ;-------------------------------------------------------------------- 18 I deWait_IRQorDRQ:18 IDEDEVICE%+Wait_IRQorDRQ: 19 19 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRQ) 20 %ifdef ASSEMBLE_SHARED_IDE_DEVICE_FUNCTIONS ; JR-IDE/ISA does not support IRQ 20 21 test BYTE [bp+IDEPACK.bDeviceControl], FLG_DEVCONTROL_nIEN 21 jnz SHORT IdeWait_PollStatusFlagInBLwithTimeoutInBH ; Interrupt disabled 22 jnz SHORT IDEDEVICE%+Wait_PollStatusFlagInBLwithTimeoutInBH ; Interrupt disabled 23 %endif 22 24 ; Fall to IdeWait_IRQorStatusFlagInBLwithTimeoutInBH 23 25 … … 35 37 ; AL, BX, CX, DX 36 38 ;-------------------------------------------------------------------- 37 IdeWait_IRQorStatusFlagInBLwithTimeoutInBH: 39 IDEDEVICE%+Wait_IRQorStatusFlagInBLwithTimeoutInBH: 40 %ifdef ASSEMBLE_SHARED_IDE_DEVICE_FUNCTIONS ; JR-IDE/ISA does not support IRQ 38 41 call IdeIrq_WaitForIRQ 42 %endif 39 43 ; Always fall to IdeWait_PollStatusFlagInBLwithTimeoutInBH for error processing 40 44 … … 52 56 ; AL, BX, CX, DX 53 57 ;-------------------------------------------------------------------- 54 I deWait_PollStatusFlagInBLwithTimeoutInBH:58 IDEDEVICE%+Wait_PollStatusFlagInBLwithTimeoutInBH: 55 59 mov ah, bl 56 60 mov cl, bh 57 61 call Timer_InitializeTimeoutWithTicksInCL 58 62 and ah, ~FLG_STATUS_BSY 59 jz SHORT PollBsyOnly63 jz SHORT IDEDEVICE%+PollBsyOnly 60 64 ; Fall to PollBsyAndFlgInAH 61 65 … … 72 76 ; AL, BX, CX, DX 73 77 ;-------------------------------------------------------------------- 78 %ifdef ASSEMBLE_SHARED_IDE_DEVICE_FUNCTIONS 74 79 PollBsyAndFlgInAH: 75 call ReadIdeStatusRegisterToAL; Discard contents for first read80 call IDEDEVICE%+ReadIdeStatusRegisterToAL; Discard contents for first read 76 81 ALIGN JUMP_ALIGN 77 82 .PollLoop: 78 call ReadIdeStatusRegisterToAL83 call IDEDEVICE%+ReadIdeStatusRegisterToAL 79 84 test al, FLG_STATUS_BSY ; Controller busy? 80 85 jnz SHORT .UpdateTimeout ; If so, jump to timeout update 81 86 test al, ah ; Test secondary flag 82 jnz SHORT I deError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL87 jnz SHORT IDEDEVICE%+Error_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL 83 88 .UpdateTimeout: 84 89 call Timer_SetCFifTimeout 85 90 jnc SHORT .PollLoop ; Loop if time left 86 call I deError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL91 call IDEDEVICE%+Error_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL 87 92 jc SHORT .ReturnErrorCodeInAH 88 93 mov ah, RET_HD_TIMEOUT ; Expected bit never got set … … 90 95 .ReturnErrorCodeInAH: 91 96 ret 97 %endif 92 98 93 99 … … 103 109 ; AL, BX, CX, DX 104 110 ;-------------------------------------------------------------------- 105 PollBsyOnly:106 call ReadIdeStatusRegisterToAL; Discard contents for first read111 IDEDEVICE%+PollBsyOnly: 112 call IDEDEVICE%+ReadIdeStatusRegisterToAL; Discard contents for first read 107 113 ALIGN JUMP_ALIGN 108 114 .PollLoop: 109 call ReadIdeStatusRegisterToAL115 call IDEDEVICE%+ReadIdeStatusRegisterToAL 110 116 test al, FLG_STATUS_BSY ; Controller busy? 111 jz SHORT I deError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL117 jz SHORT IDEDEVICE%+Error_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL 112 118 call Timer_SetCFifTimeout ; Update timeout counter 113 119 jnc SHORT .PollLoop ; Loop if time left (sets CF on timeout) 114 jmp SHORT I deError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL120 jmp SHORT IDEDEVICE%+Error_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL 115 121 116 122 … … 125 131 ;-------------------------------------------------------------------- 126 132 ALIGN JUMP_ALIGN 127 ReadIdeStatusRegisterToAL: 128 mov dl, STATUS_REGISTER_in 129 jmp IdeIO_InputToALfromIdeRegisterInDL 133 IDEDEVICE%+ReadIdeStatusRegisterToAL: 134 JUMP_TO_INPUT_TO_AL_FROM_IDE_REGISTER STATUS_REGISTER_in
Note:
See TracChangeset
for help on using the changeset viewer.