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


Ignore:
Timestamp:
Apr 19, 2013, 11:44:35 AM (12 years ago)
Author:
aitotat@…
google:author:
aitotat@gmail.com
Message:

Changes to XTIDE Universal BIOS:

  • Integrated XT-CFv3 support by James Pearce.
  • XT-CFv2 memory mapped I/O and DMA modes are no longer supported (but PIO mode is).
Location:
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h
Files:
5 edited

Legend:

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

    r526 r545  
    11; Project name  :   XTIDE Universal BIOS
    2 ; Description   :   Int 13h function AH=1Eh, Lo-tech XT-CF features.
     2; Description   :   Int 13h function AH=1Eh, Lo-tech XT-CF features
     3;
     4; More information at http://www.lo-tech.co.uk/XT-CF
    35
    46;
     
    1719; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    1820;
     21
     22; Modified by JJP for XT-CFv3 support, Mar-13
    1923
    2024; Section containing code
     
    4246    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
    4347%else
    44     push    Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
     48    push        Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
    4549    ; Fall to ProcessXTCFsubcommandFromAL
    4650%endif
     
    5660;       AH:     Int 13h return status
    5761;       CF:     0 if successful, 1 if error
     62;       DX      Command return values (see XTCF.inc)
    5863;   Corrupts registers:
    5964;       AL, BX, CX, DX, SI
     
    6267    ; IS_THIS_DRIVE_XTCF. We check this for all commands.
    6368    call    AccessDPT_IsThisDeviceXTCF
    64     jne     SHORT XTCFnotFound
     69    jne     SHORT .XTCFnotFound
    6570    and     ax, BYTE 7Fh                ; Subcommand now in AX (clears AH and CF)
    66     jz      SHORT .ReturnWithSuccess    ; IS_THIS_DRIVE_XTCF
     71    jz      SHORT .XTCFfound            ; Sub-function IS_THIS_DRIVE_XTCF (=0)
    6772
    68     ; READ_XTCF_CONTROL_REGISTER_TO_DH
    69     dec     ax                          ; Subcommand
    70     jnz     SHORT .SkipReadXtcfControlRegisterToDH
    71     mov     dx, [di+DPT.wBasePort]
    72     add     dl, XTCF_CONTROL_REGISTER   ; Will never overflow (keeps CF cleared)
    73     in      al, dx
    74     mov     [bp+IDEPACK.intpack+INTPACK.dh], al
    75 .ReturnWithSuccess:
    76     ret     ; With AH and CF cleared
     73    dec     ax                          ; Test subcommand...
     74    jz      SHORT .SetXTCFtransferMode  ; ...for value 1 (SET_XTCF_TRANSFER_MODE)
    7775
    78 .SkipReadXtcfControlRegisterToDH:
    79     ; WRITE_DH_TO_XTCF_CONTROL_REGISTER
    80     dec     ax                          ; Subcommand
    81     jnz     SHORT XTCFnotFound          ; Invalid subcommand
    82     mov     al, [bp+IDEPACK.intpack+INTPACK.dh]
    83     ; Fall to AH1Eh_ChangeXTCFmodeBasedOnControlRegisterInAL
     76    dec     ax                          ; Test subcommand for value 2 (GET_XTCF_TRANSFER_MODE)
     77    jnz     SHORT .XTCFnotFound         ; Invalid subcommand
     78
     79    ; GET_XTCF_TRANSFER_MODE
     80    call    AH1Eh_GetCurrentXTCFmodeToAX
     81    mov     dl, [di+DPT_ATA.bBlockSize]
     82    mov     [bp+IDEPACK.intpack+INTPACK.dh], al ; return mode value...
     83    mov     [bp+IDEPACK.intpack+INTPACK.dl], dl ; ...and block size, via INTPACK...
     84.XTCFfound:
     85    ret                                         ; ...with AH and CF cleared
     86
     87.XTCFnotFound:
     88.AH1Eh_LoadInvalidCommandToAHandSetCF:
     89    stc                 ; set carry flag since XT-CF not found
     90    mov     ah, RET_HD_INVALID
     91    ret                 ; and return
     92
     93.SetXTCFtransferMode:
     94    mov     al, [bp+IDEPACK.intpack+INTPACK.dh] ; get specified mode (eg XTCF_DMA_MODE)
     95    ; and fall to AH1Eh_ChangeXTCFmodeBasedOnControlRegisterInAL
    8496
    8597
    8698;--------------------------------------------------------------------
    87 ; AH1Eh_ChangeXTCFmodeBasedOnControlRegisterInAL
     99; AH1Eh_ChangeXTCFmodeBasedOnModeInAL
    88100;   Parameters:
    89 ;       AL:     XT-CF Control Register
     101;       AL:     XT-CF Mode (see XTCF.inc)
    90102;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    91103;       SS:BP:  Ptr to IDEPACK
    92 ;   Returns:
     104;   Returns:   
    93105;       AH:     Int 13h return status
    94106;       CF:     0 if successful, 1 if error
     
    96108;       AL, BX, CX, DX, SI
    97109;--------------------------------------------------------------------
    98 AH1Eh_ChangeXTCFmodeBasedOnControlRegisterInAL:
    99     ; Output Control Register
    100     mov     dx, [di+DPT.wBasePort]
    101     add     dl, XTCF_CONTROL_REGISTER
    102     out     dx, al
     110AH1Eh_ChangeXTCFmodeBasedOnModeInAL:
     111    ; Note: Control register (as of XT-CFv3) is now a write-only register,
     112    ;       whos purpose is *only* to raise DRQ.  The register cannot be read.
     113    ;       Selected transfer mode is stored in BIOS variable (DPT_ATA.bDevice).
    103114
    104115    ; We always need to enable 8-bit mode since 16-bit mode is restored
    105116    ; when controller is reset (AH=00h or 0Dh)
     117    ;
     118    ; Note that when selecting 'DEVICE_8BIT_PIO_MODE_WITH_BIU_OFFLOAD' mode,
     119    ; the ATA device (i.e. CompactFlash card) will operate in 8-bit mode, but
     120    ; data will be transferred from it's data register using 16-bit CPU instructions
     121    ; like REP INSW.  This works because XT-CF adapters are 8-bit cards, and
     122    ; the BIU in the machine splits each WORD requested by the CPU into two 8-bit
     123    ; ISA cycles at base+0h and base+1h.  The XT-CF cards do not decode A0, hence
     124    ; both accesses appear the same to the card and the BIU then re-constructs
     125    ; the data for presentation to the CPU.
     126    ;
     127    ; Also note though that some machines, noteably AT&T PC6300, have hardware
     128    ; errors in the BIU logic, resulting in reversed byte ordering.  Therefore,
     129    ; mode DEVICE_8BIT_PIO is the default transfer mode for best system
     130    ; compatibility.
     131
    106132    ePUSH_T bx, AH23h_Enable8bitPioMode
    107133
    108     ; Convert Control Register Contents to device code
    109     test    al, al
    110     jz      SHORT .Set8bitPioMode
    111     cmp     al, XTCF_MEMORY_MAPPED_MODE
    112     jae     SHORT .SetMemoryMappedMode
     134    ; Convert mode to device type (see XTCF.inc for full details)
     135    and     ax, 3
     136    jz  SHORT .Set8bitPioMode   ; XTCF_8BIT_PIO_MODE = 0
     137    dec     ax                  ; XTCF_8BIT_PIO_MODE_WITH_BIU_OFFLOAD = 1
     138    jz  SHORT .Set8bitPioModeWithBIUOffload
    113139
    114     ; Set DMA Mode
     140    ; XTCF_DMA_MODE = 2 (allow 3 as well for more optimized code)
    115141    mov     BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_DMA
     142
     143    ; DMA transfers have limited block sizee
    116144    mov     al, [di+DPT_ATA.bBlockSize]
    117     cmp     al, XTCF_DMA_MODE_MAX_BLOCK_SIZE
    118     jbe     SHORT AH24h_SetBlockSize
    119     mov     al, XTCF_DMA_MODE_MAX_BLOCK_SIZE
    120     jmp     SHORT AH24h_SetBlockSize
    121 
    122 .SetMemoryMappedMode:
    123     mov     al, DEVICE_8BIT_XTCF_MEMMAP
    124     SKIP2B  bx
     145    MIN_U   al, XTCF_DMA_MODE_MAX_BLOCK_SIZE
     146    jmp     AH24h_SetBlockSize
     147    ; exit via ret in AH24_SetBlockSize then through AH23h_Enable8bitPioMode
    125148
    126149.Set8bitPioMode:
    127     mov     al, DEVICE_8BIT_XTCF_PIO8
    128     mov     [di+DPT_ATA.bDevice], al
    129     ret     ; Via AH23h_Enable8bitPioMode
     150    mov     BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_PIO8
     151    ret     ; through AH23h_Enable8bitPioMode
     152
     153.Set8bitPioModeWithBIUOffload:
     154    mov     BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_PIO8_WITH_BIU_OFFLOAD
     155    ret     ; through AH23h_Enable8bitPioMode
    130156
    131157
    132158;--------------------------------------------------------------------
    133 ; AH1Eh_DetectXTCFwithBasePortInDX
     159; AH1Eh_GetCurrentXTCFmodeToAX
    134160;   Parameters:
    135 ;       DX:     Base I/O port address to check
    136 ;   Returns:
    137 ;       AH:     RET_HD_SUCCESS if XT-CF is found from port
    138 ;               RET_HD_INVALID if XT-CF is not found
    139 ;       CF:     Cleared if XT-CF found
    140 ;               Set if XT-CF not found
     161;       DS:DI:  Ptr to DPT (in RAMVARS segment)
     162;   Returns:   
     163;       AX:     XT-CF mode (XTCF_8BIT_PIO_MODE, XTCF_8BIT_PIO_MODE_WITH_BIU_OFFLOAD or XTCF_DMA_MODE)
     164;       CF:     Clear
    141165;   Corrupts registers:
    142 ;       AL
     166;       Nothing
    143167;--------------------------------------------------------------------
    144 AH1Eh_DetectXTCFwithBasePortInDX:
    145     push    dx
    146     add     dl, XTCF_CONTROL_REGISTER_INVERTED_in   ; set DX to XT-CF config register (inverted)
    147     in      al, dx      ; get value
    148     mov     ah, al      ; save in ah
    149     inc     dx          ; set DX to XT-CF config register (non-inverted)
    150     in      al, dx      ; get value
    151     not     al          ; invert value
    152     pop     dx
    153     sub     ah, al      ; do they match? (clear AH if they do)
    154     jz      SHORT XTCFfound
    155 
    156 XTCFnotFound:
    157 AH1Eh_LoadInvalidCommandToAHandSetCF:
    158     stc                 ; set carry flag since XT-CF not found
    159     mov     ah, RET_HD_INVALID
    160 XTCFfound:
    161     ret                 ; and return
     168AH1Eh_GetCurrentXTCFmodeToAX:
     169    eMOVZX  ax, BYTE [di+DPT_ATA.bDevice]   ; get current mode from DPT
     170    sub     al, DEVICE_8BIT_XTCF_PIO8
     171    shr     ax, 1                           ; Device type to XT-CF mode
     172    ret
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH24h_HSetBlocks.asm

    r526 r545  
    6363    cmp     al, XTCF_DMA_MODE_MAX_BLOCK_SIZE
    6464    jbe     SHORT .NoNeedToLimitBlockSize
     65
     66    ; Return error if we tried too large block for XT-CF.
     67    ; Do not limit it to maximum supported since software calling AH=24h
     68    ; must know what the actual block size is.
    6569    cmp     BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_DMA
    66     je      SHORT AH1Eh_LoadInvalidCommandToAHandSetCF
     70    je      SHORT ProcessXTCFsubcommandFromAL.AH1Eh_LoadInvalidCommandToAHandSetCF
    6771.NoNeedToLimitBlockSize:
    6872%endif ; MODULE_8BIT_IDE_ADVANCED
     
    7781    pop     bx
    7882    jnc     SHORT .StoreBlockSize
    79     mov     bl, 1       ; Block size 1 will always work
     83
     84    ; Drive disabled block mode since we tried unsupported block size.
     85    ; We must adjust DPT accordingly.
     86    mov     bl, 1       ; Block size 1 will always work (=Block mode disabled)
    8087.StoreBlockSize:        ; Store new block size to DPT and return
    8188    mov     [di+DPT_ATA.bBlockSize], bl
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH8h_HParams.asm

    r543 r545  
    5858
    5959    test    byte [bp+IDEPACK.intpack+INTPACK.dl], 080h
    60     jnz     .Done
     60    jnz     SHORT .CalledForHardDrive
    6161
    6262    mov     [bp+IDEPACK.intpack+INTPACK.bl], bl
     
    6767    call    FloppyDrive_GetCountToAX
    6868
    69 .Done:
     69.CalledForHardDrive:
    7070    mov     ah, dh
    7171
     
    133133%ifdef MODULE_SERIAL_FLOPPY
    134134    mov     bl, [di+DPT.bFlagsHigh]
    135 %ifndef CHECK_FOR_UNUSED_ENTRYPOINTS             ; not sure why this is needed for preprocessor-only
    136135    eSHR_IM bl, FLGH_DPT_SERIAL_FLOPPY_TYPE_FIELD_POSITION
    137 %endif
    138136%endif
    139137    ret
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm

    r542 r545  
    114114;;; Set XT-CF mode
    115115%ifdef MODULE_8BIT_IDE_ADVANCED
    116     call    AccessDPT_GetIdevarsToCSBX
    117     mov     al, [cs:bx+IDEVARS.bXTCFcontrolRegister]
     116    call    AH1Eh_GetCurrentXTCFmodeToAX
    118117    call    AH9h_SetModeFromALtoXTCF
    119118    STORE_ERROR_FLAG_TO_DPT     FLG_INITERROR_FAILED_TO_SET_XTCF_MODE
     
    284283    call    AccessDPT_IsThisDeviceXTCF
    285284    jne     SHORT IgnoreInvalidCommandError
    286     jmp     AH1Eh_ChangeXTCFmodeBasedOnControlRegisterInAL
     285    jmp     AH1Eh_ChangeXTCFmodeBasedOnModeInAL
    287286%endif ; MODULE_8BIT_IDE_ADVANCED
    288287
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH48h_GetExtendedDriveParameters.asm

    r544 r545  
    139139    sbb     dx, (MAX_SECTOR_COUNT_TO_RETURN_PCHS+1) >> 16
    140140    sbb     bx, cx      ; Zero
    141     jnc     SHORT .ReturnWithSuccess
     141    jnc     SHORT .DoNotSetChsFlag
    142142    or      BYTE [di+EDRIVE_INFO.wFlags], FLG_CHS_INFORMATION_IS_VALID
    143143
     144    ; We store something to P-CHS anyway since some HW detection programs
     145    ; ignore the CHS flag. And we should at least clear the variables anyway
     146    ; since the same buffer is used for all drives so it contains parameters
     147    ; from previously scanned drive.
     148.DoNotSetChsFlag:
    144149    eMOVZX  dx, BYTE [es:si+DPT.bPchsHeads]
    145150    mov     [di+EDRIVE_INFO.dwHeads], dx
Note: See TracChangeset for help on using the changeset viewer.