[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

libpciaccess: Changes to 'upstream-unstable'



 COPYING                  |   49 +
 Makefile.am              |    2 
 configure.ac             |   39 +
 src/Makefile.am          |    4 
 src/common_device_name.c |   39 +
 src/common_init.c        |    4 
 src/common_interface.c   |   18 
 src/freebsd_pci.c        |   14 
 src/linux_devmem.c       |    2 
 src/linux_sysfs.c        |   45 +
 src/netbsd_pci.c         |  409 ++++++++++++++
 src/openbsd_pci.c        |    7 
 src/pci_tools.h          |   47 -
 src/pciaccess_private.h  |    1 
 src/scanpci.c            |   19 
 src/scanpci.man          |   44 +
 src/solx_devfs.c         | 1334 +++++++++++++++++++++++++----------------------
 17 files changed, 1402 insertions(+), 675 deletions(-)

New commits:
commit 7aca9465a61934d57781352f4fcc42b779392cd0
Author: Julien Cristau <jcristau@debian.org>
Date:   Fri Oct 31 18:07:52 2008 +0100

    Bump to 0.10.5

diff --git a/configure.ac b/configure.ac
index 0064478..b15c4be 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,7 +40,7 @@ dnl refers to ${prefix}.  Thus we have to use `eval' twice.
 
 AC_PREREQ([2.57])
 
-AC_INIT(libpciaccess, 0.10.4, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=libpciaccess], libpciaccess)
+AC_INIT(libpciaccess, 0.10.5, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=libpciaccess], libpciaccess)
 AM_INIT_AUTOMAKE([dist-bzip2])
 AM_MAINTAINER_MODE
 

commit 8b0be8751279f9bc8f15ced4e5384fa2b0f78711
Author: Julien Cristau <jcristau@debian.org>
Date:   Fri Oct 31 17:33:50 2008 +0100

    Make --without-zlib work

diff --git a/configure.ac b/configure.ac
index ec39264..0064478 100644
--- a/configure.ac
+++ b/configure.ac
@@ -61,7 +61,7 @@ AC_DEFINE_DIR(PCIIDS_PATH, PCIIDS_PATH, [Path to pci.ids])
 
 AC_ARG_WITH(zlib,
 	AS_HELP_STRING([--with-zlib], [Enable zlib support to read gzip compressed pci.ids]),
-	[use_zlib="yes"],
+	[use_zlib="$withval"],
 	[use_zlib="no"])
 if test "x$use_zlib" = xyes; then
 	AC_CHECK_LIB(z, gzopen,

commit 7a5ed759f13c3fc5f379cce2ca02c9ebfae5eae9
Author: Robert Noland <rnoland@2hip.net>
Date:   Wed Oct 29 22:20:35 2008 -0400

    Fix FreeBSD systems which support pci domains.
    
    Support for FreeBSD based systems which support pci domains was broken
    in the commit to support kFreeBSD.  Include config.h so that things are
    happy again.

diff --git a/src/freebsd_pci.c b/src/freebsd_pci.c
index 352cac7..567b8f5 100644
--- a/src/freebsd_pci.c
+++ b/src/freebsd_pci.c
@@ -43,6 +43,7 @@
 #include <sys/mman.h>
 #include <sys/memrange.h>
 
+#include "config.h"
 #include "pciaccess.h"
 #include "pciaccess_private.h"
 

commit 067f979cbd410ddb82aee702d8434552e35c7154
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date:   Fri Oct 17 14:09:52 2008 -0700

    Version 0.10.4

diff --git a/configure.ac b/configure.ac
index 5c71758..ec39264 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,7 +40,7 @@ dnl refers to ${prefix}.  Thus we have to use `eval' twice.
 
 AC_PREREQ([2.57])
 
-AC_INIT(libpciaccess, 0.10.3, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=libpciaccess], libpciaccess)
+AC_INIT(libpciaccess, 0.10.4, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=libpciaccess], libpciaccess)
 AM_INIT_AUTOMAKE([dist-bzip2])
 AM_MAINTAINER_MODE
 

commit 714fef70e66b651e9a535d3d3cb20d055595a12d
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date:   Fri Oct 17 14:09:43 2008 -0700

    Add scanpci.man to EXTRA_DIST

diff --git a/Makefile.am b/Makefile.am
index 214721b..06b2bd0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -26,7 +26,7 @@ SUBDIRS = src
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = pciaccess.pc
 
