PERFORCE change 54883 for review

Robert Watson rwatson at FreeBSD.org
Mon Jun 14 02:04:02 GMT 2004


http://perforce.freebsd.org/chv.cgi?CH=54883

Change 54883 by rwatson at rwatson_tislabs on 2004/06/14 02:02:31

	Integrate netperf_socket.

Affected files ...

.. //depot/projects/netperf_socket/sys/amd64/amd64/pmap.c#13 integrate
.. //depot/projects/netperf_socket/sys/amd64/conf/GENERIC#8 integrate
.. //depot/projects/netperf_socket/sys/amd64/include/pmap.h#9 integrate
.. //depot/projects/netperf_socket/sys/contrib/altq/altq/altq_subr.c#2 integrate
.. //depot/projects/netperf_socket/sys/crypto/des/des_ecb.c#2 integrate
.. //depot/projects/netperf_socket/sys/crypto/des/des_enc.c#2 integrate
.. //depot/projects/netperf_socket/sys/crypto/des/des_setkey.c#2 integrate
.. //depot/projects/netperf_socket/sys/dev/acpica/acpi.c#22 integrate
.. //depot/projects/netperf_socket/sys/dev/acpica/acpi_acad.c#7 integrate
.. //depot/projects/netperf_socket/sys/dev/acpica/acpi_button.c#5 integrate
.. //depot/projects/netperf_socket/sys/dev/acpica/acpi_cmbat.c#4 integrate
.. //depot/projects/netperf_socket/sys/dev/acpica/acpi_ec.c#9 integrate
.. //depot/projects/netperf_socket/sys/dev/acpica/acpi_isab.c#4 integrate
.. //depot/projects/netperf_socket/sys/dev/acpica/acpi_lid.c#5 integrate
.. //depot/projects/netperf_socket/sys/dev/acpica/acpi_pcib_acpi.c#5 integrate
.. //depot/projects/netperf_socket/sys/dev/acpica/acpi_resource.c#6 integrate
.. //depot/projects/netperf_socket/sys/dev/acpica/acpivar.h#14 integrate
.. //depot/projects/netperf_socket/sys/dev/sound/pci/emu10k1.c#6 integrate
.. //depot/projects/netperf_socket/sys/i386/i386/pmap.c#9 integrate
.. //depot/projects/netperf_socket/sys/net/if_fwsubr.c#3 integrate
.. //depot/projects/netperf_socket/sys/pc98/pc98/pc98gdc.c#4 integrate
.. //depot/projects/netperf_socket/sys/sys/_types.h#2 integrate
.. //depot/projects/netperf_socket/sys/sys/resource.h#4 integrate
.. //depot/projects/netperf_socket/sys/sys/types.h#5 integrate

Differences ...

==== //depot/projects/netperf_socket/sys/amd64/amd64/pmap.c#13 (text+ko) ====

@@ -75,7 +75,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/pmap.c,v 1.468 2004/06/13 19:48:38 alc Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/pmap.c,v 1.470 2004/06/14 01:17:50 alc Exp $");
 
 /*
  *	Manages physical address maps.
@@ -464,6 +464,7 @@
 	/*
 	 * Initialize the kernel pmap (which is statically allocated).
 	 */
+	PMAP_LOCK_INIT(kernel_pmap);
 	kernel_pmap->pm_pml4 = (pdp_entry_t *) (KERNBASE + KPML4phys);
 	kernel_pmap->pm_active = -1;	/* don't allow deactivation */
 	TAILQ_INIT(&kernel_pmap->pm_pvlist);
@@ -1035,6 +1036,7 @@
 	struct pmap *pmap;
 {
 
+	PMAP_LOCK_INIT(pmap);
 	pmap->pm_pml4 = (pml4_entry_t *)(KERNBASE + KPML4phys);
 	pmap->pm_active = 0;
 	TAILQ_INIT(&pmap->pm_pvlist);
@@ -1055,6 +1057,8 @@
 	vm_page_t pml4pg;
 	static vm_pindex_t color;
 
+	PMAP_LOCK_INIT(pmap);
+
 	/*
 	 * allocate the page directory page
 	 */
@@ -1306,6 +1310,7 @@
 	atomic_subtract_int(&cnt.v_wire_count, 1);
 	vm_page_free_zero(m);
 	vm_page_unlock_queues();
+	PMAP_LOCK_DESTROY(pmap);
 }
 
 static int
@@ -1675,6 +1680,7 @@
 #endif
 	mtx_assert(&vm_page_queue_mtx, MA_OWNED);
 	while ((pv = TAILQ_FIRST(&m->md.pv_list)) != NULL) {
+		PMAP_LOCK(pv->pv_pmap);
 		pv->pv_pmap->pm_stats.resident_count--;
 		pte = pmap_pte(pv->pv_pmap, pv->pv_va);
 		tpte = pte_load_clear(pte);
@@ -1702,6 +1708,7 @@
 		TAILQ_REMOVE(&m->md.pv_list, pv, pv_list);
 		m->md.pv_list_count--;
 		pmap_unuse_pt(pv->pv_pmap, pv->pv_va, pv->pv_ptem);
+		PMAP_UNLOCK(pv->pv_pmap);
 		free_pv_entry(pv);
 	}
 	vm_page_flag_clear(m, PG_WRITEABLE);
