2 * $NetBSD: prom.c,v 1.3 1997/09/06 14:03:58 drochner Exp $
3 * $FreeBSD: src/sys/boot/ofw/libofw/ofw_console.c,v 1.7 2002/02/23 04:33:15 jake Exp $
4 * $DragonFly: src/sys/boot/ofw/libofw/ofw_console.c,v 1.1 2003/11/10 06:08:37 dillon Exp $
8 * Mach Operating System
9 * Copyright (c) 1992 Carnegie Mellon University
10 * All Rights Reserved.
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.
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.
22 * Carnegie Mellon requests users of this software to return to
24 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
25 * School of Computer Science
26 * Carnegie Mellon University
27 * Pittsburgh PA 15213-3890
29 * any improvements or extensions that they make and grant Carnegie Mellon
30 * the rights to redistribute these changes.
33 #include <sys/types.h>
35 #include "bootstrap.h"
40 static void ofw_cons_probe(struct console
*cp
);
41 static int ofw_cons_init(int);
42 void ofw_cons_putchar(int);
43 int ofw_cons_getchar(void);
44 int ofw_cons_poll(void);
46 static ihandle_t stdin
;
47 static ihandle_t stdout
;
49 struct console ofwconsole
= {
51 "OpenFirmware console",
61 ofw_cons_probe(struct console
*cp
)
65 if ((chosen
= OF_finddevice("/chosen")) == -1)
67 OF_getprop(chosen
, "stdin", &stdin
, sizeof(stdin
));
68 OF_getprop(chosen
, "stdout", &stdout
, sizeof(stdout
));
69 cp
->c_flags
|= C_PRESENTIN
|C_PRESENTOUT
;
73 ofw_cons_init(int arg
)
79 ofw_cons_putchar(int c
)
85 OF_write(stdout
, &cbuf
, 1);
89 OF_write(stdout
, &cbuf
, 1);
92 static int saved_char
= -1;
97 unsigned char ch
= '\0';
100 if (saved_char
!= -1) {
106 while ((l
= OF_read(stdin
, &ch
, 1)) != 1)
107 if (l
!= -2 && l
!= 0)
118 if (saved_char
!= -1)
121 if (OF_read(stdin
, &ch
, 1) > 0) {