Changeset 363 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm
- Timestamp:
- Mar 26, 2012, 4:20:43 PM (13 years ago)
- google:author:
- aitotat@gmail.com
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.