2 * $NetBSD: prom.c,v 1.3 1997/09/06 14:03:58 drochner Exp $
3 * $FreeBSD: src/sys/boot/alpha/libalpha/prom.c,v 1.3 1999/08/28 00:39:28 peter Exp $
4 * $DragonFly: src/sys/boot/alpha/libalpha/Attic/prom.c,v 1.3 2003/11/10 06:08:30 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 <machine/prom.h>
36 #include <machine/rpb.h>
39 #include "bootstrap.h"
43 static void prom_probe(struct console *cp);
44 static int prom_init(int);
45 void prom_putchar(int);
46 int prom_getchar(void);
49 struct console promconsole = {
51 "SRM firmware console",
63 extern struct prom_vec prom_dispatch_v;
68 r = (struct rpb *)HWRPB_ADDR;
69 c = (struct crb *)((u_int8_t *)r + r->rpb_crb_off);
71 prom_dispatch_v.routine_arg = c->crb_v_dispatch;
72 prom_dispatch_v.routine = c->crb_v_dispatch->entry_va;
74 /* Look for console tty. */
75 prom_getenv(PROM_E_TTY_DEV, buf, 4);
76 console = buf[0] - '0';
80 prom_probe(struct console *cp)
83 cp->c_flags |= C_PRESENTIN|C_PRESENTOUT;
100 ret.bits = prom_dispatch(PROM_R_PUTS, console, &cbuf, 1);
101 } while ((ret.u.retval & 1) == 0);
104 static int saved_char = -1;
111 if (saved_char != -1) {
118 ret.bits = prom_dispatch(PROM_R_GETC, console);
119 if (ret.u.status == 0 || ret.u.status == 1)
120 return (ret.u.retval);
129 if (saved_char != -1)
132 ret.bits = prom_dispatch(PROM_R_GETC, console);
133 if (ret.u.status == 0 || ret.u.status == 1) {
134 saved_char = ret.u.retval;
142 prom_getenv(id, buf, len)
148 ret.bits = prom_dispatch(PROM_R_GETENV, id, buf, len-1);
149 if (ret.u.status & 0x4)
151 buf[ret.u.retval] = '\0';
153 return (ret.u.retval);
163 ret.bits = prom_dispatch(PROM_R_OPEN, dev, len);
164 if (ret.u.status & 0x4)
167 return (ret.u.retval);