@@ -1733,6 +1740,7 @@
 
 	anychanged = 0;
 
+	PMAP_LOCK(pmap);
 	for (; sva < eva; sva = va_next) {
 
 		pml4e = pmap_pml4e(pmap, sva);
@@ -1810,6 +1818,7 @@
 	}
 	if (anychanged)
 		pmap_invalidate_all(pmap);
+	PMAP_UNLOCK(pmap);
 }
 
 /*
@@ -2183,6 +2192,7 @@
 	 * Wiring is not a hardware characteristic so there is no need to
 	 * invalidate TLB.
 	 */
+	PMAP_LOCK(pmap);
 	pte = pmap_pte(pmap, va);
 	if (wired && (*pte & PG_W) == 0) {
 		pmap->pm_stats.wired_count++;
@@ -2191,6 +2201,7 @@
 		pmap->pm_stats.wired_count--;
 		atomic_clear_long(pte, PG_W);
 	}
+	PMAP_UNLOCK(pmap);
 }
 
 
@@ -2438,6 +2449,7 @@
 	}
 #endif
 	mtx_assert(&vm_page_queue_mtx, MA_OWNED);
+	PMAP_LOCK(pmap);
 	for (pv = TAILQ_FIRST(&pmap->pm_pvlist); pv; pv = npv) {
 
 		if (pv->pv_va >= eva || pv->pv_va < sva) {
@@ -2498,6 +2510,7 @@
 		free_pv_entry(pv);
 	}
 	pmap_invalidate_all(pmap);
+	PMAP_UNLOCK(pmap);
 }
 
 /*
@@ -2530,10 +2543,13 @@
 			continue;
 		}
 #endif
+		PMAP_LOCK(pv->pv_pmap);
 		pte = pmap_pte(pv->pv_pmap, pv->pv_va);
 		if (*pte & PG_M) {
+			PMAP_UNLOCK(pv->pv_pmap);
 			return TRUE;
 		}
+		PMAP_UNLOCK(pv->pv_pmap);
 	}
 	return (FALSE);
 }
@@ -2593,6 +2609,7 @@
 		}
 #endif
 
+		PMAP_LOCK(pv->pv_pmap);
 		pte = pmap_pte(pv->pv_pmap, pv->pv_va);
 		pbits = *pte;
 		if (pbits & bit) {
@@ -2606,6 +2623,7 @@
 			}
 			pmap_invalidate_page(pv->pv_pmap, pv->pv_va);
 		}
+		PMAP_UNLOCK(pv->pv_pmap);
 	}
 	if (bit == PG_RW)
 		vm_page_flag_clear(m, PG_WRITEABLE);
@@ -2666,17 +2684,20 @@
 			if (!pmap_track_modified(pv->pv_va))
 				continue;
 
+			PMAP_LOCK(pv->pv_pmap);
 			pte = pmap_pte(pv->pv_pmap, pv->pv_va);
 
 			if (pte && ((v = pte_load(pte)) & PG_A) != 0) {
-				pte_store(pte, v & ~PG_A);
+				atomic_clear_long(pte, PG_A);
 				pmap_invalidate_page(pv->pv_pmap, pv->pv_va);
 
 				rtval++;
 				if (rtval > 4) {
+					PMAP_UNLOCK(pv->pv_pmap);
 					break;
 				}
 			}
+			PMAP_UNLOCK(pv->pv_pmap);
 		} while ((pv = pvn) != NULL && pv != pvf);
 	}
 

==== //depot/projects/netperf_socket/sys/amd64/conf/GENERIC#8 (text+ko) ====

@@ -16,7 +16,7 @@
 # If you are in doubt as to the purpose or necessity of a line, check first
 # in NOTES.
 #
-# $FreeBSD: src/sys/amd64/conf/GENERIC,v 1.410 2004/06/03 21:40:41 peter Exp $
+# $FreeBSD: src/sys/amd64/conf/GENERIC,v 1.411 2004/06/13 23:03:57 obrien Exp $
 
 machine		amd64
 cpu		HAMMER
@@ -28,6 +28,7 @@
 makeoptions	DEBUG=-g		# Build kernel with gdb(1) debug symbols
 
 options 	SCHED_ULE		# ULE scheduler
+options 	ADAPTIVE_MUTEXES	# mutexes first spin lock, then sleep
 options 	INET			# InterNETworking
 options 	INET6			# IPv6 communications protocols
 options 	FFS			# Berkeley Fast Filesystem

==== //depot/projects/netperf_socket/sys/amd64/include/pmap.h#9 (text+ko) ====

@@ -39,7 +39,7 @@
  *
  *	from: hp300: @(#)pmap.h	7.2 (Berkeley) 12/16/90
  *	from: @(#)pmap.h	7.4 (Berkeley) 5/12/91
- * $FreeBSD: src/sys/amd64/include/pmap.h,v 1.118 2004/06/13 03:44:11 alc Exp $
+ * $FreeBSD: src/sys/amd64/include/pmap.h,v 1.119 2004/06/14 01:17:50 alc Exp $
  */
 
 #ifndef _MACHINE_PMAP_H_
