1 | /* |
2 | * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved. |
3 | * |
4 | * @APPLE_OSREFERENCE_LICENSE_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 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 |
24 | * limitations under the License. |
25 | * |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
27 | */ |
28 | #ifndef _PEXPERT_I386_PROTOS_H |
29 | #define _PEXPERT_I386_PROTOS_H |
30 | |
31 | //------------------------------------------------------------------------ |
32 | // x86 IN/OUT I/O inline functions. |
33 | // |
34 | // IN : inb, inw, inl |
35 | // IN(port) |
36 | // |
37 | // OUT: outb, outw, outl |
38 | // OUT(port, data) |
39 | |
40 | typedef unsigned short i386_ioport_t; |
41 | |
42 | #define __IN(s, u) \ |
43 | static __inline__ unsigned u \ |
44 | in##s(i386_ioport_t port) \ |
45 | { \ |
46 | unsigned u data; \ |
47 | asm volatile ( \ |
48 | "in" #s " %1,%0" \ |
49 | : "=a" (data) \ |
50 | : "d" (port)); \ |
51 | return (data); \ |
52 | } |
53 | |
54 | #define __OUT(s, u) \ |
55 | static __inline__ void \ |
56 | out##s(i386_ioport_t port, unsigned u data) \ |
57 | { \ |
58 | asm volatile ( \ |
59 | "out" #s " %1,%0" \ |
60 | : \ |
61 | : "d" (port), "a" (data)); \ |
62 | } |
63 | |
64 | __IN(b, char) |
65 | __IN(w, short) |
66 | __IN(l, long) |
67 | |
68 | __OUT(b, char) |
69 | __OUT(w, short) |
70 | __OUT(l, long) |
71 | |
72 | extern void cninit(void); |
73 | extern int sprintf(char * str, const char * format, ...); |
74 | |
75 | /* ------------------------------------------------------------------------ |
76 | * from osfmk/i386/serial_io.h |
77 | */ |
78 | int switch_to_serial_console(void); |
79 | void switch_to_old_console(int); |
80 | boolean_t console_is_serial(void); |
81 | int serial_init(void); |
82 | void serial_putc(char); |
83 | int serial_getc(void); |
84 | |
85 | /* ------------------------------------------------------------------------ |
86 | * from osfmk/kern/misc_protos.h |
87 | */ |
88 | void cnputc(char); |
89 | int cngetc(void); |
90 | |
91 | #endif /* _PEXPERT_I386_PROTOS_H */ |
92 | |