Changeset 363 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Handlers


Ignore:
Timestamp:
Mar 26, 2012, 4:20:43 PM (12 years ago)
Author:
aitotat@…
google:author:
aitotat@gmail.com
Message:

Changes to XTIDE Universal BIOS:

  • Added Advanced ATA Module (MODULE_ADVANCED_ATA) with native support for QDI Vision QD6500 and QD6580 VLB IDE Controllers.
  • Hopefully optimized IDE transfer functions for 8088 (replaced some memory accesses from WORD to BYTE).
  • XT build does not fit in 8k at the moment!!!
Location:
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm

    r294 r363  
    3838;       CF:     0 if successful, 1 if error
    3939;   Corrupts registers:
    40 ;       AL, BX, DX
     40;       AL, BX, CX, DX
    4141;--------------------------------------------------------------------
    4242AH9h_InitializeDriveForUse:
     43    push    es
    4344    push    si
    44     push    cx
     45    call    ClearErrorFlagFromBootMenuInfo  ; Do this for serial devices as well
    4546
    4647%ifdef MODULE_SERIAL
    47     ;
    48     ; no need to do this for serial devices, and we use the DPT_RESET flag bits
    49     ; to store the drive type for serial floppy drives (MODULE_SERIAL_FLOPPY)
    50     ;
     48    ; no need to do this for serial devices
    5149    xor     ah, ah
    5250    test    byte [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE    ; Clears CF
    53     jnz     .ReturnNotSuccessful
     51    jnz     .ReturnWithErrorCodeInAH
     52
     53%else
     54    ; Clear Initialization Error flag from DPT
     55    and     BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_INITERROR
    5456%endif
    5557
    5658    ; Try to select drive and wait until ready
    57     or      BYTE [di+DPT.bFlagsHigh], MASKH_DPT_RESET       ; Everything uninitialized
    5859    call    AccessDPT_GetDriveSelectByteToAL
    5960    mov     [bp+IDEPACK.bDrvAndHead], al
    6061    call    Device_SelectDrive
    61     jc      SHORT .ReturnNotSuccessful
    62     and     BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_RESET_nDRDY ; Clear since success
     62    mov     al, FLG_INIT_FAILED_TO_SELECT_DRIVE
     63    call    SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo
     64    jc      SHORT .ReturnWithErrorCodeInAH
    6365
    6466    ; Initialize CHS parameters if LBA is not used
    6567    call    InitializeDeviceParameters
    66     jc      SHORT .SetWriteCache
    67     and     BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_RESET_nINITPRMS
     68    mov     al, FLG_INIT_FAILED_TO_INITIALIZE_CHS_PARAMETERS
     69    call    SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo
    6870
    6971    ; Enable or Disable Write Cache
    70 .SetWriteCache:
    7172    call    SetWriteCache
     73    mov     al, FLG_INIT_FAILED_TO_SET_WRITE_CACHE
     74    call    SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo
    7275
    7376    ; Recalibrate drive by seeking to cylinder 0
    7477.RecalibrateDrive:
    7578    call    AH11h_RecalibrateDrive
    76     jc      SHORT .InitializeBlockMode
    77     and     BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_RESET_nRECALIBRATE
     79    mov     al, FLG_INIT_FAILED_TO_RECALIBRATE_DRIVE
     80    call    SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo
    7881
    7982    ; Initialize block mode transfers
    8083.InitializeBlockMode:
    8184    call    InitializeBlockMode
    82     jc      SHORT .ReturnNotSuccessful
    83     and     BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_RESET_nSETBLOCK ; Keeps CF clear
    84 
    85 .ReturnNotSuccessful:
    86     pop     cx
     85    mov     al, FLG_INIT_FAILED_TO_SET_BLOCK_MODE
     86    call    SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo
     87
     88%ifdef MODULE_ADVANCED_ATA
     89; Initialize fastest supported PIO mode
     90.InitializePioMode:
     91    call    InitializePioMode
     92    mov     al, FLG_INIT_FAILED_TO_SET_PIO_MODE
     93    call    SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo
     94%endif
     95
     96    ; There might have been several errors so just return
     97    ; one error code for them all
     98    test    BYTE [di+DPT.bFlagsHigh], FLGH_DPT_INITERROR
     99    jz      SHORT .ReturnWithErrorCodeInAH
     100    mov     ah, RET_HD_RESETFAIL
     101    stc
     102
     103.ReturnWithErrorCodeInAH:
    87104    pop     si
     105    pop     es
    88106    ret
    89107
     
    140158
    141159
     160%ifdef MODULE_ADVANCED_ATA
     161;--------------------------------------------------------------------
     162; InitializePioMode
     163;   Parameters:
     164;       DS:DI:  Ptr to DPT (in RAMVARS segment)
     165;   Returns:
     166;       AH:     BIOS Error code
     167;       CF:     Cleared if successful
     168;               Set if any error
     169;   Corrupts registers:
     170;       AL, BX, CX, DX
     171;--------------------------------------------------------------------
     172InitializePioMode:
     173    xor     dx, dx                      ; Parameter to Sector Count Register = 0 = PIO_DEFAULT_MODE
     174    mov     al, [di+DPT_ATA.bPioMode]
     175    cmp     al, 3                       ; PIO mode 3 and above require IORDY
     176    jb      SHORT .SetTransferMode
     177    or      dl, al
     178.SetTransferMode:
     179    mov     si, FEATURE_SET_TRANSFER_MODE
     180    jmp     AH23h_SetControllerFeatures
     181%endif
     182
     183
    142184;--------------------------------------------------------------------
    143185; InitializeBlockMode
     
    160202    eCMOVNZ al, [di+DPT_ATA.bMaxBlock]  ; Load max block size
    161203    jmp     AH24h_SetBlockSize
     204
     205
     206;--------------------------------------------------------------------
     207; ClearErrorFlagFromBootMenuInfo
     208;   Parameters:
     209;       DS:DI:  Ptr to DPT
     210;   Returns:
     211;       Nothing
     212;   Corrupts registers:
     213;       BX, ES
     214;--------------------------------------------------------------------
     215ClearErrorFlagFromBootMenuInfo:
     216    call    BootMenuInfo_IsAvailable    ; Load BOOTMENUINFO segment to ES
     217    jne     SHORT .DoNotStoreErrorFlags
     218    call    BootMenuInfo_ConvertDPTtoBX
     219    mov     WORD [es:bx+BOOTMENUINFO.wInitErrorFlags], 0    ; Must clear whole WORD!
     220.DoNotStoreErrorFlags:
     221    ret
     222
     223
     224;--------------------------------------------------------------------
     225; SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo
     226;   Parameters:
     227;       AH:     BIOS Error Code
     228;       AL:     Error flag to set
     229;       DS:DI:  Ptr to DPT
     230;   Returns:
     231;       CF:     Clear if no error
     232;               Set if error flag was set
     233;   Corrupts registers:
     234;       BX, ES
     235;--------------------------------------------------------------------
     236SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo:
     237    jnc     SHORT NoErrorFlagToSet
     238    cmp     ah, RET_HD_INVALID
     239    jbe     SHORT .IgnoreInvalidCommandError
     240
     241    call    BootMenuInfo_IsAvailable
     242    jne     SHORT .BootvarsNotAvailableSoDoNotSetErrorFlag
     243
     244    call    BootMenuInfo_ConvertDPTtoBX
     245    or      [es:bx+BOOTMENUINFO.wInitErrorFlags], al
     246.BootvarsNotAvailableSoDoNotSetErrorFlag:
     247    or      BYTE [di+DPT.bFlagsHigh], FLGH_DPT_INITERROR
     248    stc
     249    ret
     250.IgnoreInvalidCommandError:
    162251ReturnSuccessSinceInitializationNotNeeded:
    163252    xor     ah, ah
    164     ret
     253NoErrorFlagToSet:
     254    ret
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm

    r294 r363  
    5353
    5454    ; Initialize Master and Slave drives
    55     eMOVZX  ax, [di+DPT.bIdevarsOffset]         ; (AL) pointer to controller we are looking to reset
     55    eMOVZX  ax, BYTE [di+DPT.bIdevarsOffset]    ; (AL) pointer to controller we are looking to reset
    5656                                                ; (AH) initialize error code, assume success
    5757
    58     mov     si, IterateAndResetDrives
     58    mov     si, IterateAndResetDrives           ; Callback function for FindDPT_IterateAllDPTs
    5959    call    FindDPT_IterateAllDPTs
    6060
     
    7373; merged into overall error code for this controller.  Master will be reset
    7474; first.  Note that the iteration will go until the end of the DPT list.
     75;
     76;   Parameters:
     77;       AL:     Offset to IDEVARS for drives to initialize
     78;       AH:     Error status from previous initialization
     79;       DS:DI:  Ptr to DPT to examine
     80;   Returns:
     81;       AH:     Error status from initialization
     82;       CF:     Set to iterate all DPTs
     83;   Corrupts registers:
     84;       AL, BX, DX
    7585;--------------------------------------------------------------------
    7686IterateAndResetDrives:
     
    7888    jne     .done
    7989    push    ax
     90    push    cx
    8091    call    AH9h_InitializeDriveForUse          ; Reset Master and Slave (Master will come first in DPT list)
     92
     93%ifdef MODULE_ADVANCED_ATA
     94    jc      SHORT .SkipControllerInitSinceError
     95    call    InitializeAdvancedIdeControllers    ; Done after drive init so drives are first set to advanced PIO mode, then the controller
     96.SkipControllerInitSinceError:
     97%endif
     98
     99    pop     cx
    81100    pop     ax
    82101    jnc     .done
     
    85104    stc                                         ; From IterateAllDPTs perspective, the DPT is never found (continue iteration)
    86105    ret
     106
     107
     108%ifdef MODULE_ADVANCED_ATA
     109;--------------------------------------------------------------------
     110; Here we initialize the more advanced controllers (VLB and PCI)
     111; to get better performance for systems with 32-bit bus.
     112;
     113; This step is optional since the controllers use slowest possible
     114; settings by default if they are not initialized.
     115;
     116; InitializeAdvancedIdeController
     117;   Parameters:
     118;       DS:DI:  Ptr to DPT
     119;   Returns:
     120;       CF:     Cleared if success or no controller to initialize
     121;               Set if error
     122;   Corrupts registers:
     123;       AX, BX, CX, DX
     124;--------------------------------------------------------------------
     125InitializeAdvancedIdeControllers:
     126    ; We want to initialize the advanced controller only after both
     127    ; Master and Slave drive are initialized to correct PIO mode.
     128    ; We check if next DPT is for the same IDE controller. If it is,
     129    ; we skip the initialization.
     130    mov     al, [di+DPT.bIdevarsOffset]
     131    cmp     al, [di++LARGEST_DPT_SIZE+DPT.bIdevarsOffset]
     132    je      SHORT .SkipInitializationUntilNextDrive ; CF cleared
     133
     134    jmp     AdvAtaInit_InitializeControllerForDPTinDSDI
     135.SkipInitializationUntilNextDrive:
     136    clc
     137    ret
     138
     139%endif  ; MODULE_ADVANCED_ATA
Note: See TracChangeset for help on using the changeset viewer.