1 /* $FreeBSD: src/sys/boot/alpha/libalpha/prom.c,v 1.3 1999/08/28 00:39:28 peter Exp $ */
2 /* $DragonFly: src/sys/boot/alpha/libalpha/Attic/prom.c,v 1.2 2003/06/17 04:28:16 dillon Exp $ */
3 /* $NetBSD: prom.c,v 1.3 1997/09/06 14:03:58 drochner Exp $ */
6 * Mach Operating System
7 * Copyright (c) 1992 Carnegie Mellon University
10 * Permission to use, copy, modify and distribute this software and its
11 * documentation is hereby granted, provided that both the copyright
12 * notice and this permission notice appear in all copies of the
13 * software, derivative works or modified versions, and any portions
14 * thereof, and that both notices appear in supporting documentation.
16 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
17 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
18 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
20 * Carnegie Mellon requests users of this software to return to
22 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
23 * School of Computer Science
24 * Carnegie Mellon University
25 * Pittsburgh PA 15213-3890
27 * any improvements or extensions that they make and grant Carnegie Mellon
28 * the rights to redistribute these changes.
31 #include <sys/types.h>
33 #include <machine/prom.h>
34 #include <machine/rpb.h>
37 #include "bootstrap.h"
41 static void prom_probe(struct console *cp);
42 static int prom_init(int);
43 void prom_putchar(int);
44 int prom_getchar(void);
47 struct console promconsole = {
49 "SRM firmware console",
61 extern struct prom_vec prom_dispatch_v;
66 r = (struct rpb *)HWRPB_ADDR;
67 c = (struct crb *)((u_int8_t *)r + r->rpb_crb_off);
69 prom_dispatch_v.routine_arg = c->crb_v_dispatch;
70 prom_dispatch_v.routine = c->crb_v_dispatch->entry_va;
72 /* Look for console tty. */
73 prom_getenv(PROM_E_TTY_DEV, buf, 4);
74 console = buf[0] - '0';
78 prom_probe(struct console *cp)
81 cp->c_flags |= C_PRESENTIN|C_PRESENTOUT;
98 ret.bits = prom_dispatch(PROM_R_PUTS, console, &cbuf, 1);
99 } while ((ret.u.retval & 1) == 0);
102 static int saved_char = -1;
109 if (saved_char != -1) {
116 ret.bits = prom_dispatch(PROM_R_GETC, console);
117 if (ret.u.status == 0 || ret.u.status == 1)
118 return (ret.u.retval);
127 if (saved_char != -1)
130 ret.bits = prom_dispatch(PROM_R_GETC, console);
131 if (ret.u.status == 0 || ret.u.status == 1) {
132 saved_char = ret.u.retval;
140 prom_getenv(id, buf, len)
146 ret.bits = prom_dispatch(PROM_R_GETENV, id, buf, len-1);
147 if (ret.u.status & 0x4)
149 buf[ret.u.retval] = '\0';
151 return (ret.u.retval);
161 ret.bits = prom_dispatch(PROM_R_OPEN, dev, len);
162 if (ret.u.status & 0x4)
165 return (ret.u.retval);