xref: /original-bsd/sys/hp300/stand/cons.c (revision da818fbb)
1 /*
2  * Copyright (c) 1988 University of Utah.
3  * Copyright (c) 1990 The Regents of the University of California.
4  * All rights reserved.
5  *
6  * This code is derived from software contributed to Berkeley by
7  * the Systems Programming Group of the University of Utah Computer
8  * Science Department.
9  *
10  * %sccs.include.redist.c%
11  *
12  * from: Utah $Hdr: cons.c 1.5 89/08/22$
13  *
14  *	@(#)cons.c	7.1 (Berkeley) 05/08/90
15  */
16 
17 #include "param.h"
18 #include "samachdep.h"
19 #include "machine/cons.h"
20 
21 int	nodev();
22 #ifdef ITECONSOLE
23 int	iteprobe(), iteinit(), itegetchar(), iteputchar();
24 #endif
25 #ifdef DCACONSOLE
26 int	dcaprobe(), dcainit(), dcagetchar(), dcaputchar();
27 #endif
28 
29 struct consdev constab[] = {
30 #ifdef ITECONSOLE
31 	{ iteprobe,	iteinit,	itegetchar,	iteputchar },
32 #endif
33 #ifdef DCACONSOLE
34 	{ dcaprobe,	dcainit,	dcagetchar,	dcaputchar },
35 #endif
36 	{ 0 },
37 };
38 
39 struct consdev *cn_tab;
40 int noconsole;
41 
42 cninit()
43 {
44 	register struct consdev *cp;
45 
46 	cn_tab = NULL;
47 	noconsole = 1;
48 	for (cp = constab; cp->cn_probe; cp++) {
49 		(*cp->cn_probe)(cp);
50 		if (cp->cn_pri > CN_DEAD &&
51 		    (cn_tab == NULL || cp->cn_pri > cn_tab->cn_pri))
52 			cn_tab = cp;
53 	}
54 	if (cn_tab) {
55 		(*cn_tab->cn_init)(cn_tab);
56 		noconsole = 0;
57 	}
58 }
59 
60 cngetc()
61 {
62 	if (cn_tab)
63 		return((*cn_tab->cn_getc)());
64 	return(0);
65 }
66 
67 cnputc(c)
68 	int c;
69 {
70 	if (cn_tab)
71 		(*cn_tab->cn_putc)(c);
72 }
73