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