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

Last change on this file since 589 was 589, checked in by krille_n_, 8 years ago

Changes:

  • BIOS: Fixed a purely cosmetic bug from r542 where, in builds containing MODULE_EBIOS, the boot menu would display an incorrect drive size (0.4 kB with MODULE_STRINGS_COMPRESSED or 0.5 kB without) for old drives with no support for LBA.
  • Fixed a bug from r392 where Vision_DetectAndReturnIDinAXandPortInDXifControllerPresent would return the ID in AL instead of AH (if DANGEROUS_DETECTION had been defined).
  • Fixed a bug from r587 in AdvAtaInit.asm that would prevent detection of QDI Vision controllers.
  • Also changed how the QDI Vision IDs are defined (removed the need for shifting) to avoid confusion. This fixed a potential bug from r587 in AdvAtaInit.asm where some IDs were not being shifted.
  • Fixed a bug in PDC20x30.asm from r587 where GetPdcIDtoAX would not return with the IDE base port in DX so DisablePdcProgrammingMode would fail.
  • Made some changes to ModuleDependency.inc and other files so that MODULE_ADVANCED_ATA now requires USE_386. Consequently it is no longer included in the regular AT-builds, only in the 386_8k-build.
  • Moved the UNROLL_SECTORS_IN_CX_TO_xWORDS macros from IDE_8bit.inc to IdeIO.inc which means it's now possible to build a BIOS without MODULE_8BIT_IDE.
  • XTIDECFG: Added a minimum DOS version check (since it needs DOS version 2+) to allow the program to quit gracefully in the unlikely scenario where someone tries to run it under DOS version 1.
  • Made some changes to Drive.asm to improve drive enumeration. The old method using GET_DOS_DRIVE_PARAMETER_BLOCK_FOR_SPECIFIC_DRIVE worked well in Windows XP but not in Windows 98 SE (in Windows or in DOS mode). The two problems were; 1) The function call would access the drives which on single floppy drive systems would cause Windows to swap between A: and B: (throwing a blue screen asking the user to insert a disk etc). 2) Only floppy drives and FAT16 drives would be available in the list of drives, no FAT32/optical/network drives.
  • Improved code in IdeControllerMenu.asm so that the default port addresses for all IDE interfaces are now restored when (re-)selecting the (same) type of IDE device.
  • Also made it impossible to select a device type unless the required module is included in the loaded BIOS.
  • The version check done when loading a BIOS now uses the FLASH_SIGNATURE definition from Version.inc. Any changes affecting RomVars now only requires updating that definition. This means that changes to RomVars must be implemented in both the BIOS and XTIDECFG before being committed to the repository.
  • Added a compatibility fix for 3Com 3C503 cards to the ROM checksumming code in Buffers.asm (Buffers_GenerateChecksum).
  • SerDrive: Made some minor changes to file names and paths to improve compatibility with case sensitive environments.
  • BIOSDRVS: Made a minor size optimization which as a side effect also makes it compatible with all DOS versions including DOS version 1.
  • Library: Renamed the WAIT_RETRACE_IF_NECESSARY_THEN macro to CALL_WAIT_FOR_RETRACE_IF_NECESSARY_THEN and made a tail-call-optimized version of it (JMP_WAIT_FOR_RETRACE_IF_NECESSARY_THEN).
  • A speed optimization to the eRCL_IM macro for 386 and higher. This change breaks emulation in the sense that the macro will fail when given a memory operand as the first parameter.
  • Other minor optimizations and fixes.
