Changeset 473 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Device/IDE/JrIdeTransfer.asm
- Timestamp:
- Oct 10, 2012, 6:22:23 PM (13 years ago)
- google:author:
- aitotat@gmail.com
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.