Ignore:
Timestamp:
May 9, 2012, 7:12:53 PM (12 years ago)
Author:
aitotat@…
google:author:
aitotat@gmail.com
Message:

Changes to XTIDE Universal BIOS:

  • Addressing modes are now NORMAL, LARGE and LBA.
  • L-CHS parameters are now generated differently for drives with 8192 or less cylinders.
File:
1 edited

Legend:

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

    r411 r421  
    3333;       ES:     BDA Segment
    3434;   Returns:
    35 ;       DL:     Drive number for new drive
    3635;       DS:DI:  Ptr to Disk Parameter Table (if successful)
    3736;       CF:     Cleared if DPT created successfully
     
    8180%endif
    8281    mov     [di+DPT.wFlags], ax
    83     ; Fall to .StoreAddressing
    84 
    85 ;--------------------------------------------------------------------
    86 ; .StoreAddressing
     82    ; Fall to .StoreCHSparametersAndAddressingMode
     83
     84;--------------------------------------------------------------------
     85; .StoreCHSparametersAndAddressingMode
    8786;   Parameters:
    8887;       DS:DI:  Ptr to Disk Parameter Table
     
    9493;       AX, BX, CX, DX
    9594;--------------------------------------------------------------------
    96 .StoreAddressing:
     95.StoreCHSparametersAndAddressingMode:
    9796    ; Check if CHS defined in ROMVARS
    9897    call    AccessDPT_GetPointerToDRVPARAMStoCSBX
    99     test    byte [cs:bx+DRVPARAMS.wFlags], FLG_DRVPARAMS_USERCHS    ; User specified CHS?
    100     jnz     SHORT .StoreUserDefinedPCHS
    101 
     98    test    byte [cs:bx+DRVPARAMS.wFlags], FLG_DRVPARAMS_USERCHS    ; User specified P-CHS?
     99    jz      SHORT .AutodetectPCHSvalues
     100
     101    ; Use DRVPARAMS P-CHS values instead of autodetected
     102    mov     ax, [cs:bx+DRVPARAMS.wCylinders]
     103    mov     bx, [cs:bx+DRVPARAMS.wHeadsAndSectors]
     104    call    AtaGeometry_GetLCHStoAXBLBHfromPCHSinAXBLBH
     105    jmp     SHORT .StoreLCHStoDPT
     106
     107    ; Get L-CHS parameters and addressing mode
     108.AutodetectPCHSvalues:
     109    call    AtaGeometry_GetLCHStoAXBLBHfromAtaInfoInESSI
     110
     111.StoreLCHStoDPT:
     112    eSHL_IM dl, ADDRESSING_MODE_FIELD_POSITION
     113    or      cl, dl
     114    or      [di+DPT.bFlagsLow], cl      ; Shift count and addressing mode
     115    mov     [di+DPT.wLchsCylinders], ax
     116    mov     [di+DPT.wLchsHeadsAndSectors], bx
     117
     118    ; Store P-CHS to DPT
     119    call    AtaGeometry_GetPCHStoAXBLBHfromAtaInfoInESSI
     120    mov     [di+DPT.bPchsHeads], bl
     121%ifdef MODULE_EBIOS
     122    mov     [di+DPT.wPchsCylinders], ax
     123    mov     [di+DPT.bPchsSectorsPerTrack], bh
     124    ; Fall to .StoreNumberOfLbaSectors
     125
     126;--------------------------------------------------------------------
     127; .StoreNumberOfLbaSectors
     128;   Parameters:
     129;       DS:DI:  Ptr to Disk Parameter Table
     130;       ES:SI:  Ptr to 512-byte ATA information read from the drive
     131;       CS:BP:  Ptr to IDEVARS for the controller
     132;   Returns:
     133;       Nothing
     134;   Corrupts registers:
     135;       AX, BX, CX, DX
     136;--------------------------------------------------------------------
    102137    ; Check if LBA supported
    103     call    AtaID_GetPCHStoAXBLBHfromAtaInfoInESSI
    104138    test    BYTE [es:si+ATA1.wCaps+1], A1_wCaps_LBA>>8
    105     jz      SHORT .StoreCHSfromAXBHBL       ; Small old drive with CHS addressing only
    106 
    107     ; Store LBA 28/48 addressing and total sector count
    108     call    AtaID_GetTotalSectorCountToBXDXAXfromAtaInfoInESSI
    109     call    StoreLbaAddressingAndTotalSectorCountFromBXDXAX
    110 
    111     ; Replace sector count with user defined if necessary
     139    jz      SHORT .NoLbaSupportedSoNoEBIOS
     140
     141    ; Store LBA 28/48 total sector count
     142    call    AtaGeometry_GetLbaSectorCountToBXDXAXfromAtaInfoInESSI
     143    call    StoreLba48AddressingFromCLandTotalSectorCountFromBXDXAX
     144
     145    ; Load user defined LBA
    112146    call    AccessDPT_GetPointerToDRVPARAMStoCSBX
    113147    test    BYTE [cs:bx+DRVPARAMS.wFlags], FLG_DRVPARAMS_USERLBA
     
    126160    jae     SHORT .KeepTotalSectorsFromAtaID
    127161.StoreUserDefinedSectorCountToDPT:
    128     call    StoreLbaAddressingAndTotalSectorCountFromBXDXAX
    129 
    130     ; Calculate L-CHS for old INT 13h
     162    xor     cx, cx      ; Always LBA28 for user defined values
     163    call    StoreLba48AddressingFromCLandTotalSectorCountFromBXDXAX
     164
    131165.KeepTotalSectorsFromAtaID:
    132     mov     bx, [di+DPT.twLbaSectors+4]     ; Restore BX
    133     call    LbaAssist_ConvertSectorCountFromBXDXAXtoLbaAssistedCHSinDXAXBLBH
    134     mov     [di+DPT.bLbaHeads], bl
    135     jmp     SHORT .StoreBlockMode
    136 
    137 ;--------------------------------------------------------------------
    138 ; .StoreUserDefinedPCHS
    139 ;   Parameters:
    140 ;       DS:DI:  Ptr to Disk Parameter Table
    141 ;       ES:SI:  Ptr to 512-byte ATA information read from the drive
    142 ;       CS:BP:  Ptr to IDEVARS for the controller
    143 ;   Returns:
    144 ;       AX:     Number of P-CHS cylinders
    145 ;       BH:     Number of P-CHS sectors per track
    146 ;       BL:     Number of P-CHS heads
    147 ;   Corrupts registers:
    148 ;       Nothing
    149 ;--------------------------------------------------------------------
    150 .StoreUserDefinedPCHS:
    151     call    AccessDPT_GetPointerToDRVPARAMStoCSBX
    152     mov     ax, [cs:bx+DRVPARAMS.wCylinders]
    153     mov     bx, [cs:bx+DRVPARAMS.wHeadsAndSectors]
    154     ; Fall to .StoreCHSfromAXBHBL
    155 
    156 ;--------------------------------------------------------------------
    157 ; .StoreCHSfromAXBHBL
    158 ;   Parameters:
    159 ;       AX:     Number of P-CHS cylinders
    160 ;       BH:     Number of P-CHS sectors per track
    161 ;       BL:     Number of P-CHS heads
    162 ;       DS:DI:  Ptr to Disk Parameter Table
    163 ;       ES:SI:  Ptr to 512-byte ATA information read from the drive
    164 ;       CS:BP:  Ptr to IDEVARS for the controller
    165 ;   Returns:
    166 ;       AX:     Number of P-CHS cylinders
    167 ;       BH:     Number of P-CHS sectors per track
    168 ;       BL:     Number of P-CHS heads
    169 ;   Corrupts registers:
    170 ;       CX
    171 ;--------------------------------------------------------------------
    172 .StoreCHSfromAXBHBL:
    173     push    ax
    174     push    bx
    175     call    AccessDPT_ShiftPCHinAXBLtoLCH   ; Get number of bits to shift
    176     pop     bx
    177     pop     ax
    178     jcxz    .StorePCHSfromAXDX              ; Small drive so use L-CHS addressing
    179 
    180     ; Store P-CHS addressing mode and number of bits to shift in L-CHS to P-CHS translation
    181     or      cl, ADDRESSING_MODE_PCHS<<ADDRESSING_MODE_FIELD_POSITION
    182     or      [di+DPT.bFlagsLow], cl
    183     ; Fall to .StoreChsFromAXBLBH
    184 
    185 ;--------------------------------------------------------------------
    186 ; .StoreChsFromAXBLBH
    187 ;   Parameters:
    188 ;       AX:     Number of P-CHS cylinders
    189 ;       BH:     Number of P-CHS sectors per track
    190 ;       BL:     Number of P-CHS heads
    191 ;       DS:DI:  Ptr to Disk Parameter Table
    192 ;       ES:SI:  Ptr to 512-byte ATA information read from the drive
    193 ;       CS:BP:  Ptr to IDEVARS for the controller
    194 ;   Returns:
    195 ;       Nothing
    196 ;   Corrupts registers:
    197 ;       Nothing
    198 ;--------------------------------------------------------------------
    199 .StorePCHSfromAXDX:
    200     mov     [di+DPT.wPchsCylinders], ax
    201     mov     [di+DPT.wPchsHeadsAndSectors], bx
     166.NoLbaSupportedSoNoEBIOS:
     167%endif ; MODULE_EBIOS
    202168    ; Fall to .StoreBlockMode
    203169
     
    268234
    269235
    270 ;--------------------------------------------------------------------
    271 ; StoreLbaAddressingAndTotalSectorCountFromBXDXAX
     236%ifdef MODULE_EBIOS
     237;--------------------------------------------------------------------
     238; StoreLba48AddressingFromCLandTotalSectorCountFromBXDXAX
    272239;   Parameters:
    273240;       BX:DX:AX:   Total Sector Count
     241;       CL:         FLGL_DPT_LBA48 if LBA48 supported
    274242;       DS:DI:      Ptr to Disk Parameter Table
    275243;   Returns:
    276244;       Nothing
    277245;   Corrupts registers:
    278 ;       CX
    279 ;--------------------------------------------------------------------
    280 StoreLbaAddressingAndTotalSectorCountFromBXDXAX:
     246;       CL
     247;--------------------------------------------------------------------
     248StoreLba48AddressingFromCLandTotalSectorCountFromBXDXAX:
     249    or      cl, FLGL_DPT_LBA_AND_EBIOS_SUPPORTED
     250    and     BYTE [di+DPT.bFlagsLow], ~FLGL_DPT_LBA48
     251    or      [di+DPT.bFlagsLow], cl
    281252    mov     [di+DPT.twLbaSectors], ax
    282253    mov     [di+DPT.twLbaSectors+2], dx
    283254    mov     [di+DPT.twLbaSectors+4], bx
    284 
    285 %ifdef MODULE_EBIOS
    286     and     BYTE [di+DPT.bFlagsLow], ~MASKL_DPT_ADDRESSING_MODE
    287     test    bx, bx
    288     jnz     SHORT .SetLba48AddressingToDPT  ; Must be LBA48
    289 
    290     ; Drives can report at most 0FFF FFFFh LBA28 sectors according to ATA specification.
    291     ; That is (2^28)-1 so we can simply check if DH is zero or not.
    292     test    dh, dh
    293     jz      SHORT .SetLba28AddressingToDPT
    294 .SetLba48AddressingToDPT:
    295     or      BYTE [di+DPT.bFlagsLow], ADDRESSING_MODE_LBA48<<ADDRESSING_MODE_FIELD_POSITION
    296 .SetLba28AddressingToDPT:
    297 %endif
    298     or      BYTE [di+DPT.bFlagsLow], ADDRESSING_MODE_LBA28<<ADDRESSING_MODE_FIELD_POSITION
    299255    ret
     256%endif ; MODULE_EBIOS
Note: See TracChangeset for help on using the changeset viewer.