xref: /netbsd/sys/arch/newsmips/newsmips/cpu_cons.c (revision 68f785b7)
1 /*	$NetBSD: cpu_cons.c,v 1.14 2018/10/14 00:10:11 tsutsui Exp $	*/
2 
3 /*
4  * Copyright (c) 1988 University of Utah.
5  * Copyright (c) 1992, 1993
6  *	The Regents of the University of California.  All rights reserved.
7  *
8  * This code is derived from software contributed to Berkeley by
9  * the Systems Programming Group of the University of Utah Computer
10  * Science Department, The Mach Operating System project at
11  * Carnegie-Mellon University, Ralph Campbell, Sony Corp. and Kazumasa
12  * Utashiro of Software Research Associates, Inc.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions
16  * are met:
17  * 1. Redistributions of source code must retain the above copyright
18  *    notice, this list of conditions and the following disclaimer.
19  * 2. Redistributions in binary form must reproduce the above copyright
20  *    notice, this list of conditions and the following disclaimer in the
21  *    documentation and/or other materials provided with the distribution.
22  * 3. Neither the name of the University nor the names of its contributors
23  *    may be used to endorse or promote products derived from this software
24  *    without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36  * SUCH DAMAGE.
37  */
38 
39 #include <sys/cdefs.h>
40 __KERNEL_RCSID(0, "$NetBSD: cpu_cons.c,v 1.14 2018/10/14 00:10:11 tsutsui Exp $");
41 
42 #include <sys/param.h>
43 #include <sys/systm.h>
44 #include <machine/adrsmap.h>
45 #include <machine/cpu.h>
46 #include <dev/cons.h>
47 
48 /*
49  * Console initialization: called early on from main,
50  * before vm init or startup.  Do enough configuration
51  * to choose and initialize a console.
52  * XXX need something better here.
53  */
54 #define	SCC_CONSOLE	0
55 #define	SW_CONSOLE	0x07
56 #define	SW_NWB512	0x04
57 #define	SW_NWB225	0x01
58 #define	SW_FBPOP	0x02
59 #define	SW_FBPOP1	0x06
60 #define	SW_FBPOP2	0x03
61 #define	SW_AUTOSEL	0x07
62 
63 extern struct consdev consdev_zs, consdev_zs_ap;
64 
65 void fb_cnattach(void);
66 void kb_hb_cnattach(void);
67 
68 void xafb_cnattach(void);
69 void kb_ap_cnattach(void);
70 
71 #include "fb.h"
72 #include "xafb.h"
73 #include "zsc.h"
74 
75 void
consinit(void)76 consinit(void)
77 {
78 	volatile int *dipsw;
79 	static int initted = 0;
80 
81 	if (initted)
82 		return;
83 
84 	initted = 1;
85 
86 	switch (systype) {
87 
88 #ifdef news3400
89 	case NEWS3400:
90 		dipsw = (void *)DIP_SWITCH;
91 
92 #if NFB > 0
93 		if (*dipsw & SW_CONSOLE) {
94 			fb_cnattach();
95 			kb_hb_cnattach();
96 			break;
97 		}
98 #endif
99 
100 #if NZSC > 0
101 		cn_tab = &consdev_zs;
102 		(*cn_tab->cn_init)(cn_tab);
103 #endif
104 		break;
105 
106 #endif /* news3400 */
107 
108 #ifdef news5000
109 	case NEWS5000:
110 		dipsw = (void *)NEWS5000_DIP_SWITCH;
111 
112 #if NXAFB > 0
113 		if (*dipsw & SW_CONSOLE) {
114 			xafb_cnattach();
115 			kb_ap_cnattach();
116 			break;
117 		}
118 #endif
119 
120 #if NZSC > 0
121 		cn_tab = &consdev_zs_ap;
122 		(*cn_tab->cn_init)(cn_tab);
123 #endif
124 		break;
125 
126 #endif /* news5000 */
127 
128 #ifdef news4000
129 	case NEWS4000:
130 		dipsw = 0;	/* XXX */
131 		(void)dipsw;
132 #if NZSC > 0
133 		cn_tab = &consdev_zs_ap;
134 		(*cn_tab->cn_init)(cn_tab);
135 #endif
136 		break;
137 
138 #endif /* news4000 */
139 	}
140 }
141