Ignore:
Timestamp:
May 6, 2012, 2:34:35 PM (13 years ago)
Author:
aitotat@…
google:author:
aitotat@gmail.com
Message:

Changes to XTIDE Universal BIOS:

  • IDE transfers now properly return number of sectors transferred when no errors.
  • Tweaked L-CHS parameters for LBA drives.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/LbaAssist.asm

    r376 r419  
    2929; with a maximum of 8.4G available.
    3030;
    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.
    4036;
    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
    4938; 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.
    5440;
    5541; LbaAssist_ConvertSectorCountFromBXDXAXtoLbaAssistedCHSinDXAXBLBH:
     
    6753    push    si
    6854
    69     ; Value A = Total sector count / 63
     55    ; Value CH = Total sector count / 63
    7056    xor     cx, cx
    71     push    cx      ; Push zero for bits 48...63
     57    push    cx                          ; Push zero for bits 48...63
    7258    push    bx
    7359    push    dx
    74     push    ax                      ; 64-bit sector count now in stack
     60    push    ax                          ; 64-bit sector count now in stack
    7561    mov     cl, LBA_ASSIST_SPT
    76     mov     bp, sp                  ; SS:BP now points sector count
    77     call    Math_DivQWatSSBPbyCX    ; Temporary value A now in stack
     62    mov     bp, sp                      ; SS:BP now points sector count
     63    call    Math_DivQWatSSBPbyCX        ; Temporary value A now in stack
    7864
    79     ; BX = Number of heads =  A / 1024
     65    ; BX:DX:AX = Value CH - 1
    8066    mov     ax, [bp]
    8167    mov     dx, [bp+2]
    8268    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
    8374    call    Size_DivideSizeInBXDXAXby1024andIncrementMagnitudeInCX
     75    add     ax, BYTE 1                  ; Add 1
     76    adc     dx, bx                      ; BX = 0
    8477
    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)
    8779    test    dx, dx                      ; 65536 or more heads?
    88     jnz     SHORT .GetNumberOfCylinders
    89     mov     cx, 128                     ; Half BX for rounding up
    90 .FindMostSignificantBitForHeadSize:
     80    jnz     SHORT .LimitHeadsTo255
     81    mov     cx, 16                      ; Min number of heads
     82.CompareNextValidNumberOfHeads:
    9183    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
    9693
    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
    10095    call    Math_DivQWatSSBPbyCX
    10196    mov     ax, [bp]
     
    10499    ; Return LBA assisted CHS
    105100    add     sp, BYTE 8                  ; Clean stack
    106     sub     bl, bh                      ; Limit heads to 255
    107     mov     bh, LBA_ASSIST_SPT
    108101    pop     si
    109102    pop     bp
Note: See TracChangeset for help on using the changeset viewer.