Changeset 542 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs


Ignore:
Timestamp:
Apr 15, 2013, 4:03:33 PM (12 years ago)
Author:
aitotat@…
google:author:
aitotat@gmail.com
Message:

Changes to XTIDE Universal BIOS:

  • Fixed a bug that allowed EBIOS functions for user defined CHS.
  • Simplified user defined CHS and LBA setup a little.
Location:
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs
Files:
4 edited

Legend:

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

    r526 r542  
    2222
    2323;--------------------------------------------------------------------
    24 ; AccessDPT_GetDriveSelectByteForOldInt13hToAL
    25 ; AccessDPT_GetDriveSelectByteForEbiosToAL
     24; AccessDPT_GetDriveSelectByteToAL
    2625;   Parameters:
    2726;       DS:DI:  Ptr to Disk Parameter Table
     
    3231;--------------------------------------------------------------------
    3332ALIGN JUMP_ALIGN
    34 AccessDPT_GetDriveSelectByteForOldInt13hToAL:
     33AccessDPT_GetDriveSelectByteToAL:
    3534    mov     al, [di+DPT.bFlagsLow]
    36     test    al, FLGL_DPT_ASSISTED_LBA
    37     jnz     SHORT GetDriveSelectByteForAssistedLBAtoAL
    38 
    39     and     al, FLG_DRVNHEAD_DRV    ; Clear all but drive select bit
     35    and     al, FLGL_DPT_SLAVE | FLGL_DPT_LBA
    4036    or      al, MASK_DRVNHEAD_SET   ; Bits set to 1 for old drives
    41     ret
    42 
    43 %ifdef MODULE_EBIOS
    44 ALIGN JUMP_ALIGN
    45 AccessDPT_GetDriveSelectByteForEbiosToAL:
    46     mov     al, [di+DPT.bFlagsLow]
    47     ; Fall to GetDriveSelectByteForAssistedLBAtoAL
    48 %endif ; MODULE_EBIOS
    49 
    50 ALIGN JUMP_ALIGN
    51 GetDriveSelectByteForAssistedLBAtoAL:
    52     and     al, FLG_DRVNHEAD_DRV    ; Master / Slave select
    53     or      al, FLG_DRVNHEAD_LBA | MASK_DRVNHEAD_SET
    5437    ret
    5538
  • trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AtaGeometry.asm

    r526 r542  
    6666;--------------------------------------------------------------------
    6767; AtaGeometry_GetLCHStoAXBLBHfromAtaInfoInESSIandTranslateModeInDX
    68 ; AtaGeometry_GetLCHStoAXBLBHfromPCHSinAXBLBHandTranslateModeInDX
    6968;   Parameters:
    7069;       DX:     Wanted translate mode or TRANSLATEMODE_AUTO to autodetect
     
    8180AtaGeometry_GetLCHStoAXBLBHfromAtaInfoInESSIandTranslateModeInDX:
    8281    call    AtaGeometry_GetPCHStoAXBLBHfromAtaInfoInESSI
    83     ; Fall to AtaGeometry_GetLCHStoAXBLBHfromPCHSinAXBLBHandTranslateModeInDX
    84 
    85 AtaGeometry_GetLCHStoAXBLBHfromPCHSinAXBLBHandTranslateModeInDX:
     82
    8683    ; Check if user defined translate mode
    8784    dec     dx                      ; Set ZF if TRANSLATEMODE_LARGE, SF if TRANSLATEMODE_NORMAL
  • trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CompatibleDPT.asm

    r541 r542  
    107107    xor     dx, dx                      ; Clear for checksum
    108108    mov     ax, [si+DPT.wLchsCylinders]
    109     MIN_U   ax, MAX_LCHS_CYLINDERS      ; Our DPT can have up to 1027
     109    ;MIN_U  ax, MAX_LCHS_CYLINDERS      ; Our DPT can have up to 1027
    110110    call    StoswThenAddALandAHtoDL     ; Bytes 0 and 1 (Logical number of cylinders)
    111111
     
    201201    ; DPTE.bDrvnhead and DPTE.bBiosVendor
    202202    xchg    di, si
    203     call    AccessDPT_GetDriveSelectByteForEbiosToAL
     203    call    AccessDPT_GetDriveSelectByteToAL
    204204    xchg    si, di
    205205    call    StoswThenAddALandAHtoDL         ; Bytes 4 and 5
  • trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm

    r535 r542  
    3838;               Set if any error
    3939;   Corrupts registers:
    40 ;       AX, BX, CX, DH
     40;       AX, BX, CX, DX
    4141;--------------------------------------------------------------------
    4242CreateDPT_FromAtaInformation:
     
    9696;--------------------------------------------------------------------
    9797.StoreCHSparametersAndAddressingMode:
    98     ; Check if CHS defined in ROMVARS
    99     call    GetUserDefinedCapacityToBXAXandFlagsToCXandModeToDXfromROMVARS
    100     test    cl, FLG_DRVPARAMS_USERCHS
    101     jz      SHORT .AutodetectPCHSvalues
     98    ; Apply any user limited values to ATA ID
     99    call    AtaID_ModifyESSIforUserDefinedLimitsAndReturnTranslateModeInDX
    102100
    103101    ; Translate P-CHS to L-CHS
    104     call    AtaGeometry_GetLCHStoAXBLBHfromPCHSinAXBLBHandTranslateModeInDX
    105     jmp     SHORT .StoreLCHStoDPT
    106 .AutodetectPCHSvalues:
    107102    call    AtaGeometry_GetLCHStoAXBLBHfromAtaInfoInESSIandTranslateModeInDX
    108 
    109 .StoreLCHStoDPT:
    110     eSHL_IM dl, TRANSLATEMODE_FIELD_POSITION
    111     or      cl, dl
    112     or      [di+DPT.bFlagsLow], cl      ; Shift count and addressing mode
    113103    mov     [di+DPT.wLchsCylinders], ax
    114104    mov     [di+DPT.wLchsHeadsAndSectors], bx
    115 
    116     ; Store P-CHS to DPT
     105    mov     al, dl
     106    eSHL_IM al, TRANSLATEMODE_FIELD_POSITION
     107    or      cl, al
     108
     109    ; Store P-CHS and flags
    117110    call    AtaGeometry_GetPCHStoAXBLBHfromAtaInfoInESSI
    118     mov     [di+DPT.bPchsHeads], bl
     111    dec     dx                      ; Set ZF if TRANSLATEMODE_LARGE, SF if TRANSLATEMODE_NORMAL
     112    js      SHORT .NothingToChange
     113    jz      SHORT .LimitHeadsForLargeAddressingMode
     114
     115    or      cl, FLGL_DPT_LBA        ; Set LBA bit for Assisted LBA
     116    jmp     SHORT .NothingToChange
     117.LimitHeadsForLargeAddressingMode:
     118    MIN_U   bl, 15                  ; Cannot have 16 P-Heads in LARGE addressing mode
     119.NothingToChange:
     120    or      [di+DPT.bFlagsLow], cl  ; Shift count and addressing mode
     121    mov     [di+DPT.wPchsHeadsAndSectors], bx
     122
    119123%ifdef MODULE_EBIOS
    120     mov     [di+DPT.bPchsSectorsPerTrack], bh
    121 
    122 ; This is what Award BIOS from 1997 Pentium motherboard does. I can't think
    123 ; of any good reason to do the same but let's keep this here just in case,
    124 ; at least for a while.
    125 %if 0
    126 %ifdef RESERVE_DIAGNOSTIC_CYLINDER
    127     ; Do not store P-Cylinders, instead calculate it from L-CHS total sector count.
    128     ; Read AH=48h_GetExtendedDriveParameters.asm for more info.
    129     xchg    ax, bx
    130     mul     ah
    131     push    ax                          ; P-Heads * P-Sectors per track
    132     call    AH15h_GetSectorCountToBXDXAX
    133     pop     bx
    134     div     bx                          ; AX = Calculated cylinders
    135 %endif ; RESERVE_DIAGNOSTIC_CYLINDER
    136 %endif ; 0
    137 
     124    test    cl, FLGL_DPT_LBA
     125    jz      SHORT .NoLbaSoNoEBIOS
     126
     127    ; Store P-Cylinders but only if we have 15,482,880 or less sectors since
     128    ; we only need P-Cylinders so we can return it from AH=48h
     129    call    AtaGeometry_GetLbaSectorCountToBXDXAXfromAtaInfoInESSI
     130    sub     ax, MAX_SECTOR_COUNT_TO_RETURN_PCHS & 0FFFFh
     131    sbb     dx, MAX_SECTOR_COUNT_TO_RETURN_PCHS >> 16
     132    sbb     bx, BYTE 0
     133    ja      SHORT .StoreNumberOfLbaSectors
     134
     135    ; Since we might have altered the default P-CHS parameters to be
     136    ; presented to the drive (AH=09h), we need to calculate new
     137    ; P-Cylinders. It could be read from the ATA ID after
     138    ; COMMAND_INITIALIZE_DEVICE_PARAMETERS but that is too much trouble.
     139    ; P-Cyls = MIN(16383*16*63, LBA sector count) / (P-Heads * P-Sectors per track)
     140    call    AtaGeometry_GetLbaSectorCountToBXDXAXfromAtaInfoInESSI
     141    xchg    cx, ax                          ; Sector count to DX:CX
     142    mov     al, [di+DPT.bPchsHeads]
     143    mul     BYTE [di+DPT.bPchsSectorsPerTrack]
     144    xchg    cx, ax
     145    div     cx                              ; AX = new P-Cylinders
    138146    mov     [di+DPT.wPchsCylinders], ax
     147
     148    ; Store CHS sector count as total sector count
     149    mul     cx
     150    xor     bx, bx
     151    xor     cx, cx                          ; Clear LBA48 flag
     152    jmp     SHORT .StoreTotalSectorsFromBXDXAXandLBA48flagFromCL
    139153    ; Fall to .StoreNumberOfLbaSectors
    140154
     
    150164;       AX, BX, CX, DX
    151165;--------------------------------------------------------------------
    152     ; Check if LBA supported
    153     test    BYTE [es:si+ATA1.wCaps+1], A1_wCaps_LBA>>8
    154     jz      SHORT .NoLbaSupportedSoNoEBIOS
    155 
     166.StoreNumberOfLbaSectors:
    156167    ; Store LBA 28/48 total sector count
    157168    call    AtaGeometry_GetLbaSectorCountToBXDXAXfromAtaInfoInESSI
    158     call    StoreLba48AddressingFromCLandTotalSectorCountFromBXDXAX
    159 
    160     ; If we have 15,482,880 or less sectors, we multiply P-CHS values
    161     ; and use that as total sector count.
    162     ; Read AH=48h_GetExtendedDriveParameters.asm for more info.
    163     sub     ax, 4001h
    164     sbb     dx, 0ECh
    165     sbb     bx, BYTE 0
    166     jnc     SHORT .NoNeedToUseCHSsectorCount    ; More than EC4000h
    167 
    168     mov     al, [di+DPT.bPchsHeads]
    169     mul     BYTE [di+DPT.bPchsSectorsPerTrack]
    170     mul     WORD [di+DPT.wPchsCylinders]
    171     xor     bx, bx
    172     call    StoreLba48AddressingFromCLandTotalSectorCountFromBXDXAX
    173 
    174     ; Load user defined LBA
    175 .NoNeedToUseCHSsectorCount:
    176     call    GetUserDefinedCapacityToBXAXandFlagsToCXandModeToDXfromROMVARS
    177     test    cl, FLG_DRVPARAMS_USERLBA
    178     jz      SHORT .KeepTotalSectorsFromAtaID
    179 
    180     ; Compare user defined and ATA-ID sector count and select smaller
    181     mov     dx, bx
    182     xor     bx, bx      ; User defined LBA now in BX:DX:AX
    183     cmp     bx, [di+DPT.twLbaSectors+4]
    184     jb      SHORT .StoreUserDefinedSectorCountToDPT
    185     cmp     dx, [di+DPT.twLbaSectors+2]
    186     jb      SHORT .StoreUserDefinedSectorCountToDPT
    187     ja      SHORT .KeepTotalSectorsFromAtaID
    188     cmp     ax, [di+DPT.twLbaSectors]
    189     jae     SHORT .KeepTotalSectorsFromAtaID
    190 .StoreUserDefinedSectorCountToDPT:
    191     ; CL bit FLGL_DPT_LBA48 is clear at this point
    192     call    StoreLba48AddressingFromCLandTotalSectorCountFromBXDXAX
    193 
    194 .KeepTotalSectorsFromAtaID:
    195 .NoLbaSupportedSoNoEBIOS:
     169.StoreTotalSectorsFromBXDXAXandLBA48flagFromCL:
     170    or      [di+DPT.bFlagsLow], cl
     171    mov     [di+DPT.twLbaSectors], ax
     172    mov     [di+DPT.twLbaSectors+2], dx
     173    mov     [di+DPT.twLbaSectors+4], bx
     174.NoLbaSoNoEBIOS:
    196175%endif ; MODULE_EBIOS
    197176    ; Fall to .StoreBlockMode
     
    288267    mov     [di+DPT.wBasePort], ax
    289268    ret
    290 
    291 
    292 ;--------------------------------------------------------------------
    293 ; GetUserDefinedCapacityToBXAXandFlagsToCXandModeToDXfromROMVARS
    294 ;   Parameters:
    295 ;       DS:DI:      Ptr to Disk Parameter Table
    296 ;   Returns:
    297 ;       AX:         User defined P-CHS Cylinders or LBA low word
    298 ;       BX:         User defined P-CHS Heads and Sectors or LBA high word
    299 ;       DX:         Translate mode or TRANSLATEMODE_AUTO
    300 ;       CX:         FLG_DRVPARAMS_USERCHS if user defined CHS in BX:AX
    301 ;                   FLG_DRVPARAMS_USERLBA if user defined LBA in BX:AX
    302 ;                   Zero if user has not defined capacity
    303 ;   Corrupts registers:
    304 ;       Nothing
    305 ;--------------------------------------------------------------------
    306 GetUserDefinedCapacityToBXAXandFlagsToCXandModeToDXfromROMVARS:
    307     call    AccessDPT_GetPointerToDRVPARAMStoCSBX
    308 
    309     ; Get settings
    310     mov     cx, [cs:bx+DRVPARAMS.wFlags]
    311     mov     dx, cx
    312     and     cx, BYTE FLG_DRVPARAMS_USERCHS | FLG_DRVPARAMS_USERLBA
    313     and     dx, BYTE MASK_DRVPARAMS_TRANSLATEMODE
    314     eSHR_IM dx, TRANSLATEMODE_FIELD_POSITION
    315 
    316     ; Get capacity
    317     mov     ax, [cs:bx+DRVPARAMS.wCylinders]        ; Or .dwMaximumLBA
    318     mov     bx, [cs:bx+DRVPARAMS.wHeadsAndSectors]  ; Or .dwMaximumLBA+2
    319     ret
    320 
    321 
    322 %ifdef MODULE_EBIOS
    323 ;--------------------------------------------------------------------
    324 ; StoreLba48AddressingFromCLandTotalSectorCountFromBXDXAX
    325 ;   Parameters:
    326 ;       BX:DX:AX:   Total Sector Count
    327 ;       CL:         FLGL_DPT_LBA48 if LBA48 supported
    328 ;       DS:DI:      Ptr to Disk Parameter Table
    329 ;   Returns:
    330 ;       Nothing
    331 ;   Corrupts registers:
    332 ;       CL
    333 ;--------------------------------------------------------------------
    334 StoreLba48AddressingFromCLandTotalSectorCountFromBXDXAX:
    335     or      cl, FLGL_DPT_LBA_AND_EBIOS_SUPPORTED
    336     and     BYTE [di+DPT.bFlagsLow], ~FLGL_DPT_LBA48
    337     or      [di+DPT.bFlagsLow], cl
    338     mov     [di+DPT.twLbaSectors], ax
    339     mov     [di+DPT.twLbaSectors+2], dx
    340     mov     [di+DPT.twLbaSectors+4], bx
    341     ret
    342 %endif ; MODULE_EBIOS
Note: See TracChangeset for help on using the changeset viewer.