Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Jun 2013 23:36:00 +0000 (UTC)
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r321224 - in head/devel/libpciaccess: . files
Message-ID:  <201306182336.r5INa02D062630@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jkim
Date: Tue Jun 18 23:36:00 2013
New Revision: 321224
URL: http://svnweb.freebsd.org/changeset/ports/321224

Log:
  Update the legacy I/O patch to support ia64.

Modified:
  head/devel/libpciaccess/Makefile
  head/devel/libpciaccess/files/patch-src-freebsd_pci.c

Modified: head/devel/libpciaccess/Makefile
==============================================================================
--- head/devel/libpciaccess/Makefile	Tue Jun 18 23:03:14 2013	(r321223)
+++ head/devel/libpciaccess/Makefile	Tue Jun 18 23:36:00 2013	(r321224)
@@ -2,7 +2,7 @@
 
 PORTNAME=	libpciaccess
 PORTVERSION=	0.13.1
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	devel
 
 MAINTAINER=	x11@FreeBSD.org

Modified: head/devel/libpciaccess/files/patch-src-freebsd_pci.c
==============================================================================
--- head/devel/libpciaccess/files/patch-src-freebsd_pci.c	Tue Jun 18 23:03:14 2013	(r321223)
+++ head/devel/libpciaccess/files/patch-src-freebsd_pci.c	Tue Jun 18 23:36:00 2013	(r321224)
@@ -1,5 +1,5 @@
 --- src/freebsd_pci.c.orig	2012-04-09 13:02:57.000000000 -0400
