]> git.saurik.com Git - apple/boot.git/blob - gen/libsa/io_inline.h
boot-111.1.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 * Portions Copyright (c) 1999 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 1.1 (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 #import <architecture/i386/io.h>
36
37 #if !defined(DEFINE_INLINE_FUNCTIONS)
38 static
39 #endif
40 inline
41 unsigned char
42 inb(
43 io_addr_t port
44 )
45 {
46 unsigned char data;
47
48 asm volatile(
49 "inb %1,%0"
50
51 : "=a" (data)
52 : "d" (port));
53
54 return (data);
55 }
56
57 #if !defined(DEFINE_INLINE_FUNCTIONS)
58 static
59 #endif
60 inline
61 unsigned short
62 inw(
63 io_addr_t port
64 )
65 {
66 unsigned short data;
67
68 asm volatile(
69 "inw %1,%0"
70
71 : "=a" (data)
72 : "d" (port));
73
74 return (data);
75 }
76
77 #if !defined(DEFINE_INLINE_FUNCTIONS)
78 static
79 #endif
80 inline
81 void
82 outb(
83 io_addr_t port,
84 unsigned char data
85 )
86 {
87 static int xxx;
88
89 asm volatile(
90 "outb %2,%1; lock; incl %0"
91
92 : "=m" (xxx)
93 : "d" (port), "a" (data), "0" (xxx)
94 : "cc");
95 }
96
97 #if !defined(DEFINE_INLINE_FUNCTIONS)
98 static
99 #endif
100 inline
101 void
102 outw(
103 io_addr_t port,
104 unsigned short data
105 )
106 {
107 static int xxx;
108
109 asm volatile(
110 "outw %2,%1; lock; incl %0"
111
112 : "=m" (xxx)
113 : "d" (port), "a" (data), "0" (xxx)
114 : "cc");
115 }
116