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!!!
File:
1 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
Note: See TracChangeset for help on using the changeset viewer.