Home | History | Annotate | Line # | Download | only in dev
cninit.c revision 1.4.16.2
      1  1.4.16.1   skrll /*	$NetBSD: cninit.c,v 1.4.16.2 2004/09/18 14:44:28 skrll Exp $	*/
      2       1.1  mellon 
      3       1.1  mellon /*
      4       1.1  mellon  * Copyright (c) 1990, 1993
      5       1.1  mellon  *	The Regents of the University of California.  All rights reserved.
      6       1.1  mellon  *
      7       1.1  mellon  * This code is derived from software contributed to Berkeley by
      8       1.1  mellon  * the Systems Programming Group of the University of Utah Computer
      9       1.1  mellon  * Science Department.
     10       1.1  mellon  *
     11       1.1  mellon  * Redistribution and use in source and binary forms, with or without
     12       1.1  mellon  * modification, are permitted provided that the following conditions
     13       1.1  mellon  * are met:
     14       1.1  mellon  * 1. Redistributions of source code must retain the above copyright
     15       1.1  mellon  *    notice, this list of conditions and the following disclaimer.
     16       1.1  mellon  * 2. Redistributions in binary form must reproduce the above copyright
     17       1.1  mellon  *    notice, this list of conditions and the following disclaimer in the
     18       1.1  mellon  *    documentation and/or other materials provided with the distribution.
     19  1.4.16.1   skrll  * 3. Neither the name of the University nor the names of its contributors
     20  1.4.16.1   skrll  *    may be used to endorse or promote products derived from this software
     21  1.4.16.1   skrll  *    without specific prior written permission.
     22  1.4.16.1   skrll  *
     23  1.4.16.1   skrll  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24  1.4.16.1   skrll  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25  1.4.16.1   skrll  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26  1.4.16.1   skrll  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27  1.4.16.1   skrll  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28  1.4.16.1   skrll  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29  1.4.16.1   skrll  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  1.4.16.1   skrll  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  1.4.16.1   skrll  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  1.4.16.1   skrll  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  1.4.16.1   skrll  * SUCH DAMAGE.
     34  1.4.16.1   skrll  *
     35  1.4.16.1   skrll  * from: Utah $Hdr: cons.c 1.7 92/01/21$
     36  1.4.16.1   skrll  *
     37  1.4.16.1   skrll  *	@(#)cons.c	8.2 (Berkeley) 1/12/94
     38  1.4.16.1   skrll  */
     39  1.4.16.1   skrll 
     40  1.4.16.1   skrll /*
     41  1.4.16.1   skrll  * Copyright (c) 1988 University of Utah.
     42  1.4.16.1   skrll  *
     43  1.4.16.1   skrll  * This code is derived from software contributed to Berkeley by
     44  1.4.16.1   skrll  * the Systems Programming Group of the University of Utah Computer
     45  1.4.16.1   skrll  * Science Department.
     46  1.4.16.1   skrll  *
     47  1.4.16.1   skrll  * Redistribution and use in source and binary forms, with or without
     48  1.4.16.1   skrll  * modification, are permitted provided that the following conditions
     49  1.4.16.1   skrll  * are met:
     50  1.4.16.1   skrll  * 1. Redistributions of source code must retain the above copyright
     51  1.4.16.1   skrll  *    notice, this list of conditions and the following disclaimer.
     52  1.4.16.1   skrll  * 2. Redistributions in binary form must reproduce the above copyright
     53  1.4.16.1   skrll  *    notice, this list of conditions and the following disclaimer in the
     54  1.4.16.1   skrll  *    documentation and/or other materials provided with the distribution.
     55       1.1  mellon  * 3. All advertising materials mentioning features or use of this software
     56       1.1  mellon  *    must display the following acknowledgement:
     57       1.1  mellon  *	This product includes software developed by the University of
     58       1.1  mellon  *	California, Berkeley and its contributors.
     59       1.1  mellon  * 4. Neither the name of the University nor the names of its contributors
     60       1.1  mellon  *    may be used to endorse or promote products derived from this software
     61       1.1  mellon  *    without specific prior written permission.
     62       1.1  mellon  *
     63       1.1  mellon  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     64       1.1  mellon  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     65       1.1  mellon  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     66       1.1  mellon  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     67       1.1  mellon  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     68       1.1  mellon  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     69       1.1  mellon  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     70       1.1  mellon  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     71       1.1  mellon  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     72       1.1  mellon  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     73       1.1  mellon  * SUCH DAMAGE.
     74       1.1  mellon  *
     75       1.1  mellon  * from: Utah $Hdr: cons.c 1.7 92/01/21$
     76       1.1  mellon  *
     77       1.1  mellon  *	@(#)cons.c	8.2 (Berkeley) 1/12/94
     78       1.1  mellon  */
     79       1.4   lukem 
     80       1.4   lukem #include <sys/cdefs.h>
     81  1.4.16.1   skrll __KERNEL_RCSID(0, "$NetBSD: cninit.c,v 1.4.16.2 2004/09/18 14:44:28 skrll Exp $");
     82       1.1  mellon 
     83       1.1  mellon #include <sys/param.h>
     84       1.1  mellon #include <sys/proc.h>
     85       1.1  mellon #include <sys/user.h>
     86       1.1  mellon #include <sys/systm.h>
     87       1.1  mellon #include <sys/buf.h>
     88       1.1  mellon #include <sys/ioctl.h>
     89       1.1  mellon #include <sys/tty.h>
     90       1.1  mellon #include <sys/file.h>
     91       1.1  mellon #include <sys/conf.h>
     92       1.1  mellon #include <sys/vnode.h>
     93       1.1  mellon 
     94       1.1  mellon #include <dev/cons.h>
     95       1.1  mellon 
     96       1.1  mellon void
     97       1.1  mellon cninit()
     98       1.1  mellon {
     99       1.3      tv 	struct consdev *cp;
    100       1.3      tv 	struct consdev *bestMatch;
    101       1.3      tv 
    102       1.3      tv 	bestMatch = cn_tab = NULL;
    103       1.1  mellon 	/*
    104       1.1  mellon 	 * Collect information about all possible consoles
    105       1.1  mellon 	 * and find the one with highest priority
    106       1.1  mellon 	 */
    107       1.1  mellon 	for (cp = constab; cp->cn_probe; cp++) {
    108       1.1  mellon 		(*cp->cn_probe)(cp);
    109       1.1  mellon 		if (cp->cn_pri > CN_DEAD &&
    110       1.3      tv 		    (bestMatch == NULL || cp->cn_pri > bestMatch->cn_pri)) {
    111       1.3      tv 			bestMatch = cp;
    112       1.3      tv 		}
    113       1.1  mellon 	}
    114       1.1  mellon 	/*
    115       1.1  mellon 	 * No console, we can handle it
    116       1.1  mellon 	 */
    117       1.3      tv 	if ((cp = bestMatch) == NULL)
    118       1.1  mellon 		return;
    119       1.1  mellon 	/*
    120       1.1  mellon 	 * Turn on console
    121       1.1  mellon 	 */
    122       1.3      tv 	{
    123       1.3      tv 		struct consdev *old_cn_tab = cn_tab;
    124       1.3      tv 
    125       1.3      tv  		(*cp->cn_init)(cp);
    126       1.3      tv 		/*
    127       1.3      tv 		 * Now let everyone know we have an active console they can
    128       1.3      tv 		 * use for diagnostics. If we use cn_tab in the search loop
    129       1.3      tv 		 * then interrupts from the ethernet at boot may cause system
    130       1.3      tv 		 * hang.
    131       1.3      tv 		 */
    132       1.3      tv 		if (cn_tab == old_cn_tab)
    133       1.3      tv 			cn_tab = bestMatch;
    134       1.3      tv 	}
    135       1.1  mellon }
    136