1 /* $NetBSD: prom.c,v 1.3 1997/09/06 14:03:58 drochner Exp $ */
4 * Mach Operating System
5 * Copyright (c) 1992 Carnegie Mellon University
8 * Permission to use, copy, modify and distribute this software and its
9 * documentation is hereby granted, provided that both the copyright
10 * notice and this permission notice appear in all copies of the
11 * software, derivative works or modified versions, and any portions
12 * thereof, and that both notices appear in supporting documentation.
14 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
15 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
16 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18 * Carnegie Mellon requests users of this software to return to
20 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
21 * School of Computer Science
22 * Carnegie Mellon University
23 * Pittsburgh PA 15213-3890
25 * any improvements or extensions that they make and grant Carnegie Mellon
26 * the rights to redistribute these changes.
29 #include <sys/cdefs.h>
30 #include <sys/types.h>
32 #include "bootstrap.h"
35 static void ofw_cons_probe(struct console *cp);
36 static int ofw_cons_init(int);
37 void ofw_cons_putchar(int);
38 int ofw_cons_getchar(void);
39 int ofw_cons_poll(void);
41 static ihandle_t stdin;
42 static ihandle_t stdout;
44 struct console ofwconsole = {
46 "Open Firmware console",
56 ofw_cons_probe(struct console *cp)
59 OF_getprop(chosen, "stdin", &stdin, sizeof(stdin));
60 OF_getprop(chosen, "stdout", &stdout, sizeof(stdout));
61 cp->c_flags |= C_PRESENTIN|C_PRESENTOUT;
65 ofw_cons_init(int arg)
71 ofw_cons_putchar(int c)
77 OF_write(stdout, &cbuf, 1);
81 OF_write(stdout, &cbuf, 1);
84 static int saved_char = -1;
89 unsigned char ch = '\0';
92 if (saved_char != -1) {
98 /* At least since version 4.0.0, QEMU became bug-compatible
99 * with PowerVM's vty, by inserting a \0 after every \r.
100 * As this confuses loader's interpreter and as a \0 coming
101 * from the console doesn't seem reasonable, it's filtered here. */
102 if (OF_read(stdin, &ch, 1) > 0 && ch != '\0')
113 if (saved_char != -1)
116 if (OF_read(stdin, &ch, 1) > 0) {