Changeset 400 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Device
- Timestamp:
- Apr 20, 2012, 2:30:16 PM (13 years ago)
- google:author:
- aitotat@gmail.com
- Location:
- trunk/XTIDE_Universal_BIOS/Src/Device
- Files:
-
- 1 added
- 3 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/Device/Device.asm
r376 r400 27 27 %endmacro 28 28 29 %macro CMP_USING_DPT_AND_JUMP_IF_JRIDE_DEVICE 130 xchg ax, bx31 eMOVZX bx, [di+DPT.bIdevarsOffset]32 cmp BYTE [cs:bx+IDEVARS.bDevice], DEVICE_JRIDE_ISA33 xchg bx, ax ; Restore BX34 je SHORT %135 %endmacro36 37 29 %macro CMP_USING_IDEVARS_IN_CSBP_AND_JUMP_IF 2 38 30 cmp BYTE [cs:bp+IDEVARS.bDevice], %1 … … 53 45 ; AX, BX, CX, DX 54 46 ;-------------------------------------------------------------------- 55 %ifdef MODULE_SERIAL 47 %ifdef MODULE_SERIAL ; IDE + Serial 56 48 Device_FinalizeDPT: 57 49 ; needs to check IDEVARS vs. checking the DPT as the serial bit in the DPT is set in the Finalize routine 58 CMP_USING_IDEVARS_IN_CSBP_AND_JUMP_IF 50 CMP_USING_IDEVARS_IN_CSBP_AND_JUMP_IF DEVICE_SERIAL_PORT, .FinalizeDptForSerialPortDevice 59 51 jmp IdeDPT_Finalize 60 52 .FinalizeDptForSerialPortDevice: 61 53 jmp SerialDPT_Finalize 62 54 63 %else ; IDE or JR-IDE/ISA64 Device_FinalizeDPT EQUIdeDPT_Finalize55 %else ; IDE 56 Device_FinalizeDPT EQU IdeDPT_Finalize 65 57 %endif 66 58 … … 76 68 ; AL, BX, CX, DX 77 69 ;-------------------------------------------------------------------- 78 %ifdef MODULE_JRIDE 79 %ifdef MODULE_SERIAL ; IDE + JR-IDE/ISA + Serial 80 Device_ResetMasterAndSlaveController: 81 TEST_USING_DPT_AND_JUMP_IF_SERIAL_DEVICE ReturnSuccessForSerialPort 82 CMP_USING_DPT_AND_JUMP_IF_JRIDE_DEVICE .ResetJrIDE 83 jmp IdeCommand_ResetMasterAndSlaveController 84 85 %else ; IDE + JR-IDE/ISA 86 Device_ResetMasterAndSlaveController: 87 CMP_USING_DPT_AND_JUMP_IF_JRIDE_DEVICE .ResetJrIDE 88 jmp IdeCommand_ResetMasterAndSlaveController 89 %endif 90 91 %elifdef MODULE_SERIAL ; IDE + Serial 70 %ifdef MODULE_SERIAL ; IDE + Serial 92 71 Device_ResetMasterAndSlaveController: 93 TEST_USING_DPT_AND_JUMP_IF_SERIAL_DEVICE 72 TEST_USING_DPT_AND_JUMP_IF_SERIAL_DEVICE ReturnSuccessForSerialPort 94 73 jmp IdeCommand_ResetMasterAndSlaveController 95 74 96 %else ; IDE 97 Device_ResetMasterAndSlaveController EQU IdeCommand_ResetMasterAndSlaveController 98 %endif 99 100 %ifdef MODULE_JRIDE 101 .ResetJrIDE: 102 jmp MemIdeCommand_ResetMasterAndSlaveController 75 %else ; IDE 76 Device_ResetMasterAndSlaveController EQU IdeCommand_ResetMasterAndSlaveController 103 77 %endif 104 78 … … 117 91 ; AL, BL, CX, DX, SI, DI, ES 118 92 ;-------------------------------------------------------------------- 119 %ifdef MODULE_JRIDE 120 %ifdef MODULE_SERIAL ; IDE + JR-IDE/ISA + Serial 121 Device_IdentifyToBufferInESSIwithDriveSelectByteInBH: 122 CMP_USING_IDEVARS_IN_CSBP_AND_JUMP_IF DEVICE_SERIAL_PORT, .IdentifyDriveFromSerialPort 123 CMP_USING_IDEVARS_IN_CSBP_AND_JUMP_IF DEVICE_JRIDE_ISA, .IdentifyDriveFromJrIde 124 jmp IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH 125 126 %else ; IDE + JR-IDE/ISA 127 Device_IdentifyToBufferInESSIwithDriveSelectByteInBH: 128 CMP_USING_IDEVARS_IN_CSBP_AND_JUMP_IF DEVICE_JRIDE_ISA, .IdentifyDriveFromJrIde 129 jmp IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH 130 %endif 131 132 %elifdef MODULE_SERIAL ; IDE + Serial 93 %ifdef MODULE_SERIAL ; IDE + Serial 133 94 Device_IdentifyToBufferInESSIwithDriveSelectByteInBH: 134 CMP_USING_IDEVARS_IN_CSBP_AND_JUMP_IF 95 CMP_USING_IDEVARS_IN_CSBP_AND_JUMP_IF DEVICE_SERIAL_PORT, .IdentifyDriveFromSerialPort 135 96 jmp IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH 136 137 %else ; IDE138 Device_IdentifyToBufferInESSIwithDriveSelectByteInBH EQU IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH139 %endif140 141 %ifdef MODULE_JRIDE142 .IdentifyDriveFromJrIde:143 jmp MemIdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH144 %endif145 146 %ifdef MODULE_SERIAL147 97 .IdentifyDriveFromSerialPort: 148 98 jmp SerialCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH 99 100 %else ; IDE 101 Device_IdentifyToBufferInESSIwithDriveSelectByteInBH EQU IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH 149 102 %endif 150 103 … … 165 118 ; AL, BX, (CX), DX, (ES:SI for data transfer commands) 166 119 ;-------------------------------------------------------------------- 167 %ifdef MODULE_JRIDE 168 %ifdef MODULE_SERIAL ; IDE + JR-IDE/ISA + Serial 169 Device_OutputCommandWithParameters: 170 TEST_USING_DPT_AND_JUMP_IF_SERIAL_DEVICE .OutputCommandToSerialPort 171 CMP_USING_DPT_AND_JUMP_IF_JRIDE_DEVICE .OutputCommandToJrIDE 172 jmp IdeCommand_OutputWithParameters 173 174 %else ; IDE + JR-IDE/ISA 175 Device_OutputCommandWithParameters: 176 CMP_USING_DPT_AND_JUMP_IF_JRIDE_DEVICE .OutputCommandToJrIDE 177 jmp IdeCommand_OutputWithParameters 178 %endif 179 180 %elifdef MODULE_SERIAL ; IDE + Serial 120 %ifdef MODULE_SERIAL ; IDE + Serial 121 ALIGN JUMP_ALIGN 181 122 Device_OutputCommandWithParameters: 182 123 TEST_USING_DPT_AND_JUMP_IF_SERIAL_DEVICE .OutputCommandToSerialPort 183 124 jmp IdeCommand_OutputWithParameters 184 125 185 %else ; IDE186 Device_OutputCommandWithParameters EQU IdeCommand_OutputWithParameters187 %endif188 189 %ifdef MODULE_JRIDE190 ALIGN JUMP_ALIGN191 .OutputCommandToJrIDE:192 jmp MemIdeCommand_OutputWithParameters193 %endif194 195 %ifdef MODULE_SERIAL196 126 ALIGN JUMP_ALIGN 197 127 .OutputCommandToSerialPort: 198 128 jmp SerialCommand_OutputWithParameters 129 130 %else ; IDE 131 Device_OutputCommandWithParameters EQU IdeCommand_OutputWithParameters 199 132 %endif 200 133 … … 211 144 ; AL, BX, CX, DX 212 145 ;-------------------------------------------------------------------- 213 %ifdef MODULE_JRIDE 214 %ifdef MODULE_SERIAL ; IDE + JR-IDE/ISA + Serial 215 Device_SelectDrive: 216 TEST_USING_DPT_AND_JUMP_IF_SERIAL_DEVICE ReturnSuccessForSerialPort 217 CMP_USING_DPT_AND_JUMP_IF_JRIDE_DEVICE .SelectJrIdeDrive 218 jmp IdeCommand_SelectDrive 219 220 %else ; IDE + JR-IDE/ISA 221 Device_SelectDrive: 222 CMP_USING_DPT_AND_JUMP_IF_JRIDE_DEVICE .SelectJrIdeDrive 223 jmp IdeCommand_SelectDrive 224 %endif 225 226 %elifdef MODULE_SERIAL ; IDE + Serial 146 %ifdef MODULE_SERIAL ; IDE + Serial 227 147 Device_SelectDrive: 228 TEST_USING_DPT_AND_JUMP_IF_SERIAL_DEVICE 148 TEST_USING_DPT_AND_JUMP_IF_SERIAL_DEVICE ReturnSuccessForSerialPort 229 149 jmp IdeCommand_SelectDrive 230 150 231 %else 232 Device_SelectDrive EQUIdeCommand_SelectDrive151 %else ; IDE 152 Device_SelectDrive EQU IdeCommand_SelectDrive 233 153 %endif 234 154 235 %ifdef MODULE_JRIDE236 ALIGN JUMP_ALIGN237 .SelectJrIdeDrive:238 jmp MemIdeCommand_SelectDrive239 %endif240 155 241 156 %ifdef MODULE_SERIAL -
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm
r376 r400 31 31 ; AL, BX, CX, DX 32 32 ;-------------------------------------------------------------------- 33 I DEDEVICE%+Command_ResetMasterAndSlaveController:33 IdeCommand_ResetMasterAndSlaveController: 34 34 ; HSR0: Set_SRST 35 35 call AccessDPT_GetDeviceControlByteToAL … … 49 49 ; HSR2: Check_status 50 50 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_MOTOR_STARTUP, FLG_STATUS_BSY) 51 jmp I DEDEVICE%+Wait_PollStatusFlagInBLwithTimeoutInBH51 jmp IdeWait_PollStatusFlagInBLwithTimeoutInBH 52 52 53 53 … … 65 65 ; AL, BL, CX, DX, SI, DI, ES 66 66 ;-------------------------------------------------------------------- 67 I DEDEVICE%+Command_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH:67 IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH: 68 68 ; Create fake DPT to be able to use Device.asm functions 69 69 call FindDPT_ForNewDriveToDSDI … … 72 72 mov [di+DPT.bIdevarsOffset], bp 73 73 mov BYTE [di+DPT_ATA.bBlockSize], 1 ; Block = 1 sector 74 %ifdef MODULE_ADVANCED_ATA75 74 call IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI 76 %endif77 %ifdef ASSEMBLE_SHARED_IDE_DEVICE_FUNCTIONS78 call IdeDPT_StoreReversedAddressLinesFlagIfNecessary79 %endif80 75 81 76 ; Wait until drive motors have reached max speed 82 77 cmp bp, BYTE ROMVARS.ideVars0 83 78 jne SHORT .SkipLongWaitSinceDriveIsNotPrimaryMaster 84 test al, FLG_DRVNHEAD_DRV79 test bh, FLG_DRVNHEAD_DRV 85 80 jnz SHORT .SkipLongWaitSinceDriveIsNotPrimaryMaster 86 81 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_MOTOR_STARTUP, FLG_STATUS_BSY) 87 call I DEDEVICE%+Wait_PollStatusFlagInBLwithTimeoutInBH82 call IdeWait_PollStatusFlagInBLwithTimeoutInBH 88 83 .SkipLongWaitSinceDriveIsNotPrimaryMaster: 89 84 … … 120 115 ;-------------------------------------------------------------------- 121 116 ALIGN JUMP_ALIGN 122 I DEDEVICE%+Command_OutputWithParameters:117 IdeCommand_OutputWithParameters: 123 118 push bx ; Store status register bits to poll 124 119 125 120 ; Select Master or Slave drive and output head number or LBA28 top bits 126 call I DEDEVICE%+Command_SelectDrive121 call IdeCommand_SelectDrive 127 122 jc SHORT .DriveNotReady 128 123 129 124 ; Output Device Control Byte to enable or disable interrupts 130 125 mov al, [bp+IDEPACK.bDeviceControl] 131 %ifdef ASSEMBLE_SHARED_IDE_DEVICE_FUNCTIONS ; JR-IDE/ISA126 %ifdef MODULE_IRQ 132 127 test al, FLG_DEVCONTROL_nIEN ; Interrupts disabled? 133 128 jnz SHORT .DoNotSetInterruptInServiceFlag … … 151 146 eMOVZX ax, [bp+IDEPACK.bLbaLowExt] ; Zero sector count 152 147 mov cx, [bp+IDEPACK.wLbaMiddleAndHighExt] 153 call IDEDEVICE%+OutputSectorCountAndAddress148 call OutputSectorCountAndAddress 154 149 %endif 155 150 … … 157 152 mov ax, [bp+IDEPACK.wSectorCountAndLbaLow] 158 153 mov cx, [bp+IDEPACK.wLbaMiddleAndHigh] 159 call IDEDEVICE%+OutputSectorCountAndAddress154 call OutputSectorCountAndAddress 160 155 161 156 ; Output command … … 164 159 165 160 ; Wait until command completed 166 pop bx ; Pop status and timeout for polling 167 cmp bl, FLG_STATUS_DRQ ; Data transfer started? 168 je SHORT IDEDEVICE%+Transfer_StartWithCommandInAL 161 pop bx ; Pop status and timeout for polling 162 cmp bl, FLG_STATUS_DRQ ; Data transfer started? 163 jne SHORT .WaitUntilNonTransferCommandCompletes 164 %ifdef MODULE_JRIDE 165 cmp BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_JRIDE_ISA 166 je SHORT JrIdeTransfer_StartWithCommandInAL 167 %endif 168 jmp IdeTransfer_StartWithCommandInAL 169 170 .WaitUntilNonTransferCommandCompletes: 171 %ifdef MODULE_IRQ 169 172 test BYTE [bp+IDEPACK.bDeviceControl], FLG_DEVCONTROL_nIEN 170 jz SHORT .WaitForIrqOrRdy 171 jmp IDEDEVICE%+Wait_PollStatusFlagInBLwithTimeoutInBH 172 173 ALIGN JUMP_ALIGN 174 .WaitForIrqOrRdy: 175 jmp IDEDEVICE%+Wait_IRQorStatusFlagInBLwithTimeoutInBH 173 jz SHORT .PollStatusFlagInsteadOfWaitIrq 174 jmp IdeWait_IRQorStatusFlagInBLwithTimeoutInBH 175 .PollStatusFlagInsteadOfWaitIrq: 176 %endif 177 jmp IdeWait_PollStatusFlagInBLwithTimeoutInBH 176 178 177 179 .DriveNotReady: … … 192 194 ;-------------------------------------------------------------------- 193 195 ALIGN JUMP_ALIGN 194 IDEDEVICE%+Command_SelectDrive: 195 ; Wait until neither Master or Slave Drive is busy. 196 ; I don't think this wait is necessary. 197 ;mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_BSY, FLG_STATUS_BSY) 198 ;cmp BYTE [bp+IDEPACK.bCommand], COMMAND_IDENTIFY_DEVICE 199 ;eCMOVE bh, TIMEOUT_IDENTIFY_DEVICE 200 ;call IDEDEVICE%+Wait_PollStatusFlagInBLwithTimeoutInBH 201 196 IdeCommand_SelectDrive: 202 197 ; Select Master or Slave Drive 203 198 mov al, [bp+IDEPACK.bDrvAndHead] … … 206 201 cmp BYTE [bp+IDEPACK.bCommand], COMMAND_IDENTIFY_DEVICE 207 202 eCMOVE bh, TIMEOUT_IDENTIFY_DEVICE 208 call I DEDEVICE%+Wait_PollStatusFlagInBLwithTimeoutInBH203 call IdeWait_PollStatusFlagInBLwithTimeoutInBH 209 204 210 205 ; Ignore errors from IDE Error Register (set by previous command) … … 232 227 ;-------------------------------------------------------------------- 233 228 ALIGN JUMP_ALIGN 234 IDEDEVICE%+OutputSectorCountAndAddress:229 OutputSectorCountAndAddress: 235 230 OUTPUT_AL_TO_IDE_REGISTER SECTOR_COUNT_REGISTER 236 231 -
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDPT.asm
r399 r400 66 66 %ifdef MODULE_ADVANCED_ATA 67 67 ;-------------------------------------------------------------------- 68 ; .StoreDeviceType69 ; Parameters:70 ; DS:DI: Ptr to Disk Parameter Table71 ; ES:SI: Ptr to 512-byte ATA information read from the drive72 ; CS:BP: Ptr to IDEVARS for the controller73 ; Returns:74 ; Nothing75 ; Corrupts registers:76 ; Nothing77 ;--------------------------------------------------------------------78 .StoreDeviceType:79 call IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI80 81 ;--------------------------------------------------------------------82 68 ; .StorePioModeAndTimings 83 69 ; Parameters: … … 124 110 ; it might have been set to 16-bit on IDEVARS 125 111 .ChangeTo32bitDevice: 126 mov BYTE [di+DPT_A DVANCED_ATA.bDevice], DEVICE_32BIT_ATA112 mov BYTE [di+DPT_ATA.bDevice], DEVICE_32BIT_ATA 127 113 128 114 .NoAdvancedControllerDetected: 115 ; Fall to IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI 129 116 130 %endif ; MODULE_ADVANCED_ATA 131 132 ;-------------------------------------------------------------------- 133 ; IdeDPT_StoreReversedAddressLinesFlagIfNecessary 134 ; Parameters: 135 ; DS:DI: Ptr to Disk Parameter Table 136 ; CS:BP: Ptr to IDEVARS for the controller 137 ; Returns: 138 ; CF: Always clear 139 ; Corrupts registers: 140 ; Nothing 141 ;-------------------------------------------------------------------- 142 IdeDPT_StoreReversedAddressLinesFlagIfNecessary: 143 cmp BYTE [cs:bp+IDEVARS.bDevice], DEVICE_XTIDE_REV2 144 je SHORT .SetFlagForSwappedA0andA3 145 cmp BYTE [cs:bp+IDEVARS.bDevice], DEVICE_FAST_XTIDE 146 jne SHORT .EndDPT 147 .SetFlagForSwappedA0andA3: 148 or BYTE [di+DPT.bFlagsHigh], FLGH_DPT_REVERSED_A0_AND_A3 149 .EndDPT: 150 clc 151 ret 117 %endif ; MODULE_ADVANCED_ATA 152 118 153 119 154 %ifdef MODULE_ADVANCED_ATA155 120 ;-------------------------------------------------------------------- 156 121 ; IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI … … 165 130 IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI: 166 131 mov al, [cs:bp+IDEVARS.bDevice] 167 mov [di+DPT_ADVANCED_ATA.bDevice], al 132 mov [di+DPT_ATA.bDevice], al 133 ; End DPT 134 clc 168 135 ret 169 170 %endif -
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeError.asm
r376 r400 34 34 ;-------------------------------------------------------------------- 35 35 ALIGN JUMP_ALIGN 36 I DEDEVICE%+Error_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL:36 IdeError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL: 37 37 mov ah, al ; IDE Status Register to AH 38 38 INPUT_TO_AL_FROM_IDE_REGISTER ERROR_REGISTER_in 39 40 %ifndef ASSEMBLE_SHARED_IDE_DEVICE_FUNCTIONS ; JR-IDE/ISA41 jmp ContinueFromMemIdeError42 %else43 ContinueFromMemIdeError:44 39 xchg al, ah ; Status Register now in AL, Error Register now in AH 45 46 ; I don't think anything actually reads these from BDA47 ;push ds48 ;LOAD_BDA_SEGMENT_TO ds, dx49 ;mov [HDBDA.wHDStAndErr], ax50 ;pop ds51 52 40 ; Fall to GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX 53 41 … … 112 100 db RET_HD_BADSECTOR ; Bit7=BBK, Bad Block Detected 113 101 db RET_HD_STATUSERR ; When Error Register is zero 114 %endif -
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeIO.asm
r376 r400 23 23 ;-------------------------------------------------------------------- 24 24 ; IdeIO_OutputALtoIdeControlBlockRegisterInDL 25 ; Parameters: 26 ; AL: Byte to output 27 ; DL: IDE Control Block Register 28 ; DS:DI: Ptr to DPT (in RAMVARS segment) 29 ; Returns: 30 ; Nothing 31 ; Corrupts registers: 32 ; BX, DX 33 ;-------------------------------------------------------------------- 34 IdeIO_OutputALtoIdeControlBlockRegisterInDL: 35 %ifdef MODULE_8BIT_IDE 36 mov dh, [di+DPT_ATA.bDevice] 37 %ifdef MODULE_JRIDE 38 test dh, dh 39 jnz SHORT .OutputToIoMappedIde 40 41 add dx, JRIDE_CONTROL_BLOCK_REGISTER_WINDOW_OFFSET 42 jmp SHORT OutputToJrIdeRegister 43 .OutputToIoMappedIde: 44 %endif 45 %endif 46 47 mov bl, IDEVARS.wPortCtrl 48 jmp SHORT OutputALtoIdeRegisterInDLwithIdevarsOffsetToBasePortInBL 49 50 51 ;-------------------------------------------------------------------- 25 52 ; IdeIO_OutputALtoIdeRegisterInDL 26 53 ; Parameters: 27 54 ; AL: Byte to output 28 ; DL: IDE Control Block Register (IdeIO_OutputALtoIdeControlBlockRegisterInDL) 29 ; IDE Register (IdeIO_OutputALtoIdeRegisterInDL) 55 ; DL: IDE Command Block Register 30 56 ; DS:DI: Ptr to DPT (in RAMVARS segment) 31 57 ; Returns: … … 35 61 ;-------------------------------------------------------------------- 36 62 ALIGN JUMP_ALIGN 37 IdeIO_OutputALtoIdeControlBlockRegisterInDL: 38 mov bl, IDEVARS.wPortCtrl 39 SKIP2B f ; cmp ax, <next instruction> 40 ; Fall to IdeIO_OutputALtoIdeRegisterInDL 63 IdeIO_OutputALtoIdeRegisterInDL: 64 %ifdef MODULE_8BIT_IDE 65 mov dh, [di+DPT_ATA.bDevice] 66 %ifdef MODULE_JRIDE 67 test dh, dh 68 jnz SHORT OutputALtoIOmappedIdeRegisterInDL 41 69 42 IdeIO_OutputALtoIdeRegisterInDL: 70 add dx, JRIDE_COMMAND_BLOCK_REGISTER_WINDOW_OFFSET 71 OutputToJrIdeRegister: 72 mov bx, dx 73 mov [cs:bx], al 74 ret 75 ALIGN JUMP_ALIGN 76 OutputALtoIOmappedIdeRegisterInDL: 77 %endif 78 %endif 79 43 80 mov bl, IDEVARS.wPort 44 call GetPortToDXandTranslateA0andA3ifNecessary 81 OutputALtoIdeRegisterInDLwithIdevarsOffsetToBasePortInBL: 82 call GetIdePortToDX 45 83 out dx, al 46 84 ret 47 85 86 87 ;-------------------------------------------------------------------- 88 ; IdeIO_InputStatusRegisterToAL 89 ; Parameters: 90 ; DS:DI: Ptr to DPT (in RAMVARS segment) 91 ; Returns: 92 ; AL: IDE Status Register contents 93 ; Corrupts registers: 94 ; BX, DX 95 ;-------------------------------------------------------------------- 96 ALIGN JUMP_ALIGN 97 IdeIO_InputStatusRegisterToAL: 98 mov dl, STATUS_REGISTER_in 99 ; Fall to IdeIO_InputToALfromIdeRegisterInDL 48 100 49 101 ;-------------------------------------------------------------------- … … 57 109 ; BX, DX 58 110 ;-------------------------------------------------------------------- 59 ALIGN JUMP_ALIGN60 111 IdeIO_InputToALfromIdeRegisterInDL: 112 %ifdef MODULE_8BIT_IDE 113 mov dh, [di+DPT_ATA.bDevice] 114 %ifdef MODULE_JRIDE 115 test dh, dh 116 jnz SHORT .InputToALfromIOmappedIdeRegisterInDL 117 118 add dx, JRIDE_COMMAND_BLOCK_REGISTER_WINDOW_OFFSET 119 mov bx, dx 120 mov al, [cs:bx] 121 ret 122 .InputToALfromIOmappedIdeRegisterInDL: 123 %endif 124 %endif 61 125 mov bl, IDEVARS.wPort 62 call Get PortToDXandTranslateA0andA3ifNecessary126 call GetIdePortToDX 63 127 in al, dx 64 128 ret … … 66 130 67 131 ;-------------------------------------------------------------------- 68 ; Get PortToDXandTranslateA0andA3ifNecessary132 ; GetIdePortToDX 69 133 ; Parameters: 70 134 ; BL: Offset to port in IDEVARS (IDEVARS.wPort or IDEVARS.wPortCtrl) 135 ; DH: Device Type (IDEVARS.bDevice) 71 136 ; DL: IDE Register 72 137 ; DS:DI: Ptr to DPT (in RAMVARS segment) … … 77 142 ;-------------------------------------------------------------------- 78 143 ALIGN JUMP_ALIGN 79 GetPortToDXandTranslateA0andA3ifNecessary: 144 GetIdePortToDX: 145 %ifdef MODULE_8BIT_IDE 146 ; Point CS:BX to IDEVARS 80 147 xor bh, bh 81 add bl, [di+DPT.bIdevarsOffset] ; CS:BX now points port address 82 xor dh, dh ; DX now has IDE register offset 83 add dx, [cs:bx] 84 test BYTE [di+DPT.bFlagsHigh], FLGH_DPT_REVERSED_A0_AND_A3 85 jz SHORT .ReturnPortInDX 148 add bl, [di+DPT.bIdevarsOffset] ; CS:BX now points port address 149 150 ; Load port address and check if A0 and A3 address lines need to be reversed 151 cmp dh, DEVICE_8BIT_XTIDE_REV1 152 mov dh, bh ; DX now has IDE register offset 153 jae SHORT .ReturnUntranslatedPortInDX ; No need to swap address lines 86 154 87 155 ; Exchange address lines A0 and A3 from DL 156 add dx, [cs:bx] ; DX now has port address 88 157 mov bl, dl 89 158 mov bh, MASK_A3_AND_A0_ADDRESS_LINES 90 and bh, bl ; BH = 0, 1, 8 or 9, we can ignore 0 and 991 jz SHORT .Return PortInDX; Jump out since DH is 0159 and bh, bl ; BH = 0, 1, 8 or 9, we can ignore 0 and 9 160 jz SHORT .ReturnTranslatedPortInDX ; Jump out since DH is 0 92 161 xor bh, MASK_A3_AND_A0_ADDRESS_LINES 93 jz SHORT .Return PortInDX; Jump out since DH was 9162 jz SHORT .ReturnTranslatedPortInDX ; Jump out since DH was 9 94 163 and dl, ~MASK_A3_AND_A0_ADDRESS_LINES 95 or dl, bh ; Address lines now reversed96 .Return PortInDX:164 or dl, bh ; Address lines now reversed 165 .ReturnTranslatedPortInDX: 97 166 ret 167 168 .ReturnUntranslatedPortInDX: 169 add dx, [cs:bx] 170 ret 171 172 %else ; Only standard IDE devices 173 xor bh, bh 174 xor dh, dh 175 add bl, [di+DPT.bIdevarsOffset] ; CS:BX now points port address 176 add dx, [cs:bx] ; DX now has port address 177 ret 178 %endif -
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm
r376 r400 208 208 mov bl, [di+DPT.bIdevarsOffset] ; CS:BX now points to IDEVARS 209 209 mov dx, [cs:bx+IDEVARS.wPort] ; Load IDE Data port address 210 %ifdef MODULE_ADVANCED_ATA 211 mov bl, [di+DPT_ADVANCED_ATA.bDevice] 212 %else 213 mov bl, [cs:bx+IDEVARS.bDevice] ; Load device type to BX 214 %endif 210 mov bl, [di+DPT_ATA.bDevice] 215 211 add bx, ax 216 212 … … 235 231 ; AX, BX, CX 236 232 ;-------------------------------------------------------------------- 233 %ifdef MODULE_8BIT_IDE 234 237 235 ALIGN JUMP_ALIGN 238 236 ReadBlockFromXtideRev1: … … 267 265 %endif 268 266 267 %endif ; MODULE_8BIT_IDE 268 269 269 ;-------------------------------------------------------------------- 270 270 ALIGN JUMP_ALIGN … … 302 302 ; AX, CX 303 303 ;-------------------------------------------------------------------- 304 %ifdef MODULE_8BIT_IDE 305 304 306 ALIGN JUMP_ALIGN 305 307 WriteBlockToXtideRev1: … … 361 363 %endif 362 364 365 %endif ; MODULE_8BIT_IDE 366 363 367 ;-------------------------------------------------------------------- 364 368 ALIGN JUMP_ALIGN … … 387 391 ALIGN WORD_ALIGN 388 392 g_rgfnPioRead: 389 dw ReadBlockFromXtideRev1 ; DEVICE_XTIDE_REV1 390 %ifdef USE_186 391 dw ReadBlockFrom16bitDataPort ; DEVICE_XTIDE_REV2 392 dw ReadBlockFrom16bitDataPort ; DEVICE_FAST_XTIDE 393 %ifdef MODULE_8BIT_IDE 394 dw ReadBlockFromXtideRev1 ; DEVICE_XTIDE_REV1 395 %ifdef USE_186 396 dw ReadBlockFrom16bitDataPort ; DEVICE_XTIDE_REV2 397 dw ReadBlockFrom16bitDataPort ; DEVICE_FAST_XTIDE 398 %else 399 dw ReadBlockFromXtideRev2 ; DEVICE_XTIDE_REV2 400 dw ReadBlockFromXtideRev2 ; DEVICE_FAST_XTIDE 401 %endif 402 393 403 %else 394 dw ReadBlockFromXtideRev2 ; DEVICE_XTIDE_REV2395 dw ReadBlockFromXtideRev2 ; DEVICE_FAST_XTIDE 396 %endif 397 dw ReadBlockFrom16bitDataPort ; DEVICE_16BIT_ATA398 dw ReadBlockFrom32bitDataPort ; DEVICE_32BIT_ATA 404 times COUNT_OF_8BIT_IDE_DEVICES dw 0 405 %endif 406 dw ReadBlockFrom16bitDataPort ; DEVICE_16BIT_ATA 407 dw ReadBlockFrom32bitDataPort ; DEVICE_32BIT_ATA 408 399 409 400 410 g_rgfnPioWrite: 401 dw WriteBlockToXtideRev1 ; DEVICE_XTIDE_REV1 402 dw WriteBlockToXtideRev2 ; DEVICE_XTIDE_REV2 403 %ifdef USE_186 404 dw WriteBlockTo16bitDataPort ; DEVICE_FAST_XTIDE 411 %ifdef MODULE_8BIT_IDE 412 dw WriteBlockToXtideRev1 ; DEVICE_XTIDE_REV1 413 dw WriteBlockToXtideRev2 ; DEVICE_XTIDE_REV2 414 %ifdef USE_186 415 dw WriteBlockTo16bitDataPort ; DEVICE_FAST_XTIDE 416 %else 417 dw WriteBlockToFastXtide ; DEVICE_FAST_XTIDE 418 %endif 419 405 420 %else 406 dw WriteBlockToFastXtide ; DEVICE_FAST_XTIDE407 %endif 408 dw WriteBlockTo16bitDataPort ; DEVICE_16BIT_ATA409 dw WriteBlockTo32bitDataPort ; DEVICE_32BIT_ATA421 times COUNT_OF_8BIT_IDE_DEVICES dw 0 422 %endif 423 dw WriteBlockTo16bitDataPort ; DEVICE_16BIT_ATA 424 dw WriteBlockTo32bitDataPort ; DEVICE_32BIT_ATA -
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeWait.asm
r398 r400 32 32 ; AL, BX, CX, DX 33 33 ;-------------------------------------------------------------------- 34 I DEDEVICE%+Wait_IRQorDRQ:34 IdeWait_IRQorDRQ: 35 35 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRQ) 36 %ifdef ASSEMBLE_SHARED_IDE_DEVICE_FUNCTIONS ; JR-IDE/ISA does not support IRQ 36 37 %ifdef MODULE_IRQ 37 38 test BYTE [bp+IDEPACK.bDeviceControl], FLG_DEVCONTROL_nIEN 38 jnz SHORT I DEDEVICE%+Wait_PollStatusFlagInBLwithTimeoutInBH ; Interrupt disabled39 jnz SHORT IdeWait_PollStatusFlagInBLwithTimeoutInBH ; Interrupt disabled 39 40 %endif 40 41 ; Fall to IdeWait_IRQorStatusFlagInBLwithTimeoutInBH … … 53 54 ; AL, BX, CX, DX 54 55 ;-------------------------------------------------------------------- 55 IDEDEVICE%+Wait_IRQorStatusFlagInBLwithTimeoutInBH: 56 %ifdef ASSEMBLE_SHARED_IDE_DEVICE_FUNCTIONS ; JR-IDE/ISA does not support IRQ 57 %ifdef MODULE_IRQ 58 call IdeIrq_WaitForIRQ 59 %endif 56 IdeWait_IRQorStatusFlagInBLwithTimeoutInBH: 57 %ifdef MODULE_IRQ 58 call IdeIrq_WaitForIRQ 60 59 %endif 61 60 ; Always fall to IdeWait_PollStatusFlagInBLwithTimeoutInBH for error processing … … 74 73 ; AL, BX, CX, DX 75 74 ;-------------------------------------------------------------------- 76 I DEDEVICE%+Wait_PollStatusFlagInBLwithTimeoutInBH:75 IdeWait_PollStatusFlagInBLwithTimeoutInBH: 77 76 mov ah, bl 78 77 mov cl, bh 79 78 call Timer_InitializeTimeoutWithTicksInCL 80 79 and ah, ~FLG_STATUS_BSY 81 jz SHORT IDEDEVICE%+PollBsyOnly80 jz SHORT PollBsyOnly 82 81 ; Fall to PollBsyAndFlgInAH 83 82 … … 94 93 ; AL, BX, CX, DX 95 94 ;-------------------------------------------------------------------- 96 I DEDEVICE%+PollBsyAndFlgInAH:97 INPUT_TO_AL_FROM_IDE_REGISTER STATUS_REGISTER_in ; Discard contents forfirst read98 ALIGN JUMP_ALIGN 95 IdePollBsyAndFlgInAH: 96 call IdeIO_InputStatusRegisterToAL ; Discard contents of first read 97 99 98 .PollLoop: 100 INPUT_TO_AL_FROM_IDE_REGISTER STATUS_REGISTER_in99 call IdeIO_InputStatusRegisterToAL 101 100 test al, FLG_STATUS_BSY ; Controller busy? 102 101 jnz SHORT .UpdateTimeout ; If so, jump to timeout update 103 102 test al, ah ; Test secondary flag 104 jnz SHORT I DEDEVICE%+Error_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL103 jnz SHORT IdeError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL 105 104 .UpdateTimeout: 106 105 call Timer_SetCFifTimeout 107 106 jnc SHORT .PollLoop ; Loop if time left 108 call I DEDEVICE%+Error_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL107 call IdeError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL 109 108 jc SHORT .ReturnErrorCodeInAH 110 109 mov ah, RET_HD_TIMEOUT ; Expected bit never got set … … 125 124 ; AL, BX, CX, DX 126 125 ;-------------------------------------------------------------------- 127 IDEDEVICE%+PollBsyOnly:128 INPUT_TO_AL_FROM_IDE_REGISTER STATUS_REGISTER_in ; Discard contents forfirst read129 ALIGN JUMP_ALIGN 126 PollBsyOnly: 127 call IdeIO_InputStatusRegisterToAL ; Discard contents of first read 128 130 129 .PollLoop: 131 INPUT_TO_AL_FROM_IDE_REGISTER STATUS_REGISTER_in130 call IdeIO_InputStatusRegisterToAL 132 131 test al, FLG_STATUS_BSY ; Controller busy? 133 jz SHORT I DEDEVICE%+Error_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL132 jz SHORT IdeError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL 134 133 call Timer_SetCFifTimeout ; Update timeout counter 135 134 jnc SHORT .PollLoop ; Loop if time left (sets CF on timeout) 136 jmp SHORT I DEDEVICE%+Error_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL135 jmp SHORT IdeError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL
Note:
See TracChangeset
for help on using the changeset viewer.