Changeset 324 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Initialization
- 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/Initialization/AtaID.asm
r181 r324 5 5 ; Section containing code 6 6 SECTION .text 7 8 ;--------------------------------------------------------------------9 ; LBA assist calculation:10 ; this is how to fit a big drive into INT13's skimpy size requirements,11 ; with a maximum of 8.4G available.12 ;13 ; total LBAs (as obtained by words 60+61)14 ; divided by 63 (sectors per track) (save as value A)15 ; Sub 1 from A16 ; divide A by 1024 + truncate.17 ; == total number of heads to use.18 ; add 119 ; this value must be either 16, 32, 64, 128, or 256 (round up)20 ; then take the value A above and divide by # of heads21 ; to get the # of cylinders to use.22 ;23 ;24 ; so a LBA28 drive will have 268,435,456 as maximum LBAs25 ;26 ; 10000000h / 63 = 410410h (total cylinders or tracks)27 ; 410410h / 1024 = 1041h, which is way more than 256 heads, but 256 is max.28 ; 410410h / 256 = 4104h cylinders29 ;30 ; there's a wealth of information at: http://www.mossywell.com/boot-sequence31 ; they show a slightly different approach to LBA assist calulations, but32 ; the method here provides compatibility with phoenix BIOS33 ;34 ; we're using the values from 60+61 here because we're topping out at 8.4G35 ; anyway, so there's no need to use the 48bit LBA values.36 ;37 ; AtaID_GetLbaAssistedCHStoDXAXBLBH:38 ; Parameters:39 ; BX:DX:AX: Total number of sectors40 ; Returns:41 ; DX:AX: Number of cylinders42 ; BH: Number of sectors per track (always 63)43 ; BL: Number of heads (16, 32, 64, 128 or 255)44 ; Corrupts registers:45 ; CX46 ;--------------------------------------------------------------------47 AtaID_GetLbaAssistedCHStoDXAXBLBH:48 push bp49 push si50 51 ; Value A = Total sector count / 6352 xor cx, cx53 push cx ; Push zero for bits 48...6354 push bx55 push dx56 push ax ; 64-bit sector count now in stack57 mov cl, LBA_ASSIST_SPT58 mov bp, sp ; SS:BP now points sector count59 call Math_DivQWatSSBPbyCX ; Temporary value A now in stack60 61 ; BX = Number of heads = A / 102462 mov ax, [bp]63 mov dx, [bp+2]64 mov bx, [bp+4]65 call Size_DivideSizeInBXDXAXby1024andIncrementMagnitudeInCX66 67 ; Heads must be 16, 32, 64, 128 or 256 (round up)68 mov bx, 256 ; Max number of heads69 test dx, dx ; 65536 or more heads?70 jnz SHORT .GetNumberOfCylinders71 mov cx, 128 ; Half BX for rounding up72 .FindMostSignificantBitForHeadSize:73 cmp ax, cx74 jae SHORT .GetNumberOfCylinders75 shr cx, 176 shr bx, 1 ; Halve number of heads77 jmp SHORT .FindMostSignificantBitForHeadSize78 79 ; DX:AX = Number of cylinders = A / number of heads80 .GetNumberOfCylinders:81 mov cx, bx82 call Math_DivQWatSSBPbyCX83 mov ax, [bp]84 mov dx, [bp+2] ; Cylinders now in DX:AX85 86 ; Return LBA assisted CHS87 add sp, BYTE 8 ; Clean stack88 sub bl, bh ; Limit heads to 25589 mov bh, LBA_ASSIST_SPT90 pop si91 pop bp92 ret93 94 7 95 8 ;--------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.