Mercurial > mplayer.hg
annotate libdha/AsmMacros.h @ 4148:3b29772a4fb2
S->C
author | nick |
---|---|
date | Mon, 14 Jan 2002 10:34:38 +0000 |
parents | 3822582553d6 |
children | 2e3262002acb |
rev | line source |
---|---|
3973 | 1 /* $XConsortium: AsmMacros.h /main/13 1996/10/25 11:33:12 kaleb $ */ |
2 /* | |
3 * (c) Copyright 1993,1994 by David Wexelblat <dwex@xfree86.org> | |
4 * | |
5 * Permission is hereby granted, free of charge, to any person obtaining a | |
6 * copy of this software and associated documentation files (the "Software"), | |
7 * to deal in the Software without restriction, including without limitation | |
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
9 * and/or sell copies of the Software, and to permit persons to whom the | |
10 * Software is furnished to do so, subject to the following conditions: | |
11 * | |
12 * The above copyright notice and this permission notice shall be included in | |
13 * all copies or substantial portions of the Software. | |
14 * | |
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
18 * DAVID WEXELBLAT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |
19 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF | |
20 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
21 * SOFTWARE. | |
22 * | |
23 * Except as contained in this notice, the name of David Wexelblat shall not be | |
24 * used in advertising or otherwise to promote the sale, use or other dealings | |
25 * in this Software without prior written authorization from David Wexelblat. | |
26 * | |
27 */ | |
28 /* | |
29 * Copyright 1997 | |
30 * Digital Equipment Corporation. All rights reserved. | |
31 * This software is furnished under license and may be used and copied only in | |
32 * accordance with the following terms and conditions. Subject to these | |
33 * conditions, you may download, copy, install, use, modify and distribute | |
34 * this software in source and/or binary form. No title or ownership is | |
35 * transferred hereby. | |
36 * | |
37 * 1) Any source code used, modified or distributed must reproduce and retain | |
38 * this copyright notice and list of conditions as they appear in the source | |
39 * file. | |
40 * | |
41 * 2) No right is granted to use any trade name, trademark, or logo of Digital | |
42 * Equipment Corporation. Neither the "Digital Equipment Corporation" name | |
43 * nor any trademark or logo of Digital Equipment Corporation may be used | |
44 * to endorse or promote products derived from this software without the | |
45 * prior written permission of Digital Equipment Corporation. | |
46 * | |
47 * 3) This software is provided "AS-IS" and any express or implied warranties, | |
48 * including but not limited to, any implied warranties of merchantability, | |
49 * fitness for a particular purpose, or non-infringement are disclaimed. In | |
50 * no event shall DIGITAL be liable for any damages whatsoever, and in | |
51 * particular, DIGITAL shall not be liable for special, indirect, | |
52 * consequential, or incidental damages or damages for | |
53 * lost profits, loss of revenue or loss of use, whether such damages arise | |
54 * in contract, | |
55 * negligence, tort, under statute, in equity, at law or otherwise, even if | |
56 * advised of the possibility of such damage. | |
57 * | |
58 */ | |
59 | |
4102 | 60 /* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/util/AsmMacros.h,v 1.1 2001/11/16 21:13:34 tsi Exp $ */ |
3973 | 61 |
62 #if defined(__GNUC__) | |
4102 | 63 #if defined(linux) && (defined(__alpha__) || defined(__ia64__)) |
4112
3822582553d6
Alpha patch by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nick
parents:
4102
diff
changeset
|
64 #include <sys/io.h> |
3973 | 65 #else |
66 #if defined(__sparc__) | |
67 #ifndef ASI_PL | |
68 #define ASI_PL 0x88 | |
69 #endif | |
70 | |
71 static __inline__ void | |
72 outb(port, val) | |
73 unsigned long port; | |
74 char val; | |
75 { | |
76 __asm__ __volatile__("stba %0, [%1] %2" : : "r" (val), "r" (port), "i" (ASI_PL)); | |
77 } | |
78 | |
79 static __inline__ void | |
80 outw(port, val) | |
81 unsigned long port; | |
82 char val; | |
83 { | |
84 __asm__ __volatile__("stha %0, [%1] %2" : : "r" (val), "r" (port), "i" (ASI_PL)); | |
85 } | |
86 | |
87 static __inline__ void | |
88 outl(port, val) | |
89 unsigned long port; | |
90 char val; | |
91 { | |
92 __asm__ __volatile__("sta %0, [%1] %2" : : "r" (val), "r" (port), "i" (ASI_PL)); | |
93 } | |
94 | |
95 static __inline__ unsigned int | |
96 inb(port) | |
97 unsigned long port; | |
98 { | |
99 unsigned char ret; | |
100 __asm__ __volatile__("lduba [%1] %2, %0" : "=r" (ret) : "r" (port), "i" (ASI_PL)); | |
101 return ret; | |
102 } | |
103 | |
104 static __inline__ unsigned int | |
105 inw(port) | |
106 unsigned long port; | |
107 { | |
108 unsigned char ret; | |
109 __asm__ __volatile__("lduha [%1] %2, %0" : "=r" (ret) : "r" (port), "i" (ASI_PL)); | |
110 return ret; | |
111 } | |
112 | |
113 static __inline__ unsigned int | |
114 inl(port) | |
115 unsigned long port; | |
116 { | |
117 unsigned char ret; | |
118 __asm__ __volatile__("lda [%1] %2, %0" : "=r" (ret) : "r" (port), "i" (ASI_PL)); | |
119 return ret; | |
120 } | |
121 #else | |
122 #ifdef __arm32__ | |
123 unsigned int IOPortBase; /* Memory mapped I/O port area */ | |
124 | |
125 static __inline__ void | |
126 outb(port, val) | |
127 short port; | |
128 char val; | |
129 { | |
130 if ((unsigned short)port >= 0x400) return; | |
131 | |
132 *(volatile unsigned char*)(((unsigned short)(port))+IOPortBase) = val; | |
133 } | |
134 | |
135 static __inline__ void | |
136 outw(port, val) | |
137 short port; | |
138 short val; | |
139 { | |
140 if ((unsigned short)port >= 0x400) return; | |
141 | |
142 *(volatile unsigned short*)(((unsigned short)(port))+IOPortBase) = val; | |
143 } | |
144 | |
145 static __inline__ void | |
146 outl(port, val) | |
147 short port; | |
148 int val; | |
149 { | |
150 if ((unsigned short)port >= 0x400) return; | |
151 | |
152 *(volatile unsigned long*)(((unsigned short)(port))+IOPortBase) = val; | |
153 } | |
154 | |
155 static __inline__ unsigned int | |
156 inb(port) | |
157 short port; | |
158 { | |
159 if ((unsigned short)port >= 0x400) return((unsigned int)-1); | |
160 | |
161 return(*(volatile unsigned char*)(((unsigned short)(port))+IOPortBase)); | |
162 } | |
163 | |
164 static __inline__ unsigned int | |
165 inw(port) | |
166 short port; | |
167 { | |
168 if ((unsigned short)port >= 0x400) return((unsigned int)-1); | |
169 | |
170 return(*(volatile unsigned short*)(((unsigned short)(port))+IOPortBase)); | |
171 } | |
172 | |
173 static __inline__ unsigned int | |
174 inl(port) | |
175 short port; | |
176 { | |
177 if ((unsigned short)port >= 0x400) return((unsigned int)-1); | |
178 | |
179 return(*(volatile unsigned long*)(((unsigned short)(port))+IOPortBase)); | |
180 } | |
181 #else /* __arm32__ */ | |
182 #if defined(Lynx) && defined(__powerpc__) | |
183 extern unsigned char *ioBase; | |
184 | |
185 static volatile void | |
186 eieio() | |
187 { | |
188 __asm__ __volatile__ ("eieio"); | |
189 } | |
190 | |
191 static void | |
192 outb(port, value) | |
193 short port; | |
194 unsigned char value; | |
195 { | |
196 *(uchar *)(ioBase + port) = value; eieio(); | |
197 } | |
198 | |
199 static void | |
200 outw(port, value) | |
201 short port; | |
202 unsigned short value; | |
203 { | |
204 *(unsigned short *)(ioBase + port) = value; eieio(); | |
205 } | |
206 | |
207 static void | |
208 outl(port, value) | |
209 short port; | |
210 unsigned long value; | |
211 { | |
212 *(unsigned long *)(ioBase + port) = value; eieio(); | |
213 } | |
214 | |
215 static unsigned char | |
216 inb(port) | |
217 short port; | |
218 { | |
219 unsigned char val; | |
220 | |
221 val = *((unsigned char *)(ioBase + port)); eieio(); | |
222 return(val); | |
223 } | |
224 | |
225 static unsigned short | |
226 inw(port) | |
227 short port; | |
228 { | |
229 unsigned short val; | |
230 | |
231 val = *((unsigned short *)(ioBase + port)); eieio(); | |
232 return(val); | |
233 } | |
234 | |
235 static unsigned long | |
236 inl(port) | |
237 short port; | |
238 { | |
239 unsigned long val; | |
240 | |
241 val = *((unsigned long *)(ioBase + port)); eieio(); | |
242 return(val); | |
243 } | |
244 | |
245 #else | |
4102 | 246 #if defined(__FreeBSD__) && defined(__alpha__) |
247 | |
248 #include <sys/types.h> | |
249 | |
250 extern void outb(u_int32_t port, u_int8_t val); | |
251 extern void outw(u_int32_t port, u_int16_t val); | |
252 extern void outl(u_int32_t port, u_int32_t val); | |
253 extern u_int8_t inb(u_int32_t port); | |
254 extern u_int16_t inw(u_int32_t port); | |
255 extern u_int32_t inl(u_int32_t port); | |
256 | |
257 #else | |
3973 | 258 #ifdef GCCUSESGAS |
259 static __inline__ void | |
260 outb(port, val) | |
261 short port; | |
262 char val; | |
263 { | |
264 __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port)); | |
265 } | |
266 | |
267 static __inline__ void | |
268 outw(port, val) | |
269 short port; | |
270 short val; | |
271 { | |
272 __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port)); | |
273 } | |
274 | |
275 static __inline__ void | |
276 outl(port, val) | |
277 short port; | |
278 unsigned int val; | |
279 { | |
280 __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port)); | |
281 } | |
282 | |
283 static __inline__ unsigned int | |
284 inb(port) | |
285 short port; | |
286 { | |
287 unsigned char ret; | |
288 __asm__ __volatile__("inb %1,%0" : | |
289 "=a" (ret) : | |
290 "d" (port)); | |
291 return ret; | |
292 } | |
293 | |
294 static __inline__ unsigned int | |
295 inw(port) | |
296 short port; | |
297 { | |
298 unsigned short ret; | |
299 __asm__ __volatile__("inw %1,%0" : | |
300 "=a" (ret) : | |
301 "d" (port)); | |
302 return ret; | |
303 } | |
304 | |
305 static __inline__ unsigned int | |
306 inl(port) | |
307 short port; | |
308 { | |
309 unsigned int ret; | |
310 __asm__ __volatile__("inl %1,%0" : | |
311 "=a" (ret) : | |
312 "d" (port)); | |
313 return ret; | |
314 } | |
315 | |
316 #else /* GCCUSESGAS */ | |
317 | |
318 static __inline__ void | |
319 outb(port, val) | |
320 short port; | |
321 char val; | |
322 { | |
323 __asm__ __volatile__("out%B0 (%1)" : :"a" (val), "d" (port)); | |
324 } | |
325 | |
326 static __inline__ void | |
327 outw(port, val) | |
328 short port; | |
329 short val; | |
330 { | |
331 __asm__ __volatile__("out%W0 (%1)" : :"a" (val), "d" (port)); | |
332 } | |
333 | |
334 static __inline__ void | |
335 outl(port, val) | |
336 short port; | |
337 unsigned int val; | |
338 { | |
339 __asm__ __volatile__("out%L0 (%1)" : :"a" (val), "d" (port)); | |
340 } | |
341 | |
342 static __inline__ unsigned int | |
343 inb(port) | |
344 short port; | |
345 { | |
346 unsigned int ret; | |
347 __asm__ __volatile__("in%B0 (%1)" : | |
348 "=a" (ret) : | |
349 "d" (port)); | |
350 return ret; | |
351 } | |
352 | |
353 static __inline__ unsigned int | |
354 inw(port) | |
355 short port; | |
356 { | |
357 unsigned int ret; | |
358 __asm__ __volatile__("in%W0 (%1)" : | |
359 "=a" (ret) : | |
360 "d" (port)); | |
361 return ret; | |
362 } | |
363 | |
364 static __inline__ unsigned int | |
365 inl(port) | |
366 short port; | |
367 { | |
368 unsigned int ret; | |
369 __asm__ __volatile__("in%L0 (%1)" : | |
370 "=a" (ret) : | |
371 "d" (port)); | |
372 return ret; | |
373 } | |
374 | |
375 #endif /* GCCUSESGAS */ | |
376 #endif /* Lynx && __powerpc__ */ | |
377 #endif /* arm32 */ | |
378 #endif /* linux && __sparc__ */ | |
379 #endif /* linux && __alpha__ */ | |
4102 | 380 #endif /* __FreeBSD__ && __alpha__ */ |
3973 | 381 |
382 #if defined(linux) || defined(__arm32__) || (defined(Lynx) && defined(__powerpc__)) | |
383 | |
384 #define intr_disable() | |
385 #define intr_enable() | |
386 | |
387 #else | |
388 | |
389 static __inline__ void | |
390 intr_disable() | |
391 { | |
392 __asm__ __volatile__("cli"); | |
393 } | |
394 | |
395 static __inline__ void | |
396 intr_enable() | |
397 { | |
398 __asm__ __volatile__("sti"); | |
399 } | |
400 | |
401 #endif /* else !linux && !__arm32__ */ | |
402 | |
403 #else /* __GNUC__ */ | |
404 | |
405 #if defined(_MINIX) && defined(_ACK) | |
406 | |
407 /* inb, outb, inw and outw are defined in the library */ | |
408 /* ... but I've no idea if the same is true for inl & outl */ | |
409 | |
410 u8_t inb(U16_t); | |
411 void outb(U16_t, U8_t); | |
412 u16_t inw(U16_t); | |
413 void outw(U16_t, U16_t); | |
414 u32_t inl(U16_t); | |
415 void outl(U16_t, U32_t); | |
416 | |
417 #else /* not _MINIX and _ACK */ | |
418 | |
419 # if defined(__STDC__) && (__STDC__ == 1) | |
420 # ifndef NCR | |
421 # define asm __asm | |
422 # endif | |
423 # endif | |
424 # ifdef SVR4 | |
425 # include <sys/types.h> | |
426 # ifndef __USLC__ | |
427 # define __USLC__ | |
428 # endif | |
429 # endif | |
430 #ifndef SCO325 | |
431 # include <sys/inline.h> | |
432 #else | |
433 # include "../common/scoasm.h" | |
434 #endif | |
435 #define intr_disable() asm("cli") | |
436 #define intr_enable() asm("sti") | |
437 | |
438 #endif /* _MINIX and _ACK */ | |
439 #endif /* __GNUC__ */ |