@@ -129,6 +129,8 @@
 
 #ifndef LOCORE
 
+#include <sys/_lock.h>
+#include <sys/_mutex.h>
 #include <sys/queue.h>
 
 typedef u_int64_t pd_entry_t;
@@ -218,6 +220,7 @@
 };
 
 struct pmap {
+	struct mtx		pm_mtx;
 	pml4_entry_t		*pm_pml4;	/* KVA of level 4 page table */
 	TAILQ_HEAD(,pv_entry)	pm_pvlist;	/* list of mappings in pmap */
 	u_int			pm_active;	/* active on cpus */
@@ -231,6 +234,17 @@
 #ifdef _KERNEL
 extern struct pmap	kernel_pmap_store;
 #define kernel_pmap	(&kernel_pmap_store)
+
+#define	PMAP_LOCK(pmap)		mtx_lock(&(pmap)->pm_mtx)
+#define	PMAP_LOCK_ASSERT(pmap, type) \
+				mtx_assert(&(pmap)->pm_mtx, (type))
+#define	PMAP_LOCK_DESTROY(pmap)	mtx_destroy(&(pmap)->pm_mtx)
+#define	PMAP_LOCK_INIT(pmap)	mtx_init(&(pmap)->pm_mtx, "pmap", \
+				    NULL, MTX_DEF)
+#define	PMAP_LOCKED(pmap)	mtx_owned(&(pmap)->pm_mtx)
+#define	PMAP_MTX(pmap)		(&(pmap)->pm_mtx)
+#define	PMAP_TRYLOCK(pmap)	mtx_trylock(&(pmap)->pm_mtx)
+#define	PMAP_UNLOCK(pmap)	mtx_unlock(&(pmap)->pm_mtx)
 #endif
 
 /*

==== //depot/projects/netperf_socket/sys/contrib/altq/altq/altq_subr.c#2 (text+ko) ====

@@ -1,4 +1,4 @@
-/*	$FreeBSD: src/sys/contrib/altq/altq/altq_subr.c,v 1.2 2004/06/12 00:57:20 mlaier Exp $	*/
+/*	$FreeBSD: src/sys/contrib/altq/altq/altq_subr.c,v 1.3 2004/06/13 22:52:38 mlaier Exp $	*/
 /*	$KAME: altq_subr.c,v 1.21 2003/11/06 06:32:53 kjc Exp $	*/
 
 /*
@@ -71,7 +71,9 @@
 
 /* machine dependent clock related includes */
 #ifdef __FreeBSD__
+#if __FreeBSD__ < 3
 #include "opt_cpu.h"	/* for FreeBSD-2.2.8 to get i586_ctr_freq */
+#endif
 #include <machine/clock.h>
 #endif
 #if defined(__i386__)

==== //depot/projects/netperf_socket/sys/crypto/des/des_ecb.c#2 (text+ko) ====

@@ -1,7 +1,7 @@
-/*	$FreeBSD: src/sys/crypto/des/des_ecb.c,v 1.5 2002/03/05 09:19:02 ume Exp $	*/
 /*	$KAME: des_ecb.c,v 1.6 2001/09/10 04:03:58 itojun Exp $	*/
 
 /* crypto/des/ecb_enc.c */
+
 /* Copyright (C) 1995-1998 Eric Young (eay at mincom.oz.au)
  * All rights reserved.
  *
@@ -48,6 +48,9 @@
  * [including the GNU Public Licence.]
  */
 
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/sys/crypto/des/des_ecb.c,v 1.6 2004/06/14 00:38:54 obrien Exp $");
+
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <crypto/des/des_locl.h>

==== //depot/projects/netperf_socket/sys/crypto/des/des_enc.c#2 (text+ko) ====

@@ -1,7 +1,7 @@
 /*	$KAME: des_enc.c,v 1.1 2001/09/10 04:03:58 itojun Exp $	*/
-/*	$FreeBSD: src/sys/crypto/des/des_enc.c,v 1.1 2002/03/05 09:19:02 ume Exp $	*/
 
 /* crypto/des/des_enc.c */
+
 /* Copyright (C) 1995-1998 Eric Young (eay at cryptsoft.com)
  * All rights reserved.
  *
@@ -59,6 +59,9 @@
  * [including the GNU Public Licence.]
  */
 
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/sys/crypto/des/des_enc.c,v 1.2 2004/06/14 00:38:54 obrien Exp $");
+
 #include <sys/types.h>
 #include <crypto/des/des_locl.h>
 

==== //depot/projects/netperf_socket/sys/crypto/des/des_setkey.c#2 (text+ko) ====

@@ -1,7 +1,7 @@
-/*	$FreeBSD: src/sys/crypto/des/des_setkey.c,v 1.6 2002/03/05 09:19:02 ume Exp $	*/
 /*	$KAME: des_setkey.c,v 1.7 2001/09/10 04:03:58 itojun Exp $	*/
 
 /* crypto/des/set_key.c */
