Changeset 363 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Device/IDE
- Timestamp:
- Mar 26, 2012, 4:20:43 PM (13 years ago)
- google:author:
- aitotat@gmail.com
- Location:
- trunk/XTIDE_Universal_BIOS/Src/Device/IDE
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm
r294 r363 56 56 mov [di+DPT.bIdevarsOffset], bp 57 57 mov BYTE [di+DPT_ATA.bSetBlock], 1 ; Block = 1 sector 58 %ifdef MODULE_ADVANCED_ATA 59 call IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI 60 %endif 58 61 %ifdef ASSEMBLE_SHARED_IDE_DEVICE_FUNCTIONS 59 62 call IdeDPT_StoreReversedAddressLinesFlagIfNecessary -
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDPT.asm
r361 r363 14 14 ; CF: Clear, IDE interface only supports hard disks 15 15 ; Corrupts registers: 16 ; AX 16 ; AX, BX, CX, DX 17 17 ;-------------------------------------------------------------------- 18 18 IdeDPT_Finalize: 19 ; Fall to .StoreBlockMode20 19 21 20 ;-------------------------------------------------------------------- … … 34 33 mov ah, [es:si+ATA1.bBlckSize] ; Max block size in sectors 35 34 mov [di+DPT_ATA.wSetAndMaxBlock], ax 36 ; Fall to IdeDPT_StoreReversedAddressLinesFlagIfNecessary 35 36 %ifdef MODULE_ADVANCED_ATA 37 ;-------------------------------------------------------------------- 38 ; .StoreDeviceType 39 ; Parameters: 40 ; DS:DI: Ptr to Disk Parameter Table 41 ; ES:SI: Ptr to 512-byte ATA information read from the drive 42 ; CS:BP: Ptr to IDEVARS for the controller 43 ; Returns: 44 ; Nothing 45 ; Corrupts registers: 46 ; Nothing 47 ;-------------------------------------------------------------------- 48 .StoreDeviceType: 49 call IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI 50 51 ;-------------------------------------------------------------------- 52 ; .StorePioModeAndTimings 53 ; Parameters: 54 ; DS:DI: Ptr to Disk Parameter Table 55 ; ES:SI: Ptr to 512-byte ATA information read from the drive 56 ; CS:BP: Ptr to IDEVARS for the controller 57 ; Returns: 58 ; Nothing 59 ; Corrupts registers: 60 ; AX, CX, DX 61 ;-------------------------------------------------------------------- 62 .StorePioMode: 63 call AtaID_GetMaxPioModeToAXandMinCycleTimeToDX 64 call AtaID_ConvertPioModeFromAXandMinCycleTimeFromDXtoActiveAndRecoveryTime 65 mov [di+DPT_ATA.bPioMode], al 66 mov [di+DPT_ADVANCED_ATA.wMinPioActiveTimeNs], cx 67 mov [di+DPT_ADVANCED_ATA.wMinPioRecoveryTimeNs], dx 68 69 ;-------------------------------------------------------------------- 70 ; .DetectAdvancedIdeController 71 ; Parameters: 72 ; DS:DI: Ptr to Disk Parameter Table 73 ; ES:SI: Ptr to 512-byte ATA information read from the drive 74 ; CS:BP: Ptr to IDEVARS for the controller 75 ; Returns: 76 ; Nothing 77 ; Corrupts registers: 78 ; AX, BX, CX, DX 79 ;-------------------------------------------------------------------- 80 .DetectAdvancedIdeController: 81 mov dx, [cs:bp+IDEVARS.wPort] 82 mov [di+DPT_ADVANCED_ATA.wIdeBasePort], dx 83 call AdvAtaInit_DetectControllerForIdeBaseInDX 84 mov [di+DPT_ADVANCED_ATA.wControllerID], ax ; Store zero if none detected 85 mov [di+DPT_ADVANCED_ATA.wControllerBasePort], cx 86 jnc SHORT .NoAdvancedControllerDetected 87 88 ; Use highest common PIO mode from controller and drive. 89 ; Many VLB controllers support PIO modes up to 2. 90 call AdvAtaInit_GetControllerMaxPioModeToAL 91 jnc SHORT .ChangeTo32bitDevice 92 MIN_U [di+DPT_ATA.bPioMode], al 93 94 ; We have detected 32-bit controller so change Device Type since 95 ; it might have been set to 16-bit on IDEVARS 96 .ChangeTo32bitDevice: 97 mov BYTE [di+DPT_ATA.bDevice], DEVICE_32BIT_ATA 98 99 .NoAdvancedControllerDetected: 100 101 %endif ; MODULE_ADVANCED_ATA 37 102 38 103 ;-------------------------------------------------------------------- … … 42 107 ; CS:BP: Ptr to IDEVARS for the controller 43 108 ; Returns: 44 ; CF: Always clear , we don't support floppies on the IDE inteface109 ; CF: Always clear 45 110 ; Corrupts registers: 46 111 ; Nothing … … 53 118 .SetFlagForSwappedA0andA3: 54 119 or BYTE [di+DPT.bFlagsHigh], FLGH_DPT_REVERSED_A0_AND_A3 55 56 120 .EndDPT: 57 121 clc 58 122 ret 123 124 125 %ifdef MODULE_ADVANCED_ATA 126 ;-------------------------------------------------------------------- 127 ; IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI 128 ; Parameters: 129 ; DS:DI: Ptr to Disk Parameter Table 130 ; CS:BP: Ptr to IDEVARS for the controller 131 ; Returns: 132 ; Nothing 133 ; Corrupts registers: 134 ; AL 135 ;-------------------------------------------------------------------- 136 IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI: 137 mov al, [cs:bp+IDEVARS.bDevice] 138 mov [di+DPT_ATA.bDevice], al 139 ret 140 %endif -
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm
r361 r363 5 5 ; This struct must not be larger than IDEPACK without INTPACK. 6 6 struc PIOVARS 7 .w WordsInBlock resb 2 ; 0, Block size in WORDs8 . wWordsLeft resb 2 ; 2, WORDs left to transfer9 .w WordsDone resb 2 ; 4, Number of sectors xferred10 resb 1 ; 6,7 .wDataPort resb 2 ; 0, IDE Data Port 8 .fnXfer resb 2 ; 2, Offset to transfer function 9 .wSectorsInBlock resb 2 ; 4, Block size in sectors 10 .bSectorsLeft resb 1 ; 6, Sectors left to transfer 11 11 resb 1 ; 7, IDEPACK.bDeviceControl 12 .wDataPort resb 2 ; 8, IDE Data Port 13 .fnXfer resb 2 ; 10, Offset to transfer function 12 .bSectorsDone resb 1 ; 8, Number of sectors xferred 14 13 endstruc 15 14 … … 69 68 xchg si, di ; ES:DI now points buffer 70 69 71 mov cx, [bp+PIOVARS.w WordsInBlock]70 mov cx, [bp+PIOVARS.wSectorsInBlock] ; Max 128 72 71 73 72 ALIGN JUMP_ALIGN 74 73 .ReadNextBlockFromDrive: 75 74 mov dx, [bp+PIOVARS.wDataPort] 76 cmp [bp+PIOVARS. wWordsLeft], cx75 cmp [bp+PIOVARS.bSectorsLeft], cl 77 76 jbe SHORT .ReadLastBlockFromDrive 78 77 call [bp+PIOVARS.fnXfer] … … 84 83 xchg si, di ; ES:DI now points buffer 85 84 86 ; Increment number of successfully read WORDs87 mov cx, [bp+PIOVARS.w WordsInBlock]88 sub [bp+PIOVARS. wWordsLeft], cx89 add [bp+PIOVARS. wWordsDone], cx85 ; Increment number of successfully read sectors 86 mov cx, [bp+PIOVARS.wSectorsInBlock] 87 sub [bp+PIOVARS.bSectorsLeft], cl 88 add [bp+PIOVARS.bSectorsDone], cl 90 89 jmp SHORT .ReadNextBlockFromDrive 91 90 92 91 ALIGN JUMP_ALIGN 93 92 .ReadLastBlockFromDrive: 94 mov c x, [bp+PIOVARS.wWordsLeft]93 mov cl, [bp+PIOVARS.bSectorsLeft] ; CH is already zero 95 94 call [bp+PIOVARS.fnXfer] ; Transfer possibly partial block 96 95 … … 103 102 ; Return number of successfully read sectors 104 103 ReturnWithTransferErrorInAH: 105 mov cx, [bp+PIOVARS.wWordsDone] 106 jc SHORT .ConvertTransferredWordsInCXtoSectors 107 add cx, [bp+PIOVARS.wWordsLeft] ; Never sets CF 108 .ConvertTransferredWordsInCXtoSectors: 109 xchg cl, ch 104 mov cl, [bp+PIOVARS.bSectorsDone] 105 mov ch, 0 ; Preserve CF 110 106 ret 111 107 … … 137 133 jc SHORT ReturnWithTransferErrorInAH 138 134 139 mov cx, [bp+PIOVARS.w WordsInBlock]135 mov cx, [bp+PIOVARS.wSectorsInBlock] ; Max 128 140 136 141 137 ALIGN JUMP_ALIGN 142 138 .WriteNextBlockToDrive: 143 139 mov dx, [bp+PIOVARS.wDataPort] 144 cmp [bp+PIOVARS. wWordsLeft], cx140 cmp [bp+PIOVARS.bSectorsLeft], cl 145 141 jbe SHORT .WriteLastBlockToDrive 146 142 call [bp+PIOVARS.fnXfer] … … 150 146 jc SHORT ReturnWithTransferErrorInAH 151 147 152 ; Increment number of successfully written WORDs153 mov cx, [bp+PIOVARS.w WordsInBlock]154 sub [bp+PIOVARS. wWordsLeft], cx155 add [bp+PIOVARS. wWordsDone], cx148 ; Increment number of successfully written sectors 149 mov cx, [bp+PIOVARS.wSectorsInBlock] 150 sub [bp+PIOVARS.bSectorsLeft], cl 151 add [bp+PIOVARS.bSectorsDone], cl 156 152 jmp SHORT .WriteNextBlockToDrive 157 153 158 154 ALIGN JUMP_ALIGN 159 155 .WriteLastBlockToDrive: 160 mov c x, [bp+PIOVARS.wWordsLeft]156 mov cl, [bp+PIOVARS.bSectorsLeft] ; CH is already zero 161 157 %ifdef USE_186 162 158 push CheckErrorsAfterTransferringLastBlock … … 183 179 InitializePiovarsInSSBPwithSectorCountInAH: 184 180 ; Store sizes 185 xor al, al 186 mov [bp+PIOVARS.wWordsLeft], ax 187 mov ah, [di+DPT_ATA.bSetBlock] 188 mov [bp+PIOVARS.wWordsInBlock], ax 189 cbw 190 mov [bp+PIOVARS.wWordsDone], ax ; Zero 181 mov [bp+PIOVARS.bSectorsLeft], ah 182 eMOVZX ax, BYTE [di+DPT_ATA.bSetBlock] 183 mov [bp+PIOVARS.wSectorsInBlock], ax 184 mov [bp+PIOVARS.bSectorsDone], ah ; Zero 191 185 192 186 ; Get transfer function based on bus type … … 194 188 mov bl, [di+DPT.bIdevarsOffset] ; CS:BX now points to IDEVARS 195 189 mov dx, [cs:bx+IDEVARS.wPort] ; Load IDE Data port address 190 %ifdef MODULE_ADVANCED_ATA 191 mov bl, [di+DPT_ATA.bDevice] 192 %else 196 193 mov bl, [cs:bx+IDEVARS.bDevice] ; Load device type to BX 194 %endif 197 195 add bx, ax 196 198 197 mov [bp+PIOVARS.wDataPort], dx 199 198 mov ax, [cs:bx] ; Load offset to transfer function … … 208 207 ; ReadBlockFrom32bitDataPort VLB/PCI 32-bit IDE 209 208 ; Parameters: 210 ; CX: Block size in WORDs209 ; CX: Block size in 512 byte sectors 211 210 ; DX: IDE Data port address 212 211 ; ES:DI: Normalized ptr to buffer to receive data … … 218 217 ALIGN JUMP_ALIGN 219 218 ReadBlockFromXtideRev1: 220 eSHR_IM cx, 2 ; Loop unrolling219 UNROLL_SECTORS_IN_CX_TO_QWORDS 221 220 mov bx, 8 ; Bit mask for toggling data low/high reg 222 221 ALIGN JUMP_ALIGN … … 233 232 ALIGN JUMP_ALIGN 234 233 ReadBlockFromXtideRev2: 235 times 2 shr cx, 1 ; WORD count to QWORD count234 UNROLL_SECTORS_IN_CX_TO_QWORDS 236 235 ALIGN JUMP_ALIGN 237 236 .ReadNextQword: … … 251 250 ALIGN JUMP_ALIGN 252 251 ReadBlockFrom16bitDataPort: 252 xchg cl, ch ; Sectors to WORDs 253 253 rep 254 254 db 6Dh ; INSW (we want this in XT build) … … 258 258 ALIGN JUMP_ALIGN 259 259 ReadBlockFrom32bitDataPort: 260 shr cx, 1 ; WORD count to DWORD count 260 db 0C1h ; SHL 261 db 0E1h ; CX 262 db 7 ; 7 (Sectors to DWORDs) 261 263 rep 262 264 db 66h ; Override operand size to 32-bit … … 272 274 ; WriteBlockTo32bitDataPort VLB/PCI 32-bit IDE 273 275 ; Parameters: 274 ; CX: Block size in WORDs276 ; CX: Block size in 512-byte sectors 275 277 ; DX: IDE Data port address 276 278 ; ES:SI: Normalized ptr to buffer containing data … … 284 286 push ds 285 287 push bx 286 eSHR_IM cx, 2 ; Loop unrolling288 UNROLL_SECTORS_IN_CX_TO_QWORDS 287 289 mov bx, 8 ; Bit mask for toggling data low/high reg 288 290 push es ; Copy ES... … … 302 304 ALIGN JUMP_ALIGN 303 305 WriteBlockToXtideRev2: 306 UNROLL_SECTORS_IN_CX_TO_QWORDS 304 307 push ds 305 eSHR_IM cx, 2 ; Loop unrolling306 308 push es ; Copy ES... 307 309 pop ds ; ...to DS … … 320 322 ALIGN JUMP_ALIGN 321 323 WriteBlockToFastXtide: 322 times 2 shr cx, 1 ; WORD count to QWORD count324 UNROLL_SECTORS_IN_CX_TO_QWORDS 323 325 push ds 324 326 push es … … 342 344 ALIGN JUMP_ALIGN 343 345 WriteBlockTo16bitDataPort: 346 xchg cl, ch ; Sectors to WORDs 344 347 es ; Source is ES segment 345 348 rep … … 350 353 ALIGN JUMP_ALIGN 351 354 WriteBlockTo32bitDataPort: 352 shr cx, 1 ; WORD count to DWORD count 355 db 0C1h ; SHL 356 db 0E1h ; CX 357 db 7 ; 7 (Sectors to DWORDs) 353 358 es ; Source is ES segment 354 359 rep
Note:
See TracChangeset
for help on using the changeset viewer.