-+++ src/freebsd_pci.c	2013-04-16 02:19:10.000000000 -0400
++++ src/freebsd_pci.c	2013-06-18 19:29:20.000000000 -0400
 @@ -1,6 +1,8 @@
  /*
   * (C) Copyright Eric Anholt 2006
@@ -9,153 +9,177 @@
   * All Rights Reserved.
   *
   * Permission is hereby granted, free of charge, to any person obtaining a
-@@ -561,6 +563,138 @@
-     freebsd_pci_sys = NULL;
- }
- 
+@@ -37,6 +39,11 @@
+ #include <unistd.h>
+ #include <fcntl.h>
+ #include <errno.h>
 +#if defined(__i386__) || defined(__amd64__)
 +#include <machine/cpufunc.h>
++#else
++#include <dev/io/iodev.h>
 +#endif
-+
+ #include <sys/types.h>
+ #include <sys/param.h>
+ #include <sys/pciio.h>
+@@ -561,6 +568,152 @@
+     freebsd_pci_sys = NULL;
+ }
+ 
 +static struct pci_io_handle *
-+pci_device_freebsd_open_legacy_io(struct pci_io_handle *ret,
-+    struct pci_device *dev, pciaddr_t base, pciaddr_t size)
-+{
-+#if defined(__i386__) || defined(__amd64__)
-+	ret->fd = open("/dev/io", O_RDWR | O_CLOEXEC);
-+
-+	if (ret->fd < 0)
-+		return NULL;
-+
-+	ret->base = base;
-+	ret->size = size;
-+	return ret;
-+#elif defined(PCI_MAGIC_IO_RANGE)
-+	ret->memory = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED,
-+	    aperturefd, PCI_MAGIC_IO_RANGE + base);
-+	if (ret->memory == MAP_FAILED)
-+		return NULL;
-+
-+	ret->base = base;
-+	ret->size = size;
-+	return ret;
++pci_device_freebsd_open_legacy_io( struct pci_io_handle *ret,
++				   struct pci_device *dev, pciaddr_t base,
++				   pciaddr_t size )
++{
++#if defined(PCI_MAGIC_IO_RANGE)
++    ret->memory = mmap( NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED,
++			aperturefd, PCI_MAGIC_IO_RANGE + base );
++    if ( ret->memory == MAP_FAILED )
++	return NULL;
 +#else
++    ret->fd = open( "/dev/io", O_RDWR | O_CLOEXEC );
++    if ( ret->fd < 0 )
 +	return NULL;
 +#endif
++    ret->base = base;
++    ret->size = size;
++    return ret;
 +}
 +
-+#if defined(__i386__) || defined(__amd64__)
 +static void
-+pci_device_freebsd_close_io(struct pci_device *dev, struct pci_io_handle *handle)
++pci_device_freebsd_close_io( struct pci_device *dev,
++			     struct pci_io_handle *handle )
 +{
-+	if (handle->fd > -1)
-+		close(handle->fd);
++    if ( handle->fd > -1 )
++	close( handle->fd );
 +}
-+#endif
 +
 +static uint32_t
-+pci_device_freebsd_read32(struct pci_io_handle *handle, uint32_t reg)
++pci_device_freebsd_read32( struct pci_io_handle *handle, uint32_t reg )
 +{
-+#if defined(__i386__) || defined(__amd64__)
-+	return inl(handle->base + reg);
-+#else
-+	return *(uint32_t *)((uintptr_t)handle->memory + reg);
++#if defined(PCI_MAGIC_IO_RANGE)
++    return *(uint32_t *)((uintptr_t)handle->memory + reg);
++#elif defined(__i386__) || defined(__amd64__)
++    return inl( handle->base + reg );
++#else
++    struct iodev_pio_req req = { IODEV_PIO_READ, handle->base + reg, 4, 0 };
++    if ( handle->fd > -1 )
++	ioctl( handle->fd, IODEV_PIO, &req );
++    return req.val;
 +#endif
 +}
 +
 +static uint16_t
-+pci_device_freebsd_read16(struct pci_io_handle *handle, uint32_t reg)
++pci_device_freebsd_read16( struct pci_io_handle *handle, uint32_t reg )
 +{
-+#if defined(__i386__) || defined(__amd64__)
-+	return inw(handle->base + reg);
-+#else
-+	return *(uint16_t *)((uintptr_t)handle->memory + reg);
++#if defined(PCI_MAGIC_IO_RANGE)
++    return *(uint16_t *)((uintptr_t)handle->memory + reg);
++#elif defined(__i386__) || defined(__amd64__)
++    return inw( handle->base + reg );
++#else
++    struct iodev_pio_req req = { IODEV_PIO_READ, handle->base + reg, 2, 0 };
++    if ( handle->fd > -1 )
++	ioctl( handle->fd, IODEV_PIO, &req );
++    return req.val;
 +#endif
 +}
 +
 +static uint8_t
-+pci_device_freebsd_read8(struct pci_io_handle *handle, uint32_t reg)
++pci_device_freebsd_read8( struct pci_io_handle *handle, uint32_t reg )
 +{
-+#if defined(__i386__) || defined(__amd64__)
-+	return inb(handle->base + reg);
-+#else
-+	return *(uint8_t *)((uintptr_t)handle->memory + reg);
++#if defined(PCI_MAGIC_IO_RANGE)
++    return *(uint8_t *)((uintptr_t)handle->memory + reg);
++#elif defined(__i386__) || defined(__amd64__)
++    return inb( handle->base + reg );
++#else
++    struct iodev_pio_req req = { IODEV_PIO_READ, handle->base + reg, 1, 0 };
++    if ( handle->fd > -1 )
++	ioctl( handle->fd, IODEV_PIO, &req );
++    return req.val;
 +#endif
 +}
 +
 +static void
-+pci_device_freebsd_write32(struct pci_io_handle *handle, uint32_t reg,
-+    uint32_t data)
++pci_device_freebsd_write32( struct pci_io_handle *handle, uint32_t reg,
++			    uint32_t data )
 +{
-+#if defined(__i386__) || defined(__amd64__)
-+	outl(handle->base + reg, data);
-+#else
-+	*(uint16_t *)((uintptr_t)handle->memory + reg) = data;
++#if defined(PCI_MAGIC_IO_RANGE)
++    *(uint32_t *)((uintptr_t)handle->memory + reg) = data;
++#elif defined(__i386__) || defined(__amd64__)
++    outl( handle->base + reg, data );
++#else
++    struct iodev_pio_req req = { IODEV_PIO_WRITE, handle->base + reg, 4, data };
++    if ( handle->fd > -1 )
++	ioctl( handle->fd, IODEV_PIO, &req );
 +#endif
 +}
 +
 +static void
-+pci_device_freebsd_write16(struct pci_io_handle *handle, uint32_t reg,
-+    uint16_t data)
++pci_device_freebsd_write16( struct pci_io_handle *handle, uint32_t reg,
++			    uint16_t data )
 +{
-+#if defined(__i386__) || defined(__amd64__)
-+	outw(handle->base + reg, data);
-+#else
-+	*(uint8_t *)((uintptr_t)handle->memory + reg) = data;
++#if defined(PCI_MAGIC_IO_RANGE)
++    *(uint16_t *)((uintptr_t)handle->memory + reg) = data;
++#elif defined(__i386__) || defined(__amd64__)
++    outw( handle->base + reg, data );
++#else
++    struct iodev_pio_req req = { IODEV_PIO_WRITE, handle->base + reg, 2, data };
++    if ( handle->fd > -1 )
++	ioctl( handle->fd, IODEV_PIO, &req );
 +#endif
 +}
 +
 +static void
-+pci_device_freebsd_write8(struct pci_io_handle *handle, uint32_t reg,
-+    uint8_t data)
++pci_device_freebsd_write8( struct pci_io_handle *handle, uint32_t reg,
++			   uint8_t data )
 +{
-+#if defined(__i386__) || defined(__amd64__)
-+	outb(handle->base + reg, data);
-+#else
-+	*(uint32_t *)((uintptr_t)handle->memory + reg) = data;
++#if defined(PCI_MAGIC_IO_RANGE)
++    *(uint8_t *)((uintptr_t)handle->memory + reg) = data;
++#elif defined(__i386__) || defined(__amd64__)
++    outb(handle->base + reg, data);
++#else
++    struct iodev_pio_req req = { IODEV_PIO_WRITE, handle->base + reg, 1, data };
++    if ( handle->fd > -1 )
++	ioctl( handle->fd, IODEV_PIO, &req );
 +#endif
 +}
 +
 +static int
-+pci_device_freebsd_map_legacy(struct pci_device *dev, pciaddr_t base,
-+    pciaddr_t size, unsigned map_flags, void **addr)
++pci_device_freebsd_map_legacy( struct pci_device *dev, pciaddr_t base,
++			       pciaddr_t size, unsigned map_flags, void **addr )
 +{
-+	struct pci_device_mapping map;
-+	int err;
++    struct pci_device_mapping map;
++    int err;
 +
-+	map.base = base;
-+	map.size = size;
-+	map.flags = map_flags;
-+	map.memory = NULL;
-+	err = pci_device_freebsd_map_range(dev, &map);
-+	*addr = map.memory;
-+
-+	return err;
++    map.base = base;
++    map.size = size;
++    map.flags = map_flags;
++    map.memory = NULL;
++    err = pci_device_freebsd_map_range( dev, &map );
++    *addr = map.memory;
++    return err;
 +}
 +
 +static int
-+pci_device_freebsd_unmap_legacy(struct pci_device *dev, void *addr,
-+    pciaddr_t size)
++pci_device_freebsd_unmap_legacy( struct pci_device *dev, void *addr,
++				 pciaddr_t size)
 +{
-+	struct pci_device_mapping map;
++    struct pci_device_mapping map;
 +
-+	map.memory = addr;
-+	map.size = size;
-+	map.flags = 0;
-+	return pci_device_freebsd_unmap_range(dev, &map);
++    map.memory = addr;
++    map.size = size;
++    map.flags = 0;
++    return pci_device_freebsd_unmap_range( dev, &map );
 +}
 +
  static const struct pci_system_methods freebsd_pci_methods = {
      .destroy = pci_system_freebsd_destroy,
      .destroy_device = NULL, /* nothing to do for this */
-@@ -571,6 +705,18 @@
+@@ -571,6 +724,16 @@
      .read = pci_device_freebsd_read,
      .write = pci_device_freebsd_write,
      .fill_capabilities = pci_fill_capabilities_generic,
 +    .open_legacy_io = pci_device_freebsd_open_legacy_io,
-+#if defined(__i386__) || defined(__amd64__)
 +    .close_io = pci_device_freebsd_close_io,
-+#endif
 +    .read32 = pci_device_freebsd_read32,
 +    .read16 = pci_device_freebsd_read16,
 +    .read8 = pci_device_freebsd_read8,



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