1 /* 2 * Copyright (c) 1992 OMRON Corporation. 3 * Copyright (c) 1992, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * OMRON Corporation. 8 * 9 * %sccs.include.redist.c% 10 * 11 * @(#)cons.c 8.1 (Berkeley) 06/10/93 12 */ 13 14 #include <sys/param.h> 15 #include <sys/systm.h> 16 #include <sys/buf.h> 17 #include <sys/ioctl.h> 18 #include <sys/tty.h> 19 #include <sys/file.h> 20 #include <sys/conf.h> 21 #include <luna68k/luna68k/cons.h> 22 23 #define NBMC 1 24 #define NSIO 1 25 #define NROM 1 26 27 /* XXX - all this could be autoconfig()ed */ 28 #include "romvec.h" 29 #if NBMC > 0 30 int bmccnprobe(), bmccninit(), bmccngetc(), bmccnputc(); 31 #endif 32 #if NSIO > 0 33 int siocnprobe(), siocninit(), siocngetc(), siocnputc(); 34 #endif 35 #if NROM > 0 36 int romcnprobe(), romcninit(), romcngetc(), romcnputc(); 37 #endif 38 39 struct consdev constab[] = { 40 #if NBMC > 0 41 { bmccnprobe, bmccninit, bmccngetc, bmccnputc }, 42 #endif 43 #if NSIO > 0 44 { siocnprobe, siocninit, siocngetc, siocnputc }, 45 #endif 46 #if NROM > 0 47 { romcnprobe, romcninit, romcngetc, romcnputc }, 48 #endif 49 { 0 }, 50 }; 51 /* end XXX */ 52 53 struct tty *constty = 0; /* virtual console output device */ 54 struct consdev *cn_tab; /* physical console device info */ 55 struct tty *cn_tty; /* XXX: console tty struct for tprintf */ 56 57 cninit() 58 { 59 register struct consdev *cp; 60 61 /* 62 * Collect information about all possible consoles 63 * and find the one with highest priority 64 */ 65 for (cp = constab; cp->cn_probe; cp++) { 66 (*cp->cn_probe)(cp); 67 if (cp->cn_pri > CN_DEAD && 68 (cn_tab == NULL || cp->cn_pri > cn_tab->cn_pri)) 69 cn_tab = cp; 70 } 71 /* 72 * No console, we can handle it 73 */ 74 if ((cp = cn_tab) == NULL) 75 return; 76 /* 77 * Turn on console 78 */ 79 cn_tty = cp->cn_tp; 80 (*cp->cn_init)(cp); 81 } 82 83 cngetc() 84 { 85 if (cn_tab == NULL) 86 return(0); 87 return((*cn_tab->cn_getc)(cn_tab->cn_dev)); 88 } 89 90 cnputc(c) 91 register int c; 92 { 93 if (cn_tab == NULL) 94 return; 95 if (c) { 96 (*cn_tab->cn_putc)(cn_tab->cn_dev, c); 97 if (c == '\n') 98 (*cn_tab->cn_putc)(cn_tab->cn_dev, '\r'); 99 } 100 } 101