Changeset 324 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS


Ignore:
Timestamp:
Mar 11, 2012, 6:45:03 PM (12 years ago)
Author:
aitotat@…
google:author:
aitotat@gmail.com
Message:

Changes to XTIDE Universal BIOS:

  • Boot Menu now displays correct capacity when using user defined LBA.
Location:
trunk/XTIDE_Universal_BIOS
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Inc/ATA_ID.inc

    r277 r324  
    1 ; File name     :   ATA_ID.inc
    2 ; Project name  :   IDE BIOS
    3 ; Created date  :   30.10.2009
    4 ; Last update   :   12.3.2010
    5 ; Author        :   Tomi Tilli
     1; Project name  :   XTIDE Universal BIOS
    62; Description   :   ATA Identify Drive information.
    73%ifndef ATA_ID_INC
     
    5854endstruc
    5955
     56A1_MODEL_NUMBER_LENGTH  EQU 40      ; 40 ASCII characters
     57
    6058; ATA-1 Word 0, General configuration
    6159A1_wGenCfg_NONMAG       EQU (1<<15) ; Reserved for non-magnetic drives
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeError.asm

    r294 r324  
    2929
    3030    ; I don't think anything actually reads these from BDA
    31     push    ds
    32     LOAD_BDA_SEGMENT_TO ds, dx
    33     mov     [HDBDA.wHDStAndErr], ax
    34     pop     ds
     31    ;push   ds
     32    ;LOAD_BDA_SEGMENT_TO    ds, dx
     33    ;mov        [HDBDA.wHDStAndErr], ax
     34    ;pop        ds
    3535
    3636    ; Fall to GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH48h_GetExtendedDriveParameters.asm

    r294 r324  
    4545    mov     WORD [si+EDRIVE_INFO.wFlags], FLG_DMA_BOUNDARY_ERRORS_HANDLED_BY_BIOS
    4646
    47     push    ds  ; Move CS to DS to avoid segment overrides
    48     push    cs
    49     pop     ds
    50 
    51     ; Limit LBA if necessary
    52     test    BYTE [di+DRVPARAMS.wFlags], FLG_DRVPARAMS_USERLBA
    53     jz      SHORT .StoreTotalSectorsFromBXDXAX
    54     test    bx, bx
    55     jnz     SHORT .LimitTotalSectors
    56     cmp     dx, [di+DRVPARAMS.dwMaximumLBA+2]
    57     jb      SHORT .StoreTotalSectorsFromBXDXAX      ; Real size less than max
    58     ja      SHORT .LimitTotalSectors
    59     cmp     ax, [di+DRVPARAMS.dwMaximumLBA]
    60     jbe     SHORT .StoreTotalSectorsFromBXDXAX      ; Real size less than max
    61 
    62 .LimitTotalSectors:
    63     xor     bx, bx
    64     mov     ax, [di+DRVPARAMS.dwMaximumLBA]
    65     mov     dx, [di+DRVPARAMS.dwMaximumLBA+2]
    66 
    67 .StoreTotalSectorsFromBXDXAX:
    68     pop     ds  ; Restore DS from the change above
     47    ; Store total sector count
    6948    mov     [si+EDRIVE_INFO.qwTotalSectors], ax
    7049    xor     ax, ax                                  ; Return with success
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm

    r181 r324  
    55; Section containing code
    66SECTION .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 A
    16 ; divide A by 1024 + truncate.
    17 ; == total number of heads to use.
    18 ; add 1
    19 ; this value must be either 16, 32, 64, 128, or 256 (round up)
    20 ; then take the value A above and divide by # of heads
    21 ; to get the # of cylinders to use.
    22 ;
    23 ;
    24 ; so a LBA28 drive will have 268,435,456 as maximum LBAs
    25 ;
    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 cylinders
    29 ;
    30 ; there's a wealth of information at: http://www.mossywell.com/boot-sequence
    31 ; they show a slightly different approach to LBA assist calulations, but
    32 ; the method here provides compatibility with phoenix BIOS
    33 ;
    34 ; we're using the values from 60+61 here because we're topping out at 8.4G
    35 ; 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 sectors
    40 ;   Returns:
    41 ;       DX:AX:  Number of cylinders
    42 ;       BH:     Number of sectors per track (always 63)
    43 ;       BL:     Number of heads (16, 32, 64, 128 or 255)
    44 ;   Corrupts registers:
    45 ;       CX
    46 ;--------------------------------------------------------------------
    47 AtaID_GetLbaAssistedCHStoDXAXBLBH:
    48     push    bp
    49     push    si
    50 
    51     ; Value A = Total sector count / 63
    52     xor     cx, cx
    53     push    cx      ; Push zero for bits 48...63
    54     push    bx
    55     push    dx
    56     push    ax                      ; 64-bit sector count now in stack
    57     mov     cl, LBA_ASSIST_SPT
    58     mov     bp, sp                  ; SS:BP now points sector count
    59     call    Math_DivQWatSSBPbyCX    ; Temporary value A now in stack
    60 
    61     ; BX = Number of heads =  A / 1024
    62     mov     ax, [bp]
    63     mov     dx, [bp+2]
    64     mov     bx, [bp+4]
    65     call    Size_DivideSizeInBXDXAXby1024andIncrementMagnitudeInCX
    66 
    67     ; Heads must be 16, 32, 64, 128 or 256 (round up)
    68     mov     bx, 256                     ; Max number of heads
    69     test    dx, dx                      ; 65536 or more heads?
    70     jnz     SHORT .GetNumberOfCylinders
    71     mov     cx, 128                     ; Half BX for rounding up
    72 .FindMostSignificantBitForHeadSize:
    73     cmp     ax, cx
    74     jae     SHORT .GetNumberOfCylinders
    75     shr     cx, 1
    76     shr     bx, 1                       ; Halve number of heads
    77     jmp     SHORT .FindMostSignificantBitForHeadSize
    78 
    79     ; DX:AX = Number of cylinders = A / number of heads
    80 .GetNumberOfCylinders:
    81     mov     cx, bx
    82     call    Math_DivQWatSSBPbyCX
    83     mov     ax, [bp]
    84     mov     dx, [bp+2]                  ; Cylinders now in DX:AX
    85 
    86     ; Return LBA assisted CHS
    87     add     sp, BYTE 8                  ; Clean stack
    88     sub     bl, bh                      ; Limit heads to 255
    89     mov     bh, LBA_ASSIST_SPT
    90     pop     si
    91     pop     bp
    92     ret
    93 
    947
    958;--------------------------------------------------------------------
  • trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm

    r231 r324  
    5858
    5959    call    AccessDPT_GetLbaSectorCountToBXDXAX
    60     call    AtaID_GetLbaAssistedCHStoDXAXBLBH
     60    call    AccessDPT_ConvertSectorCountFromBXDXAXtoLbaAssistedCHSinDXAXBLBH
    6161    test    dx, dx
    6262    jnz     SHORT .LimitAXtoMaxLCHScylinders
     
    157157    and     al, MASKL_DPT_ADDRESSING_MODE
    158158%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;--------------------------------------------------------------------
     200AccessDPT_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
  • trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm

    r294 r324  
    8787    jz      SHORT .StoreCHSfromAXBHBL       ; Small old drive with CHS addressing only
    8888
    89     ; Check if 48-bit LBA supported
    90     test    BYTE [es:si+ATA6.wSetSup83+1], A6_wSetSup83_LBA48>>8
    91     jz      SHORT .StoreLBA28addressing
    92     or      BYTE [di+DPT.bFlagsLow], ADDRESSING_MODE_LBA48<<ADDRESSING_MODE_FIELD_POSITION
    93 .StoreLBA28addressing:
    94     or      BYTE [di+DPT.bFlagsLow], ADDRESSING_MODE_LBA28<<ADDRESSING_MODE_FIELD_POSITION
     89    ; Store LBA 28/48 addressing and total sector count
    9590    call    AtaID_GetTotalSectorCountToBXDXAXfromAtaInfoInESSI
    96     mov     [di+DPT.twLbaSectors], ax
    97     mov     [di+DPT.twLbaSectors+2], dx
    98     mov     [di+DPT.twLbaSectors+4], bx
    99     call    AtaID_GetLbaAssistedCHStoDXAXBLBH
     91    call    StoreLbaAddressingAndTotalSectorCountFromBXDXAX
     92
     93    ; Replace sector count with user defined if necessary
     94    call    AccessDPT_GetPointerToDRVPARAMStoCSBX
     95    test    BYTE [cs:bx+DRVPARAMS.wFlags], FLG_DRVPARAMS_USERLBA
     96    jz      SHORT .KeepTotalSectorsFromAtaID
     97    mov     ax, [cs:bx+DRVPARAMS.dwMaximumLBA]
     98    mov     dx, [cs:bx+DRVPARAMS.dwMaximumLBA+2]
     99    xor     bx, bx
     100
     101    ; Compare user defined and ATA-ID sector count and select smaller
     102    cmp     bx, [di+DPT.twLbaSectors+4]
     103    jb      SHORT .StoreUserDefinedSectorCountToDPT
     104    cmp     dx, [di+DPT.twLbaSectors+2]
     105    jb      SHORT .StoreUserDefinedSectorCountToDPT
     106    ja      SHORT .KeepTotalSectorsFromAtaID
     107    cmp     ax, [di+DPT.twLbaSectors]
     108    jae     SHORT .KeepTotalSectorsFromAtaID
     109.StoreUserDefinedSectorCountToDPT:
     110    call    StoreLbaAddressingAndTotalSectorCountFromBXDXAX
     111
     112    ; Calculate L-CHS for old INT 13h
     113.KeepTotalSectorsFromAtaID:
     114    mov     bx, [di+DPT.twLbaSectors+4]     ; Restore BX
     115    call    AccessDPT_ConvertSectorCountFromBXDXAXtoLbaAssistedCHSinDXAXBLBH
    100116    mov     [di+DPT.bLbaHeads], bl
    101117    jmp     SHORT .StoreBlockMode
     
    233249    ret
    234250
     251
     252;--------------------------------------------------------------------
     253; StoreLbaAddressingAndTotalSectorCountFromBXDXAX
     254;   Parameters:
     255;       BX:DX:AX:   Total Sector Count
     256;       DS:DI:      Ptr to Disk Parameter Table
     257;   Returns:
     258;       Nothing
     259;   Corrupts registers:
     260;       CX
     261;--------------------------------------------------------------------
     262StoreLbaAddressingAndTotalSectorCountFromBXDXAX:
     263    mov     [di+DPT.twLbaSectors], ax
     264    mov     [di+DPT.twLbaSectors+2], dx
     265    mov     [di+DPT.twLbaSectors+4], bx
     266
     267    and     BYTE [di+DPT.bFlagsLow], ~MASKL_DPT_ADDRESSING_MODE
     268    test    bx, bx
     269    jnz     SHORT .SetLba48AddressingToDPT
     270    test    dh, 0F0h
     271    jz      SHORT .SetLba28AddressingToDPT
     272.SetLba48AddressingToDPT:
     273    or      BYTE [di+DPT.bFlagsLow], ADDRESSING_MODE_LBA48<<ADDRESSING_MODE_FIELD_POSITION
     274.SetLba28AddressingToDPT:
     275    or      BYTE [di+DPT.bFlagsLow], ADDRESSING_MODE_LBA28<<ADDRESSING_MODE_FIELD_POSITION
     276    ret
Note: See TracChangeset for help on using the changeset viewer.