Changeset 473 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Device/IDE
- Timestamp:
- Oct 10, 2012, 6:22:23 PM (12 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
r445 r473 56 56 ; Parameters: 57 57 ; BH: Drive Select byte for Drive and Head Select Register 58 ; DX: Autodetected port for XT-CF 58 59 ; DS: Segment to RAMVARS 59 60 ; ES:SI: Ptr to buffer to receive 512-byte IDE Information … … 70 71 eMOVZX ax, bh 71 72 mov [di+DPT.wFlags], ax 72 mov [di+DPT.bIdevarsOffset], bp 73 call CreateDPT_StoreIdevarsOffsetAndBasePortFromCSBPtoDPTinDSDI 74 call IdeDPT_StoreDeviceTypeToDPTinDSDIfromIdevarsInCSBP 73 75 mov BYTE [di+DPT_ATA.bBlockSize], 1 ; Block = 1 sector 74 call IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI75 76 76 77 ; Wait until drive motors have reached full speed 77 cmp bp, BYTE ROMVARS.ideVars0 78 cmp bp, BYTE ROMVARS.ideVars0 ; First controller? 78 79 jne SHORT .SkipLongWaitSinceDriveIsNotPrimaryMaster 79 test bh, FLG_DRVNHEAD_DRV 80 test bh, FLG_DRVNHEAD_DRV ; Wait already done for Master 80 81 jnz SHORT .SkipLongWaitSinceDriveIsNotPrimaryMaster 81 82 call AHDh_WaitUntilDriveMotorHasReachedFullSpeed … … 87 88 88 89 %ifdef MODULE_8BIT_IDE 89 ; Enable 8-bit PIO mode for Lo-tech XT-CF 90 ; We set XT-CF to 8-bit PIO mode for Identify Device command. 91 ; Correct XT-CF mode is later set on AH=09h (after all drives are detected). 92 call AccessDPT_IsThisDeviceXTCF 93 jne SHORT .SkipXTCFmodeChange 94 95 xor al, al ; XTCF_8BIT_PIO_MODE 90 96 push si 91 call AH 9h_Enable8bitPioModeForXTCF97 call AH1Eh_ChangeXTCFmodeBasedOnControlRegisterInAL 92 98 pop si 93 99 jc SHORT .FailedToSet8bitMode 94 %endif 100 .SkipXTCFmodeChange: 101 %endif ; MODULE_8BIT_IDE 95 102 96 103 ; Prepare to output Identify Device command … … 170 177 cmp bl, FLG_STATUS_DRQ ; Data transfer started? 171 178 jne SHORT .WaitUntilNonTransferCommandCompletes 172 %ifdef MODULE_JRIDE 173 cmp BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_JRIDE_ISA 174 je SHORT JrIdeTransfer_StartWithCommandInAL 179 %ifdef MODULE_8BIT_IDE 180 cmp BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_DMA 181 je SHORT 0 ; IdeDma_StartTransferWithCommandInAL 182 ja SHORT JrIdeTransfer_StartWithCommandInAL ; DEVICE_8BIT_XTCF_MEMMAP or DEVICE_8BIT_JRIDE_ISA 175 183 %endif 176 184 jmp IdeTransfer_StartWithCommandInAL … … 205 213 ; We use different timeout value when detecting drives. 206 214 ; This prevents unnecessary long delays when drive is not present. 207 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRDY, FLG_STATUS_DRDY)215 mov cx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRDY, FLG_STATUS_DRDY) 208 216 cmp WORD [RAMVARS.wDrvDetectSignature], RAMVARS_DRV_DETECT_SIGNATURE 209 eCMOVE bh, TIMEOUT_SELECT_DRIVE_DURING_DRIVE_DETECTION217 eCMOVE ch, TIMEOUT_SELECT_DRIVE_DURING_DRIVE_DETECTION 210 218 211 219 ; Select Master or Slave Drive 212 220 mov al, [bp+IDEPACK.bDrvAndHead] 213 221 OUTPUT_AL_TO_IDE_REGISTER DRIVE_AND_HEAD_SELECT_REGISTER 222 mov bx, cx 214 223 call IdeWait_PollStatusFlagInBLwithTimeoutInBH 215 224 … … 248 257 249 258 mov al, ch 250 JUMP_TO_OUTPUT_AL_TO_IDE_REGISTER LBA_HIGH_REGISTER 259 OUTPUT_AL_TO_IDE_REGISTER LBA_HIGH_REGISTER 260 ret -
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDPT.asm
r410 r473 64 64 ;-------------------------------------------------------------------- 65 65 .StoreDeviceType: 66 call IdeDPT_StoreDeviceType FromIdevarsInCSBPtoDPTinDSDI66 call IdeDPT_StoreDeviceTypeToDPTinDSDIfromIdevarsInCSBP 67 67 68 68 … … 111 111 ;-------------------------------------------------------------------- 112 112 .DetectAdvancedIdeController: 113 call AccessDPT_GetIdeBasePortToBX113 mov bx, [di+DPT.wBasePort] 114 114 call AdvAtaInit_DetectControllerForIdeBaseInBX 115 115 mov [di+DPT_ADVANCED_ATA.wControllerID], ax ; Store zero if none detected … … 138 138 139 139 ;-------------------------------------------------------------------- 140 ; IdeDPT_StoreDeviceType FromIdevarsInCSBPtoDPTinDSDI140 ; IdeDPT_StoreDeviceTypeToDPTinDSDIfromIdevarsInCSBP 141 141 ; Parameters: 142 142 ; DS:DI: Ptr to Disk Parameter Table … … 147 147 ; AL 148 148 ;-------------------------------------------------------------------- 149 IdeDPT_StoreDeviceType FromIdevarsInCSBPtoDPTinDSDI:149 IdeDPT_StoreDeviceTypeToDPTinDSDIfromIdevarsInCSBP: 150 150 mov al, [cs:bp+IDEVARS.bDevice] 151 151 mov [di+DPT_ATA.bDevice], al -
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeIO.asm
r443 r473 1 1 ; Project name : XTIDE Universal BIOS 2 ; Description : IDE Register I/O functions. 2 ; Description : IDE Register I/O functions when supporting 8-bit 3 ; devices that need address translations. 3 4 4 5 ; … … 22 23 23 24 ;-------------------------------------------------------------------- 25 ; IdeIO_InputStatusRegisterToAL 26 ; Parameters: 27 ; DS:DI: Ptr to DPT (in RAMVARS segment) 28 ; Returns: 29 ; AL: IDE Status Register contents 30 ; Corrupts registers: 31 ; BX, DX 32 ;-------------------------------------------------------------------- 33 ALIGN JUMP_ALIGN 34 IdeIO_InputStatusRegisterToAL: 35 %ifndef MODULE_8BIT_IDE 36 INPUT_TO_AL_FROM_IDE_REGISTER STATUS_REGISTER_in 37 ret 38 39 %else 40 mov dl, STATUS_REGISTER_in 41 ; Fall to IdeIO_InputToALfromIdeRegisterInDL 42 43 ;-------------------------------------------------------------------- 44 ; IdeIO_InputToALfromIdeRegisterInDL 45 ; Parameters: 46 ; DL: IDE Register 47 ; DS:DI: Ptr to DPT (in RAMVARS segment) 48 ; Returns: 49 ; AL: Inputted byte 50 ; Corrupts registers: 51 ; BX, DX 52 ;-------------------------------------------------------------------- 53 IdeIO_InputToALfromIdeRegisterInDL: 54 xor dh, dh ; IDE Register index now in DX 55 56 mov al, [di+DPT_ATA.bDevice] 57 cmp al, DEVICE_8BIT_XTIDE_REV2 58 je SHORT .ReverseA0andA3fromRegisterIndexInDX 59 jb SHORT .InputToALfromRegisterInDX ; Standard IDE controllers and XTIDE rev 1 60 cmp al, DEVICE_8BIT_JRIDE_ISA 61 jne SHORT .ShlRegisterIndexInDX ; All XT-CF modes 62 ; Fall to .InputToALfromMemoryMappedRegisterInDX 63 64 .InputToALfromMemoryMappedRegisterInDX: 65 mov bx, JRIDE_COMMAND_BLOCK_REGISTER_WINDOW_OFFSET 66 add bx, dx 67 push ds 68 mov ds, [di+DPT.wBasePort] ; Segment for JR-IDE/ISA 69 mov al, [bx] 70 pop ds 71 ret 72 73 .ReverseA0andA3fromRegisterIndexInDX: 74 mov bx, dx 75 mov dl, [cs:bx+g_rgbSwapA0andA3fromIdeRegisterIndex] 76 SKIP2B bx ; Skip shl dx, 1 77 78 .ShlRegisterIndexInDX: 79 shl dx, 1 80 ; Fall to .InputToALfromRegisterInDX 81 82 .InputToALfromRegisterInDX: 83 add dx, [di+DPT.wBasePort] 84 in al, dx 85 ret 86 87 88 ;-------------------------------------------------------------------- 24 89 ; IdeIO_OutputALtoIdeControlBlockRegisterInDL 25 90 ; Parameters: … … 33 98 ;-------------------------------------------------------------------- 34 99 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 ; MODULE_JRIDE 45 %endif ; MODULE_8BIT_IDE 100 ; Note! We do not need to reverse A0 and A3 for XTIDE rev 2 since 101 ; the only Control Block Register we access is DEVICE_CONTROL_REGISTER_out 102 ; at offset 6 (0110b). 103 xor dh, dh ; IDE Register index now in DX 46 104 47 mov bl, IDEVARS.wPortCtrl 48 jmp SHORT OutputALtoIdeRegisterInDLwithIdevarsOffsetToBasePortInBL 105 mov bl, [di+DPT_ATA.bDevice] 106 cmp bl, DEVICE_8BIT_XTIDE_REV2 107 jbe SHORT .OutputALtoControlBlockRegisterInDX ; Standard IDE controllers and XTIDE rev 1 108 cmp bl, DEVICE_8BIT_JRIDE_ISA 109 jne SHORT .ShlRegisterIndexInDX ; All XT-CF modes 110 ; Fall to .OutputALtoMemoryMappedRegisterInDX 111 112 .OutputALtoMemoryMappedRegisterInDX: 113 mov bx, JRIDE_CONTROL_BLOCK_REGISTER_WINDOW_OFFSET 114 jmp SHORT IdeIO_OutputALtoIdeRegisterInDL.OutputALtoMemoryMappedRegisterInDXwithWindowOffsetInBX 115 116 .ShlRegisterIndexInDX: 117 add dl, OFFSET_TO_CONTROL_BLOCK_REGISTERS 118 shl dx, 1 119 jmp SHORT OutputALtoRegisterInDX 120 121 .OutputALtoControlBlockRegisterInDX: 122 call AccessDPT_GetIdevarsToCSBX 123 add dx, [cs:bx+IDEVARS.wControlBlockPort] 124 jmp SHORT OutputALtoPortInDX 49 125 50 126 … … 62 138 ALIGN JUMP_ALIGN 63 139 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 69 70 %if JRIDE_COMMAND_BLOCK_REGISTER_WINDOW_OFFSET & 0FFh = 0 71 mov dh, JRIDE_COMMAND_BLOCK_REGISTER_WINDOW_OFFSET >> 8 72 %else 73 add dx, JRIDE_COMMAND_BLOCK_REGISTER_WINDOW_OFFSET 74 %endif 75 OutputToJrIdeRegister: 76 mov bx, dx 77 mov [cs:bx], al 78 ret 79 ALIGN JUMP_ALIGN 80 OutputALtoIOmappedIdeRegisterInDL: 81 %endif ; MODULE_JRIDE 82 %endif ; MODULE_8BIT_IDE 140 xor dh, dh ; IDE Register index now in DX 83 141 84 mov bl, IDEVARS.wPort 85 OutputALtoIdeRegisterInDLwithIdevarsOffsetToBasePortInBL: 86 call GetIdePortToDX 142 mov bl, [di+DPT_ATA.bDevice] 143 cmp bl, DEVICE_8BIT_XTIDE_REV2 144 je SHORT .ReverseA0andA3fromRegisterIndexInDX 145 jb SHORT OutputALtoRegisterInDX ; Standard IDE controllers and XTIDE rev 1 146 cmp bl, DEVICE_8BIT_JRIDE_ISA 147 jne SHORT .ShlRegisterIndexInDX ; All XT-CF modes 148 ; Fall to .OutputALtoMemoryMappedRegisterInDX 149 150 .OutputALtoMemoryMappedRegisterInDX: 151 mov bx, JRIDE_COMMAND_BLOCK_REGISTER_WINDOW_OFFSET 152 .OutputALtoMemoryMappedRegisterInDXwithWindowOffsetInBX: 153 add bx, dx 154 push ds 155 mov ds, [di+DPT.wBasePort] ; Segment for JR-IDE/ISA 156 mov [bx], al 157 pop ds 158 ret 159 160 .ReverseA0andA3fromRegisterIndexInDX: 161 mov bx, dx 162 mov dl, [cs:bx+g_rgbSwapA0andA3fromIdeRegisterIndex] 163 SKIP2B bx ; Skip shl dx, 1 164 165 .ShlRegisterIndexInDX: 166 shl dx, 1 167 ; Fall to OutputALtoRegisterInDX 168 169 ALIGN JUMP_ALIGN 170 OutputALtoRegisterInDX: 171 add dx, [di+DPT.wBasePort] 172 OutputALtoPortInDX: 87 173 out dx, al 88 174 ret 89 175 90 176 91 ;--------------------------------------------------------------------92 ; IdeIO_InputStatusRegisterToAL93 ; Parameters:94 ; DS:DI: Ptr to DPT (in RAMVARS segment)95 ; Returns:96 ; AL: IDE Status Register contents97 ; Corrupts registers:98 ; BX, DX99 ;--------------------------------------------------------------------100 ALIGN JUMP_ALIGN101 IdeIO_InputStatusRegisterToAL:102 mov dl, STATUS_REGISTER_in103 ; Fall to IdeIO_InputToALfromIdeRegisterInDL104 177 105 ;-------------------------------------------------------------------- 106 ; IdeIO_InputToALfromIdeRegisterInDL 107 ; Parameters: 108 ; DL: IDE Register 109 ; DS:DI: Ptr to DPT (in RAMVARS segment) 110 ; Returns: 111 ; AL: Inputted byte 112 ; Corrupts registers: 113 ; BX, DX 114 ;-------------------------------------------------------------------- 115 IdeIO_InputToALfromIdeRegisterInDL: 116 %ifdef MODULE_8BIT_IDE 117 mov dh, [di+DPT_ATA.bDevice] 118 %ifdef MODULE_JRIDE 119 test dh, dh 120 jnz SHORT .InputToALfromIOmappedIdeRegisterInDL 121 122 %if JRIDE_COMMAND_BLOCK_REGISTER_WINDOW_OFFSET & 0FFh = 0 123 mov dh, JRIDE_COMMAND_BLOCK_REGISTER_WINDOW_OFFSET >> 8 124 %else 125 add dx, JRIDE_COMMAND_BLOCK_REGISTER_WINDOW_OFFSET 126 %endif 127 mov bx, dx 128 mov al, [cs:bx] 129 ret 130 .InputToALfromIOmappedIdeRegisterInDL: 131 %endif ; MODULE_JRIDE 132 %endif ; MODULE_8BIT_IDE 133 mov bl, IDEVARS.wPort 134 call GetIdePortToDX 135 in al, dx 136 ret 178 ; A0 <-> A3 lookup table 179 g_rgbSwapA0andA3fromIdeRegisterIndex: 180 db 0000b ; <-> 0000b, 0 181 db 1000b ; <-> 0001b, 1 182 db 0010b ; <-> 0010b, 2 183 db 1010b ; <-> 0011b, 3 184 db 0100b ; <-> 0100b, 4 185 db 1100b ; <-> 0101b, 5 186 db 0110b ; <-> 0110b, 6 187 db 1110b ; <-> 0111b, 7 137 188 138 139 ;-------------------------------------------------------------------- 140 ; GetIdePortToDX 141 ; Parameters: 142 ; BL: Offset to port in IDEVARS (IDEVARS.wPort or IDEVARS.wPortCtrl) 143 ; DH: Device Type (IDEVARS.bDevice) 144 ; DL: IDE Register 145 ; DS:DI: Ptr to DPT (in RAMVARS segment) 146 ; Returns: 147 ; DX: Source/Destination Port 148 ; Corrupts registers: 149 ; BX 150 ;-------------------------------------------------------------------- 151 ALIGN JUMP_ALIGN 152 GetIdePortToDX: 153 %ifdef MODULE_8BIT_IDE 154 ; Point CS:BX to IDEVARS 155 xor bh, bh 156 add bl, [di+DPT.bIdevarsOffset] ; CS:BX now points port address 157 158 ; Load port address and check if A0 and A3 address lines need to be reversed 159 cmp dh, DEVICE_8BIT_XTIDE_REV1 160 mov dh, bh ; DX now has IDE register offset 161 jae SHORT .ReturnUntranslatedPortInDX ; No need to swap address lines 162 163 ; Exchange address lines A0 and A3 from DL 164 add dx, [cs:bx] ; DX now has port address 165 mov bl, dl ; Port low byte to BL 166 and bl, MASK_A3_AND_A0_ADDRESS_LINES ; Clear all bits except A0 and A3 167 jz SHORT .ReturnTranslatedPortInDX ; A0 and A3 both zeroes, no change needed 168 cmp bl, MASK_A3_AND_A0_ADDRESS_LINES 169 je SHORT .ReturnTranslatedPortInDX ; A0 and A3 both ones, no change needed 170 xor dl, MASK_A3_AND_A0_ADDRESS_LINES ; Invert A0 and A3 171 .ReturnTranslatedPortInDX: 172 ret 173 174 .ReturnUntranslatedPortInDX: 175 add dx, [cs:bx] 176 ret 177 178 %else ; Only standard IDE devices 179 xor bh, bh 180 add bl, [di+DPT.bIdevarsOffset] ; CS:BX now points port address 181 xor dh, dh 182 add dx, [cs:bx] ; DX now has port address 183 ret 184 %endif 189 %endif ; MODULE_8BIT_IDE -
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm
r445 r473 206 206 ALIGN JUMP_ALIGN 207 207 InitializePiovarsInSSBPwithSectorCountInAH: 208 ; Store sizes 208 ; Store sizes and Data Port 209 209 mov [bp+PIOVARS.bSectorsLeft], ah 210 mov ax, [di+DPT.wBasePort] 211 mov [bp+PIOVARS.wDataPort], ax 210 212 eMOVZX ax, [di+DPT_ATA.bBlockSize] 211 213 mov [bp+PIOVARS.wSectorsInBlock], ax … … 214 216 ; Get transfer function based on bus type 215 217 xchg ax, bx ; Lookup table offset to AX 216 mov bl, [di+DPT.bIdevarsOffset] ; CS:BX now points to IDEVARS217 mov dx, [cs:bx+IDEVARS.wPort] ; Load IDE Data port address218 218 mov bl, [di+DPT_ATA.bDevice] 219 219 add bx, ax 220 221 mov [bp+PIOVARS.wDataPort], dx222 220 mov ax, [cs:bx] ; Load offset to transfer function 223 221 mov [bp+PIOVARS.fnXfer], ax … … 225 223 226 224 227 ;--------------------------------------------------------------------228 ; ReadBlockFromXtideRev1 XTIDE rev 1229 ; ReadBlockFromXtideRev2 XTIDE rev 2 or rev 1 with swapped A0 and A3 (chuck-mod)230 ; ReadBlockFrom8bitDataPort CF-XT when using 8-bit PIO231 ; ReadBlockFrom16bitDataPort Normal 16-bit IDE232 ; ReadBlockFrom32bitDataPort VLB/PCI 32-bit IDE233 ; Parameters:234 ; CX: Block size in 512 byte sectors235 ; DX: IDE Data port address236 ; ES:DI: Normalized ptr to buffer to receive data237 ; Returns:238 ; Nothing239 ; Corrupts registers:240 ; AX, BX, CX241 ;--------------------------------------------------------------------242 %ifdef MODULE_8BIT_IDE243 244 ALIGN JUMP_ALIGN245 ReadBlockFromXtideRev1:246 UNROLL_SECTORS_IN_CX_TO_OWORDS247 mov bl, 8 ; Bit mask for toggling data low/high reg248 ALIGN JUMP_ALIGN249 .InswLoop:250 %rep 8 ; WORDs251 XTIDE_INSW252 %endrep253 loop .InswLoop254 ret255 256 ;--------------------------------------------------------------------257 %ifndef USE_186 ; 8086/8088 compatible WORD read258 ALIGN JUMP_ALIGN259 ReadBlockFromXtideRev2:260 UNROLL_SECTORS_IN_CX_TO_OWORDS261 ALIGN JUMP_ALIGN262 .ReadNextOword:263 %rep 8 ; WORDs264 in ax, dx ; Read WORD265 stosw ; Store WORD to [ES:DI]266 %endrep267 loop .ReadNextOword268 ret269 %endif270 271 ;--------------------------------------------------------------------272 %ifdef USE_186273 ALIGN JUMP_ALIGN274 ReadBlockFrom8bitDataPort:275 shl cx, 9 ; Sectors to BYTEs276 rep insb277 ret278 279 %else ; If 8088/8086280 ALIGN JUMP_ALIGN281 ReadBlockFrom8bitDataPort:282 UNROLL_SECTORS_IN_CX_TO_OWORDS283 ALIGN JUMP_ALIGN284 .ReadNextOword:285 %rep 16 ; BYTEs286 in al, dx ; Read BYTE287 stosb ; Store BYTE to [ES:DI]288 %endrep289 loop .ReadNextOword290 ret291 %endif292 %endif ; MODULE_8BIT_IDE293 294 ;--------------------------------------------------------------------295 %ifdef USE_186296 ALIGN JUMP_ALIGN297 ReadBlockFrom16bitDataPort:298 xchg cl, ch ; Sectors to WORDs299 rep insw300 ret301 %endif302 303 ;--------------------------------------------------------------------304 %ifdef USE_AT305 ALIGN JUMP_ALIGN306 ReadBlockFrom32bitDataPort:307 shl cx, 7 ; Sectors to DWORDs308 rep309 db 66h ; Override operand size to 32-bit310 db 6Dh ; INSW/INSD311 ret312 %endif313 314 315 ;--------------------------------------------------------------------316 ; WriteBlockToXtideRev1 XTIDE rev 1317 ; WriteBlockToXtideRev2 XTIDE rev 2 or rev 1 with swapped A0 and A3 (chuck-mod)318 ; WriteBlockTo8bitDataPort XT-CF when using 8-bit PIO319 ; WriteBlockTo16bitDataPort Normal 16-bit IDE320 ; WriteBlockTo32bitDataPort VLB/PCI 32-bit IDE321 ; Parameters:322 ; CX: Block size in 512-byte sectors323 ; DX: IDE Data port address324 ; ES:SI: Normalized ptr to buffer containing data325 ; Returns:326 ; Nothing327 ; Corrupts registers:328 ; AX, BX, CX, DX329 ;--------------------------------------------------------------------330 %ifdef MODULE_8BIT_IDE331 332 ALIGN JUMP_ALIGN333 WriteBlockToXtideRev1:334 push ds335 UNROLL_SECTORS_IN_CX_TO_QWORDS336 mov bl, 8 ; Bit mask for toggling data low/high reg337 push es ; Copy ES...338 pop ds ; ...to DS339 ALIGN JUMP_ALIGN340 .OutswLoop:341 %rep 4 ; WORDs342 XTIDE_OUTSW343 %endrep344 loop .OutswLoop345 pop ds346 ret347 348 ;--------------------------------------------------------------------349 ALIGN JUMP_ALIGN350 WriteBlockToXtideRev2:351 UNROLL_SECTORS_IN_CX_TO_QWORDS352 push ds353 push es ; Copy ES...354 pop ds ; ...to DS355 ALIGN JUMP_ALIGN356 .WriteNextQword:357 %rep 4 ; WORDs358 XTIDE_MOD_OUTSW359 %endrep360 loop .WriteNextQword361 pop ds362 ret363 364 ;--------------------------------------------------------------------365 %ifdef USE_186366 ALIGN JUMP_ALIGN367 WriteBlockTo8bitDataPort:368 shl cx, 9 ; Sectors to BYTEs369 es ; Source is ES segment370 rep outsb371 ret372 373 %else ; If 8088/8086374 ALIGN JUMP_ALIGN375 WriteBlockTo8bitDataPort:376 UNROLL_SECTORS_IN_CX_TO_DWORDS377 push ds378 push es379 pop ds380 ALIGN JUMP_ALIGN381 .WriteNextDword:382 %rep 4 ; BYTEs383 lodsb ; Load BYTE from [DS:SI]384 out dx, al ; Write BYTE385 %endrep386 loop .WriteNextDword387 pop ds388 ret389 %endif390 %endif ; MODULE_8BIT_IDE391 392 ;--------------------------------------------------------------------393 %ifdef USE_AT394 ALIGN JUMP_ALIGN395 WriteBlockTo16bitDataPort:396 xchg cl, ch ; Sectors to WORDs397 es ; Source is ES segment398 rep outsw399 ret400 401 ;--------------------------------------------------------------------402 ALIGN JUMP_ALIGN403 WriteBlockTo32bitDataPort:404 shl cx, 7 ; Sectors to DWORDs405 es ; Source is ES segment406 rep407 db 66h ; Override operand size to 32-bit408 db 6Fh ; OUTSW/OUTSD409 ret410 %endif ; USE_AT411 412 413 225 414 226 ; Lookup tables to get transfer function based on bus type 415 227 ALIGN WORD_ALIGN 416 228 g_rgfnPioRead: 229 %ifdef USE_AT 230 dw IdePioBlock_ReadFrom16bitDataPort ; 0, DEVICE_16BIT_ATA 231 dw IdePioBlock_ReadFrom32bitDataPort ; 1, DEVICE_32BIT_ATA 232 %else 233 dd 0 234 %endif 417 235 %ifdef MODULE_8BIT_IDE 418 dw 0 ; 0, DEVICE_8BIT_JRIDE_ISA 419 dw ReadBlockFrom8bitDataPort ; 1, DEVICE_8BIT_XTCF 420 %ifdef USE_186 421 dw ReadBlockFrom16bitDataPort ; 2, DEVICE_8BIT_XTIDE_REV2 422 %else 423 dw ReadBlockFromXtideRev2 ; 2, DEVICE_8BIT_XTIDE_REV2 236 dw IdePioBlock_ReadFromXtideRev1 ; 2, DEVICE_8BIT_XTIDE_REV1 237 %ifndef USE_AT 238 g_rgfnPioWrite: 424 239 %endif 425 dw ReadBlockFromXtideRev1 ; 3, DEVICE_XTIDE_REV1 426 427 %else 428 times COUNT_OF_8BIT_IDE_DEVICES dw 0 429 %endif 240 dw IdePioBlock_ReadFromXtideRev2 ; 3, DEVICE_8BIT_XTIDE_REV2 241 dw IdePioBlock_ReadFrom8bitDataPort ; 4, DEVICE_8BIT_XTCF_PIO8 242 %endif 243 430 244 %ifdef USE_AT 431 dw ReadBlockFrom16bitDataPort ; 4, DEVICE_16BIT_ATA432 dw ReadBlockFrom32bitDataPort ; 5, DEVICE_32BIT_ATA433 %endif434 435 436 245 g_rgfnPioWrite: 246 dw IdePioBlock_WriteTo16bitDataPort ; 0, DEVICE_16BIT_ATA 247 dw IdePioBlock_WriteTo32bitDataPort ; 1, DEVICE_32BIT_ATA 248 %endif 437 249 %ifdef MODULE_8BIT_IDE 438 dw 0 ; 0, DEVICE_8BIT_JRIDE_ISA 439 dw WriteBlockTo8bitDataPort ; 1, DEVICE_8BIT_XTCF 440 dw WriteBlockToXtideRev2 ; 2, DEVICE_XTIDE_REV2 441 dw WriteBlockToXtideRev1 ; 3, DEVICE_XTIDE_REV1 442 443 %else 444 times COUNT_OF_8BIT_IDE_DEVICES dw 0 445 %endif 446 %ifdef USE_AT 447 dw WriteBlockTo16bitDataPort ; 4, DEVICE_16BIT_ATA 448 dw WriteBlockTo32bitDataPort ; 5, DEVICE_32BIT_ATA 449 %endif 250 dw IdePioBlock_WriteToXtideRev1 ; 2, DEVICE_8BIT_XTIDE_REV1 251 dw IdePioBlock_WriteToXtideRev2 ; 3, DEVICE_8BIT_XTIDE_REV2 252 dw IdePioBlock_WriteTo8bitDataPort ; 4, DEVICE_8BIT_XTCF_PIO8 253 %endif -
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/JrIdeTransfer.asm
r445 r473 28 28 endstruc 29 29 30 SECTOR_ACCESS_WINDOW_SIZE EQU 512 ; 512 bytes 31 30 32 31 33 ; Section containing code … … 37 39 ; AL: IDE command that was used to start the transfer 38 40 ; (all PIO read and write commands including Identify Device) 39 ; ES:SI: Ptr to normalized data buffer 41 ; ES:SI: Ptr to normalized data buffer (SI 0...15) 40 42 ; DS:DI: Ptr to DPT (in RAMVARS segment) 41 43 ; SS:BP: Ptr to IDEPACK … … 49 51 ALIGN JUMP_ALIGN 50 52 JrIdeTransfer_StartWithCommandInAL: 51 push cs ; We push CS here (segment of SAW) and later pop it to DS (reads) or ES (writes) 52 53 ; Initialize PIOVARS 54 xor cx, cx 55 mov [bp+MEMPIOVARS.bSectorsDone], cl 56 mov cl, [bp+IDEPACK.bSectorCount] 57 mov [bp+MEMPIOVARS.bSectorsLeft], cl 58 mov cl, [di+DPT_ATA.bBlockSize] 59 mov [bp+MEMPIOVARS.wSectorsInBlock], cx 53 ; Initialize MEMPIOVARS 54 xchg cx, ax ; IDE command to CL 55 xor ax, ax 56 mov [bp+MEMPIOVARS.bSectorsDone], al 57 mov al, [bp+IDEPACK.bSectorCount] 58 mov [bp+MEMPIOVARS.bSectorsLeft], al 59 mov al, [di+DPT_ATA.bBlockSize] 60 mov [bp+MEMPIOVARS.wSectorsInBlock], ax 60 61 mov [bp+MEMPIOVARS.fpDPT], di 61 62 mov [bp+MEMPIOVARS.fpDPT+2], ds 62 63 64 ; Get far pointer to Sector Access Window 65 mov dx, [di+DPT.wBasePort] 66 cmp BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_JRIDE_ISA 67 jne SHORT .GetSectorAccessWindowForXTCF 68 69 ; Get Sector Access Window for JR-IDE/ISA 70 mov di, JRIDE_SECTOR_ACCESS_WINDOW_OFFSET 71 mov ds, dx ; Segment for JR-IDE/ISA 72 jmp SHORT .SectorAccessWindowLoadedToDSDI 73 74 .GetSectorAccessWindowForXTCF: 75 xor di, di 76 add dl, XTCF_CONTROL_REGISTER 77 in al, dx ; Read high byte for Sector Access Window segment 78 xchg ah, al 79 mov ds, ax 80 63 81 ; Are we reading or writing? 64 test al, 16 ; Bit 4 is cleared on all the read commands but set on 3 of the 4 write commands 82 .SectorAccessWindowLoadedToDSDI: 83 test cl, 16 ; Bit 4 is cleared on all the read commands but set on 3 of the 4 write commands 65 84 jnz SHORT WriteToSectorAccessWindow 66 cmp al, COMMAND_WRITE_MULTIPLE85 cmp cl, COMMAND_WRITE_MULTIPLE 67 86 je SHORT WriteToSectorAccessWindow 68 87 ; Fall to ReadFromSectorAccessWindow … … 71 90 ; ReadFromSectorAccessWindow 72 91 ; Parameters: 73 ; Stack: Segment part of ptr to Sector Access Window92 ; DS:DI: Ptr to Sector Access Window 74 93 ; ES:SI: Normalized ptr to buffer to receive data 75 94 ; SS:BP: Ptr to MEMPIOVARS … … 84 103 ;-------------------------------------------------------------------- 85 104 ReadFromSectorAccessWindow: 86 pop ds ; CS -> DS 87 mov di, si ; ES:DI = destination 88 mov si, JRIDE_SECTOR_ACCESS_WINDOW_OFFSET ; DS:SI = source 89 105 xchg si, di ; DS:SI = source, ES:DI = Destination 90 106 call WaitUntilReadyToTransferNextBlock 91 107 jc SHORT ReturnWithMemoryIOtransferErrorInAH … … 140 156 ; WriteToSectorAccessWindow 141 157 ; Parameters: 142 ; Stack: Segment part of ptr to Sector Access Window158 ; DS:DI: Ptr to Sector Access Window 143 159 ; ES:SI: Normalized ptr to buffer containing data 144 160 ; SS:BP: Ptr to MEMPIOVARS … … 155 171 WriteToSectorAccessWindow: 156 172 push es 157 p opds158 pop es ; CS -> ES159 mov di, JRIDE_SECTOR_ACCESS_WINDOW_OFFSET173 push ds 174 pop es ; ES:DI = Sector Access Window (destination) 175 pop ds ; DS:SI = Ptr to source buffer 160 176 161 177 ; Always poll when writing first block (IRQs are generated for following blocks) … … 205 221 ALIGN JUMP_ALIGN 206 222 .WriteBlock: 207 mov ch, JRIDE_SECTOR_ACCESS_WINDOW_SIZE >> 9223 mov ch, SECTOR_ACCESS_WINDOW_SIZE >> 9 208 224 rep movsw 209 225 mov di, bx ; Reset for next sector … … 232 248 ALIGN JUMP_ALIGN 233 249 .ReadBlock: 234 mov ch, JRIDE_SECTOR_ACCESS_WINDOW_SIZE >> 9250 mov ch, SECTOR_ACCESS_WINDOW_SIZE >> 9 235 251 rep movsw 236 252 mov si, bx ; Reset for next sector … … 261 277 262 278 263 %if JRIDE_SECTOR_ACCESS_WINDOW_SIZE <> 512264 %error " JRIDE_SECTOR_ACCESS_WINDOW_SIZE is no longer equal to 512. JrIdeTransfer.asm needs changes."279 %if SECTOR_ACCESS_WINDOW_SIZE <> 512 280 %error "SECTOR_ACCESS_WINDOW_SIZE is no longer equal to 512. JrIdeTransfer.asm needs changes." 265 281 %endif
Note:
See TracChangeset
for help on using the changeset viewer.