Changeset 419 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/LbaAssist.asm
- Timestamp:
- May 6, 2012, 2:34:35 PM (13 years ago)
- google:author:
- aitotat@gmail.com
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/LbaAssist.asm
r376 r419 29 29 ; with a maximum of 8.4G available. 30 30 ; 31 ; total LBAs (as obtained by words 60+61) 32 ; divided by 63 (sectors per track) (save as value A) 33 ; Sub 1 from A 34 ; divide A by 1024 + truncate. 35 ; == total number of heads to use. 36 ; add 1 37 ; this value must be either 16, 32, 64, 128, or 256 (round up) 38 ; then take the value A above and divide by # of heads 39 ; to get the # of cylinders to use. 31 ; If cylinders > 8192 32 ; Variable CH = Total Sectors / 63 33 ; Divide (CH 1) by 1024 (as an assembler bitwise right shift) and add 1 34 ; Round the result up to the nearest of 16, 32, 64, 128 and 255. This is the value to be used for the number of heads. 35 ; Divide CH by the number of heads. This is the value to be used for the number of cylinders. 40 36 ; 41 ; 42 ; so a LBA28 drive will have 268,435,456 as maximum LBAs 43 ; 44 ; 10000000h / 63 = 410410h (total cylinders or tracks) 45 ; 410410h / 1024 = 1041h, which is way more than 256 heads, but 256 is max. 46 ; 410410h / 256 = 4104h cylinders 47 ; 48 ; there's a wealth of information at: http://www.mossywell.com/boot-sequence 37 ; There's a wealth of information at: http://www.mossywell.com/boot-sequence 49 38 ; they show a slightly different approach to LBA assist calulations, but 50 ; the method here provides compatibility with phoenix BIOS 51 ; 52 ; we're using the values from 60+61 here because we're topping out at 8.4G 53 ; anyway, so there's no need to use the 48bit LBA values. 39 ; the method here provides compatibility with phoenix BIOS. 54 40 ; 55 41 ; LbaAssist_ConvertSectorCountFromBXDXAXtoLbaAssistedCHSinDXAXBLBH: … … 67 53 push si 68 54 69 ; Value A= Total sector count / 6355 ; Value CH = Total sector count / 63 70 56 xor cx, cx 71 push cx ; Push zero for bits 48...6357 push cx ; Push zero for bits 48...63 72 58 push bx 73 59 push dx 74 push ax ; 64-bit sector count now in stack60 push ax ; 64-bit sector count now in stack 75 61 mov cl, LBA_ASSIST_SPT 76 mov bp, sp ; SS:BP now points sector count77 call Math_DivQWatSSBPbyCX ; Temporary value A now in stack62 mov bp, sp ; SS:BP now points sector count 63 call Math_DivQWatSSBPbyCX ; Temporary value A now in stack 78 64 79 ; BX = Number of heads = A / 102465 ; BX:DX:AX = Value CH - 1 80 66 mov ax, [bp] 81 67 mov dx, [bp+2] 82 68 mov bx, [bp+4] 69 sub ax, BYTE 1 ; Subtract 1 70 sbb dx, BYTE 0 71 sbb bx, BYTE 0 72 73 ; DX:AX = Number of heads = ((Value CH - 1) / 1024) + 1 83 74 call Size_DivideSizeInBXDXAXby1024andIncrementMagnitudeInCX 75 add ax, BYTE 1 ; Add 1 76 adc dx, bx ; BX = 0 84 77 85 ; Heads must be 16, 32, 64, 128 or 256 (round up) 86 mov bx, 256 ; Max number of heads 78 ; Heads must be 16, 32, 64, 128 or 255 (round up to the nearest) 87 79 test dx, dx ; 65536 or more heads? 88 jnz SHORT . GetNumberOfCylinders89 mov cx, 1 28 ; Half BX for rounding up90 . FindMostSignificantBitForHeadSize:80 jnz SHORT .LimitHeadsTo255 81 mov cx, 16 ; Min number of heads 82 .CompareNextValidNumberOfHeads: 91 83 cmp ax, cx 92 jae SHORT .GetNumberOfCylinders 93 shr cx, 1 94 shr bx, 1 ; Halve number of heads 95 jmp SHORT .FindMostSignificantBitForHeadSize 84 jbe SHORT .NumberOfHeadsNowInCX 85 shl cx, 1 ; Double number of heads 86 test ch, ch ; Reached 256 heads? 87 jnz SHORT .CompareNextValidNumberOfHeads 88 .LimitHeadsTo255: 89 mov cx, 255 90 .NumberOfHeadsNowInCX: 91 mov bx, cx ; Number of heads are returned in BL 92 mov bh, LBA_ASSIST_SPT ; Sectors per Track 96 93 97 ; DX:AX = Number of cylinders = A / number of heads 98 .GetNumberOfCylinders: 99 mov cx, bx 94 ; DX:AX = Number of cylinders = Value CH (without - 1) / number of heads 100 95 call Math_DivQWatSSBPbyCX 101 96 mov ax, [bp] … … 104 99 ; Return LBA assisted CHS 105 100 add sp, BYTE 8 ; Clean stack 106 sub bl, bh ; Limit heads to 255107 mov bh, LBA_ASSIST_SPT108 101 pop si 109 102 pop bp
Note:
See TracChangeset
for help on using the changeset viewer.