]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. | |
7 | * | |
8 | * This file contains Original Code and/or Modifications of Original Code | |
9 | * as defined in and that are subject to the Apple Public Source License | |
10 | * Version 2.0 (the 'License'). You may not use this file except in | |
11 | * compliance with the License. Please obtain a copy of the License at | |
12 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
13 | * file. | |
14 | * | |
15 | * The Original Code and all software distributed under the License are | |
16 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
19 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
20 | * Please see the License for the specific language governing rights and | |
21 | * limitations under the License. | |
22 | * | |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* | |
26 | * @OSF_COPYRIGHT@ | |
27 | */ | |
28 | /* | |
29 | */ | |
30 | ||
31 | /* | |
32 | * Olivetti Mach Console driver v0.0 | |
33 | * Copyright Ing. C. Olivetti & C. S.p.A. 1988, 1989 | |
34 | * All rights reserved. | |
35 | * | |
36 | */ | |
37 | /* | |
38 | * Copyright 1988, 1989 by Olivetti Advanced Technology Center, Inc., | |
39 | * Cupertino, California. | |
40 | * | |
41 | * All Rights Reserved | |
42 | * | |
43 | * Permission to use, copy, modify, and distribute this software and | |
44 | * its documentation for any purpose and without fee is hereby | |
45 | * granted, provided that the above copyright notice appears in all | |
46 | * copies and that both the copyright notice and this permission notice | |
47 | * appear in supporting documentation, and that the name of Olivetti | |
48 | * not be used in advertising or publicity pertaining to distribution | |
49 | * of the software without specific, written prior permission. | |
50 | * | |
51 | * OLIVETTI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE | |
52 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, | |
53 | * IN NO EVENT SHALL OLIVETTI BE LIABLE FOR ANY SPECIAL, INDIRECT, OR | |
54 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | |
55 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, | |
56 | * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUR OF OR IN CONNECTION | |
57 | * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
58 | * | |
59 | * | |
60 | * Copyright 1988, 1989 by Intel Corporation, Santa Clara, California. | |
61 | * | |
62 | * All Rights Reserved | |
63 | * | |
64 | * Permission to use, copy, modify, and distribute this software and | |
65 | * its documentation for any purpose and without fee is hereby | |
66 | * granted, provided that the above copyright notice appears in all | |
67 | * copies and that both the copyright notice and this permission notice | |
68 | * appear in supporting documentation, and that the name of Intel | |
69 | * not be used in advertising or publicity pertaining to distribution | |
70 | * of the software without specific, written prior permission. | |
71 | * | |
72 | * INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE | |
73 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, | |
74 | * IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR | |
75 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | |
76 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, | |
77 | * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION | |
78 | * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
79 | */ | |
80 | ||
81 | /* $ Header: $ */ | |
82 | ||
83 | #include <pexpert/pexpert.h> | |
84 | ||
85 | /* | |
86 | * Common I/O ports. | |
87 | */ | |
88 | #define K_RDWR 0x60 /* keyboard data & cmds (read/write) */ | |
89 | #define K_STATUS 0x64 /* keybd status (read-only) */ | |
90 | #define K_CMD 0x64 /* keybd ctlr command (write-only) */ | |
91 | ||
92 | /* | |
93 | * Bit definitions for K_STATUS port. | |
94 | */ | |
95 | #define K_OBUF_FUL 0x01 /* output (from keybd) buffer full */ | |
96 | #define K_IBUF_FUL 0x02 /* input (to keybd) buffer full */ | |
97 | #define K_SYSFLAG 0x04 /* "System Flag" */ | |
98 | #define K_CMD_DATA 0x08 /* 1 = input buf has cmd, 0 = data */ | |
99 | #define K_KBD_INHBT 0x10 /* 0 if keyboard inhibited */ | |
100 | #define K_XMT_TIMEOUT 0x20 /* Transmit time out */ | |
101 | #define K_RCV_TIMEOUT 0x40 /* Receive time out */ | |
102 | ||
103 | /* | |
104 | * Keyboard controller commands (sent to K_CMD port). | |
105 | */ | |
106 | #define K_CMD_READ 0x20 /* read controller command byte */ | |
107 | #define K_CMD_WRITE 0x60 /* write controller command byte */ | |
108 | #define K_CMD_TEST 0xab /* test interface */ | |
109 | #define K_CMD_DUMP 0xac /* diagnostic dump */ | |
110 | #define K_CMD_DISBLE 0xad /* disable keyboard */ | |
111 | #define K_CMD_ENBLE 0xae /* enable keyboard */ | |
112 | #define K_CMD_RDKBD 0xc4 /* read keyboard ID */ | |
113 | #define K_CMD_ECHO 0xee /* used for diagnostic testing */ | |
114 | #define K_CMD_RESET 0xfe /* issue a system reset */ | |
115 | ||
116 | /* | |
117 | * cngetc / cnmaygetc | |
118 | * | |
119 | * Get one character using polling, rather than interrupts. | |
120 | * Used by the kernel debugger. | |
121 | */ | |
122 | ||
123 | int | |
124 | cngetc(void) | |
125 | { | |
126 | char c; | |
127 | ||
128 | if ( 0 == (*PE_poll_input)(0, &c) ) | |
129 | return ( c ); | |
130 | else | |
131 | return ( 0 ); | |
132 | } | |
133 | ||
134 | int | |
135 | cnmaygetc(void) | |
136 | { | |
137 | char c; | |
138 | ||
139 | if ( 0 == (*PE_poll_input)(0, &c) ) | |
140 | return ( c ); | |
141 | else | |
142 | return ( 0 ); | |
143 | } | |
144 | ||
145 | /* | |
146 | * kd_sendcmd | |
147 | * | |
148 | * This function sends a command byte to the keyboard command | |
149 | * port, but first waits until the input/output data buffer is | |
150 | * clear before sending the data. | |
151 | * | |
152 | */ | |
153 | ||
154 | static void | |
155 | kd_sendcmd(unsigned char ch) | |
156 | { | |
157 | while (inb(K_STATUS) & K_IBUF_FUL); | |
158 | outb(K_CMD, ch); | |
159 | } | |
160 | ||
161 | /* | |
162 | * kdreboot | |
163 | * | |
164 | * Send a command to the motherboard keyboard controller to | |
165 | * issue a hardware reset. | |
166 | */ | |
167 | ||
168 | void | |
169 | kdreboot(void) | |
170 | { | |
171 | extern void cpu_shutdown(void); | |
172 | ||
173 | kd_sendcmd( K_CMD_RESET ); | |
174 | ||
175 | /* | |
176 | * DRAT. We're still here. Let's try a "CPU shutdown", which consists | |
177 | * of clearing the IDTR and causing an exception. It's in locore.s | |
178 | */ | |
179 | cpu_shutdown(); | |
180 | /*NOTREACHED*/ | |
181 | } |