Changeset 545 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdePioBlock.asm
- Timestamp:
- Apr 19, 2013, 11:44:35 AM (12 years ago)
- google:author:
- aitotat@gmail.com
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdePioBlock.asm
r526 r545 20 20 ; 21 21 22 ; Modified by JJP for XT-CFv3 support, Mar-13 23 22 24 ; Section containing code 23 25 SECTION .text 26 27 28 ; -------------------------------------------------------------------------------------------------- 29 ; 30 ; READ routines follow 31 ; 32 ; -------------------------------------------------------------------------------------------------- 33 24 34 25 35 %ifdef MODULE_8BIT_IDE … … 50 60 51 61 ;-------------------------------------------------------------------- 52 ; IdePioBlock_ReadFromXtideRev2 or rev 1 with swapped A0 and A3 (chuck-mod) 53 ; Parameters: 54 ; CX: Block size in 512 byte sectors 55 ; DX: IDE Data port address 62 ; IdePioBlock_ReadFrom8bitDataPort 63 ; 64 ; 8-bit PIO from a single data port. 65 ; 66 ; Parameters: 67 ; CX: Block size in 512 byte sectors 68 ; DX: IDE Data port address 56 69 ; ES:DI: Normalized ptr to buffer to receive data 57 70 ; Returns: … … 60 73 ; AX, BX, CX 61 74 ;-------------------------------------------------------------------- 62 %ifndef USE_186 ; 8086/8088 compatible WORD read 63 64 ALIGN JUMP_ALIGN 65 IdePioBlock_ReadFromXtideRev2: 75 ALIGN JUMP_ALIGN 76 IdePioBlock_ReadFrom8bitDataPort: 77 %ifdef USE_186 78 shl cx, 9 ; Sectors to BYTEs 79 rep insb 80 ret 81 %else ; If 8088/8086 82 UNROLL_SECTORS_IN_CX_TO_OWORDS 83 ALIGN JUMP_ALIGN 84 .ReadNextOword: 85 %rep 16 ; BYTEs 86 in al, dx ; Read BYTE 87 stosb ; Store BYTE to [ES:DI] 88 %endrep 89 loop .ReadNextOword 90 ret 91 %endif 92 93 %endif ; MODULE_8BIT_IDE 94 95 96 ;-------------------------------------------------------------------- 97 ; IdePioBlock_ReadFrom16bitDataPort 98 ; 99 ; 16-bit PIO from a single data port. 100 ; 101 ; Parameters: 102 ; CX: Block size in 512 byte sectors 103 ; DX: IDE Data port address 104 ; ES:DI: Normalized ptr to buffer to receive data 105 ; Returns: 106 ; Nothing 107 ; Corrupts registers: 108 ; AX, BX, CX 109 ;-------------------------------------------------------------------- 110 ALIGN JUMP_ALIGN 111 IdePioBlock_ReadFrom16bitDataPort: 112 %ifdef USE_186 113 xchg cl, ch ; Sectors to WORDs 114 rep insw 115 ret 116 117 %else ; If 8088/8086 66 118 UNROLL_SECTORS_IN_CX_TO_OWORDS 67 119 ALIGN JUMP_ALIGN 68 120 .ReadNextOword: 69 121 %rep 8 ; WORDs 70 in ax, dx ; Read WORD 71 stosw ; Store WORD to [ES:DI] 72 %endrep 73 loop .ReadNextOword 74 ret 75 122 in ax, dx ; Read BYTE 123 stosw ; Store BYTE to [ES:DI] 124 %endrep 125 loop .ReadNextOword 126 ret 76 127 %endif 77 128 78 79 ;--------------------------------------------------------------------80 ; IdePioBlock_ReadFrom8bitDataPort CF-XT when using 8-bit PIO81 ; Parameters:82 ; CX: Block size in 512 byte sectors83 ; DX: IDE Data port address84 ; ES:DI: Normalized ptr to buffer to receive data85 ; Returns:86 ; Nothing87 ; Corrupts registers:88 ; AX, BX, CX89 ;--------------------------------------------------------------------90 ALIGN JUMP_ALIGN91 IdePioBlock_ReadFrom8bitDataPort:92 %ifdef USE_18693 shl cx, 9 ; Sectors to BYTEs94 rep insb95 ret96 97 %else ; If 8088/808698 UNROLL_SECTORS_IN_CX_TO_OWORDS99 ALIGN JUMP_ALIGN100 .ReadNextOword:101 %rep 16 ; BYTEs102 in al, dx ; Read BYTE103 stosb ; Store BYTE to [ES:DI]104 %endrep105 loop .ReadNextOword106 ret107 %endif108 109 110 ;--------------------------------------------------------------------111 ; IdePioBlock_WriteToXtideRev1112 ; Parameters:113 ; CX: Block size in 512-byte sectors114 ; DX: IDE Data port address115 ; ES:SI: Normalized ptr to buffer containing data116 ; Returns:117 ; Nothing118 ; Corrupts registers:119 ; AX, BX, CX, DX120 ;--------------------------------------------------------------------121 ALIGN JUMP_ALIGN122 IdePioBlock_WriteToXtideRev1:123 push ds124 UNROLL_SECTORS_IN_CX_TO_QWORDS125 mov bl, 8 ; Bit mask for toggling data low/high reg126 push es ; Copy ES...127 pop ds ; ...to DS128 ALIGN JUMP_ALIGN129 .OutswLoop:130 %rep 4 ; WORDs131 XTIDE_OUTSW132 %endrep133 loop .OutswLoop134 pop ds135 ret136 137 138 ;--------------------------------------------------------------------139 ; IdePioBlock_WriteToXtideRev2 or rev 1 with swapped A0 and A3 (chuck-mod)140 ; Parameters:141 ; CX: Block size in 512-byte sectors142 ; DX: IDE Data port address143 ; ES:SI: Normalized ptr to buffer containing data144 ; Returns:145 ; Nothing146 ; Corrupts registers:147 ; AX, BX, CX, DX148 ;--------------------------------------------------------------------149 ALIGN JUMP_ALIGN150 IdePioBlock_WriteToXtideRev2:151 UNROLL_SECTORS_IN_CX_TO_QWORDS152 push ds153 push es ; Copy ES...154 pop ds ; ...to DS155 ALIGN JUMP_ALIGN156 .WriteNextQword:157 %rep 4 ; WORDs158 XTIDE_MOD_OUTSW159 %endrep160 loop .WriteNextQword161 pop ds162 ret163 164 165 ;--------------------------------------------------------------------166 ; IdePioBlock_WriteTo8bitDataPort XT-CF when using 8-bit PIO167 ; Parameters:168 ; CX: Block size in 512-byte sectors169 ; DX: IDE Data port address170 ; ES:SI: Normalized ptr to buffer containing data171 ; Returns:172 ; Nothing173 ; Corrupts registers:174 ; AX, BX, CX, DX175 ;--------------------------------------------------------------------176 ALIGN JUMP_ALIGN177 IdePioBlock_WriteTo8bitDataPort:178 179 %ifdef USE_186180 shl cx, 9 ; Sectors to BYTEs181 es ; Source is ES segment182 rep outsb183 ret184 185 %else ; If 8088/8086186 UNROLL_SECTORS_IN_CX_TO_DWORDS187 push ds188 push es189 pop ds190 ALIGN JUMP_ALIGN191 .WriteNextDword:192 %rep 4 ; BYTEs193 lodsb ; Load BYTE from [DS:SI]194 out dx, al ; Write BYTE195 %endrep196 loop .WriteNextDword197 pop ds198 ret199 %endif200 201 %endif ; MODULE_8BIT_IDE202 203 204 ;--------------------------------------------------------------------205 ; IdePioBlock_ReadFromXtideRev2 (when 80186/80188 instructions are available)206 ; IdePioBlock_ReadFrom16bitDataPort Normal 16-bit IDE207 ; IdePioBlock_ReadFrom32bitDataPort VLB/PCI 32-bit IDE208 ; Parameters:209 ; CX: Block size in 512 byte sectors210 ; DX: IDE Data port address211 ; ES:DI: Normalized ptr to buffer to receive data212 ; Returns:213 ; Nothing214 ; Corrupts registers:215 ; AX, BX, CX216 ;--------------------------------------------------------------------217 ALIGN JUMP_ALIGN218 %ifdef USE_186219 %ifdef MODULE_8BIT_IDE220 IdePioBlock_ReadFromXtideRev2:221 %endif222 %endif223 IdePioBlock_ReadFrom16bitDataPort:224 xchg cl, ch ; Sectors to WORDs225 rep226 db 6Dh ; INSW227 ret228 129 229 130 ;-------------------------------------------------------------------- … … 239 140 240 141 241 ;-------------------------------------------------------------------- 242 ; IdePioBlock_WriteTo16bitDataPort Normal 16-bit IDE 142 143 ; -------------------------------------------------------------------------------------------------- 144 ; 145 ; WRITE routines follow 146 ; 147 ; -------------------------------------------------------------------------------------------------- 148 149 %ifdef MODULE_8BIT_IDE 150 151 ;-------------------------------------------------------------------- 152 ; IdePioBlock_WriteToXtideRev1 153 ; Parameters: 154 ; CX: Block size in 512-byte sectors 155 ; DX: IDE Data port address 156 ; ES:SI: Normalized ptr to buffer containing data 157 ; Returns: 158 ; Nothing 159 ; Corrupts registers: 160 ; AX, BX, CX, DX 161 ;-------------------------------------------------------------------- 162 ALIGN JUMP_ALIGN 163 IdePioBlock_WriteToXtideRev1: 164 push ds 165 UNROLL_SECTORS_IN_CX_TO_QWORDS 166 mov bl, 8 ; Bit mask for toggling data low/high reg 167 push es ; Copy ES... 168 pop ds ; ...to DS 169 ALIGN JUMP_ALIGN 170 .OutswLoop: 171 %rep 4 ; WORDs 172 XTIDE_OUTSW 173 %endrep 174 loop .OutswLoop 175 pop ds 176 ret 177 178 179 ;-------------------------------------------------------------------- 180 ; IdePioBlock_WriteToXtideRev2 or rev 1 with swapped A0 and A3 (chuck-mod) 181 ; Parameters: 182 ; CX: Block size in 512-byte sectors 183 ; DX: IDE Data port address 184 ; ES:SI: Normalized ptr to buffer containing data 185 ; Returns: 186 ; Nothing 187 ; Corrupts registers: 188 ; AX, BX, CX, DX 189 ;-------------------------------------------------------------------- 190 ALIGN JUMP_ALIGN 191 IdePioBlock_WriteToXtideRev2: 192 UNROLL_SECTORS_IN_CX_TO_QWORDS 193 push ds 194 push es ; Copy ES... 195 pop ds ; ...to DS 196 ALIGN JUMP_ALIGN 197 .WriteNextQword: 198 %rep 4 ; WORDs 199 XTIDE_MOD_OUTSW ; special macro 200 %endrep 201 loop .WriteNextQword 202 pop ds 203 ret 204 205 206 ;-------------------------------------------------------------------- 207 ; IdePioBlock_WriteTo8bitDataPort 208 ; Parameters: 209 ; CX: Block size in 512-byte sectors 210 ; DX: IDE Data port address 211 ; ES:SI: Normalized ptr to buffer containing data 212 ; Returns: 213 ; Nothing 214 ; Corrupts registers: 215 ; AX, BX, CX, DX 216 ;-------------------------------------------------------------------- 217 ALIGN JUMP_ALIGN 218 IdePioBlock_WriteTo8bitDataPort: 219 %ifdef USE_186 220 shl cx, 9 ; Sectors to BYTEs 221 es ; Source is ES segment 222 rep outsb 223 ret 224 225 %else ; If 8088/8086 226 UNROLL_SECTORS_IN_CX_TO_QWORDS 227 push ds 228 ;mov ax, es 229 ;mov ds, ax ; move es to ds via ax (does this run faster on 8088?) 230 push es 231 pop ds 232 ALIGN JUMP_ALIGN 233 .WriteNextQword: 234 %rep 8 ; BYTEs 235 lodsb ; Load BYTE from [DS:SI] 236 out dx, al ; Write BYTE 237 %endrep 238 loop .WriteNextQword 239 pop ds 240 ret 241 %endif 242 243 %endif ; MODULE_8BIT_IDE 244 245 246 ;-------------------------------------------------------------------- 247 ; IdePioBlock_WriteTo16bitDataPort Normal 16-bit IDE, XT-CFv3 in BIU Mode 243 248 ; IdePioBlock_WriteTo32bitDataPort VLB/PCI 32-bit IDE 244 249 ; Parameters: 245 ; CX: 246 ; DX: 250 ; CX: Block size in 512-byte sectors 251 ; DX: IDE Data port address 247 252 ; ES:SI: Normalized ptr to buffer containing data 248 253 ; Returns: … … 253 258 ALIGN JUMP_ALIGN 254 259 IdePioBlock_WriteTo16bitDataPort: 260 %ifdef USE_186 255 261 xchg cl, ch ; Sectors to WORDs 256 262 es ; Source is ES segment 257 rep 258 db 6Fh ; OUTSW 259 ret 263 rep outsw 264 ret 265 266 %else ; If 8088/8086 267 UNROLL_SECTORS_IN_CX_TO_QWORDS 268 push ds 269 ;mov ax, es 270 ;mov ds, ax ; move es to ds via ax (does this run faster on 8088?) 271 push es 272 pop ds 273 ALIGN JUMP_ALIGN 274 .WriteNextQword: 275 %rep 4 ; WORDs 276 lodsw ; Load BYTE from [DS:SI] 277 out dx, ax ; Write BYTE 278 %endrep 279 loop .WriteNextQword 280 pop ds 281 ret 282 %endif ; if/else USE_186 260 283 261 284 ;--------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.