Get rid of the #define mess for other platforms. We're just Unix.
[dragonfly.git] / sys / boot / arc / lib / arcconsole.c
1 /*
2  * $NetBSD: prom.c,v 1.3 1997/09/06 14:03:58 drochner Exp $
3  * $FreeBSD: src/sys/boot/arc/lib/arcconsole.c,v 1.2 1999/08/28 00:39:36 peter Exp $
4  * $DragonFly: src/sys/boot/arc/lib/Attic/arcconsole.c,v 1.3 2003/11/10 06:08:31 dillon Exp $
5  */
6
7 /*  
8  * Mach Operating System
9  * Copyright (c) 1992 Carnegie Mellon University
10  * All Rights Reserved.
11  * 
12  * Permission to use, copy, modify and distribute this software and its
13  * documentation is hereby granted, provided that both the copyright
14  * notice and this permission notice appear in all copies of the
15  * software, derivative works or modified versions, and any portions
16  * thereof, and that both notices appear in supporting documentation.
17  * 
18  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
19  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
20  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
21  * 
22  * Carnegie Mellon requests users of this software to return to
23  * 
24  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
25  *  School of Computer Science
26  *  Carnegie Mellon University
27  *  Pittsburgh PA 15213-3890
28  * 
29  * any improvements or extensions that they make and grant Carnegie Mellon
30  * the rights to redistribute these changes.
31  */
32
33 #include <sys/types.h>
34
35 #include "bootstrap.h"
36 #include "arctypes.h"
37 #include "arcfuncs.h"
38
39 int console;
40
41 static void arc_probe(struct console *cp);
42 static int arc_init(int);
43 static void arc_putchar(int);
44 static int arc_getchar(void);
45 static int arc_poll(void);
46
47 struct console arcconsole = {
48     "arc",
49     "ARC firmware console",
50     0,
51     arc_probe,
52     arc_init,
53     arc_putchar,
54     arc_getchar,
55     arc_poll,
56 };
57
58 static void
59 arc_probe(struct console *cp)
60 {
61     cp->c_flags |= C_PRESENTIN|C_PRESENTOUT;
62 }
63
64 static int
65 arc_init(int arg)
66 {
67     return 0;
68 }
69
70 static void
71 arc_putchar(int c)
72 {
73     char cbuf = c;
74     u_int32_t count;
75
76     Write(StandardOut, &cbuf, 1, &count);
77 }
78
79 static int saved_char = -1;
80
81 int
82 arc_getchar()
83 {
84     char cbuf;
85     u_int32_t count;
86
87     arc_putchar('_');
88     arc_putchar('\b');
89     Read(StandardIn, &cbuf, 1, &count);
90     arc_putchar(' ');
91     arc_putchar('\b');
92     if (count == 1)
93         return cbuf;
94     else
95         return -1;
96 }
97
98 int
99 arc_poll()
100 {
101     return GetReadStatus(StandardIn) == ESUCCESS;
102 }
103
104 int
105 arc_open(dev, len)
106     char *dev;
107     int len;
108 {
109     return 0;
110 }