Annotation of src/sys/arch/x86/x86/consinit.c, Revision 1.14.30.1
1.14.30.1! mjf 1: /* $NetBSD: consinit.c,v 1.15 2007/11/14 17:55:00 ad Exp $ */
1.1 fvdl 2:
3: /*
4: * Copyright (c) 1998
5: * Matthias Drochner. All rights reserved.
6: *
7: * Redistribution and use in source and binary forms, with or without
8: * modification, are permitted provided that the following conditions
9: * are met:
10: * 1. Redistributions of source code must retain the above copyright
11: * notice, this list of conditions and the following disclaimer.
12: * 2. Redistributions in binary form must reproduce the above copyright
13: * notice, this list of conditions and the following disclaimer in the
14: * documentation and/or other materials provided with the distribution.
15: *
16: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26: *
27: */
28:
29: #include <sys/cdefs.h>
1.14.30.1! mjf 30: __KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.15 2007/11/14 17:55:00 ad Exp $");
1.1 fvdl 31:
32: #include "opt_kgdb.h"
33:
34: #include <sys/param.h>
35: #include <sys/systm.h>
36: #include <sys/device.h>
37: #include <machine/bus.h>
38: #include <machine/bootinfo.h>
39:
40: #include "vga.h"
41: #include "ega.h"
42: #include "pcdisplay.h"
43: #if (NVGA > 0) || (NEGA > 0) || (NPCDISPLAY > 0)
44: #include <dev/ic/mc6845reg.h>
45: #include <dev/ic/pcdisplayvar.h>
46: #if (NVGA > 0)
47: #include <dev/ic/vgareg.h>
48: #include <dev/ic/vgavar.h>
49: #endif
50: #if (NEGA > 0)
51: #include <dev/isa/egavar.h>
52: #endif
53: #if (NPCDISPLAY > 0)
54: #include <dev/isa/pcdisplayvar.h>
55: #endif
56: #endif
57:
58: #include "pckbc.h"
59: #if (NPCKBC > 0)
60: #include <dev/isa/isareg.h>
61: #include <dev/ic/i8042reg.h>
62: #include <dev/ic/pckbcvar.h>
1.4 bjh21 63: #include <dev/pckbport/pckbportvar.h>
1.1 fvdl 64: #endif
65: #include "pckbd.h" /* for pckbc_machdep_cnattach */
66:
1.10 jmcneill 67: #ifdef __i386__
68: #include "vesafb.h"
69: #if (NVESAFB > 0)
70: #include <arch/i386/bios/vesafbvar.h>
71: #endif
72: #endif
73:
1.13 jmcneill 74: #ifdef __i386__
75: #include "xboxfb.h"
76: #if (NXBOXFB > 0)
77: #include <machine/xbox.h>
78: #endif
79: #endif
80:
1.1 fvdl 81: #include "com.h"
82: #if (NCOM > 0)
83: #include <sys/termios.h>
84: #include <dev/ic/comreg.h>
85: #include <dev/ic/comvar.h>
86: #endif
87:
88: #include "ukbd.h"
89: #if (NUKBD > 0)
90: #include <dev/usb/ukbdvar.h>
91: #endif
92:
93: #ifndef CONSDEVNAME
94: #define CONSDEVNAME "pc"
95: #endif
96:
97: #if (NCOM > 0)
98: #ifndef CONADDR
99: #define CONADDR 0x3f8
100: #endif
101: #ifndef CONSPEED
102: #define CONSPEED TTYDEF_SPEED
103: #endif
104: #ifndef CONMODE
105: #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
106: #endif
107: int comcnmode = CONMODE;
108: #endif /* NCOM */
109:
110: const struct btinfo_console default_consinfo = {
111: {0, 0},
112: CONSDEVNAME,
113: #if (NCOM > 0)
114: CONADDR, CONSPEED
115: #else
116: 0, 0
117: #endif
118: };
119:
120: #ifdef KGDB
121: #ifndef KGDB_DEVNAME
122: #define KGDB_DEVNAME "com"
123: #endif
124: const char kgdb_devname[] = KGDB_DEVNAME;
125:
126: #if (NCOM > 0)
127: #ifndef KGDB_DEVADDR
128: #define KGDB_DEVADDR 0x3f8
129: #endif
130: int comkgdbaddr = KGDB_DEVADDR;
131: #ifndef KGDB_DEVRATE
132: #define KGDB_DEVRATE TTYDEF_SPEED
133: #endif
134: int comkgdbrate = KGDB_DEVRATE;
135: #ifndef KGDB_DEVMODE
136: #define KGDB_DEVMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
137: #endif
138: int comkgdbmode = KGDB_DEVMODE;
139: #endif /* NCOM */
140:
141: #endif /* KGDB */
142:
143: /*
144: * consinit:
145: * initialize the system console.
146: * XXX - shouldn't deal with this initted thing, but then,
147: * it shouldn't be called from init386 either.
148: */
149: void
150: consinit()
151: {
152: const struct btinfo_console *consinfo;
153: static int initted;
154:
155: if (initted)
156: return;
157: initted = 1;
158:
159: #ifndef CONS_OVERRIDE
160: consinfo = lookup_bootinfo(BTINFO_CONSOLE);
161: if (!consinfo)
162: #endif
163: consinfo = &default_consinfo;
164:
1.14.30.1! mjf 165: #if (NVGA > 0) || (NEGA > 0) || (NPCDISPLAY > 0) || (NVESAFB > 0) || (NXBOXFB > 0)
1.1 fvdl 166: if (!strcmp(consinfo->devname, "pc")) {
1.6 augustss 167: int error;
1.10 jmcneill 168: #if (NVESAFB > 0)
169: if (!vesafb_cnattach())
170: goto dokbd;
171: #endif
1.13 jmcneill 172: #if (NXBOXFB > 0)
1.14 jmcneill 173: switch (xboxfb_cnattach()) {
174: case 0:
1.13 jmcneill 175: goto dokbd;
1.14 jmcneill 176: case 1:
177: break;
178: case -1:
179: /* defer initialization until later */
180: initted = 0;
181: return;
182: }
1.13 jmcneill 183: #endif
1.1 fvdl 184: #if (NVGA > 0)
185: if (!vga_cnattach(X86_BUS_SPACE_IO, X86_BUS_SPACE_MEM,
186: -1, 1))
187: goto dokbd;
188: #endif
189: #if (NEGA > 0)
190: if (!ega_cnattach(X86_BUS_SPACE_IO, X86_BUS_SPACE_MEM))
191: goto dokbd;
192: #endif
193: #if (NPCDISPLAY > 0)
194: if (!pcdisplay_cnattach(X86_BUS_SPACE_IO, X86_BUS_SPACE_MEM))
195: goto dokbd;
196: #endif
197: if (0) goto dokbd; /* XXX stupid gcc */
198: dokbd:
1.7 augustss 199: error = ENODEV;
1.1 fvdl 200: #if (NPCKBC > 0)
1.5 augustss 201: error = pckbc_cnattach(X86_BUS_SPACE_IO, IO_KBD, KBCMDP,
1.1 fvdl 202: PCKBC_KBD_SLOT);
203: #endif
1.5 augustss 204: #if (NUKBD > 0)
205: if (error)
1.7 augustss 206: error = ukbd_cnattach();
1.1 fvdl 207: #endif
1.7 augustss 208: if (error)
209: printf("WARNING: no console keyboard, error=%d\n",
210: error);
1.1 fvdl 211: return;
212: }
1.13 jmcneill 213: #endif /* PC | VT | VGA | PCDISPLAY | VESAFB | XBOXFB */
1.1 fvdl 214: #if (NCOM > 0)
215: if (!strcmp(consinfo->devname, "com")) {
216: bus_space_tag_t tag = X86_BUS_SPACE_IO;
1.9 jmmv 217: int addr = consinfo->addr;
218: int speed = consinfo->speed;
1.1 fvdl 219:
1.9 jmmv 220: if (addr == 0)
221: addr = CONADDR;
222: if (speed == 0)
223: speed = CONSPEED;
224:
225: if (comcnattach(tag, addr, speed,
1.3 thorpej 226: COM_FREQ, COM_TYPE_NORMAL, comcnmode))
1.1 fvdl 227: panic("can't init serial console @%x", consinfo->addr);
228:
229: return;
230: }
231: #endif
232: panic("invalid console device %s", consinfo->devname);
233: }
234:
235: #ifdef KGDB
236: void
237: kgdb_port_init()
238: {
239: #if (NCOM > 0)
240: if(!strcmp(kgdb_devname, "com")) {
241: bus_space_tag_t tag = X86_BUS_SPACE_IO;
242:
243: com_kgdb_attach(tag, comkgdbaddr, comkgdbrate, COM_FREQ,
1.3 thorpej 244: COM_TYPE_NORMAL, comkgdbmode);
1.1 fvdl 245: }
246: #endif
247: }
248: #endif
CVSweb <webmaster@jp.NetBSD.org>