PageRenderTime 60ms CodeModel.GetById 32ms RepoModel.GetById 0ms app.codeStats 0ms

/board/MAI/bios_emulator/scitech/src/v86bios/AsmMacros.h

https://github.com/xoox/u-boot-1.2.0
C Header | 450 lines | 329 code | 60 blank | 61 comment | 17 complexity | 44edad34e99a6365615fa5a43fdf7e02 MD5 | raw file
  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. /* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/AsmMacros.h,v 3.14 1999/09/25 14:36:58 dawes Exp $ */
  60. #if defined(__GNUC__)
  61. #if defined(linux) && (defined(__alpha__) || defined(__ia64__))
  62. #undef inb
  63. #define inb _inb
  64. #undef inw
  65. #define inw _inw
  66. #undef inl
  67. #define inl _inl
  68. #undef outb
  69. #define outb(p,v) _outb((v),(p))
  70. #undef outw
  71. #define outw(p,v) _outw((v),(p))
  72. #undef outl
  73. #define outl(p,v) _outl((v),(p))
  74. #else
  75. #if defined(__sparc__)
  76. #ifndef ASI_PL
  77. #define ASI_PL 0x88
  78. #endif
  79. static __inline__ void
  80. outb(port, val)
  81. unsigned long port;
  82. char val;
  83. {
  84. __asm__ __volatile__("stba %0, [%1] %2" : : "r" (val), "r" (port), "i" (ASI_PL));
  85. }
  86. static __inline__ void
  87. outw(port, val)
  88. unsigned long port;
  89. char val;
  90. {
  91. __asm__ __volatile__("stha %0, [%1] %2" : : "r" (val), "r" (port), "i" (ASI_PL));
  92. }
  93. static __inline__ void
  94. outl(port, val)
  95. unsigned long port;
  96. char val;
  97. {
  98. __asm__ __volatile__("sta %0, [%1] %2" : : "r" (val), "r" (port), "i" (ASI_PL));
  99. }
  100. static __inline__ unsigned int
  101. inb(port)
  102. unsigned long port;
  103. {
  104. unsigned char ret;
  105. __asm__ __volatile__("lduba [%1] %2, %0" : "=r" (ret) : "r" (port), "i" (ASI_PL));
  106. return ret;
  107. }
  108. static __inline__ unsigned int
  109. inw(port)
  110. unsigned long port;
  111. {
  112. unsigned char ret;
  113. __asm__ __volatile__("lduha [%1] %2, %0" : "=r" (ret) : "r" (port), "i" (ASI_PL));
  114. return ret;
  115. }
  116. static __inline__ unsigned int
  117. inl(port)
  118. unsigned long port;
  119. {
  120. unsigned char ret;
  121. __asm__ __volatile__("lda [%1] %2, %0" : "=r" (ret) : "r" (port), "i" (ASI_PL));
  122. return ret;
  123. }
  124. #else
  125. #ifdef __arm32__
  126. unsigned int IOPortBase; /* Memory mapped I/O port area */
  127. static __inline__ void
  128. outb(port, val)
  129. short port;
  130. char val;
  131. {
  132. if ((unsigned short)port >= 0x400) return;
  133. *(volatile unsigned char*)(((unsigned short)(port))+IOPortBase) = val;
  134. }
  135. static __inline__ void
  136. outw(port, val)
  137. short port;
  138. short val;
  139. {
  140. if ((unsigned short)port >= 0x400) return;
  141. *(volatile unsigned short*)(((unsigned short)(port))+IOPortBase) = val;
  142. }
  143. static __inline__ void
  144. outl(port, val)
  145. short port;
  146. int val;
  147. {
  148. if ((unsigned short)port >= 0x400) return;
  149. *(volatile unsigned long*)(((unsigned short)(port))+IOPortBase) = val;
  150. }
  151. static __inline__ unsigned int
  152. inb(port)
  153. short port;
  154. {
  155. if ((unsigned short)port >= 0x400) return((unsigned int)-1);
  156. return(*(volatile unsigned char*)(((unsigned short)(port))+IOPortBase));
  157. }
  158. static __inline__ unsigned int
  159. inw(port)
  160. short port;
  161. {
  162. if ((unsigned short)port >= 0x400) return((unsigned int)-1);
  163. return(*(volatile unsigned short*)(((unsigned short)(port))+IOPortBase));
  164. }
  165. static __inline__ unsigned int
  166. inl(port)
  167. short port;
  168. {
  169. if ((unsigned short)port >= 0x400) return((unsigned int)-1);
  170. return(*(volatile unsigned long*)(((unsigned short)(port))+IOPortBase));
  171. }
  172. #else /* __arm32__ */
  173. #if defined(Lynx) && defined(__powerpc__)
  174. extern unsigned char *ioBase;
  175. static volatile void
  176. eieio()
  177. {
  178. __asm__ __volatile__ ("eieio");
  179. }
  180. static void
  181. outb(port, value)
  182. short port;
  183. unsigned char value;
  184. {
  185. *(uchar *)(ioBase + port) = value; eieio();
  186. }
  187. static void
  188. outw(port, value)
  189. short port;
  190. unsigned short value;
  191. {
  192. *(unsigned short *)(ioBase + port) = value; eieio();
  193. }
  194. static void
  195. outl(port, value)
  196. short port;
  197. unsigned long value;
  198. {
  199. *(unsigned long *)(ioBase + port) = value; eieio();
  200. }
  201. static unsigned char
  202. inb(port)
  203. short port;
  204. {
  205. unsigned char val;
  206. val = *((unsigned char *)(ioBase + port)); eieio();
  207. return(val);
  208. }
  209. static unsigned short
  210. inw(port)
  211. short port;
  212. {
  213. unsigned short val;
  214. val = *((unsigned short *)(ioBase + port)); eieio();
  215. return(val);
  216. }
  217. static unsigned long
  218. inl(port)
  219. short port;
  220. {
  221. unsigned long val;
  222. val = *((unsigned long *)(ioBase + port)); eieio();
  223. return(val);
  224. }
  225. #else
  226. #if defined(__FreeBSD__) && defined(__alpha__)
  227. #include <sys/types.h>
  228. extern void outb(u_int32_t port, u_int8_t val);
  229. extern void outw(u_int32_t port, u_int16_t val);
  230. extern void outl(u_int32_t port, u_int32_t val);
  231. extern u_int8_t inb(u_int32_t port);
  232. extern u_int16_t inw(u_int32_t port);
  233. extern u_int32_t inl(u_int32_t port);
  234. #else
  235. #ifdef GCCUSESGAS
  236. static __inline__ void
  237. outb(port, val)
  238. short port;
  239. char val;
  240. {
  241. __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
  242. }
  243. static __inline__ void
  244. outw(port, val)
  245. short port;
  246. short val;
  247. {
  248. __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
  249. }
  250. static __inline__ void
  251. outl(port, val)
  252. short port;
  253. unsigned int val;
  254. {
  255. __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
  256. }
  257. static __inline__ unsigned int
  258. inb(port)
  259. short port;
  260. {
  261. unsigned char ret;
  262. __asm__ __volatile__("inb %1,%0" :
  263. "=a" (ret) :
  264. "d" (port));
  265. return ret;
  266. }
  267. static __inline__ unsigned int
  268. inw(port)
  269. short port;
  270. {
  271. unsigned short ret;
  272. __asm__ __volatile__("inw %1,%0" :
  273. "=a" (ret) :
  274. "d" (port));
  275. return ret;
  276. }
  277. static __inline__ unsigned int
  278. inl(port)
  279. short port;
  280. {
  281. unsigned int ret;
  282. __asm__ __volatile__("inl %1,%0" :
  283. "=a" (ret) :
  284. "d" (port));
  285. return ret;
  286. }
  287. #else /* GCCUSESGAS */
  288. static __inline__ void
  289. outb(port, val)
  290. short port;
  291. char val;
  292. {
  293. __asm__ __volatile__("out%B0 (%1)" : :"a" (val), "d" (port));
  294. }
  295. static __inline__ void
  296. outw(port, val)
  297. short port;
  298. short val;
  299. {
  300. __asm__ __volatile__("out%W0 (%1)" : :"a" (val), "d" (port));
  301. }
  302. static __inline__ void
  303. outl(port, val)
  304. short port;
  305. unsigned int val;
  306. {
  307. __asm__ __volatile__("out%L0 (%1)" : :"a" (val), "d" (port));
  308. }
  309. static __inline__ unsigned int
  310. inb(port)
  311. short port;
  312. {
  313. unsigned int ret;
  314. __asm__ __volatile__("in%B0 (%1)" :
  315. "=a" (ret) :
  316. "d" (port));
  317. return ret;
  318. }
  319. static __inline__ unsigned int
  320. inw(port)
  321. short port;
  322. {
  323. unsigned int ret;
  324. __asm__ __volatile__("in%W0 (%1)" :
  325. "=a" (ret) :
  326. "d" (port));
  327. return ret;
  328. }
  329. static __inline__ unsigned int
  330. inl(port)
  331. short port;
  332. {
  333. unsigned int ret;
  334. __asm__ __volatile__("in%L0 (%1)" :
  335. "=a" (ret) :
  336. "d" (port));
  337. return ret;
  338. }
  339. #endif /* GCCUSESGAS */
  340. #endif /* Lynx && __powerpc__ */
  341. #endif /* arm32 */
  342. #endif /* linux && __sparc__ */
  343. #endif /* linux && __alpha__ */
  344. #endif /* __FreeBSD__ && __alpha__ */
  345. #if defined(linux) || defined(__arm32__) || (defined(Lynx) && defined(__powerpc__))
  346. #define intr_disable()
  347. #define intr_enable()
  348. #else
  349. static __inline__ void
  350. intr_disable()
  351. {
  352. __asm__ __volatile__("cli");
  353. }
  354. static __inline__ void
  355. intr_enable()
  356. {
  357. __asm__ __volatile__("sti");
  358. }
  359. #endif /* else !linux && !__arm32__ */
  360. #else /* __GNUC__ */
  361. #if defined(_MINIX) && defined(_ACK)
  362. /* inb, outb, inw and outw are defined in the library */
  363. /* ... but I've no idea if the same is true for inl & outl */
  364. u8_t inb(U16_t);
  365. void outb(U16_t, U8_t);
  366. u16_t inw(U16_t);
  367. void outw(U16_t, U16_t);
  368. u32_t inl(U16_t);
  369. void outl(U16_t, U32_t);
  370. #else /* not _MINIX and _ACK */
  371. # if defined(__STDC__) && (__STDC__ == 1)
  372. # ifndef NCR
  373. # define asm __asm
  374. # endif
  375. # endif
  376. # ifdef SVR4
  377. # include <sys/types.h>
  378. # ifndef __USLC__
  379. # define __USLC__
  380. # endif
  381. # endif
  382. #ifndef SCO325
  383. # include <sys/inline.h>
  384. #else
  385. # include "../common/scoasm.h"
  386. #endif
  387. #define intr_disable() asm("cli")
  388. #define intr_enable() asm("sti")
  389. #endif /* _MINIX and _ACK */
  390. #endif /* __GNUC__ */