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