Changeset 365 in xtideuniversalbios


Ignore:
Timestamp:
Mar 27, 2012, 5:01:57 PM (10 years ago)
Author:
aitotat@…
google:author:
aitotat@gmail.com
Message:

Changes to XTIDE Universal BIOS:

  • Errors from AH=9h are stored to DPTs again.
  • XT build fits in 8k again.
Location:
trunk/XTIDE_Universal_BIOS
Files:
11 edited

Legend:

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

    r364 r365  
    3232%else
    3333                            resb    2   ; padding to make BOOTMENUINFO size an even multiple of DPT size
    34 %endif
    35                            
    36                            
     34%endif             
    3735endstruc
    3836
    39 ; Flags for BOOTMENUINFO.wInitErrorFlags
    40 FLG_INIT_FAILED_TO_SELECT_DRIVE                 EQU     (1<<0)
    41 FLG_INIT_FAILED_TO_INITIALIZE_CHS_PARAMETERS    EQU     (1<<1)
    42 FLG_INIT_FAILED_TO_SET_WRITE_CACHE              EQU     (1<<2)
    43 FLG_INIT_FAILED_TO_RECALIBRATE_DRIVE            EQU     (1<<3)
    44 FLG_INIT_FAILED_TO_SET_BLOCK_MODE               EQU     (1<<4)
    45 FLG_INIT_FAILED_TO_SET_PIO_MODE                 EQU     (1<<5)
    4637
    4738DPT_BOOTMENUINFO_SIZE_MULTIPLIER  equ   BOOTMENUINFO_size / LARGEST_DPT_SIZE
  • trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc

    r364 r365  
    4040
    4141; IDE device only
    42 FLGH_DPT_INITERROR              EQU (1<<7)
    4342%ifdef MODULE_ADVANCED_ATA
    44 FLGH_DPT_IORDY                  EQU (1<<6)  ; Controller and Drive supports IORDY
     43FLGH_DPT_IORDY                  EQU (1<<7)  ; Controller and Drive supports IORDY
    4544%endif
    4645
     
    6160struc DPT_ATA   ; 10 + 2 bytes = 12 bytes
    6261    .dpt                        resb    DPT_size
     62    .bBlockSize                 resb    1   ; Current block size in sectors (do not set to zero!)
     63    .bInitError                 resb    1
     64endstruc
    6365
    64     ; Block size is specified in sectors (1, 2, 4, 8, 16, 32, 64 or 128)
    65     .wSetAndMaxBlock:
    66     .bSetBlock                  resb    1   ; Current block size (do not set to zero!)
    67     .bMaxBlock                  resb    1   ; Maximum block size, 0 = block mode not supported
    68 endstruc
     66; Flags for BOOTMENUINFO.wInitErrorFlags
     67FLG_INITERROR_FAILED_TO_SELECT_DRIVE                EQU     (1<<0)
     68FLG_INITERROR_FAILED_TO_INITIALIZE_CHS_PARAMETERS   EQU     (1<<1)
     69FLG_INITERROR_FAILED_TO_SET_WRITE_CACHE             EQU     (1<<2)
     70FLG_INITERROR_FAILED_TO_RECALIBRATE_DRIVE           EQU     (1<<3)
     71FLG_INITERROR_FAILED_TO_SET_BLOCK_MODE              EQU     (1<<4)
     72FLG_INITERROR_FAILED_TO_SET_PIO_MODE                EQU     (1<<5)
    6973
    7074
  • trunk/XTIDE_Universal_BIOS/Inc/IdeRegisters.inc

    r363 r365  
    6464
    6565; Commands for IDE Controller
     66COMMAND_RECALIBRATE                     EQU     10h
    6667COMMAND_READ_SECTORS                    EQU     20h
    6768COMMAND_READ_SECTORS_EXT                EQU     24h     ; LBA48
  • trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuInfo.asm

    r364 r365  
    6565
    6666;--------------------------------------------------------------------
    67 ; BootMenuInfo_IsAvailable
    68 ;   Parameters:
    69 ;       Nothing
    70 ;   Returns:
    71 ;       ES:     Segment to BOOTVARS with BOOTMENUINFOs
    72 ;       ZF:     Set if BOOTVARS with BOOTMENUINFOs is available
    73 ;               Cleared if not available (no longer initializing)
    74 ;   Corrupts registers:
    75 ;       BX
    76 ;--------------------------------------------------------------------
    77 BootMenuInfo_IsAvailable:
    78     LOAD_BDA_SEGMENT_TO es, bx
    79     cmp     WORD [es:BOOTVARS.wMagicWord], BOOTVARS_MAGIC_WORD
    80     ret
    81 
    82 
    83 ;--------------------------------------------------------------------
    8467; Returns offset to BOOTMENUINFO based on DPT pointer.
    8568;
     
    9073;       BX:     Offset to BOOTMENUINFO struct
    9174;   Corrupts registers:
    92 ;       Nothing
     75;       AX
    9376;--------------------------------------------------------------------
    9477BootMenuInfo_ConvertDPTtoBX:
    95     push    ax
    9678    mov     ax, di
    9779    sub     ax, BYTE RAMVARS_size                   ; subtract off base of DPTs
     
    10082    add     ax, BOOTVARS.rgBootNfo                  ; add base of BOOTMENUINFO
    10183    xchg    ax, bx
    102     pop     ax
    10384    ret
  • trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrintCfg.asm

    r363 r365  
    6565    test    BYTE [di+DPT.bFlagsHigh], FLGH_DPT_BLOCK_MODE_SUPPORTED
    6666    jz      SHORT .PushBlockSizeFromAX
    67     mov     al, [di+DPT_ATA.bSetBlock]
     67    mov     al, [di+DPT_ATA.bBlockSize]
    6868.PushBlockSizeFromAX:
    6969    push    ax
     
    114114;--------------------------------------------------------------------
    115115.PushResetStatus:
    116     call    BootMenuInfo_IsAvailable    ; Load segment to ES
    117     call    BootMenuInfo_ConvertDPTtoBX
    118     push    WORD [es:bx+BOOTMENUINFO.wInitErrorFlags]
     116    xor     ax, ax
     117%ifdef MODULE_SERIAL
     118    test    BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
     119    jnz     SHORT .AlwaysSuccess
     120    mov     al, [di+DPT_ATA.bInitError]
     121.AlwaysSuccess:
     122%endif
     123    push    ax
    119124
    120125;;; fall-out to BootMenuPrint_HardDiskRefreshInformation.
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm

    r363 r365  
    5555    mov     [di+DPT.wFlags], ax
    5656    mov     [di+DPT.bIdevarsOffset], bp
    57     mov     BYTE [di+DPT_ATA.bSetBlock], 1  ; Block = 1 sector
     57    mov     BYTE [di+DPT_ATA.bBlockSize], 1 ; Block = 1 sector
    5858%ifdef MODULE_ADVANCED_ATA
    5959    call    IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDPT.asm

    r364 r365  
    3030;--------------------------------------------------------------------
    3131.StoreBlockMode:
    32     mov     al, 1                           ; Block mode will be enabled on AH=9h
    33     mov     ah, [es:si+ATA1.bBlckSize]      ; Max block size in sectors
    34     mov     [di+DPT_ATA.wSetAndMaxBlock], ax
     32    mov     BYTE [di+DPT_ATA.bBlockSize], 1
    3533
    3634%ifdef MODULE_ADVANCED_ATA
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm

    r364 r365  
    180180    ; Store sizes
    181181    mov     [bp+PIOVARS.bSectorsLeft], ah
    182     eMOVZX  ax, BYTE [di+DPT_ATA.bSetBlock]
     182    eMOVZX  ax, BYTE [di+DPT_ATA.bBlockSize]
    183183    mov     [bp+PIOVARS.wSectorsInBlock], ax
    184184    mov     [bp+PIOVARS.bSectorsDone], ah       ; Zero
  • trunk/XTIDE_Universal_BIOS/Src/Device/MemoryMappedIDE/MemIdeTransfer.asm

    r294 r365  
    4242    mov     ch, [bp+IDEPACK.bSectorCount]
    4343    mov     [bp+MEMPIOVARS.wWordsLeft], cx
    44     mov     ch, [di+DPT_ATA.bSetBlock]
     44    mov     ch, [di+DPT_ATA.bBlockSize]
    4545    mov     [bp+MEMPIOVARS.wWordsInBlock], cx
    4646    mov     [bp+MEMPIOVARS.fpDPT], di
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH24h_HSetBlocks.asm

    r294 r365  
    4040;       CF:     0 if successful, 1 if error
    4141;   Corrupts registers:
    42 ;       AL, BX, CX, DX
     42;       AL, CX, DX
    4343;--------------------------------------------------------------------
    4444AH24h_SetBlockSize:
     45    push    bx
     46
    4547    push    ax
    46     xchg    dx, ax          ; DL = Block size (Sector Count Register)
    47     or      BYTE [di+DPT.bFlagsHigh], FLGH_DPT_BLOCK_MODE_SUPPORTED ; Assume success
     48    xchg    dx, ax      ; DL = Block size (Sector Count Register)
    4849    mov     al, COMMAND_SET_MULTIPLE_MODE
    4950    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRDY, FLG_STATUS_DRDY)
    5051    call    Idepack_StoreNonExtParametersAndIssueCommandFromAL
    5152    pop     bx
    52     jnc     .StoreBlockSize
    53     mov     bl, 1   ; Disable block mode
    54     and     BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_BLOCK_MODE_SUPPORTED
    55 .StoreBlockSize:    ; Store new block size to DPT and return
    56     mov     [di+DPT_ATA.bSetBlock], bl
     53    jnc     SHORT .StoreBlockSize
     54    mov     bl, 1       ; Block size 1 will always work
     55.StoreBlockSize:        ; Store new block size to DPT and return
     56    mov     [di+DPT_ATA.bBlockSize], bl
     57
     58    pop     bx
    5759    ret
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm

    r364 r365  
    4343    push    es
    4444    push    si
    45     call    ClearErrorFlagFromBootMenuInfo  ; Do this for serial devices as well
    4645
    4746%ifdef MODULE_SERIAL
     
    5251
    5352%else
    54     ; Clear Initialization Error flag from DPT
    55     and     BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_INITERROR
     53    ; Clear Initialization Error flags from DPT
     54    mov     BYTE [di+DPT_ATA.bInitError], 0
    5655%endif
    5756
     
    6059    mov     [bp+IDEPACK.bDrvAndHead], al
    6160    call    Device_SelectDrive
    62     mov     al, FLG_INIT_FAILED_TO_SELECT_DRIVE
    63     call    SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo
     61    mov     al, FLG_INITERROR_FAILED_TO_SELECT_DRIVE
     62    call    SetErrorFlagFromALwithErrorCodeInAH
    6463    jc      SHORT .ReturnWithErrorCodeInAH
    6564
    6665    ; Initialize CHS parameters if LBA is not used
    6766    call    InitializeDeviceParameters
    68     mov     al, FLG_INIT_FAILED_TO_INITIALIZE_CHS_PARAMETERS
    69     call    SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo
     67    mov     al, FLG_INITERROR_FAILED_TO_INITIALIZE_CHS_PARAMETERS
     68    call    SetErrorFlagFromALwithErrorCodeInAH
    7069
    7170    ; Enable or Disable Write Cache
    7271    call    SetWriteCache
    73     mov     al, FLG_INIT_FAILED_TO_SET_WRITE_CACHE
    74     call    SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo
     72    mov     al, FLG_INITERROR_FAILED_TO_SET_WRITE_CACHE
     73    call    SetErrorFlagFromALwithErrorCodeInAH
    7574
    7675    ; Recalibrate drive by seeking to cylinder 0
    7776.RecalibrateDrive:
    7877    call    AH11h_RecalibrateDrive
    79     mov     al, FLG_INIT_FAILED_TO_RECALIBRATE_DRIVE
    80     call    SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo
     78    mov     al, FLG_INITERROR_FAILED_TO_RECALIBRATE_DRIVE
     79    call    SetErrorFlagFromALwithErrorCodeInAH
    8180
    8281    ; Initialize block mode transfers
    8382.InitializeBlockMode:
    8483    call    InitializeBlockMode
    85     mov     al, FLG_INIT_FAILED_TO_SET_BLOCK_MODE
    86     call    SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo
     84    mov     al, FLG_INITERROR_FAILED_TO_SET_BLOCK_MODE
     85    call    SetErrorFlagFromALwithErrorCodeInAH
    8786
    8887%ifdef MODULE_ADVANCED_ATA
     
    9089.InitializePioMode:
    9190    call    InitializePioMode
    92     mov     al, FLG_INIT_FAILED_TO_SET_PIO_MODE
    93     call    SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo
     91    mov     al, FLG_INITERROR_FAILED_TO_SET_PIO_MODE
     92    call    SetErrorFlagFromALwithErrorCodeInAH
    9493%endif
    9594
    9695    ; There might have been several errors so just return
    9796    ; one error code for them all
    98     test    BYTE [di+DPT.bFlagsHigh], FLGH_DPT_INITERROR
    99     jz      SHORT .ReturnWithErrorCodeInAH
     97    cmp     BYTE [di+DPT_ATA.bInitError], 0
     98    je      SHORT .ReturnWithErrorCodeInAH
    10099    mov     ah, RET_HD_RESETFAIL
    101100    stc
     
    198197InitializeBlockMode:
    199198    test    BYTE [di+DPT.bFlagsHigh], FLGH_DPT_BLOCK_MODE_SUPPORTED ; Clear CF
    200     jz      SHORT ReturnSuccessSinceInitializationNotNeeded
    201 
     199    jz      SHORT .BlockModeNotSupportedOrDisabled
    202200    call    AccessDPT_GetPointerToDRVPARAMStoCSBX
    203     mov     al, 1                       ; Disable block mode
    204201    test    BYTE [cs:bx+DRVPARAMS.wFlags], FLG_DRVPARAMS_BLOCKMODE
    205     eCMOVNZ al, [di+DPT_ATA.bMaxBlock]  ; Load max block size
    206     jmp     AH24h_SetBlockSize
    207 
    208 
    209 ;--------------------------------------------------------------------
    210 ; ClearErrorFlagFromBootMenuInfo
    211 ;   Parameters:
    212 ;       DS:DI:  Ptr to DPT
    213 ;   Returns:
    214 ;       Nothing
    215 ;   Corrupts registers:
    216 ;       BX, ES
    217 ;--------------------------------------------------------------------
    218 ClearErrorFlagFromBootMenuInfo:
    219     call    BootMenuInfo_IsAvailable    ; Load BOOTMENUINFO segment to ES
    220     jne     SHORT .DoNotStoreErrorFlags
    221     call    BootMenuInfo_ConvertDPTtoBX
    222     mov     WORD [es:bx+BOOTMENUINFO.wInitErrorFlags], 0    ; Must clear whole WORD!
    223 .DoNotStoreErrorFlags:
    224     ret
    225 
    226 
    227 ;--------------------------------------------------------------------
    228 ; SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo
     202    jz      SHORT .BlockModeNotSupportedOrDisabled
     203
     204    ; Try block sizes until we find largest possible supported by drive
     205    mov     bl, 128
     206.TryNextBlockSize:
     207    mov     al, bl
     208    call    AH24h_SetBlockSize
     209    jnc     SHORT .SupportedBlockSizeFound
     210    shr     bl, 1                       ; Try next size
     211    jmp     SHORT .TryNextBlockSize
     212.SupportedBlockSizeFound:
     213    mov     [di+DPT_ATA.bBlockSize], bl
     214.BlockModeNotSupportedOrDisabled:
     215ReturnSuccessSinceInitializationNotNeeded:
     216    ret
     217
     218
     219;--------------------------------------------------------------------
     220; SetErrorFlagFromALwithErrorCodeInAH
    229221;   Parameters:
    230222;       AH:     BIOS Error Code
     
    237229;       BX, ES
    238230;--------------------------------------------------------------------
    239 SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo:
    240     jnc     SHORT NoErrorFlagToSet
     231SetErrorFlagFromALwithErrorCodeInAH:
     232    jnc     SHORT .NoErrorFlagToSet
    241233    cmp     ah, RET_HD_INVALID
    242234    jbe     SHORT .IgnoreInvalidCommandError
    243235
    244     call    BootMenuInfo_IsAvailable
    245     jne     SHORT .BootvarsNotAvailableSoDoNotSetErrorFlag
    246 
    247     call    BootMenuInfo_ConvertDPTtoBX
    248     or      [es:bx+BOOTMENUINFO.wInitErrorFlags], al
    249 .BootvarsNotAvailableSoDoNotSetErrorFlag:
    250     or      BYTE [di+DPT.bFlagsHigh], FLGH_DPT_INITERROR
     236    or      [di+DPT_ATA.bInitError], al
    251237    stc
    252238    ret
    253239.IgnoreInvalidCommandError:
    254 ReturnSuccessSinceInitializationNotNeeded:
    255240    xor     ah, ah
    256 NoErrorFlagToSet:
    257     ret
     241.NoErrorFlagToSet:
     242    ret
Note: See TracChangeset for help on using the changeset viewer.