libhd 5.0
|
00001 /* $XConsortium: AsmMacros.h /main/13 1996/10/25 11:33:12 kaleb $ */ 00002 /* 00003 * (c) Copyright 1993,1994 by David Wexelblat <dwex@xfree86.org> 00004 * 00005 * Permission is hereby granted, free of charge, to any person obtaining a 00006 * copy of this software and associated documentation files (the "Software"), 00007 * to deal in the Software without restriction, including without limitation 00008 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00009 * and/or sell copies of the Software, and to permit persons to whom the 00010 * Software is furnished to do so, subject to the following conditions: 00011 * 00012 * The above copyright notice and this permission notice shall be included in 00013 * all copies or substantial portions of the Software. 00014 * 00015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00016 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00017 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00018 * DAVID WEXELBLAT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 00019 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 00020 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00021 * SOFTWARE. 00022 * 00023 * Except as contained in this notice, the name of David Wexelblat shall not be 00024 * used in advertising or otherwise to promote the sale, use or other dealings 00025 * in this Software without prior written authorization from David Wexelblat. 00026 * 00027 */ 00028 /* 00029 * Copyright 1997 00030 * Digital Equipment Corporation. All rights reserved. 00031 * This software is furnished under license and may be used and copied only in 00032 * accordance with the following terms and conditions. Subject to these 00033 * conditions, you may download, copy, install, use, modify and distribute 00034 * this software in source and/or binary form. No title or ownership is 00035 * transferred hereby. 00036 * 00037 * 1) Any source code used, modified or distributed must reproduce and retain 00038 * this copyright notice and list of conditions as they appear in the source 00039 * file. 00040 * 00041 * 2) No right is granted to use any trade name, trademark, or logo of Digital 00042 * Equipment Corporation. Neither the "Digital Equipment Corporation" name 00043 * nor any trademark or logo of Digital Equipment Corporation may be used 00044 * to endorse or promote products derived from this software without the 00045 * prior written permission of Digital Equipment Corporation. 00046 * 00047 * 3) This software is provided "AS-IS" and any express or implied warranties, 00048 * including but not limited to, any implied warranties of merchantability, 00049 * fitness for a particular purpose, or non-infringement are disclaimed. In 00050 * no event shall DIGITAL be liable for any damages whatsoever, and in 00051 * particular, DIGITAL shall not be liable for special, indirect, 00052 * consequential, or incidental damages or damages for 00053 * lost profits, loss of revenue or loss of use, whether such damages arise 00054 * in contract, 00055 * negligence, tort, under statute, in equity, at law or otherwise, even if 00056 * advised of the possibility of such damage. 00057 * 00058 */ 00059 00060 /* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/AsmMacros.h,v 3.14 1999/09/25 14:36:58 dawes Exp $ */ 00061 00062 00063 #if defined(__GNUC__) 00064 00065 #if defined(linux) && (defined(__alpha__) || defined(__ia64__)) 00066 00067 #include <sys/io.h> 00068 00069 #undef inb 00070 #undef inw 00071 #undef inl 00072 #undef outb 00073 #undef outw 00074 #undef outl 00075 00076 static __inline__ unsigned int inb(unsigned long int p) { return _inb(p); }; 00077 static __inline__ unsigned int inw(unsigned long int p) { return _inw(p); }; 00078 static __inline__ unsigned int inl(unsigned long int p) { return _inl(p); }; 00079 static __inline__ void outb(unsigned long int p, unsigned char v) { _outb(v,p); }; 00080 static __inline__ void outw(unsigned long int p, unsigned short v) { _outw(v,p); }; 00081 static __inline__ void outl(unsigned long int p, unsigned int v) { _outl(v,p); }; 00082 00083 #else 00084 00085 #if defined(__sparc__) 00086 #ifndef ASI_PL 00087 #define ASI_PL 0x88 00088 #endif 00089 00090 static __inline__ void 00091 outb(port, val) 00092 unsigned long port; 00093 char val; 00094 { 00095 __asm__ __volatile__("stba %0, [%1] %2" : : "r" (val), "r" (port), "i" (ASI_PL)); 00096 } 00097 00098 static __inline__ void 00099 outw(port, val) 00100 unsigned long port; 00101 char val; 00102 { 00103 __asm__ __volatile__("stha %0, [%1] %2" : : "r" (val), "r" (port), "i" (ASI_PL)); 00104 } 00105 00106 static __inline__ void 00107 outl(port, val) 00108 unsigned long port; 00109 char val; 00110 { 00111 __asm__ __volatile__("sta %0, [%1] %2" : : "r" (val), "r" (port), "i" (ASI_PL)); 00112 } 00113 00114 static __inline__ unsigned int 00115 inb(port) 00116 unsigned long port; 00117 { 00118 unsigned char ret; 00119 __asm__ __volatile__("lduba [%1] %2, %0" : "=r" (ret) : "r" (port), "i" (ASI_PL)); 00120 return ret; 00121 } 00122 00123 static __inline__ unsigned int 00124 inw(port) 00125 unsigned long port; 00126 { 00127 unsigned char ret; 00128 __asm__ __volatile__("lduha [%1] %2, %0" : "=r" (ret) : "r" (port), "i" (ASI_PL)); 00129 return ret; 00130 } 00131 00132 static __inline__ unsigned int 00133 inl(port) 00134 unsigned long port; 00135 { 00136 unsigned char ret; 00137 __asm__ __volatile__("lda [%1] %2, %0" : "=r" (ret) : "r" (port), "i" (ASI_PL)); 00138 return ret; 00139 } 00140 #else 00141 #ifdef __arm32__ 00142 unsigned int IOPortBase; /* Memory mapped I/O port area */ 00143 00144 static __inline__ void 00145 outb(port, val) 00146 short port; 00147 char val; 00148 { 00149 if ((unsigned short)port >= 0x400) return; 00150 00151 *(volatile unsigned char*)(((unsigned short)(port))+IOPortBase) = val; 00152 } 00153 00154 static __inline__ void 00155 outw(port, val) 00156 short port; 00157 short val; 00158 { 00159 if ((unsigned short)port >= 0x400) return; 00160 00161 *(volatile unsigned short*)(((unsigned short)(port))+IOPortBase) = val; 00162 } 00163 00164 static __inline__ void 00165 outl(port, val) 00166 short port; 00167 int val; 00168 { 00169 if ((unsigned short)port >= 0x400) return; 00170 00171 *(volatile unsigned long*)(((unsigned short)(port))+IOPortBase) = val; 00172 } 00173 00174 static __inline__ unsigned int 00175 inb(port) 00176 short port; 00177 { 00178 if ((unsigned short)port >= 0x400) return((unsigned int)-1); 00179 00180 return(*(volatile unsigned char*)(((unsigned short)(port))+IOPortBase)); 00181 } 00182 00183 static __inline__ unsigned int 00184 inw(port) 00185 short port; 00186 { 00187 if ((unsigned short)port >= 0x400) return((unsigned int)-1); 00188 00189 return(*(volatile unsigned short*)(((unsigned short)(port))+IOPortBase)); 00190 } 00191 00192 static __inline__ unsigned int 00193 inl(port) 00194 short port; 00195 { 00196 if ((unsigned short)port >= 0x400) return((unsigned int)-1); 00197 00198 return(*(volatile unsigned long*)(((unsigned short)(port))+IOPortBase)); 00199 } 00200 #else /* __arm32__ */ 00201 #if defined(Lynx) && defined(__powerpc__) 00202 extern unsigned char *ioBase; 00203 00204 static volatile void 00205 eieio() 00206 { 00207 __asm__ __volatile__ ("eieio"); 00208 } 00209 00210 static void 00211 outb(port, value) 00212 short port; 00213 unsigned char value; 00214 { 00215 *(uchar *)(ioBase + port) = value; eieio(); 00216 } 00217 00218 static void 00219 outw(port, value) 00220 short port; 00221 unsigned short value; 00222 { 00223 *(unsigned short *)(ioBase + port) = value; eieio(); 00224 } 00225 00226 static void 00227 outl(port, value) 00228 short port; 00229 unsigned long value; 00230 { 00231 *(unsigned long *)(ioBase + port) = value; eieio(); 00232 } 00233 00234 static unsigned char 00235 inb(port) 00236 short port; 00237 { 00238 unsigned char val; 00239 00240 val = *((unsigned char *)(ioBase + port)); eieio(); 00241 return(val); 00242 } 00243 00244 static unsigned short 00245 inw(port) 00246 short port; 00247 { 00248 unsigned short val; 00249 00250 val = *((unsigned short *)(ioBase + port)); eieio(); 00251 return(val); 00252 } 00253 00254 static unsigned long 00255 inl(port) 00256 short port; 00257 { 00258 unsigned long val; 00259 00260 val = *((unsigned long *)(ioBase + port)); eieio(); 00261 return(val); 00262 } 00263 00264 #else 00265 #if defined(__FreeBSD__) && defined(__alpha__) 00266 00267 #include <sys/types.h> 00268 00269 extern void outb(u_int32_t port, u_int8_t val); 00270 extern void outw(u_int32_t port, u_int16_t val); 00271 extern void outl(u_int32_t port, u_int32_t val); 00272 extern u_int8_t inb(u_int32_t port); 00273 extern u_int16_t inw(u_int32_t port); 00274 extern u_int32_t inl(u_int32_t port); 00275 00276 #else 00277 #ifdef GCCUSESGAS 00278 static __inline__ void 00279 outb(port, val) 00280 short port; 00281 char val; 00282 { 00283 __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port)); 00284 } 00285 00286 static __inline__ void 00287 outw(port, val) 00288 short port; 00289 short val; 00290 { 00291 __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port)); 00292 } 00293 00294 static __inline__ void 00295 outl(port, val) 00296 short port; 00297 unsigned int val; 00298 { 00299 __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port)); 00300 } 00301 00302 static __inline__ unsigned int 00303 inb(port) 00304 short port; 00305 { 00306 unsigned char ret; 00307 __asm__ __volatile__("inb %1,%0" : 00308 "=a" (ret) : 00309 "d" (port)); 00310 return ret; 00311 } 00312 00313 static __inline__ unsigned int 00314 inw(port) 00315 short port; 00316 { 00317 unsigned short ret; 00318 __asm__ __volatile__("inw %1,%0" : 00319 "=a" (ret) : 00320 "d" (port)); 00321 return ret; 00322 } 00323 00324 static __inline__ unsigned int 00325 inl(port) 00326 short port; 00327 { 00328 unsigned int ret; 00329 __asm__ __volatile__("inl %1,%0" : 00330 "=a" (ret) : 00331 "d" (port)); 00332 return ret; 00333 } 00334 00335 #else /* GCCUSESGAS */ 00336 00337 static __inline__ void 00338 outb(port, val) 00339 short port; 00340 char val; 00341 { 00342 __asm__ __volatile__("out%B0 (%1)" : :"a" (val), "d" (port)); 00343 } 00344 00345 static __inline__ void 00346 outw(port, val) 00347 short port; 00348 short val; 00349 { 00350 __asm__ __volatile__("out%W0 (%1)" : :"a" (val), "d" (port)); 00351 } 00352 00353 static __inline__ void 00354 outl(port, val) 00355 short port; 00356 unsigned int val; 00357 { 00358 __asm__ __volatile__("out%L0 (%1)" : :"a" (val), "d" (port)); 00359 } 00360 00361 static __inline__ unsigned int 00362 inb(port) 00363 short port; 00364 { 00365 unsigned int ret; 00366 __asm__ __volatile__("in%B0 (%1)" : 00367 "=a" (ret) : 00368 "d" (port)); 00369 return ret; 00370 } 00371 00372 static __inline__ unsigned int 00373 inw(port) 00374 short port; 00375 { 00376 unsigned int ret; 00377 __asm__ __volatile__("in%W0 (%1)" : 00378 "=a" (ret) : 00379 "d" (port)); 00380 return ret; 00381 } 00382 00383 static __inline__ unsigned int 00384 inl(port) 00385 short port; 00386 { 00387 unsigned int ret; 00388 __asm__ __volatile__("in%L0 (%1)" : 00389 "=a" (ret) : 00390 "d" (port)); 00391 return ret; 00392 } 00393 00394 #endif /* GCCUSESGAS */ 00395 #endif /* Lynx && __powerpc__ */ 00396 #endif /* arm32 */ 00397 #endif /* linux && __sparc__ */ 00398 #endif /* linux && __alpha__ */ 00399 #endif /* __FreeBSD__ && __alpha__ */ 00400 00401 #if defined(linux) || defined(__arm32__) || (defined(Lynx) && defined(__powerpc__)) 00402 00403 #define intr_disable() 00404 #define intr_enable() 00405 00406 #else 00407 00408 static __inline__ void 00409 intr_disable() 00410 { 00411 __asm__ __volatile__("cli"); 00412 } 00413 00414 static __inline__ void 00415 intr_enable() 00416 { 00417 __asm__ __volatile__("sti"); 00418 } 00419 00420 #endif /* else !linux && !__arm32__ */ 00421 00422 #else /* __GNUC__ */ 00423 00424 #if defined(_MINIX) && defined(_ACK) 00425 00426 /* inb, outb, inw and outw are defined in the library */ 00427 /* ... but I've no idea if the same is true for inl & outl */ 00428 00429 u8_t inb(U16_t); 00430 void outb(U16_t, U8_t); 00431 u16_t inw(U16_t); 00432 void outw(U16_t, U16_t); 00433 u32_t inl(U16_t); 00434 void outl(U16_t, U32_t); 00435 00436 #else /* not _MINIX and _ACK */ 00437 00438 # if defined(__STDC__) && (__STDC__ == 1) 00439 # ifndef NCR 00440 # define asm __asm 00441 # endif 00442 # endif 00443 # ifdef SVR4 00444 # include <sys/types.h> 00445 # ifndef __USLC__ 00446 # define __USLC__ 00447 # endif 00448 # endif 00449 #ifndef SCO325 00450 # include <sys/inline.h> 00451 #else 00452 # include "../common/scoasm.h" 00453 #endif 00454 #define intr_disable() asm("cli") 00455 #define intr_enable() asm("sti") 00456 00457 #endif /* _MINIX and _ACK */ 00458 #endif /* __GNUC__ */