File size: 6.2 KB
Line 
1; Project name  :   XTIDE Universal BIOS
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
5
6;
7; XTIDE Universal BIOS and Associated Tools
8; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
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.
14;
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
18; GNU General Public License for more details.
19; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20;
21
22; Section containing code
23SECTION .text
24
25;--------------------------------------------------------------------
26; Int 13h function AH=1Eh, Lo-tech XT-CF features.
27; This function is supported only by XTIDE Universal BIOS.
28;
29; AH1Eh_HandlerForXTCFfeatures
30;   Parameters:
31;       AL, CX: Same as in INTPACK
32;       DL:     Translated Drive number
33;       DS:DI:  Ptr to DPT (in RAMVARS segment)
34;       SS:BP:  Ptr to IDEPACK
35;   Parameters on INTPACK:
36;       AL:     XT-CF subcommand (see XTCF.inc for more info)
37;   Returns with INTPACK:
38;       AH:     Int 13h return status
39;       CF:     0 if successful, 1 if error
40;       DX:     Command return values (see XTCF.inc)
41;--------------------------------------------------------------------
42AH1Eh_HandlerForXTCFfeatures:
43%ifndef USE_186
44    call    ProcessXTCFsubcommandFromAL
45    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
46%else
47    push    Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
48    ; Fall to ProcessXTCFsubcommandFromAL
49%endif
50
51
52;--------------------------------------------------------------------
53; ProcessXTCFsubcommandFromAL
54;   Parameters:
55;       AL:     XT-CF subcommand (see XTCF.inc for more info)
56;       DS:DI:  Ptr to DPT (in RAMVARS segment)
57;       SS:BP:  Ptr to IDEPACK
58;   Returns:
59;       AH:     Int 13h return status
60;       CF:     0 if successful, 1 if error
61;   Corrupts registers:
62;       AL, BX, CX, DX, SI
63;--------------------------------------------------------------------
64ProcessXTCFsubcommandFromAL:
65    ; IS_THIS_DRIVE_XTCF. We check this for all commands.
66    call    AccessDPT_IsThisDeviceXTCF
67    jc      SHORT .XTCFnotFound
68    and     ax, 0FFh                    ; Subcommand now in AX (clears AH and CF)
69    jz      SHORT .XTCFfound            ; Sub-function IS_THIS_DRIVE_XTCF (=0)
70
71    dec     ax                          ; Test subcommand...
72    jz      SHORT .SetXTCFtransferMode  ; ...for value 1 (SET_XTCF_TRANSFER_MODE)
73
74    dec     ax                          ; Test subcommand for value 2 (GET_XTCF_TRANSFER_MODE)
75    jnz     SHORT .AH1Eh_LoadInvalidCommandToAHandSetCF
76
77    ; GET_XTCF_TRANSFER_MODE
78    call    AH1Eh_GetCurrentXTCFmodeToAX
79    mov     dh, al
80    mov     dl, [di+DPT_ATA.bBlockSize]
81    mov     [bp+IDEPACK.intpack+INTPACK.dx], dx ; Return mode value (DH) and block size (DL) via INTPACK
82.XTCFfound:
83    ret     ; With AH and CF cleared
84
85.XTCFnotFound:
86.AH1Eh_LoadInvalidCommandToAHandSetCF:
87    stc     ; Set carry flag since XT-CF not found or invalid subcommand
88    mov     ah, RET_HD_INVALID
89    ret
90
91.SetXTCFtransferMode:
92    mov     al, [bp+IDEPACK.intpack+INTPACK.dh] ; Get specified mode (eg XTCF_DMA_MODE)
93    ; Fall to AH1Eh_ChangeXTCFmodeBasedOnModeInAL
94
95
96;--------------------------------------------------------------------
97; AH1Eh_ChangeXTCFmodeBasedOnModeInAL
98;   Parameters:
99;       AL:     XT-CF Mode (see XTCF.inc)
100;       DS:DI:  Ptr to DPT (in RAMVARS segment)
101;       SS:BP:  Ptr to IDEPACK
102;   Returns:
103;       AH:     Int 13h return status
104;       CF:     0 if successful, 1 if error
105;   Corrupts registers:
106;       AL, BX, CX, DX, SI
107;--------------------------------------------------------------------
108AH1Eh_ChangeXTCFmodeBasedOnModeInAL:
109    ; Note: Control register (as of XT-CFv3) is now a write-only register,
110    ;       whose purpose is *only* to raise DRQ.  The register cannot be read.
111    ;       Selected transfer mode is stored in BIOS variable (DPT_ATA.bDevice).
112
113    ; Note that when selecting 'XTCF_8BIT_PIO_MODE_WITH_BIU_OFFLOAD' mode,
114    ; the ATA device (i.e. CompactFlash card) will operate in 8-bit mode, but
115    ; data will be transferred from its data register using 16-bit CPU instructions
116    ; like REP INSW.  This works because XT-CF adapters are 8-bit cards, and
117    ; the BIU in the machine splits each WORD requested by the CPU into two 8-bit
118    ; ISA cycles at base+0h and base+1h.  The XT-CF cards do not decode A0, hence
119    ; both accesses appear the same to the card and the BIU then re-constructs
120    ; the data for presentation to the CPU.
121    ;
122    ; Also note that some machines, noteably the Olivetti M24 (also known as
123    ; the AT&T PC6300 and Xerox 6060), have hardware errors in the BIU logic,
124    ; resulting in reversed byte ordering.  Therefore, XTCF_8BIT_PIO_MODE is
125    ; the default transfer mode for best system compatibility.
126
127
128    ; Is requested mode valid?
129    cmp     al, 3                       ; Valid modes are 0...3
130    ja      SHORT ProcessXTCFsubcommandFromAL.AH1Eh_LoadInvalidCommandToAHandSetCF
131
132    ; Convert mode to XT-CF device type (see RomVars.inc and XTCF.inc for full details)
133    eSHL_IM al, 1                       ; Shift requested mode
134    add     al, XTCF_DEVICE_OFFSET      ; Add the device offset (already shifted)
135    mov     [di+DPT_ATA.bDevice], al    ; Set the new mode (or device actually)
136
137    cmp     al, DEVICE_8BIT_XTCF_PIO16_WITH_BIU_OFFLOAD
138    je      SHORT AH23h_Disable8bitPioMode
139
140    ; We always need to enable 8-bit mode since 16-bit mode is restored
141    ; when controller is reset (AH=00h or 0Dh)
142
143    cmp     al, DEVICE_8BIT_XTCF_DMA
144    jne     SHORT AH23h_Enable8bitPioMode
145
146    ; DMA transfers have limited block size
147    mov     al, XTCF_DMA_MODE_MAX_BLOCK_SIZE
148    cmp     [di+DPT_ATA.bBlockSize], al
149    jbe     SHORT AH23h_Enable8bitPioMode   ; No need to limit block size
150    call    AH24h_SetBlockSize
151    jmp     SHORT AH23h_Enable8bitPioMode
152
153
154;--------------------------------------------------------------------
155; AH1Eh_GetCurrentXTCFmodeToAX
156;   Parameters:
157;       DS:DI:  Ptr to DPT (in RAMVARS segment)
158;   Returns:
159;       AX:     XT-CF mode (see XTCF.inc)
160;       CF:     Clear
161;   Corrupts registers:
162;       Nothing
163;--------------------------------------------------------------------
164AH1Eh_GetCurrentXTCFmodeToAX:
165    mov     ax, -XTCF_DEVICE_OFFSET & 0FFh
166    add     al, [di+DPT_ATA.bDevice]
167    shr     al, 1
168    ret
169
Note: See TracBrowser for help on using the repository browser.