]> git.ipfire.org Git - u-boot.git/blame - board/MAI/bios_emulator/scitech/src/v86bios/io.c
* Code cleanup:
[u-boot.git] / board / MAI / bios_emulator / scitech / src / v86bios / io.c
CommitLineData
c7de829c
WD
1/*
2 * Copyright 1999 Egbert Eich
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of the authors not be used in
9 * advertising or publicity pertaining to distribution of the software without
10 * specific, written prior permission. The authors makes no representations
11 * about the suitability of this software for any purpose. It is provided
12 * "as is" without express or implied warranty.
13 *
14 * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
21 */
22#include "debug.h"
23
24#include <stdio.h>
25#if defined(__alpha__) || defined (__ia64__)
26#include <sys/io.h>
27#endif
28#include "AsmMacros.h"
29#include "v86bios.h"
30#include "pci.h"
31
32int r_inb = 0, r_inw = 0, r_inl = 0, r_outb = 0, r_outw = 0, r_outl = 0;
33int in_b = 0, in_w = 0, in_l = 0, out_b = 0, out_w = 0, out_l = 0;
34
35
36int
37port_rep_inb(CARD16 port, CARD8 *base, int d_f, CARD32 count)
38{
39 register int inc = d_f ? -1 : 1;
40 CARD8 *dst = base;
8bde7f77 41
c7de829c 42 p_printf(" rep_insb(%#x) %d bytes at %p %s",
8bde7f77 43 port, count, base, d_f?"up":"down");
c7de829c 44 if (Config.PrintIp)
8bde7f77 45 p_printf(" %x\n",getIP());
c7de829c
WD
46 else p_printf("\n");
47
48 r_inb++;
49 while (count--) {
8bde7f77
WD
50 *dst = inb(port);
51 dst += inc;
c7de829c
WD
52 }
53 return (dst-base);
54}
55
56int
57port_rep_inw(CARD16 port, CARD16 *base, int d_f, CARD32 count)
58{
59 register int inc = d_f ? -1 : 1;
60 CARD16 *dst = base;
8bde7f77 61
c7de829c 62 p_printf(" rep_insw(%#x) %d bytes at %p %s",
8bde7f77 63 port, count, base, d_f?"up":"down");
c7de829c 64 if (Config.PrintIp)
8bde7f77 65 p_printf(" %x\n",getIP());
c7de829c
WD
66 else p_printf("\n");
67
68 r_inw++;
69 while (count--) {
8bde7f77
WD
70 *dst = inw(port);
71 dst += inc;
c7de829c
WD
72 }
73 return (dst-base);
74}
75
76int
77port_rep_inl(CARD16 port, CARD32 *base, int d_f, CARD32 count)
78{
79 register int inc = d_f ? -1 : 1;
80 CARD32 *dst = base;
8bde7f77 81
c7de829c 82 p_printf(" rep_insl(%#x) %d bytes at %p %s",
8bde7f77 83 port, count, base, d_f?"up":"down");
c7de829c 84 if (Config.PrintIp)
8bde7f77 85 p_printf(" %x\n",getIP());
c7de829c
WD
86 else p_printf("\n");
87
88 r_inl++;
89 while (count--) {
8bde7f77
WD
90 *dst = inl(port);
91 dst += inc;
c7de829c
WD
92 }
93 return (dst-base);
94}
95
96int
97port_rep_outb(CARD16 port, CARD8 *base, int d_f, CARD32 count)
98{
99 register int inc = d_f ? -1 : 1;
100 CARD8 *dst = base;
8bde7f77 101
c7de829c 102 p_printf(" rep_outb(%#x) %d bytes at %p %s",
8bde7f77 103 port, count, base, d_f?"up":"down");
c7de829c 104 if (Config.PrintIp)
8bde7f77 105 p_printf(" %x\n",getIP());
c7de829c
WD
106 else p_printf("\n");
107
108 r_outb++;
109 while (count--) {
8bde7f77
WD
110 outb(port,*dst);
111 dst += inc;
c7de829c
WD
112 }
113 return (dst-base);
114}
115
116int
117port_rep_outw(CARD16 port, CARD16 *base, int d_f, CARD32 count)
118{
119 register int inc = d_f ? -1 : 1;
120 CARD16 *dst = base;
8bde7f77 121
c7de829c 122 p_printf(" rep_outw(%#x) %d bytes at %p %s",
8bde7f77 123 port, count, base, d_f?"up":"down");
c7de829c 124 if (Config.PrintIp)
8bde7f77 125 p_printf(" %x\n",getIP());
c7de829c
WD
126 else p_printf("\n");
127
128 r_outw++;
129 while (count--) {
8bde7f77
WD
130 outw(port,*dst);
131 dst += inc;
c7de829c
WD
132 }
133 return (dst-base);
134}
135
136int
137port_rep_outl(CARD16 port, CARD32 *base, int d_f, CARD32 count)
138{
139 register int inc = d_f ? -1 : 1;
140 CARD32 *dst = base;
8bde7f77 141
c7de829c 142 p_printf(" rep_outl(%#x) %d bytes at %p %s",
8bde7f77 143 port, count, base, d_f?"up":"down");
c7de829c 144 if (Config.PrintIp)
8bde7f77 145 p_printf(" %x\n",getIP());
c7de829c
WD
146 else p_printf("\n");
147
148 r_outl++;
149 while (count--) {
8bde7f77
WD
150 outl(port,*dst);
151 dst += inc;
c7de829c
WD
152 }
153 return (dst-base);
154}
155
156CARD8
157p_inb(CARD16 port)
158{
159 CARD8 val = 0;
160 in_b++;
161 val = inb(port);
162 p_printf(" inb(%#x) = %2.2x",port,val);
163 if (Config.PrintIp)
8bde7f77 164 p_printf(" %x\n",getIP());
c7de829c
WD
165 else p_printf("\n");
166
167 return val;
168}
169
170CARD16
171p_inw(CARD16 port)
172{
173 CARD16 val = 0;
174 in_w++;
175 val = inw(port);
176 p_printf(" inw(%#x) = %4.4x",port,val);
177 if (Config.PrintIp)
8bde7f77 178 p_printf(" %x\n",getIP());
c7de829c
WD
179 else p_printf("\n");
180
181 return val;
182}
183
184CARD32
185p_inl(CARD16 port)
186{
187 CARD32 val = 0;
188 in_l++;
189#ifdef NEED_PCI_IO
190 if (cfg1in(port,&val))
8bde7f77 191 return val;
c7de829c
WD
192 else
193#endif
194 val = inl(port);
195 p_printf(" inl(%#x) = %8.8x",port,val);
196 if (Config.PrintIp)
8bde7f77 197 p_printf(" %x\n",getIP());
c7de829c
WD
198 else p_printf("\n");
199
200 return val;
201}
202
203void
204p_outb(CARD16 port, CARD8 val)
205{
206 out_b++;
207 p_printf(" outb(%#x, %2.2x)",port,val);
208 if (Config.PrintIp)
8bde7f77 209 p_printf(" %x\n",getIP());
c7de829c
WD
210 else p_printf("\n");
211
212 outb(port,val);
213}
214
215void
216p_outw(CARD16 port, CARD16 val)
217{
218 out_w++;
219 p_printf(" outw(%#x, %4.4x)",port,val);
220 if (Config.PrintIp)
8bde7f77 221 p_printf(" %x\n",getIP());
c7de829c
WD
222 else p_printf("\n");
223
224 outw(port,val);
225}
226
227void
228p_outl(CARD16 port, CARD32 val)
229{
230 out_l++;
231 p_printf(" outl(%#x, %8.8x)",port,val);
232 if (Config.PrintIp)
8bde7f77 233 p_printf(" %x\n",getIP());
c7de829c
WD
234 else p_printf("\n");
235
236#ifdef NEED_PCI_IO
237 if (cfg1out(port,val))
8bde7f77 238 return;
c7de829c
WD
239#endif
240 outl(port,val);
241}
242
243void
244io_statistics(void)
245{
246 p_printf("rep: inb: %i, inw: %i, inl: %i, outb: %i, outw: %i, outl: %i\n",
8bde7f77 247 r_inb,r_inw,r_inl,r_outb,r_outw,r_outl);
c7de829c 248 p_printf("inb: %i, inw: %i, inl: %i, outb: %i, outw: %i, outl: %i\n",
8bde7f77 249 in_b,in_w,in_l,out_b,out_w,out_l);
c7de829c
WD
250}
251
252void
253clear_stat(void)
254{
255 r_inb = r_inw = r_inl = r_outb = r_outw = r_outl = 0;
256 in_b = in_w = in_l = out_b = out_w = out_l = 0;
257}