1 | /*␊ |
2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.␊ |
3 | *␊ |
4 | * ␊ |
5 | * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights␊ |
6 | * Reserved. This file contains Original Code and/or Modifications of␊ |
7 | * Original Code as defined in and that are subject to the Apple Public␊ |
8 | * Source License Version 2.0 (the "License"). You may not use this file␊ |
9 | * except in compliance with the License. Please obtain a copy of the␊ |
10 | * License at http://www.apple.com/publicsource and read it before using␊ |
11 | * this file.␊ |
12 | * ␊ |
13 | * The Original Code and all software distributed under the License are␊ |
14 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER␊ |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,␊ |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,␊ |
17 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the␊ |
18 | * License for the specific language governing rights and limitations␊ |
19 | * under the License.␊ |
20 | * ␊ |
21 | *␊ |
22 | * Copyright (c) 1992 NeXT Computer, Inc.␊ |
23 | *␊ |
24 | * Inlines for io space access.␊ |
25 | *␊ |
26 | * HISTORY␊ |
27 | *␊ |
28 | * 20 May 1992 ? at NeXT␊ |
29 | *␉Created.␊ |
30 | */␊ |
31 | ␊ |
32 | #ifndef __LIBSAIO_IO_INLINE_H␊ |
33 | #define __LIBSAIO_IO_INLINE_H␊ |
34 | ␊ |
35 | /*␊ |
36 | *############################################################################␊ |
37 | *␊ |
38 | * x86 IN/OUT I/O inline functions.␊ |
39 | *␊ |
40 | * IN : inb, inw, inl␊ |
41 | * IN(port)␊ |
42 | *␊ |
43 | * OUT: outb, outw, outl␊ |
44 | * OUT(port, data)␊ |
45 | *␊ |
46 | *############################################################################␊ |
47 | */␊ |
48 | ␊ |
49 | #define __IN(s, u) \␊ |
50 | static inline unsigned u \␊ |
51 | in##s(unsigned short port) \␊ |
52 | { \␊ |
53 | unsigned u data; \␊ |
54 | asm volatile ( \␊ |
55 | ␉"in" #s " %1,%0" \␊ |
56 | ␉␉: "=a" (data) \␊ |
57 | ␉␉: "d" (port)); \␊ |
58 | return (data); \␊ |
59 | }␊ |
60 | ␊ |
61 | #define __OUT(s, u) \␊ |
62 | static inline void \␊ |
63 | out##s(unsigned short port, unsigned u data) \␊ |
64 | { \␊ |
65 | asm volatile ( \␊ |
66 | ␉"out" #s " %1,%0" \␊ |
67 | ␉␉: \␊ |
68 | ␉␉: "d" (port), "a" (data)); \␊ |
69 | }␊ |
70 | ␊ |
71 | __IN(b, char) /* inb() */␊ |
72 | __IN(w, short) /* inw() */␊ |
73 | __IN(l, long) /* inl() */␊ |
74 | ␊ |
75 | __OUT(b, char) /* outb() */␊ |
76 | __OUT(w, short) /* outw() */␊ |
77 | __OUT(l, long) /* outl() */␊ |
78 | ␊ |
79 | ␊ |
80 | static inline void cmos_write_byte (int loc, int val)␊ |
81 | {␊ |
82 | ␉outb (0x70, loc);␊ |
83 | ␉outb (0x71, val);␊ |
84 | }␊ |
85 | ␊ |
86 | static inline unsigned cmos_read_byte (int loc)␊ |
87 | {␊ |
88 | ␉outb (0x70, loc);␊ |
89 | ␉return inb (0x71);␊ |
90 | }␊ |
91 | ␊ |
92 | #define CMOS_WRITE_BYTE(x, y)␉cmos_write_byte(x, y)␊ |
93 | #define CMOS_READ_BYTE(x)␉cmos_read_byte(x)␊ |
94 | ␊ |
95 | static inline void cli() {␊ |
96 | ␉asm("cli");␊ |
97 | }␊ |
98 | static inline void sti() {␊ |
99 | ␉asm("sti");␊ |
100 | }␊ |
101 | ␊ |
102 | #endif /* !__LIBSAIO_IO_INLINE_H */␊ |
103 | |