summaryrefslogtreecommitdiff
path: root/i386/i386at
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2011-02-26 21:57:11 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2011-02-26 21:57:11 +0100
commitdd687a62dfb81ec125f41a257229f58d80b7044d (patch)
treea7c7d54acf611248e4c64a508717e8dd076e47c7 /i386/i386at
parent3d095d907e0047621950b3dcd9ff8b1f3d596797 (diff)
Add console=comN boot option to enable serial console
* i386/configfrag.ac (RCLINE, RCADDR): Remove defines. * i386/i386at/com.c: Include <string.h> and <util/atoi.h> [!RCLINE] (RCBAUD, comcndev, comcnprobe, comcninit, comcngetc, comcnputc): Declare and define macro, variable, and functions. (rcline): New variable. (kernel_cmdline): New declaration. (comcnprobe): Detect "console=comN" option and set rcline accordingly, use rcline instead of RCLINE for serial console selection. * i386/i386at/cons_conf.c [NCOM>0 && !RCLINE] (comcnprobe, comcninit, comcngetc, comcnputc): Declare functions. [NCOM>0 && !RCLINE] (constab): Enable "com" console. * i386/i386at/kd_event.c (kbdopen): Call kdinit function, for when the VGA+pckbd console was not initialized.
Diffstat (limited to 'i386/i386at')
-rw-r--r--i386/i386at/com.c23
-rw-r--r--i386/i386at/cons_conf.c4
-rw-r--r--i386/i386at/kd_event.c3
3 files changed, 19 insertions, 11 deletions
diff --git a/i386/i386at/com.c b/i386/i386at/com.c
index 602e1ff..325e099 100644
--- a/i386/i386at/com.c
+++ b/i386/i386at/com.c
@@ -26,6 +26,9 @@
#if NCOM > 0
+#include <string.h>
+#include <util/atoi.h>
+
#include <mach/std_types.h>
#include <sys/types.h>
#include <kern/printf.h>
@@ -64,14 +67,16 @@ boolean_t comfifo[NCOM];
boolean_t comtimer_active;
int comtimer_state[NCOM];
-#if RCLINE >= 0
#define RCBAUD B9600
+static int rcline = -1;
static struct bus_device *comcndev;
int comcnprobe(struct consdev *cp);
int comcninit(struct consdev *cp);
int comcngetc(dev_t dev, int wait);
int comcnputc(dev_t dev, int c);
-#endif
+
+/* XX */
+extern char *kernel_cmdline;
#ifndef PORTSELECTOR
#define ISPEED B9600
@@ -177,7 +182,6 @@ comprobe(int port, struct bus_device *dev)
return comprobe_general(dev, /*noisy*/ 0);
}
-#if RCLINE >= 0
/*
* Probe routine for use by the console
*/
@@ -187,13 +191,19 @@ comcnprobe(struct consdev *cp)
struct bus_device *b;
int maj, unit, pri;
+#define CONSOLE_PARAMETER " console=com"
+ u_char *console = (u_char *) strstr(kernel_cmdline, CONSOLE_PARAMETER);
+
+ if (console)
+ mach_atoi(console + strlen(CONSOLE_PARAMETER), &rcline);
+
maj = 0;
unit = -1;
pri = CN_DEAD;
for (b = bus_device_init; b->driver; b++)
if (strcmp(b->name, "com") == 0
- && b->unit == RCLINE
+ && b->unit == rcline
&& comprobe_general(b, /*quiet*/ 0))
{
/* Found one */
@@ -206,7 +216,6 @@ comcnprobe(struct consdev *cp)
cp->cn_dev = makedev(maj, unit);
cp->cn_pri = pri;
}
-#endif
/*
@@ -237,7 +246,6 @@ comattach(struct bus_device *dev)
}
}
-#if RCLINE >= 0
/*
* Attach/init routine for console. This isn't called by
* configure_bus_device which sets the alive, adaptor, and minfo
@@ -280,7 +288,6 @@ comcninit(struct consdev *cp)
}
}
-#endif
/*
* Probe for COM<dev> after autoconfiguration.
@@ -861,7 +868,6 @@ comgetc(int unit)
return c;
}
-#if RCLINE >= 0
/*
* Routines for the console
*/
@@ -893,6 +899,5 @@ comcngetc(dev_t dev, int wait)
c = inb(TXRX(addr));
return c & 0x7f;
}
-#endif /* RCLINE */
#endif /* NCOM */
diff --git a/i386/i386at/cons_conf.c b/i386/i386at/cons_conf.c
index ea8ccb5..8a4b37c 100644
--- a/i386/i386at/cons_conf.c
+++ b/i386/i386at/cons_conf.c
@@ -34,7 +34,7 @@
extern int hypcnprobe(), hypcninit(), hypcngetc(), hypcnputc();
#else /* MACH_HYP */
extern int kdcnprobe(), kdcninit(), kdcngetc(), kdcnputc();
-#if NCOM > 0 && RCLINE >= 0
+#if NCOM > 0
extern int comcnprobe(), comcninit(), comcngetc(), comcnputc();
#endif
#endif /* MACH_HYP */
@@ -48,7 +48,7 @@ struct consdev constab[] = {
{"hyp", hypcnprobe, hypcninit, hypcngetc, hypcnputc},
#else /* MACH_HYP */
{"kd", kdcnprobe, kdcninit, kdcngetc, kdcnputc},
-#if NCOM > 0 && RCLINE >= 0 && 1
+#if NCOM > 0
{"com", comcnprobe, comcninit, comcngetc, comcnputc},
#endif
#endif /* MACH_HYP */
diff --git a/i386/i386at/kd_event.c b/i386/i386at/kd_event.c
index 5d8d563..3983a11 100644
--- a/i386/i386at/kd_event.c
+++ b/i386/i386at/kd_event.c
@@ -142,6 +142,9 @@ kbdopen(dev, flags)
dev_t dev;
int flags;
{
+ spl_t o_pri = spltty();
+ kdinit();
+ splx(o_pri);
kbdinit();
#ifdef MACH_KERNEL