Changeset 542 in xtideuniversalbios


Ignore:
Timestamp:
Apr 15, 2013, 4:03:33 PM (8 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
Files:
15 edited

Legend:

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

    r540 r542  
    3737    .bLchsHeads             resb    1   ; (1...255)
    3838    .bLchsSectorsPerTrack   resb    1   ; (1...63)
     39    .wPchsHeadsAndSectors:
    3940    .bPchsHeads             resb    1   ; (1...16)
     41    .bPchsSectorsPerTrack   resb    1   ; (1...63)
    4042
    4143    ; LBA and remaining P-CHS variables
    4244%ifdef MODULE_EBIOS
    43     .bPchsSectorsPerTrack   resb    1
    4445    .wPchsCylinders         resb    2
    4546    .twLbaSectors           resb    6   ; 48-bit sector count for LBA addressing
     
    5657    FLGL_DPT_ENABLE_IRQ                 EQU (1<<5)              ; Bit 5, Enable IRQ
    5758%endif
     59    FLGL_DPT_LBA                        EQU FLG_DRVNHEAD_LBA    ; Bit 6, Drive supports LBA and so EBIOS functions can be supported
    5860%ifdef MODULE_EBIOS
    59     FLGL_DPT_LBA_AND_EBIOS_SUPPORTED    EQU FLG_DRVNHEAD_LBA    ; Bit 6, Drive supports LBA and so EBIOS functions can be supported
    6061    FLGL_DPT_LBA48                      EQU (1<<7)              ; Bit 7, Drive supports 48-bit LBA (Must be bit 7!)
    6162%endif
  • trunk/XTIDE_Universal_BIOS/Inc/EBIOS.inc

    r541 r542  
    4444endstruc
    4545
    46 MINIMUM_EDRIVEINFO_SIZE     EQU     26  ; 26 bytes does not include EDD pointer
    47 EDRIVEINFO_SIZE_WITH_DPTE   EQU     EDRIVE_INFO_size
     46MINIMUM_EDRIVEINFO_SIZE         EQU     26  ; 26 bytes does not include EDD pointer
     47EDRIVEINFO_SIZE_WITH_DPTE       EQU     EDRIVE_INFO_size
     48MAX_SECTOR_COUNT_TO_RETURN_PCHS EQU     15482880
    4849
    4950; Flags for EDRIVE_INFO.wFlags
  • trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc

    r536 r542  
    194194    MAX_USER_HEADS                  EQU 16
    195195    MAX_USER_SECTORS_PER_TRACK      EQU 63
     196    MAX_USER_CHS_COUNT              EQU (MAX_USER_CYLINDERS * MAX_USER_HEADS * MAX_USER_SECTORS_PER_TRACK)
    196197FLG_DRVPARAMS_USERLBA           EQU (1<<6)  ; User specified LBA value
    197     MIN_USER_LBA_COUNT              EQU ((MAX_USER_CYLINDERS*MAX_USER_HEADS*MAX_USER_SECTORS_PER_TRACK)+1)
     198    MIN_USER_LBA_COUNT              EQU (MAX_USER_CHS_COUNT+1)
    198199    MAX_USER_LBA_COUNT              EQU ((2^28)-1)
    199200
  • trunk/XTIDE_Universal_BIOS/Src/Device/Idepack.asm

    r526 r542  
    7070
    7171    and     ah, 0Fh                     ; Limit bits for LBA28
    72     call    AccessDPT_GetDriveSelectByteForEbiosToAL
     72    call    AccessDPT_GetDriveSelectByteToAL
    7373    or      al, ah
    7474    mov     [bp+IDEPACK.bDrvAndHead], al
     
    108108    push    bx
    109109    call    Address_OldInt13hAddressToIdeAddress
    110     call    AccessDPT_GetDriveSelectByteForOldInt13hToAL
     110    call    AccessDPT_GetDriveSelectByteToAL
    111111    or      al, bh          ; AL now has Drive and Head Select Byte
    112112    mov     [bp+IDEPACK.bDrvAndHead], al
     
    150150    ; Drive and Head select byte
    151151    and     ah, MASK_DRVNHEAD_HEAD      ; Keep head bits only
    152     call    AccessDPT_GetDriveSelectByteForOldInt13hToAL
     152    call    AccessDPT_GetDriveSelectByteToAL
    153153    or      al, ah
    154154    mov     [bp+IDEPACK.bDrvAndHead], al
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm

    r540 r542  
    123123ALIGN JUMP_ALIGN
    124124.JumpToEbiosFunction:
    125     test    BYTE [di+DPT.bFlagsLow], FLGL_DPT_LBA_AND_EBIOS_SUPPORTED
     125    test    BYTE [di+DPT.bFlagsLow], FLGL_DPT_LBA
    126126    jz      SHORT UnsupportedFunction   ; No eINT 13h for CHS drives
    127127    sub     bl, 41h<<1                  ; BX = Offset to eINT 13h jump table
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm

    r526 r542  
    9999;;; SelectDrive
    100100    ; Try to select drive and wait until ready
    101     call    AccessDPT_GetDriveSelectByteForOldInt13hToAL
     101    call    AccessDPT_GetDriveSelectByteToAL
    102102    mov     [bp+IDEPACK.bDrvAndHead], al
    103103    call    Device_SelectDrive
     
    130130
    131131;;; InitializeDeviceParameters
    132     ; Initialize CHS parameters if LBA is not used and
    133     ; user has specified P-CHS parameters
    134     test    BYTE [di+DPT.bFlagsLow], FLGL_DPT_ASSISTED_LBA
    135     jnz     SHORT .SkipInitializeDeviceParameters       ; No need to initialize CHS parameters if LBA mode enabled
    136     call    AccessDPT_GetPointerToDRVPARAMStoCSBX
    137     test    BYTE [cs:bx+DRVPARAMS.wFlags], FLG_DRVPARAMS_USERCHS    ; User specified P-CHS?
    138     jz      SHORT .SkipInitializeDeviceParameters
    139 
    140132    ; Initialize Logical Sectors per Track and Max Head number
    141     mov     ax, [cs:bx+DRVPARAMS.wHeadsAndSectors]
     133    mov     ax, [di+DPT.wPchsHeadsAndSectors]
    142134    dec     ax                          ; Max Head number
    143     xchg    al, ah                      ; Heads now in AH
    144     mov     dx, ax                      ; Sectors per Track now in DL
     135    xchg    ah, al
     136    mov     dl, al                      ; Sectors per track
    145137    mov     al, COMMAND_INITIALIZE_DEVICE_PARAMETERS
    146138    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_BSY, FLG_STATUS_BSY)
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH48h_GetExtendedDriveParameters.asm

    r541 r542  
    5252;    AH=48h Total Sector Count: 11873* 16*63 = 11,967,984
    5353;
    54 ; Notice how AH=48h returns lesser total sector count than AH=8h! The only
     54; Notice how AH=48h returns lesser total sector count than AH=08h! The only
    5555; way I could think of to get 11873 cylinders is to divide AH=08h sector
    5656; count with P-CHS heads and sectors: (745*255*63) / (16*63) = 11873
    5757;
    58 ; I have no idea what is the reasoning behind it but at least there is one
    59 ; BIOS that does just that.
    60 ;
    61 ; I decided that we multiply P-CHS values and do not waste space like the
    62 ; Award BIOS does.
     58; The only reason I can think of is that the Award BIOS has a bug and
     59; uses L-CHS when it should use P-CHS values in the calculation.
    6360;
    6461;
     
    139136    ; Store P-CHS. Based on phoenix specification this is returned only if
    140137    ; total sector count is 15,482,880 or less.
    141     sub     ax, 4001h
    142     sbb     dx, 0ECh
     138    sub     ax, MAX_SECTOR_COUNT_TO_RETURN_PCHS & 0FFFFh
     139    sbb     dx, MAX_SECTOR_COUNT_TO_RETURN_PCHS >> 16
    143140    sbb     bx, cx      ; Zero
    144     jnc     SHORT .ReturnWithSuccess    ; More than EC4000h
    145     or      WORD [di+EDRIVE_INFO.wFlags], FLG_CHS_INFORMATION_IS_VALID
     141    ja      SHORT .ReturnWithSuccess
     142    or      BYTE [di+EDRIVE_INFO.wFlags], FLG_CHS_INFORMATION_IS_VALID
    146143
    147144    eMOVZX  dx, BYTE [es:si+DPT.bPchsHeads]
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Address.asm

    r526 r542  
    120120; Only 24-bits are used since LHCS to LBA28 conversion has 8.4GB limit.
    121121; LBA = ((cylToSeek*headsPerCyl+headToSeek)*sectPerTrack)+sectToSeek-1
     122; headsPerCyl and sectPerTrack are the current translation values (L-CHS).
    122123;
    123124; Returned address is in same registers that
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/Vision.asm

    r534 r542  
    4141    in      al, QD65XX_BASE_PORT + QD65XX_CONFIG_REGISTER_in
    4242
    43 %if 0
     43%ifdef DANGEROUS_DETECTION
    4444    ; Checking alternative base port is currently commented away
    4545    ; since Intel PIIX4 south bridge mirrors Interrupt Controller registers
     
    5151    or      dl, QD65XX_ALTERNATIVE_BASE_PORT
    5252    in      al, QD65XX_ALTERNATIVE_BASE_PORT + QD65XX_CONFIG_REGISTER_in
    53 %endif ; 0
     53%endif ; DANGEROUS_DETECTION
    5454    ; Fall to IsConfigRegisterWithIDinAL
    5555
     
    6565;       Nothing
    6666;--------------------------------------------------------------------
    67 ;IsConfigRegisterWithIDinAL:
     67IsConfigRegisterWithIDinAL:
    6868    mov     ah, al
    6969    and     al, MASK_QDCONFIG_CONTROLLER_ID
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm

    r526 r542  
    9595
    9696
     97;--------------------------------------------------------------------
     98; Writes user defined limits from ROMVARS to ATA ID read from the drive.
     99; Modifying the ATA ID reduces code and possibilites for bugs since
     100; only little furher checks are needed elsewhere.
     101;
     102; AtaID_ModifyESSIforUserDefinedLimitsAndReturnTranslateModeInDX
     103;   Parameters:
     104;       DS:DI:  Ptr to incomplete Disk Parameter Table
     105;       ES:SI:  Ptr to 512-byte ATA information read from the drive
     106;       CS:BP:  Ptr to IDEVARS for the controller
     107;   Returns:
     108;       DX:     User defined P-CHS to L-CHS translate mode
     109;   Corrupts registers:
     110;       AX, BX, CX
     111;--------------------------------------------------------------------
     112AtaID_ModifyESSIforUserDefinedLimitsAndReturnTranslateModeInDX:
     113    call    AccessDPT_GetPointerToDRVPARAMStoCSBX
     114    push    ds
     115    push    es
     116    pop     ds      ; DS:SI now points to ATA information
     117
     118    ; Load User Defined CHS or LBA to CX:AX
     119    mov     dx, [cs:bx+DRVPARAMS.wFlags]
     120    mov     ax, [cs:bx+DRVPARAMS.wCylinders]        ; Or .dwMaximumLBA
     121    mov     cx, [cs:bx+DRVPARAMS.wHeadsAndSectors]  ; Or .dwMaximumLBA+2
     122
     123    ; * User defined CHS *
     124    test    dl, FLG_DRVPARAMS_USERCHS
     125    jz      SHORT .NoUserDefinedCHS
     126
     127    ; Apply new CHS and disable LBA (we also want to set CHS addressing)
     128    mov     [si+ATA1.wCylCnt], ax
     129    eMOVZX  ax, cl
     130    mov     [si+ATA1.wHeadCnt], ax
     131    mov     al, ch
     132    mov     [si+ATA1.wSPT], ax
     133    and     BYTE [si+ATA1.wCaps+1], ~(A1_wCaps_LBA>>8)
     134    and     BYTE [si+ATA6.wSetSup83+1], ~(A6_wSetSup83_LBA48>>8)
     135.NoUserDefinedCHS:
     136
     137    ; * User defined LBA *
     138    test    dl, FLG_DRVPARAMS_USERLBA
     139    jz      SHORT .NoUserDefinedLBA
     140
     141    ; Apply new LBA and disable LBA48
     142    cmp     cx, [si+ATA1.dwLBACnt+2]
     143    ja      SHORT .NoUserDefinedLBA     ; Do not set larger than drive
     144    jb      SHORT .StoreNewLBA
     145    cmp     ax, [si+ATA1.dwLBACnt]
     146    ja      SHORT .NoUserDefinedLBA     ; Allow same size to disable LBA48
     147.StoreNewLBA:
     148    mov     [si+ATA1.dwLBACnt], ax
     149    mov     [si+ATA1.dwLBACnt+2], cx
     150    and     BYTE [si+ATA6.wSetSup83+1], ~(A6_wSetSup83_LBA48>>8)
     151.NoUserDefinedLBA:
     152
     153    ; * Disable Block Mode transfers *
     154    test    dl, FLG_DRVPARAMS_BLOCKMODE
     155    jnz     SHORT .NoNeedToDisableBlockMode
     156    mov     BYTE [si+ATA1.bBlckSize], 1 ; sectors
     157.NoNeedToDisableBlockMode:
     158
     159    ; * Load P-CHS to L-CHS translate mode to DX *
     160    and     dx, BYTE MASK_DRVPARAMS_TRANSLATEMODE
     161    eSHR_IM dx, TRANSLATEMODE_FIELD_POSITION
     162
     163    pop     ds
     164    ret
     165
     166
    97167%ifdef MODULE_ADVANCED_ATA
    98168;--------------------------------------------------------------------
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/Initialize.asm

    r541 r542  
    9595;--------------------------------------------------------------------
    9696.StoreDptPointersToIntVectors:
     97%ifndef USE_AT
     98    test    BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
     99    jz      SHORT .CompatibleDPTsCreated    ; Only Full operating mode has extra RAM to spare
     100%endif
     101
    97102    mov     dl, 80h
    98103    call    FindDPT_ForDriveNumberInDL  ; DPT to DS:DI
  • 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.