+
 /* Copyright (C) 1995-1996 Eric Young (eay at mincom.oz.au)
  * All rights reserved.
  *
@@ -55,6 +55,10 @@
  * 1.1 added norm_expand_bits
  * 1.0 First working version
  */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/sys/crypto/des/des_setkey.c,v 1.7 2004/06/14 00:38:16 obrien Exp $");
+
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <crypto/des/des_locl.h>

==== //depot/projects/netperf_socket/sys/dev/acpica/acpi.c#22 (text+ko) ====

@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	$FreeBSD: src/sys/dev/acpica/acpi.c,v 1.158 2004/06/13 17:29:35 njl Exp $
+ *	$FreeBSD: src/sys/dev/acpica/acpi.c,v 1.159 2004/06/13 22:52:30 njl Exp $
  */
 
 #include "opt_acpi.h"
@@ -81,6 +81,9 @@
 struct mtx	acpi_mutex;
 #endif
 
+/* Local pools for managing system resources for ACPI child devices. */
+struct rman acpi_rman_io, acpi_rman_mem;
+
 struct acpi_quirks {
     char	*OemId;
     uint32_t	OemRevision;
@@ -111,10 +114,7 @@
 			uintptr_t *result);
 static int	acpi_write_ivar(device_t dev, device_t child, int index,
 			uintptr_t value);
-static int	acpi_set_resource(device_t dev, device_t child, int type,
-			int rid, u_long start, u_long count);
-static int	acpi_get_resource(device_t dev, device_t child, int type,
-			int rid, u_long *startp, u_long *countp);
+static struct resource_list *acpi_get_rlist(device_t dev, device_t child);
 static struct resource *acpi_alloc_resource(device_t bus, device_t child,
 			int type, int *rid, u_long start, u_long end,
 			u_long count, u_int flags);
@@ -162,8 +162,9 @@
     DEVMETHOD(bus_print_child,		acpi_print_child),
     DEVMETHOD(bus_read_ivar,		acpi_read_ivar),
     DEVMETHOD(bus_write_ivar,		acpi_write_ivar),
-    DEVMETHOD(bus_set_resource,		acpi_set_resource),
-    DEVMETHOD(bus_get_resource,		acpi_get_resource),
+    DEVMETHOD(bus_get_resource_list,	acpi_get_rlist),
+    DEVMETHOD(bus_set_resource,		bus_generic_rl_set_resource),
+    DEVMETHOD(bus_get_resource,		bus_generic_rl_get_resource),
     DEVMETHOD(bus_alloc_resource,	acpi_alloc_resource),
     DEVMETHOD(bus_release_resource,	acpi_release_resource),
     DEVMETHOD(bus_child_pnpinfo_str,	acpi_child_pnpinfo_str_method),
@@ -395,6 +396,20 @@
     bzero(sc, sizeof(*sc));
     sc->acpi_dev = dev;
 
+    /* Initialize resource manager. */
+    acpi_rman_io.rm_type = RMAN_ARRAY;
+    acpi_rman_io.rm_start = 0;
+    acpi_rman_io.rm_end = 0xffff;
+    acpi_rman_io.rm_descr = "I/O ports";
+    if (rman_init(&acpi_rman_io) != 0)
+	panic("acpi rman_init IO ports failed");
+    acpi_rman_mem.rm_type = RMAN_ARRAY;
+    acpi_rman_mem.rm_start = 0;
+    acpi_rman_mem.rm_end = ~0ul;
+    acpi_rman_mem.rm_descr = "I/O memory addresses";
+    if (rman_init(&acpi_rman_mem) != 0)
+	panic("acpi rman_init memory failed");
+
 #ifdef ACPI_DEBUGGER
     debugpoint = getenv("debug.acpi.debugger");
     if (debugpoint) {
@@ -824,56 +839,102 @@
 /*
  * Handle child resource allocation/removal
  */
-static int
-acpi_set_resource(device_t dev, device_t child, int type, int rid,
-		  u_long start, u_long count)
+static struct resource_list *
+acpi_get_rlist(device_t dev, device_t child)
 {
-    struct acpi_device		*ad = device_get_ivars(child);
-    struct resource_list	*rl = &ad->ad_rl;
+    struct acpi_device		*ad;
 
-    resource_list_add(rl, type, rid, start, start + count -1, count);
-
-    return(0);
-}
-
-static int
-acpi_get_resource(device_t dev, device_t child, int type, int rid,
-		  u_long *startp, u_long *countp)
-{
-    struct acpi_device		*ad = device_get_ivars(child);
-    struct resource_list	*rl = &ad->ad_rl;
-    struct resource_list_entry	*rle;
-
-    rle = resource_list_find(rl, type, rid);
-    if (!rle)
-	return(ENOENT);
-	
-    if (startp)
-	*startp = rle->start;
-    if (countp)
-	*countp = rle->count;
-
-    return (0);
+    ad = device_get_ivars(child);
+    return (&ad->ad_rl);
 }
 
 static struct resource *
 acpi_alloc_resource(device_t bus, device_t child, int type, int *rid,
-		    u_long start, u_long end, u_long count, u_int flags)
+    u_long start, u_long end, u_long count, u_int flags)
 {
     struct acpi_device *ad = device_get_ivars(child);
     struct resource_list *rl = &ad->ad_rl;
+    struct resource_list_entry *rle;
+    struct resource *res;
+    struct rman *rm;
+    int needactivate;
+
+    /*
+     * If this is an allocation of the "default" range for a given RID, and
+     * we know what the resources for this device are (i.e., they're on the
+     * child's resource list), use those start/end values.
+     */
+    if (start == 0UL && end == ~0UL) {
+	rle = resource_list_find(rl, type, *rid);
+	if (rle == NULL)
+	    return (NULL);
+	start = rle->start;
+	end = rle->end;
+	count = rle->count;
+    }
+
+    /* If we don't manage this address, pass the request up to the parent. */
+    rle = acpi_sysres_find(type, start);
+    if (rle == NULL) {
+	return (BUS_ALLOC_RESOURCE(device_get_parent(bus), child, type, rid,
+	    start, end, count, flags));
+    }
 
-    return (resource_list_alloc(rl, bus, child, type, rid, start, end, count,
-	    flags));
+    /* We only handle memory and IO resources through rman. */
+    switch (type) {
+    case SYS_RES_IOPORT:
+	rm = &acpi_rman_io;
+	break;
+    case SYS_RES_MEMORY:
+	rm = &acpi_rman_mem;
+	break;
+    default:
+	panic("acpi_alloc_resource: invalid res type %d", type);
+    }
+
+    /* If we do know it, allocate it from the local pool. */
+    needactivate = flags & RF_ACTIVE;
+    flags &= ~RF_ACTIVE;
+    res = rman_reserve_resource(rm, start, end, count, flags, child);
+    if (res == NULL)
+	return (NULL);
+
+    /* Copy the bus tag from the pre-allocated resource. */
+    rman_set_bustag(res, rman_get_bustag(rle->res));
+    if (type == SYS_RES_IOPORT)
+	rman_set_bushandle(res, res->r_start);
+
+    /* If requested, activate the resource using the parent's method. */
+    if (needactivate)
+	if (bus_activate_resource(child, type, *rid, res) != 0) {
+	    rman_release_resource(res);
+	    return (NULL);
+	}
+
+    return (res);
 }
 
 static int
