1 1.7 rmind /* $NetBSD: cons.c,v 1.7 2011/02/08 20:20:14 rmind Exp $ */ 2 1.1 thorpej 3 1.1 thorpej /* 4 1.7 rmind * Copyright (c) 1988 University of Utah. 5 1.1 thorpej * Copyright (c) 1990, 1993 6 1.1 thorpej * The Regents of the University of California. All rights reserved. 7 1.3 agc * 8 1.3 agc * This code is derived from software contributed to Berkeley by 9 1.3 agc * the Systems Programming Group of the University of Utah Computer 10 1.3 agc * Science Department. 11 1.3 agc * 12 1.3 agc * Redistribution and use in source and binary forms, with or without 13 1.3 agc * modification, are permitted provided that the following conditions 14 1.3 agc * are met: 15 1.3 agc * 1. Redistributions of source code must retain the above copyright 16 1.3 agc * notice, this list of conditions and the following disclaimer. 17 1.3 agc * 2. Redistributions in binary form must reproduce the above copyright 18 1.3 agc * notice, this list of conditions and the following disclaimer in the 19 1.3 agc * documentation and/or other materials provided with the distribution. 20 1.3 agc * 3. Neither the name of the University nor the names of its contributors 21 1.3 agc * may be used to endorse or promote products derived from this software 22 1.3 agc * without specific prior written permission. 23 1.3 agc * 24 1.3 agc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25 1.3 agc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 1.3 agc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 1.3 agc * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28 1.3 agc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 1.3 agc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 1.3 agc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 1.3 agc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 1.3 agc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 1.3 agc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 1.3 agc * SUCH DAMAGE. 35 1.3 agc * 36 1.3 agc * from: Utah Hdr: cons.c 1.7 92/02/28 37 1.3 agc * 38 1.3 agc * @(#)cons.c 8.1 (Berkeley) 6/10/93 39 1.3 agc */ 40 1.1 thorpej 41 1.1 thorpej #include <sys/param.h> 42 1.1 thorpej #include <dev/cons.h> 43 1.1 thorpej 44 1.1 thorpej #include <hp300/stand/common/consdefs.h> 45 1.1 thorpej #include <hp300/stand/common/samachdep.h> 46 1.1 thorpej 47 1.1 thorpej struct consdev constab[] = { 48 1.1 thorpej #ifdef ITECONSOLE 49 1.1 thorpej { iteprobe, iteinit, itegetchar, iteputchar }, 50 1.1 thorpej #endif 51 1.1 thorpej #ifdef DCACONSOLE 52 1.1 thorpej { dcaprobe, dcainit, dcagetchar, dcaputchar }, 53 1.1 thorpej #endif 54 1.2 thorpej #ifdef APCICONSOLE 55 1.2 thorpej { apciprobe, apciinit, apcigetchar, apciputchar }, 56 1.2 thorpej #endif 57 1.1 thorpej #ifdef DCMCONSOLE 58 1.1 thorpej { dcmprobe, dcminit, dcmgetchar, dcmputchar }, 59 1.1 thorpej #endif 60 1.1 thorpej { 0 }, 61 1.1 thorpej }; 62 1.1 thorpej 63 1.1 thorpej int curcons_scode; /* select code of device currently being probed */ 64 1.1 thorpej int cons_scode; /* final select code of console device */ 65 1.1 thorpej 66 1.1 thorpej struct consdev *cn_tab; 67 1.1 thorpej int noconsole; 68 1.1 thorpej 69 1.1 thorpej void 70 1.5 tsutsui cninit(void) 71 1.1 thorpej { 72 1.4 tsutsui struct consdev *cp; 73 1.1 thorpej 74 1.1 thorpej cn_tab = NULL; 75 1.1 thorpej noconsole = 1; 76 1.1 thorpej cons_scode = 256; /* larger than last valid select code */ 77 1.1 thorpej for (cp = constab; cp->cn_probe; cp++) { 78 1.1 thorpej (*cp->cn_probe)(cp); 79 1.1 thorpej if (cp->cn_pri > CN_DEAD && 80 1.1 thorpej (cn_tab == NULL || cp->cn_pri > cn_tab->cn_pri)) { 81 1.1 thorpej cn_tab = cp; 82 1.1 thorpej cons_scode = curcons_scode; 83 1.1 thorpej } 84 1.1 thorpej } 85 1.1 thorpej if (cn_tab) { 86 1.1 thorpej (*cn_tab->cn_init)(cn_tab); 87 1.1 thorpej noconsole = 0; 88 1.1 thorpej #if 0 89 1.1 thorpej printf("console: "); 90 1.2 thorpej switch (cons_scode) { 91 1.2 thorpej case -2: 92 1.2 thorpej printf("apci\n"); 93 1.2 thorpej break; 94 1.2 thorpej case -1: 95 1.1 thorpej printf("internal grf\n"); 96 1.2 thorpej break; 97 1.2 thorpej default: 98 1.1 thorpej printf("scode %d\n", cons_scode); 99 1.2 thorpej } 100 1.1 thorpej #endif 101 1.1 thorpej } 102 1.1 thorpej } 103 1.1 thorpej 104 1.1 thorpej int 105 1.5 tsutsui cngetc(void) 106 1.1 thorpej { 107 1.1 thorpej 108 1.1 thorpej /* Note: the dev_t arguments are not used! */ 109 1.1 thorpej if (cn_tab) 110 1.4 tsutsui return (*cn_tab->cn_getc)(0); 111 1.4 tsutsui return 0; 112 1.1 thorpej } 113 1.1 thorpej 114 1.1 thorpej int 115 1.5 tsutsui cnputc(int c) 116 1.1 thorpej { 117 1.1 thorpej 118 1.1 thorpej /* Note: the dev_t arguments are not used! */ 119 1.1 thorpej if (userom) 120 1.1 thorpej romputchar(c); 121 1.2 thorpej else if (cn_tab) 122 1.1 thorpej (*cn_tab->cn_putc)(0, c); 123 1.1 thorpej 124 1.4 tsutsui return 0; 125 1.1 thorpej } 126