1*98edb555Sguenther /* $OpenBSD: cninit.c,v 1.15 2017/12/30 20:46:59 guenther Exp $ */
2df930be7Sderaadt /* $NetBSD: cninit.c,v 1.2 1995/04/11 22:08:10 pk Exp $ */
3df930be7Sderaadt
4df930be7Sderaadt /*
5df930be7Sderaadt * Copyright (c) 1988 University of Utah.
6df930be7Sderaadt * Copyright (c) 1990, 1993
7df930be7Sderaadt * The Regents of the University of California. All rights reserved.
8df930be7Sderaadt *
9df930be7Sderaadt * This code is derived from software contributed to Berkeley by
10df930be7Sderaadt * the Systems Programming Group of the University of Utah Computer
11df930be7Sderaadt * Science Department.
12df930be7Sderaadt *
13df930be7Sderaadt * Redistribution and use in source and binary forms, with or without
14df930be7Sderaadt * modification, are permitted provided that the following conditions
15df930be7Sderaadt * are met:
16df930be7Sderaadt * 1. Redistributions of source code must retain the above copyright
17df930be7Sderaadt * notice, this list of conditions and the following disclaimer.
18df930be7Sderaadt * 2. Redistributions in binary form must reproduce the above copyright
19df930be7Sderaadt * notice, this list of conditions and the following disclaimer in the
20df930be7Sderaadt * documentation and/or other materials provided with the distribution.
2129295d1cSmillert * 3. Neither the name of the University nor the names of its contributors
22df930be7Sderaadt * may be used to endorse or promote products derived from this software
23df930be7Sderaadt * without specific prior written permission.
24df930be7Sderaadt *
25df930be7Sderaadt * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26df930be7Sderaadt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27df930be7Sderaadt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28df930be7Sderaadt * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29df930be7Sderaadt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30df930be7Sderaadt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31df930be7Sderaadt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32df930be7Sderaadt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33df930be7Sderaadt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34df930be7Sderaadt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35df930be7Sderaadt * SUCH DAMAGE.
36df930be7Sderaadt *
37df930be7Sderaadt * from: Utah $Hdr: cons.c 1.7 92/01/21$
38df930be7Sderaadt *
39df930be7Sderaadt * @(#)cons.c 8.2 (Berkeley) 1/12/94
40df930be7Sderaadt */
41df930be7Sderaadt
42df930be7Sderaadt #include <sys/param.h>
434bd35839Smickey #include <sys/systm.h>
44df930be7Sderaadt #include <sys/ioctl.h>
45df930be7Sderaadt #include <sys/tty.h>
46df930be7Sderaadt #include <sys/conf.h>
47df930be7Sderaadt #include <sys/vnode.h>
48df930be7Sderaadt
49df930be7Sderaadt #include <dev/cons.h>
50df930be7Sderaadt
51b1560ceaSmiod struct consdev *cn_tab = NULL;
52b1560ceaSmiod
53df930be7Sderaadt void
cninit(void)54efbf6099Stedu cninit(void)
55df930be7Sderaadt {
56c27077acSmiod struct consdev *cp;
57df930be7Sderaadt
58df930be7Sderaadt /*
59df930be7Sderaadt * Collect information about all possible consoles
60713cf266Sjsing * and find the one with highest priority.
61df930be7Sderaadt */
62df930be7Sderaadt for (cp = constab; cp->cn_probe; cp++) {
63df930be7Sderaadt (*cp->cn_probe)(cp);
64713cf266Sjsing if (cp->cn_pri != CN_DEAD &&
65df930be7Sderaadt (cn_tab == NULL || cp->cn_pri > cn_tab->cn_pri))
66df930be7Sderaadt cn_tab = cp;
67df930be7Sderaadt }
68713cf266Sjsing
69df930be7Sderaadt /*
70713cf266Sjsing * No console, we can handle it.
71df930be7Sderaadt */
72df930be7Sderaadt if ((cp = cn_tab) == NULL)
73df930be7Sderaadt return;
74713cf266Sjsing
75df930be7Sderaadt /*
76713cf266Sjsing * Turn on console.
77df930be7Sderaadt */
78df930be7Sderaadt (*cp->cn_init)(cp);
79df930be7Sderaadt }
80