]> git.saurik.com Git - apple/xnu.git/blame - osfmk/i386/pio.h
xnu-792.21.3.tar.gz
[apple/xnu.git] / osfmk / i386 / pio.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
8f6c56a5 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
1c79356b 5 *
8f6c56a5
A
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
8ad349bb 24 * limitations under the License.
8f6c56a5
A
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b
A
27 */
28/*
29 * @OSF_COPYRIGHT@
30 */
31/*
32 * Mach Operating System
33 * Copyright (c) 1991,1990 Carnegie Mellon University
34 * All Rights Reserved.
35 *
36 * Permission to use, copy, modify and distribute this software and its
37 * documentation is hereby granted, provided that both the copyright
38 * notice and this permission notice appear in all copies of the
39 * software, derivative works or modified versions, and any portions
40 * thereof, and that both notices appear in supporting documentation.
41 *
42 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
43 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
44 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
45 *
46 * Carnegie Mellon requests users of this software to return to
47 *
48 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
49 * School of Computer Science
50 * Carnegie Mellon University
51 * Pittsburgh PA 15213-3890
52 *
53 * any improvements or extensions that they make and grant Carnegie Mellon
54 * the rights to redistribute these changes.
55 */
56/*
57 */
58#ifndef I386_PIO_H
59#define I386_PIO_H
1c79356b
A
60#include <mach_assert.h>
61
62typedef unsigned short i386_ioport_t;
63
64/* read a longword */
65extern unsigned long inl(
66 i386_ioport_t port);
67/* read a shortword */
68extern unsigned short inw(
69 i386_ioport_t port);
70/* read a byte */
71extern unsigned char inb(
72 i386_ioport_t port);
73/* write a longword */
74extern void outl(
75 i386_ioport_t port,
76 unsigned long datum);
77/* write a word */
78extern void outw(
79 i386_ioport_t port,
80 unsigned short datum);
81/* write a longword */
82extern void outb(
83 i386_ioport_t port,
84 unsigned char datum);
85
86/* input an array of longwords */
87extern void linl(
88 i386_ioport_t port,
89 int * data,
90 int count);
91/* output an array of longwords */
92extern void loutl(
93 i386_ioport_t port,
94 int * data,
95 int count);
96
97/* input an array of words */
98extern void linw(
99 i386_ioport_t port,
100 int * data,
101 int count);
102/* output an array of words */
103extern void loutw(
104 i386_ioport_t port,
105 int * data,
106 int count);
107
108/* input an array of bytes */
109extern void linb(
110 i386_ioport_t port,
111 char * data,
112 int count);
113/* output an array of bytes */
114extern void loutb(
115 i386_ioport_t port,
116 char * data,
117 int count);
118
21362eb3
A
119#if defined(__GNUC__) && (!MACH_ASSERT)
120extern __inline__ unsigned long inl(
121 i386_ioport_t port)
122{
123 unsigned long datum;
124 __asm__ volatile("inl %1, %0" : "=a" (datum) : "d" (port));
125 return(datum);
126}
127
128extern __inline__ unsigned short inw(
129 i386_ioport_t port)
130{
131 unsigned short datum;
132 __asm__ volatile(".byte 0x66; inl %1, %0" : "=a" (datum) : "d" (port));
133 return(datum);
134}
135
136extern __inline__ unsigned char inb(
137 i386_ioport_t port)
138{
139 unsigned char datum;
140 __asm__ volatile("inb %1, %0" : "=a" (datum) : "d" (port));
141 return(datum);
142}
143
144extern __inline__ void outl(
145 i386_ioport_t port,
146 unsigned long datum)
147{
148 __asm__ volatile("outl %0, %1" : : "a" (datum), "d" (port));
149}
150
151extern __inline__ void outw(
152 i386_ioport_t port,
153 unsigned short datum)
154{
155 __asm__ volatile(".byte 0x66; outl %0, %1" : : "a" (datum), "d" (port));
156}
157
158extern __inline__ void outb(
159 i386_ioport_t port,
160 unsigned char datum)
161{
162 __asm__ volatile("outb %0, %1" : : "a" (datum), "d" (port));
163}
164#endif /* defined(__GNUC__) && (!MACH_ASSERT) */
1c79356b 165#endif /* I386_PIO_H */