few users to pci_mapreg_info().
ok jsg@
-.\" $OpenBSD: pci_mapreg_map.9,v 1.1 2019/02/23 04:54:25 dlg Exp $
+.\" $OpenBSD: pci_mapreg_map.9,v 1.2 2023/04/13 15:07:42 miod Exp $
.\"
.\" Copyright (c) 2019 David Gwynne <dlg@openbsd.org>
.\" All rights reserved.
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: February 23 2019 $
+.Dd $Mdocdate: April 13 2023 $
.Dt PCI_MAPREG_MAP 9
.Os
.Sh NAME
.Nm pci_mapreg_info ,
.Nm pci_mapreg_probe ,
.Nm pci_mapreg_type
-.\" .Nm pci_mem_find ,
-.\" .Nm pci_io_find
.Nd PCI register mappings
.Sh SYNOPSIS
.In dev/pci/pcivar.h
.Fa "pcitag_t tag"
.Fa "int reg"
.Fc
-.\" .Ft int
-.\" .Fo pci_mem_find
-.\" .Fa "pci_chipset_tag_t pc"
-.\" .Fa "pcitag_t pcitag"
-.\" .Fa "int reg"
-.\" .Fa "bus_addr_t *basep"
-.\" .Fa "bus_size_t *sizep"
-.\" .Fa "int *cacheablep"
-.\" .Fc
-.\" .Ft int
-.\" .Fo pci_io_find
-.\" .Fa "pci_chipset_tag_t pc"
-.\" .Fa "pcitag_t pcitag"
-.\" .Fa "int reg"
-.\" .Fa "bus_addr_t *basep"
-.\" .Fa "bus_size_t *sizep"
-.\" .Fa "int *cacheablep"
-.\" .Fc
.Sh DESCRIPTION
These functions provide wrappers and helpers around
.Xr bus_space 9
-/* $OpenBSD: sti_pci_machdep.c,v 1.2 2009/04/10 17:11:27 miod Exp $ */
+/* $OpenBSD: sti_pci_machdep.c,v 1.3 2023/04/13 15:07:43 miod Exp $ */
/*
* Copyright (c) 2007, 2009 Miodrag Vallat.
* matches what PAGE0 says, then we are the console, and it
* doesn't matter which BAR matched.
*/
- for (bar = PCI_MAPREG_START; bar <= PCI_MAPREG_PPB_END; ) {
+ for (bar = PCI_MAPREG_START; bar <= PCI_MAPREG_PPB_END; bar += 4) {
cf = pci_conf_read(paa->pa_pc, paa->pa_tag, bar);
-
- if (PCI_MAPREG_TYPE(cf) == PCI_MAPREG_TYPE_IO) {
- rc = pci_io_find(paa->pa_pc, paa->pa_tag, bar, &addr,
- NULL);
+ rc = pci_mapreg_info(paa->pa_pc, paa->pa_tag, bar,
+ _PCI_MAPREG_TYPEBITS(cf), &addr, NULL, NULL);
+ if (PCI_MAPREG_TYPE(cf) == PCI_MAPREG_TYPE_MEM &&
+ PCI_MAPREG_MEM_TYPE(cf) == PCI_MAPREG_MEM_TYPE_64BIT)
bar += 4;
- } else {
- rc = pci_mem_find(paa->pa_pc, paa->pa_tag, bar, &addr,
- NULL, NULL);
- if (PCI_MAPREG_MEM_TYPE(cf) ==
- PCI_MAPREG_MEM_TYPE_64BIT)
- bar += 8;
- else
- bar += 4;
- }
if (rc == 0 &&
(hppa_hpa_t)addr == (hppa_hpa_t)PAGE0->mem_cons.pz_hpa)
-/* $OpenBSD: vgafb.c,v 1.64 2022/12/31 05:06:18 gkoehler Exp $ */
+/* $OpenBSD: vgafb.c,v 1.65 2023/04/13 15:07:43 miod Exp $ */
/* $NetBSD: vga.c,v 1.3 1996/12/02 22:24:54 cgd Exp $ */
/*
bus_addr_t ba;
bus_size_t bs;
int hasmem = 0, hasmmio = 0;
- uint32_t i, cf;
+ uint32_t bar, cf;
int rv;
/*
* For nvidia, this finds mmio 0x10 and frame memory 0x14.
* Some nvidias have a 3rd mem region 0x18, which we ignore.
*/
- for (i = PCI_MAPREG_START; i <= PCI_MAPREG_PPB_END; i += 4) {
- cf = pci_conf_read(pa->pa_pc, pa->pa_tag, i);
+ for (bar = PCI_MAPREG_START; bar <= PCI_MAPREG_PPB_END; bar += 4) {
+ cf = pci_conf_read(pa->pa_pc, pa->pa_tag, bar);
if (PCI_MAPREG_TYPE(cf) == PCI_MAPREG_TYPE_MEM) {
/* Memory mapping... frame memory or mmio? */
- rv = pci_mem_find(pa->pa_pc, pa->pa_tag, i,
- &ba, &bs, NULL);
+ rv = pci_mapreg_info(pa->pa_pc, pa->pa_tag, bar,
+ _PCI_MAPREG_TYPEBITS(cf), &ba, &bs, NULL);
if (rv != 0)
continue;
/* Ignore any other mem region. */
break;
}
+ if (PCI_MAPREG_MEM_TYPE(cf) ==
+ PCI_MAPREG_MEM_TYPE_64BIT)
+ bar += 4;
}
}
-/* $OpenBSD: vgafb.c,v 1.68 2022/07/15 17:57:26 kettenis Exp $ */
+/* $OpenBSD: vgafb.c,v 1.69 2023/04/13 15:07:43 miod Exp $ */
/*
* Copyright (c) 2001 Jason L. Wright (jason@thought.net)
bus_addr_t ba;
bus_size_t bs;
int hasio = 0, hasmem = 0, hasmmio = 0;
- u_int32_t i, cf;
+ u_int32_t bar, cf;
int rv;
- for (i = PCI_MAPREG_START; i <= PCI_MAPREG_PPB_END; i += 4) {
- cf = pci_conf_read(pa->pa_pc, pa->pa_tag, i);
+ for (bar = PCI_MAPREG_START; bar <= PCI_MAPREG_PPB_END; bar += 4) {
+ cf = pci_conf_read(pa->pa_pc, pa->pa_tag, bar);
if (PCI_MAPREG_TYPE(cf) == PCI_MAPREG_TYPE_IO) {
if (hasio)
continue;
- rv = pci_io_find(pa->pa_pc, pa->pa_tag, i,
- &sc->sc_io_addr, &sc->sc_io_size);
+ rv = pci_mapreg_info(pa->pa_pc, pa->pa_tag, bar,
+ _PCI_MAPREG_TYPEBITS(cf),
+ &sc->sc_io_addr, &sc->sc_io_size, NULL);
if (rv != 0) {
if (rv != ENOENT)
printf("%s: failed to find io at 0x%x\n",
- sc->sc_sunfb.sf_dev.dv_xname, i);
+ sc->sc_sunfb.sf_dev.dv_xname, bar);
continue;
}
hasio = 1;
} else {
/* Memory mapping... frame memory or mmio? */
- rv = pci_mem_find(pa->pa_pc, pa->pa_tag, i,
- &ba, &bs, NULL);
+ rv = pci_mapreg_info(pa->pa_pc, pa->pa_tag, bar,
+ _PCI_MAPREG_TYPEBITS(cf), &ba, &bs, NULL);
if (rv != 0) {
if (rv != ENOENT)
printf("%s: failed to find mem at 0x%x\n",
- sc->sc_sunfb.sf_dev.dv_xname, i);
+ sc->sc_sunfb.sf_dev.dv_xname, bar);
continue;
}
sc->sc_mem_size = bs;
}
}
+ if (PCI_MAPREG_MEM_TYPE(cf) ==
+ PCI_MAPREG_MEM_TYPE_64BIT)
+ bar += 4;
}
}
-/* $OpenBSD: pci_map.c,v 1.32 2019/06/17 11:04:06 kettenis Exp $ */
+/* $OpenBSD: pci_map.c,v 1.33 2023/04/13 15:07:43 miod Exp $ */
/* $NetBSD: pci_map.c,v 1.7 2000/05/10 16:58:42 thorpej Exp $ */
/*-
return (0);
}
-int
-pci_io_find(pci_chipset_tag_t pc, pcitag_t pcitag, int reg,
- bus_addr_t *iobasep, bus_size_t *iosizep)
-{
- return (obsd_pci_io_find(pc, pcitag, reg, 0, iobasep, iosizep, 0));
-}
-
-int
-pci_mem_find(pci_chipset_tag_t pc, pcitag_t pcitag, int reg,
- bus_addr_t *membasep, bus_size_t *memsizep, int *cacheablep)
-{
- return (obsd_pci_mem_find(pc, pcitag, reg, -1, membasep, memsizep,
- cacheablep));
-}
-
pcireg_t
pci_mapreg_type(pci_chipset_tag_t pc, pcitag_t tag, int reg)
{
-/* $OpenBSD: pcivar.h,v 1.77 2022/01/04 20:43:44 deraadt Exp $ */
+/* $OpenBSD: pcivar.h,v 1.78 2023/04/13 15:07:43 miod Exp $ */
/* $NetBSD: pcivar.h,v 1.23 1997/06/06 23:48:05 thorpej Exp $ */
/*
bus_space_tag_t *, bus_space_handle_t *, bus_addr_t *,
bus_size_t *, bus_size_t);
-int pci_io_find(pci_chipset_tag_t, pcitag_t, int, bus_addr_t *,
- bus_size_t *);
-int pci_mem_find(pci_chipset_tag_t, pcitag_t, int, bus_addr_t *,
- bus_size_t *, int *);
-
int pci_get_capability(pci_chipset_tag_t, pcitag_t, int,
int *, pcireg_t *);
int pci_get_ht_capability(pci_chipset_tag_t, pcitag_t, int,
-/* $OpenBSD: ppb.c,v 1.71 2023/01/20 15:11:44 kettenis Exp $ */
+/* $OpenBSD: ppb.c,v 1.72 2023/04/13 15:07:43 miod Exp $ */
/* $NetBSD: ppb.c,v 1.16 1997/06/06 23:48:05 thorpej Exp $ */
/*
io_count++;
else
mem_count++;
+
+ if (type == (PCI_MAPREG_TYPE_MEM |
+ PCI_MAPREG_MEM_TYPE_64BIT))
+ reg += 4;
}
if (reg_rom != 0) {
-/* $OpenBSD: rtsx_pci.c,v 1.15 2022/03/11 18:00:51 mpi Exp $ */
+/* $OpenBSD: rtsx_pci.c,v 1.16 2023/04/13 15:07:43 miod Exp $ */
/*
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
bus_size_t size;
int flags;
int bar = RTSX_PCI_BAR;
+ pcireg_t type;
if ((pci_conf_read(pa->pa_pc, pa->pa_tag, RTSX_CFG_PCI)
& RTSX_CFG_ASIC) != 0) {
break;
}
- if (pci_mem_find(pa->pa_pc, pa->pa_tag, bar, NULL, NULL, NULL) != 0) {
+ type = pci_mapreg_type(pa->pa_pc, pa->pa_tag, bar);
+ if (pci_mapreg_info(pa->pa_pc, pa->pa_tag, bar, type, NULL, NULL,
+ NULL) != 0) {
printf("%s: can't find registers\n", sc->sc.sc_dev.dv_xname);
return;
}
-
- if (pci_mapreg_map(pa, bar, PCI_MAPREG_TYPE_MEM, 0, &iot, &ioh, NULL,
- &size, 0)) {
+ if (pci_mapreg_map(pa, bar, type, 0, &iot, &ioh, NULL, &size, 0)) {
printf("%s: can't map registers\n", sc->sc.sc_dev.dv_xname);
return;
}
-/* $OpenBSD: sti_pci.c,v 1.12 2023/04/03 18:59:47 miod Exp $ */
+/* $OpenBSD: sti_pci.c,v 1.13 2023/04/13 15:07:43 miod Exp $ */
/*
* Copyright (c) 2006, 2007, 2023 Miodrag Vallat.
{
bus_addr_t addr;
bus_size_t size;
- u_int32_t cf;
+ pcireg_t type;
int rc;
if (bar == 0) {
return EINVAL;
}
- cf = pci_conf_read(pa->pa_pc, pa->pa_tag, bar);
-
- if (PCI_MAPREG_TYPE(cf) == PCI_MAPREG_TYPE_IO) {
- rc = pci_io_find(pa->pa_pc, pa->pa_tag, bar,
- &addr, &size);
- } else {
- rc = pci_mem_find(pa->pa_pc, pa->pa_tag, bar,
- &addr, &size, NULL);
- }
+ type = pci_mapreg_type(pa->pa_pc, pa->pa_tag, bar);
+ rc = pci_mapreg_info(pa->pa_pc, pa->pa_tag, bar, type, &addr, &size,
+ NULL);
if (rc != 0) {
printf("%s: invalid bar %02x for region %d\n",
sc->sc_dev.dv_xname, bar, region);