xref: /netbsd-src/sys/arch/hp300/stand/common/kbd.c (revision ce099b40997c43048fb78bd578195f81d2456523)
1*ce099b40Smartin /*	$NetBSD: kbd.c,v 1.7 2008/04/28 20:23:19 martin Exp $	*/
2f9cbf4e4Sthorpej 
3f9cbf4e4Sthorpej /*-
4f9cbf4e4Sthorpej  * Copyright (c) 1997 The NetBSD Foundation, Inc.
5f9cbf4e4Sthorpej  * All rights reserved.
6f9cbf4e4Sthorpej  *
7f9cbf4e4Sthorpej  * This code is derived from software contributed to The NetBSD Foundation
8f9cbf4e4Sthorpej  * by Jason R. Thorpe.
9f9cbf4e4Sthorpej  *
10f9cbf4e4Sthorpej  * Redistribution and use in source and binary forms, with or without
11f9cbf4e4Sthorpej  * modification, are permitted provided that the following conditions
12f9cbf4e4Sthorpej  * are met:
13f9cbf4e4Sthorpej  * 1. Redistributions of source code must retain the above copyright
14f9cbf4e4Sthorpej  *    notice, this list of conditions and the following disclaimer.
15f9cbf4e4Sthorpej  * 2. Redistributions in binary form must reproduce the above copyright
16f9cbf4e4Sthorpej  *    notice, this list of conditions and the following disclaimer in the
17f9cbf4e4Sthorpej  *    documentation and/or other materials provided with the distribution.
18f9cbf4e4Sthorpej  *
19f9cbf4e4Sthorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20f9cbf4e4Sthorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21f9cbf4e4Sthorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
221bcecdd6Sjtc  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
231bcecdd6Sjtc  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24f9cbf4e4Sthorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25f9cbf4e4Sthorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26f9cbf4e4Sthorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27f9cbf4e4Sthorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28f9cbf4e4Sthorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29f9cbf4e4Sthorpej  * POSSIBILITY OF SUCH DAMAGE.
30f9cbf4e4Sthorpej  */
31f9cbf4e4Sthorpej 
32f9cbf4e4Sthorpej /*
33f9cbf4e4Sthorpej  * Indirect keyboard driver for standalone ITE.
34f9cbf4e4Sthorpej  */
35f9cbf4e4Sthorpej 
36f9cbf4e4Sthorpej #ifdef ITECONSOLE
37f9cbf4e4Sthorpej 
38f9cbf4e4Sthorpej #include <sys/param.h>
39f9cbf4e4Sthorpej 
40212f884fStsutsui #include <lib/libsa/stand.h>
41212f884fStsutsui 
42f9cbf4e4Sthorpej #include <hp300/stand/common/samachdep.h>
43f9cbf4e4Sthorpej #include <hp300/stand/common/kbdvar.h>
44f9cbf4e4Sthorpej 
45f9cbf4e4Sthorpej #ifndef SMALL
46f9cbf4e4Sthorpej 
47f9cbf4e4Sthorpej /*
48f9cbf4e4Sthorpej  * Function switch initialized by keyboard drivers.
49f9cbf4e4Sthorpej  */
50f9cbf4e4Sthorpej struct kbdsw *selected_kbd;
51f9cbf4e4Sthorpej 
52f9cbf4e4Sthorpej int
kbdgetc(void)53d3dc0553Stsutsui kbdgetc(void)
54f9cbf4e4Sthorpej {
55f9cbf4e4Sthorpej 
56212f884fStsutsui 	return (selected_kbd != NULL) ? (*selected_kbd->k_getc)() : 0;
57f9cbf4e4Sthorpej }
58f9cbf4e4Sthorpej 
59f9cbf4e4Sthorpej void
kbdnmi(void)60d3dc0553Stsutsui kbdnmi(void)
61f9cbf4e4Sthorpej {
62f9cbf4e4Sthorpej 
63f9cbf4e4Sthorpej 	if (selected_kbd != NULL)
64f9cbf4e4Sthorpej 		(*selected_kbd->k_nmi)();
65eac0352aSthorpej 
66eac0352aSthorpej 	/*
67eac0352aSthorpej 	 * This is the only reasonable thing to do, unfortunately.
68eac0352aSthorpej 	 * Simply restarting the boot block by frobbing the stack and
69eac0352aSthorpej 	 * jumping to begin: doesn't properly reset variables that
70eac0352aSthorpej 	 * are in the data segment.
71eac0352aSthorpej 	 */
72eac0352aSthorpej 	printf("\nboot interrupted, resetting...\n");
73eac0352aSthorpej 	DELAY(1000000);
74eac0352aSthorpej 	call_req_reboot();
75f9cbf4e4Sthorpej }
76f9cbf4e4Sthorpej 
77f9cbf4e4Sthorpej void
kbdinit(void)78d3dc0553Stsutsui kbdinit(void)
79f9cbf4e4Sthorpej {
80f9cbf4e4Sthorpej 	int i;
81f9cbf4e4Sthorpej 
82f9cbf4e4Sthorpej 	selected_kbd = NULL;
83f9cbf4e4Sthorpej 
84f9cbf4e4Sthorpej 	for (i = 0; kbdsw[i].k_init != NULL; i++) {
85f9cbf4e4Sthorpej 		if ((*kbdsw[i].k_init)()) {
86f9cbf4e4Sthorpej 			selected_kbd = &kbdsw[i];
87f9cbf4e4Sthorpej 			return;
88f9cbf4e4Sthorpej 		}
89f9cbf4e4Sthorpej 	}
90f9cbf4e4Sthorpej }
91f9cbf4e4Sthorpej 
92f9cbf4e4Sthorpej #endif /* SMALL */
93f9cbf4e4Sthorpej 
94f9cbf4e4Sthorpej #endif /* ITECONSOLE */
95