]> git.saurik.com Git - apple/boot.git/blob - i386/libsaio/io_inline.h
boot-122.tar.gz
[apple/boot.git] / i386 / libsaio / io_inline.h
1 /*
2 * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 2.0 (the "License"). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
12 * this file.
13 *
14 * The Original Code and all software distributed under the License are
15 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
20 * under the License.
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 */
24 /*
25 * Copyright (c) 1992 NeXT Computer, Inc.
26 *
27 * Inlines for io space access.
28 *
29 * HISTORY
30 *
31 * 20 May 1992 ? at NeXT
32 * Created.
33 */
34
35 #ifndef __LIBSAIO_IO_INLINE_H
36 #define __LIBSAIO_IO_INLINE_H
37
38 /*
39 *############################################################################
40 *
41 * x86 IN/OUT I/O inline functions.
42 *
43 * IN : inb, inw, inl
44 * IN(port)
45 *
46 * OUT: outb, outw, outl
47 * OUT(port, data)
48 *
49 *############################################################################
50 */
51
52 #define __IN(s, u) \
53 static inline unsigned u \
54 in##s(unsigned short port) \
55 { \
56 unsigned u data; \
57 asm volatile ( \
58 "in" #s " %1,%0" \
59 : "=a" (data) \
60 : "d" (port)); \
61 return (data); \
62 }
63
64 #define __OUT(s, u) \
65 static inline void \
66 out##s(unsigned short port, unsigned u data) \
67 { \
68 asm volatile ( \
69 "out" #s " %1,%0" \
70 : \
71 : "d" (port), "a" (data)); \
72 }
73
74 __IN(b, char) /* inb() */
75 __IN(w, short) /* inw() */
76 __IN(l, long) /* inl() */
77
78 __OUT(b, char) /* outb() */
79 __OUT(w, short) /* outw() */
80 __OUT(l, long) /* outl() */
81
82 #endif /* !__LIBSAIO_IO_INLINE_H */