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 | *␊ |
42 | * x86 IN/OUT I/O inline functions.␊ |
43 | *␊ |
44 | * IN : inb, inw, inl␊ |
45 | * IN(port)␊ |
46 | *␊ |
47 | * OUT: outb, outw, outl␊ |
48 | * OUT(port, data)␊ |
49 | *␊ |
50 | *############################################################################␊ |
51 | */␊ |
52 | ␊ |
53 | #define __IN(s, u) \␊ |
54 | static inline unsigned u \␊ |
55 | in##s(unsigned short port) \␊ |
56 | { \␊ |
57 | unsigned u data; \␊ |
58 | asm volatile ( \␊ |
59 | ␉"in" #s " %1,%0" \␊ |
60 | ␉␉: "=a" (data) \␊ |
61 | ␉␉: "d" (port)); \␊ |
62 | return (data); \␊ |
63 | }␊ |
64 | ␊ |
65 | #define __OUT(s, u) \␊ |
66 | static inline void \␊ |
67 | out##s(unsigned short port, unsigned u data) \␊ |
68 | { \␊ |
69 | asm volatile ( \␊ |
70 | ␉"out" #s " %1,%0" \␊ |
71 | ␉␉: \␊ |
72 | ␉␉: "d" (port), "a" (data)); \␊ |
73 | }␊ |
74 | ␊ |
75 | __IN(b, char) /* inb() */␊ |
76 | __IN(w, short) /* inw() */␊ |
77 | __IN(l, long) /* inl() */␊ |
78 | ␊ |
79 | __OUT(b, char) /* outb() */␊ |
80 | __OUT(w, short) /* outw() */␊ |
81 | __OUT(l, long) /* outl() */␊ |
82 | ␊ |
83 | ␊ |
84 | static inline void cmos_write_byte (int loc, int val)␊ |
85 | {␊ |
86 | ␉outb (0x70, loc);␊ |
87 | ␉outb (0x71, val);␊ |
88 | }␊ |
89 | ␊ |
90 | static inline unsigned cmos_read_byte (int loc)␊ |
91 | {␊ |
92 | ␉outb (0x70, loc);␊ |
93 | ␉return inb (0x71);␊ |
94 | }␊ |
95 | ␊ |
96 | #define CMOS_WRITE_BYTE(x, y)␉cmos_write_byte(x, y)␊ |
97 | #define CMOS_READ_BYTE(x)␉cmos_read_byte(x)␊ |
98 | ␊ |
99 | static inline void cli() {␊ |
100 | ␉asm("cli");␊ |
101 | }␊ |
102 | static inline void sti() {␊ |
103 | ␉asm("sti");␊ |
104 | }␊ |
105 | ␊ |
106 | #endif /* !__LIBSAIO_IO_INLINE_H */␊ |
107 | |