summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2011-05-10 17:56:34 -0400
committerJeremy Huddleston <jeremyhu@apple.com>2011-10-07 11:32:36 -0700
commit8cc9a8fe57adfb52abaa90a8a2ac2316de8eb898 (patch)
tree281c318d1598710c7bf2359338c5cda5c644dbb5
parente1a0240a3d6840b497845680c2bf6753415ba20f (diff)
downloadlibpciaccess-8cc9a8fe57adfb52abaa90a8a2ac2316de8eb898.tar.gz
Add map_legacy interface
This allows platforms to hand back mmaps of the low 1M (ISA) address space on a per-domain basis. Signed-off-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
-rw-r--r--include/pciaccess.h8
-rw-r--r--src/common_interface.c44
-rw-r--r--src/pciaccess_private.h4
3 files changed, 56 insertions, 0 deletions
diff --git a/include/pciaccess.h b/include/pciaccess.h
index 00ae6de..c457424 100644
--- a/include/pciaccess.h
+++ b/include/pciaccess.h
@@ -526,4 +526,12 @@ void pci_io_write32(struct pci_io_handle *handle, uint32_t reg, uint32_t data);
void pci_io_write16(struct pci_io_handle *handle, uint32_t reg, uint16_t data);
void pci_io_write8(struct pci_io_handle *handle, uint32_t reg, uint8_t data);
+/*
+ * Legacy memory access
+ */
+
+int pci_device_map_legacy(struct pci_device *dev, pciaddr_t base,
+ pciaddr_t size, unsigned map_flags, void **addr);
+int pci_device_unmap_legacy(struct pci_device *dev, void *addr, pciaddr_t size);
+
#endif /* PCIACCESS_H */
diff --git a/src/common_interface.c b/src/common_interface.c
index 94a0d21..6dccf8e 100644
--- a/src/common_interface.c
+++ b/src/common_interface.c
@@ -654,3 +654,47 @@ pci_device_enable(struct pci_device *dev)
if (pci_sys->methods->enable)
pci_sys->methods->enable(dev);
}
+
+/**
+ * Map the legacy memory space for the PCI domain containing \c dev.
+ *
+ * \param dev Device whose memory region is to be mapped.
+ * \param base Base address of the range to be mapped.
+ * \param size Size of the range to be mapped.
+ * \param map_flags Flag bits controlling how the mapping is accessed.
+ * \param addr Location to store the mapped address.
+ *
+ * \returns
+ * Zero on success or an \c errno value on failure.
+ */
+int
+pci_device_map_legacy(struct pci_device *dev, pciaddr_t base, pciaddr_t size,
+ unsigned map_flags, void **addr)
+{
+ if (base > 0x100000 || base + size > 0x100000)
+ return EINVAL;
+
+ if (!pci_sys->methods->map_legacy)
+ return ENOSYS;
+
+ return pci_sys->methods->map_legacy(dev, base, size, map_flags, addr);
+}
+
+/**
+ * Unmap the legacy memory space for the PCI domain containing \c dev.
+ *
+ * \param dev Device whose memory region is to be unmapped.
+ * \param addr Location of the mapped address.
+ * \param size Size of the range to be unmapped.
+ *
+ * \returns
+ * Zero on success or an \c errno value on failure.
+ */
+int
+pci_device_unmap_legacy(struct pci_device *dev, void *addr, pciaddr_t size)
+{
+ if (!pci_sys->methods->unmap_legacy)
+ return ENOSYS;
+
+ return pci_sys->methods->unmap_legacy(dev, addr, size);
+}
diff --git a/src/pciaccess_private.h b/src/pciaccess_private.h
index beaeaa7..1653b8b 100644
--- a/src/pciaccess_private.h
+++ b/src/pciaccess_private.h
@@ -77,6 +77,10 @@ struct pci_system_methods {
void (*write16)( struct pci_io_handle *handle, uint32_t reg,
uint16_t data );
void (*write8)( struct pci_io_handle *handle, uint32_t reg, uint8_t data );
+
+ int (*map_legacy)(struct pci_device *dev, pciaddr_t base, pciaddr_t size,
+ unsigned map_flags, void **addr);
+ int (*unmap_legacy)(struct pci_device *dev, void *addr, pciaddr_t size);
};
struct pci_device_mapping {