1 /* $NetBSD: consinit.c,v 1.12 2009/03/16 06:17:20 cegger Exp $ */
2 /* NetBSD: consinit.c,v 1.4 2004/03/13 17:31:34 bjh21 Exp */
6 * Matthias Drochner. All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #include <sys/cdefs.h>
31 __KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.12 2009/03/16 06:17:20 cegger Exp $");
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/device.h>
38 #include <machine/bus.h>
39 #include <machine/bootinfo.h>
44 #include "pcdisplay.h"
45 #if (NVGA > 0) || (NEGA > 0) || (NPCDISPLAY > 0)
46 #include <dev/ic/mc6845reg.h>
47 #include <dev/ic/pcdisplayvar.h>
49 #include <dev/ic/vgareg.h>
50 #include <dev/ic/vgavar.h>
53 #include <dev/isa/egavar.h>
56 #include <dev/isa/pcdisplayvar.h>
62 #include <dev/isa/isareg.h>
63 #include <dev/ic/i8042reg.h>
64 #include <dev/ic/pckbcvar.h>
66 #include "pckbd.h" /* for pckbc_machdep_cnattach */
70 #include <dev/usb/ukbdvar.h>
76 #include <dev/pckbport/pckbportvar.h>
77 #include <xen/hypervisor.h>
82 #include <sys/termios.h>
83 #include <dev/ic/comreg.h>
84 #include <dev/ic/comvar.h>
88 #define CONSDEVNAME "pc"
96 #define CONSPEED TTYDEF_SPEED
99 #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
101 int comcnmode
= CONMODE
;
104 const struct btinfo_console default_consinfo
= {
116 #define KGDB_DEVNAME "com"
118 const char kgdb_devname
[] = KGDB_DEVNAME
;
122 #define KGDB_DEVADDR 0x3f8
124 int comkgdbaddr
= KGDB_DEVADDR
;
126 #define KGDB_DEVRATE TTYDEF_SPEED
128 int comkgdbrate
= KGDB_DEVRATE
;
130 #define KGDB_DEVMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
132 int comkgdbmode
= KGDB_DEVMODE
;
139 * initialize the system console.
140 * XXX - shouldn't deal with this initted thing, but then,
141 * it shouldn't be called from init386 either.
146 static int initted
= 0;
147 union xen_cmdline_parseinfo xcp
;
153 xen_parse_cmdline(XEN_PARSE_CONSOLE
, &xcp
);
156 if (xendomain_is_privileged()) {
158 if (strcmp(default_consinfo
.devname
, "tty0") == 0 ||
159 strcmp(default_consinfo
.devname
, "pc") == 0) {
161 if (strcmp(xcp
.xcp_console
, "tty0") == 0 || /* linux name */
162 strcmp(xcp
.xcp_console
, "pc") == 0) { /* NetBSD name */
163 #endif /* CONS_OVERRIDE */
165 vga_cnattach(X86_BUS_SPACE_IO
, X86_BUS_SPACE_MEM
,
169 error
= pckbc_cnattach(X86_BUS_SPACE_IO
, IO_KBD
, KBCMDP
,
174 error
= ukbd_cnattach();
177 printf("WARNING: no console keyboard, "
178 "error=%d\n", error
);
186 #endif /* NXENCONS */
187 panic("consinit: no console");
195 if(!strcmp(kgdb_devname
, "com")) {
196 bus_space_tag_t tag
= X86_BUS_SPACE_IO
;
198 com_kgdb_attach(tag
, comkgdbaddr
, comkgdbrate
, COM_FREQ
,
199 COM_TYPE_NORMAL
, comkgdbmode
);