--- a/open-src/lib/libpciaccess/Makefile Thu Feb 07 17:54:01 2013 -0800
+++ b/open-src/lib/libpciaccess/Makefile Mon Feb 18 17:09:57 2013 -0800
@@ -2,7 +2,7 @@
#
# libpciaccess Makefile
#
-# Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2008, 2013, Oracle and/or its affiliates. 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"),
@@ -43,7 +43,8 @@
scanpci_64bit.patch,-p1 \
sparc.patch \
nexus_devlist.patch,-p1 \
- rom_and_scanpci.patch,-p1
+ rom_and_scanpci.patch,-p1 \
+ sparc_domain.patch,-p1
# Library name
LIBNAME=libpciaccess
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/lib/libpciaccess/sparc_domain.patch Mon Feb 18 17:09:57 2013 -0800
@@ -0,0 +1,269 @@
+--- a/src/solx_devfs.c Fri Feb 15 12:42:00 2013
++++ b/src/solx_devfs.c Fri Feb 15 12:39:04 2013
+@@ -1,6 +1,6 @@
+ /*
+ * (C) Copyright IBM Corporation 2006
+- * Copyright (c) 2007, 2009, 2011, 2012, Oracle and/or its affiliates.
++ * Copyright (c) 2007, 2009, 2011, 2012, 2013 Oracle and/or its affiliates.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+@@ -71,11 +71,6 @@
+ char *path; /* for errors/debugging; fd is all we need */
+ char *dev_path;
+ struct nexus *next;
+-#ifdef __sparc
+- size_t *devlist;
+- volatile size_t num_allocated_elems;
+- volatile size_t num_devices;
+-#endif
+ } nexus_t;
+
+ typedef struct probe_info {
+@@ -102,6 +97,7 @@
+ static bdf_table_info_t *bdf_table = NULL;
+ static size_t num_bdfs = 0;
+ static size_t num_allocated_bdfs = 0;
++static size_t nexus_count = 0;
+ #endif
+
+ /*
+@@ -142,24 +138,7 @@
+ # define U45_SB_CLASS_RID 0x06040000
+ #endif
+
+-#ifdef __sparc
+ static nexus_t *
+-find_nexus_for_dev(struct pci_device *dev)
+-{
+- nexus_t *nexus;
+- int i;
+-
+- for (nexus = nexus_list ; nexus != NULL ; nexus = nexus->next) {
+- for (i = 0; i < nexus->num_devices; i++) {
+- size_t dev_idx = nexus->devlist[i];
+- if (&pci_sys->devices[dev_idx].base == dev)
+- return nexus;
+- }
+- }
+- return NULL;
+-}
+-#else
+-static nexus_t *
+ find_nexus_for_bus( int domain, int bus )
+ {
+ nexus_t *nexus;
+@@ -172,7 +151,6 @@
+ }
+ return NULL;
+ }
+-#endif
+
+ #define GET_CONFIG_VAL_8(offset) (config_hdr.bytes[offset])
+ #define GET_CONFIG_VAL_16(offset) \
+@@ -202,20 +180,6 @@
+ close(nexus->fd);
+ free(nexus->path);
+ free(nexus->dev_path);
+-#ifdef __sparc
+- {
+- struct pci_device *dev;
+- int i;
+-
+- for (i = 0; i < nexus->num_devices; i++) {
+- size_t dev_idx = nexus->devlist[i];
+- dev = &pci_sys->devices[dev_idx].base;
+- if (MAPPING_DEV_PATH(dev))
+- di_devfs_path_free((char *) MAPPING_DEV_PATH(dev));
+- }
+- }
+- free(nexus->devlist);
+-#endif
+ free(nexus);
+ }
+ nexus_list = NULL;
+@@ -231,7 +195,21 @@
+ #endif
+ }
+
++
++#ifdef __sparc
+ /*
++ * Release resources per device
++ */
++static void
++pci_system_solx_devfs_destroy_device( struct pci_device *dev )
++{
++ if (MAPPING_DEV_PATH(dev))
++ di_devfs_path_free((char *) MAPPING_DEV_PATH(dev));
++}
++#endif
++
++
++/*
+ * Retrieve first 16 dwords of device's config header, except for the first
+ * dword. First 16 dwords are defined by the PCI specification.
+ */
+@@ -456,8 +434,7 @@
+ * function number.
+ */
+
+- size_t dev_idx = pinfo->num_devices;
+- pci_base = &pinfo->devices[dev_idx].base;
++ pci_base = &pinfo->devices[pinfo->num_devices].base;
+
+ pci_base->domain = nexus->domain;
+ pci_base->bus = prg_p->bus_no;
+@@ -480,7 +457,7 @@
+ pci_base->subdevice_id = GET_CONFIG_VAL_16(PCI_CONF_SUBSYSID);
+ pci_base->irq = GET_CONFIG_VAL_8(PCI_CONF_ILINE);
+
+- pinfo->devices[dev_idx].header_type
++ pinfo->devices[pinfo->num_devices].header_type
+ = GET_CONFIG_VAL_8(PCI_CONF_HEADER);
+
+ #ifdef DEBUG
+@@ -510,25 +487,6 @@
+ pinfo->devices = new_devs;
+ }
+
+-#ifdef __sparc
+- nexus->devlist[nexus->num_devices++] = dev_idx;
+-
+- if (nexus->num_devices == nexus->num_allocated_elems) {
+- size_t *new_devs;
+- size_t new_num_elems = nexus->num_allocated_elems * 2;
+-
+- new_devs = realloc(nexus->devlist,
+- new_num_elems * sizeof (size_t *));
+- if (new_devs == NULL)
+- return (rval);
+- (void) memset(&new_devs[nexus->num_devices], 0,
+- nexus->num_allocated_elems *
+- sizeof (size_t *));
+- nexus->num_allocated_elems = new_num_elems;
+- nexus->devlist = new_devs;
+- }
+-#endif
+-
+ /*
+ * Accommodate devices which state their
+ * multi-functionality only in their function 0 config
+@@ -671,6 +629,9 @@
+ #endif
+ }
+ }
++#ifdef __sparc
++ domain = nexus_count;
++#else
+ else if (strcmp(prop_name, "pciseg") == 0) {
+ numval = di_prop_ints(prop, &ints);
+ if (numval == 1) {
+@@ -677,6 +638,7 @@
+ domain = ints[0];
+ }
+ }
++#endif
+ }
+
+ #ifdef __sparc
+@@ -716,15 +678,7 @@
+ nexus->domain = domain;
+
+ #ifdef __sparc
+- if ((nexus->devlist = calloc(INITIAL_NUM_DEVICES,
+- sizeof (size_t *))) == NULL) {
+- (void) fprintf(stderr, "Error allocating memory for nexus devlist: %s\n",
+- strerror(errno));
+- free (nexus);
+- return (DI_WALK_TERMINATE);
+- }
+- nexus->num_allocated_elems = INITIAL_NUM_DEVICES;
+- nexus->num_devices = 0;
++ nexus_count++;
+ #endif
+
+ nexus_name = di_devfs_minor_path(minor);
+@@ -875,11 +829,7 @@
+ (struct pci_device_private *) dev;
+ nexus_t *nexus;
+
+-#ifdef __sparc
+- if ( (nexus = find_nexus_for_dev(dev)) == NULL )
+-#else
+ if ( (nexus = find_nexus_for_bus(dev->domain, dev->bus)) == NULL )
+-#endif
+ return ENODEV;
+
+ /*
+@@ -1119,11 +1069,7 @@
+ int i = 0;
+ nexus_t *nexus;
+
+-#ifdef __sparc
+- nexus = find_nexus_for_dev(dev);
+-#else
+ nexus = find_nexus_for_bus(dev->domain, dev->bus);
+-#endif
+
+ *bytes_read = 0;
+
+@@ -1177,11 +1123,7 @@
+ int cmd;
+ nexus_t *nexus;
+
+-#ifdef __sparc
+- nexus = find_nexus_for_dev(dev);
+-#else
+ nexus = find_nexus_for_bus(dev->domain, dev->bus);
+-#endif
+
+ if ( bytes_written != NULL ) {
+ *bytes_written = 0;
+@@ -1366,7 +1308,11 @@
+
+ static const struct pci_system_methods solx_devfs_methods = {
+ .destroy = pci_system_solx_devfs_destroy,
++#ifdef __sparc
++ .destroy_device = pci_system_solx_devfs_destroy_device,
++#else
+ .destroy_device = NULL,
++#endif
+ .read_rom = pci_device_solx_devfs_read_rom,
+ .probe = pci_device_solx_devfs_probe,
+ .map_range = pci_device_solx_devfs_map_range,
+@@ -1427,6 +1373,9 @@
+ pinfo.num_allocated_elems = INITIAL_NUM_DEVICES;
+ pinfo.num_devices = 0;
+ pinfo.devices = devices;
++#ifdef __sparc
++ nexus_count = 0;
++#endif
+ (void) di_walk_minor(di_node, DDI_NT_REGACC, 0, &pinfo, probe_nexus_node);
+
+ di_fini(di_node);
+--- a/src/common_init.c Fri Dec 14 15:50:20 2012
++++ b/src/common_init.c Fri Dec 14 15:50:35 2012
+@@ -112,22 +112,14 @@
+ }
+ }
+
+-#ifdef __sparc
+- if ( pci_sys->methods->destroy != NULL ) {
+- (*pci_sys->methods->destroy)();
+- }
+-#endif
+-
+ free( pci_sys->devices );
+ pci_sys->devices = NULL;
+ pci_sys->num_devices = 0;
+ }
+
+-#ifndef __sparc
+ if ( pci_sys->methods->destroy != NULL ) {
+ (*pci_sys->methods->destroy)();
+ }
+-#endif
+
+ free( pci_sys );
+ pci_sys = NULL;