Changeset 324 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm
- Timestamp:
- Mar 11, 2012, 6:45:03 PM (13 years ago)
- google:author:
- aitotat@gmail.com
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm
r231 r324 58 58 59 59 call AccessDPT_GetLbaSectorCountToBXDXAX 60 call A taID_GetLbaAssistedCHStoDXAXBLBH60 call AccessDPT_ConvertSectorCountFromBXDXAXtoLbaAssistedCHSinDXAXBLBH 61 61 test dx, dx 62 62 jnz SHORT .LimitAXtoMaxLCHScylinders … … 157 157 and al, MASKL_DPT_ADDRESSING_MODE 158 158 %endmacro 159 160 161 ;-------------------------------------------------------------------- 162 ; LBA assist calculation: 163 ; this is how to fit a big drive into INT13's skimpy size requirements, 164 ; with a maximum of 8.4G available. 165 ; 166 ; total LBAs (as obtained by words 60+61) 167 ; divided by 63 (sectors per track) (save as value A) 168 ; Sub 1 from A 169 ; divide A by 1024 + truncate. 170 ; == total number of heads to use. 171 ; add 1 172 ; this value must be either 16, 32, 64, 128, or 256 (round up) 173 ; then take the value A above and divide by # of heads 174 ; to get the # of cylinders to use. 175 ; 176 ; 177 ; so a LBA28 drive will have 268,435,456 as maximum LBAs 178 ; 179 ; 10000000h / 63 = 410410h (total cylinders or tracks) 180 ; 410410h / 1024 = 1041h, which is way more than 256 heads, but 256 is max. 181 ; 410410h / 256 = 4104h cylinders 182 ; 183 ; there's a wealth of information at: http://www.mossywell.com/boot-sequence 184 ; they show a slightly different approach to LBA assist calulations, but 185 ; the method here provides compatibility with phoenix BIOS 186 ; 187 ; we're using the values from 60+61 here because we're topping out at 8.4G 188 ; anyway, so there's no need to use the 48bit LBA values. 189 ; 190 ; AccessDPT_ConvertSectorCountFromBXDXAXtoLbaAssistedCHStoDXAXBLBH: 191 ; Parameters: 192 ; BX:DX:AX: Total number of sectors 193 ; Returns: 194 ; DX:AX: Number of cylinders 195 ; BH: Number of sectors per track (always 63) 196 ; BL: Number of heads (16, 32, 64, 128 or 255) 197 ; Corrupts registers: 198 ; CX 199 ;-------------------------------------------------------------------- 200 AccessDPT_ConvertSectorCountFromBXDXAXtoLbaAssistedCHSinDXAXBLBH: 201 push bp 202 push si 203 204 ; Value A = Total sector count / 63 205 xor cx, cx 206 push cx ; Push zero for bits 48...63 207 push bx 208 push dx 209 push ax ; 64-bit sector count now in stack 210 mov cl, LBA_ASSIST_SPT 211 mov bp, sp ; SS:BP now points sector count 212 call Math_DivQWatSSBPbyCX ; Temporary value A now in stack 213 214 ; BX = Number of heads = A / 1024 215 mov ax, [bp] 216 mov dx, [bp+2] 217 mov bx, [bp+4] 218 call Size_DivideSizeInBXDXAXby1024andIncrementMagnitudeInCX 219 220 ; Heads must be 16, 32, 64, 128 or 256 (round up) 221 mov bx, 256 ; Max number of heads 222 test dx, dx ; 65536 or more heads? 223 jnz SHORT .GetNumberOfCylinders 224 mov cx, 128 ; Half BX for rounding up 225 .FindMostSignificantBitForHeadSize: 226 cmp ax, cx 227 jae SHORT .GetNumberOfCylinders 228 shr cx, 1 229 shr bx, 1 ; Halve number of heads 230 jmp SHORT .FindMostSignificantBitForHeadSize 231 232 ; DX:AX = Number of cylinders = A / number of heads 233 .GetNumberOfCylinders: 234 mov cx, bx 235 call Math_DivQWatSSBPbyCX 236 mov ax, [bp] 237 mov dx, [bp+2] ; Cylinders now in DX:AX 238 239 ; Return LBA assisted CHS 240 add sp, BYTE 8 ; Clean stack 241 sub bl, bh ; Limit heads to 255 242 mov bh, LBA_ASSIST_SPT 243 pop si 244 pop bp 245 ret
Note:
See TracChangeset
for help on using the changeset viewer.