xref: /csrg-svn/sys/luna68k/stand/cons.c (revision 63199)
157082Sakito /*
257082Sakito  * Copyright (c) 1992 OMRON Corporation.
3*63199Sbostic  * Copyright (c) 1992, 1993
4*63199Sbostic  *	The Regents of the University of California.  All rights reserved.
557082Sakito  *
657082Sakito  * This code is derived from software contributed to Berkeley by
757082Sakito  * OMRON Corporation.
857082Sakito  *
957082Sakito  * %sccs.include.redist.c%
1057082Sakito  *
11*63199Sbostic  *	@(#)cons.c	8.1 (Berkeley) 06/10/93
1257082Sakito  */
1357082Sakito 
1457082Sakito #include <sys/param.h>
1557082Sakito #include <sys/systm.h>
1657082Sakito #include <sys/buf.h>
1757082Sakito #include <sys/ioctl.h>
1857082Sakito #include <sys/tty.h>
1957082Sakito #include <sys/file.h>
2057082Sakito #include <sys/conf.h>
2157082Sakito #include <luna68k/luna68k/cons.h>
2257082Sakito 
2357082Sakito #define NBMC	1
2457082Sakito #define	NSIO	1
2557082Sakito #define	NROM	1
2657082Sakito 
2757082Sakito /* XXX - all this could be autoconfig()ed */
2857082Sakito #include "romvec.h"
2957082Sakito #if NBMC > 0
3057082Sakito int bmccnprobe(), bmccninit(), bmccngetc(), bmccnputc();
3157082Sakito #endif
3257082Sakito #if NSIO > 0
3357082Sakito int siocnprobe(), siocninit(), siocngetc(), siocnputc();
3457082Sakito #endif
3557082Sakito #if NROM > 0
3657082Sakito int romcnprobe(), romcninit(), romcngetc(), romcnputc();
3757082Sakito #endif
3857082Sakito 
3957082Sakito struct	consdev constab[] = {
4057082Sakito #if NBMC > 0
4157082Sakito 	{ bmccnprobe,	bmccninit,	bmccngetc,	bmccnputc },
4257082Sakito #endif
4357082Sakito #if NSIO > 0
4457082Sakito 	{ siocnprobe,	siocninit,	siocngetc,	siocnputc },
4557082Sakito #endif
4657082Sakito #if NROM > 0
4757082Sakito 	{ romcnprobe,	romcninit,	romcngetc,	romcnputc },
4857082Sakito #endif
4957082Sakito 	{ 0 },
5057082Sakito };
5157082Sakito /* end XXX */
5257082Sakito 
5357082Sakito struct	tty *constty = 0;	/* virtual console output device */
5457082Sakito struct	consdev *cn_tab;	/* physical console device info */
5557082Sakito struct	tty *cn_tty;		/* XXX: console tty struct for tprintf */
5657082Sakito 
cninit()5757082Sakito cninit()
5857082Sakito {
5957082Sakito 	register struct consdev *cp;
6057082Sakito 
6157082Sakito 	/*
6257082Sakito 	 * Collect information about all possible consoles
6357082Sakito 	 * and find the one with highest priority
6457082Sakito 	 */
6557082Sakito 	for (cp = constab; cp->cn_probe; cp++) {
6657082Sakito 		(*cp->cn_probe)(cp);
6757082Sakito 		if (cp->cn_pri > CN_DEAD &&
6857082Sakito 		    (cn_tab == NULL || cp->cn_pri > cn_tab->cn_pri))
6957082Sakito 			cn_tab = cp;
7057082Sakito 	}
7157082Sakito 	/*
7257082Sakito 	 * No console, we can handle it
7357082Sakito 	 */
7457082Sakito 	if ((cp = cn_tab) == NULL)
7557082Sakito 		return;
7657082Sakito 	/*
7757082Sakito 	 * Turn on console
7857082Sakito 	 */
7957082Sakito 	cn_tty = cp->cn_tp;
8057082Sakito 	(*cp->cn_init)(cp);
8157082Sakito }
8257082Sakito 
cngetc()8357082Sakito cngetc()
8457082Sakito {
8557082Sakito 	if (cn_tab == NULL)
8657082Sakito 		return(0);
8757082Sakito 	return((*cn_tab->cn_getc)(cn_tab->cn_dev));
8857082Sakito }
8957082Sakito 
cnputc(c)9057082Sakito cnputc(c)
9157082Sakito 	register int c;
9257082Sakito {
9357082Sakito 	if (cn_tab == NULL)
9457082Sakito 		return;
9557082Sakito 	if (c) {
9657082Sakito 		(*cn_tab->cn_putc)(cn_tab->cn_dev, c);
9757082Sakito 		if (c == '\n')
9857082Sakito 			(*cn_tab->cn_putc)(cn_tab->cn_dev, '\r');
9957082Sakito 	}
10057082Sakito }
101