]> git.saurik.com Git - apple/boot.git/blob - gen/libsa/io_inline.h
boot-111.tar.gz
[apple/boot.git] / gen / libsa / io_inline.h
1 /*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /*
26 * Copyright (c) 1992 NeXT Computer, Inc.
27 *
28 * Inlines for io space access.
29 *
30 * HISTORY
31 *
32 * 20 May 1992 ? at NeXT
33 * Created.
34 */
35
36 #import <architecture/i386/io.h>
37
38 #if !defined(DEFINE_INLINE_FUNCTIONS)
39 static
40 #endif
41 inline
42 unsigned char
43 inb(
44 io_addr_t port
45 )
46 {
47 unsigned char data;
48
49 asm volatile(
50 "inb %1,%0"
51
52 : "=a" (data)
53 : "d" (port));
54
55 return (data);
56 }
57
58 #if !defined(DEFINE_INLINE_FUNCTIONS)
59 static
60 #endif
61 inline
62 unsigned short
63 inw(
64 io_addr_t port
65 )
66 {
67 unsigned short data;
68
69 asm volatile(
70 "inw %1,%0"
71
72 : "=a" (data)
73 : "d" (port));
74
75 return (data);
76 }
77
78 #if !defined(DEFINE_INLINE_FUNCTIONS)
79 static
80 #endif
81 inline
82 void
83 outb(
84 io_addr_t port,
85 unsigned char data
86 )
87 {
88 static int xxx;
89
90 asm volatile(
91 "outb %2,%1; lock; incl %0"
92
93 : "=m" (xxx)
94 : "d" (port), "a" (data), "0" (xxx)
95 : "cc");
96 }
97
98 #if !defined(DEFINE_INLINE_FUNCTIONS)
99 static
100 #endif
101 inline
102 void
103 outw(
104 io_addr_t port,
105 unsigned short data
106 )
107 {
108 static int xxx;
109
110 asm volatile(
111 "outw %2,%1; lock; incl %0"
112
113 : "=m" (xxx)
114 : "d" (port), "a" (data), "0" (xxx)
115 : "cc");
116 }
117