diff options
author | zeising <zeising@FreeBSD.org> | 2013-07-03 19:43:03 +0800 |
---|---|---|
committer | zeising <zeising@FreeBSD.org> | 2013-07-03 19:43:03 +0800 |
commit | 672f6bd72cb4ba8b001f7709b67fc1c7307be08d (patch) | |
tree | 5aaa91d486788f4d52da25c2d28e029e65b35960 | |
parent | 71edc70bb6fce70db627df90afe1e634321f32ef (diff) | |
download | freebsd-ports-gnome-672f6bd72cb4ba8b001f7709b67fc1c7307be08d.tar.gz freebsd-ports-gnome-672f6bd72cb4ba8b001f7709b67fc1c7307be08d.tar.zst freebsd-ports-gnome-672f6bd72cb4ba8b001f7709b67fc1c7307be08d.zip |
Give this a chance to work on sparc as well.
Submitted by: Marius Strobl
Obtained from: xorg development repo
-rw-r--r-- | devel/libpciaccess/Makefile | 2 | ||||
-rw-r--r-- | devel/libpciaccess/files/patch-src-common_init.c | 13 | ||||
-rw-r--r-- | devel/libpciaccess/files/patch-src-freebsd_pci.c | 126 | ||||
-rw-r--r-- | devel/libpciaccess/files/patch-src-pciaccess_private.h | 10 |
4 files changed, 140 insertions, 11 deletions
diff --git a/devel/libpciaccess/Makefile b/devel/libpciaccess/Makefile index e111f7b1a7fa..e7724600f1dc 100644 --- a/devel/libpciaccess/Makefile +++ b/devel/libpciaccess/Makefile @@ -2,7 +2,7 @@ PORTNAME= libpciaccess PORTVERSION= 0.13.1 -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= devel MAINTAINER= x11@FreeBSD.org diff --git a/devel/libpciaccess/files/patch-src-common_init.c b/devel/libpciaccess/files/patch-src-common_init.c new file mode 100644 index 000000000000..d8028b2a4c2c --- /dev/null +++ b/devel/libpciaccess/files/patch-src-common_init.c @@ -0,0 +1,13 @@ +--- src/common_init.c.orig 2008-10-11 18:31:00.000000000 +0000 ++++ src/common_init.c 2009-03-29 20:10:52.000000000 +0000 +@@ -70,7 +70,9 @@ + void + pci_system_init_dev_mem(int fd) + { +-#ifdef __OpenBSD__ ++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) ++ pci_system_freebsd_init_dev_mem(fd); ++#elif defined(__OpenBSD__) + pci_system_openbsd_init_dev_mem(fd); + #endif + } diff --git a/devel/libpciaccess/files/patch-src-freebsd_pci.c b/devel/libpciaccess/files/patch-src-freebsd_pci.c index 5516325b3829..a72ec24108b7 100644 --- a/devel/libpciaccess/files/patch-src-freebsd_pci.c +++ b/devel/libpciaccess/files/patch-src-freebsd_pci.c @@ -21,7 +21,99 @@ #include <sys/types.h> #include <sys/param.h> #include <sys/pciio.h> -@@ -561,6 +568,152 @@ +@@ -72,6 +79,10 @@ + #define PCIM_BAR_MEM_SPACE 0 + #define PCIM_BAR_IO_SPACE 1 + ++#if defined(__sparc64__) ++static int screenfd; ++#endif ++ + /** + * FreeBSD private pci_system structure that extends the base pci_system + * structure. +@@ -103,12 +114,18 @@ + { + const int prot = ((map->flags & PCI_DEV_MAP_FLAG_WRITABLE) != 0) + ? (PROT_READ | PROT_WRITE) : PROT_READ; ++#if !defined(__sparc64__) + struct mem_range_desc mrd; + struct mem_range_op mro; ++#endif + + int fd, err = 0; + ++#if defined(__sparc64__) ++ fd = screenfd; ++#else + fd = open("/dev/mem", O_RDWR | O_CLOEXEC); ++#endif + if (fd == -1) + return errno; + +@@ -118,6 +135,7 @@ + err = errno; + } + ++#if !defined(__sparc64__) + mrd.mr_base = map->base; + mrd.mr_len = map->size; + strncpy(mrd.mr_owner, "pciaccess", sizeof(mrd.mr_owner)); +@@ -138,6 +156,7 @@ + } + + close(fd); ++#endif + + return err; + } +@@ -146,6 +165,7 @@ + pci_device_freebsd_unmap_range( struct pci_device *dev, + struct pci_device_mapping *map ) + { ++#if !defined(__sparc64__) + struct mem_range_desc mrd; + struct mem_range_op mro; + int fd; +@@ -171,6 +191,7 @@ + fprintf(stderr, "Failed to open /dev/mem\n"); + } + } ++#endif + + return pci_device_generic_unmap_range(dev, map); + } +@@ -293,7 +314,11 @@ + } + + printf("Using rom_base = 0x%lx\n", (long)rom_base); ++#if defined(__sparc64__) ++ memfd = screenfd; ++#else + memfd = open( "/dev/mem", O_RDONLY | O_CLOEXEC ); ++#endif + if ( memfd == -1 ) + return errno; + +@@ -306,7 +331,9 @@ + memcpy( buffer, bios, dev->rom_size ); + + munmap( bios, dev->rom_size ); ++#if !defined(__sparc64__) + close( memfd ); ++#endif + + if (pci_rom) { + pci_device_cfg_write_u32( dev, PCIR_BIOS, rom ); +@@ -341,7 +368,6 @@ + static int + pci_device_freebsd_probe( struct pci_device * dev ) + { +- struct pci_device_private *priv = (struct pci_device_private *) dev; + struct pci_bar_io bar; + uint8_t irq; + int err, i; +@@ -561,6 +587,154 @@ freebsd_pci_sys = NULL; } @@ -30,9 +122,9 @@ + struct pci_device *dev, pciaddr_t base, + pciaddr_t size ) +{ -+#if defined(PCI_MAGIC_IO_RANGE) ++#if defined(__sparc64__) + ret->memory = mmap( NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, -+ aperturefd, PCI_MAGIC_IO_RANGE + base ); ++ screenfd, base ); + if ( ret->memory == MAP_FAILED ) + return NULL; +#else @@ -49,14 +141,16 @@ +pci_device_freebsd_close_io( struct pci_device *dev, + struct pci_io_handle *handle ) +{ ++#if !defined(__sparc64__) + if ( handle->fd > -1 ) + close( handle->fd ); ++#endif +} + +static uint32_t +pci_device_freebsd_read32( struct pci_io_handle *handle, uint32_t reg ) +{ -+#if defined(PCI_MAGIC_IO_RANGE) ++#if defined(__sparc64__) + return *(uint32_t *)((uintptr_t)handle->memory + reg); +#elif defined(__i386__) || defined(__amd64__) + return inl( handle->base + reg ); @@ -71,7 +165,7 @@ +static uint16_t +pci_device_freebsd_read16( struct pci_io_handle *handle, uint32_t reg ) +{ -+#if defined(PCI_MAGIC_IO_RANGE) ++#if defined(__sparc64__) + return *(uint16_t *)((uintptr_t)handle->memory + reg); +#elif defined(__i386__) || defined(__amd64__) + return inw( handle->base + reg ); @@ -86,7 +180,7 @@ +static uint8_t +pci_device_freebsd_read8( struct pci_io_handle *handle, uint32_t reg ) +{ -+#if defined(PCI_MAGIC_IO_RANGE) ++#if defined(__sparc64__) + return *(uint8_t *)((uintptr_t)handle->memory + reg); +#elif defined(__i386__) || defined(__amd64__) + return inb( handle->base + reg ); @@ -102,7 +196,7 @@ +pci_device_freebsd_write32( struct pci_io_handle *handle, uint32_t reg, + uint32_t data ) +{ -+#if defined(PCI_MAGIC_IO_RANGE) ++#if defined(__sparc64__) + *(uint32_t *)((uintptr_t)handle->memory + reg) = data; +#elif defined(__i386__) || defined(__amd64__) + outl( handle->base + reg, data ); @@ -117,7 +211,7 @@ +pci_device_freebsd_write16( struct pci_io_handle *handle, uint32_t reg, + uint16_t data ) +{ -+#if defined(PCI_MAGIC_IO_RANGE) ++#if defined(__sparc64__) + *(uint16_t *)((uintptr_t)handle->memory + reg) = data; +#elif defined(__i386__) || defined(__amd64__) + outw( handle->base + reg, data ); @@ -132,7 +226,7 @@ +pci_device_freebsd_write8( struct pci_io_handle *handle, uint32_t reg, + uint8_t data ) +{ -+#if defined(PCI_MAGIC_IO_RANGE) ++#if defined(__sparc64__) + *(uint8_t *)((uintptr_t)handle->memory + reg) = data; +#elif defined(__i386__) || defined(__amd64__) + outb(handle->base + reg, data); @@ -174,7 +268,7 @@ static const struct pci_system_methods freebsd_pci_methods = { .destroy = pci_system_freebsd_destroy, .destroy_device = NULL, /* nothing to do for this */ -@@ -571,6 +724,16 @@ +@@ -571,6 +745,16 @@ .read = pci_device_freebsd_read, .write = pci_device_freebsd_write, .fill_capabilities = pci_fill_capabilities_generic, @@ -191,3 +285,15 @@ }; /** +@@ -644,3 +828,11 @@ + + return 0; + } ++ ++void ++pci_system_freebsd_init_dev_mem(int fd) ++{ ++#if defined(__sparc64__) ++ screenfd = fd; ++#endif ++} diff --git a/devel/libpciaccess/files/patch-src-pciaccess_private.h b/devel/libpciaccess/files/patch-src-pciaccess_private.h new file mode 100644 index 000000000000..2d9cb99c7123 --- /dev/null +++ b/devel/libpciaccess/files/patch-src-pciaccess_private.h @@ -0,0 +1,10 @@ +--- src/pciaccess_private.h.orig 2008-10-11 18:31:00.000000000 +0000 ++++ src/pciaccess_private.h 2009-03-29 20:07:50.000000000 +0000 +@@ -136,6 +136,7 @@ + + extern int pci_system_linux_sysfs_create( void ); + extern int pci_system_freebsd_create( void ); ++extern void pci_system_freebsd_init_dev_mem( int ); + extern int pci_system_netbsd_create( void ); + extern int pci_system_openbsd_create( void ); + extern void pci_system_openbsd_init_dev_mem( int ); |