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 | ; Modified by JJP for XT-CFv3 support, Mar-13
|
---|
23 |
|
---|
24 | ; Section containing code
|
---|
25 | SECTION .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
|
---|
42 | ; DX: Command return values (see XTCF.inc)
|
---|
43 | ;--------------------------------------------------------------------
|
---|
44 | AH1Eh_HandlerForXTCFfeatures:
|
---|
45 | %ifndef USE_186
|
---|
46 | call ProcessXTCFsubcommandFromAL
|
---|
47 | jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
|
---|
48 | %else
|
---|
49 | push Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
|
---|
50 | ; Fall to ProcessXTCFsubcommandFromAL
|
---|
51 | %endif
|
---|
52 |
|
---|
53 |
|
---|
54 | ;--------------------------------------------------------------------
|
---|
55 | ; ProcessXTCFsubcommandFromAL
|
---|
56 | ; Parameters:
|
---|
57 | ; AL: XT-CF subcommand (see XTCF.inc for more info)
|
---|
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:
|
---|
64 | ; AL, BX, CX, DX, SI
|
---|
65 | ;--------------------------------------------------------------------
|
---|
66 | ProcessXTCFsubcommandFromAL:
|
---|
67 | ; IS_THIS_DRIVE_XTCF. We check this for all commands.
|
---|
68 | call AccessDPT_IsThisDeviceXTCF
|
---|
69 | jne SHORT .XTCFnotFound
|
---|
70 | and ax, 0FFh ; Subcommand now in AX (clears AH and CF)
|
---|
71 | jz SHORT .XTCFfound ; Sub-function IS_THIS_DRIVE_XTCF (=0)
|
---|
72 |
|
---|
73 | dec ax ; Test subcommand...
|
---|
74 | jz SHORT .SetXTCFtransferMode ; ...for value 1 (SET_XTCF_TRANSFER_MODE)
|
---|
75 |
|
---|
76 | dec ax ; Test subcommand for value 2 (GET_XTCF_TRANSFER_MODE)
|
---|
77 | jnz SHORT .AH1Eh_LoadInvalidCommandToAHandSetCF
|
---|
78 |
|
---|
79 | ; GET_XTCF_TRANSFER_MODE
|
---|
80 | call AH1Eh_GetCurrentXTCFmodeToAX
|
---|
81 | mov dh, al
|
---|
82 | mov dl, [di+DPT_ATA.bBlockSize]
|
---|
83 | mov [bp+IDEPACK.intpack+INTPACK.dx], dx ; Return mode value (DH) and block size (DL) 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 or invalid subcommand
|
---|
90 | mov ah, RET_HD_INVALID
|
---|
91 | ret
|
---|
92 |
|
---|
93 | .SetXTCFtransferMode:
|
---|
94 | mov al, [bp+IDEPACK.intpack+INTPACK.dh] ; Get specified mode (eg XTCF_DMA_MODE)
|
---|
95 | ; Fall to AH1Eh_ChangeXTCFmodeBasedOnModeInAL
|
---|
96 |
|
---|
97 |
|
---|
98 | ;--------------------------------------------------------------------
|
---|
99 | ; AH1Eh_ChangeXTCFmodeBasedOnModeInAL
|
---|
100 | ; Parameters:
|
---|
101 | ; AL: XT-CF Mode (see XTCF.inc)
|
---|
102 | ; DS:DI: Ptr to DPT (in RAMVARS segment)
|
---|
103 | ; SS:BP: Ptr to IDEPACK
|
---|
104 | ; Returns:
|
---|
105 | ; AH: Int 13h return status
|
---|
106 | ; CF: 0 if successful, 1 if error
|
---|
107 | ; Corrupts registers:
|
---|
108 | ; AL, BX, CX, DX, SI
|
---|
109 | ;--------------------------------------------------------------------
|
---|
110 | AH1Eh_ChangeXTCFmodeBasedOnModeInAL:
|
---|
111 | ; Note: Control register (as of XT-CFv3) is now a write-only register,
|
---|
112 | ; whose purpose is *only* to raise DRQ. The register cannot be read.
|
---|
113 | ; Selected transfer mode is stored in BIOS variable (DPT_ATA.bDevice).
|
---|
114 |
|
---|
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
|
---|
117 | ; data will be transferred from its data register using 16-bit CPU instructions
|
---|
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 | ;
|
---|
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.
|
---|
128 |
|
---|
129 | ; We always need to enable 8-bit mode since 16-bit mode is restored
|
---|
130 | ; when controller is reset (AH=00h or 0Dh)
|
---|
131 | ePUSH_T bx, AH23h_Enable8bitPioMode
|
---|
132 |
|
---|
133 | ; Convert mode to device type (see XTCF.inc for full details)
|
---|
134 | and ax, 3
|
---|
135 | jz SHORT .Set8bitPioMode ; XTCF_8BIT_PIO_MODE = 0
|
---|
136 | dec ax ; XTCF_8BIT_PIO_MODE_WITH_BIU_OFFLOAD = 1
|
---|
137 | jz SHORT .Set8bitPioModeWithBIUOffload
|
---|
138 |
|
---|
139 | ; XTCF_DMA_MODE = 2 (allow 3 as well for more optimized code)
|
---|
140 | mov BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_DMA
|
---|
141 |
|
---|
142 | ; DMA transfers have limited block size
|
---|
143 | mov al, [di+DPT_ATA.bBlockSize]
|
---|
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
|
---|
148 |
|
---|
149 | .Set8bitPioMode:
|
---|
150 | mov al, DEVICE_8BIT_XTCF_PIO8
|
---|
151 | SKIP2B bx
|
---|
152 |
|
---|
153 | .Set8bitPioModeWithBIUOffload:
|
---|
154 | mov al, DEVICE_8BIT_XTCF_PIO8_WITH_BIU_OFFLOAD
|
---|
155 | mov [di+DPT_ATA.bDevice], al
|
---|
156 | ret
|
---|
157 |
|
---|
158 |
|
---|
159 | ;--------------------------------------------------------------------
|
---|
160 | ; AH1Eh_GetCurrentXTCFmodeToAX
|
---|
161 | ; Parameters:
|
---|
162 | ; DS:DI: Ptr to DPT (in RAMVARS segment)
|
---|
163 | ; Returns:
|
---|
164 | ; AX: XT-CF mode (XTCF_8BIT_PIO_MODE, XTCF_8BIT_PIO_MODE_WITH_BIU_OFFLOAD or XTCF_DMA_MODE)
|
---|
165 | ; CF: Clear
|
---|
166 | ; Corrupts registers:
|
---|
167 | ; Nothing
|
---|
168 | ;--------------------------------------------------------------------
|
---|
169 | AH1Eh_GetCurrentXTCFmodeToAX:
|
---|
170 | mov al, [di+DPT_ATA.bDevice]
|
---|
171 | shr al, 1
|
---|
172 | cbw
|
---|
173 | sub al, DEVICE_8BIT_XTCF_PIO8 >> 1
|
---|
174 | ret
|
---|