-acpi_release_resource(device_t bus, device_t child, int type, int rid, struct resource *r)
+acpi_release_resource(device_t bus, device_t child, int type, int rid,
+    struct resource *r)
 {
-    struct acpi_device *ad = device_get_ivars(child);
-    struct resource_list *rl = &ad->ad_rl;
+    int ret;
+
+    /*
+     * If we know about this address, deactivate it and release it to the
+     * local pool.  If we don't, pass this request up to the parent.
+     */
+    if (acpi_sysres_find(type, rman_get_start(r)) == NULL) {
+	if (rman_get_flags(r) & RF_ACTIVE) {
+	    ret = bus_deactivate_resource(child, type, rid, r);
+	    if (ret != 0)
+		return (ret);
+	}
+	ret = rman_release_resource(r);
+    } else
+	ret = BUS_RELEASE_RESOURCE(device_get_parent(bus), child, type, rid, r);
 
-    return (resource_list_release(rl, bus, child, type, rid, r));
+    return (ret);
 }
 
 /* Allocate an IO port or memory resource, given its GAS. */
@@ -1043,8 +1104,8 @@
 {
     ACPI_HANDLE	parent;
     ACPI_STATUS	status;
+    int		i;
     static char	*scopes[] = {"\\_PR_", "\\_TZ_", "\\_SI", "\\_SB_", NULL};
-    int		i;
 
     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
     ACPI_ASSERTLOCK;
@@ -1091,6 +1152,28 @@
     return_VOID;
 }
 
+static int
+acpi_probe_order(ACPI_HANDLE handle, int level, int *order)
+{
+    int ret;
+
+    ret = 0;
+    /* IO port and memory system resource holders are first. */
+    if (acpi_MatchHid(handle, "PNP0C01") || acpi_MatchHid(handle, "PNP0C02")) {
+	*order = 1;
+	ret = 1;
+    }
+
+    /* The embedded controller is needed to handle accesses early. */
+    if (acpi_MatchHid(handle, "PNP0C09")) {
+	*order = 2;
+	ret = 1;
+    }
+
+    *order = (level + 1) * 10;
+    return (ret);
+}
+
 /*
  * Evaluate a child device and determine whether we might attach a device to
  * it.
@@ -1099,7 +1182,8 @@
 acpi_probe_child(ACPI_HANDLE handle, UINT32 level, void *context, void **status)
 {
     ACPI_OBJECT_TYPE	type;
-    device_t		child, bus = (device_t)context;
+    device_t		child, bus;
+    int			order, probe_now;
 
     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
 
@@ -1107,6 +1191,7 @@
     if (acpi_avoid(handle))
 	return_ACPI_STATUS (AE_OK);
 
+    bus = (device_t)context;
     if (ACPI_SUCCESS(AcpiGetType(handle, &type))) {
 	switch(type) {
 	case ACPI_TYPE_DEVICE:
@@ -1122,7 +1207,8 @@
 	     */
 	    ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "scanning '%s'\n",
 			     acpi_name(handle)));
