Print this page
NEX-16819 loader UEFI support
Includes work by Toomas Soome <tsoome@me.com>
Upstream commits:
loader: pxe receive cleanup
9475 libefi: Do not return only if ReceiveFilter
installboot: should support efi system partition
8931 boot1.efi: scan all display modes rather than
loader: spinconsole updates
loader: gfx experiment to try GOP Blt() function.
sha1 build test
loader: add sha1 hash calculation
common/sha1: update for loader build
loader: biosdisk rework
uts: 32-bit kernel FB needs mapping in low memory
uts: add diag-device
uts: boot console mirror with diag-device
uts: enable very early console on ttya
kmdb: add diag-device as input/output device
uts: test VGA memory exclusion from mapping
uts: clear boot mapping and protect boot pages test
uts: add dboot map debug printf
uts: need to release FB pages in release_bootstrap()
uts: add screenmap ioctl
uts: update sys/queue.h
loader: add illumos uts/common to include path
loader: tem/gfx font cleanup
loader: vbe checks
uts: gfx_private set KD_TEXT when KD_RESETTEXT is
uts: gfx 8-bit update
loader: gfx 8-bit fix
loader: always set media size from partition.
uts: MB2 support for 32-bit kernel
loader: x86 should have tem 80x25
uts: x86 should have tem 80x25
uts: font update
loader: font update
uts: tem attributes
loader: tem.c comment added
uts: use font module
loader: add font module
loader: build rules for new font setup
uts: gfx_private update for new font structure
uts: early boot update for new font structure
uts: font update
uts: font build rules update for new fonts
uts: tem update to new font structure
loader: module.c needs to include tem_impl.h
uts: gfx_private 8x16 font rework
uts: make font_lookup public
loader: font rework
uts: font rework
9259 libefi: efi_alloc_and_read should check for PMBR
uts: tem utf-8 support
loader: implement tem utf-8 support
loader: tem should be able to display UTF-8
7784 uts: console input should support utf-8
7796 uts: ldterm default to utf-8
uts: do not reset serial console
uts: set up colors even if tem is not console
uts: add type for early boot properties
uts: gfx_private experiment with drm and vga
uts: gfx_private should use setmode drm callback.
uts: identify FB types and set up gfx_private based
loader: replace gop and vesa with framebuffer
uts: boot needs simple tem to support mdb
uts: boot_keyboard should emit esc sequences for
uts: gfx_private FB showuld be written by line
kmdb: set terminal window size
uts: gfx_private needs to keep track of early boot FB
pnglite: move pnglite to usr/src/common
loader: gfx_fb
ficl-sys: add gfx primitives
loader: add illumos.png logo
ficl: add fb-putimage
loader: add png support
loader: add alpha blending for gfx_fb
loader: use term-drawrect for menu frame
ficl: add simple gfx words
uts: provide fb_info via fbgattr dev_specific array.
uts: gfx_private add alpha blending
uts: update sys/ascii.h
uts: tem OSC support (incomplete)
uts: implement env module support and use data from
uts: tem get colors from early boot data
loader: use crc32 from libstand (libz)
loader: optimize for size
loader: pass tem info to the environment
loader: import tem for loader console
loader: UEFI loader needs to set ISADIR based on
loader: need UEFI32 support
8918 loader.efi: add vesa edid support
uts: tem_safe_pix_clear_prom_output() should only
uts: tem_safe_pix_clear_entire_screen() should use
uts: tem_safe_check_first_time() should query cursor
uts: tem implement cls callback & visual_io v4
uts: gfx_vgatext use block cursor for vgatext
uts: gfx_private implement cls callback & visual_io
uts: gfx_private bitmap framebuffer implementation
uts: early start frame buffer console support
uts: font functions should check the input char
uts: font rendering should support 16/24/32bit depths
uts: use smallest font as fallback default.
uts: update terminal dimensions based on selected
7834 uts: vgatext should use gfx_private
uts: add spacing property to 8859-1.bdf
terminfo: add underline for sun-color
terminfo: sun-color has 16 colors
uts: add font load callback type
loader: do not repeat int13 calls with error 0x20 and
8905 loader: add skein/edonr support
8904 common/crypto: make skein and edonr loader
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Revert "NEX-16819 loader UEFI support"
This reverts commit ec06b9fc617b99234e538bf2e7e4d02a24993e0c.
Reverting due to failures in the zfs-tests and the sharefs-tests
NEX-16819 loader UEFI support
Includes work by Toomas Soome <tsoome@me.com>
Upstream commits:
loader: pxe receive cleanup
9475 libefi: Do not return only if ReceiveFilter
installboot: should support efi system partition
8931 boot1.efi: scan all display modes rather than
loader: spinconsole updates
loader: gfx experiment to try GOP Blt() function.
sha1 build test
loader: add sha1 hash calculation
common/sha1: update for loader build
loader: biosdisk rework
uts: 32-bit kernel FB needs mapping in low memory
uts: add diag-device
uts: boot console mirror with diag-device
uts: enable very early console on ttya
kmdb: add diag-device as input/output device
uts: test VGA memory exclusion from mapping
uts: clear boot mapping and protect boot pages test
uts: add dboot map debug printf
uts: need to release FB pages in release_bootstrap()
uts: add screenmap ioctl
uts: update sys/queue.h
loader: add illumos uts/common to include path
loader: tem/gfx font cleanup
loader: vbe checks
uts: gfx_private set KD_TEXT when KD_RESETTEXT is
uts: gfx 8-bit update
loader: gfx 8-bit fix
loader: always set media size from partition.
uts: MB2 support for 32-bit kernel
loader: x86 should have tem 80x25
uts: x86 should have tem 80x25
uts: font update
loader: font update
uts: tem attributes
loader: tem.c comment added
uts: use font module
loader: add font module
loader: build rules for new font setup
uts: gfx_private update for new font structure
uts: early boot update for new font structure
uts: font update
uts: font build rules update for new fonts
uts: tem update to new font structure
loader: module.c needs to include tem_impl.h
uts: gfx_private 8x16 font rework
uts: make font_lookup public
loader: font rework
uts: font rework
libefi: efi_alloc_and_read should check for PMBR
uts: tem utf-8 support
loader: implement tem utf-8 support
loader: tem should be able to display UTF-8
7784 uts: console input should support utf-8
7796 uts: ldterm default to utf-8
uts: do not reset serial console
uts: set up colors even if tem is not console
uts: add type for early boot properties
uts: gfx_private experiment with drm and vga
uts: gfx_private should use setmode drm callback.
uts: identify FB types and set up gfx_private based
loader: replace gop and vesa with framebuffer
uts: boot needs simple tem to support mdb
uts: boot_keyboard should emit esc sequences for
uts: gfx_private FB showuld be written by line
kmdb: set terminal window size
uts: gfx_private needs to keep track of early boot FB
pnglite: move pnglite to usr/src/common
loader: gfx_fb
ficl-sys: add gfx primitives
loader: add illumos.png logo
ficl: add fb-putimage
loader: add png support
loader: add alpha blending for gfx_fb
loader: use term-drawrect for menu frame
ficl: add simple gfx words
uts: provide fb_info via fbgattr dev_specific array.
uts: gfx_private add alpha blending
uts: update sys/ascii.h
uts: tem OSC support (incomplete)
uts: implement env module support and use data from
uts: tem get colors from early boot data
loader: use crc32 from libstand (libz)
loader: optimize for size
loader: pass tem info to the environment
loader: import tem for loader console
loader: UEFI loader needs to set ISADIR based on
loader: need UEFI32 support
8918 loader.efi: add vesa edid support
uts: tem_safe_pix_clear_prom_output() should only
uts: tem_safe_pix_clear_entire_screen() should use
uts: tem_safe_check_first_time() should query cursor
uts: tem implement cls callback & visual_io v4
uts: gfx_vgatext use block cursor for vgatext
uts: gfx_private implement cls callback & visual_io
uts: gfx_private bitmap framebuffer implementation
uts: early start frame buffer console support
uts: font functions should check the input char
uts: font rendering should support 16/24/32bit depths
uts: use smallest font as fallback default.
uts: update terminal dimensions based on selected
7834 uts: vgatext should use gfx_private
uts: add spacing property to 8859-1.bdf
terminfo: add underline for sun-color
terminfo: sun-color has 16 colors
uts: add font load callback type
loader: do not repeat int13 calls with error 0x20 and
8905 loader: add skein/edonr support
8904 common/crypto: make skein and edonr loader
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/i86pc/boot/boot_keyboard.c
+++ new/usr/src/uts/i86pc/boot/boot_keyboard.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 26 #pragma ident "%Z%%M% %I% %E% SMI"
27 27
28 28 /*
29 29 * Miniature keyboard driver for bootstrap. This allows keyboard
30 30 * support to continue after we take over interrupts and disable
31 31 * BIOS keyboard support.
32 32 */
33 33
34 34 #include <sys/types.h>
35 35 #include <sys/archsystm.h>
36 36 #include <sys/boot_console.h>
37 37 #include "boot_keyboard_table.h"
38 38
39 39 #if defined(_BOOT)
40 40 #include "dboot/dboot_asm.h"
41 41 #include "dboot/dboot_xboot.h"
42 42 #endif /* _BOOT */
43 43
44 44 /*
45 45 * Definitions for BIOS keyboard state. We use BIOS's variable to store
46 46 * state, ensuring that we stay in sync with it.
47 47 */
48 48 #define BIOS_KB_FLAG 0x417
49 49 #define BIOS_RIGHT_SHIFT 0x01
50 50 #define BIOS_LEFT_SHIFT 0x02
51 51 #define BIOS_EITHER_SHIFT (BIOS_LEFT_SHIFT | BIOS_RIGHT_SHIFT)
52 52 #define BIOS_CTL_SHIFT 0x04
53 53 #define BIOS_ALT_SHIFT 0x08
54 54 #define BIOS_SCROLL_STATE 0x10
55 55 #define BIOS_NUM_STATE 0x20
56 56 #define BIOS_CAPS_STATE 0x40
57 57 #define BIOS_INS_STATE 0x80
58 58
59 59 #define BIOS_KB_FLAG_1 0x418
60 60 #define BIOS_SYS_SHIFT 0x04
61 61 #define BIOS_HOLD_STATE 0x08
62 62 #define BIOS_SCROLL_SHIFT 0x10
63 63 #define BIOS_NUM_SHIFT 0x20
64 64 #define BIOS_CAPS_SHIFT 0x40
65 65 #define BIOS_INS_SHIFT 0x80
66 66
67 67 #if defined(__xpv) && defined(_BOOT)
68 68
69 69 /*
70 70 * Device memory addresses
71 71 *
72 72 * In dboot under the hypervisor we don't have any memory mappings
73 73 * for the first meg of low memory so we can't access devices there.
74 74 * Intead we've mapped the device memory that we need to access into
75 75 * a local variable within dboot so we can access the device memory
76 76 * there.
77 77 */
78 78 extern unsigned short *kb_status;
79 79 #define kb_flag ((unsigned char *)&kb_status[BIOS_KB_FLAG])
80 80 #define kb_flag_1 ((unsigned char *)&kb_status[BIOS_KB_FLAG_1])
81 81
82 82 #else /* __xpv && _BOOT */
83 83
84 84 /* Device memory addresses */
85 85 #define kb_flag ((unsigned char *)BIOS_KB_FLAG)
86 86 #define kb_flag_1 ((unsigned char *)BIOS_KB_FLAG_1)
87 87
88 88 #endif /* __xpv && _BOOT */
89 89
90 90 /*
91 91 * Keyboard controller registers
92 92 */
93 93 #define I8042_DATA 0x60
94 94 #define I8042_STAT 0x64
95 95 #define I8042_CMD 0x64
96 96
97 97 /*
98 98 * Keyboard controller status register bits
99 99 */
100 100 #define I8042_STAT_OUTBF 0x01
101 101 #define I8042_STAT_INBF 0x02
102 102 #define I8042_STAT_AUXBF 0x20
103 103
104 104 /*
105 105 * Keyboard controller commands
106 106 */
107 107 #define I8042_RCB 0x20
108 108 #define I8042_WCB 0x60
109 109
110 110 /*
111 111 * Keyboard commands
112 112 */
113 113 #define KB_SET_LED 0xED /* LED byte follows... */
114 114 #define KB_LED_SCROLL_LOCK 0x01 /* Bits for LED byte */
115 115 #define KB_LED_NUM_LOCK 0x02
116 116 #define KB_LED_CAPS_LOCK 0x04
117 117
118 118 #ifndef ASSERT
119 119 #define ASSERT(x)
120 120 #endif
121 121
122 122 #define peek8(p) (*(p))
123 123 #define poke8(p, val) (*(p) = (val))
124 124
125 125 static struct {
126 126 boolean_t initialized;
127 127 enum { KB_LED_IDLE, KB_LED_COMMAND_SENT, KB_LED_VALUE_SENT }
128 128 led_state;
129 129 int led_commanded;
130 130 /*
131 131 * Possible values:
132 132 *
133 133 * -1 Nothing pending
134 134 * 0x000-0x0ff Pending byte
135 135 * 0x100-0x1ff Needs leading zero, then low byte next.
136 136 *
|
↓ open down ↓ |
136 lines elided |
↑ open up ↑ |
137 137 * Others undefined.
138 138 */
139 139 int pending;
140 140 } kb = {
141 141 B_FALSE, /* initialized? */
142 142 KB_LED_IDLE, /* LED command state */
143 143 -1, /* commanded LEDs - force refresh */
144 144 -1, /* pending */
145 145 };
146 146
147 +#define KTAB_STRLEN 3
148 +static char keystringtab[KTAB_STRLEN] = {'\033', '[', ' '};
149 +static int keystring = -1;
150 +
147 151 static int kb_translate(unsigned char code);
148 152 static void kb_send(unsigned char cmd);
149 153 static void kb_update_leds(void);
150 154 static uchar_t kb_calculate_leds(void);
151 155
152 156 int
153 157 kb_getchar(void)
154 158 {
155 159 int ret;
156 160
157 161 while (!kb_ischar())
158 162 /* LOOP */;
159 163
164 + if (keystring >= 0) {
165 + ret = keystringtab[keystring++];
166 + if (keystring == KTAB_STRLEN) {
167 + keystring = -1;
168 + kb.pending = -1;
169 + }
170 + return (ret);
171 + }
172 +
160 173 /*
161 174 * kb_ischar() doesn't succeed without leaving kb.pending
162 175 * set.
163 176 */
164 177 ASSERT(kb.pending >= 0);
165 178
166 179 if (kb.pending & 0x100) {
167 - ret = 0;
168 180 kb.pending &= 0xff;
181 + switch (kb.pending) {
182 + case 'H': /* Up */
183 + keystringtab[2] = 'A';
184 + keystring = 0;
185 + return (kb_getchar());
186 + case 'P': /* Down */
187 + keystringtab[2] = 'B';
188 + keystring = 0;
189 + return (kb_getchar());
190 + case 'M': /* Right */
191 + keystringtab[2] = 'C';
192 + keystring = 0;
193 + return (kb_getchar());
194 + case 'K': /* Left */
195 + keystringtab[2] = 'D';
196 + keystring = 0;
197 + return (kb_getchar());
198 + default:
199 + ret = 0;
200 + }
169 201 } else {
170 202 ret = kb.pending;
171 203 kb.pending = -1;
172 204 }
173 205
174 206 return (ret);
175 207 }
176 208
177 209 int
178 210 kb_ischar(void)
179 211 {
180 212 unsigned char buffer_stat;
181 213 unsigned char code;
182 214 unsigned char leds;
183 215
184 216 if (!kb.initialized) {
185 217 kb_init();
186 218 kb.initialized = B_TRUE;
187 219 }
188 220
189 221 if (kb.pending >= 0)
190 222 return (1);
191 223
192 224 for (;;) {
193 225 buffer_stat = inb(I8042_STAT);
194 226 if (buffer_stat == 0xff)
195 227 return (0);
196 228 buffer_stat &= (I8042_STAT_OUTBF | I8042_STAT_AUXBF);
197 229
198 230 switch (buffer_stat) {
199 231 case 0:
200 232 case I8042_STAT_AUXBF:
201 233 return (0);
202 234 case (I8042_STAT_OUTBF | I8042_STAT_AUXBF):
203 235 /*
204 236 * Discard unwanted mouse data.
205 237 */
206 238 (void) inb(I8042_DATA);
207 239 continue;
208 240 }
209 241
210 242 code = inb(I8042_DATA);
211 243
212 244 switch (code) {
213 245 /*
214 246 * case 0xAA:
215 247 *
216 248 * You might think that we should ignore 0xAA on the
217 249 * grounds that it is the BAT Complete response and will
218 250 * occur on keyboard detach/reattach. Unfortunately,
219 251 * it is ambiguous - this is also the code for a break
220 252 * of the left shift key. Since it will be harmless for
221 253 * us to "spuriously" process a break of Left Shift,
222 254 * we just let the normal code handle it. Perhaps we
223 255 * should take a hint and refresh the LEDs, but I
224 256 * refuse to get very worried about hot-plug issues
225 257 * in this mini-driver.
226 258 */
227 259 case 0xFA:
228 260
229 261 switch (kb.led_state) {
230 262 case KB_LED_IDLE:
231 263 /*
232 264 * Spurious. Oh well, ignore it.
233 265 */
234 266 break;
235 267 case KB_LED_COMMAND_SENT:
236 268 leds = kb_calculate_leds();
237 269 kb_send(leds);
238 270 kb.led_commanded = leds;
239 271 kb.led_state = KB_LED_VALUE_SENT;
240 272 break;
241 273 case KB_LED_VALUE_SENT:
242 274 kb.led_state = KB_LED_IDLE;
243 275 /*
244 276 * Check for changes made while we were
245 277 * working on the last change.
246 278 */
247 279 kb_update_leds();
248 280 break;
249 281 }
250 282 continue;
251 283
252 284 case 0xE0:
253 285 case 0xE1:
254 286 /*
255 287 * These are used to distinguish the keys added on
256 288 * the AT-101 keyboard from the original 84 keys.
257 289 * We don't care, and the codes are carefully arranged
258 290 * so that we don't have to.
259 291 */
260 292 continue;
261 293
262 294 default:
263 295 if (code & 0x80) {
264 296 /* Release */
265 297 code &= 0x7f;
266 298 switch (keyboard_translate[code].normal) {
267 299 case KBTYPE_SPEC_LSHIFT:
268 300 poke8(kb_flag, peek8(kb_flag) &
269 301 ~BIOS_LEFT_SHIFT);
270 302 break;
271 303 case KBTYPE_SPEC_RSHIFT:
272 304 poke8(kb_flag, peek8(kb_flag) &
273 305 ~BIOS_RIGHT_SHIFT);
274 306 break;
275 307 case KBTYPE_SPEC_CTRL:
276 308 poke8(kb_flag, peek8(kb_flag) &
277 309 ~BIOS_CTL_SHIFT);
278 310 break;
279 311 case KBTYPE_SPEC_ALT:
280 312 poke8(kb_flag, peek8(kb_flag) &
281 313 ~BIOS_ALT_SHIFT);
282 314 break;
283 315 case KBTYPE_SPEC_CAPS_LOCK:
284 316 poke8(kb_flag_1, peek8(kb_flag_1) &
285 317 ~BIOS_CAPS_SHIFT);
286 318 break;
287 319 case KBTYPE_SPEC_NUM_LOCK:
288 320 poke8(kb_flag_1, peek8(kb_flag_1) &
289 321 ~BIOS_NUM_SHIFT);
290 322 break;
291 323 case KBTYPE_SPEC_SCROLL_LOCK:
292 324 poke8(kb_flag_1, peek8(kb_flag_1) &
293 325 ~BIOS_SCROLL_SHIFT);
294 326 break;
295 327 default:
296 328 /*
297 329 * Ignore all other releases.
298 330 */
299 331 break;
300 332 }
301 333 } else {
302 334 /* Press */
303 335
304 336 kb.pending = kb_translate(code);
305 337 if (kb.pending >= 0) {
306 338 return (1);
307 339 }
308 340 }
309 341 }
310 342 }
311 343 }
312 344
313 345 int
314 346 kb_translate(unsigned char code)
315 347 {
316 348 struct keyboard_translate *k;
317 349 unsigned short action;
318 350 boolean_t shifted;
319 351
320 352 k = keyboard_translate + code;
321 353
322 354 shifted = (peek8(kb_flag) & BIOS_EITHER_SHIFT) != 0;
323 355
324 356 switch (k->normal & 0xFF00) {
325 357 case KBTYPE_NUMPAD:
326 358 if (peek8(kb_flag) & BIOS_NUM_STATE)
327 359 shifted = !shifted;
328 360 break;
329 361 case KBTYPE_ALPHA:
330 362 if (peek8(kb_flag) & BIOS_CAPS_STATE)
331 363 shifted = !shifted;
332 364 break;
333 365 }
334 366
335 367 if (peek8(kb_flag) & BIOS_ALT_SHIFT)
336 368 action = k->alted;
337 369 else if (peek8(kb_flag) & BIOS_CTL_SHIFT)
338 370 action = k->ctrled;
339 371 else if (shifted)
340 372 action = k->shifted;
341 373 else
342 374 action = k->normal;
343 375
344 376 switch (action & 0xFF00) {
345 377 case KBTYPE_NORMAL:
346 378 case KBTYPE_ALPHA:
347 379 return (action & 0xFF);
348 380
349 381 case KBTYPE_NUMPAD:
350 382 case KBTYPE_FUNC:
351 383 return ((action & 0xFF) | 0x100);
352 384
353 385 case KBTYPE_SPEC:
354 386 break;
355 387
356 388 default:
357 389 /*
358 390 * Bad entry.
359 391 */
360 392 ASSERT(0);
361 393 return (-1);
362 394 }
363 395
364 396 /*
365 397 * Handle special keys, mostly shifts.
366 398 */
367 399 switch (action) {
368 400 case KBTYPE_SPEC_NOP:
369 401 case KBTYPE_SPEC_UNDEF:
370 402 break;
371 403
372 404 case KBTYPE_SPEC_LSHIFT:
373 405 poke8(kb_flag, peek8(kb_flag) | BIOS_LEFT_SHIFT);
374 406 break;
375 407
376 408 case KBTYPE_SPEC_RSHIFT:
377 409 poke8(kb_flag, peek8(kb_flag) | BIOS_RIGHT_SHIFT);
378 410 break;
379 411
380 412 case KBTYPE_SPEC_CTRL:
381 413 poke8(kb_flag, peek8(kb_flag) | BIOS_CTL_SHIFT);
382 414 break;
383 415
384 416 case KBTYPE_SPEC_ALT:
385 417 poke8(kb_flag, peek8(kb_flag) | BIOS_ALT_SHIFT);
386 418 break;
387 419
388 420 case KBTYPE_SPEC_CAPS_LOCK:
389 421 if (!(peek8(kb_flag_1) & BIOS_CAPS_SHIFT)) {
390 422 poke8(kb_flag_1, peek8(kb_flag_1) | BIOS_CAPS_SHIFT);
391 423 poke8(kb_flag, peek8(kb_flag) ^ BIOS_CAPS_STATE);
392 424 }
393 425 break;
394 426
395 427 case KBTYPE_SPEC_NUM_LOCK:
396 428 if (!(peek8(kb_flag_1) & BIOS_NUM_SHIFT)) {
397 429 poke8(kb_flag_1, peek8(kb_flag_1) | BIOS_NUM_SHIFT);
398 430 poke8(kb_flag, peek8(kb_flag) ^ BIOS_NUM_STATE);
399 431 }
400 432 break;
401 433
402 434 case KBTYPE_SPEC_SCROLL_LOCK:
403 435 if (!(peek8(kb_flag_1) & BIOS_SCROLL_SHIFT)) {
404 436 poke8(kb_flag_1, peek8(kb_flag_1) | BIOS_SCROLL_SHIFT);
405 437 poke8(kb_flag, peek8(kb_flag) ^ BIOS_SCROLL_STATE);
406 438 }
407 439 break;
408 440
409 441 case KBTYPE_SPEC_MAYBE_REBOOT:
410 442 #if 0 /* Solaris doesn't reboot via ctrl-alt-del */
411 443 if ((peek8(kb_flag) & (BIOS_CTL_SHIFT|BIOS_ALT_SHIFT)) ==
412 444 (BIOS_CTL_SHIFT|BIOS_ALT_SHIFT)) {
413 445 reset();
414 446 /* NOTREACHED */
415 447 }
416 448 #endif
417 449 break;
418 450
419 451 default:
420 452 /*
421 453 * Bad entry
422 454 */
423 455 ASSERT(0);
424 456 break;
425 457 }
426 458
427 459 /*
428 460 * Consider updating the LEDs. This does nothing if nothing
429 461 * needs to be done.
430 462 */
431 463 kb_update_leds();
432 464
433 465 return (-1);
434 466 }
435 467
436 468 void
437 469 kb_send(unsigned char cmd)
438 470 {
439 471 int retries;
440 472
441 473 for (retries = 0;
442 474 (inb(I8042_STAT) & I8042_STAT_INBF) != 0 && retries < 100000;
443 475 retries++)
444 476 /* LOOP */;
445 477 outb(I8042_DATA, cmd);
446 478 }
447 479
448 480 void
449 481 kb_update_leds(void)
450 482 {
451 483 if (kb.led_state != KB_LED_IDLE) {
452 484 /*
453 485 * The state machine will take care of any additional
454 486 * changes that are necessary.
455 487 */
456 488 return;
457 489 }
458 490
459 491 if (kb_calculate_leds() == kb.led_commanded) {
460 492 kb.led_state = KB_LED_IDLE;
461 493 } else {
462 494 kb_send(KB_SET_LED);
463 495 kb.led_state = KB_LED_COMMAND_SENT;
464 496 }
465 497 }
466 498
467 499 #define MIMR_PORT 0x21 /* Mask register for master PIC */
468 500 #define MIMR_KB 2 /* Keyboard mask bit in master PIC */
469 501
470 502 void
471 503 kb_init(void)
472 504 {
473 505 /*
474 506 * Resist the urge to muck with the keyboard/mouse. Just assume
475 507 * that the bios, grub, and any optional hypervisor have left
476 508 * the keyboard in a sane and usable state. Messing with it now
477 509 * could result it making it unusuable, which would break early
478 510 * kmdb debugging support. Note that we don't actually need to
479 511 * disable interrupts for the keyboard/mouse since we're already
480 512 * in protected mode and we're not compeating with the bios for
481 513 * keyboard access. Also, we don't need to disable the mouse
482 514 * port since our polled input routine will just drop any mouse
483 515 * data that it recieves.
484 516 */
485 517 kb_update_leds();
486 518 }
487 519
488 520 unsigned char
489 521 kb_calculate_leds(void)
490 522 {
491 523 int res;
492 524
493 525 res = 0;
494 526
495 527 if (peek8(kb_flag) & BIOS_CAPS_STATE)
496 528 res |= KB_LED_CAPS_LOCK;
497 529
498 530 if (peek8(kb_flag) & BIOS_NUM_STATE)
499 531 res |= KB_LED_NUM_LOCK;
500 532
501 533 if (peek8(kb_flag) & BIOS_SCROLL_STATE)
502 534 res |= KB_LED_SCROLL_LOCK;
503 535
504 536 return ((char)res);
505 537 }
|
↓ open down ↓ |
327 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX