skiconsole.c revision 1.2 1 /* $NetBSD: skiconsole.c,v 1.2 2006/04/22 07:58:53 cherry Exp $ */
2
3 /*-
4 * Copyright (c) 2000 Doug Rabson
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29 #include <sys/cdefs.h>
30 /* __FBSDID("$FreeBSD: src/sys/boot/ia64/libski/skiconsole.c,v 1.2 2003/04/03 21:36:29 obrien Exp $"); */
31 #include <lib/libsa/stand.h>
32
33 #include "bootstrap.h"
34 #include "libski.h"
35
36 static void
37 ski_cons_probe(struct console *cp)
38 {
39 cp->c_flags |= C_PRESENTIN | C_PRESENTOUT;
40 }
41
42 static int
43 ski_cons_init(int arg)
44 {
45 ssc(0, 0, 0, 0, SSC_CONSOLE_INIT);
46 return 0;
47 }
48
49 void
50 ski_cons_putchar(int c)
51 {
52 ssc(c, 0, 0, 0, SSC_PUTCHAR);
53 }
54
55 static int pollchar = -1;
56
57 int
58 ski_cons_getchar()
59 {
60 int c;
61
62 if (pollchar > 0) {
63 c = pollchar;
64 pollchar = -1;
65 return c;
66 }
67
68 do {
69 c = ssc(0, 0, 0, 0, SSC_GETCHAR);
70 } while (c == 0);
71
72 return c;
73 }
74
75 int
76 ski_cons_poll()
77 {
78 int c;
79 if (pollchar > 0)
80 return 1;
81 c = ssc(0, 0, 0, 0, SSC_GETCHAR);
82 if (!c)
83 return 0;
84 pollchar = c;
85 return 1;
86 }
87
88 struct console ski_console = {
89 "ski",
90 "ia64 SKI console",
91 0,
92 ski_cons_probe,
93 ski_cons_init,
94 ski_cons_putchar,
95 ski_cons_getchar,
96 ski_cons_poll
97 };
98