diff options
| author | soren <soren@NetBSD.org> | 2013-07-22 13:40:36 +0000 |
|---|---|---|
| committer | soren <soren@NetBSD.org> | 2013-07-22 13:40:36 +0000 |
| commit | bd972b9ac790f935d94175af36d40602b8a92b60 (patch) | |
| tree | 8ef237f7d10802a5b45edb58f551713ec52f32a5 /sys/dev | |
| parent | 1d4c0c04c40b6d15ff404ed70528ec01a7c007f7 (diff) | |
Allow console on com_puc without a compile-time option so that PC servers
can become headless after the first reboot (sadly, e.g. Intel AMT presents
as a com_puc, but doesn't appear in the BIOS serial port table, so you need
a keyboard and monitor to install and set the installboot parameters first).
Fix com_puc console on devices with offset BAR's.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/pci/puc.c | 79 | ||||
| -rw-r--r-- | sys/dev/pci/puccn.c | 22 | ||||
| -rw-r--r-- | sys/dev/pci/puccn.h | 3 |
3 files changed, 48 insertions, 56 deletions
diff --git a/sys/dev/pci/puc.c b/sys/dev/pci/puc.c index f889d6130af..6cc60a21920 100644 --- a/sys/dev/pci/puc.c +++ b/sys/dev/pci/puc.c @@ -1,4 +1,4 @@ -/* $NetBSD: puc.c,v 1.32 2011/05/28 10:48:50 ryo Exp $ */ +/* $NetBSD: puc.c,v 1.33 2013/07/22 13:40:36 soren Exp $ */ /* * Copyright (c) 1996, 1998, 1999 @@ -53,7 +53,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: puc.c,v 1.32 2011/05/28 10:48:50 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: puc.c,v 1.33 2013/07/22 13:40:36 soren Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -68,7 +68,7 @@ __KERNEL_RCSID(0, "$NetBSD: puc.c,v 1.32 2011/05/28 10:48:50 ryo Exp $"); #include <dev/ic/comvar.h> #include "locators.h" -#include "opt_puccn.h" +#include "com.h" struct puc_softc { /* static configuration data */ @@ -147,13 +147,10 @@ puc_attach(device_t parent, device_t self, void *aux) pci_intr_handle_t intrhandle; pcireg_t subsys; int i, barindex; - bus_addr_t base; - bus_space_tag_t tag; -#ifdef PUCCN - bus_space_handle_t ioh; -#endif int locs[PUCCF_NLOCS]; + sc->sc_pc = pa->pa_pc; + subsys = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_SUBSYS_ID_REG); sc->sc_desc = puc_find_description(PCI_VENDOR(pa->pa_id), PCI_PRODUCT(pa->pa_id), PCI_VENDOR(subsys), PCI_PRODUCT(subsys)); @@ -177,19 +174,19 @@ puc_attach(device_t parent, device_t self, void *aux) return; } - printf(": %s (", sc->sc_desc->name); + aprint_naive("\n"); + aprint_normal(": %s (", sc->sc_desc->name); for (i = 0; PUC_PORT_VALID(sc->sc_desc, i); i++) - printf("%s%s", i ? ", " : "", + aprint_normal("%s%s", i ? ", " : "", puc_port_type_name(sc->sc_desc->ports[i].type)); - printf(")\n"); + aprint_normal(")\n"); for (i = 0; i < 6; i++) { pcireg_t bar, type; sc->sc_bar_mappings[i].mapped = 0; - bar = pci_conf_read(pa->pa_pc, pa->pa_tag, - PCI_MAPREG_START + 4 * i); /* XXX const */ + bar = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_BAR(i)); if (bar == 0) /* BAR not implemented(?) */ continue; @@ -197,31 +194,24 @@ puc_attach(device_t parent, device_t self, void *aux) PCI_MAPREG_TYPE_IO : PCI_MAPREG_MEM_TYPE(bar)); if (type == PCI_MAPREG_TYPE_IO) { - tag = pa->pa_iot; - base = PCI_MAPREG_IO_ADDR(bar); + sc->sc_bar_mappings[i].t = pa->pa_iot; + sc->sc_bar_mappings[i].a = PCI_MAPREG_IO_ADDR(bar); + sc->sc_bar_mappings[i].s = PCI_MAPREG_IO_SIZE(bar); } else { - tag = pa->pa_memt; - base = PCI_MAPREG_MEM_ADDR(bar); - } -#ifdef PUCCN - if (com_is_console(tag, base, &ioh)) { - sc->sc_bar_mappings[i].mapped = 1; - sc->sc_bar_mappings[i].a = base; - sc->sc_bar_mappings[i].s = COM_NPORTS; - sc->sc_bar_mappings[i].t = tag; - sc->sc_bar_mappings[i].h = ioh; - continue; + sc->sc_bar_mappings[i].t = pa->pa_memt; + sc->sc_bar_mappings[i].a = PCI_MAPREG_MEM_ADDR(bar); + sc->sc_bar_mappings[i].s = PCI_MAPREG_MEM_SIZE(bar); } -#endif + sc->sc_bar_mappings[i].mapped = (pci_mapreg_map(pa, - PCI_MAPREG_START + 4 * i, type, 0, + PCI_BAR(i), type, 0, &sc->sc_bar_mappings[i].t, &sc->sc_bar_mappings[i].h, &sc->sc_bar_mappings[i].a, &sc->sc_bar_mappings[i].s) == 0); if (sc->sc_bar_mappings[i].mapped) continue; - aprint_error_dev(self, "couldn't map BAR at offset 0x%lx\n", + aprint_debug_dev(self, "couldn't map BAR at offset 0x%lx\n", (long)(PCI_MAPREG_START + 4 * i)); } @@ -259,17 +249,32 @@ puc_attach(device_t parent, device_t self, void *aux) /* enable port 0-7 interrupt */ bus_space_write_1(sc->sc_bar_mappings[1].t, sc->sc_bar_mappings[1].h, SB16C105X_OPT_IMRREG0, 0xff); + } else { + if (!pmf_device_register(self, NULL, NULL); + aprint_error_dev(self, + "couldn't establish power handler\n"); } /* Configure each port. */ for (i = 0; PUC_PORT_VALID(sc->sc_desc, i); i++) { + barindex = PUC_PORT_BAR_INDEX(sc->sc_desc->ports[i].bar); bus_space_handle_t subregion_handle; + int is_console = 0; /* make sure the base address register is mapped */ - barindex = PUC_PORT_BAR_INDEX(sc->sc_desc->ports[i].bar); +#if NCOM > 0 + is_console = com_is_console(sc->sc_bar_mappings[barindex].t, + sc->sc_bar_mappings[barindex].a + + sc->sc_desc->ports[i].offset, &subregion_handle); + if (is_console) { + sc->sc_bar_mappings[barindex].mapped = 1; + sc->sc_bar_mappings[barindex].h = subregion_handle - + sc->sc_desc->ports[i].offset; /* XXX hack */ + } +#endif if (!sc->sc_bar_mappings[barindex].mapped) { - printf("%s: %s port uses unmapped BAR (0x%x)\n", - device_xname(self), + aprint_error_dev(self, + "%s port uses unmapped BAR (0x%x)\n", puc_port_type_name(sc->sc_desc->ports[i].type), sc->sc_desc->ports[i].bar); continue; @@ -282,17 +287,13 @@ puc_attach(device_t parent, device_t self, void *aux) paa.pc = pa->pa_pc; paa.tag = pa->pa_tag; paa.intrhandle = intrhandle; - paa.a = sc->sc_bar_mappings[barindex].a; + paa.a = sc->sc_bar_mappings[barindex].a + + sc->sc_desc->ports[i].offset; paa.t = sc->sc_bar_mappings[barindex].t; paa.dmat = pa->pa_dmat; paa.dmat64 = pa->pa_dmat64; - if ( -#ifdef PUCCN - !com_is_console(sc->sc_bar_mappings[barindex].t, - sc->sc_bar_mappings[barindex].a, &subregion_handle) - && -#endif + if (!is_console && bus_space_subregion(sc->sc_bar_mappings[barindex].t, sc->sc_bar_mappings[barindex].h, sc->sc_desc->ports[i].offset, diff --git a/sys/dev/pci/puccn.c b/sys/dev/pci/puccn.c index 917e3a9642b..74b82bb13b3 100644 --- a/sys/dev/pci/puccn.c +++ b/sys/dev/pci/puccn.c @@ -1,4 +1,4 @@ -/* $NetBSD: puccn.c,v 1.10 2010/04/28 19:17:05 dyoung Exp $ */ +/* $NetBSD: puccn.c,v 1.11 2013/07/22 13:40:36 soren Exp $ */ /* * Derived from pci.c @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: puccn.c,v 1.10 2010/04/28 19:17:05 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: puccn.c,v 1.11 2013/07/22 13:40:36 soren Exp $"); #include "opt_kgdb.h" @@ -71,18 +71,6 @@ __KERNEL_RCSID(0, "$NetBSD: puccn.c,v 1.10 2010/04/28 19:17:05 dyoung Exp $"); #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE|CSTOPB|PARENB))|CS8) /* 8N1 */ #endif -#ifdef i386 /* Handle i386 directly */ -int -cpu_comcnprobe(struct consdev *cn, struct pci_attach_args *pa) -{ - pci_mode_detect(); - pa->pa_iot = x86_bus_space_io; - pa->pa_pc = 0; - pa->pa_tag = pci_make_tag(0, 0, 31, 0); - return 0; -} -#endif - cons_decl(com); static bus_addr_t puccnbase; @@ -110,9 +98,11 @@ pucprobe_doit(struct consdev *cn) pcireg_t base; /* Fetch our tags */ - if (cpu_comcnprobe(cn, &pa) != 0) { +#if defined(amd64) || defined(i386) + if (cpu_comcnprobe(cn, &pa) != 0) +#endif return 0; - } + puctag = pa.pa_iot; pci_decompose_tag(pa.pa_pc, pa.pa_tag, &bus, &maxdev, NULL); diff --git a/sys/dev/pci/puccn.h b/sys/dev/pci/puccn.h index ca0d137b8c3..51a756cb36d 100644 --- a/sys/dev/pci/puccn.h +++ b/sys/dev/pci/puccn.h @@ -1,4 +1,4 @@ -/* $NetBSD: puccn.h,v 1.4 2005/12/11 12:22:50 christos Exp $ */ +/* $NetBSD: puccn.h,v 1.5 2013/07/22 13:40:36 soren Exp $ */ /* * Derived from pci.c @@ -34,6 +34,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <dev/cons.h> /* * Machine independent support for PCI serial console support. |