-EXTRA_DIST = pciaccess.pc.in autogen.sh src/scanpci.c
+EXTRA_DIST = pciaccess.pc.in autogen.sh src/scanpci.c src/scanpci.man
 
 EXTRA_DIST += ChangeLog
 MAINTAINERCLEANFILES = ChangeLog

commit 77f274b6386301cb31c074061a8c947a78b49da9
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date:   Fri Oct 17 13:51:28 2008 -0700

    Update COPYING with the rest of the copyright/license notices from the code

diff --git a/COPYING b/COPYING
index 7ec9c42..b38c33e 100644
--- a/COPYING
+++ b/COPYING
@@ -1,4 +1,5 @@
-(C) Copyright IBM Corporation 2006
+(C) Copyright IBM Corporation 2006, 2007
+(C) Copyright Eric Anholt 2006
 All Rights Reserved.
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -22,7 +23,7 @@ IN THE SOFTWARE.
 
 ------------------------------------------------------------------------------
 
-Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+Copyright 2007, 2008 Sun Microsystems, Inc.  All rights reserved.
 
 Permission is hereby granted, free of charge, to any person obtaining a
 copy of this software and associated documentation files (the
@@ -48,3 +49,20 @@ Except as contained in this notice, the name of a copyright holder
 shall not be used in advertising or otherwise to promote the sale, use
 or other dealings in this Software without prior written authorization
 of the copyright holder.
+
+------------------------------------------------------------------------------
+
+Copyright (c) 2008 Juan Romero Pardines
+Copyright (c) 2008 Mark Kettenis
+
+Permission to use, copy, modify, and distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

commit 482d1da02498a6a31a6d829a5be41727f6333f94
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date:   Fri Oct 17 13:48:46 2008 -0700

    Add scanpci man page from Xorg

diff --git a/src/scanpci.man b/src/scanpci.man
new file mode 100644
index 0000000..aec7b2e
--- /dev/null
+++ b/src/scanpci.man
@@ -0,0 +1,44 @@
+.\" Copyright (C) 2000 The XFree86 Project, Inc.  All Rights Reserved.
+.\" 
+.\" Permission is hereby granted, free of charge, to any person obtaining a copy
+.\" of this software and associated documentation files (the "Software"), to
+.\" deal in the Software without restriction, including without limitation the
+.\" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+.\" sell copies of the Software, and to permit persons to whom the Software is
+.\" furnished to do so, subject to the following conditions:
+.\" 
+.\" The above copyright notice and this permission notice shall be included in
+.\" all copies or substantial portions of the Software.
+.\" 
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+.\" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+.\" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+.\" XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+.\" IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+.\" CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+.\" 
+.\" Except as contained in this notice, the name of the XFree86 Project shall
+.\" not be used in advertising or otherwise to promote the sale, use or other
+.\" dealings in this Software without prior written authorization from the
+.\" XFree86 Project.
+.\" 
+.TH SCANPCI 1 __xorgversion__
+.SH NAME
+scanpci - scan/probe PCI buses
+.SH SYNOPSIS
+.B scanpci
+.RB [ \-v ]
+.SH DESCRIPTION
+.I Scanpci
+is a utility that can be used to scan PCI buses and report information
+about the configuration space settings for each PCI device.
+On most platforms,
+.I scanpci
+can only be run by the root user.
+.SH OPTIONS
+.TP 8
+.B \-v
+Print the configuration space information for each device in a verbose
+format.  Without this option, only a brief description is printed for
+each device.
+

commit f537fc50e014063d1a1297bfd82680ae3f170281
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date:   Thu Oct 16 21:17:24 2008 -0700

    More minor Solaris cleanups

diff --git a/src/solx_devfs.c b/src/solx_devfs.c
index b9346fe..e184841 100644
--- a/src/solx_devfs.c
+++ b/src/solx_devfs.c
@@ -58,13 +58,10 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <sys/types.h>
-#include <sys/stat.h>
 #include <fcntl.h>
 #include <sys/mman.h>
-#include <dirent.h>
 #include <errno.h>
 #include <sys/pci.h>
-#include <assert.h>
 #include <libdevinfo.h>
 #include "pci_tools.h"
 
@@ -72,7 +69,7 @@
 #include "pciaccess_private.h"
 
 #define	MAX_DEVICES	256
-#define	CELL_NUMS_1275		(sizeof(pci_regspec_t)/sizeof(uint_t))
+#define	CELL_NUMS_1275	(sizeof(pci_regspec_t) / sizeof(uint_t))
 
 typedef union {
     uint8_t bytes[16 * sizeof (uint32_t)];
@@ -189,25 +186,14 @@ find_nexus_for_domain( int domain )
     return NULL;
 }
 
-static uint32_t
-get_config_hdr_value(pci_conf_hdr_t *config_hdr_p, uint16_t offset,
-		     uint8_t size)
-{
-    uint32_t value = 0;
-
-    while (size-- > 0) {
-	value = (value << 8) + config_hdr_p->bytes[offset + size];
-    }
-
-    return value;
-}
-
-#define GET_CONFIG_VAL_8(offset) \
-	(config_hdr.bytes[offset])
+#define GET_CONFIG_VAL_8(offset) (config_hdr.bytes[offset])
 #define GET_CONFIG_VAL_16(offset) \
-	(uint16_t)get_config_hdr_value(&config_hdr, offset, 2)
+    (uint16_t) (GET_CONFIG_VAL_8(offset) + (GET_CONFIG_VAL_8(offset+1) << 8))
 #define GET_CONFIG_VAL_32(offset) \
-	(uint32_t)get_config_hdr_value(&config_hdr, offset, 4)
+    (uint32_t) (GET_CONFIG_VAL_8(offset) + 		\
+		(GET_CONFIG_VAL_8(offset+1) << 8) +	\
+		(GET_CONFIG_VAL_8(offset+2) << 16) +	\
+		(GET_CONFIG_VAL_8(offset+3) << 24))
 
 /*
  * Release all the resources
@@ -217,9 +203,9 @@ static void
 pci_system_solx_devfs_destroy( void )
 {
     /*
-     * the memory allocated in create routines
-     * will be freed in pci_system_init
-     * It is more reasonable to free them here
+     * The memory allocated for pci_sys & devices in create routines
+     * will be freed in pci_system_cleanup.
+     * Need to free system-specific allocations here.
      */
     nexus_t *nexus, *next;
 
@@ -240,7 +226,7 @@ pci_system_solx_devfs_destroy( void )
  * Attempt to access PCI subsystem using Solaris's devfs interface.
  * Solaris version
  */
-int
+_pci_hidden int
 pci_system_solx_devfs_create( void )
 {
     int err = 0;
@@ -258,11 +244,12 @@ pci_system_solx_devfs_create( void )
      */
     if ((pci_sys = calloc(1, sizeof (struct pci_system))) != NULL) {
 	pci_sys->methods = &solx_devfs_methods;
+
 	if ((pci_sys->devices =
 	     calloc(MAX_DEVICES, sizeof (struct pci_device_private)))
 	    != NULL) {
-	    if ((di_node = di_init("/", DINFOCPYALL))
-		== DI_NODE_NIL) {
+
+	    if ((di_node = di_init("/", DINFOCPYALL)) == DI_NODE_NIL) {
 		err = errno;
 		(void) fprintf(stderr, "di_init() failed: %s\n",
 			       strerror(errno));
@@ -374,6 +361,7 @@ probe_dev(nexus_t *nexus, pcitool_reg_t *prg_p, struct pci_system *pci_sys)
 	prg_p->data = 0;
 	prg_p->user_version = PCITOOL_USER_VERSION;
 
+	errno = 0;
 	if (((rval = ioctl(nexus->fd, PCITOOL_DEVICE_GET_REG, prg_p)) != 0) ||
 	    (prg_p->data == 0xffffffff)) {
 
@@ -528,6 +516,7 @@ probe_nexus_node(di_node_t di_node, di_minor_t minor, void *arg)
     }
 
     snprintf(nexus_path, sizeof(nexus_path), "/devices%s", nexus_name);
+    di_devfs_path_free(nexus_name);
 
     if ((fd = open(nexus_path, O_RDWR)) >= 0) {
 	nexus->fd = fd;
@@ -546,7 +535,6 @@ probe_nexus_node(di_node_t di_node, di_minor_t minor, void *arg)
 		       nexus_path, strerror(errno));
 	free(nexus);
     }
-    di_devfs_path_free(nexus_name);
 
     return DI_WALK_CONTINUE;
 }
@@ -712,8 +700,8 @@ pci_device_solx_devfs_probe( struct pci_device * dev )
 	 * using libdevinfo
 	 */
 	if ((rnode = di_init("/", DINFOCPYALL)) == DI_NODE_NIL) {
-	    (void) fprintf(stderr, "di_init failed: %s\n", strerror(errno));
 	    err = errno;
+	    (void) fprintf(stderr, "di_init failed: %s\n", strerror(errno));
 	} else {
 	    args.bus = dev->bus;
 	    args.dev = dev->dev;
@@ -725,7 +713,7 @@ pci_device_solx_devfs_probe( struct pci_device * dev )
     }
     if (args.node != DI_NODE_NIL) {
 	/*
-	 * It will success for sure, because it was
+	 * It will succeed for sure, because it was
 	 * successfully called in find_target_node
 	 */
 	len = di_prop_lookup_ints(DDI_DEV_T_ANY, args.node,
@@ -809,35 +797,27 @@ pci_device_solx_devfs_probe( struct pci_device * dev )
 }
 
 /*
- * Solaris version: read the ROM data
+ * Solaris version: read the VGA ROM data
  */
 static int
 pci_device_solx_devfs_read_rom( struct pci_device * dev, void * buffer )
 {
-    void *prom = MAP_FAILED;
-
-    if (xsvc_fd < 0) {
-	if ((xsvc_fd = open("/dev/xsvc", O_RDWR)) < 0) {
-	    (void) fprintf(stderr, "can not open xsvc driver\n");
-
-	    return (-1);
+    int err;
+    struct pci_device_mapping prom = {
+	.base = 0xC0000,
+	.size = dev->rom_size,
+	.flags = 0
+    };
+    
+    err = pci_device_solx_devfs_map_range(dev, &prom);
+    if (err == 0) {
+	(void) bcopy(prom.memory, buffer, dev->rom_size);
+
+	if (munmap(prom.memory, dev->rom_size) == -1) {
+	    err = errno;
 	}
     }
-
-    prom = mmap(NULL, dev->rom_size,
-		PROT_READ, MAP_SHARED,
-		xsvc_fd, 0xC0000);
-
-    if (prom == MAP_FAILED) {
-	(void) fprintf(stderr, "map rom base =0xC0000 failed");
-	return (-1);
-    }
-    (void) bcopy(prom, buffer, dev->rom_size);
-
-    /*
-     * Still used xsvc to do the user space mapping
-     */
-    return (0);
+    return err;
 }
 
 /*
@@ -927,7 +907,7 @@ pci_device_solx_devfs_write( struct pci_device * dev, const void * data,
 	    cfg_prg.acc_attr = PCITOOL_ACC_ATTR_SIZE_8 + NATIVE_ENDIAN;
 	    break;
         default:
-	    assert(0);
+	    return EINVAL;
     }
     cfg_prg.bus_no = dev->bus;
     cfg_prg.dev_no = dev->dev;
@@ -971,10 +951,15 @@ pci_device_solx_devfs_map_range(struct pci_device *dev,
 			? (PROT_READ | PROT_WRITE) : PROT_READ;
     int err = 0;
 
+    /*
+     * Still used xsvc to do the user space mapping
+     */
     if (xsvc_fd < 0) {
 	if ((xsvc_fd = open("/dev/xsvc", O_RDWR)) < 0) {
-	    (void) fprintf(stderr, "can not open xsvc driver\n");
-	    return errno;
+	    err = errno;
+	    (void) fprintf(stderr, "can not open /dev/xsvc: %s\n",
+			   strerror(errno));
+	    return err;
 	}
     }
 
@@ -982,7 +967,8 @@ pci_device_solx_devfs_map_range(struct pci_device *dev,
     if (map->memory == MAP_FAILED) {
 	err = errno;
 
-	(void) fprintf(stderr, "map rom region =%llx failed", map->base);
+	(void) fprintf(stderr, "map rom region =%llx failed: %s\n",
+		       map->base, strerror(errno));
     }
 
     return err;

commit 9a5565c72c13aa107167c9c4a4469dd11ac13714
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date:   Thu Oct 16 18:18:09 2008 -0700

    Clean up formatting of solx_devfs.c

diff --git a/src/solx_devfs.c b/src/solx_devfs.c
index 9321bd2..b9346fe 100644
--- a/src/solx_devfs.c
+++ b/src/solx_devfs.c
@@ -23,7 +23,7 @@
  */
 /*
  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
- * 
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the
  * "Software"), to deal in the Software without restriction, including
@@ -33,7 +33,7 @@
  * copyright notice(s) and this permission notice appear in all copies of
  * the Software and that both the above copyright notice(s) and this
  * permission notice appear in supporting documentation.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
@@ -43,7 +43,7 @@
  * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- * 
+ *
  * Except as contained in this notice, the name of a copyright holder
  * shall not be used in advertising or otherwise to promote the sale, use
  * or other dealings in this Software without prior written authorization
@@ -73,27 +73,29 @@
 
 #define	MAX_DEVICES	256
 #define	CELL_NUMS_1275		(sizeof(pci_regspec_t)/sizeof(uint_t))
+
 typedef union {
-	uint8_t bytes[16 * sizeof (uint32_t)];
-	uint32_t dwords[16];
+    uint8_t bytes[16 * sizeof (uint32_t)];
+    uint32_t dwords[16];
 } pci_conf_hdr_t;
 
 typedef struct i_devnode {
-	uint8_t bus;
-	uint8_t dev;
-	uint8_t func;
-	di_node_t node;
+    uint8_t bus;
+    uint8_t dev;
+    uint8_t func;
+    di_node_t node;
 } i_devnode_t;
 
 typedef struct nexus {
-	int fd;
-	int domain;
-	struct nexus *next;
+    int fd;
+    int domain;
+    struct nexus *next;
 } nexus_t;
 
 static nexus_t *nexus_list = NULL;
 static int num_domains = 0;
 static int xsvc_fd = -1;
+
 /*
  * Read config space in native processor endianness.  Endian-neutral
  * processing can then take place.  On big endian machines, MSB and LSB
@@ -101,11 +103,11 @@ static int xsvc_fd = -1;
  * They are in correct order if read as big endian.
  */
 #if defined(__sparc)
-#define	NATIVE_ENDIAN	PCITOOL_ACC_ATTR_ENDN_BIG
+# define NATIVE_ENDIAN	PCITOOL_ACC_ATTR_ENDN_BIG
 #elif defined(__x86)
-#define	NATIVE_ENDIAN	PCITOOL_ACC_ATTR_ENDN_LTL
+# define NATIVE_ENDIAN	PCITOOL_ACC_ATTR_ENDN_LTL
 #else
-#error "ISA is neither __sparc nor __x86"
+# error "ISA is neither __sparc nor __x86"
 #endif
 
 /*
@@ -121,11 +123,11 @@ static int xsvc_fd = -1;
  * otherwise disappear.
  */
 #if (NATIVE_ENDIAN == PCITOOL_ACC_ATTR_ENDN_BIG)
-#define	U45_SB_DEVID_VID	0xb9104952
-#define	U45_SB_CLASS_RID	0x00000406
+# define U45_SB_DEVID_VID	0xb9104952
+# define U45_SB_CLASS_RID	0x00000406
 #else
-#define	U45_SB_DEVID_VID	0x524910b9
-#define	U45_SB_CLASS_RID	0x06040000
+# define U45_SB_DEVID_VID	0x524910b9
+# define U45_SB_CLASS_RID	0x06040000
 #endif
 
 #define	DEBUGON	0
@@ -146,27 +148,19 @@ static int pci_device_solx_devfs_write( struct pci_device * dev,
     const void * data, pciaddr_t offset, pciaddr_t size,
     pciaddr_t * bytes_written );
 
-static int
-probe_dev(nexus_t *nexus, pcitool_reg_t *prg_p, struct pci_system *pci_sys);
-
-static int
-do_probe(nexus_t *nexus, struct pci_system *pci_sys);
-
-static int 
-probe_nexus_node(di_node_t di_node, di_minor_t minor, void *arg);
+static int probe_dev(nexus_t *nexus, pcitool_reg_t *prg_p,
+		     struct pci_system *pci_sys);
 
-static void
-pci_system_solx_devfs_destroy( void );
+static int do_probe(nexus_t *nexus, struct pci_system *pci_sys);
 
-static int
-get_config_header(int fd, uint8_t bus_no, uint8_t dev_no, uint8_t func_no,
-    pci_conf_hdr_t *config_hdr_p);
-
-int
-pci_system_solx_devfs_create( void );
+static int probe_nexus_node(di_node_t di_node, di_minor_t minor, void *arg);
 
+static void pci_system_solx_devfs_destroy( void );
 
+static int get_config_header(int fd, uint8_t bus_no, uint8_t dev_no,
+			     uint8_t func_no, pci_conf_hdr_t *config_hdr_p);
 
+int pci_system_solx_devfs_create( void );
 
 static const struct pci_system_methods solx_devfs_methods = {
     .destroy = pci_system_solx_devfs_destroy,
@@ -185,27 +179,27 @@ static const struct pci_system_methods solx_devfs_methods = {
 static nexus_t *
 find_nexus_for_domain( int domain )
 {
-	nexus_t *nexus;
+    nexus_t *nexus;
 
-	for (nexus = nexus_list ; nexus != NULL ; nexus = nexus->next) {
-		if (nexus->domain == domain) {
-			return nexus;
-		}
+    for (nexus = nexus_list ; nexus != NULL ; nexus = nexus->next) {
+	if (nexus->domain == domain) {
+	    return nexus;
 	}
-	return NULL;
+    }
+    return NULL;
 }
 
 static uint32_t
 get_config_hdr_value(pci_conf_hdr_t *config_hdr_p, uint16_t offset,
 		     uint8_t size)
 {
-	uint32_t value = 0;
+    uint32_t value = 0;
 
-	while (size-- > 0) { 
-		value = (value << 8) + config_hdr_p->bytes[offset + size]; 
-	} 
+    while (size-- > 0) {
+	value = (value << 8) + config_hdr_p->bytes[offset + size];
+    }
 
-	return value;
+    return value;
 }
 
 #define GET_CONFIG_VAL_8(offset) \
@@ -222,24 +216,24 @@ get_config_hdr_value(pci_conf_hdr_t *config_hdr_p, uint16_t offset,
 static void
 pci_system_solx_devfs_destroy( void )
 {
-	/*
-	 * the memory allocated in create routines
-	 * will be freed in pci_system_init
-	 * It is more reasonable to free them here
-	 */
-	nexus_t *nexus, *next;
-	for (nexus = nexus_list ; nexus != NULL ; nexus = next) {
-		next = nexus->next;
-		close(nexus->fd);
-		free(nexus);
-	}
-	nexus_list = NULL;
-	
-	if (xsvc_fd >= 0) {
-		close(xsvc_fd);
-		xsvc_fd = -1;
-	}
-
+    /*
+     * the memory allocated in create routines
+     * will be freed in pci_system_init
+     * It is more reasonable to free them here
+     */
+    nexus_t *nexus, *next;
+
+    for (nexus = nexus_list ; nexus != NULL ; nexus = next) {
+	next = nexus->next;
+	close(nexus->fd);
+	free(nexus);
+    }
+    nexus_list = NULL;
+
+    if (xsvc_fd >= 0) {
+	close(xsvc_fd);
+	xsvc_fd = -1;
+    }
 }
 
 /*
@@ -249,53 +243,51 @@ pci_system_solx_devfs_destroy( void )
 int
 pci_system_solx_devfs_create( void )
 {
-	int err = 0;
-	di_node_t di_node; 
-
-
-	if (nexus_list != NULL) {
-		return 0;
-	}
-
-	/*
-	 * Only allow MAX_DEVICES exists
-	 * I will fix it later to get
-	 * the total devices first
-	 */
-	if ((pci_sys = calloc(1, sizeof (struct pci_system))) != NULL) {
-		pci_sys->methods = &solx_devfs_methods;
-		if ((pci_sys->devices =
-		     calloc(MAX_DEVICES, sizeof (struct pci_device_private)))
-		    != NULL) {
-			if ((di_node = di_init("/", DINFOCPYALL))
-			    == DI_NODE_NIL) { 
-				err = errno;
-				(void) fprintf(stderr,
-					       "di_init() failed: %s\n", 
-					       strerror(errno)); 
-			} else {
-				(void) di_walk_minor(di_node, DDI_NT_REGACC,
-						     0, pci_sys,
-						     probe_nexus_node);
-				di_fini(di_node); 
-			}
-		}
-		else {
-			err = errno;
-		}
-	} else {
+    int err = 0;
+    di_node_t di_node;
+
+
+    if (nexus_list != NULL) {
+	return 0;
+    }
+
+    /*
+     * Only allow MAX_DEVICES exists
+     * I will fix it later to get
+     * the total devices first
+     */
+    if ((pci_sys = calloc(1, sizeof (struct pci_system))) != NULL) {
+	pci_sys->methods = &solx_devfs_methods;
+	if ((pci_sys->devices =
+	     calloc(MAX_DEVICES, sizeof (struct pci_device_private)))
+	    != NULL) {
+	    if ((di_node = di_init("/", DINFOCPYALL))
+		== DI_NODE_NIL) {
 		err = errno;
+		(void) fprintf(stderr, "di_init() failed: %s\n",
+			       strerror(errno));
+	    } else {
+		(void) di_walk_minor(di_node, DDI_NT_REGACC, 0, pci_sys,
+				     probe_nexus_node);
+		di_fini(di_node);
+	    }
 	}
+	else {
+	    err = errno;
+	}
+    } else {
+	err = errno;
+    }
+
+    if (err != 0) {
+	if (pci_sys != NULL) {
+	    free(pci_sys->devices);
+	    free(pci_sys);
+	    pci_sys = NULL;
+	}
+    }
 
-	if (err != 0) {
-		if (pci_sys != NULL) {
-			free(pci_sys->devices);
-			free(pci_sys);
-			pci_sys = NULL;
-		}
-	}		
-	
-	return (err);
+    return (err);
 }
 
 /*
@@ -304,32 +296,31 @@ pci_system_solx_devfs_create( void )
  */
 static int
 get_config_header(int fd, uint8_t bus_no, uint8_t dev_no, uint8_t func_no,
-    pci_conf_hdr_t *config_hdr_p)
+		  pci_conf_hdr_t *config_hdr_p)
 {
-	pcitool_reg_t cfg_prg;
-	int i;
-	int rval = 0;
-
-	/* Prepare a local pcitool_reg_t so as to not disturb the caller's. */
-	cfg_prg.offset = 0;
-	cfg_prg.acc_attr = PCITOOL_ACC_ATTR_SIZE_4 + NATIVE_ENDIAN;
-	cfg_prg.bus_no = bus_no;
-	cfg_prg.dev_no = dev_no;
-	cfg_prg.func_no = func_no;
-	cfg_prg.barnum = 0;
-	cfg_prg.user_version = PCITOOL_USER_VERSION;
-
-	/* Get dwords 1-15 of config space. They must be read as uint32_t. */
-	for (i = 1; i < (sizeof (pci_conf_hdr_t) / sizeof (uint32_t)); i++) {
-		cfg_prg.offset += sizeof (uint32_t);
-		if ((rval =
-		    ioctl(fd, PCITOOL_DEVICE_GET_REG, &cfg_prg)) != 0) {
-			break;
-		}
-		config_hdr_p->dwords[i] = (uint32_t)cfg_prg.data;
+    pcitool_reg_t cfg_prg;
+    int i;
+    int rval = 0;
+
+    /* Prepare a local pcitool_reg_t so as to not disturb the caller's. */
+    cfg_prg.offset = 0;
+    cfg_prg.acc_attr = PCITOOL_ACC_ATTR_SIZE_4 + NATIVE_ENDIAN;
+    cfg_prg.bus_no = bus_no;
+    cfg_prg.dev_no = dev_no;
+    cfg_prg.func_no = func_no;
+    cfg_prg.barnum = 0;
+    cfg_prg.user_version = PCITOOL_USER_VERSION;
+
+    /* Get dwords 1-15 of config space. They must be read as uint32_t. */
+    for (i = 1; i < (sizeof (pci_conf_hdr_t) / sizeof (uint32_t)); i++) {
+	cfg_prg.offset += sizeof (uint32_t);
+	if ((rval = ioctl(fd, PCITOOL_DEVICE_GET_REG, &cfg_prg)) != 0) {
+	    break;
 	}
+	config_hdr_p->dwords[i] = (uint32_t)cfg_prg.data;
+    }
 
-	return (rval);
+    return (rval);
 }
 
 
@@ -339,229 +330,225 @@ get_config_header(int fd, uint8_t bus_no, uint8_t dev_no, uint8_t func_no,
 static int
 probe_dev(nexus_t *nexus, pcitool_reg_t *prg_p, struct pci_system *pci_sys)
 {
-	pci_conf_hdr_t	config_hdr;
-	boolean_t	multi_function_device;
-	int8_t		func;
-	int8_t		first_func = 0;
-	int8_t		last_func = PCI_REG_FUNC_M >> PCI_REG_FUNC_SHIFT;
-	int		rval = 0;
-	struct pci_device *pci_base;
+    pci_conf_hdr_t	config_hdr;
+    boolean_t		multi_function_device;
+    int8_t		func;
+    int8_t		first_func = 0;
+    int8_t		last_func = PCI_REG_FUNC_M >> PCI_REG_FUNC_SHIFT;
+    int			rval = 0;
+    struct pci_device *	pci_base;
+
+    /*
+     * Loop through at least func=first_func.  Continue looping through
+     * functions if there are no errors and the device is a multi-function
+     * device.
+     *
+     * (Note, if first_func == 0, header will show whether multifunction
+     * device and set multi_function_device.  If first_func != 0, then we
+     * will force the loop as the user wants a specific function to be
+     * checked.
+     */
+    for (func = first_func, multi_function_device = B_FALSE;
+	 ((func <= last_func) &&
+	  ((func == first_func) || (multi_function_device)));
+	 func++) {
+	prg_p->func_no = func;
 
 	/*
-	 * Loop through at least func=first_func.  Continue looping through
-	 * functions if there are no errors and the device is a multi-function
-	 * device.
+	 * Four things can happen here:
+	 *
+	 * 1) ioctl comes back as EFAULT and prg_p->status is
+	 *    PCITOOL_INVALID_ADDRESS.  There is no device at this location.
+	 *
+	 * 2) ioctl comes back successful and the data comes back as
+	 *    zero.  Config space is mapped but no device responded.
+	 *
+	 * 3) ioctl comes back successful and the data comes back as
+	 *    non-zero.  We've found a device.
 	 *
-	 * (Note, if first_func == 0, header will show whether multifunction
-	 * device and set multi_function_device.  If first_func != 0, then we
-	 * will force the loop as the user wants a specific function to be
-	 * checked.
+	 * 4) Some other error occurs in an ioctl.
 	 */
-	for (func = first_func, multi_function_device = B_FALSE;
-	    ((func <= last_func) &&
-		((func == first_func) || (multi_function_device)));
-	    func++) {
-		prg_p->func_no = func;
-
-		/*
-		 * Four things can happen here:
-		 *
-		 * 1) ioctl comes back as EFAULT and prg_p->status is
-		 *    PCITOOL_INVALID_ADDRESS.  There is no device at this
-		 *    location.
-		 *
-		 * 2) ioctl comes back successful and the data comes back as
-		 *    zero.  Config space is mapped but no device responded.
-		 *
-		 * 3) ioctl comes back successful and the data comes back as
-		 *    non-zero.  We've found a device.
-		 *
-		 * 4) Some other error occurs in an ioctl.
-		 */
-
-		prg_p->status = PCITOOL_SUCCESS;
-		prg_p->offset = 0;
-		prg_p->data = 0;
-		prg_p->user_version = PCITOOL_USER_VERSION;
-		if (((rval = ioctl(nexus->fd, PCITOOL_DEVICE_GET_REG, prg_p)) != 0) ||
-		    (prg_p->data == 0xffffffff)) {
-
-			/*
-			 * Accept errno == EINVAL along with status of
-			 * PCITOOL_OUT_OF_RANGE because some systems
-			 * don't implement the full range of config space.
-			 * Leave the loop quietly in this case.
-			 */
-			if ((errno == EINVAL) ||
-			    (prg_p->status == PCITOOL_OUT_OF_RANGE)) {
-				break;
-			}
-
-			/*
-			 * Exit silently with ENXIO as this means that there are
-			 * no devices under the pci root nexus.
-			 */
-			else if ((errno == ENXIO) &&
-			    (prg_p->status == PCITOOL_IO_ERROR)) {
-				break;
-			}
-
-			/*
-			 * Expect errno == EFAULT along with status of
-			 * PCITOOL_INVALID_ADDRESS because there won't be
-			 * devices at each stop.  Quit on any other error.
-			 */
-			else if (((errno != EFAULT) ||
-			    (prg_p->status != PCITOOL_INVALID_ADDRESS)) &&
-			    (prg_p->data != 0xffffffff)) {
-
-				break;
-
-			/*
-			 * If no function at this location,
-			 * just advance to the next function.
-			 */
-			} else {
-				rval = 0;
-			}
-
-		/*
-		 * Data came back as 0.
-		 * Treat as unresponsive device and check next device.
-		 */
-		} else if (prg_p->data == 0) {
-			rval = 0;
-			break;	/* Func loop. */
-
-		/* Found something. */
-		} else {
-			config_hdr.dwords[0] = (uint32_t)prg_p->data;
-
-			/* Get the rest of the PCI header. */
-			if ((rval = get_config_header(nexus->fd, prg_p->bus_no,
-			    prg_p->dev_no, prg_p->func_no, &config_hdr)) !=
-			    0) {
-				break;
-			}
-
-			/*
-			 * Special case for the type of Southbridge found on
-			 * Ultra-45 and other sun4u fire workstations.
-			 */
-			if ((config_hdr.dwords[0] == U45_SB_DEVID_VID) &&
-			    (config_hdr.dwords[2] == U45_SB_CLASS_RID)) {
-				rval = ECANCELED;
-				break;
-			}
-
-			/*
-			 * Found one device with bus number, device number and
-			 * function number.
-			 */
-
-			pci_base =
-				&pci_sys->devices[pci_sys->num_devices].base;
-			
-			/*


Reply to: