[PATCH libpciaccess 1/2] Add map_legacy interface
Mark Kettenis
mark.kettenis at xs4all.nl
Tue May 10 23:23:25 PDT 2011
> From: Adam Jackson <ajax at redhat.com>
> Date: Tue, 10 May 2011 17:56:34 -0400
>
> This allows platforms to hand back mmaps of the low 1M (ISA) address
> space on a per-domain basis.
Any reason why you chose to have an explicit "write_enable" flag
instead of using the standard "map_flags" used in the non-legacy
pci_device_map_range() interface?
> Signed-off-by: Adam Jackson <ajax at redhat.com>
> ---
> include/pciaccess.h | 8 ++++++++
> src/common_interface.c | 43 +++++++++++++++++++++++++++++++++++++++++++
> src/pciaccess_private.h | 3 +++
> 3 files changed, 54 insertions(+), 0 deletions(-)
>
> diff --git a/include/pciaccess.h b/include/pciaccess.h
> index 88515e2..b7795b9 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, int write_enable, 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 4af772a..fe3c1af 100644
> --- a/src/common_interface.c
> +++ b/src/common_interface.c
> @@ -32,6 +32,7 @@
> #include <stdlib.h>
> #include <string.h>
> #include <errno.h>
> +#include <sys/mman.h>
>
> #include "pciaccess.h"
> #include "pciaccess_private.h"
> @@ -654,3 +655,45 @@ 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 write_enable Map for writing (non-zero).
> + * \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,
> + int write_enable, void **addr)
> +{
> + if (base > 1048576 || base + size > 1048576)
> + return EINVAL;
> +
> + if (!pci_sys->methods->map_legacy)
> + return ENOSYS;
> +
> + return pci_sys->methods->map_legacy(dev, base, size, write_enable, 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)
> +{
> + /* Maybe vtable this? Meh. */
> + return munmap(addr, size);
> +}
> diff --git a/src/pciaccess_private.h b/src/pciaccess_private.h
> index 1111ef0..7870395 100644
> --- a/src/pciaccess_private.h
> +++ b/src/pciaccess_private.h
> @@ -77,6 +77,9 @@ 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,
> + int write_enable, void **addr);
> };
>
> struct pci_device_mapping {
> --
> 1.7.5
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
>
More information about the xorg-devel
mailing list