Changeset 558 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDmaBlock.asm
- Timestamp:
- Jun 23, 2013, 3:52:31 PM (12 years ago)
- google:author:
- krille_n_@hotmail.com
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDmaBlock.asm
r551 r558 1 1 ; Project name : XTIDE Universal BIOS 2 ; Description : IDE Read/Write functions for transferring 3 ; block using DMA.4 ; These functions should only be called from IdeTransfer.asm. 2 ; Description : IDE Read/Write functions for transferring block using DMA. 3 ; These functions should only be called from IdeTransfer.asm. 4 5 5 ; Modified JJP 05-Jun-13 6 6 7 ; 7 8 ; XTIDE Universal BIOS and Associated Tools … … 84 85 shl cx, 9 ; CX = Block size in BYTEs 85 86 %else 86 xchg 87 xchg cl, ch 87 88 shl cx, 1 88 89 %endif … … 92 93 neg ax ; 2s compliment 93 94 94 ; if DI was zero carry flag will be cleared (and set otherwise)95 ; If DI was zero carry flag will be cleared (and set otherwise) 95 96 ; When DI is zero only one transfer is required since we've limited the 96 97 ; XT-CFv3 block size to 32k 97 jnc .TransferLastDmaPageWithSizeInCX98 jnc SHORT .TransferLastDmaPageWithSizeInCX 98 99 99 100 ; CF was set, so DI != 0 and we might need one or two transfers 100 101 cmp cx, ax ; if we won't cross a physical page boundary... 101 jbe SHORT .TransferLastDmaPageWithSizeInCX ; ...perform the transfer in one operation102 jbe SHORT .TransferLastDmaPageWithSizeInCX ; ...perform the transfer in one operation 102 103 103 104 ; Calculate how much we can transfer on first and second rounds 104 xchg cx, ax; CX = BYTEs for first page105 sub ax, cx 106 push 105 xchg cx, ax ; CX = BYTEs for first page 106 sub ax, cx ; AX = BYTEs for second page 107 push ax ; Save bytes for second transfer on stack 107 108 108 109 ; Transfer first DMA page … … 126 127 ; ES:DI updated (CX is added) 127 128 ; Corrupts registers: 128 ; AX 129 ; AX, CX 129 130 ;-------------------------------------------------------------------- 130 131 ALIGN JUMP_ALIGN … … 161 162 sti ; Enable interrupts 162 163 164 ; Update physical address in ES:DI - since IO might need several calls through this function either from here 165 ; if crossing a physical page boundary, or from IdeTransfer.asm if requested sectors was > PIOVARS.wSectorsInBlock 166 ; We update the pointer here (before the actual transfer) to avoid having to save the byte count on the stack 167 mov ax, es ; copy physical page address to ax 168 add di, cx ; add requested bytes to di 169 adc al, 0 ; and increment physical page address, if required 170 mov es, ax ; and save it back in es 171 163 172 ; XT-CF transfers 16 bytes at a time. We need to manually start transfer for every block by writing (anything) 164 173 ; to the XT-CFv3 Control Register, which raises DRQ thereby passing system control to the 8237 DMA controller. … … 169 178 170 179 %if 0 ; Slow DMA code - works by checking 8237 status register after each 16-byte transfer, until it reports TC has been raised. 171 ;ALIGN JUMP_ALIGN 172 ;.TransferNextBlock: 173 ; cli ; We want no ISR to read DMA Status Register before we do 174 ; out dx, al ; Transfer up to 16 bytes to/from XT-CF card 175 ; in al, STATUS_REGISTER_DMA8_in 176 ; sti 177 ; test al, FLG_CH3_HAS_REACHED_TERMINAL_COUNT 178 ; jz SHORT .TransferNextBlock ; All bytes transferred? 179 %endif ; Slow DMA code 180 181 %if 1 ; Fast DMA code - perform computed number of transfers, then check DMA status register to be sure 182 push cx ; need byte count to update pointer at the end 180 ALIGN JUMP_ALIGN 181 .TransferNextBlock: 182 cli ; We want no ISR to read DMA Status Register before we do 183 out dx, al ; Transfer up to 16 bytes to/from XT-CF card 184 in al, STATUS_REGISTER_DMA8_in 185 sti 186 test al, FLG_CH3_HAS_REACHED_TERMINAL_COUNT 187 jz SHORT .TransferNextBlock ; All bytes transferred? 188 %else ; Fast DMA code - perform computed number of transfers, then check DMA status register to be sure 183 189 add cx, BYTE 15 ; We'll divide transfers in 16-byte atomic transfers, 184 190 eSHR_IM cx, 4 ; so include any partial block, which will be terminated … … 191 197 test al, FLG_CH3_HAS_REACHED_TERMINAL_COUNT ; ... for channel 3 terminal count 192 198 jz SHORT .TransferNextDmaBlock ; If not set, get more bytes 193 pop cx ; get back requested bytes 194 %endif ; Fast DMA code 195 196 ; Update physical address in ES:DI - since IO might need several calls through this function either from here 197 ; if crossing a physical page boundary, and from IdeTransfer.asm if requested sectors was > PIOVARS.wSectorsInBlock 198 mov ax, es ; copy physical page address to ax 199 add di, cx ; add requested bytes to di 200 adc al, 0 ; and increment physical page address, if required 201 mov es, ax ; and save it back in es 199 %endif 202 200 203 201 ret
Note:
See TracChangeset
for help on using the changeset viewer.