xref: /original-bsd/sys/hp300/stand/cons.c (revision e0c0d005)
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.3 (Berkeley) 12/16/90
15  */
16 
17 #include "sys/param.h"
18 #include "samachdep.h"
19 #include "../hp300/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 #ifdef DCMCONSOLE
29 int	dcmprobe(), dcminit(), dcmgetchar(), dcmputchar();
30 #endif
31 
32 struct consdev constab[] = {
33 #ifdef ITECONSOLE
34 	{ iteprobe,	iteinit,	itegetchar,	iteputchar },
35 #endif
36 #ifdef DCACONSOLE
37 	{ dcaprobe,	dcainit,	dcagetchar,	dcaputchar },
38 #endif
39 #ifdef DCMCONSOLE
40 	{ dcmprobe,	dcminit,	dcmgetchar,	dcmputchar },
41 #endif
42 	{ 0 },
43 };
44 
45 struct consdev *cn_tab;
46 int noconsole;
47 
48 cninit()
49 {
50 	register struct consdev *cp;
51 
52 	cn_tab = NULL;
53 	noconsole = 1;
54 	for (cp = constab; cp->cn_probe; cp++) {
55 		(*cp->cn_probe)(cp);
56 		if (cp->cn_pri > CN_DEAD &&
57 		    (cn_tab == NULL || cp->cn_pri > cn_tab->cn_pri))
58 			cn_tab = cp;
59 	}
60 	if (cn_tab) {
61 		(*cn_tab->cn_init)(cn_tab);
62 		noconsole = 0;
63 	}
64 }
65 
66 cngetc()
67 {
68 	if (cn_tab)
69 		return((*cn_tab->cn_getc)());
70 	return(0);
71 }
72 
73 cnputc(c)
74 	int c;
75 {
76 	if (cn_tab)
77 		(*cn_tab->cn_putc)(c);
78 }
79