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

Last change on this file since 473 was 473, checked in by aitotat@…, 12 years ago

Changes to XTIDE Universal BIOS:

  • Large changes to prepare full XT-CF support (DMA not yet implemented and memory mapped transfers are not working).
File size: 4.9 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Int 13h function AH=1Eh, Lo-tech XT-CF features.
3
4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
7;
8; This program is free software; you can redistribute it and/or modify
9; it under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2 of the License, or
11; (at your option) any later version.
12;
13; This program is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16; GNU General Public License for more details.
17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;
19
20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
24; Int 13h function AH=1Eh, Lo-tech XT-CF features.
25; This function is supported only by XTIDE Universal BIOS.
26;
27; AH1Eh_HandlerForXTCFfeatures
28; Parameters:
29; AL, CX: Same as in INTPACK
30; DL: Translated Drive number
31; DS:DI: Ptr to DPT (in RAMVARS segment)
32; SS:BP: Ptr to IDEPACK
33; Parameters on INTPACK:
34; AL: XT-CF subcommand (see XTCF.inc for more info)
35; Returns with INTPACK:
36; AH: Int 13h return status
37; CF: 0 if successful, 1 if error
38;--------------------------------------------------------------------
39AH1Eh_HandlerForXTCFfeatures:
40%ifndef USE_186
41 call AH1Eh_ProcessXTCFsubcommandFromAL
42 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
43%else
44 push Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
45 ; Fall to AH1Eh_ProcessXTCFsubcommandFromAL
46%endif
47
48
49;--------------------------------------------------------------------
50; AH1Eh_ProcessXTCFsubcommandFromAL
51; Parameters:
52; AL: XT-CF subcommand (see XTCF.inc for more info)
53; DS:DI: Ptr to DPT (in RAMVARS segment)
54; SS:BP: Ptr to IDEPACK
55; Returns:
56; AH: Int 13h return status
57; CF: 0 if successful, 1 if error
58; Corrupts registers:
59; AL, BX, CX, DX, SI
60;--------------------------------------------------------------------
61AH1Eh_ProcessXTCFsubcommandFromAL:
62 ; IS_THIS_DRIVE_XTCF. We check this for all commands.
63 call AccessDPT_IsThisDeviceXTCF
64 jne SHORT XTCFnotFound
65 and ax, BYTE 7Fh ; Subcommand now in AX
66 jz SHORT .ReturnWithSuccess ; IS_THIS_DRIVE_XTCF
67
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
73 in al, dx
74 mov [bp+IDEPACK.intpack+INTPACK.dh], al
75.ReturnWithSuccess:
76 xor ah, ah
77 ret
78.SkipReadXtcfControlRegisterToDH:
79
80 ; WRITE_DH_TO_XTCF_CONTROL_REGISTER
81 dec ax ; Subcommand
82 jnz SHORT XTCFnotFound ; Invalid subcommand
83 mov al, [bp+IDEPACK.intpack+INTPACK.dh]
84 ; Fall to AH1Eh_ChangeXTCFmodeBasedOnControlRegisterInAL
85
86
87;--------------------------------------------------------------------
88; AH1Eh_ChangeXTCFmodeBasedOnControlRegisterInAL
89; Parameters:
90; AL: XT-CF Control Register
91; DS:DI: Ptr to DPT (in RAMVARS segment)
92; SS:BP: Ptr to IDEPACK
93; Returns:
94; AH: Int 13h return status
95; CF: 0 if successful, 1 if error
96; Corrupts registers:
97; AL, BX, CX, DX, SI
98;--------------------------------------------------------------------
99AH1Eh_ChangeXTCFmodeBasedOnControlRegisterInAL:
100 ; Output Control Register
101 mov dx, [di+DPT.wBasePort]
102 add dl, XTCF_CONTROL_REGISTER
103 out dx, al
104
105 ; Convert Control Register Contents to device code
106 test al, al
107 jz SHORT .Set8bitPioMode
108 cmp al, XTCF_MEMORY_MAPPED_MODE
109 jae SHORT .SetMemoryMappedMode
110
111 ; Set DMA Mode
112 mov BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_DMA
113 jmp AH23h_Disable8bitPioMode
114
115.SetMemoryMappedMode:
116 mov BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_MEMMAP
117 jmp AH23h_Disable8bitPioMode
118
119.Set8bitPioMode:
120 mov BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_PIO8
121 jmp AH23h_Enable8bitPioMode
122
123
124;--------------------------------------------------------------------
125; AH1Eh_DetectXTCFwithBasePortInDX
126; Parameters:
127; DX: Base I/O port address to check
128; Returns:
129; AH: RET_HD_SUCCESS if XT-CF is found from port
130; RET_HD_INVALID if XT-CF is not found
131; CF: Cleared if XT-CF found
132; Set if XT-CF not found
133; Corrupts registers:
134; AL
135;--------------------------------------------------------------------
136AH1Eh_DetectXTCFwithBasePortInDX:
137 push dx
138 add dl, XTCT_CONTROL_REGISTER_INVERTED_in ; set DX to XT-CF config register (inverted)
139 in al, dx ; get value
140 mov ah, al ; save in ah
141 inc dx ; set DX to XT-CF config register (non-inverted)
142 in al, dx ; get value
143 not al ; invert value
144 pop dx
145 sub ah, al ; do they match? (clear AH if they do)
146 jz SHORT XTCFfound
147
148XTCFnotFound:
149AH1Eh_LoadInvalidCommandToAHandSetCF:
150 stc ; set carry flag since XT-CF not found
151 mov ah, RET_HD_INVALID
152XTCFfound:
153 ret ; and return
Note: See TracBrowser for help on using the repository browser.