summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2020-06-17 01:15:33 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2020-06-17 01:15:33 +0000
commitb5c7a4ef7a2d0789ba4fa50126cfda273efd6b77 (patch)
treeba74753d93fabc4785b69bf0509857fd39761487
parentac3fe4983878f8e7a91e9506971cb40f1ffde4dc (diff)
sparc64 should define __HAVE_PCI_MSIX
-rw-r--r--sys/arch/sparc64/dev/pci_machdep.c42
-rw-r--r--sys/arch/sparc64/include/pci_machdep.h8
2 files changed, 48 insertions, 2 deletions
diff --git a/sys/arch/sparc64/dev/pci_machdep.c b/sys/arch/sparc64/dev/pci_machdep.c
index c5399013be9..71cb3abc527 100644
--- a/sys/arch/sparc64/dev/pci_machdep.c
+++ b/sys/arch/sparc64/dev/pci_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pci_machdep.c,v 1.49 2019/12/05 12:46:54 mpi Exp $ */
+/* $OpenBSD: pci_machdep.c,v 1.50 2020/06/17 01:15:32 dlg Exp $ */
/* $NetBSD: pci_machdep.c,v 1.22 2001/07/20 00:07:13 eeh Exp $ */
/*
@@ -611,3 +611,43 @@ pci_msix_enable(pci_chipset_tag_t pc, pcitag_t tag, bus_space_tag_t memt,
pci_conf_write(pc, tag, off, reg | PCI_MSIX_MC_MSIXE);
}
+int
+pci_msix_table_map(pci_chipset_tag_t pc, pcitag_t tag,
+ bus_space_tag_t memt, bus_space_handle_t *memh)
+{
+ bus_addr_t base;
+ pcireg_t reg, table, type;
+ int bir, offset;
+ int off, tblsz;
+
+ if (pci_get_capability(pc, tag, PCI_CAP_MSIX, &off, &reg) == 0)
+ panic("%s: no msix capability", __func__);
+
+ table = pci_conf_read(pc, tag, off + PCI_MSIX_TABLE);
+ bir = (table & PCI_MSIX_TABLE_BIR);
+ offset = (table & PCI_MSIX_TABLE_OFF);
+ tblsz = PCI_MSIX_MC_TBLSZ(reg) + 1;
+
+ bir = PCI_MAPREG_START + bir * 4;
+ type = pci_mapreg_type(pc, tag, bir);
+ if (pci_mapreg_info(pc, tag, bir, type, &base, NULL, NULL) ||
+ bus_space_map(memt, base + offset, tblsz * 16, 0, memh))
+ return (-1);
+
+ return (0);
+}
+
+void
+pci_msix_table_unmap(pci_chipset_tag_t pc, pcitag_t tag,
+ bus_space_tag_t memt, bus_space_handle_t memh)
+{
+ pcireg_t reg;
+ int tblsz;
+
+ if (pci_get_capability(pc, tag, PCI_CAP_MSIX, NULL, &reg) == 0)
+ panic("%s: no msix capability", __func__);
+
+ tblsz = PCI_MSIX_MC_TBLSZ(reg) + 1;
+
+ bus_space_unmap(memt, memh, tblsz * 16);
+}
diff --git a/sys/arch/sparc64/include/pci_machdep.h b/sys/arch/sparc64/include/pci_machdep.h
index b94a3154b86..ca3576ff2ee 100644
--- a/sys/arch/sparc64/include/pci_machdep.h
+++ b/sys/arch/sparc64/include/pci_machdep.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pci_machdep.h,v 1.36 2019/12/05 12:46:54 mpi Exp $ */
+/* $OpenBSD: pci_machdep.h,v 1.37 2020/06/17 01:15:32 dlg Exp $ */
/* $NetBSD: pci_machdep.h,v 1.7 2001/07/20 00:07:14 eeh Exp $ */
/*
@@ -39,6 +39,8 @@ struct pci_attach_args;
* define some bits used to glue into the common PCI code.
*/
+#define __HAVE_PCI_MSIX
+
typedef struct sparc_pci_chipset *pci_chipset_tag_t;
#define PCI_INTR_INTX 0x00000000
@@ -110,6 +112,10 @@ void pci_intr_disestablish(pci_chipset_tag_t, void *);
void pci_msi_enable(pci_chipset_tag_t, pcitag_t, bus_addr_t, int);
void pci_msix_enable(pci_chipset_tag_t, pcitag_t, bus_space_tag_t,
int, bus_addr_t, uint32_t);
+int pci_msix_table_map(pci_chipset_tag_t, pcitag_t,
+ bus_space_tag_t, bus_space_handle_t *);
+void pci_msix_table_unmap(pci_chipset_tag_t, pcitag_t,
+ bus_space_tag_t, bus_space_handle_t);
int sparc64_pci_enumerate_bus(struct pci_softc *,
int (*match)(struct pci_attach_args *),