From dd687a62dfb81ec125f41a257229f58d80b7044d Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 26 Feb 2011 21:57:11 +0100 Subject: Add console=comN boot option to enable serial console * i386/configfrag.ac (RCLINE, RCADDR): Remove defines. * i386/i386at/com.c: Include and [!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. --- i386/configfrag.ac | 16 ---------------- i386/i386at/com.c | 23 ++++++++++++++--------- i386/i386at/cons_conf.c | 4 ++-- i386/i386at/kd_event.c | 3 +++ 4 files changed, 19 insertions(+), 27 deletions(-) (limited to 'i386') diff --git a/i386/configfrag.ac b/i386/configfrag.ac index 1132b69..e4ce97e 100644 --- a/i386/configfrag.ac +++ b/i386/configfrag.ac @@ -66,22 +66,6 @@ AC_DEFINE_UNQUOTED([NCOM], [$ncom], [NCOM]) # i386/bogus/lpr.h AC_DEFINE_UNQUOTED([NLPR], [$nlpr], [NLPR]) - -# i386/bogus/rc.h -# -# This controls whether or not we use a serial line for the console -# (ie, remote console). -# -# -# Values for RCLINE: -# -1 = disable -# 0 = port 0x3f8/irq 4 (DOS COM1) -# 1 = port 0x2f8/irq 3 (DOS COM2) -# 2 = port 0x3e8/irq 5 (DOS COM3) -# 3 = port 0x2e8/irq 9 (DOS COM4) -# -AC_DEFINE([RCLINE], [-1], [com port for the remote console]) -AC_DEFINE([RCADDR], [0x3f8], [where is the com port for the remote console]) # # Options. 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 +#include + #include #include #include @@ -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 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 -- cgit v1.2.3