diff options
author | 2012-06-03 13:17:47 +0000 | |
---|---|---|
committer | 2012-06-03 13:17:47 +0000 | |
commit | a1e303c3bee5e26c162fdd93f7c7af84c08ab2e0 (patch) | |
tree | 9607db0df46d78d378679d5994bbf8e0018c4c5f | |
parent | Remove unnecessary tcpib_wdt_unlock() calls. (diff) | |
download | wireguard-openbsd-a1e303c3bee5e26c162fdd93f7c7af84c08ab2e0.tar.xz wireguard-openbsd-a1e303c3bee5e26c162fdd93f7c7af84c08ab2e0.zip |
Add support for serial consoles at non-standard addresses. This implements
a new "machine comaddr" command that makes it possible to configure the
io port used to access the serial port. This can be used to use serial ports
on a puc(4) device as serial console.
-rw-r--r-- | sys/arch/amd64/amd64/machdep.c | 16 | ||||
-rw-r--r-- | sys/arch/amd64/include/biosvar.h | 10 | ||||
-rw-r--r-- | sys/arch/amd64/stand/boot/conf.c | 4 | ||||
-rw-r--r-- | sys/arch/amd64/stand/cdboot/conf.c | 4 | ||||
-rw-r--r-- | sys/arch/amd64/stand/libsa/bioscons.c | 21 | ||||
-rw-r--r-- | sys/arch/amd64/stand/libsa/cmd_i386.c | 15 | ||||
-rw-r--r-- | sys/arch/amd64/stand/libsa/exec_i386.c | 5 | ||||
-rw-r--r-- | sys/arch/amd64/stand/pxeboot/conf.c | 4 | ||||
-rw-r--r-- | sys/arch/i386/i386/bios.c | 16 | ||||
-rw-r--r-- | sys/arch/i386/include/biosvar.h | 10 | ||||
-rw-r--r-- | sys/arch/i386/stand/boot/conf.c | 4 | ||||
-rw-r--r-- | sys/arch/i386/stand/cdboot/conf.c | 4 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/bioscons.c | 18 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/cmd_i386.c | 15 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/exec_i386.c | 5 | ||||
-rw-r--r-- | sys/arch/i386/stand/pxeboot/conf.c | 4 |
16 files changed, 109 insertions, 46 deletions
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index 25aa5bb7199..814a71658a2 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.153 2012/05/06 04:20:40 guenther Exp $ */ +/* $OpenBSD: machdep.c,v 1.154 2012/06/03 13:18:32 kettenis Exp $ */ /* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */ /*- @@ -1797,17 +1797,23 @@ getbootinfo(char *bootinfo, int bootinfo_size) #endif #endif case BOOTARG_CONSDEV: - if (q->ba_size >= sizeof(bios_consdev_t)) { + if (q->ba_size >= sizeof(bios_oconsdev_t)) { bios_consdev_t *cdp = (bios_consdev_t*)q->ba_arg; #if NCOM > 0 static const int ports[] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 }; int unit = minor(cdp->consdev); - if (major(cdp->consdev) == 8 && unit >= 0 && - unit < (sizeof(ports)/sizeof(ports[0]))) { + int consaddr = -1; + if (q->ba_size >= sizeof(bios_consdev_t)) + consaddr = cdp->consaddr; + if (consaddr == -1 && unit >= 0 && + unit < (sizeof(ports)/sizeof(ports[0]))) + consaddr = ports[unit]; + if (major(cdp->consdev) == 8 && + consaddr != -1) { comconsunit = unit; - comconsaddr = ports[unit]; + comconsaddr = consaddr; comconsrate = cdp->conspeed; /* Probe the serial port this time. */ diff --git a/sys/arch/amd64/include/biosvar.h b/sys/arch/amd64/include/biosvar.h index abdb416b45e..7c993d09439 100644 --- a/sys/arch/amd64/include/biosvar.h +++ b/sys/arch/amd64/include/biosvar.h @@ -1,5 +1,5 @@ /* XXX - DSR */ -/* $OpenBSD: biosvar.h,v 1.15 2012/01/11 15:58:27 jsing Exp $ */ +/* $OpenBSD: biosvar.h,v 1.16 2012/06/03 13:18:33 kettenis Exp $ */ /* * Copyright (c) 1997-1999 Michael Shalayeff @@ -196,8 +196,16 @@ typedef struct _bios_pciinfo { typedef struct _bios_consdev { dev_t consdev; int conspeed; + int consaddr; + int consfreq; } __packed bios_consdev_t; +/* XXX Remove before OpenBSD 5.3 gets released. */ +typedef struct _bios_oconsdev { + dev_t consdev; + int conspeed; +} __packed bios_oconsdev_t; + #define BOOTARG_BOOTMAC 7 typedef struct _bios_bootmac { char mac[6]; diff --git a/sys/arch/amd64/stand/boot/conf.c b/sys/arch/amd64/stand/boot/conf.c index 017370e1c31..07a8d41e5ec 100644 --- a/sys/arch/amd64/stand/boot/conf.c +++ b/sys/arch/amd64/stand/boot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.22 2012/03/19 15:20:16 jsing Exp $ */ +/* $OpenBSD: conf.c,v 1.23 2012/06/03 13:18:33 kettenis Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -42,7 +42,7 @@ #include <biosdev.h> #include <dev/cons.h> -const char version[] = "3.19"; +const char version[] = "3.20"; int debug = 1; diff --git a/sys/arch/amd64/stand/cdboot/conf.c b/sys/arch/amd64/stand/cdboot/conf.c index 51b2534636f..b9d0b5ec142 100644 --- a/sys/arch/amd64/stand/cdboot/conf.c +++ b/sys/arch/amd64/stand/cdboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.19 2011/03/08 17:24:31 krw Exp $ */ +/* $OpenBSD: conf.c,v 1.20 2012/06/03 13:18:33 kettenis Exp $ */ /* * Copyright (c) 2004 Tom Cosgrove @@ -43,7 +43,7 @@ #include <biosdev.h> #include <dev/cons.h> -const char version[] = "3.16"; +const char version[] = "3.17"; int debug = 1; diff --git a/sys/arch/amd64/stand/libsa/bioscons.c b/sys/arch/amd64/stand/libsa/bioscons.c index d414a4f47ff..481289ef468 100644 --- a/sys/arch/amd64/stand/libsa/bioscons.c +++ b/sys/arch/amd64/stand/libsa/bioscons.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bioscons.c,v 1.5 2008/04/20 01:46:35 dlg Exp $ */ +/* $OpenBSD: bioscons.c,v 1.6 2012/06/03 13:18:33 kettenis Exp $ */ /* * Copyright (c) 1997-1999 Michael Shalayeff @@ -132,11 +132,12 @@ com_probe(struct consdev *cn) } int com_speed = -1; /* default speed is 9600 baud */ +int com_addr = -1; void com_init(struct consdev *cn) { - int port = comports[minor(cn->cn_dev)]; + int port = (com_addr == -1) ? comports[minor(cn->cn_dev)] : com_addr; outb(port + com_ier, 0); if (com_speed == -1) @@ -153,7 +154,7 @@ com_init(struct consdev *cn) int com_getc(dev_t dev) { - int port = comports[minor(dev & 0x7f)]; + int port = (com_addr == -1) ? comports[minor(dev & 0x7f)] : com_addr; if (dev & 0x80) return (inb(port + com_lsr) & LSR_RXRDY); @@ -168,8 +169,9 @@ com_getc(dev_t dev) int comspeed(dev_t dev, int sp) { + int port = (com_addr == -1) ? comports[minor(dev)] : com_addr; int i, newsp; - int err; + int err; if (sp <= 0) return com_speed; @@ -206,10 +208,10 @@ comspeed(dev_t dev, int sp) sleep(5); } - outb(comports[minor(dev)] + com_cfcr, LCR_DLAB); - outb(comports[minor(dev)] + com_dlbl, newsp); - outb(comports[minor(dev)] + com_dlbh, newsp>>8); - outb(comports[minor(dev)] + com_cfcr, LCR_8BITS); + outb(port + com_cfcr, LCR_DLAB); + outb(port + com_dlbl, newsp); + outb(port + com_dlbh, newsp>>8); + outb(port + com_cfcr, LCR_8BITS); if (com_speed != -1) printf("\ncom%d: %d baud\n", minor(dev), sp); @@ -221,11 +223,10 @@ comspeed(dev_t dev, int sp) void com_putc(dev_t dev, int c) { - int port = comports[minor(dev)]; + int port = (com_addr == -1) ? comports[minor(dev)] : com_addr; while ((inb(port + com_lsr) & LSR_TXRDY) == 0) ; outb(port + com_data, c); } - diff --git a/sys/arch/amd64/stand/libsa/cmd_i386.c b/sys/arch/amd64/stand/libsa/cmd_i386.c index ea6c5f636b0..f2a4ddd2ea9 100644 --- a/sys/arch/amd64/stand/libsa/cmd_i386.c +++ b/sys/arch/amd64/stand/libsa/cmd_i386.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd_i386.c,v 1.3 2010/07/02 00:36:52 weingart Exp $ */ +/* $OpenBSD: cmd_i386.c,v 1.4 2012/06/03 13:18:33 kettenis Exp $ */ /* * Copyright (c) 1997-1999 Michael Shalayeff @@ -41,6 +41,7 @@ extern const char version[]; int Xboot(void); +int Xcomaddr(void); int Xdiskinfo(void); int Xmemory(void); int Xregs(void); @@ -50,6 +51,7 @@ int bootbuf(void *, int); const struct cmd_table cmd_machine[] = { { "boot", CMDT_CMD, Xboot }, + { "comaddr", CMDT_CMD, Xcomaddr }, { "diskinfo", CMDT_CMD, Xdiskinfo }, { "memory", CMDT_CMD, Xmemory }, #ifdef DEBUG @@ -203,3 +205,14 @@ Xmemory(void) return 0; } + +int +Xcomaddr(void) +{ + extern int com_addr; + + if (cmd.argc >= 2) + com_addr = (int)strtol(cmd.argv[1], NULL, 0); + + return 0; +} diff --git a/sys/arch/amd64/stand/libsa/exec_i386.c b/sys/arch/amd64/stand/libsa/exec_i386.c index fce78a12636..82999fa0218 100644 --- a/sys/arch/amd64/stand/libsa/exec_i386.c +++ b/sys/arch/amd64/stand/libsa/exec_i386.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_i386.c,v 1.8 2012/01/11 15:58:27 jsing Exp $ */ +/* $OpenBSD: exec_i386.c,v 1.9 2012/06/03 13:18:33 kettenis Exp $ */ /* * Copyright (c) 1997-1998 Michael Shalayeff @@ -54,6 +54,7 @@ run_loadfile(u_long *marks, int howto) caddr_t av = (caddr_t)BOOTARG_OFF; bios_consdev_t cd; extern int com_speed; /* from bioscons.c */ + extern int com_addr; bios_ddb_t ddb; extern int db_console; bios_bootduid_t bootduid; @@ -63,6 +64,8 @@ run_loadfile(u_long *marks, int howto) cd.consdev = cn_tab->cn_dev; cd.conspeed = com_speed; + cd.consaddr = com_addr; + cd.consfreq = 0; addbootarg(BOOTARG_CONSDEV, sizeof(cd), &cd); if (bootmac != NULL) diff --git a/sys/arch/amd64/stand/pxeboot/conf.c b/sys/arch/amd64/stand/pxeboot/conf.c index c253a7155a9..5d95c767ead 100644 --- a/sys/arch/amd64/stand/pxeboot/conf.c +++ b/sys/arch/amd64/stand/pxeboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.23 2011/03/08 17:24:31 krw Exp $ */ +/* $OpenBSD: conf.c,v 1.24 2012/06/03 13:18:33 kettenis Exp $ */ /* * Copyright (c) 2004 Tom Cosgrove @@ -45,7 +45,7 @@ #include "pxeboot.h" #include "pxe_net.h" -const char version[] = "3.16"; +const char version[] = "3.17"; int debug = 0; #undef _TEST diff --git a/sys/arch/i386/i386/bios.c b/sys/arch/i386/i386/bios.c index 661649599d8..2c706f93454 100644 --- a/sys/arch/i386/i386/bios.c +++ b/sys/arch/i386/i386/bios.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bios.c,v 1.93 2012/01/13 12:55:52 jsing Exp $ */ +/* $OpenBSD: bios.c,v 1.94 2012/06/03 13:17:47 kettenis Exp $ */ /* * Copyright (c) 1997-2001 Michael Shalayeff @@ -499,17 +499,23 @@ bios_getopt() break; #endif case BOOTARG_CONSDEV: - if (q->ba_size >= sizeof(bios_consdev_t)) { + if (q->ba_size >= sizeof(bios_oconsdev_t)) { bios_consdev_t *cdp = (bios_consdev_t*)q->ba_arg; #if NCOM > 0 static const int ports[] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 }; int unit = minor(cdp->consdev); - if (major(cdp->consdev) == 8 && unit >= 0 && - unit < (sizeof(ports)/sizeof(ports[0]))) { + int consaddr = -1; + if (q->ba_size >= sizeof(bios_consdev_t)) + consaddr = cdp->consaddr; + if (consaddr == -1 && unit >=0 && + unit < (sizeof(ports)/sizeof(ports[0]))) + consaddr = ports[unit]; + if (major(cdp->consdev) == 8 && + consaddr != -1) { comconsunit = unit; - comconsaddr = ports[unit]; + comconsaddr = consaddr; comconsrate = cdp->conspeed; /* Probe the serial port this time. */ diff --git a/sys/arch/i386/include/biosvar.h b/sys/arch/i386/include/biosvar.h index 11a9c900d58..54e64129af9 100644 --- a/sys/arch/i386/include/biosvar.h +++ b/sys/arch/i386/include/biosvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: biosvar.h,v 1.57 2012/01/11 15:58:27 jsing Exp $ */ +/* $OpenBSD: biosvar.h,v 1.58 2012/06/03 13:17:47 kettenis Exp $ */ /* * Copyright (c) 1997-1999 Michael Shalayeff @@ -196,8 +196,16 @@ typedef struct _bios_pciinfo { typedef struct _bios_consdev { dev_t consdev; int conspeed; + int consaddr; + int consfreq; } __packed bios_consdev_t; +/* XXX Remove before OpenBSD 5.3 gets released. */ +typedef struct _bios_oconsdev { + dev_t consdev; + int conspeed; +} __packed bios_oconsdev_t; + #define BOOTARG_SMPINFO 6 /* struct mp_float[] */ #define BOOTARG_BOOTMAC 7 diff --git a/sys/arch/i386/stand/boot/conf.c b/sys/arch/i386/stand/boot/conf.c index f1f3be3125f..1bd9a72f460 100644 --- a/sys/arch/i386/stand/boot/conf.c +++ b/sys/arch/i386/stand/boot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.46 2011/04/26 17:33:17 jsing Exp $ */ +/* $OpenBSD: conf.c,v 1.47 2012/06/03 13:17:47 kettenis Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -43,7 +43,7 @@ #include <dev/cons.h> #include "debug.h" -const char version[] = "3.17"; +const char version[] = "3.18"; int debug = 1; diff --git a/sys/arch/i386/stand/cdboot/conf.c b/sys/arch/i386/stand/cdboot/conf.c index 15c11cf01b5..1055b75b892 100644 --- a/sys/arch/i386/stand/cdboot/conf.c +++ b/sys/arch/i386/stand/cdboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.17 2011/03/08 17:24:31 krw Exp $ */ +/* $OpenBSD: conf.c,v 1.18 2012/06/03 13:17:47 kettenis Exp $ */ /* * Copyright (c) 2004 Tom Cosgrove @@ -44,7 +44,7 @@ #include <dev/cons.h> #include "debug.h" -const char version[] = "3.16"; +const char version[] = "3.17"; int debug = 1; #undef _TEST diff --git a/sys/arch/i386/stand/libsa/bioscons.c b/sys/arch/i386/stand/libsa/bioscons.c index b5d7702e35b..a4ff3b2b0dd 100644 --- a/sys/arch/i386/stand/libsa/bioscons.c +++ b/sys/arch/i386/stand/libsa/bioscons.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bioscons.c,v 1.31 2008/04/20 01:46:35 dlg Exp $ */ +/* $OpenBSD: bioscons.c,v 1.32 2012/06/03 13:17:47 kettenis Exp $ */ /* * Copyright (c) 1997-1999 Michael Shalayeff @@ -134,11 +134,12 @@ com_probe(struct consdev *cn) } int com_speed = -1; +int com_addr = -1; void com_init(struct consdev *cn) { - int port = comports[minor(cn->cn_dev)]; + int port = (com_addr == -1) ? comports[minor(cn->cn_dev)] : com_addr; outb(port + com_ier, 0); if (com_speed == -1) @@ -155,7 +156,7 @@ com_init(struct consdev *cn) int com_getc(dev_t dev) { - int port = comports[minor(dev & 0x7f)]; + int port = (com_addr == -1) ? comports[minor(dev & 0x7f)] : com_addr; if (dev & 0x80) return (inb(port + com_lsr) & LSR_RXRDY); @@ -170,6 +171,7 @@ com_getc(dev_t dev) int comspeed(dev_t dev, int sp) { + int port = (com_addr == -1) ? comports[minor(dev)] : com_addr; int i, newsp; int err; @@ -208,10 +210,10 @@ comspeed(dev_t dev, int sp) sleep(5); } - outb(comports[minor(dev)] + com_cfcr, LCR_DLAB); - outb(comports[minor(dev)] + com_dlbl, newsp); - outb(comports[minor(dev)] + com_dlbh, newsp>>8); - outb(comports[minor(dev)] + com_cfcr, LCR_8BITS); + outb(port + com_cfcr, LCR_DLAB); + outb(port + com_dlbl, newsp); + outb(port + com_dlbh, newsp>>8); + outb(port + com_cfcr, LCR_8BITS); if (com_speed != -1) printf("\ncom%d: %d baud\n", minor(dev), sp); @@ -223,7 +225,7 @@ comspeed(dev_t dev, int sp) void com_putc(dev_t dev, int c) { - int port = comports[minor(dev)]; + int port = (com_addr == -1) ? comports[minor(dev)] : com_addr; while ((inb(port + com_lsr) & LSR_TXRDY) == 0) ; diff --git a/sys/arch/i386/stand/libsa/cmd_i386.c b/sys/arch/i386/stand/libsa/cmd_i386.c index 67d4c2f40f8..4a2f6f938d0 100644 --- a/sys/arch/i386/stand/libsa/cmd_i386.c +++ b/sys/arch/i386/stand/libsa/cmd_i386.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd_i386.c,v 1.30 2010/07/02 00:36:52 weingart Exp $ */ +/* $OpenBSD: cmd_i386.c,v 1.31 2012/06/03 13:17:47 kettenis Exp $ */ /* * Copyright (c) 1997-1999 Michael Shalayeff @@ -42,6 +42,7 @@ extern const char version[]; int Xboot(void); +int Xcomaddr(void); int Xdiskinfo(void); int Xmemory(void); int Xregs(void); @@ -51,6 +52,7 @@ int bootbuf(void *, int); const struct cmd_table cmd_machine[] = { { "boot", CMDT_CMD, Xboot }, + { "comaddr", CMDT_CMD, Xcomaddr }, { "diskinfo", CMDT_CMD, Xdiskinfo }, { "memory", CMDT_CMD, Xmemory }, #ifdef DEBUG @@ -206,3 +208,14 @@ Xmemory(void) return 0; } + +int +Xcomaddr(void) +{ + extern int com_addr; + + if (cmd.argc >= 2) + com_addr = (int)strtol(cmd.argv[1], NULL, 0); + + return 0; +} diff --git a/sys/arch/i386/stand/libsa/exec_i386.c b/sys/arch/i386/stand/libsa/exec_i386.c index cad431225be..d88b2df1d01 100644 --- a/sys/arch/i386/stand/libsa/exec_i386.c +++ b/sys/arch/i386/stand/libsa/exec_i386.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_i386.c,v 1.35 2012/01/11 15:58:27 jsing Exp $ */ +/* $OpenBSD: exec_i386.c,v 1.36 2012/06/03 13:17:47 kettenis Exp $ */ /* * Copyright (c) 1997-1998 Michael Shalayeff @@ -52,6 +52,7 @@ run_loadfile(u_long *marks, int howto) caddr_t av = (caddr_t)BOOTARG_OFF; bios_consdev_t cd; extern int com_speed; /* from bioscons.c */ + extern int com_addr; bios_ddb_t ddb; extern int db_console; bios_bootduid_t bootduid; @@ -61,6 +62,8 @@ run_loadfile(u_long *marks, int howto) cd.consdev = cn_tab->cn_dev; cd.conspeed = com_speed; + cd.consaddr = com_addr; + cd.consfreq = 0; addbootarg(BOOTARG_CONSDEV, sizeof(cd), &cd); if (bootmac != NULL) diff --git a/sys/arch/i386/stand/pxeboot/conf.c b/sys/arch/i386/stand/pxeboot/conf.c index c53482fcbba..dbf4d0cd84b 100644 --- a/sys/arch/i386/stand/pxeboot/conf.c +++ b/sys/arch/i386/stand/pxeboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.22 2011/03/08 17:24:31 krw Exp $ */ +/* $OpenBSD: conf.c,v 1.23 2012/06/03 13:17:47 kettenis Exp $ */ /* * Copyright (c) 2004 Tom Cosgrove @@ -46,7 +46,7 @@ #include "pxeboot.h" #include "pxe_net.h" -const char version[] = "3.16"; +const char version[] = "3.17"; int debug = 1; #undef _TEST |