Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 Jul 2013 11:43:04 +0000 (UTC)
From:      Niclas Zeising <zeising@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r322221 - in head/devel/libpciaccess: . files
Message-ID:  <201307031143.r63Bh4FV047294@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: zeising
Date: Wed Jul  3 11:43:03 2013
New Revision: 322221
URL: http://svnweb.freebsd.org/changeset/ports/322221

Log:
  Give this a chance to work on sparc as well.
  
  Submitted by:	Marius Strobl
  Obtained from:	xorg development repo

Added:
  head/devel/libpciaccess/files/patch-src-common_init.c
     - copied unchanged from r319054, head/devel/libpciaccess/files/patch-src-common_init.c
  head/devel/libpciaccess/files/patch-src-pciaccess_private.h
     - copied unchanged from r319054, head/devel/libpciaccess/files/patch-src-pciaccess_private.h
Modified:
  head/devel/libpciaccess/Makefile
  head/devel/libpciaccess/files/patch-src-freebsd_pci.c

Modified: head/devel/libpciaccess/Makefile
==============================================================================
--- head/devel/libpciaccess/Makefile	Wed Jul  3 11:35:50 2013	(r322220)
+++ head/devel/libpciaccess/Makefile	Wed Jul  3 11:43:03 2013	(r322221)
@@ -2,7 +2,7 @@
 
 PORTNAME=	libpciaccess
 PORTVERSION=	0.13.1
-PORTREVISION=	2
+PORTREVISION=	3
 CATEGORIES=	devel
 
 MAINTAINER=	x11@FreeBSD.org

Copied: head/devel/libpciaccess/files/patch-src-common_init.c (from r319054, head/devel/libpciaccess/files/patch-src-common_init.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/libpciaccess/files/patch-src-common_init.c	Wed Jul  3 11:43:03 2013	(r322221, copy of r319054, head/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
+ }

Modified: head/devel/libpciaccess/files/patch-src-freebsd_pci.c
==============================================================================
--- head/devel/libpciaccess/files/patch-src-freebsd_pci.c	Wed Jul  3 11:35:50 2013	(r322220)
+++ head/devel/libpciaccess/files/patch-src-freebsd_pci.c	Wed Jul  3 11:43:03 2013	(r322221)
@@ -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
++}

Copied: head/devel/libpciaccess/files/patch-src-pciaccess_private.h (from r319054, head/devel/libpciaccess/files/patch-src-pciaccess_private.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/libpciaccess/files/patch-src-pciaccess_private.h	Wed Jul  3 11:43:03 2013	(r322221, copy of r319054, head/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 );



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201307031143.r63Bh4FV047294>