diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2011-02-26 21:57:11 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2011-02-26 21:57:11 +0100 |
commit | dd687a62dfb81ec125f41a257229f58d80b7044d (patch) | |
tree | a7c7d54acf611248e4c64a508717e8dd076e47c7 /i386/i386at/com.c | |
parent | 3d095d907e0047621950b3dcd9ff8b1f3d596797 (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/com.c')
-rw-r--r-- | i386/i386at/com.c | 23 |
1 files changed, 14 insertions, 9 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 */ |