-	    child = BUS_ADD_CHILD(bus, level * 10, NULL, -1);
+	    probe_now = acpi_probe_order(handle, level, &order);
+	    child = BUS_ADD_CHILD(bus, order, NULL, -1);
 	    if (child == NULL)
 		break;
 
@@ -1154,6 +1240,8 @@
 	    acpi_parse_resources(child, handle, &acpi_res_parse_set, NULL);
 
 	    /* If we're debugging, probe/attach now rather than later */
+	    if (probe_now)
+		device_probe_and_attach(child);
 	    ACPI_DEBUG_EXEC(device_probe_and_attach(child));
 	    break;
 	}
@@ -1342,13 +1430,12 @@
 }
 
 /*
- * Match a HID string against a device
+ * Match a HID string against a handle
  */
 BOOLEAN
-acpi_MatchHid(device_t dev, char *hid) 
+acpi_MatchHid(ACPI_HANDLE h, char *hid) 
 {
     ACPI_DEVICE_INFO	*devinfo;
-    ACPI_HANDLE		h;
     ACPI_BUFFER		buf;
     ACPI_STATUS		error;
     int			ret, i;
@@ -1356,15 +1443,13 @@
     ACPI_ASSERTLOCK;
 
     ret = FALSE;
-    if (hid == NULL)
-	return (FALSE);
-    if ((h = acpi_get_handle(dev)) == NULL)
-	return (FALSE);
+    if (hid == NULL || h == NULL)
+	return (ret);
     buf.Pointer = NULL;
     buf.Length = ACPI_ALLOCATE_BUFFER;
     error = AcpiGetObjectInfo(h, &buf);
     if (ACPI_FAILURE(error))
-	return (FALSE);
+	return (ret);
     devinfo = (ACPI_DEVICE_INFO *)buf.Pointer;
 
     if ((devinfo->Valid & ACPI_VALID_HID) != 0 &&

==== //depot/projects/netperf_socket/sys/dev/acpica/acpi_acad.c#7 (text+ko) ====

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/dev/acpica/acpi_acad.c,v 1.26 2004/05/30 20:08:23 phk Exp $
+ * $FreeBSD: src/sys/dev/acpica/acpi_acad.c,v 1.27 2004/06/13 22:52:30 njl Exp $
  */
 
 #include "opt_acpi.h"
@@ -137,7 +137,7 @@
 acpi_acad_probe(device_t dev)
 {
     if (acpi_get_type(dev) == ACPI_TYPE_DEVICE && !acpi_disabled("acad") &&
-	acpi_MatchHid(dev, "ACPI0003")) {
+	acpi_MatchHid(acpi_get_handle(dev), "ACPI0003")) {
 	device_set_desc(dev, "AC Adapter");
 	return (0);
     }

==== //depot/projects/netperf_socket/sys/dev/acpica/acpi_button.c#5 (text+ko) ====

@@ -25,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	$FreeBSD: src/sys/dev/acpica/acpi_button.c,v 1.26 2004/05/30 20:08:23 phk Exp $
+ *	$FreeBSD: src/sys/dev/acpica/acpi_button.c,v 1.27 2004/06/13 22:52:30 njl Exp $
  */
 
 #include "opt_acpi.h"
@@ -90,24 +90,26 @@
 acpi_button_probe(device_t dev)
 {
     struct acpi_button_softc	*sc;
+    ACPI_HANDLE h;
     int ret = ENXIO;
 
+    h = acpi_get_handle(dev);
     sc = device_get_softc(dev);
     if (acpi_get_type(dev) == ACPI_TYPE_DEVICE && !acpi_disabled("button")) {
-	if (acpi_MatchHid(dev, "PNP0C0C")) {
+	if (acpi_MatchHid(h, "PNP0C0C")) {
 	    device_set_desc(dev, "Power Button");
 	    sc->button_type = ACPI_POWER_BUTTON;
 	    ret = 0;
-	} else if (acpi_MatchHid(dev, "ACPI_FPB")) {
+	} else if (acpi_MatchHid(h, "ACPI_FPB")) {
 	    device_set_desc(dev, "Power Button (fixed)");
 	    sc->button_type = ACPI_POWER_BUTTON;
 	    sc->fixed = 1;
 	    ret = 0;
-	} else if (acpi_MatchHid(dev, "PNP0C0E")) {
+	} else if (acpi_MatchHid(h, "PNP0C0E")) {
 	    device_set_desc(dev, "Sleep Button");
 	    sc->button_type = ACPI_SLEEP_BUTTON;
 	    ret = 0;
-	} else if (acpi_MatchHid(dev, "ACPI_FSB")) {
+	} else if (acpi_MatchHid(h, "ACPI_FSB")) {
 	    device_set_desc(dev, "Sleep Button (fixed)");
 	    sc->button_type = ACPI_SLEEP_BUTTON;
 	    sc->fixed = 1;

==== //depot/projects/netperf_socket/sys/dev/acpica/acpi_cmbat.c#4 (text+ko) ====

@@ -25,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/dev/acpica/acpi_cmbat.c,v 1.29 2004/05/30 20:08:23 phk Exp $
+ * $FreeBSD: src/sys/dev/acpica/acpi_cmbat.c,v 1.30 2004/06/13 22:52:30 njl Exp $
  */
 
 #include "opt_acpi.h"
@@ -291,8 +291,8 @@
 static int
 acpi_cmbat_probe(device_t dev)
 {
-    if (acpi_get_type(dev) == ACPI_TYPE_DEVICE &&
-	!acpi_disabled("cmbat") && acpi_MatchHid(dev, "PNP0C0A")) {
+    if (acpi_get_type(dev) == ACPI_TYPE_DEVICE && !acpi_disabled("cmbat")
+	&& acpi_MatchHid(acpi_get_handle(dev), "PNP0C0A")) {
 
 	device_set_desc(dev, "Control Method Battery");
 	return (0);

==== //depot/projects/netperf_socket/sys/dev/acpica/acpi_ec.c#9 (text+ko) ====

@@ -25,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	$FreeBSD: src/sys/dev/acpica/acpi_ec.c,v 1.51 2004/05/30 20:08:23 phk Exp $
+ *	$FreeBSD: src/sys/dev/acpica/acpi_ec.c,v 1.52 2004/06/13 22:52:30 njl Exp $
  */
 /******************************************************************************
  *
@@ -137,7 +137,7 @@
  *****************************************************************************/
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_ec.c,v 1.51 2004/05/30 20:08:23 phk Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_ec.c,v 1.52 2004/06/13 22:52:30 njl Exp $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>
@@ -454,7 +454,7 @@
     if (DEV_ECDT(dev)) {
 	params = acpi_get_private(dev);
 	ret = 0;
-    } else if (acpi_MatchHid(dev, "PNP0C09")) {
+    } else if (acpi_MatchHid(acpi_get_handle(dev), "PNP0C09")) {
 	params = malloc(sizeof(struct acpi_ec_params), M_TEMP,
 			M_WAITOK | M_ZERO);
 	h = acpi_get_handle(dev);

==== //depot/projects/netperf_socket/sys/dev/acpica/acpi_isab.c#4 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_isab.c,v 1.7 2004/05/30 20:08:23 phk Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_isab.c,v 1.8 2004/06/13 22:52:30 njl Exp $");
 
 /*
  * ISA Bridge driver for Generic ISA Bus Devices.  See section 10.7 of the
@@ -90,11 +90,13 @@
 static int
 acpi_isab_probe(device_t dev)
 {
+	ACPI_HANDLE h;
 
+	h = acpi_get_handle(dev);
 	if (acpi_get_type(dev) == ACPI_TYPE_DEVICE &&
 	    !acpi_disabled("isa") &&
 	    devclass_get_device(isab_devclass, 0) == dev &&
-	    (acpi_MatchHid(dev, "PNP0A05") || acpi_MatchHid(dev, "PNP0A06"))) {
+	    (acpi_MatchHid(h, "PNP0A05") || acpi_MatchHid(h, "PNP0A06"))) {
 		device_set_desc(dev, "ACPI Generic ISA bridge");
 		return (0);
 	}

==== //depot/projects/netperf_socket/sys/dev/acpica/acpi_lid.c#5 (text+ko) ====

@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_lid.c,v 1.22 2004/05/30 20:08:23 phk Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_lid.c,v 1.23 2004/06/13 22:52:30 njl Exp $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>
@@ -82,7 +82,7 @@
 acpi_lid_probe(device_t dev)
 {
     if (acpi_get_type(dev) == ACPI_TYPE_DEVICE && !acpi_disabled("lid") &&
-	acpi_MatchHid(dev, "PNP0C0D")) {
+	acpi_MatchHid(acpi_get_handle(dev), "PNP0C0D")) {
 
 	device_set_desc(dev, "Control Method Lid Switch");
 	return (0);

==== //depot/projects/netperf_socket/sys/dev/acpica/acpi_pcib_acpi.c#5 (text+ko) ====

@@ -24,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	$FreeBSD: src/sys/dev/acpica/acpi_pcib_acpi.c,v 1.34 2004/05/30 20:08:23 phk Exp $
+ *	$FreeBSD: src/sys/dev/acpica/acpi_pcib_acpi.c,v 1.35 2004/06/13 22:52:30 njl Exp $
  */
 #include "opt_acpi.h"
 #include <sys/param.h>
@@ -117,7 +117,7 @@
 {
 
     if (acpi_get_type(dev) == ACPI_TYPE_DEVICE && !acpi_disabled("pci") &&
-	acpi_MatchHid(dev, "PNP0A03")) {
+	acpi_MatchHid(acpi_get_handle(dev), "PNP0A03")) {
 
 	if (pci_cfgregopen() == 0)
 		return (ENXIO);

==== //depot/projects/netperf_socket/sys/dev/acpica/acpi_resource.c#6 (text+ko) ====

@@ -26,12 +26,13 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_resource.c,v 1.24 2004/05/30 20:08:23 phk Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_resource.c,v 1.25 2004/06/13 22:52:30 njl Exp $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>
 #include <sys/kernel.h>
 #include <sys/bus.h>
+#include <sys/malloc.h>
 #include <sys/module.h>
 
 #include <machine/bus.h>
@@ -537,72 +538,125 @@
 }
 
 /*
- * Resource-owning placeholders.
+ * Resource-owning placeholders for IO and memory pseudo-devices.
  *
- * This code "owns" system resource objects that aren't
- * otherwise useful to devices, and which shouldn't be
- * considered "free".
- *
- * Note that some systems claim *all* of the physical address space
- * with a PNP0C01 device, so we cannot correctly "own" system memory
- * here (must be done in the SMAP handler on x86 systems, for
- * example).
+ * This code allocates system resource objects that will be owned by ACPI
+ * child devices.  Really, the acpi parent device should have the resources
+ * but this would significantly affect the device probe code.
  */
 
-static int	acpi_sysresource_probe(device_t dev);
-static int	acpi_sysresource_attach(device_t dev);
+static int	acpi_sysres_probe(device_t dev);
+static int	acpi_sysres_attach(device_t dev);
 
-static device_method_t acpi_sysresource_methods[] = {
+static device_method_t acpi_sysres_methods[] = {
     /* Device interface */
-    DEVMETHOD(device_probe,	acpi_sysresource_probe),
-    DEVMETHOD(device_attach,	acpi_sysresource_attach),
+    DEVMETHOD(device_probe,	acpi_sysres_probe),
+    DEVMETHOD(device_attach,	acpi_sysres_attach),
 
     {0, 0}
 };
 
-static driver_t acpi_sysresource_driver = {
+static driver_t acpi_sysres_driver = {
     "acpi_sysresource",
-    acpi_sysresource_methods,
+    acpi_sysres_methods,
     0,
 };
 
-static devclass_t acpi_sysresource_devclass;
-DRIVER_MODULE(acpi_sysresource, acpi, acpi_sysresource_driver,
-	      acpi_sysresource_devclass, 0, 0);
+static devclass_t acpi_sysres_devclass;
+DRIVER_MODULE(acpi_sysresource, acpi, acpi_sysres_driver, acpi_sysres_devclass,
+    0, 0);
 MODULE_DEPEND(acpi_sysresource, acpi, 1, 1, 1);
 
 static int
-acpi_sysresource_probe(device_t dev)
+acpi_sysres_probe(device_t dev)
 {
-    if (!acpi_disabled("sysresource") && acpi_MatchHid(dev, "PNP0C02"))
-	device_set_desc(dev, "System Resource");
-    else
+    ACPI_HANDLE h;
+
+    h = acpi_get_handle(dev);
+    if (acpi_disabled("sysresource") ||
+	(!acpi_MatchHid(h, "PNP0C01") && !acpi_MatchHid(h, "PNP0C02")))
 	return (ENXIO);
 
+    device_set_desc(dev, "System Resource");
     device_quiet(dev);
     return (-100);
 }
 
 static int
-acpi_sysresource_attach(device_t dev)
+acpi_sysres_attach(device_t dev)
 {
-    struct resource	*res;
-    int			i, rid;
+    device_t gparent;
+    struct resource *res;
+    struct rman *rm;
+    struct resource_list_entry *rle;
+    struct resource_list *rl;
 
     /*
-     * Suck up all the resources that might have been assigned to us.
-     * Note that it's impossible to tell the difference between a
-     * resource that someone else has claimed, and one that doesn't
-     * exist.
+     * Pre-allocate/manage all memory and IO resources.  We detect duplicates
+     * by setting rle->res to the resource we got from the parent.  We can't
+     * ignore them since rman can't handle duplicates.
      */
-    for (i = 0; i < 100; i++) {
-	rid = i;
-	res = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, 0);
-	rid = i;
-	res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, 0);
-	rid = i;
-	res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_SHAREABLE);
+    rl = BUS_GET_RESOURCE_LIST(device_get_parent(dev), dev);
+    SLIST_FOREACH(rle, rl, link) {
+	if (rle->res != NULL) {
+	    device_printf(dev, "duplicate resource for %lx\n", rle->start);
+	    continue;
+	}
+
+	/* Only memory and IO resources are valid here. */
+	switch (rle->type) {
+	case SYS_RES_IOPORT:
+	    rm = &acpi_rman_io;
+	    break;
+	case SYS_RES_MEMORY:
+	    rm = &acpi_rman_mem;
+	    break;
+	default:
+	    continue;
+	}
+
+	/* Pre-allocate resource and add to our rman pool. */
+	gparent = device_get_parent(device_get_parent(dev));
+	res = BUS_ALLOC_RESOURCE(gparent, dev, rle->type, &rle->rid,
+	    rle->start, rle->start + rle->count - 1, rle->count, 0);
+	if (res != NULL) {
+	    rman_manage_region(rm, rman_get_start(res), rman_get_end(res));
+	    rle->res = res;
+	}
     }
 
     return (0);
 }
+
+struct resource_list_entry *
+acpi_sysres_find(int type, u_long addr)
+{

>>> TRUNCATED FOR MAIL (1000 lines) <<<


More information about the p4-projects mailing list