Changeset 242 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Device/IDE
- Timestamp:
- Feb 10, 2012, 3:12:40 AM (13 years ago)
- google:author:
- krille_n_@hotmail.com
- Location:
- trunk/XTIDE_Universal_BIOS/Src/Device/IDE
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDPT.asm
r160 r242 14 14 ; Nothing 15 15 ; Corrupts registers: 16 ; AX , BX, CX, DX16 ; AX 17 17 ;-------------------------------------------------------------------- 18 18 IdeDPT_Finalize: … … 28 28 ; Nothing 29 29 ; Corrupts registers: 30 ; Nothing30 ; AX 31 31 ;-------------------------------------------------------------------- 32 32 .StoreBlockMode: -
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm
r238 r242 35 35 ALIGN JUMP_ALIGN 36 36 IdeTransfer_StartWithCommandInAL: 37 mov ah, [bp+IDEPACK.bSectorCount]38 39 37 ; Are we reading or writing? 40 38 test al, 16 ; Bit 4 is cleared on all the read commands but set on 3 of the 4 write commands 41 jnz SHORT .PrepareToWriteDataFromESSI 39 mov ah, [bp+IDEPACK.bSectorCount] 40 jnz SHORT WriteToDrive 42 41 cmp al, COMMAND_WRITE_MULTIPLE 43 je SHORT .PrepareToWriteDataFromESSI 44 45 ; Prepare to read data to ESSI 46 mov bx, g_rgfnPioRead 47 call InitializePiovarsInSSBPwithSectorCountInAH 48 xchg si, di 49 jmp SHORT ReadFromDrive 50 51 ALIGN JUMP_ALIGN 52 .PrepareToWriteDataFromESSI: 53 mov bx, g_rgfnPioWrite 54 call InitializePiovarsInSSBPwithSectorCountInAH 55 ; Fall to WriteToDrive 56 57 58 ;-------------------------------------------------------------------- 59 ; WriteToDrive 60 ; Parameters: 42 je SHORT WriteToDrive 43 ; Fall to ReadFromDrive 44 45 ;-------------------------------------------------------------------- 46 ; ReadFromDrive 47 ; Parameters: 48 ; AH: Number of sectors to transfer (1...128) 49 ; ES:SI: Normalized ptr to buffer to receive data 61 50 ; DS:DI: Ptr to DPT (in RAMVARS segment) 62 ; ES:SI: Normalized ptr to buffer containing data63 51 ; SS:BP: Ptr to PIOVARS 64 52 ; Returns: 53 ; DS:DI: Ptr to DPT (in RAMVARS segment) 65 54 ; AH: BIOS Error code 66 55 ; CX: Number of successfully transferred sectors … … 70 59 ; AL, BX, DX, SI, ES 71 60 ;-------------------------------------------------------------------- 61 ReadFromDrive: 62 ; Prepare to read data to ESSI 63 mov bx, g_rgfnPioRead 64 call InitializePiovarsInSSBPwithSectorCountInAH 65 66 ; Wait until drive is ready to transfer 67 call IdeWait_IRQorDRQ ; Wait until ready to transfer 68 jc SHORT ReturnWithTransferErrorInAH 69 xchg si, di ; ES:DI now points buffer 70 71 mov cx, [bp+PIOVARS.wWordsInBlock] 72 73 ALIGN JUMP_ALIGN 74 .ReadNextBlockFromDrive: 75 mov dx, [bp+PIOVARS.wDataPort] 76 cmp [bp+PIOVARS.wWordsLeft], cx 77 jbe SHORT .ReadLastBlockFromDrive 78 call [bp+PIOVARS.fnXfer] 79 80 ; Wait until ready for next block and check for errors 81 xchg di, si ; DS:DI now points DPT 82 call IdeWait_IRQorDRQ ; Wait until ready to transfer 83 jc SHORT ReturnWithTransferErrorInAH 84 xchg si, di ; ES:DI now points buffer 85 86 ; Increment number of successfully read WORDs 87 mov cx, [bp+PIOVARS.wWordsInBlock] 88 sub [bp+PIOVARS.wWordsLeft], cx 89 add [bp+PIOVARS.wWordsDone], cx 90 jmp SHORT .ReadNextBlockFromDrive 91 92 ALIGN JUMP_ALIGN 93 .ReadLastBlockFromDrive: 94 mov cx, [bp+PIOVARS.wWordsLeft] 95 call [bp+PIOVARS.fnXfer] ; Transfer possibly partial block 96 97 ; Check for errors in last block 98 mov di, si ; DS:DI now points DPT 99 CheckErrorsAfterTransferringLastBlock: 100 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRDY) 101 call IdeWait_PollStatusFlagInBLwithTimeoutInBH 102 103 ; Return number of successfully read sectors 104 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 110 ret 111 112 113 ;-------------------------------------------------------------------- 114 ; WriteToDrive 115 ; Parameters: 116 ; AH: Number of sectors to transfer (1...128) 117 ; DS:DI: Ptr to DPT (in RAMVARS segment) 118 ; ES:SI: Normalized ptr to buffer containing data 119 ; SS:BP: Ptr to PIOVARS 120 ; Returns: 121 ; AH: BIOS Error code 122 ; CX: Number of successfully transferred sectors 123 ; CF: 0 if transfer succesfull 124 ; 1 if any error 125 ; Corrupts registers: 126 ; AL, BX, DX, SI, ES 127 ;-------------------------------------------------------------------- 128 ALIGN JUMP_ALIGN 72 129 WriteToDrive: 130 ; Prepare to write data from ESSI 131 mov bx, g_rgfnPioWrite 132 call InitializePiovarsInSSBPwithSectorCountInAH 133 73 134 ; Always poll when writing first block (IRQs are generated for following blocks) 74 135 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRQ) … … 76 137 jc SHORT ReturnWithTransferErrorInAH 77 138 139 mov cx, [bp+PIOVARS.wWordsInBlock] 140 78 141 ALIGN JUMP_ALIGN 79 142 .WriteNextBlockToDrive: 80 mov cx, [bp+PIOVARS.wWordsInBlock]81 143 mov dx, [bp+PIOVARS.wDataPort] 82 144 cmp [bp+PIOVARS.wWordsLeft], cx … … 89 151 90 152 ; Increment number of successfully written WORDs 91 mov ax, [bp+PIOVARS.wWordsInBlock]92 sub [bp+PIOVARS.wWordsLeft], ax93 add [bp+PIOVARS.wWordsDone], ax153 mov cx, [bp+PIOVARS.wWordsInBlock] 154 sub [bp+PIOVARS.wWordsLeft], cx 155 add [bp+PIOVARS.wWordsDone], cx 94 156 jmp SHORT .WriteNextBlockToDrive 95 157 … … 107 169 108 170 ;-------------------------------------------------------------------- 109 ; ReadFromDrive110 ; Parameters:111 ; ES:DI: Normalized ptr to buffer to recieve data112 ; DS:SI: Ptr to DPT (in RAMVARS segment)113 ; SS:BP: Ptr to PIOVARS114 ; Returns:115 ; DS:DI: Ptr to DPT (in RAMVARS segment)116 ; AH: BIOS Error code117 ; CX: Number of successfully transferred sectors118 ; CF: 0 if transfer succesfull119 ; 1 if any error120 ; Corrupts registers:121 ; AL, BX, DX, SI, ES122 ;--------------------------------------------------------------------123 ALIGN JUMP_ALIGN124 ReadFromDrive:125 ; Wait until drive is ready to transfer126 xchg di, si ; DS:DI now points DPT127 call IdeWait_IRQorDRQ ; Wait until ready to transfer128 jc SHORT ReturnWithTransferErrorInAH129 xchg si, di ; ES:DI now points buffer130 131 ALIGN JUMP_ALIGN132 .ReadNextBlockFromDrive:133 mov cx, [bp+PIOVARS.wWordsInBlock]134 mov dx, [bp+PIOVARS.wDataPort]135 cmp [bp+PIOVARS.wWordsLeft], cx136 jbe SHORT .ReadLastBlockFromDrive137 call [bp+PIOVARS.fnXfer]138 139 ; Wait until ready for next block and check for errors140 xchg di, si ; DS:DI now points DPT141 call IdeWait_IRQorDRQ ; Wait until ready to transfer142 jc SHORT ReturnWithTransferErrorInAH143 xchg si, di ; ES:DI now points buffer144 145 ; Increment number of successfully read WORDs146 mov ax, [bp+PIOVARS.wWordsInBlock]147 sub [bp+PIOVARS.wWordsLeft], ax148 add [bp+PIOVARS.wWordsDone], ax149 jmp SHORT .ReadNextBlockFromDrive150 151 ALIGN JUMP_ALIGN152 .ReadLastBlockFromDrive:153 mov cx, [bp+PIOVARS.wWordsLeft]154 call [bp+PIOVARS.fnXfer] ; Transfer possibly partial block155 156 ; Check for errors in last block157 mov di, si ; DS:DI now points DPT158 CheckErrorsAfterTransferringLastBlock:159 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRDY)160 call IdeWait_PollStatusFlagInBLwithTimeoutInBH161 162 ; Return number of successfully read sectors163 ReturnWithTransferErrorInAH:164 mov cx, [bp+PIOVARS.wWordsDone]165 jc SHORT .ConvertTransferredWordsInCXtoSectors166 add cx, [bp+PIOVARS.wWordsLeft] ; Never sets CF167 .ConvertTransferredWordsInCXtoSectors:168 xchg cl, ch169 ret170 171 172 ;--------------------------------------------------------------------173 171 ; InitializePiovarsInSSBPwithSectorCountInAH 174 172 ; Parameters: … … 180 178 ; Nothing 181 179 ; Corrupts registers: 182 ; AX, BX, CX,DX180 ; AX, BX, DX 183 181 ;-------------------------------------------------------------------- 184 182 ALIGN JUMP_ALIGN … … 187 185 xor al, al 188 186 mov [bp+PIOVARS.wWordsLeft], ax 187 mov ah, [di+DPT_ATA.bSetBlock] 188 mov [bp+PIOVARS.wWordsInBlock], ax 189 189 cbw 190 190 mov [bp+PIOVARS.wWordsDone], ax ; Zero 191 mov ah, [di+DPT_ATA.bSetBlock]192 mov [bp+PIOVARS.wWordsInBlock], ax193 191 194 192 ; Get transfer function based on bus type 195 193 xchg ax, bx ; Lookup table offset to AX 196 eMOVZX bx, BYTE [di+DPT.bIdevarsOffset]; CS:BX now points to IDEVARS194 mov bl, [di+DPT.bIdevarsOffset] ; CS:BX now points to IDEVARS 197 195 mov dx, [cs:bx+IDEVARS.wPort] ; Load IDE Data port address 198 196 mov bl, [cs:bx+IDEVARS.bDevice] ; Load device type to BX 199 197 add bx, ax 198 mov [bp+PIOVARS.wDataPort], dx 200 199 mov ax, [cs:bx] ; Load offset to transfer function 201 mov [bp+PIOVARS.wDataPort], dx202 200 mov [bp+PIOVARS.fnXfer], ax 203 201 ret … … 213 211 ; CX: Block size in WORDs 214 212 ; DX: IDE Data port address 215 ; ES:DI: Normalized ptr to buffer to rec ieve data213 ; ES:DI: Normalized ptr to buffer to receive data 216 214 ; Returns: 217 215 ; Nothing … … 236 234 SingleByteRead: 237 235 %ifdef USE_186 ; INS instruction available 236 dec cx ; Avoid overflowing CX on a 128 sector transfer 238 237 shl cx, 1 ; WORD count to BYTE count 238 inc cx 239 239 rep insb 240 insb 240 241 %else ; If 8088/8086 241 242 shr cx, 1 ; WORD count to DWORD count … … 328 329 SingleByteWrite: 329 330 %ifdef USE_186 ; OUTS instruction available 331 dec cx ; Avoid overflowing CX on a 128 sector transfer 330 332 shl cx, 1 ; WORD count to BYTE count 333 inc cx 331 334 es ; Source is ES segment 332 335 rep outsb 336 es outsb 333 337 %else ; If 8088/8086 334 338 shr cx, 1 ; WORD count to DWORD count … … 386 390 387 391 388 389 392 ; Lookup tables to get transfer function based on bus type 390 393 ALIGN WORD_ALIGN
Note:
See TracChangeset
for help on using the changeset viewer.