source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1Eh_XTCF.asm @ 558

Last change on this file since 558 was 558, checked in by krille_n_@…, 11 years ago

Changes:

  • Building the BIOS Drive Information Tool now works again.
  • Moved all XT-CF related code to MODULE_8BIT_IDE_ADVANCED. I don't see how an XT-CF card could work without *_ADVANCED anyway but if I'm wrong, feel free to undo this. Note! The autodetection code in XTIDECFG has NOT been changed to reflect this (still relies on MODULE_8BIT_IDE).
  • Optimizations and fixes in general.
File size: 6.3 KB
RevLine 
[471]1; Project name  :   XTIDE Universal BIOS
[545]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
[471]5
6;
[491]7; XTIDE Universal BIOS and Associated Tools
[526]8; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
[471]9;
10; This program is free software; you can redistribute it and/or modify
11; it under the terms of the GNU General Public License as published by
12; the Free Software Foundation; either version 2 of the License, or
13; (at your option) any later version.
[491]14;
[471]15; This program is distributed in the hope that it will be useful,
16; but WITHOUT ANY WARRANTY; without even the implied warranty of
17; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
[491]18; GNU General Public License for more details.
[471]19; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
[491]20;
[471]21
[545]22; Modified by JJP for XT-CFv3 support, Mar-13
23
[471]24; Section containing code
25SECTION .text
26
27;--------------------------------------------------------------------
28; Int 13h function AH=1Eh, Lo-tech XT-CF features.
29; This function is supported only by XTIDE Universal BIOS.
30;
31; AH1Eh_HandlerForXTCFfeatures
32;   Parameters:
33;       AL, CX: Same as in INTPACK
34;       DL:     Translated Drive number
35;       DS:DI:  Ptr to DPT (in RAMVARS segment)
36;       SS:BP:  Ptr to IDEPACK
37;   Parameters on INTPACK:
38;       AL:     XT-CF subcommand (see XTCF.inc for more info)
39;   Returns with INTPACK:
40;       AH:     Int 13h return status
41;       CF:     0 if successful, 1 if error
[558]42;       DX:     Command return values (see XTCF.inc)
[471]43;--------------------------------------------------------------------
44AH1Eh_HandlerForXTCFfeatures:
45%ifndef USE_186
[475]46    call    ProcessXTCFsubcommandFromAL
[471]47    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
48%else
[558]49    push    Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
[475]50    ; Fall to ProcessXTCFsubcommandFromAL
[471]51%endif
52
53
54;--------------------------------------------------------------------
[475]55; ProcessXTCFsubcommandFromAL
[471]56;   Parameters:
[473]57;       AL:     XT-CF subcommand (see XTCF.inc for more info)
[471]58;       DS:DI:  Ptr to DPT (in RAMVARS segment)
59;       SS:BP:  Ptr to IDEPACK
60;   Returns:
61;       AH:     Int 13h return status
62;       CF:     0 if successful, 1 if error
63;   Corrupts registers:
[473]64;       AL, BX, CX, DX, SI
[471]65;--------------------------------------------------------------------
[475]66ProcessXTCFsubcommandFromAL:
[472]67    ; IS_THIS_DRIVE_XTCF. We check this for all commands.
[473]68    call    AccessDPT_IsThisDeviceXTCF
[545]69    jne     SHORT .XTCFnotFound
[558]70    and     ax, 0FFh                    ; Subcommand now in AX (clears AH and CF)
[545]71    jz      SHORT .XTCFfound            ; Sub-function IS_THIS_DRIVE_XTCF (=0)
[472]72
[545]73    dec     ax                          ; Test subcommand...
74    jz      SHORT .SetXTCFtransferMode  ; ...for value 1 (SET_XTCF_TRANSFER_MODE)
[491]75
[545]76    dec     ax                          ; Test subcommand for value 2 (GET_XTCF_TRANSFER_MODE)
[558]77    jnz     SHORT .AH1Eh_LoadInvalidCommandToAHandSetCF
[473]78
[545]79    ; GET_XTCF_TRANSFER_MODE
80    call    AH1Eh_GetCurrentXTCFmodeToAX
[558]81    mov     dh, al
[545]82    mov     dl, [di+DPT_ATA.bBlockSize]
[558]83    mov     [bp+IDEPACK.intpack+INTPACK.dx], dx ; Return mode value (DH) and block size (DL) via INTPACK
[545]84.XTCFfound:
[558]85    ret     ; With AH and CF cleared
[473]86
[545]87.XTCFnotFound:
88.AH1Eh_LoadInvalidCommandToAHandSetCF:
[558]89    stc     ; Set carry flag since XT-CF not found or invalid subcommand
[545]90    mov     ah, RET_HD_INVALID
[558]91    ret
[545]92
93.SetXTCFtransferMode:
[558]94    mov     al, [bp+IDEPACK.intpack+INTPACK.dh] ; Get specified mode (eg XTCF_DMA_MODE)
95    ; Fall to AH1Eh_ChangeXTCFmodeBasedOnModeInAL
[545]96
97
[473]98;--------------------------------------------------------------------
[545]99; AH1Eh_ChangeXTCFmodeBasedOnModeInAL
[473]100;   Parameters:
[545]101;       AL:     XT-CF Mode (see XTCF.inc)
[473]102;       DS:DI:  Ptr to DPT (in RAMVARS segment)
103;       SS:BP:  Ptr to IDEPACK
[558]104;   Returns:
[473]105;       AH:     Int 13h return status
106;       CF:     0 if successful, 1 if error
107;   Corrupts registers:
108;       AL, BX, CX, DX, SI
109;--------------------------------------------------------------------
[545]110AH1Eh_ChangeXTCFmodeBasedOnModeInAL:
111    ; Note: Control register (as of XT-CFv3) is now a write-only register,
[558]112    ;       whose purpose is *only* to raise DRQ.  The register cannot be read.
[545]113    ;       Selected transfer mode is stored in BIOS variable (DPT_ATA.bDevice).
[472]114
[545]115    ; Note that when selecting 'DEVICE_8BIT_PIO_MODE_WITH_BIU_OFFLOAD' mode,
116    ; the ATA device (i.e. CompactFlash card) will operate in 8-bit mode, but
[558]117    ; data will be transferred from its data register using 16-bit CPU instructions
[545]118    ; like REP INSW.  This works because XT-CF adapters are 8-bit cards, and
119    ; the BIU in the machine splits each WORD requested by the CPU into two 8-bit
120    ; ISA cycles at base+0h and base+1h.  The XT-CF cards do not decode A0, hence
121    ; both accesses appear the same to the card and the BIU then re-constructs
122    ; the data for presentation to the CPU.
123    ;
[558]124    ; Also note that some machines, noteably the Olivetti M24 (also known as
125    ; the AT&T PC6300 and Xerox 6060), have hardware errors in the BIU logic,
126    ; resulting in reversed byte ordering.  Therefore, mode DEVICE_8BIT_PIO is
127    ; the default transfer mode for best system compatibility.
[545]128
[558]129    ; We always need to enable 8-bit mode since 16-bit mode is restored
130    ; when controller is reset (AH=00h or 0Dh)
[505]131    ePUSH_T bx, AH23h_Enable8bitPioMode
132
[545]133    ; Convert mode to device type (see XTCF.inc for full details)
134    and     ax, 3
[558]135    jz      SHORT .Set8bitPioMode   ; XTCF_8BIT_PIO_MODE = 0
136    dec     ax                      ; XTCF_8BIT_PIO_MODE_WITH_BIU_OFFLOAD = 1
137    jz      SHORT .Set8bitPioModeWithBIUOffload
[472]138
[545]139    ; XTCF_DMA_MODE = 2 (allow 3 as well for more optimized code)
[473]140    mov     BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_DMA
[545]141
[558]142    ; DMA transfers have limited block size
[474]143    mov     al, [di+DPT_ATA.bBlockSize]
[558]144    cmp     al, XTCF_DMA_MODE_MAX_BLOCK_SIZE
145    jbe     SHORT AH24h_SetBlockSize
146    mov     al, XTCF_DMA_MODE_MAX_BLOCK_SIZE
147    jmp     SHORT AH24h_SetBlockSize
[473]148
149.Set8bitPioMode:
[558]150    mov     al, DEVICE_8BIT_XTCF_PIO8
151    SKIP2B  bx
[491]152
[545]153.Set8bitPioModeWithBIUOffload:
[558]154    mov     al, DEVICE_8BIT_XTCF_PIO8_WITH_BIU_OFFLOAD
155    mov     [di+DPT_ATA.bDevice], al
156    ret
[473]157
[545]158
[472]159;--------------------------------------------------------------------
[545]160; AH1Eh_GetCurrentXTCFmodeToAX
[472]161;   Parameters:
[545]162;       DS:DI:  Ptr to DPT (in RAMVARS segment)
[558]163;   Returns:
[545]164;       AX:     XT-CF mode (XTCF_8BIT_PIO_MODE, XTCF_8BIT_PIO_MODE_WITH_BIU_OFFLOAD or XTCF_DMA_MODE)
165;       CF:     Clear
[472]166;   Corrupts registers:
[545]167;       Nothing
[472]168;--------------------------------------------------------------------
[545]169AH1Eh_GetCurrentXTCFmodeToAX:
[558]170    mov     al, [di+DPT_ATA.bDevice]
171    shr     al, 1
172    cbw
173    sub     al, DEVICE_8BIT_XTCF_PIO8 >> 1
[545]174    ret
Note: See TracBrowser for help on using the repository browser.