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 | ;--------------------------------------------------------------------
|
---|
43 | AH1Eh_HandlerForXTCFfeatures:
|
---|
44 | %ifndef USE_186
|
---|
45 | call ProcessXTCFsubcommandFromAL
|
---|
46 | jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
|
---|
47 | %else
|
---|
48 | push Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
|
---|
49 | ; Fall to ProcessXTCFsubcommandFromAL
|
---|
50 | %endif
|
---|
51 |
|
---|
52 |
|
---|
53 | ;--------------------------------------------------------------------
|
---|
54 | ; ProcessXTCFsubcommandFromAL
|
---|
55 | ; Parameters:
|
---|
56 | ; AL: XT-CF subcommand (see XTCF.inc for more info)
|
---|
57 | ; DS:DI: Ptr to DPT (in RAMVARS segment)
|
---|
58 | ; SS:BP: Ptr to IDEPACK
|
---|
59 | ; Returns:
|
---|
60 | ; AH: Int 13h return status
|
---|
61 | ; CF: 0 if successful, 1 if error
|
---|
62 | ; DX Command return values (see XTCF.inc)
|
---|
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, BYTE 7Fh ; 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 .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
|
---|
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 | ; whos 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 | ; We always need to enable 8-bit mode since 16-bit mode is restored
|
---|
116 | ; 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 |
|
---|
132 | ePUSH_T bx, AH23h_Enable8bitPioMode
|
---|
133 |
|
---|
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
|
---|
139 |
|
---|
140 | ; XTCF_DMA_MODE = 2 (allow 3 as well for more optimized code)
|
---|
141 | mov BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_DMA
|
---|
142 |
|
---|
143 | ; DMA transfers have limited block sizee
|
---|
144 | mov al, [di+DPT_ATA.bBlockSize]
|
---|
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
|
---|
148 |
|
---|
149 | .Set8bitPioMode:
|
---|
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
|
---|
156 |
|
---|
157 |
|
---|
158 | ;--------------------------------------------------------------------
|
---|
159 | ; AH1Eh_GetCurrentXTCFmodeToAX
|
---|
160 | ; Parameters:
|
---|
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
|
---|
165 | ; Corrupts registers:
|
---|
166 | ; Nothing
|
---|
167 | ;--------------------------------------------------------------------
|
---|
168 | AH1Eh_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
|
---|