Move get current drive int21 function to winedos.
[wine] / dlls / winedos / ioports.c
1 /*
2  * Emulation of processor ioports.
3  *
4  * Copyright 1995 Morten Welinder
5  * Copyright 1998 Andreas Mohr, Ove Kaaven
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 #include "config.h"
23
24 #include "windef.h"
25 #include "dosexe.h"
26 #include "vga.h"
27 #include "wine/debug.h"
28
29 WINE_DEFAULT_DEBUG_CHANNEL(int);
30
31 /**********************************************************************
32  *          DOSVM_inport
33  */
34 BOOL WINAPI DOSVM_inport( int port, int size, DWORD *res )
35 {
36     switch (port)
37     {
38     case 0x60:
39         *res = DOSVM_Int09ReadScan(NULL);
40         break;
41     case 0x22a:
42     case 0x22c:
43     case 0x22e:
44         *res = (DWORD)SB_ioport_in( port );
45         break;
46     case 0x3ba:
47     case 0x3c0:
48     case 0x3c1:
49     case 0x3c2:
50     case 0x3c3:
51     case 0x3c4:
52     case 0x3c5:
53     case 0x3c6:
54     case 0x3c7:
55     case 0x3c8:
56     case 0x3c9:
57     case 0x3ca:
58     case 0x3cb:
59     case 0x3cc:
60     case 0x3cd:
61     case 0x3ce:
62     case 0x3cf:
63     case 0x3d0:
64     case 0x3d1:
65     case 0x3d2:
66     case 0x3d3:
67     case 0x3d4:
68     case 0x3d5:
69     case 0x3d6:
70     case 0x3d7:
71     case 0x3d8:
72     case 0x3d9:
73     case 0x3da:
74     case 0x3db:
75     case 0x3dc:
76     case 0x3dd:
77     case 0x3de:
78     case 0x3df:
79         if(size > 1)
80            FIXME("Trying to read more than one byte from VGA!\n");
81         *res = (DWORD)VGA_ioport_in( port );
82         break;
83     case 0x00:
84     case 0x01:
85     case 0x02:
86     case 0x03:
87     case 0x04:
88     case 0x05:
89     case 0x06:
90     case 0x07:
91     case 0xC0:
92     case 0xC2:
93     case 0xC4:
94     case 0xC6:
95     case 0xC8:
96     case 0xCA:
97     case 0xCC:
98     case 0xCE:
99     case 0x87:
100     case 0x83:
101     case 0x81:
102     case 0x82:
103     case 0x8B:
104     case 0x89:
105     case 0x8A:
106     case 0x487:
107     case 0x483:
108     case 0x481:
109     case 0x482:
110     case 0x48B:
111     case 0x489:
112     case 0x48A:
113     case 0x08:
114     case 0xD0:
115     case 0x0D:
116     case 0xDA:
117         *res = (DWORD)DMA_ioport_in( port );
118         break;
119     default:
120         return FALSE;  /* not handled */
121     }
122     return TRUE;  /* handled */
123 }
124
125
126 /**********************************************************************
127  *          DOSVM_outport
128  */
129 BOOL WINAPI DOSVM_outport( int port, int size, DWORD value )
130 {
131     switch (port)
132     {
133     case 0x20:
134         DOSVM_PIC_ioport_out( port, (BYTE)value );
135         break;
136     case 0x226:
137     case 0x22c:
138         SB_ioport_out( port, (BYTE)value );
139         break;
140     case 0x3c0:
141     case 0x3c1:
142     case 0x3c2:
143     case 0x3c3:
144     case 0x3c4:
145     case 0x3c5:
146     case 0x3c6:
147     case 0x3c7:
148     case 0x3c8:
149     case 0x3c9:
150     case 0x3ca:
151     case 0x3cb:
152     case 0x3cc:
153     case 0x3cd:
154     case 0x3ce:
155     case 0x3cf:
156     case 0x3d0:
157     case 0x3d1:
158     case 0x3d2:
159     case 0x3d3:
160     case 0x3d4:
161     case 0x3d5:
162     case 0x3d6:
163     case 0x3d7:
164     case 0x3d8:
165     case 0x3d9:
166     case 0x3da:
167     case 0x3db:
168     case 0x3dc:
169     case 0x3dd:
170     case 0x3de:
171     case 0x3df:
172         VGA_ioport_out( port, LOBYTE(value) );
173         if(size > 1) {
174             VGA_ioport_out( port+1, HIBYTE(value) );
175             if(size > 2) {
176                 VGA_ioport_out( port+2, LOBYTE(HIWORD(value)) );
177                 VGA_ioport_out( port+3, HIBYTE(HIWORD(value)) );
178             }
179         }
180         break;
181     case 0x00:
182     case 0x01:
183     case 0x02:
184     case 0x03:
185     case 0x04:
186     case 0x05:
187     case 0x06:
188     case 0x07:
189     case 0xC0:
190     case 0xC2:
191     case 0xC4:
192     case 0xC6:
193     case 0xC8:
194     case 0xCA:
195     case 0xCC:
196     case 0xCE:
197     case 0x87:
198     case 0x83:
199     case 0x81:
200     case 0x82:
201     case 0x8B:
202     case 0x89:
203     case 0x8A:
204     case 0x487:
205     case 0x483:
206     case 0x481:
207     case 0x482:
208     case 0x48B:
209     case 0x489:
210     case 0x48A:
211     case 0x08:
212     case 0xD0:
213     case 0x0B:
214     case 0xD6:
215     case 0x0A:
216     case 0xD4:
217     case 0x0F:
218     case 0xDE:
219     case 0x09:
220     case 0xD2:
221     case 0x0C:
222     case 0xD8:
223     case 0x0D:
224     case 0xDA:
225     case 0x0E:
226     case 0xDC:
227         DMA_ioport_out( port, (BYTE)value );
228         break;
229     default:
230         return FALSE;  /* not handled */
231     }
232     return TRUE;  /* handled */
233 }