Changeset 422 in xtideuniversalbios for trunk


Ignore:
Timestamp:
May 12, 2012, 1:58:25 PM (13 years ago)
Author:
aitotat@…
google:author:
aitotat@gmail.com
Message:

Changes to XTIDE Universal BIOS:

  • Modified ROMVARS for user defined CHS translation mode.
  • Base DPT struct now includes initialization error flags again.
Location:
trunk/XTIDE_Universal_BIOS
Files:
10 edited

Legend:

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

    r421 r422  
    6363
    6464struc DRVDETECTINFO
     65    .StartOfDrvDetectInfo:
    6566    .szDrvName              resb    MAX_HARD_DISK_NAME_LENGTH
    6667                            resb    2   ; Zero word (ensures string terminates)
    6768    .wInitErrorFlags        resb    2   ; Errors during initialization
    6869
    69 %if LARGEST_DPT_SIZE == 28
    70                             resb    22  ; padding to make DRVDETECTINFO size an even multiple of DPT size
    71 %elif LARGEST_DPT_SIZE == 20
    72                             resb    6
    73 %elif LARGEST_DPT_SIZE == 18
    74                             resb    2
    75 %else   ; LARGEST_DPT_SIZE == 10
    76                             resb    6
    77 %endif
     70    ; DRVDETECTINFO's size must be an even multiple of DPT's size
     71    .EndOfDriveDetectInfo:  resb    LARGEST_DPT_SIZE - (.EndOfDriveDetectInfo % LARGEST_DPT_SIZE)
    7872endstruc
    7973
  • trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc

    r421 r422  
    2323
    2424; Base DPT for all device types
    25 struc DPT   ; 8 or 18 bytes
     25struc DPT   ; 10 or 18 bytes
    2626    ; General Disk Parameter Table related
    2727    .wFlags:
     
    2929    .bFlagsHigh             resb    1
    3030    .bIdevarsOffset         resb    1   ; Offset to IDEVARS for this drive
     31    .bInitError             resb    1   ; Flags for AH=09h initialization errors
    3132
    32     .bPchsHeads             resb    1   ; (1...16)
     33    ; CHS variables
    3334    .wLchsCylinders         resb    2   ; (1...1027, yes 1027)
    3435    .wLchsHeadsAndSectors:
    3536    .bLchsHeads             resb    1   ; (1...255)
    3637    .bLchsSectorsPerTrack   resb    1   ; (1...63)
     38    .bPchsHeads             resb    1   ; (1...16)
    3739
     40    ; LBA and remaining P-CHS variables
    3841%ifdef MODULE_EBIOS
     42    .bPchsSectorsPerTrack   resb    1
     43    .wPchsCylinders         resb    2
    3944    .twLbaSectors           resb    6   ; 48-bit sector count for LBA addressing
    40     .wPchsCylinders         resb    2
    41     .bPchsSectorsPerTrack   resb    1
    42                             resb    1
     45%else
     46                            resb    1   ; Alignment
    4347%endif
    4448endstruc
     
    4650    ; Bit definitions for DPT.bFlagsLow
    4751    MASKL_DPT_CHS_SHIFT_COUNT           EQU (3<<0)              ; Bits 0...1, P-CHS to L-CHS bit shift count (0...3)
    48     MASKL_DPT_ADDRESSING_MODE           EQU (3<<ADDRESSING_MODE_FIELD_POSITION) ; Bits 2...3, NORMAL, LARGE or Assisted LBA addressing mode
    49     FLGL_DPT_ASSISTED_LBA               EQU (1<<(ADDRESSING_MODE_FIELD_POSITION+1))
     52    MASKL_DPT_TRANSLATEMODE             EQU MASK_DRVPARAMS_TRANSLATEMODE    ; Bits 2...3, NORMAL, LARGE or Assisted LBA addressing mode
     53    FLGL_DPT_ASSISTED_LBA               EQU (1<<(TRANSLATEMODE_FIELD_POSITION+1))
    5054    FLGL_DPT_SLAVE                      EQU FLG_DRVNHEAD_DRV    ; Bit 4, Drive is a Slave Drive
    5155%ifdef MODULE_IRQ
     
    5660    FLGL_DPT_LBA48                      EQU (1<<7)              ; Bit 7, Drive supports 48-bit LBA (Must be bit 7!)
    5761%endif
    58 
    59     ; Addressing modes for DPT.bFlagsLow
    60     ADDRESSING_MODE_FIELD_POSITION      EQU     2
    61     ADDRESSING_MODE_NORMAL              EQU     0
    62     ADDRESSING_MODE_LARGE               EQU     1
    63     ADDRESSING_MODE_ASSISTED_LBA        EQU     2   ; 28-bit or 48-bit LBA
    6462
    6563
     
    8785
    8886
     87    ; Flags for DPT_ADVANCED_ATA.bInitError
     88    FLG_INITERROR_FAILED_TO_SELECT_DRIVE                EQU (1<<0)
     89    FLG_INITERROR_FAILED_TO_INITIALIZE_CHS_PARAMETERS   EQU (1<<1)
     90    FLG_INITERROR_FAILED_TO_SET_WRITE_CACHE             EQU (1<<2)
     91    FLG_INITERROR_FAILED_TO_RECALIBRATE_DRIVE           EQU (1<<3)
     92    FLG_INITERROR_FAILED_TO_SET_BLOCK_MODE              EQU (1<<4)
     93    FLG_INITERROR_FAILED_TO_SET_PIO_MODE                EQU (1<<5)
     94    FLG_INITERROR_FAILED_TO_INITIALIZE_STANDBY_TIMER    EQU (1<<6)
     95
     96
    8997
    9098; DPT for ATA devices
    91 struc DPT_ATA   ; 8/18 bytes + 2 bytes = 10/20 bytes
     99struc DPT_ATA   ; 10/18 bytes + 2 bytes = 12/20 bytes
    92100    .dpt                    resb    DPT_size
    93101    .bBlockSize             resb    1   ; Current block size in sectors (do not set to zero!)
     
    100108; EBDA must be reserved for DPTs when using these!
    101109%ifdef MODULE_ADVANCED_ATA
    102 struc DPT_ADVANCED_ATA  ; 10/20 bytes + 8 bytes = 18/28 bytes
     110struc DPT_ADVANCED_ATA  ; 12/20 bytes + 8 bytes = 20/28 bytes
    103111    .dpt_ata                resb    DPT_ATA_size
    104112    .wControllerID          resb    2   ; Controller specific ID WORD (from Advanced Controller detection)
     
    106114    .wMinPioCycleTime       resb    2   ; Minimum PIO Cycle Time in ns
    107115    .bPioMode               resb    1   ; Best supported PIO mode
    108     .bInitError             resb    1   ; Flags for initialization errors
     116                            resb    1
    109117endstruc
    110 
    111     ; Flags for DPT_ADVANCED_ATA.bInitError
    112     FLG_INITERROR_FAILED_TO_SELECT_DRIVE                EQU (1<<0)
    113     FLG_INITERROR_FAILED_TO_INITIALIZE_CHS_PARAMETERS   EQU (1<<1)
    114     FLG_INITERROR_FAILED_TO_SET_WRITE_CACHE             EQU (1<<2)
    115     FLG_INITERROR_FAILED_TO_RECALIBRATE_DRIVE           EQU (1<<3)
    116     FLG_INITERROR_FAILED_TO_SET_BLOCK_MODE              EQU (1<<4)
    117     FLG_INITERROR_FAILED_TO_SET_PIO_MODE                EQU (1<<5)
    118     FLG_INITERROR_FAILED_TO_INITIALIZE_STANDBY_TIMER    EQU (1<<6)
    119118%endif
    120119
  • trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc

    r408 r422  
    164164
    165165; Bit defines for DRVPARAMS.wFlags
    166 MASK_DRVPARAMS_WRITECACHE   EQU (3<<0)  ; Drive internal write cache settings (must start at bit 0)
    167 FLG_DRVPARAMS_BLOCKMODE     EQU (1<<2)  ; Enable Block mode transfers
    168 FLG_DRVPARAMS_USERCHS       EQU (1<<3)  ; User specified P-CHS values
    169 FLG_DRVPARAMS_USERLBA       EQU (1<<4)  ; User specified LBA values
     166MASK_DRVPARAMS_WRITECACHE       EQU (3<<0)  ; Bits 0...1, Drive internal write cache settings (must start at bit 0)
     167    DEFAULT_WRITE_CACHE             EQU 0   ; Must be 0
     168    DISABLE_WRITE_CACHE             EQU 1
     169    ENABLE_WRITE_CACHE              EQU 2
     170MASK_DRVPARAMS_TRANSLATEMODE    EQU (3<<TRANSLATEMODE_FIELD_POSITION)   ; Bits 2...3, Position shared with DPT
     171    TRANSLATEMODE_FIELD_POSITION    EQU 2
     172    TRANSLATEMODE_NORMAL            EQU 0
     173    TRANSLATEMODE_LARGE             EQU 1
     174    TRANSLATEMODE_ASSISTED_LBA      EQU 2   ; 28-bit or 48-bit LBA
     175    TRANSLATEMODE_AUTO              EQU 3   ; Only available in ROMVARS, not in DPTs
     176FLG_DRVPARAMS_BLOCKMODE         EQU (1<<4)  ; Enable Block mode transfers
     177FLG_DRVPARAMS_USERCHS           EQU (1<<5)  ; User specified P-CHS values
     178    MAX_USER_CYLINDERS              EQU 16383
     179    MAX_USER_HEADS                  EQU 16
     180    MAX_USER_SECTORS_PER_TRACK      EQU 63
     181FLG_DRVPARAMS_USERLBA           EQU (1<<6)  ; User specified LBA value
     182    MIN_USER_LBA_COUNT              EQU ((MAX_USER_CYLINDERS*MAX_USER_HEADS*MAX_USER_SECTORS_PER_TRACK)+1)
     183    MAX_USER_LBA_COUNT              EQU ((2^28)-1)
    170184
    171 ; Drive Write Cache values for DRVPARAMS.wFlags.MASK_DRVPARAMS_WRITECACHE
    172 DEFAULT_WRITE_CACHE         EQU 0       ; Must be 0
    173 DISABLE_WRITE_CACHE         EQU 1
    174 ENABLE_WRITE_CACHE          EQU 2
    175185
    176186%endif ; ROMVARS_INC
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm

    r421 r422  
    3535;--------------------------------------------------------------------
    3636%macro STORE_ERROR_FLAG_TO_DPT 1
    37 %ifdef MODULE_ADVANCED_ATA
    3837    mov     al, %1
    3938    call    SetErrorFlagFromALwithErrorCodeInAH
    40 %endif
    4139%endmacro
    4240
     
    8280%ifdef MODULE_ADVANCED_ATA
    8381    ; Clear Initialization Error flags from DPT
    84     mov     [di+DPT_ADVANCED_ATA.bInitError], al
     82    mov     [di+DPT.bInitError], al
    8583%endif
    8684
     
    205203.ReturnWithErrorCodeInAH:
    206204%ifdef MODULE_ADVANCED_ATA
    207     mov     ah, [di+DPT_ADVANCED_ATA.bInitError]
     205    mov     ah, [di+DPT.bInitError]
    208206    test    ah, ah  ; Clears CF
    209207    jz      SHORT .ReturnWithSuccess
     
    225223
    226224
    227 %ifdef MODULE_ADVANCED_ATA
    228225;--------------------------------------------------------------------
    229226; SetErrorFlagFromALwithErrorCodeInAH
     
    247244    jbe     SHORT IgnoreInvalidCommandError
    248245
    249     or      [di+DPT_ADVANCED_ATA.bInitError], al
     246    or      [di+DPT.bInitError], al
    250247    stc
    251248.NoErrorFlagToSet:
    252249    ret
    253 
    254 %endif
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Address.asm

    r421 r422  
    103103Address_OldInt13hAddressToIdeAddress:
    104104        call    Address_ExtractLCHSparametersFromOldInt13hAddress
    105         ACCESSDPT__GET_UNSHIFTED_ADDRESS_MODE_TO_AXZF
     105        ACCESSDPT__GET_UNSHIFTED_TRANSLATE_MODE_TO_AXZF
    106106
    107107;;; 0: ADDRESSING_MODE_NORMAL
  • trunk/XTIDE_Universal_BIOS/Src/Main.asm

    r421 r422  
    9292    at  ROMVARS.ideVars0+IDEVARS.bDevice,       db  DEVICE_16BIT_ATA
    9393    at  ROMVARS.ideVars0+IDEVARS.bIRQ,          db  0
    94     at  ROMVARS.ideVars0+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags,  db  DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
    95     at  ROMVARS.ideVars0+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags,   db  DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
     94    at  ROMVARS.ideVars0+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags,  dw  DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE | (TRANSLATEMODE_AUTO<<TRANSLATEMODE_FIELD_POSITION)
     95    at  ROMVARS.ideVars0+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags,   dw  DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE | (TRANSLATEMODE_AUTO<<TRANSLATEMODE_FIELD_POSITION)
    9696
    9797    at  ROMVARS.ideVars1+IDEVARS.wPort,         dw  DEVICE_ATA_SECONDARY_PORT
     
    9999    at  ROMVARS.ideVars1+IDEVARS.bDevice,       db  DEVICE_16BIT_ATA
    100100    at  ROMVARS.ideVars1+IDEVARS.bIRQ,          db  0
    101     at  ROMVARS.ideVars1+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags,  db  DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
    102     at  ROMVARS.ideVars1+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags,   db  DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
     101    at  ROMVARS.ideVars1+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags,  dw  DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE | (TRANSLATEMODE_AUTO<<TRANSLATEMODE_FIELD_POSITION)
     102    at  ROMVARS.ideVars1+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags,   dw  DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE | (TRANSLATEMODE_AUTO<<TRANSLATEMODE_FIELD_POSITION)
    103103
    104104    at  ROMVARS.ideVars2+IDEVARS.wPort,         dw  DEVICE_ATA_TERTIARY_PORT
     
    106106    at  ROMVARS.ideVars2+IDEVARS.bDevice,       db  DEVICE_16BIT_ATA
    107107    at  ROMVARS.ideVars2+IDEVARS.bIRQ,          db  0
    108     at  ROMVARS.ideVars2+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags,  db  DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
    109     at  ROMVARS.ideVars2+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags,   db  DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
     108    at  ROMVARS.ideVars2+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags,  dw  DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE | (TRANSLATEMODE_AUTO<<TRANSLATEMODE_FIELD_POSITION)
     109    at  ROMVARS.ideVars2+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags,   dw  DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE | (TRANSLATEMODE_AUTO<<TRANSLATEMODE_FIELD_POSITION)
    110110
    111111    at  ROMVARS.ideVars3+IDEVARS.wPort,         dw  DEVICE_ATA_QUATERNARY_PORT
     
    113113    at  ROMVARS.ideVars3+IDEVARS.bDevice,       db  DEVICE_16BIT_ATA
    114114    at  ROMVARS.ideVars3+IDEVARS.bIRQ,          db  0
    115     at  ROMVARS.ideVars3+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags,  db  DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
    116     at  ROMVARS.ideVars3+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags,   db  DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE
     115    at  ROMVARS.ideVars3+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags,  dw  DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE | (TRANSLATEMODE_AUTO<<TRANSLATEMODE_FIELD_POSITION)
     116    at  ROMVARS.ideVars3+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags,   dw  DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE | (TRANSLATEMODE_AUTO<<TRANSLATEMODE_FIELD_POSITION)
    117117
    118118%ifdef MODULE_SERIAL
  • trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuPrintCfg.asm

    r421 r422  
    5656;--------------------------------------------------------------------
    5757.PushAddressingMode:
    58     ACCESSDPT__GET_UNSHIFTED_ADDRESS_MODE_TO_AXZF
     58    ACCESSDPT__GET_UNSHIFTED_TRANSLATE_MODE_TO_AXZF
    5959    ;;
    6060    ;; This multiply both shifts the addressing mode bits down to low order bits, and
     
    6262    ;; with AL clear, and so we exchange AL and AH after the multiply for the final result.
    6363    ;;
    64     mov     cx, g_szAddressingModes_Displacement << (8-ADDRESSING_MODE_FIELD_POSITION)
     64    mov     cx, g_szAddressingModes_Displacement << (8-TRANSLATEMODE_FIELD_POSITION)
    6565    mul     cx
    6666    xchg    al, ah      ; AL = always zero after above multiplication
     
    132132;--------------------------------------------------------------------
    133133.PushResetStatus:
    134 %ifdef MODULE_ADVANCED_ATA
    135     mov     al, [di+DPT_ADVANCED_ATA.bInitError]
     134    mov     al, [di+DPT.bInitError]
    136135    push    ax
    137 %else
    138     ePUSH_T ax, 0
    139 %endif
    140136
    141137;;; fall-out to BootMenuPrint_HardDiskRefreshInformation.
  • trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm

    r421 r422  
    144144ALIGN JUMP_ALIGN
    145145AccessDPT_GetPointerToDRVPARAMStoCSBX:
    146     eMOVZX  bx, [di+DPT.bIdevarsOffset]         ; CS:BX points to IDEVARS
     146    eMOVZX  bx, BYTE [di+DPT.bIdevarsOffset]    ; CS:BX points to IDEVARS
    147147    add     bx, BYTE IDEVARS.drvParamsMaster    ; CS:BX points to Master Drive DRVPARAMS
    148148    test    BYTE [di+DPT.bFlagsLow], FLGL_DPT_SLAVE
     
    154154
    155155;--------------------------------------------------------------------
    156 ; ACCESSDPT__GET_UNSHIFTED_ADDRESS_MODE_TO_AXZF
     156; ACCESSDPT__GET_UNSHIFTED_TRANSLATE_MODE_TO_AXZF
    157157;   Parameters:
    158158;       DS:DI:  Ptr to Disk Parameter Table
    159159;   Returns:
    160 ;       AX:     Addressing Mode (ADDRESSING_MODE_NORMAL, ADDRESSING_MODE_LARGE or ADDRESSING_MODE_ASSISTED_LBA)
     160;       AX:     Translate Mode (TRANSLATEMODE_NORMAL, TRANSLATEMODE_LARGE or TRANSLATEMODE_ASSISTED_LBA)
    161161;               unshifted (still shifted where it is in bFlagsLow)
    162162;       ZF:     Set based on value in AL
     
    168168; is not worth it for these two instructions (4 bytes total)
    169169;
    170 %macro ACCESSDPT__GET_UNSHIFTED_ADDRESS_MODE_TO_AXZF 0
     170%macro ACCESSDPT__GET_UNSHIFTED_TRANSLATE_MODE_TO_AXZF 0
    171171    mov     al, [di+DPT.bFlagsLow]
    172     and     ax, BYTE MASKL_DPT_ADDRESSING_MODE
     172    and     ax, BYTE MASKL_DPT_TRANSLATEMODE
    173173%endmacro
  • trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AtaGeometry.asm

    r421 r422  
    3434;   Returns:
    3535;       BX:DX:AX:   48-bit sector count
    36 ;       CL:         FLGL_DPT_LBA48 if LBA48 supported, zero otherwise
     36;       CL:         FLGL_DPT_LBA48 if LBA48 supported
     37;                   Zero if only LBA28 is supported
    3738;   Corrupts registers:
    3839;       Nothing
     
    6465
    6566;--------------------------------------------------------------------
    66 ; AtaGeometry_GetLCHStoAXBLBHfromAtaInfoInESSI:
    67 ;   Parameters:
     67; AtaGeometry_GetLCHStoAXBLBHfromAtaInfoInESSIandTranslateModeInDX
     68; AtaGeometry_GetLCHStoAXBLBHfromPCHSinAXBLBHandTranslateModeInDX
     69;   Parameters:
     70;       DX:     Wanted translate mode or TRANSLATEMODE_AUTO to autodetect
    6871;       ES:SI:  Ptr to 512-byte ATA information read from the drive
    6972;   Returns:
     
    7275;       BH:     Number of L-CHS sectors per track (1...63)
    7376;       CX:     Number of bits shifted (0...3)
    74 ;       DL:     Addressing mode
     77;       DL:     CHS Translate Mode
    7578;   Corrupts registers:
    7679;       DH
    7780;--------------------------------------------------------------------
    78 AtaGeometry_GetLCHStoAXBLBHfromAtaInfoInESSI:
     81AtaGeometry_GetLCHStoAXBLBHfromAtaInfoInESSIandTranslateModeInDX:
    7982    call    AtaGeometry_GetPCHStoAXBLBHfromAtaInfoInESSI
    8083    ; Fall to AtaGeometry_GetLCHStoAXBLBHfromPCHSinAXBLBH
    8184
    82 AtaGeometry_GetLCHStoAXBLBHfromPCHSinAXBLBH:
     85AtaGeometry_GetLCHStoAXBLBHfromPCHSinAXBLBHandTranslateModeInDX:
     86    ; Check if user defined translate mode
     87    test    dx, dx
     88    jnz     SHORT .CheckIfLargeTranslationWanted
     89    MIN_U   ax, MAX_LCHS_CYLINDERS  ; TRANSLATEMODE_NORMAL maximum cylinders
     90    inc     dx
     91.CheckIfLargeTranslationWanted:
     92    dec     dx                      ; Set ZF if TRANSLATEMODE_LARGE
     93    jz      SHORT ConvertPCHfromAXBLtoRevisedEnhancedCHinAXBL
     94    dec     dx                      ; Set ZF if TRANSLATEMODE_ASSISTED_LBA
     95    jz      SHORT .UseAssistedLBA
     96    ; TRANSLATEMODE_AUTO set
     97
    8398    ; Generate L-CHS using simple bit shift algorithm (ECHS) if
    8499    ; 8192 or less cylinders.
    85100    cmp     ax, 8192
    86     jbe     SHORT ConvertPCHfromAXBXtoEnhancedCHinAXBX
     101    jbe     SHORT ConvertPCHfromAXBLtoEnhancedCHinAXBL
    87102
    88103    ; We have 8193 or more cylinders so two algorithms are available:
    89104    ; Revised ECHS or Assisted LBA. The Assisted LBA provides larger
    90105    ; capacity but requires LBA support from drive (drives this large
    91     ; always support LBA but we may have intentionally cleared the LBA
    92     ; bit to force CHS addressing).
     106    ; always support LBA but user might have unintentionally set LBA).
     107.UseAssistedLBA:
    93108    test    BYTE [es:si+ATA1.wCaps+1], A1_wCaps_LBA>>8
    94     jz      SHORT ConvertPCHfromAXBXtoRevisedEnhancedCHinAXBX
     109    jz      SHORT ConvertPCHfromAXBLtoRevisedEnhancedCHinAXBL
    95110
    96111    ; Drive supports LBA
    97     call    AtaGeometry_GetSectorCountToDXAXfromCHSinAXBLBH
     112    call    GetSectorCountToDXAXfromCHSinAXBLBH
    98113    call    ConvertChsSectorCountFromDXAXtoLbaAssistedLCHSinAXBLBH
    99114    xor     cx, cx      ; No bits to shift
    100     mov     dl, ADDRESSING_MODE_ASSISTED_LBA
     115    mov     dl, TRANSLATEMODE_ASSISTED_LBA
    101116    ret
    102117
     
    121136
    122137;--------------------------------------------------------------------
    123 ; AtaGeometry_GetSectorCountToDXAXfromCHSinAXBLBH
     138; GetSectorCountToDXAXfromCHSinAXBLBH
    124139;   Parameters:
    125140;       ES:SI:  Ptr to 512-byte ATA information read from the drive
     
    132147;       BX
    133148;--------------------------------------------------------------------
    134 AtaGeometry_GetSectorCountToDXAXfromCHSinAXBLBH:
     149GetSectorCountToDXAXfromCHSinAXBLBH:
    135150    xchg    ax, bx
    136151    mul     ah          ; AX = Heads * Sectors per track
     
    157172;  Do a standard ECHS translation
    158173;
    159 ; ConvertPCHfromAXBXtoRevisedEnhancedCHinAXBX:
     174; ConvertPCHfromAXBLtoRevisedEnhancedCHinAXBL:
    160175;   Parameters:
    161176;       AX:     Number of P-CHS cylinders (8193...16383)
     
    169184;       Nothing
    170185;--------------------------------------------------------------------
    171 ConvertPCHfromAXBXtoRevisedEnhancedCHinAXBX:
     186ConvertPCHfromAXBLtoRevisedEnhancedCHinAXBL:
     187    ; Generate L-CHS using simple bit shift algorithm (ECHS) if
     188    ; 8192 or less cylinders
     189    cmp     ax, 8192
     190    jbe     SHORT ConvertPCHfromAXBLtoEnhancedCHinAXBL
    172191    cmp     bl, 16  ; Drives with 8193 or more cylinders can report 15 heads
    173     jb      SHORT ConvertPCHfromAXBXtoEnhancedCHinAXBX
     192    jb      SHORT ConvertPCHfromAXBLtoEnhancedCHinAXBL
    174193
    175194    eMOVZX  cx, bl  ; CX = 16
     
    201220;  Use the multiplier on the Cylinder and Head values to obtain the translated values.
    202221;
    203 ; ConvertPCHfromAXBXtoEnhancedCHinAXBX:
     222; ConvertPCHfromAXBLtoEnhancedCHinAXBL:
    204223;   Parameters:
    205224;       AX:     Number of P-CHS cylinders (1...8192)
     
    209228;       BL:     Number of L-CHS heads (?...128)
    210229;       CX:     Number of bits shifted (0...3)
    211 ;       DL:     ADDRESSING_MODE_NORMAL or ADDRESSING_MODE_LARGE
     230;       DL:     TRANSLATEMODE_NORMAL or TRANSLATEMODE_LARGE
    212231;   Corrupts registers:
    213232;       Nothing
    214233;--------------------------------------------------------------------
    215 ConvertPCHfromAXBXtoEnhancedCHinAXBX:
     234ConvertPCHfromAXBLtoEnhancedCHinAXBL:
    216235    xor     cx, cx      ; No bits to shift initially
    217     xor     dl, dl      ; Assume ADDRESSING_MODE_NORMAL
     236    xor     dl, dl      ; Assume TRANSLATEMODE_NORMAL
    218237.ShiftIfMoreThan1024Cylinder:
    219238    cmp     ax, MAX_LCHS_CYLINDERS
    220239    jbe     SHORT ReturnLCHSinAXBLBH
    221     shr     ax, 1
    222     shl     bl, 1
     240    shr     ax, 1       ; Halve cylinders
     241    shl     bl, 1       ; Double heads
    223242    inc     cx          ; Increment bit shift count
    224     mov     dl, ADDRESSING_MODE_LARGE
     243    mov     dl, TRANSLATEMODE_LARGE
    225244    jmp     SHORT .ShiftIfMoreThan1024Cylinder
    226245
  • trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm

    r421 r422  
    5555;--------------------------------------------------------------------
    5656.InitializeDPT:
    57     mov     [di+DPT.bIdevarsOffset], bp ; IDEVARS must start in first 256 bytes of ROM
     57    mov     [di+DPT.bIdevarsOffset], bp     ; IDEVARS must start in first 256 bytes of ROM
    5858    ; Fall to .StoreDriveSelectAndDriveControlByte
    5959
     
    9595.StoreCHSparametersAndAddressingMode:
    9696    ; Check if CHS defined in ROMVARS
    97     call    AccessDPT_GetPointerToDRVPARAMStoCSBX
    98     test    byte [cs:bx+DRVPARAMS.wFlags], FLG_DRVPARAMS_USERCHS    ; User specified P-CHS?
     97    call    GetUserDefinedCapacityToBXAXandFlagsToCXandModeToDXfromROMVARS
     98    test    cl, FLG_DRVPARAMS_USERCHS
    9999    jz      SHORT .AutodetectPCHSvalues
    100100
    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
     101    ; Translate P-CHS to L-CHS
     102    call    AtaGeometry_GetLCHStoAXBLBHfromPCHSinAXBLBHandTranslateModeInDX
    105103    jmp     SHORT .StoreLCHStoDPT
    106 
    107     ; Get L-CHS parameters and addressing mode
    108104.AutodetectPCHSvalues:
    109     call    AtaGeometry_GetLCHStoAXBLBHfromAtaInfoInESSI
     105    call    AtaGeometry_GetLCHStoAXBLBHfromAtaInfoInESSIandTranslateModeInDX
    110106
    111107.StoreLCHStoDPT:
    112     eSHL_IM dl, ADDRESSING_MODE_FIELD_POSITION
     108    eSHL_IM dl, TRANSLATEMODE_FIELD_POSITION
    113109    or      cl, dl
    114110    or      [di+DPT.bFlagsLow], cl      ; Shift count and addressing mode
     
    144140
    145141    ; Load user defined LBA
    146     call    AccessDPT_GetPointerToDRVPARAMStoCSBX
    147     test    BYTE [cs:bx+DRVPARAMS.wFlags], FLG_DRVPARAMS_USERLBA
     142    call    GetUserDefinedCapacityToBXAXandFlagsToCXandModeToDXfromROMVARS
     143    test    cl, FLG_DRVPARAMS_USERLBA
    148144    jz      SHORT .KeepTotalSectorsFromAtaID
    149     mov     ax, [cs:bx+DRVPARAMS.dwMaximumLBA]
    150     mov     dx, [cs:bx+DRVPARAMS.dwMaximumLBA+2]
    151     xor     bx, bx
    152145
    153146    ; Compare user defined and ATA-ID sector count and select smaller
     147    xor     dx, dx
     148    xchg    bx, dx      ; User defined LBA now in BX:DX:AX
    154149    cmp     bx, [di+DPT.twLbaSectors+4]
    155150    jb      SHORT .StoreUserDefinedSectorCountToDPT
     
    160155    jae     SHORT .KeepTotalSectorsFromAtaID
    161156.StoreUserDefinedSectorCountToDPT:
    162     xor     cx, cx      ; Always LBA28 for user defined values
     157    ; CL bit FLGL_DPT_LBA48 is clear at this point
    163158    call    StoreLba48AddressingFromCLandTotalSectorCountFromBXDXAX
    164159
     
    234229
    235230
     231;--------------------------------------------------------------------
     232; GetUserDefinedCapacityToBXAXandFlagsToCXandModeToDXfromROMVARS
     233;   Parameters:
     234;       DS:DI:      Ptr to Disk Parameter Table
     235;   Returns:
     236;       AX:         User defined P-CHS Cylinders or LBA low word
     237;       BX:         User defined P-CHS Heads and Sectors or LBA high word
     238;       DX:         Translate mode or TRANSLATEMODE_AUTO
     239;       CX:         FLG_DRVPARAMS_USERCHS if user defined CHS in BX:AX
     240;                   FLG_DRVPARAMS_USERLBA if user defined LBA in BX:AX
     241;                   Zero if user has not defined capacity
     242;   Corrupts registers:
     243;       Nothing
     244;--------------------------------------------------------------------
     245GetUserDefinedCapacityToBXAXandFlagsToCXandModeToDXfromROMVARS:
     246    call    AccessDPT_GetPointerToDRVPARAMStoCSBX
     247
     248    ; Get settings
     249    mov     cx, [cs:bx+DRVPARAMS.wFlags]
     250    mov     dx, cx
     251    and     cx, BYTE FLG_DRVPARAMS_USERCHS | FLG_DRVPARAMS_USERLBA
     252    and     dx, BYTE MASK_DRVPARAMS_TRANSLATEMODE
     253    eSHR_IM dx, TRANSLATEMODE_FIELD_POSITION
     254
     255    ; Get capacity
     256    mov     ax, [cs:bx+DRVPARAMS.wCylinders]        ; Or .dwMaximumLBA
     257    mov     bx, [cs:bx+DRVPARAMS.wHeadsAndSectors]  ; Or .dwMaximumLBA+2
     258    ret
     259
     260
    236261%ifdef MODULE_EBIOS
    237262;--------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.