Changeset 167 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Device/IDE
- Timestamp:
- Aug 21, 2011, 3:42:15 PM (13 years ago)
- google:author:
- aitotat@gmail.com
- Location:
- trunk/XTIDE_Universal_BIOS/Src/Device/IDE
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm
r160 r167 128 128 129 129 ; Output Sector Address High (only used by LBA48) 130 mov ax, [bp+IDEPACK.wSectorCountHighAndLbaLowExt] 130 xor ax, ax ; Sector Count High always zero since 127 sector limit 131 mov ah, BYTE [bp+IDEPACK.bLbaLowExt] 131 132 mov cx, [bp+IDEPACK.wLbaMiddleAndHighExt] 132 133 call OutputSectorCountAndAddress -
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm
r161 r167 5 5 ; This struct must not be larger than IDEPACK without INTPACK. 6 6 struc PIOVARS 7 .wBlocksLeft resb 2 7 .wBlockLeftAndSectorsInLastBlock: 8 .bBlocksLeft resb 1 9 .bSectorsInLastBlock: resb 1 8 10 .wBlockSize resb 2 ; Block size in WORDs (256...32768) 9 11 .wDataPort resb 2 10 .bSectorsInLastBlock:resb 112 resb 1 11 13 resb 1 ; Offset 7 = IDEPACK.bDeviceControl 12 14 .fnXfer resb 2 ; Offset to transfer function … … 32 34 ALIGN JUMP_ALIGN 33 35 IdeTransfer_StartWithCommandInAL: 34 mov ah, [bp+IDEPACK.bSectorCountHighExt]35 36 36 ; Are we reading or writing? 37 37 test al, 16 ; Bit 4 is cleared on all the read commands but set on 3 of the 4 write commands … … 42 42 ; Prepare to read data to ESSI 43 43 mov bx, g_rgfnPioRead 44 mov al, [bp+IDEPACK.bSectorCount] 45 call InitializePiovarsInSSBPwithSectorCountInAX 44 call InitializePiovarsToSSBPfromIdepackInSSBP 46 45 xchg si, di 46 %ifdef USE_186 47 push ReadFromDriveToESDI 48 jmp Registers_NormalizeESDI 49 %else 47 50 call Registers_NormalizeESDI 48 jmp SHORT ReadFromDrive 51 jmp SHORT ReadFromDriveToESDI 52 %endif 49 53 50 54 ALIGN JUMP_ALIGN 51 55 .PrepareToWriteDataFromESSI: 52 56 mov bx, g_rgfnPioWrite 53 mov al, [bp+IDEPACK.bSectorCount] 54 call InitializePiovarsInSSBPwithSectorCountInAX 57 call InitializePiovarsToSSBPfromIdepackInSSBP 55 58 call Registers_NormalizeESSI 56 ; Fall to WriteToDrive 57 58 59 ;-------------------------------------------------------------------- 60 ; WriteToDrive 59 ; Fall to WriteToDriveFromESSI 60 61 62 ;-------------------------------------------------------------------- 63 ; WriteToDriveFromESSI 61 64 ; Parameters: 62 65 ; DS:DI: Ptr to DPT (in RAMVARS segment) … … 70 73 ; AL, BX, CX, DX, SI, ES 71 74 ;-------------------------------------------------------------------- 72 WriteToDrive :75 WriteToDriveFromESSI: 73 76 ; Always poll when writing first block (IRQs are generated for following blocks) 74 77 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRQ) … … 78 81 .WriteNextBlock: 79 82 mov dx, [bp+PIOVARS.wDataPort] 80 dec WORD [bp+PIOVARS.wBlocksLeft] ; Transferring last (possibly partial) block?83 dec BYTE [bp+PIOVARS.bBlocksLeft] ; Transferring last (possibly partial) block? 81 84 jz SHORT .XferLastBlock ; If so, jump to transfer 82 85 mov cx, [bp+PIOVARS.wBlockSize] ; Load block size in WORDs 83 86 call [bp+PIOVARS.fnXfer] ; Transfer full block 84 85 ; Normalize pointer when necessary86 mov ax, si87 shr ax, 1 ; WORD offset88 add ax, [bp+PIOVARS.wBlockSize]89 jns SHORT .WaitUntilReadyToTransferNextBlock90 call Registers_NormalizeESSI91 92 ALIGN JUMP_ALIGN93 .WaitUntilReadyToTransferNextBlock:94 87 %ifdef USE_186 95 88 push .WriteNextBlock … … 117 110 118 111 ;-------------------------------------------------------------------- 119 ; ReadFromDrive 112 ; ReadFromDriveToESDI 120 113 ; Parameters: 121 114 ; ES:DI: Normalized ptr to buffer to recieve data … … 131 124 ;-------------------------------------------------------------------- 132 125 ALIGN JUMP_ALIGN 133 ReadFromDrive :126 ReadFromDriveToESDI: 134 127 ; Wait until drive is ready to transfer 135 128 xchg di, si ; DS:DI now points DPT 136 129 call IdeWait_IRQorDRQ ; Wait until ready to transfer 137 jc SHORT WriteToDrive .ReturnWithTransferErrorInAH130 jc SHORT WriteToDriveFromESSI.ReturnWithTransferErrorInAH 138 131 xchg si, di ; ES:DI now points buffer 139 132 140 133 ; Transfer full or last (possible partial) block 141 134 mov dx, [bp+PIOVARS.wDataPort] 142 dec WORD [bp+PIOVARS.wBlocksLeft]135 dec BYTE [bp+PIOVARS.bBlocksLeft] 143 136 jz SHORT .XferLastBlock 144 137 mov cx, [bp+PIOVARS.wBlockSize] ; Load block size in WORDs 138 %ifdef USE_186 139 push ReadFromDriveToESDI 140 jmp [bp+PIOVARS.fnXfer] 141 %else 145 142 call [bp+PIOVARS.fnXfer] ; Transfer full block 146 147 ; Normalize pointer when necessary 148 mov ax, di 149 shr ax, 1 ; WORD offset 150 add ax, [bp+PIOVARS.wBlockSize] 151 jns SHORT ReadFromDrive 152 call Registers_NormalizeESDI 153 jmp SHORT ReadFromDrive ; Loop while blocks left 143 jmp SHORT ReadFromDriveToESDI ; Loop while blocks left 144 %endif 154 145 155 146 ALIGN JUMP_ALIGN … … 164 155 165 156 ;-------------------------------------------------------------------- 166 ; InitializePiovarsInSSBPwithSectorCountInAX 167 ; Parameters: 168 ; AX: Number of sectors to transfer (1...65535) 157 ; InitializePiovarsToSSBPfromIdepackInSSBP 158 ; Parameters: 169 159 ; BX: Offset to transfer function lookup table 170 160 ; DS:DI: Ptr to DPT (in RAMVARS segment) 161 ; SS:BP: Ptr to IDEPACK 162 ; Returns: 171 163 ; SS:BP: Ptr to PIOVARS 172 ; Returns:173 ; Nothing174 164 ; Corrupts registers: 175 165 ; AX, BX, CX, DX 176 166 ;-------------------------------------------------------------------- 177 167 ALIGN JUMP_ALIGN 178 InitializePiovars InSSBPwithSectorCountInAX:168 InitializePiovarsToSSBPfromIdepackInSSBP: 179 169 ; Store number of blocks to transfer 180 eMOVZX cx, BYTE [di+DPT_ATA.bSetBlock] ; Block size in sectors 181 xor dx, dx ; DX:AX = Sectors to transfer (1...65535) 182 div cx ; AX = Full blocks to transfer 183 test dx, dx 184 mov dh, cl ; DH = Full block size if no partial blocks to transfer 170 eMOVZX cx, BYTE [di+DPT_ATA.bSetBlock] ; Block size in sectors, zero CH 171 eMOVZX ax, BYTE [bp+IDEPACK.bSectorCount] ; AX = sectors to transfer (1...128) 172 div cl ; AL = Full blocks to transfer 173 test ah, ah ; AH = Sectors in partial block 185 174 jz SHORT .NoPartialBlocksToTransfer 186 inc ax ; Partial block187 mov dh, dl ; DH = Size of partial block in sectors175 inc ax ; Add partial block to total block count 176 SKIP2B dx ; Skip mov ah, cl 188 177 .NoPartialBlocksToTransfer: 189 mov [bp+PIOVARS.wBlocksLeft], ax190 mov [bp+PIOVARS. bSectorsInLastBlock], dh178 mov ah, cl ; Full block size if no partial blocks to transfer 179 mov [bp+PIOVARS.wBlockLeftAndSectorsInLastBlock], ax 191 180 192 181 ; Store block size in WORDs
Note:
See TracChangeset
for help on using the changeset viewer.