Index: sys/boot/pc32/libi386/biosacpi.c
===================================================================
RCS file: /home/source/dragonfly/cvs/src/sys/boot/pc32/libi386/biosacpi.c,v
retrieving revision 1.4
diff -u -p -r1.4 biosacpi.c
--- sys/boot/pc32/libi386/biosacpi.c	16 Aug 2005 10:31:35 -0000	1.4
+++ sys/boot/pc32/libi386/biosacpi.c	10 Nov 2006 02:30:16 -0000
@@ -42,15 +42,15 @@
  * environment.
  */
 
-static RSDP_DESCRIPTOR	*biosacpi_find_rsdp(void);
-static RSDP_DESCRIPTOR	*biosacpi_search_rsdp(char *base, int length);
+static ACPI_TABLE_RSDP	*biosacpi_find_rsdp(void);
+static ACPI_TABLE_RSDP	*biosacpi_search_rsdp(char *base, int length);
 
 #define RSDP_CHECKSUM_LENGTH 20
 
 void
 biosacpi_detect(void)
 {
-    RSDP_DESCRIPTOR	*rsdp;
+    ACPI_TABLE_RSDP	*rsdp;
     char		buf[160];
     int			revision;
 
@@ -86,10 +86,10 @@ biosacpi_detect(void)
 /*
  * Find the RSDP in low memory.  See section 5.2.2 of the ACPI spec.
  */
-static RSDP_DESCRIPTOR *
+static ACPI_TABLE_RSDP *
 biosacpi_find_rsdp(void)
 {
-    RSDP_DESCRIPTOR	*rsdp;
+    ACPI_TABLE_RSDP	*rsdp;
     uint16_t		*addr;
 
     /* EBDA is the 1 KB addressed by the 16 bit pointer at 0x40E. */
@@ -104,19 +104,19 @@ biosacpi_find_rsdp(void)
     return (NULL);
 }
 
-static RSDP_DESCRIPTOR *
+static ACPI_TABLE_RSDP *
 biosacpi_search_rsdp(char *base, int length)
 {
-    RSDP_DESCRIPTOR	*rsdp;
+    ACPI_TABLE_RSDP	*rsdp;
     u_int8_t		*cp, sum;
     int			ofs, idx;
 
     /* search on 16-byte boundaries */
     for (ofs = 0; ofs < length; ofs += 16) {
-	rsdp = (RSDP_DESCRIPTOR *)(base + ofs);
+	rsdp = (ACPI_TABLE_RSDP *)(base + ofs);
 
 	/* compare signature, validate checksum */
-	if (!strncmp(rsdp->Signature, RSDP_SIG, strlen(RSDP_SIG))) {
+	if (!strncmp(rsdp->Signature, ACPI_SIG_RSDP, strlen(ACPI_SIG_RSDP))) {
 	    cp = (u_int8_t *)rsdp;
 	    sum = 0;
 	    for (idx = 0; idx < RSDP_CHECKSUM_LENGTH; idx++)
Index: sys/conf/acpi.mk
===================================================================
RCS file: /home/source/dragonfly/cvs/src/sys/conf/acpi.mk,v
retrieving revision 1.4
diff -u -p -r1.4 acpi.mk
--- sys/conf/acpi.mk	7 Nov 2006 06:43:22 -0000	1.4
+++ sys/conf/acpi.mk	7 Nov 2006 11:18:37 -0000
@@ -1,7 +1,7 @@
 # $DragonFly: src/sys/conf/acpi.mk,v 1.4 2006/11/07 06:43:22 dillon Exp $
 #
 
-ACPICA_VERSION=		20050309
+ACPICA_VERSION=		20060912
 ACPICA_DIR?=		contrib/dev/acpica-unix-${ACPICA_VERSION}
 OSACPI_MI_DIR?=		dev/acpica5
 OSACPI_MD_DIR?=		machine/${MACHINE}/acpica5
Index: sys/conf/files
===================================================================
RCS file: /home/source/dragonfly/cvs/src/sys/conf/files,v
retrieving revision 1.143
diff -u -p -r1.143 files
--- sys/conf/files	16 Nov 2006 13:43:55 -0000	1.143
+++ sys/conf/files	20 Nov 2006 05:29:27 -0000
@@ -1366,8 +1366,10 @@ ${OSACPI_MI_DIR}/acpi_powerres.c	optiona
 ${OSACPI_MI_DIR}/acpi_resource.c	optional acpi
 ${OSACPI_MI_DIR}/acpi_thermal.c		optional acpi
 ${OSACPI_MI_DIR}/acpi_timer.c		optional acpi
+${OSACPI_MI_DIR}/Osd/OsdCache.c		optional acpi
 ${OSACPI_MI_DIR}/Osd/OsdDebug.c		optional acpi
 ${OSACPI_MI_DIR}/Osd/OsdHardware.c	optional acpi
+${OSACPI_MI_DIR}/Osd/OsdInterface.c	optional acpi
 ${OSACPI_MI_DIR}/Osd/OsdInterrupt.c	optional acpi
 ${OSACPI_MI_DIR}/Osd/OsdMemory.c	optional acpi
 ${OSACPI_MI_DIR}/Osd/OsdSchedule.c	optional acpi
@@ -1444,6 +1446,7 @@ ${ACPICA_DIR}/interpreter/executer/exsto
 ${ACPICA_DIR}/interpreter/executer/exsystem.c	optional acpi
 ${ACPICA_DIR}/interpreter/executer/exutils.c	optional acpi
 ${ACPICA_DIR}/interpreter/parser/psargs.c	optional acpi
+${ACPICA_DIR}/interpreter/parser/psloop.c	optional acpi
 ${ACPICA_DIR}/interpreter/parser/psopcode.c	optional acpi
 ${ACPICA_DIR}/interpreter/parser/psparse.c	optional acpi
 ${ACPICA_DIR}/interpreter/parser/psscope.c	optional acpi
@@ -1471,6 +1474,7 @@ ${ACPICA_DIR}/resources/rsaddr.c		option
 ${ACPICA_DIR}/resources/rscalc.c		optional acpi
 ${ACPICA_DIR}/resources/rscreate.c		optional acpi
 ${ACPICA_DIR}/resources/rsdump.c		optional acpi
+${ACPICA_DIR}/resources/rsinfo.c		optional acpi
 ${ACPICA_DIR}/resources/rsio.c			optional acpi
 ${ACPICA_DIR}/resources/rsirq.c			optional acpi
 ${ACPICA_DIR}/resources/rslist.c		optional acpi
@@ -1478,11 +1482,9 @@ ${ACPICA_DIR}/resources/rsmemory.c		opti
 ${ACPICA_DIR}/resources/rsmisc.c		optional acpi
 ${ACPICA_DIR}/resources/rsutils.c		optional acpi
 ${ACPICA_DIR}/resources/rsxface.c		optional acpi
-${ACPICA_DIR}/tables/tbconvrt.c			optional acpi
-${ACPICA_DIR}/tables/tbget.c			optional acpi
-${ACPICA_DIR}/tables/tbgetall.c			optional acpi
+${ACPICA_DIR}/tables/tbfadt.c			optional acpi
+${ACPICA_DIR}/tables/tbfind.c			optional acpi
 ${ACPICA_DIR}/tables/tbinstal.c			optional acpi
-${ACPICA_DIR}/tables/tbrsdt.c			optional acpi
 ${ACPICA_DIR}/tables/tbutils.c			optional acpi
 ${ACPICA_DIR}/tables/tbxface.c			optional acpi
 ${ACPICA_DIR}/tables/tbxfroot.c			optional acpi
@@ -1496,5 +1498,8 @@ ${ACPICA_DIR}/utilities/utglobal.c		opti
 ${ACPICA_DIR}/utilities/utinit.c		optional acpi
 ${ACPICA_DIR}/utilities/utmath.c		optional acpi
 ${ACPICA_DIR}/utilities/utmisc.c		optional acpi
+${ACPICA_DIR}/utilities/utmutex.c		optional acpi
 ${ACPICA_DIR}/utilities/utobject.c		optional acpi
+${ACPICA_DIR}/utilities/utresrc.c		optional acpi
+${ACPICA_DIR}/utilities/utstate.c		optional acpi
 ${ACPICA_DIR}/utilities/utxface.c		optional acpi
Index: sys/dev/acpica5/Makefile
===================================================================
RCS file: /home/source/dragonfly/cvs/src/sys/dev/acpica5/Makefile,v
retrieving revision 1.14
diff -u -p -r1.14 Makefile
--- sys/dev/acpica5/Makefile	7 Nov 2006 06:43:23 -0000	1.14
+++ sys/dev/acpica5/Makefile	15 Nov 2006 14:58:55 -0000
@@ -1,10 +1,20 @@
 # $FreeBSD: src/sys/modules/acpi/acpi/Makefile,v 1.3 2004/01/08 16:38:32 njl Exp $
 # $DragonFly: src/sys/dev/acpica5/Makefile,v 1.14 2006/11/07 06:43:23 dillon Exp $
 
+CONTRIBDIR=	${SYSDIR}/${ACPICA_DIR}
+PATCHES=	include,acglobal.h.patch
+
 SYSDIR?= ${.CURDIR}/../..
+.if ACPI_DEBUG_LOCKS
+CFLAGS+=	-I${.OBJDIR}/include -DACPI_DEBUG_LOCKS=1
+PATCHES+=	include,acpiosxf.h.patch
+.endif
+
 .include "Makefile.inc"
 
-.PATH:	${SYSDIR}/${OSACPI_MD_DIR}			\
+.PATH:	${.OBJDIR}					\
+	${.OBJDIR}/include				\
+	${SYSDIR}/${OSACPI_MD_DIR}			\
 	${SYSDIR}/machine/${MACHINE}/isa		\
 	${SYSDIR}/bus/pci 				\
 	${.CURDIR}/Osd					\
@@ -13,6 +23,7 @@ SYSDIR?= ${.CURDIR}/../..
 
 KMOD	= acpi
 
+SRCS+=		${PATCHES}
 # ACPI CA sources
 SRCS+=	dsfield.c dsinit.c dsmethod.c dsmthdat.c
 SRCS+=	dsobject.c dsopcode.c dsutils.c dswexec.c dswload.c
@@ -27,15 +38,15 @@ SRCS+=	hwacpi.c hwgpe.c hwregs.c hwsleep
 SRCS+=	nsaccess.c nsalloc.c nsdump.c nseval.c nsinit.c
 SRCS+=	nsload.c nsnames.c nsobject.c nsparse.c nssearch.c
 SRCS+=	nsutils.c nswalk.c nsxfeval.c nsxfname.c nsxfobj.c
-SRCS+=	psargs.c psopcode.c psparse.c psscope.c
+SRCS+=	psargs.c psloop.c psopcode.c psparse.c psscope.c
 SRCS+=	pstree.c psutils.c pswalk.c psxface.c
-SRCS+=	rsaddr.c rscalc.c rscreate.c rsdump.c rsio.c
+SRCS+=	rsaddr.c rscalc.c rscreate.c rsdump.c rsinfo.c rsio.c
 SRCS+=	rsirq.c rslist.c rsmemory.c rsmisc.c rsutils.c
-SRCS+=	rsxface.c tbconvrt.c tbget.c tbgetall.c tbinstal.c
-SRCS+=	tbrsdt.c tbutils.c tbxface.c tbxfroot.c utalloc.c
+SRCS+=	rsxface.c tbfadt.c tbfind.c tbinstal.c
+SRCS+=	tbutils.c tbxface.c tbxfroot.c utalloc.c
 SRCS+=	utclib.c utcopy.c utdebug.c utdelete.c uteval.c
-SRCS+=	utglobal.c utinit.c utmath.c utmisc.c utobject.c
-SRCS+=	utxface.c
+SRCS+=	utglobal.c utinit.c utmath.c utmisc.c utmutex.c utobject.c
+SRCS+=	utresrc.c utstate.c utxface.c
 
 # OSD layer
 #
@@ -48,7 +59,7 @@ SRCS+=  acpi_package.c
 SRCS+=  acpi_powerres.c acpi_resource.c acpi_thermal.c
 SRCS+=  acpi_timer.c
 SRCS+=  OsdDebug.c
-SRCS+=  OsdHardware.c OsdInterrupt.c OsdMemory.c OsdSchedule.c
+SRCS+=  OsdHardware.c OsdInterface.c OsdInterrupt.c OsdMemory.c OsdSchedule.c
 SRCS+=  OsdStream.c OsdSynch.c OsdTable.c OsdEnvironment.c
 SRCS+=  opt_acpi.h opt_bus.h opt_ddb.h
 SRCS+=  device_if.h bus_if.h pci_if.h pcib_if.h isa_if.h
@@ -71,6 +82,12 @@ opt_ddb.h: Makefile
 opt_ddb.h: Makefile
 	echo -n > ${.TARGET}
 .endif
+.if ACPI_USE_LOCAL_CACHE
+CFLAGS+= -DACPI_USE_LOCAL_CACHE
+SRCS+=		utcache.c
+.else
+SRCS+=		OsdCache.c
+.endif
 
 # Machine-specific code such as sleep/wakeup
 SRCS+=	acpi_machdep.c acpi_wakecode.h acpi_wakeup.c
@@ -90,3 +107,7 @@ SUBDIR=	acpi_toshiba
 all: ${PROG} ${SUBDIR}
 
 .include <bsd.kmod.mk>
+
+# *.o files compiled from the patched C sources in the subdirectories of
+# ${OBJDIR} are placed right under ${OBJDIR}, not under each subdirectory
+OBJS:=		${OBJS:N*/*}
Index: sys/dev/acpica5/Makefile.inc
===================================================================
RCS file: /home/source/dragonfly/cvs/src/sys/dev/acpica5/Makefile.inc,v
retrieving revision 1.7
diff -u -p -r1.7 Makefile.inc
--- sys/dev/acpica5/Makefile.inc	16 Aug 2005 10:31:35 -0000	1.7
+++ sys/dev/acpica5/Makefile.inc	10 Nov 2006 08:06:36 -0000
@@ -3,6 +3,7 @@
 .include "${SYSDIR}/conf/acpi.mk"
 
 CFLAGS+=	-I${.OBJDIR}			\
+		-I${.OBJDIR}/include		\
 		-I${.CURDIR}			\
 		-I${SYSDIR}/${OSACPI_MI_DIR}	\
 		-I${SYSDIR}/${ACPICA_DIR}/include
Index: sys/dev/acpica5/acdragonfly.h
===================================================================
RCS file: /home/source/dragonfly/cvs/src/sys/dev/acpica5/acdragonfly.h,v
retrieving revision 1.2
diff -u -p -r1.2 acdragonfly.h
--- sys/dev/acpica5/acdragonfly.h	5 Jul 2004 00:07:35 -0000	1.2
+++ sys/dev/acpica5/acdragonfly.h	5 Nov 2006 10:55:32 -0000
@@ -123,6 +123,7 @@
 #include <platform/acgcc.h>
 #include <machine/acpica_machdep.h>
 
+#define ACPI_UINTPTR_T		uintptr_t
 #ifdef _KERNEL
 #include "opt_acpi.h"
 #endif
@@ -150,6 +151,13 @@
 #endif /* DDB */
 #endif /* ACPI_DEBUG_OUTPUT */
 
+#define ACPI_SPINLOCK	struct acpi_spinlock *
+struct acpi_spinlock;
+
+#ifndef ACPI_USE_LOCAL_CACHE
+#define ACPI_CACHE_T	struct acpicache
+struct acpicache;
+#endif
 #else /* _KERNEL */
 
 /* Not building kernel code, so use libc */
@@ -199,4 +207,5 @@ strstr(char *s, char *find)
 }
 #endif /* _KERNEL */
 
+#define inline		__inline
 #endif /* __ACDRAGONFLY_H_ */
Index: sys/dev/acpica5/acpi.c
===================================================================
RCS file: /home/source/dragonfly/cvs/src/sys/dev/acpica5/acpi.c,v
retrieving revision 1.24
diff -u -p -r1.24 acpi.c
--- sys/dev/acpica5/acpi.c	25 Oct 2006 20:55:52 -0000	1.24
+++ sys/dev/acpica5/acpi.c	7 Nov 2006 05:17:58 -0000
@@ -49,6 +49,7 @@
 #include <sys/rman.h>
 
 #include <sys/thread2.h>
+#include <sys/lock.h>
 
 #include <machine/clock.h>
 #include <machine/globaldata.h>
@@ -253,17 +254,6 @@ acpi_Startup(void)
 	return_VALUE (error);
     started = 1;
 
-#if __FreeBSD_version >= 500000
-    /* Initialise the ACPI mutex */
-    mtx_init(&acpi_mutex, "ACPI global lock", NULL, MTX_DEF);
-#endif
-
-    /*
-     * Set the globals from our tunables.  This is needed because ACPI-CA
-     * uses UINT8 for some values and we have no tunable_byte.
-     */
-    AcpiGbl_AllMethodsSerialized = (UINT8)acpi_serialize_methods;
-
     /* Start up the ACPI CA subsystem. */
 #ifdef ACPI_DEBUGGER
     debugpoint = kgetenv("debug.acpi.debugger");
@@ -273,23 +263,11 @@ acpi_Startup(void)
 	freeenv(debugpoint);
     }
 #endif
-    if (ACPI_FAILURE(error = AcpiInitializeSubsystem())) {
-	printf("ACPI: initialisation failed: %s\n", AcpiFormatException(error));
+    error = AcpiInitializeTables(NULL, 16, TRUE);
+    if (ACPI_FAILURE(error)) {
+	printf("ACPI: table initialization failed:\n");
 	return_VALUE (error);
     }
-#ifdef ACPI_DEBUGGER
-    debugpoint = kgetenv("debug.acpi.debugger");
-    if (debugpoint) {
-	if (!strcmp(debugpoint, "tables"))
-	    acpi_EnterDebugger();
-	freeenv(debugpoint);
-    }
-#endif
-
-    if (ACPI_FAILURE(error = AcpiLoadTables())) {
-	printf("ACPI: table load failed: %s\n", AcpiFormatException(error));
-	return_VALUE(error);
-    }
 
     /* Set up any quirks we have for this XSDT. */
     acpi_quirks_set();
@@ -341,16 +319,41 @@ acpi_identify(driver_t *driver, device_t
 }
 
 /*
+ * Get a mapping of the root table header, as ACPICA code no longer
+ * keeps local copy of RSDT/XSDT
+ *
+ * return value: if non-NULL, mapped physical address of root table header.
+ * caller is supposed to unmap the region by AcpiOsUnmapMemory()
+ */
+static ACPI_TABLE_HEADER *
+acpi_map_rsdt_header(void)
+{
+    ACPI_PHYSICAL_ADDRESS rsdp_addr, addr;
+    ACPI_TABLE_RSDP *rsdp;
+
+    if ((rsdp_addr = AcpiOsGetRootPointer()) == NULL)
+	return(NULL);
+    if ((rsdp = AcpiOsMapMemory(rsdp_addr, sizeof(*rsdp))) == NULL)
+	return(NULL);
+    if (rsdp->Revision > 1 && rsdp->XsdtPhysicalAddress)
+	addr = (ACPI_PHYSICAL_ADDRESS)rsdp->XsdtPhysicalAddress;
+    else
+	addr = (ACPI_PHYSICAL_ADDRESS)rsdp->RsdtPhysicalAddress;
+    AcpiOsUnmapMemory(rsdp, sizeof(*rsdp));
+
+    return AcpiOsMapMemory(addr, sizeof(ACPI_TABLE_HEADER));
+}
+
+/*
  * Fetch some descriptive data from ACPI to put in our attach message
  */
 static int
 acpi_probe(device_t dev)
 {
-    ACPI_TABLE_HEADER	th;
+    ACPI_TABLE_HEADER	*th;
     char		buf[20];
     int			error;
     struct sbuf		sb;
-    ACPI_STATUS		status;
     ACPI_LOCK_DECL;
 
     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
@@ -364,22 +367,25 @@ acpi_probe(device_t dev)
 
     ACPI_LOCK;
 
-    if (ACPI_FAILURE(status = AcpiGetTableHeader(ACPI_TABLE_XSDT, 1, &th))) {
-	device_printf(dev, "couldn't get XSDT header: %s\n",
-		      AcpiFormatException(status));
+    th = acpi_map_rsdt_header();
+    if (th == NULL) {
+	device_printf(dev, "couldn't get RSDT header\n");
 	error = ENXIO;
-    } else {
-	sbuf_new(&sb, buf, sizeof(buf), SBUF_FIXEDLEN);
-	sbuf_bcat(&sb, th.OemId, 6);
-	sbuf_trim(&sb);
-	sbuf_putc(&sb, ' ');
-	sbuf_bcat(&sb, th.OemTableId, 8);
-	sbuf_trim(&sb);
-	sbuf_finish(&sb);
-	device_set_desc_copy(dev, sbuf_data(&sb));
-	sbuf_delete(&sb);
-	error = 0;
+	goto unlock;
     }
+
+    sbuf_new(&sb, buf, sizeof(buf), SBUF_FIXEDLEN);
+    sbuf_bcat(&sb, th->OemId, 6);
+    sbuf_trim(&sb);
+    sbuf_putc(&sb, ' ');
+    sbuf_bcat(&sb, th->OemTableId, 8);
+    sbuf_trim(&sb);
+    sbuf_finish(&sb);
+    device_set_desc_copy(dev, sbuf_data(&sb));
+    sbuf_delete(&sb);
+    AcpiOsUnmapMemory(th, sizeof(*th));
+    error = 0;
+unlock:
     ACPI_UNLOCK;
     return_VALUE(error);
 }
@@ -393,29 +399,60 @@ acpi_attach(device_t dev)
     UINT32		flags;
     UINT8		TypeA, TypeB;
     char		*env;
+    ACPI_TABLE_FACS	*facsp;
 #ifdef ACPI_DEBUGGER
     char		*debugpoint;
 #endif
     ACPI_LOCK_DECL;
 
     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
+#if __FreeBSD_version >= 500000
+    /* Initialise the ACPI mutex */
+    mtx_init(&acpi_mutex, "ACPI global lock", NULL, MTX_DEF);
+#endif
+
     ACPI_LOCK;
     sc = device_get_softc(dev);
     bzero(sc, sizeof(*sc));
     sc->acpi_dev = dev;
     callout_init(&sc->acpi_sleep_timer);
 
+    /*
+     * Set the globals from our tunables.  This is needed because ACPI-CA
+     * uses UINT8 for some values and we have no tunable_byte.
+     */
+    AcpiGbl_AllMethodsSerialized = (UINT8)acpi_serialize_methods;
+    AcpiGbl_EnableInterpreterSlack = TRUE;
+
+    error = ENXIO;
 #ifdef ACPI_DEBUGGER
     debugpoint = kgetenv("debug.acpi.debugger");
     if (debugpoint) {
-	if (!strcmp(debugpoint, "spaces"))
+	if (!strcmp(debugpoint, "tables"))
 	    acpi_EnterDebugger();
 	freeenv(debugpoint);
     }
 #endif
 
+    if (ACPI_FAILURE(status = AcpiInitializeSubsystem())) {
+	printf("ACPI: initialisation failed: %s\n",
+	       AcpiFormatException(status));
+	goto out;
+    }
+    if (ACPI_FAILURE(status = AcpiLoadTables())) {
+	printf("ACPI: table load failed: %s\n", AcpiFormatException(status));
+	goto out;
+    }
+
+#ifdef ACPI_DEBUGGER
+    debugpoint = kgetenv("debug.acpi.debugger");
+    if (debugpoint) {
+	if (!strcmp(debugpoint, "spaces"))
+	    acpi_EnterDebugger();
+	freeenv(debugpoint);
+    }
+#endif
     /* Install the default address space handlers. */
-    error = ENXIO;
     status = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT,
 		ACPI_ADR_SPACE_SYSTEM_MEMORY, ACPI_DEFAULT_HANDLER, NULL, NULL);
     if (ACPI_FAILURE(status)) {
@@ -536,8 +573,13 @@ acpi_attach(device_t dev)
     }
 
     /* Only enable S4BIOS by default if the FACS says it is available. */
-    if (AcpiGbl_FACS->S4Bios_f != 0)
+    status = AcpiGetTableByIndex(ACPI_TABLE_INDEX_FACS,
+				(ACPI_TABLE_HEADER **)&facsp);
+    if (ACPI_SUCCESS(status)) {
+	if ((facsp->Flags & ACPI_FACS_S4_BIOS_PRESENT) != 0)
 	    sc->acpi_s4bios = 1;
+	AcpiOsUnmapMemory(facsp, sizeof(*facsp));
+    }
 
     /*
      * Dispatch the default sleep state to devices.  The lid switch is set
@@ -638,7 +680,7 @@ acpi_shutdown(device_t dev)
 static void
 acpi_quirks_set(void)
 {
-    XSDT_DESCRIPTOR *xsdt;
+    ACPI_TABLE_HEADER *rsdt;
     struct acpi_quirks *quirk;
     char *env, *tmp;
     int len;
@@ -664,10 +706,11 @@ acpi_quirks_set(void)
      * Search through our quirk table and concatenate the disabled
      * values with whatever we find.
      */
-    xsdt = AcpiGbl_XSDT;
+    if ((rsdt = acpi_map_rsdt_header()) == NULL)
+	goto out;
     for (quirk = acpi_quirks_table; quirk->OemId; quirk++) {
-	if (!strncmp(xsdt->OemId, quirk->OemId, strlen(quirk->OemId)) &&
-	    (xsdt->OemRevision == quirk->OemRevision ||
+	if (!strncmp(rsdt->OemId, quirk->OemId, strlen(quirk->OemId)) &&
+	    (rsdt->OemRevision == quirk->OemRevision ||
 	    quirk->OemRevision == ACPI_OEM_REV_ANY)) {
 		len += strlen(quirk->value) + 2;
 		if ((tmp = kmalloc(len, M_TEMP, M_NOWAIT)) == NULL)
@@ -680,6 +723,7 @@ acpi_quirks_set(void)
 		break;
 	}
     }
+    AcpiOsUnmapMemory(rsdt, sizeof(*rsdt));
 
 out:
     if (env)
@@ -894,11 +938,10 @@ acpi_bus_alloc_gas(device_t dev, int *ri
 {
     int type;
 
-    if (gas == NULL || !ACPI_VALID_ADDRESS(gas->Address) ||
-	gas->RegisterBitWidth < 8)
+    if (gas == NULL || !ACPI_VALID_ADDRESS(gas->Address) || gas->BitWidth < 8)
 	return (NULL);
 
-    switch (gas->AddressSpaceId) {
+    switch (gas->SpaceId) {
     case ACPI_ADR_SPACE_SYSTEM_MEMORY:
 	type = SYS_RES_MEMORY;
 	break;
@@ -909,7 +952,7 @@ acpi_bus_alloc_gas(device_t dev, int *ri
 	return (NULL);
     }
 
-    bus_set_resource(dev, type, *rid, gas->Address, gas->RegisterBitWidth / 8);
+    bus_set_resource(dev, type, *rid, gas->Address, gas->BitWidth / 8);
     return (bus_alloc_resource_any(dev, type, rid, RF_ACTIVE));
 }
 
@@ -1252,14 +1295,14 @@ acpi_enable_fixed_events(struct acpi_sof
     ACPI_ASSERTLOCK;
 
     /* Enable and clear fixed events and install handlers. */
-    if (AcpiGbl_FADT != NULL && AcpiGbl_FADT->PwrButton == 0) {
+    if ((AcpiGbl_FADT.Flags & ACPI_FADT_POWER_BUTTON) == 0) {
 	AcpiClearEvent(ACPI_EVENT_POWER_BUTTON);
 	AcpiInstallFixedEventHandler(ACPI_EVENT_POWER_BUTTON,
 				     acpi_event_power_button_sleep, sc);
 	if (first_time)
 	    device_printf(sc->acpi_dev, "Power Button (fixed)\n");
     }
-    if (AcpiGbl_FADT != NULL && AcpiGbl_FADT->SleepButton == 0) {
+    if ((AcpiGbl_FADT.Flags & ACPI_FADT_SLEEP_BUTTON) == 0) {
 	AcpiClearEvent(ACPI_EVENT_SLEEP_BUTTON);
 	AcpiInstallFixedEventHandler(ACPI_EVENT_SLEEP_BUTTON,
 				     acpi_event_sleep_button_sleep, sc);
@@ -1421,7 +1464,7 @@ acpi_TimerDelta(uint32_t end, uint32_t s
 
     if (end >= start)
 	delta = end - start;
-    else if (AcpiGbl_FADT->TmrValExt == 0)
+    else if ((AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) == 0)
 	delta = ((0x00FFFFFF - start) + end + 1) & 0x00FFFFFF;
     else
 	delta = ((0xFFFFFFFF - start) + end + 1);
@@ -1574,7 +1617,7 @@ acpi_FindIndexedResource(ACPI_BUFFER *bu
 	    return (AE_BAD_PARAMETER);
 
 	/* Check for terminator */
-	if (rp->Id == ACPI_RSTYPE_END_TAG || rp->Length == 0)
+	if (rp->Type == ACPI_RESOURCE_TYPE_END_TAG || rp->Length == 0)
 	    return (AE_NOT_FOUND);
 	rp = ACPI_NEXT_RESOURCE(rp);
     }
@@ -1606,7 +1649,7 @@ acpi_AppendBufferResource(ACPI_BUFFER *b
 	if ((buf->Pointer = AcpiOsAllocate(buf->Length)) == NULL)
 	    return (AE_NO_MEMORY);
 	rp = (ACPI_RESOURCE *)buf->Pointer;
-	rp->Id = ACPI_RSTYPE_END_TAG;
+	rp->Type = ACPI_RESOURCE_TYPE_END_TAG;
 	rp->Length = 0;
     }
     if (res == NULL)
@@ -1622,7 +1665,7 @@ acpi_AppendBufferResource(ACPI_BUFFER *b
 	/* Range check, don't go outside the buffer */
 	if (rp >= (ACPI_RESOURCE *)((u_int8_t *)buf->Pointer + buf->Length))
 	    return (AE_BAD_PARAMETER);
-	if (rp->Id == ACPI_RSTYPE_END_TAG || rp->Length == 0)
+	if (rp->Type == ACPI_RESOURCE_TYPE_END_TAG || rp->Length == 0)
 	    break;
 	rp = ACPI_NEXT_RESOURCE(rp);
     }
@@ -1639,8 +1682,8 @@ acpi_AppendBufferResource(ACPI_BUFFER *b
      * for some reason we are stuffing a *really* huge resource.
      */
     while ((((u_int8_t *)rp - (u_int8_t *)buf->Pointer) + 
-	    res->Length + ACPI_RESOURCE_LENGTH_NO_DATA +
-	    ACPI_RESOURCE_LENGTH) >= buf->Length) {
+	    res->Length + ACPI_RS_SIZE_NO_DATA +
+	    ACPI_RS_SIZE_MIN) >= buf->Length) {
 	if ((newp = AcpiOsAllocate(buf->Length * 2)) == NULL)
 	    return (AE_NO_MEMORY);
 	bcopy(buf->Pointer, newp, buf->Length);
@@ -1652,11 +1695,11 @@ acpi_AppendBufferResource(ACPI_BUFFER *b
     }
     
     /* Insert the new resource. */
-    bcopy(res, rp, res->Length + ACPI_RESOURCE_LENGTH_NO_DATA);
+    bcopy(res, rp, res->Length + ACPI_RS_SIZE_NO_DATA);
     
     /* And add the terminator. */
     rp = ACPI_NEXT_RESOURCE(rp);
-    rp->Id = ACPI_RSTYPE_END_TAG;
+    rp->Type = ACPI_RESOURCE_TYPE_END_TAG;
     rp->Length = 0;
 
     return (AE_OK);
@@ -1749,13 +1792,8 @@ acpi_SetSleepState(struct acpi_softc *sc
 
 	if (state != ACPI_STATE_S1) {
 	    acpi_sleep_machdep(sc, state);
-
 	    /* AcpiEnterSleepState() may be incomplete, unlock if locked. */
-	    if (AcpiGbl_MutexInfo[ACPI_MTX_HARDWARE].OwnerId !=
-		ACPI_MUTEX_NOT_ACQUIRED) {
-
-		AcpiUtReleaseMutex(ACPI_MTX_HARDWARE);
-	    }
+	    AcpiOsReleaseLock(AcpiGbl_HardwareLock, 1);
 
 	    /* Re-enable ACPI hardware on wakeup from sleep state 4. */
 	    if (state == ACPI_STATE_S4)
Index: sys/dev/acpica5/acpi_acad.c
===================================================================
RCS file: /home/source/dragonfly/cvs/src/sys/dev/acpica5/acpi_acad.c,v
retrieving revision 1.6
diff -u -p -r1.6 acpi_acad.c
--- sys/dev/acpica5/acpi_acad.c	25 Oct 2006 20:55:52 -0000	1.6
+++ sys/dev/acpica5/acpi_acad.c	26 Oct 2006 05:29:11 -0000
@@ -124,7 +124,7 @@ acpi_acad_notify_handler(ACPI_HANDLE h, 
     case ACPI_DEVICE_CHECK_EXISTENCE:
     case ACPI_POWERSOURCE_STAT_CHANGE:
 	/* Temporarily.  It is better to notify policy manager */
-	AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_acad_get_status, context);
+	AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_acad_get_status, context);
 	break;
     default:
 	device_printf(dev, "unknown notify %#x\n", notify);
@@ -180,7 +180,7 @@ acpi_acad_attach(device_t dev)
 			     acpi_acad_notify_handler, dev);
     AcpiInstallNotifyHandler(handle, ACPI_DEVICE_NOTIFY,
 			     acpi_acad_notify_handler, dev);
-    AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_acad_init_acline, dev);
+    AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_acad_init_acline, dev);
 
     return (0);
 }
Index: sys/dev/acpica5/acpi_button.c
===================================================================
RCS file: /home/source/dragonfly/cvs/src/sys/dev/acpica5/acpi_button.c,v
retrieving revision 1.3
diff -u -p -r1.3 acpi_button.c
--- sys/dev/acpica5/acpi_button.c	5 Jul 2004 00:07:35 -0000	1.3
+++ sys/dev/acpica5/acpi_button.c	4 Oct 2006 03:58:10 -0000
@@ -249,12 +249,10 @@ acpi_button_notify_handler(ACPI_HANDLE h
     sc = (struct acpi_button_softc *)context;
     switch (notify) {
     case ACPI_NOTIFY_BUTTON_PRESSED_FOR_SLEEP:
-	AcpiOsQueueForExecution(OSD_PRIORITY_LO,
-				acpi_button_notify_sleep, sc);
+	AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_button_notify_sleep, sc);
 	break;   
     case ACPI_NOTIFY_BUTTON_PRESSED_FOR_WAKEUP:
-	AcpiOsQueueForExecution(OSD_PRIORITY_LO,
-				acpi_button_notify_wakeup, sc);
+	AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_button_notify_wakeup, sc);
 	break;   
     default:
 	device_printf(sc->button_dev, "unknown notify %#x\n", notify);
Index: sys/dev/acpica5/acpi_cmbat.c
===================================================================
RCS file: /home/source/dragonfly/cvs/src/sys/dev/acpica5/acpi_cmbat.c,v
retrieving revision 1.9
diff -u -p -r1.9 acpi_cmbat.c
--- sys/dev/acpica5/acpi_cmbat.c	25 Oct 2006 20:55:52 -0000	1.9
+++ sys/dev/acpica5/acpi_cmbat.c	26 Oct 2006 05:29:11 -0000
@@ -280,7 +280,7 @@ acpi_cmbat_notify_handler(ACPI_HANDLE h,
     case ACPI_NOTIFY_BUS_CHECK:
     case ACPI_BATTERY_BIF_CHANGE:
 	timespecclear(&sc->bif_lastupdated);
-	AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_cmbat_get_bif, dev);
+	AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_cmbat_get_bif, dev);
 	break;
     default:
 	break;
@@ -344,7 +344,7 @@ acpi_cmbat_attach(device_t dev)
     acpi_cmbat_units++;
     timespecclear(&acpi_cmbat_info_lastupdated);
     sc->initializing = 0;
-    AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_cmbat_init_battery, dev);
+    AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_cmbat_init_battery, dev);
 
     return (0);
 }
@@ -352,7 +352,7 @@ acpi_cmbat_attach(device_t dev)
 static int
 acpi_cmbat_resume(device_t dev)
 {
-    AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_cmbat_init_battery, dev);
+    AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_cmbat_init_battery, dev);
     return (0);
 }
 
Index: sys/dev/acpica5/acpi_cpu.c
===================================================================
RCS file: /home/source/dragonfly/cvs/src/sys/dev/acpica5/acpi_cpu.c,v
retrieving revision 1.15
diff -u -p -r1.15 acpi_cpu.c
--- sys/dev/acpica5/acpi_cpu.c	25 Oct 2006 20:55:52 -0000	1.15
+++ sys/dev/acpica5/acpi_cpu.c	10 Nov 2006 08:52:52 -0000
@@ -244,9 +244,9 @@ acpi_cpu_probe(device_t dev)
 	    acpi_PkgInt32(obj, 0, &cx_count);
 	AcpiOsFree(obj);
     } else {
-	if (AcpiGbl_FADT->Plvl2Lat <= 100)
+	if (AcpiGbl_FADT.C2Latency <= 100)
 	    cx_count++;
-	if (AcpiGbl_FADT->Plvl3Lat <= 1000)
+	if (AcpiGbl_FADT.C3Latency <= 1000)
 	    cx_count++;
 	if (cx_count > 0)
 	    cx_count++;
@@ -319,7 +319,7 @@ acpi_cpu_attach(device_t dev)
 	status = AcpiInstallNotifyHandler(sc->cpu_handle, ACPI_DEVICE_NOTIFY,
 					  acpi_cpu_notify, sc);
 	if (device_get_unit(dev) == 0)
-	    AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_cpu_startup, NULL);
+	    AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_cpu_startup, NULL);
     } else {
 	sysctl_ctx_free(&acpi_cpu_sysctl_ctx);
     }
@@ -396,11 +396,11 @@ acpi_cpu_throttle_probe(struct acpi_cpu_
 
     /* Get throttling parameters from the FADT.  0 means not supported. */
     if (device_get_unit(sc->cpu_dev) == 0) {
-	cpu_smi_cmd = AcpiGbl_FADT->SmiCmd;
-	cpu_pstate_cnt = AcpiGbl_FADT->PstateCnt;
-	cpu_cst_cnt = AcpiGbl_FADT->CstCnt;
-	cpu_duty_offset = AcpiGbl_FADT->DutyOffset;
-	cpu_duty_width = AcpiGbl_FADT->DutyWidth;
+	cpu_smi_cmd = AcpiGbl_FADT.SmiCommand;
+	cpu_pstate_cnt = AcpiGbl_FADT.PstateControl;
+	cpu_cst_cnt = AcpiGbl_FADT.CstControl;
+	cpu_duty_offset = AcpiGbl_FADT.DutyOffset;
+	cpu_duty_width = AcpiGbl_FADT.DutyWidth;
     }
     if (cpu_duty_width == 0 || (cpu_quirks & CPU_QUIRK_NO_THROTTLE) != 0)
 	return (ENXIO);
@@ -449,8 +449,8 @@ acpi_cpu_throttle_probe(struct acpi_cpu_
 	if (sc->cpu_p_blk_len < 4)
 	    return (ENXIO);
 	gas.Address = sc->cpu_p_blk;
-	gas.AddressSpaceId = ACPI_ADR_SPACE_SYSTEM_IO;
-	gas.RegisterBitWidth = 32;
+	gas.SpaceId = ACPI_ADR_SPACE_SYSTEM_IO;
+	gas.BitWidth = 32;
 	sc->cpu_p_cnt = acpi_bus_alloc_gas(sc->cpu_dev, &cpu_rid, &gas);
 	if (sc->cpu_p_cnt != NULL) {
 	    ACPI_DEBUG_PRINT((ACPI_DB_INFO, "acpi_cpu%d: P_CNT from P_BLK\n",
@@ -480,8 +480,9 @@ acpi_cpu_cx_probe(struct acpi_cpu_softc 
      * instruction is present, flush the caches before entering C3 instead.
      * Otherwise, just disable C3 completely.
      */
-    if (AcpiGbl_FADT->V1_Pm2CntBlk == 0 || AcpiGbl_FADT->Pm2CntLen == 0) {
-	if (AcpiGbl_FADT->WbInvd && AcpiGbl_FADT->WbInvdFlush == 0) {
+    if (AcpiGbl_FADT.Pm2ControlBlock == 0 || AcpiGbl_FADT.Pm2ControlLength == 0) {
+	if ((AcpiGbl_FADT.Flags & ACPI_FADT_WBINVD) != 0 &&
+	    (AcpiGbl_FADT.Flags & ACPI_FADT_WBINVD_FLUSH) == 0) {
 	    cpu_quirks |= CPU_QUIRK_NO_BM_CTRL;
 	    ACPI_DEBUG_PRINT((ACPI_DB_INFO,
 		"acpi_cpu%d: no BM control, using flush cache method\n",
@@ -521,15 +522,15 @@ acpi_cpu_cx_probe(struct acpi_cpu_softc 
 	    goto done;
 
 	/* Validate and allocate resources for C2 (P_LVL2). */
-	gas.AddressSpaceId = ACPI_ADR_SPACE_SYSTEM_IO;
-	gas.RegisterBitWidth = 8;
-	if (AcpiGbl_FADT->Plvl2Lat <= 100) {
+	gas.SpaceId = ACPI_ADR_SPACE_SYSTEM_IO;
+	gas.BitWidth = 8;
+	if (AcpiGbl_FADT.C2Latency <= 100) {
 	    gas.Address = sc->cpu_p_blk + 4;
 	    cx_ptr->p_lvlx = acpi_bus_alloc_gas(sc->cpu_dev, &cpu_rid, &gas);
 	    if (cx_ptr->p_lvlx != NULL) {
 		cpu_rid++;
 		cx_ptr->type = ACPI_STATE_C2;
-		cx_ptr->trans_lat = AcpiGbl_FADT->Plvl2Lat;
+		cx_ptr->trans_lat = AcpiGbl_FADT.C2Latency;
 		cpu_non_c3 = 1;
 		cx_ptr++;
 		sc->cpu_cx_count++;
@@ -539,7 +540,7 @@ acpi_cpu_cx_probe(struct acpi_cpu_softc 
 	    goto done;
 
 	/* Validate and allocate resources for C3 (P_LVL3). */
-	if (AcpiGbl_FADT->Plvl3Lat <= 1000 &&
+	if (AcpiGbl_FADT.C3Latency <= 1000 &&
 	    (cpu_quirks & CPU_QUIRK_NO_C3) == 0) {
 
 	    gas.Address = sc->cpu_p_blk + 5;
@@ -547,7 +548,7 @@ acpi_cpu_cx_probe(struct acpi_cpu_softc 
 	    if (cx_ptr->p_lvlx != NULL) {
 		cpu_rid++;
 		cx_ptr->type = ACPI_STATE_C3;
-		cx_ptr->trans_lat = AcpiGbl_FADT->Plvl3Lat;
+		cx_ptr->trans_lat = AcpiGbl_FADT.C3Latency;
 		cx_ptr++;
 		sc->cpu_cx_count++;
 	    }
@@ -979,7 +980,7 @@ acpi_cpu_idle(void)
      * get the time very close to the CPU start/stop clock logic, this
      * is the only reliable time source.
      */
-    AcpiHwLowLevelRead(32, &start_time, &AcpiGbl_FADT->XPmTmrBlk);
+    AcpiHwLowLevelRead(32, &start_time, &AcpiGbl_FADT.XPmTimerBlock);
     CPU_GET_REG(cx_next->p_lvlx, 1);
 
     /*
@@ -988,8 +989,8 @@ acpi_cpu_idle(void)
      * the processor has stopped.  Doing it again provides enough
      * margin that we are certain to have a correct value.
      */
-    AcpiHwLowLevelRead(32, &end_time, &AcpiGbl_FADT->XPmTmrBlk);
-    AcpiHwLowLevelRead(32, &end_time, &AcpiGbl_FADT->XPmTmrBlk);
+    AcpiHwLowLevelRead(32, &end_time, &AcpiGbl_FADT.XPmTimerBlock);
+    AcpiHwLowLevelRead(32, &end_time, &AcpiGbl_FADT.XPmTimerBlock);
 
     /* Enable bus master arbitration and disable bus master wakeup. */
     if (cx_next->type == ACPI_STATE_C3 &&
Index: sys/dev/acpica5/acpi_ec.c
===================================================================
RCS file: /home/source/dragonfly/cvs/src/sys/dev/acpica5/acpi_ec.c,v
retrieving revision 1.9
diff -u -p -r1.9 acpi_ec.c
--- sys/dev/acpica5/acpi_ec.c	25 Oct 2006 20:55:52 -0000	1.9
+++ sys/dev/acpica5/acpi_ec.c	5 Nov 2006 11:45:43 -0000
@@ -227,16 +227,6 @@ typedef UINT8				EC_EVENT;
 #define EC_SET_CSR(sc, v)						\
 	bus_space_write_1((sc)->ec_csr_tag, (sc)->ec_csr_handle, 0, (v))
 
-/* Embedded Controller Boot Resources Table (ECDT) */
-typedef struct {
-    ACPI_TABLE_HEADER		header;
-    ACPI_GENERIC_ADDRESS	control;
-    ACPI_GENERIC_ADDRESS	data;
-    UINT32			uid;
-    UINT8			gpe_bit;
-    char			ec_id[0];
-} ACPI_TABLE_ECDT;
-
 /* Additional params to pass from the probe routine */
 struct acpi_ec_params {
     int		glk;
@@ -374,23 +364,21 @@ acpi_ec_ecdt_probe(device_t parent)
     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
 
     /* Find and validate the ECDT. */
-    status = AcpiGetFirmwareTable("ECDT", 1, ACPI_LOGICAL_ADDRESSING, 
-		(ACPI_TABLE_HEADER **)&ecdt);
+    status = AcpiGetTable(ACPI_SIG_ECDT, 1, (ACPI_TABLE_HEADER **)&ecdt);
     if (ACPI_FAILURE(status) ||
-	ecdt->control.RegisterBitWidth != 8 ||
-	ecdt->data.RegisterBitWidth != 8) {
+	ecdt->Control.BitWidth != 8 || ecdt->Data.BitWidth != 8) {
 	return;
     }
 
     /* Create the child device with the given unit number. */
-    child = BUS_ADD_CHILD(parent, parent, 0, "acpi_ec", ecdt->uid);
+    child = BUS_ADD_CHILD(parent, parent, 0, "acpi_ec", ecdt->Uid);
     if (child == NULL) {
 	printf("%s: can't add child\n", __func__);
 	return;
     }
 
     /* Find and save the ACPI handle for this device. */
-    status = AcpiGetHandle(NULL, ecdt->ec_id, &h);
+    status = AcpiGetHandle(NULL, ecdt->Id, &h);
     if (ACPI_FAILURE(status)) {
 	device_delete_child(parent, child);
 	printf("%s: can't get handle\n", __func__);
@@ -399,9 +387,9 @@ acpi_ec_ecdt_probe(device_t parent)
     acpi_set_handle(child, h);
 
     /* Set the data and CSR register addresses. */
-    bus_set_resource(child, SYS_RES_IOPORT, 0, ecdt->data.Address,
+    bus_set_resource(child, SYS_RES_IOPORT, 0, ecdt->Data.Address,
 	/*count*/1);
-    bus_set_resource(child, SYS_RES_IOPORT, 1, ecdt->control.Address,
+    bus_set_resource(child, SYS_RES_IOPORT, 1, ecdt->Control.Address,
 	/*count*/1);
 
     /*
@@ -413,8 +401,8 @@ acpi_ec_ecdt_probe(device_t parent)
      */
     params = kmalloc(sizeof(struct acpi_ec_params), M_TEMP, M_WAITOK | M_ZERO);
     params->gpe_handle = NULL;
-    params->gpe_bit = ecdt->gpe_bit;
-    params->uid = ecdt->uid;
+    params->gpe_bit = ecdt->Gpe;
+    params->uid = ecdt->Uid;
     acpi_GetInteger(h, "_GLK", &params->glk);
     acpi_set_private(child, params);
     acpi_set_magic(child, (int)&acpi_ec_devclass);
@@ -718,7 +706,7 @@ EcGpeHandler(void *Context)
     AcpiDisableGpe(sc->ec_gpehandle, sc->ec_gpebit, ACPI_NOT_ISR);
 
     /* Schedule the GPE query handler. */
-    Status = AcpiOsQueueForExecution(OSD_PRIORITY_GPE, EcGpeQueryHandler,
+    Status = AcpiOsExecute(OSL_GPE_HANDLER, EcGpeQueryHandler,
 		Context);
     if (ACPI_FAILURE(Status)) {
 	printf("Queuing GPE query handler failed.\n");
Index: sys/dev/acpica5/acpi_lid.c
===================================================================
RCS file: /home/source/dragonfly/cvs/src/sys/dev/acpica5/acpi_lid.c,v
retrieving revision 1.3
diff -u -p -r1.3 acpi_lid.c
--- sys/dev/acpica5/acpi_lid.c	5 Jul 2004 00:07:35 -0000	1.3
+++ sys/dev/acpica5/acpi_lid.c	4 Oct 2006 03:58:10 -0000
@@ -183,8 +183,7 @@ acpi_lid_notify_handler(ACPI_HANDLE h, U
     sc = (struct acpi_lid_softc *)context;
     switch (notify) {
     case ACPI_NOTIFY_STATUS_CHANGED:
-	AcpiOsQueueForExecution(OSD_PRIORITY_LO,
-				acpi_lid_notify_status_changed, sc);
+	AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_lid_notify_status_changed, sc);
 	break;
     default:
 	device_printf(sc->lid_dev, "unknown notify %#x\n", notify);
Index: sys/dev/acpica5/acpi_resource.c
===================================================================
RCS file: /home/source/dragonfly/cvs/src/sys/dev/acpica5/acpi_resource.c,v
retrieving revision 1.4
diff -u -p -r1.4 acpi_resource.c
--- sys/dev/acpica5/acpi_resource.c	25 Oct 2006 20:55:52 -0000	1.4
+++ sys/dev/acpica5/acpi_resource.c	26 Oct 2006 05:29:11 -0000
@@ -94,129 +94,129 @@ acpi_parse_resources(device_t dev, ACPI_
 	curr += res->Length;
 
 	/* Handle the individual resource types */
-	switch(res->Id) {
-	case ACPI_RSTYPE_END_TAG:
+	switch(res->Type) {
+	case ACPI_RESOURCE_TYPE_END_TAG:
 	    ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "EndTag\n"));
 	    curr = last;
 	    break;
-	case ACPI_RSTYPE_FIXED_IO:
-	    if (res->Data.FixedIo.RangeLength <= 0)
+	case ACPI_RESOURCE_TYPE_FIXED_IO:
+	    if (res->Data.FixedIo.AddressLength <= 0)
 		break;
 	    ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "FixedIo 0x%x/%d\n",
-			     res->Data.FixedIo.BaseAddress,
-			     res->Data.FixedIo.RangeLength));
+			     res->Data.FixedIo.Address,
+			     res->Data.FixedIo.AddressLength));
 	    set->set_ioport(dev, context,
-			    res->Data.FixedIo.BaseAddress,
-			    res->Data.FixedIo.RangeLength);
+			    res->Data.FixedIo.Address,
+			    res->Data.FixedIo.AddressLength);
 	    break;
-	case ACPI_RSTYPE_IO:
-	    if (res->Data.Io.RangeLength <= 0)
+	case ACPI_RESOURCE_TYPE_IO:
+	    if (res->Data.Io.AddressLength <= 0)
 		break;
-	    if (res->Data.Io.MinBaseAddress == res->Data.Io.MaxBaseAddress) {
+	    if (res->Data.Io.Minimum == res->Data.Io.Maximum) {
 		ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Io 0x%x/%d\n",
-				 res->Data.Io.MinBaseAddress,
-				 res->Data.Io.RangeLength));
+				 res->Data.Io.Minimum,
+				 res->Data.Io.AddressLength));
 		set->set_ioport(dev, context,
-				res->Data.Io.MinBaseAddress,
-				res->Data.Io.RangeLength);
+				res->Data.Io.Minimum,
+				res->Data.Io.AddressLength);
 	    } else {
 		ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Io 0x%x-0x%x/%d\n",
-				 res->Data.Io.MinBaseAddress,
-				 res->Data.Io.MaxBaseAddress, 
-				 res->Data.Io.RangeLength));
+				 res->Data.Io.Minimum,
+				 res->Data.Io.Maximum, 
+				 res->Data.Io.AddressLength));
 		set->set_iorange(dev, context,
-				 res->Data.Io.MinBaseAddress,
-				 res->Data.Io.MaxBaseAddress, 
-				 res->Data.Io.RangeLength,
+				 res->Data.Io.Minimum,
+				 res->Data.Io.Maximum, 
+				 res->Data.Io.AddressLength,
 				 res->Data.Io.Alignment);
 	    }
 	    break;
-	case ACPI_RSTYPE_FIXED_MEM32:
-	    if (res->Data.FixedMemory32.RangeLength <= 0)
+	case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
+	    if (res->Data.FixedMemory32.AddressLength <= 0)
 		break;
 	    ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "FixedMemory32 0x%x/%d\n",
-			      res->Data.FixedMemory32.RangeBaseAddress, 
-			      res->Data.FixedMemory32.RangeLength));
+			      res->Data.FixedMemory32.Address, 
+			      res->Data.FixedMemory32.AddressLength));
 	    set->set_memory(dev, context,
-			    res->Data.FixedMemory32.RangeBaseAddress, 
-			    res->Data.FixedMemory32.RangeLength);
+			    res->Data.FixedMemory32.Address, 
+			    res->Data.FixedMemory32.AddressLength);
 	    break;
-	case ACPI_RSTYPE_MEM32:
-	    if (res->Data.Memory32.RangeLength <= 0)
+	case ACPI_RESOURCE_TYPE_MEMORY32:
+	    if (res->Data.Memory32.AddressLength <= 0)
 		break;
-	    if (res->Data.Memory32.MinBaseAddress ==
-		res->Data.Memory32.MaxBaseAddress) {
+	    if (res->Data.Memory32.Minimum ==
+		res->Data.Memory32.Maximum) {
 
 		ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Memory32 0x%x/%d\n",
-				  res->Data.Memory32.MinBaseAddress, 
-				  res->Data.Memory32.RangeLength));
+				  res->Data.Memory32.Minimum, 
+				  res->Data.Memory32.AddressLength));
 		set->set_memory(dev, context,
-				res->Data.Memory32.MinBaseAddress,
-				res->Data.Memory32.RangeLength);
+				res->Data.Memory32.Minimum,
+				res->Data.Memory32.AddressLength);
 	    } else {
 		ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Memory32 0x%x-0x%x/%d\n",
-				 res->Data.Memory32.MinBaseAddress, 
-				 res->Data.Memory32.MaxBaseAddress,
-				 res->Data.Memory32.RangeLength));
+				 res->Data.Memory32.Minimum, 
+				 res->Data.Memory32.Maximum,
+				 res->Data.Memory32.AddressLength));
 		set->set_memoryrange(dev, context,
-				     res->Data.Memory32.MinBaseAddress,
-				     res->Data.Memory32.MaxBaseAddress,
-				     res->Data.Memory32.RangeLength,
+				     res->Data.Memory32.Minimum,
+				     res->Data.Memory32.Maximum,
+				     res->Data.Memory32.AddressLength,
 				     res->Data.Memory32.Alignment);
 	    }
 	    break;
-	case ACPI_RSTYPE_MEM24:
-	    if (res->Data.Memory24.RangeLength <= 0)
+	case ACPI_RESOURCE_TYPE_MEMORY24:
+	    if (res->Data.Memory24.AddressLength <= 0)
 		break;
-	    if (res->Data.Memory24.MinBaseAddress ==
-		res->Data.Memory24.MaxBaseAddress) {
+	    if (res->Data.Memory24.Minimum ==
+		res->Data.Memory24.Maximum) {
 
 		ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Memory24 0x%x/%d\n",
-				 res->Data.Memory24.MinBaseAddress, 
-				 res->Data.Memory24.RangeLength));
-		set->set_memory(dev, context, res->Data.Memory24.MinBaseAddress,
-				res->Data.Memory24.RangeLength);
+				 res->Data.Memory24.Minimum, 
+				 res->Data.Memory24.AddressLength));
+		set->set_memory(dev, context, res->Data.Memory24.Minimum,
+				res->Data.Memory24.AddressLength);
 	    } else {
 		ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Memory24 0x%x-0x%x/%d\n",
-				 res->Data.Memory24.MinBaseAddress, 
-				 res->Data.Memory24.MaxBaseAddress,
-				 res->Data.Memory24.RangeLength));
+				 res->Data.Memory24.Minimum, 
+				 res->Data.Memory24.Maximum,
+				 res->Data.Memory24.AddressLength));
 		set->set_memoryrange(dev, context,
-				     res->Data.Memory24.MinBaseAddress,
-				     res->Data.Memory24.MaxBaseAddress,
-				     res->Data.Memory24.RangeLength,
+				     res->Data.Memory24.Minimum,
+				     res->Data.Memory24.Maximum,
+				     res->Data.Memory24.AddressLength,
 				     res->Data.Memory24.Alignment);
 	    }
 	    break;
-	case ACPI_RSTYPE_IRQ:
+	case ACPI_RESOURCE_TYPE_IRQ:
 	    /*
 	     * from 1.0b 6.4.2 
 	     * "This structure is repeated for each separate interrupt
 	     * required"
 	     */
 	    set->set_irq(dev, context, res->Data.Irq.Interrupts,
-		res->Data.Irq.NumberOfInterrupts, res->Data.Irq.EdgeLevel,
-		res->Data.Irq.ActiveHighLow);
+		res->Data.Irq.InterruptCount, res->Data.Irq.Triggering,
+		res->Data.Irq.Polarity);
 	    break;
-	case ACPI_RSTYPE_DMA:
+	case ACPI_RESOURCE_TYPE_DMA:
 	    /*
 	     * from 1.0b 6.4.3 
 	     * "This structure is repeated for each separate dma channel
 	     * required"
 	     */
 	    set->set_drq(dev, context, res->Data.Dma.Channels,
-			 res->Data.Dma.NumberOfChannels);
+			 res->Data.Dma.ChannelCount);
 	    break;
-	case ACPI_RSTYPE_START_DPF:
+	case ACPI_RESOURCE_TYPE_START_DEPENDENT:
 	    ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "start dependant functions\n"));
 	    set->set_start_dependant(dev, context,
 				     res->Data.StartDpf.CompatibilityPriority);
 	    break;
-	case ACPI_RSTYPE_END_DPF:
+	case ACPI_RESOURCE_TYPE_END_DEPENDENT:
 	    ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "end dependant functions\n"));
 	    set->set_end_dependant(dev, context);
 	    break;
-	case ACPI_RSTYPE_ADDRESS32:
+	case ACPI_RESOURCE_TYPE_ADDRESS32:
 	    if (res->Data.Address32.AddressLength <= 0)
 		break;
 	    if (res->Data.Address32.ProducerConsumer != ACPI_CONSUMER) {
@@ -233,53 +233,53 @@ acpi_parse_resources(device_t dev, ACPI_
 		break;
 	    }
 
-	    if (res->Data.Address32.MinAddressFixed == ACPI_ADDRESS_FIXED &&
-		res->Data.Address32.MaxAddressFixed == ACPI_ADDRESS_FIXED) {
+	    if (res->Data.Address32.Minimum == ACPI_ADDRESS_FIXED &&
+		res->Data.Address32.Maximum == ACPI_ADDRESS_FIXED) {
 
 		if (res->Data.Address32.ResourceType == ACPI_MEMORY_RANGE) {
 		    ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
 				     "Address32/Memory 0x%x/%d\n",
-				     res->Data.Address32.MinAddressRange,
+				     res->Data.Address32.Minimum,
 				     res->Data.Address32.AddressLength));
 		    set->set_memory(dev, context,
-				    res->Data.Address32.MinAddressRange,
+				    res->Data.Address32.Minimum,
 				    res->Data.Address32.AddressLength);
 		} else {
 		    ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
 				     "Address32/IO 0x%x/%d\n",
-				     res->Data.Address32.MinAddressRange,
+				     res->Data.Address32.Minimum,
 				     res->Data.Address32.AddressLength));
 		    set->set_ioport(dev, context,
-				    res->Data.Address32.MinAddressRange,
+				    res->Data.Address32.Minimum,
 				    res->Data.Address32.AddressLength);
 		}
 	    } else {
 		if (res->Data.Address32.ResourceType == ACPI_MEMORY_RANGE) {
 		    ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
 				     "Address32/Memory 0x%x-0x%x/%d\n",
-				     res->Data.Address32.MinAddressRange,
-				     res->Data.Address32.MaxAddressRange,
+				     res->Data.Address32.Minimum,
+				     res->Data.Address32.Maximum,
 				     res->Data.Address32.AddressLength));
 		    set->set_memoryrange(dev, context,
-					  res->Data.Address32.MinAddressRange,
-					  res->Data.Address32.MaxAddressRange,
+					  res->Data.Address32.Minimum,
+					  res->Data.Address32.Maximum,
 					  res->Data.Address32.AddressLength,
 					  res->Data.Address32.Granularity);
 		} else {
 		    ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
 				     "Address32/IO 0x%x-0x%x/%d\n",
-				     res->Data.Address32.MinAddressRange,
-				     res->Data.Address32.MaxAddressRange,
+				     res->Data.Address32.Minimum,
+				     res->Data.Address32.Maximum,
 				     res->Data.Address32.AddressLength));
 		    set->set_iorange(dev, context,
-				     res->Data.Address32.MinAddressRange,
-				     res->Data.Address32.MaxAddressRange,
+				     res->Data.Address32.Minimum,
+				     res->Data.Address32.Maximum,
 				     res->Data.Address32.AddressLength,
 				     res->Data.Address32.Granularity);
 		}
 	    }		    
 	    break;
-	case ACPI_RSTYPE_ADDRESS16:
+	case ACPI_RESOURCE_TYPE_ADDRESS16:
 	    if (res->Data.Address16.AddressLength <= 0)
 		break;
 	    if (res->Data.Address16.ProducerConsumer != ACPI_CONSUMER) {
@@ -296,64 +296,64 @@ acpi_parse_resources(device_t dev, ACPI_
 		break;
 	    }
 
-	    if (res->Data.Address16.MinAddressFixed == ACPI_ADDRESS_FIXED &&
-		res->Data.Address16.MaxAddressFixed == ACPI_ADDRESS_FIXED) {
+	    if (res->Data.Address16.Minimum == ACPI_ADDRESS_FIXED &&
+		res->Data.Address16.Maximum == ACPI_ADDRESS_FIXED) {
 
 		if (res->Data.Address16.ResourceType == ACPI_MEMORY_RANGE) {
 		    ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
 				     "Address16/Memory 0x%x/%d\n",
-				     res->Data.Address16.MinAddressRange,
+				     res->Data.Address16.Minimum,
 				     res->Data.Address16.AddressLength));
 		    set->set_memory(dev, context,
-				    res->Data.Address16.MinAddressRange,
+				    res->Data.Address16.Minimum,
 				    res->Data.Address16.AddressLength);
 		} else {
 		    ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
 				     "Address16/IO 0x%x/%d\n",
-				     res->Data.Address16.MinAddressRange,
+				     res->Data.Address16.Minimum,
 				     res->Data.Address16.AddressLength));
 		    set->set_ioport(dev, context,
-				    res->Data.Address16.MinAddressRange,
+				    res->Data.Address16.Minimum,
 				    res->Data.Address16.AddressLength);
 		}
 	    } else {
 		if (res->Data.Address16.ResourceType == ACPI_MEMORY_RANGE) {
 		    ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
 				     "Address16/Memory 0x%x-0x%x/%d\n",
-				     res->Data.Address16.MinAddressRange,
-				     res->Data.Address16.MaxAddressRange,
+				     res->Data.Address16.Minimum,
+				     res->Data.Address16.Maximum,
 				     res->Data.Address16.AddressLength));
 		    set->set_memoryrange(dev, context,
-					  res->Data.Address16.MinAddressRange,
-					  res->Data.Address16.MaxAddressRange,
+					  res->Data.Address16.Minimum,
+					  res->Data.Address16.Maximum,
 					  res->Data.Address16.AddressLength,
 					  res->Data.Address16.Granularity);
 		} else {
 		    ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
 				     "Address16/IO 0x%x-0x%x/%d\n",
-				     res->Data.Address16.MinAddressRange,
-				     res->Data.Address16.MaxAddressRange,
+				     res->Data.Address16.Minimum,
+				     res->Data.Address16.Maximum,
 				     res->Data.Address16.AddressLength));
 		    set->set_iorange(dev, context,
-				     res->Data.Address16.MinAddressRange,
-				     res->Data.Address16.MaxAddressRange,
+				     res->Data.Address16.Minimum,
+				     res->Data.Address16.Maximum,
 				     res->Data.Address16.AddressLength,
 				     res->Data.Address16.Granularity);
 		}
 	    }		    
 	    break;
-	case ACPI_RSTYPE_ADDRESS64:
+	case ACPI_RESOURCE_TYPE_ADDRESS64:
 	    ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
 			     "unimplemented Address64 resource\n"));
 	    break;
-	case ACPI_RSTYPE_EXT_IRQ:
+	case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
 	    /* XXX special handling? */
-	    set->set_irq(dev, context,res->Data.ExtendedIrq.Interrupts,
-		res->Data.ExtendedIrq.NumberOfInterrupts,
-		res->Data.ExtendedIrq.EdgeLevel,
-		res->Data.ExtendedIrq.ActiveHighLow);
+	    set->set_ext_irq(dev, context, res->Data.ExtendedIrq.Interrupts,
+		res->Data.ExtendedIrq.InterruptCount,
+		res->Data.ExtendedIrq.Triggering,
+		res->Data.ExtendedIrq.Polarity);
 	    break;
-	case ACPI_RSTYPE_VENDOR:
+	case ACPI_RESOURCE_TYPE_VENDOR:
 	    ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
 			     "unimplemented VendorSpecific resource\n"));
 	    break;
@@ -383,9 +383,12 @@ static void	acpi_res_set_memory(device_t
 static void	acpi_res_set_memoryrange(device_t dev, void *context,
 					 u_int32_t low, u_int32_t high, 
 					 u_int32_t length, u_int32_t align);
-static void	acpi_res_set_irq(device_t dev, void *context, u_int32_t *irq,
+static void	acpi_res_set_irq(device_t dev, void *context, u_int8_t *irq,
 				 int count, int trig, int pol);
-static void	acpi_res_set_drq(device_t dev, void *context, u_int32_t *drq,
+static void	acpi_res_set_ext_irq(device_t dev, void *context,
+				     u_int32_t *irq, int count, int trig,
+				     int pol);
+static void	acpi_res_set_drq(device_t dev, void *context, u_int8_t *drq,
 				 int count);
 static void	acpi_res_set_start_dependant(device_t dev, void *context,
 					     int preference);
@@ -399,6 +402,7 @@ struct acpi_parse_resource_set acpi_res_
     acpi_res_set_memory,
     acpi_res_set_memoryrange,
     acpi_res_set_irq,
+    acpi_res_set_ext_irq,
     acpi_res_set_drq,
     acpi_res_set_start_dependant,
     acpi_res_set_end_dependant
@@ -480,7 +484,7 @@ acpi_res_set_memoryrange(device_t dev, v
 }
 
 static void
-acpi_res_set_irq(device_t dev, void *context, u_int32_t *irq, int count,
+acpi_res_set_irq(device_t dev, void *context, u_int8_t *irq, int count,
     int trig, int pol)
 {
     struct acpi_res_context	*cp = (struct acpi_res_context *)context;
@@ -501,7 +505,28 @@ acpi_res_set_irq(device_t dev, void *con
 }
 
 static void
-acpi_res_set_drq(device_t dev, void *context, u_int32_t *drq, int count)
+acpi_res_set_ext_irq(device_t dev, void *context, u_int32_t *irq, int count,
+    int trig, int pol)
+{
+    struct acpi_res_context	*cp = (struct acpi_res_context *)context;
+
+    if (cp == NULL || irq == NULL)
+	return;
+
+    /* This implements no resource relocation. */
+    if (count != 1)
+	return;
+
+    bus_set_resource(dev, SYS_RES_IRQ, cp->ar_nirq++, *irq, 1);
+#if 0	/* From FreeBSD-5 XXX */
+    BUS_CONFIG_INTR(dev, *irq, (trig == ACPI_EDGE_SENSITIVE) ?
+	INTR_TRIGGER_EDGE : INTR_TRIGGER_LEVEL, (pol == ACPI_ACTIVE_HIGH) ?
+	INTR_POLARITY_HIGH : INTR_POLARITY_LOW);
+#endif
+}
+
+static void
+acpi_res_set_drq(device_t dev, void *context, u_int8_t *drq, int count)
 {
     struct acpi_res_context	*cp = (struct acpi_res_context *)context;
 
Index: sys/dev/acpica5/acpi_thermal.c
===================================================================
RCS file: /home/source/dragonfly/cvs/src/sys/dev/acpica5/acpi_thermal.c,v
retrieving revision 1.5
diff -u -p -r1.5 acpi_thermal.c
--- sys/dev/acpica5/acpi_thermal.c	4 Jun 2005 14:25:45 -0000	1.5
+++ sys/dev/acpica5/acpi_thermal.c	4 Oct 2006 03:58:10 -0000
@@ -685,12 +685,12 @@ acpi_tz_notify_handler(ACPI_HANDLE h, UI
     switch(notify) {
     case TZ_NOTIFY_TEMPERATURE:
 	/* Temperature change occurred */
-	AcpiOsQueueForExecution(OSD_PRIORITY_HIGH, acpi_tz_monitor, sc);
+	AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_tz_monitor, sc);
 	break;
     case TZ_NOTIFY_DEVICES:
     case TZ_NOTIFY_LEVELS:
 	/* Zone devices/setpoints changed */
-	AcpiOsQueueForExecution(OSD_PRIORITY_HIGH,
+	AcpiOsExecute(OSL_NOTIFY_HANDLER,
 				(ACPI_OSD_EXEC_CALLBACK)acpi_tz_establish, sc);
 	break;
     default:
@@ -761,7 +761,7 @@ acpi_tz_power_profile(void *arg)
 	    sc->tz_flags |= TZ_FLAG_NO_SCP;
 	} else {
 	    /* We have to re-evaluate the entire zone now */
-	    AcpiOsQueueForExecution(OSD_PRIORITY_HIGH,
+	    AcpiOsExecute(OSL_NOTIFY_HANDLER,
 				    (ACPI_OSD_EXEC_CALLBACK)acpi_tz_establish,
 				    sc);
 	}
Index: sys/dev/acpica5/acpi_timer.c
===================================================================
RCS file: /home/source/dragonfly/cvs/src/sys/dev/acpica5/acpi_timer.c,v
retrieving revision 1.9
diff -u -p -r1.9 acpi_timer.c
--- sys/dev/acpica5/acpi_timer.c	25 Oct 2006 20:55:52 -0000	1.9
+++ sys/dev/acpica5/acpi_timer.c	5 Nov 2006 10:14:43 -0000
@@ -132,7 +132,7 @@ acpi_timer_identify(driver_t *driver, de
 
     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
 
-    if (acpi_disabled("timer") || AcpiGbl_FADT == NULL)
+    if (acpi_disabled("timer"))
 	return (ENXIO);
 
     if ((dev = BUS_ADD_CHILD(parent, parent, 0, "acpi_timer", 0)) == NULL) {
@@ -142,10 +142,10 @@ acpi_timer_identify(driver_t *driver, de
     acpi_timer_dev = dev;
 
     rid = 0;
-    rlen = AcpiGbl_FADT->PmTmLen;
-    rtype = (AcpiGbl_FADT->XPmTmrBlk.AddressSpaceId)
+    rlen = AcpiGbl_FADT.PmTimerLength;
+    rtype = (AcpiGbl_FADT.XPmTimerBlock.SpaceId)
       ? SYS_RES_IOPORT : SYS_RES_MEMORY;
-    rstart = AcpiGbl_FADT->XPmTmrBlk.Address;
+    rstart = AcpiGbl_FADT.XPmTimerBlock.Address;
     bus_set_resource(dev, rtype, rid, rstart, rlen);
     acpi_timer_reg = bus_alloc_resource_any(dev, rtype, &rid, RF_ACTIVE);
     if (acpi_timer_reg == NULL) {
@@ -155,7 +155,7 @@ acpi_timer_identify(driver_t *driver, de
     }
     acpi_timer_bsh = rman_get_bushandle(acpi_timer_reg);
     acpi_timer_bst = rman_get_bustag(acpi_timer_reg);
-    if (AcpiGbl_FADT->TmrValExt != 0)
+    if ((AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) != 0)
 	acpi_counter_mask = 0xffffffff;
     else
 	acpi_counter_mask = 0x00ffffff;
@@ -182,7 +182,7 @@ acpi_timer_identify(driver_t *driver, de
     }
 
     sprintf(desc, "%d-bit timer at 3.579545MHz",
-	    AcpiGbl_FADT->TmrValExt ? 32 : 24);
+	    (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) ? 32 : 24);
     device_set_desc_copy(dev, desc);
 
     cputimer_register(&acpi_cputimer);
Index: sys/dev/acpica5/acpivar.h
===================================================================
RCS file: /home/source/dragonfly/cvs/src/sys/dev/acpica5/acpivar.h,v
retrieving revision 1.9
diff -u -p -r1.9 acpivar.h
--- sys/dev/acpica5/acpivar.h	25 Oct 2006 20:55:52 -0000	1.9
+++ sys/dev/acpica5/acpivar.h	26 Oct 2006 05:29:11 -0000
@@ -255,9 +255,11 @@ struct acpi_parse_resource_set {
 		    uint32_t length);
     void	(*set_memoryrange)(device_t dev, void *context, uint32_t low,
 		    uint32_t high, uint32_t length, uint32_t align);
-    void	(*set_irq)(device_t dev, void *context, u_int32_t *irq,
+    void	(*set_irq)(device_t dev, void *context, u_int8_t *irq,
 		    int count, int trig, int pol);
-    void	(*set_drq)(device_t dev, void *context, u_int32_t *drq,
+    void	(*set_ext_irq)(device_t dev, void *context, u_int32_t *irq,
+		    int count, int trig, int pol);
+    void	(*set_drq)(device_t dev, void *context, u_int8_t *drq,
 		    int count);
     void	(*set_start_dependant)(device_t dev, void *context,
 		    int preference);
Index: sys/dev/acpica5/include,acglobal.h.patch
===================================================================
RCS file: sys/dev/acpica5/include,acglobal.h.patch
diff -N sys/dev/acpica5/include,acglobal.h.patch
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sys/dev/acpica5/include,acglobal.h.patch	7 Nov 2006 04:58:21 -0000
@@ -0,0 +1,19 @@
+# $Dragonfly$
+
+--- acglobal.h.orig	2006-09-13 02:49:30.000000000 +0900
++++ acglobal.h	2006-11-05 21:06:38.000000000 +0900
+@@ -321,12 +321,13 @@
+ extern const char                      *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS];
+ 
+ /* Exception codes */
+-
++#ifndef DEFINE_ACPI_GLOBALS
+ extern      char const                 *AcpiGbl_ExceptionNames_Env[];
+ extern      char const                 *AcpiGbl_ExceptionNames_Pgm[];
+ extern      char const                 *AcpiGbl_ExceptionNames_Tbl[];
+ extern      char const                 *AcpiGbl_ExceptionNames_Aml[];
+ extern      char const                 *AcpiGbl_ExceptionNames_Ctrl[];
++#endif
+ 
+ 
+ /*****************************************************************************
Index: sys/dev/acpica5/include,acpiosxf.h.patch
===================================================================
RCS file: sys/dev/acpica5/include,acpiosxf.h.patch
diff -N sys/dev/acpica5/include,acpiosxf.h.patch
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sys/dev/acpica5/include,acpiosxf.h.patch	7 Nov 2006 04:58:50 -0000
@@ -0,0 +1,19 @@
+# $DragonFly$
+
+--- acpiosxf.h	2006-07-08 05:32:42.000000000 +0900
++++ acpiosxf.h	2006-09-10 16:35:59.000000000 +0900
+@@ -198,9 +198,12 @@
+ AcpiOsDeleteLock (
+     ACPI_SPINLOCK           Handle);
+ 
++#define AcpiOsAcquireLock(Handle) \
++_AcpiOsAcquireLock(Handle, __func__, __LINE__)
+ ACPI_CPU_FLAGS
+-AcpiOsAcquireLock (
+-    ACPI_SPINLOCK           Handle);
++_AcpiOsAcquireLock (
++    ACPI_SPINLOCK           Handle,
++    const char *func, int line);
+ 
+ void
+ AcpiOsReleaseLock (
Index: sys/dev/acpica5/Osd/OsdCache.c
===================================================================
RCS file: sys/dev/acpica5/Osd/OsdCache.c
diff -N sys/dev/acpica5/Osd/OsdCache.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sys/dev/acpica5/Osd/OsdCache.c	4 Oct 2006 03:58:10 -0000
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2006 Jeffrey M. Hsu.  All rights reserved.
+ *
+ * This code is derived from software contributed to The DragonFly Project
+ * by Jeffrey M. Hsu.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of The DragonFly Project nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific, prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/objcache.h>
+
+struct acpicache {
+	struct objcache *cache;
+	struct objcache_malloc_args args;
+};
+
+#include "acpi.h"
+
+#ifndef ACPI_USE_LOCAL_CACHE
+
+ACPI_STATUS
+AcpiOsCreateCache(char *CacheName, UINT16 ObjectSize, UINT16 MaxDepth,
+    ACPI_CACHE_T **ReturnCache)
+{
+	ACPI_CACHE_T *cache;
+
+	cache = kmalloc(sizeof(*cache), M_TEMP, M_WAITOK);
+	cache->args.objsize = ObjectSize;
+	cache->args.mtype = M_CACHE;
+	cache->cache = objcache_create(CacheName, MaxDepth, 0,
+	    null_ctor, null_dtor, NULL,
+	    objcache_malloc_alloc, objcache_malloc_free, &cache->args);
+	*ReturnCache = cache;
+	return AE_OK;
+}
+
+ACPI_STATUS
+AcpiOsDeleteCache(ACPI_CACHE_T *Cache)
+{
+	objcache_destroy(Cache->cache);
+	kfree(Cache, M_TEMP);
+	return AE_OK;
+}
+
+
+ACPI_STATUS
+AcpiOsPurgeCache(ACPI_CACHE_T *Cache)
+{
+	struct objcache *reclaimlist[] = { Cache->cache };
+
+	objcache_reclaimlist(reclaimlist, 1, M_WAITOK);
+	return AE_OK;
+}
+
+void *
+AcpiOsAcquireObject(ACPI_CACHE_T *Cache)
+{
+	void *Object;
+
+	Object = objcache_get(Cache->cache, M_WAITOK);
+	bzero(Object, Cache->args.objsize);
+	return Object;
+}
+
+ACPI_STATUS
+AcpiOsReleaseObject(ACPI_CACHE_T *Cache, void *Object)
+{
+	objcache_put(Cache->cache, Object);
+	return AE_OK;
+}
+
+#endif
Index: sys/dev/acpica5/Osd/OsdDebug.c
===================================================================
RCS file: /home/source/dragonfly/cvs/src/sys/dev/acpica5/Osd/OsdDebug.c,v
retrieving revision 1.4
diff -u -p -r1.4 OsdDebug.c
--- sys/dev/acpica5/Osd/OsdDebug.c	25 Oct 2006 20:55:52 -0000	1.4
+++ sys/dev/acpica5/Osd/OsdDebug.c	26 Oct 2006 05:29:12 -0000
@@ -60,6 +60,7 @@ AcpiOsGetLine(char *Buffer)
 #endif /* DDB */
 }
 
+#if 0	/* unused for ages */
 void
 AcpiOsDbgAssert(void *FailedAssertion, void *FileName, UINT32 LineNumber,
     char *Message)
@@ -67,6 +68,7 @@ AcpiOsDbgAssert(void *FailedAssertion, v
     printf("ACPI: %s:%d - %s\n", (char *)FileName, LineNumber, Message);
     printf("ACPI: assertion  %s\n", (char *)FailedAssertion);
 }
+#endif
 
 ACPI_STATUS
 AcpiOsSignal(UINT32 Function, void *Info)
Index: sys/dev/acpica5/Osd/OsdInterface.c
===================================================================
RCS file: sys/dev/acpica5/Osd/OsdInterface.c
diff -N sys/dev/acpica5/Osd/OsdInterface.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sys/dev/acpica5/Osd/OsdInterface.c	4 Oct 2006 03:58:10 -0000
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2006 Jeffrey M. Hsu.  All rights reserved.
+ *
+ * This code is derived from software contributed to The DragonFly Project
+ * by Jeffrey M. Hsu.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of The DragonFly Project nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific, prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "acpi.h"
+
+/*
+ * Match an interface string to the interfaces supported by the
+ * host. Strings originate from an AML call to the _OSI method.
+ *
+ * Returns AE_OK if interface is supported, AE_SUPPORT otherwise.
+ */
+ACPI_STATUS
+AcpiOsValidateInterface (char *Interface)
+{
+	return (AE_SUPPORT);
+}
Index: sys/dev/acpica5/Osd/OsdMemory.c
===================================================================
RCS file: /home/source/dragonfly/cvs/src/sys/dev/acpica5/Osd/OsdMemory.c,v
retrieving revision 1.4
diff -u -p -r1.4 OsdMemory.c
--- sys/dev/acpica5/Osd/OsdMemory.c	5 Sep 2006 00:55:36 -0000	1.4
+++ sys/dev/acpica5/Osd/OsdMemory.c	20 Nov 2006 11:40:22 -0000
@@ -64,23 +64,25 @@ AcpiOsFree(void *Memory)
     kfree(Memory, M_ACPICA);
 }
 
-ACPI_STATUS
-AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS PhysicalAddress, ACPI_SIZE Length,
-    void **LogicalAddress)
+void *
+AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS Where, ACPI_SIZE Length)
 {
     acpi_memtrack_t track;
+    void *map;
 
-    *LogicalAddress = pmap_mapdev((vm_offset_t)PhysicalAddress, Length);
-    if (*LogicalAddress == NULL)
-	return(AE_BAD_ADDRESS);
+    if (Length == 0)
+	db_print_backtrace();
+    map = pmap_mapdev((vm_offset_t)Where, Length);
+    if (map == NULL)
+	return(NULL);
     else {
 	track = kmalloc(sizeof(struct acpi_memtrack), M_ACPICA, M_INTWAIT);
 	track->next = acpi_mapbase;
-	track->base = *LogicalAddress;
+	track->base = map;
 	track->size = Length;
 	acpi_mapbase = track;
     }
-    return(AE_OK);
+    return(map);
 }
 
 void
@@ -161,7 +163,8 @@ AcpiOsReadMemory(ACPI_PHYSICAL_ADDRESS A
 {
     void	*LogicalAddress;
 
-    if (AcpiOsMapMemory(Address, Width / 8, &LogicalAddress) != AE_OK)
+    LogicalAddress = AcpiOsMapMemory(Address, Width / 8);
+    if (LogicalAddress == NULL)
 	return (AE_NOT_EXIST);
 
     switch (Width) {
@@ -192,7 +195,8 @@ AcpiOsWriteMemory(ACPI_PHYSICAL_ADDRESS 
 {
     void	*LogicalAddress;
 
-    if (AcpiOsMapMemory(Address, Width / 8, &LogicalAddress) != AE_OK)
+    LogicalAddress = AcpiOsMapMemory(Address, Width / 8);
+    if (LogicalAddress == NULL)
 	return (AE_NOT_EXIST);
 
     switch (Width) {
@@ -217,3 +221,15 @@ AcpiOsWriteMemory(ACPI_PHYSICAL_ADDRESS 
 
     return (AE_OK);
 }
+
+ACPI_STATUS
+AcpiOsValidateAddress (UINT8 SpaceId, ACPI_PHYSICAL_ADDRESS Address,
+    ACPI_SIZE Length)
+{
+#if 0
+    if (Address == 0)
+	return (AE_AML_ILLEGAL_ADDRESS);
+    /* XXX */
+#endif
+    return (AE_OK);
+}
Index: sys/dev/acpica5/Osd/OsdSchedule.c
===================================================================
RCS file: /home/source/dragonfly/cvs/src/sys/dev/acpica5/Osd/OsdSchedule.c,v
retrieving revision 1.6
diff -u -p -r1.6 OsdSchedule.c
--- sys/dev/acpica5/Osd/OsdSchedule.c	5 Sep 2006 00:55:36 -0000	1.6
+++ sys/dev/acpica5/Osd/OsdSchedule.c	4 Oct 2006 03:58:10 -0000
@@ -68,7 +68,7 @@ struct acpi_task {
     struct lwkt_msg		at_msg;
     ACPI_OSD_EXEC_CALLBACK	at_function;
     void			*at_context;
-    int				at_priority;
+    ACPI_EXECUTE_TYPE		at_type;
 };
 
 static struct thread *acpi_task_td;
@@ -111,29 +111,18 @@ acpi_task_thread(void *arg)
  * to automatically free the message.
  */
 ACPI_STATUS
-AcpiOsQueueForExecution(UINT32 Priority, ACPI_OSD_EXEC_CALLBACK Function,
-    void *Context)
+AcpiOsExecute(ACPI_EXECUTE_TYPE Type, ACPI_OSD_EXEC_CALLBACK Function,
+	      void *Context)
 {
     struct acpi_task	*at;
-    int pri;
 
-    ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
-
-    if (Function == NULL)
-	return_ACPI_STATUS (AE_BAD_PARAMETER);
-
-    switch (Priority) {
-    case OSD_PRIORITY_GPE:
-	pri = 4;
-	break;
-    case OSD_PRIORITY_HIGH:
-	pri = 3;
-	break;
-    case OSD_PRIORITY_MED:
-	pri = 2;
-	break;
-    case OSD_PRIORITY_LO:
-	pri = 1;
+    switch (Type) {
+    case OSL_GLOBAL_LOCK_HANDLER:
+    case OSL_NOTIFY_HANDLER:
+    case OSL_GPE_HANDLER:
+    case OSL_DEBUGGER_THREAD:
+    case OSL_EC_POLL_HANDLER:
+    case OSL_EC_BURST_HANDLER:
 	break;
     default:
 	return_ACPI_STATUS (AE_BAD_PARAMETER);
@@ -145,7 +134,7 @@ AcpiOsQueueForExecution(UINT32 Priority,
 		lwkt_cmd_op_none, lwkt_cmd_op_none);
     at->at_function = Function;
     at->at_context = Context;
-    at->at_priority = pri;
+    at->at_type = Type;
     lwkt_sendmsg(&acpi_task_td->td_msgport, &at->at_msg);
     return_ACPI_STATUS (AE_OK);
 }
Index: sys/dev/acpica5/Osd/OsdSynch.c
===================================================================
RCS file: /home/source/dragonfly/cvs/src/sys/dev/acpica5/Osd/OsdSynch.c,v
retrieving revision 1.8
diff -u -p -r1.8 OsdSynch.c
--- sys/dev/acpica5/Osd/OsdSynch.c	5 Sep 2006 00:55:36 -0000	1.8
+++ sys/dev/acpica5/Osd/OsdSynch.c	4 Oct 2006 03:58:10 -0000
@@ -41,6 +41,7 @@
 #include <sys/lock.h>
 #include <sys/thread.h>
 #include <sys/thread2.h>
+#include <sys/spinlock2.h>
 
 #define _COMPONENT	ACPI_OS_SERVICES
 ACPI_MODULE_NAME("SYNCH")
@@ -343,49 +344,138 @@ AcpiOsSignalSemaphore(ACPI_HANDLE Handle
     return_ACPI_STATUS (AE_OK);
 }
 
+struct acpi_spinlock {
+    thread_t	owner;
+    int count;
+    int idle;
+#ifdef ACPI_DEBUG_LOCKS
+    const char *func;
+    int line;
+#endif
+};
+
 ACPI_STATUS
-AcpiOsCreateLock(ACPI_HANDLE *OutHandle)
+AcpiOsCreateLock(ACPI_SPINLOCK *OutHandle)
 {
-    struct lock *lock;
+    ACPI_SPINLOCK spin;
 
     if (OutHandle == NULL)
 	return (AE_BAD_PARAMETER);
-    lock = kmalloc(sizeof(*lock), M_ACPISEM, M_INTWAIT|M_ZERO);
-    lockinit(lock, "oslck", 0, 0);
-    *OutHandle = (ACPI_HANDLE)lock;
+    spin = kmalloc(sizeof(*spin), M_ACPISEM, M_INTWAIT|M_ZERO);
+    spin->owner = NULL;
+    spin->count = 0;
+    spin->idle = 0;
+#ifdef ACPI_DEBUG_LOCKS
+    spin->func = "";
+    spin->line = 0;
+#endif
+    *OutHandle = spin;
     return (AE_OK);
 }
 
 void
-AcpiOsDeleteLock (ACPI_HANDLE Handle)
+AcpiOsDeleteLock (ACPI_SPINLOCK Spin)
 {
-    struct lock *lock;
-
-    if ((lock = (struct lock *)Handle) != NULL)
-	    kfree(lock, M_ACPISEM);
+    if (Spin != NULL)
+	kfree(Spin, M_ACPISEM);
 }
 
+#ifdef ACPI_DEBUG_LOCKS
+void db_print_backtrace(void);
+#endif
 /*
- * The Flags parameter seems to state whether or not caller is an ISR
- * (and thus can't block) but since we have ithreads, we don't worry
- * about potentially blocking.
+ * OS-dependent locking primitives.  These routines should be able to be
+ * called from an interrupt-handler or cpu_idle thread.
+ *
+ * NB: some of ACPI-CA functions with locking flags, say AcpiSetRegister(),
+ * are changed to unconditionally call AcpiOsAcquireLock/AcpiOsReleaseLock.
  */
-void
-AcpiOsAcquireLock (ACPI_HANDLE Handle, UINT32 Flags)
+ACPI_CPU_FLAGS
+#ifdef ACPI_DEBUG_LOCKS
+_AcpiOsAcquireLock (ACPI_SPINLOCK Spin, const char *func, int line)
+#else
+AcpiOsAcquireLock (ACPI_SPINLOCK Spin)
+#endif
 {
-    struct lock *lock;
-
-    if ((lock = (struct lock *)Handle) != NULL)
-	lockmgr(lock, LK_EXCLUSIVE|LK_RETRY);
+    struct globaldata *gd = mycpu;
+    thread_t td = curthread;
+    thread_t owner;
+
+    if (Spin == NULL)
+	return(0);
+    if (&gd->gd_idlethread == td) {
+	++Spin->idle;
+	return(0);
+    }
+    crit_enter_gd(gd);
+    if (Spin->owner == td) {
+	/* this is a wrong condition */
+#ifdef ACPI_DEBUG_LOCKS
+	printf("%s: %p already locked by myself at %s:%d, %d\n",
+	       td->td_comm, Spin, Spin->func, Spin->line, 0);
+	db_print_backtrace();
+#endif
+    }
+    while (Spin->idle || ((owner = Spin->owner) != NULL && owner != td)) {
+#ifdef ACPI_DEBUG_LOCKS
+	if (Spin->idle)
+		owner = &gd->gd_idlethread;
+	printf("%s: %p already locked by %p(%s) at %s:%d, yielding\n",
+	       td->td_comm, Spin, owner, owner->td_comm,
+	       Spin->func, Spin->line);
+#endif
+	crit_exit_gd(gd);
+	crit_enter_gd(gd);
+    }
+    if (++Spin->count == 1) {
+	Spin->owner = td;
+#ifdef ACPI_DEBUG_LOCKS
+	Spin->func = func, Spin->line = line;
+#endif
+    }
+    crit_exit_gd(gd);
+    return(0);
 }
 
+/*
+ * Flags: if non-zero, only release the lock if the current thread
+ *	  has acquired it.
+ */
 void
-AcpiOsReleaseLock (ACPI_HANDLE Handle, UINT32 Flags)
+AcpiOsReleaseLock (ACPI_SPINLOCK Spin, UINT32 Flags)
 {
-    struct lock *lock;
+    struct globaldata *gd;
+#ifdef ACPI_DEBUG_LOCKS
+    thread_t td;
+#endif
 
-    if ((lock = (struct lock *)Handle) != NULL)
-	lockmgr(lock, LK_RELEASE);
+    if (Spin == NULL)
+	return;
+    gd = mycpu;
+    if (&gd->gd_idlethread == curthread) {
+	--Spin->idle;
+	return;
+    }
+    crit_enter_gd(gd);
+    if (Flags && Spin->count == 0) {
+	crit_exit_gd(gd);
+	return;
+    }
+#ifdef ACPI_DEBUG_LOCKS
+    if (Spin->count == 0) {
+	td = curthread;
+	printf("%s: %p(%s) is not the owner of %p\n", __func__,
+	       td, td->td_comm ? td->td_comm : "?", Spin);
+    }
+#endif
+    if (--Spin->count == 0) {
+	Spin->owner = NULL;
+#ifdef ACPI_DEBUG_LOCKS
+	Spin->func = "";
+	Spin->line = 0;
+#endif
+    }
+    crit_exit_gd(gd);
 }
 
 #ifdef notyet
Index: sys/machine/pc32/acpica5/OsdEnvironment.c
===================================================================
RCS file: /home/source/dragonfly/cvs/src/sys/machine/pc32/acpica5/OsdEnvironment.c,v
retrieving revision 1.2
diff -u -p -r1.2 OsdEnvironment.c
--- sys/machine/pc32/acpica5/OsdEnvironment.c	27 Jun 2004 08:52:45 -0000	1.2
+++ sys/machine/pc32/acpica5/OsdEnvironment.c	16 Nov 2006 15:08:19 -0000
@@ -54,10 +54,10 @@ AcpiOsTerminate(void)
 	return(0);
 }
 
-ACPI_STATUS
-AcpiOsGetRootPointer(UINT32 Flags, ACPI_POINTER *RsdpPhysicalAddress)
+ACPI_PHYSICAL_ADDRESS
+AcpiOsGetRootPointer(void)
 {
-	ACPI_POINTER ptr;
+	ACPI_NATIVE_UINT ptr;
 	ACPI_STATUS status;
 
 	if (i386_acpi_root == 0) {
@@ -66,13 +66,10 @@ AcpiOsGetRootPointer(UINT32 Flags, ACPI_
 		 * RSDP in a hint.  We could recover this rather than searching
 		 * manually here.
 		 */
-		status = AcpiFindRootPointer(Flags, &ptr);
+		status = AcpiFindRootPointer(&ptr);
 		if (status == AE_OK)
-			i386_acpi_root = ptr.Pointer.Physical;
-	} else
-		status = AE_OK;
+			i386_acpi_root = ptr;
+	}
 
-	RsdpPhysicalAddress->PointerType = ACPI_PHYSICAL_POINTER;
-	RsdpPhysicalAddress->Pointer.Physical = i386_acpi_root;
-	return (status);
+	return (i386_acpi_root);
 }
Index: sys/machine/pc32/acpica5/acpi_machdep.c
===================================================================
RCS file: /home/source/dragonfly/cvs/src/sys/machine/pc32/acpica5/acpi_machdep.c,v
retrieving revision 1.11
diff -u -p -r1.11 acpi_machdep.c
--- sys/machine/pc32/acpica5/acpi_machdep.c	7 Nov 2006 06:43:24 -0000	1.11
+++ sys/machine/pc32/acpica5/acpi_machdep.c	24 Nov 2006 15:23:58 -0000
@@ -320,8 +320,8 @@ acpi_machdep_init(device_t dev)
 	acpi_install_wakeup_handler(sc);
 
 	if (intr_model == ACPI_INTR_PIC)
-		BUS_CONFIG_INTR(dev, AcpiGbl_FADT->SciInt, INTR_TRIGGER_LEVEL,
-		    INTR_POLARITY_LOW);
+		BUS_CONFIG_INTR(dev, AcpiGbl_FADT.SciInterrupt,
+		    INTR_TRIGGER_LEVEL, INTR_POLARITY_LOW);
 	else
 		acpi_SetIntrModel(intr_model);
 
Index: usr.sbin/acpi/acpidb/Makefile
===================================================================
RCS file: /home/source/dragonfly/cvs/src/usr.sbin/acpi/acpidb/Makefile,v
retrieving revision 1.3
diff -u -p -r1.3 Makefile
--- usr.sbin/acpi/acpidb/Makefile	16 Aug 2005 10:31:35 -0000	1.3
+++ usr.sbin/acpi/acpidb/Makefile	17 Nov 2006 06:47:17 -0000
@@ -24,25 +24,27 @@ SRCS+=	dbcmds.c dbdisply.c dbexec.c dbfi
 	nsinit.c nsload.c nsnames.c nsobject.c \
 	nsparse.c nssearch.c nsutils.c nswalk.c \
 	nsxfeval.c nsxfname.c nsxfobj.c \
-	psargs.c psopcode.c psparse.c psscope.c \
+	psargs.c psloop.c psopcode.c psparse.c psscope.c \
 	pstree.c psutils.c pswalk.c psxface.c \
-	rsaddr.c rscalc.c rscreate.c rsdump.c \
+	rsaddr.c rscalc.c rscreate.c rsdump.c rsinfo.c \
 	rsio.c rsirq.c rslist.c rsmemory.c \
 	rsmisc.c rsutils.c rsxface.c \
-	tbconvrt.c tbget.c tbgetall.c tbinstal.c \
-	tbrsdt.c tbutils.c tbxface.c tbxfroot.c \
-	utalloc.c utcopy.c utdebug.c utdelete.c \
+	tbfadt.c tbfind.c tbinstal.c tbutils.c tbxface.c tbxfroot.c \
+	utalloc.c utcache.c utcopy.c utdebug.c utdelete.c \
 	uteval.c utglobal.c utinit.c utmath.c \
-	utmisc.c utobject.c utxface.c
+	utmisc.c utmutex.c utobject.c utresrc.c utstate.c utxface.c
+
+SRCS+=	aeexec.c
 
 .include <bsd.init.mk>
-.if ${ACPICA_VERSION} >= 20041203
-CONTRIBDIR= ${SYSDIR}/${ACPICA_DIR}
-SRCS+=	osunixxf.c.patch
-.endif
 MAN=	acpidb.8
+.PATH:	${SYSDIR}/${ACPICA_DIR}/tools/acpiexec
 
 CFLAGS+= -DACPI_APPLICATION -DACPI_DEBUG_OUTPUT -DACPI_DEBUGGER \
-	-DACPI_DISASSEMBLER
+	-DACPI_DISASSEMBLER -D__cdecl=
+
+CONTRIBDIR=	${SYSDIR}/${ACPICA_DIR}
+SRCS+=		osunixxf.c.patch
 
 .include <bsd.prog.mk>
+OBJS:=		${OBJS:N*/*}
Index: usr.sbin/acpi/acpidb/acpidb.c
===================================================================
RCS file: /home/source/dragonfly/cvs/src/usr.sbin/acpi/acpidb/acpidb.c,v
retrieving revision 1.1
diff -u -p -r1.1 acpidb.c
--- usr.sbin/acpi/acpidb/acpidb.c	5 Jul 2004 00:22:43 -0000	1.1
+++ usr.sbin/acpi/acpidb/acpidb.c	17 Nov 2006 13:25:47 -0000
@@ -338,12 +338,14 @@ DECLARE_VM_SPACE_HANDLER(smbus,		ACPI_AD
 DECLARE_VM_SPACE_HANDLER(cmos,		ACPI_ADR_SPACE_CMOS);
 DECLARE_VM_SPACE_HANDLER(pci_bar_target,ACPI_ADR_SPACE_PCI_BAR_TARGET);
 
+static u_int8_t *mapped_rsdp;
+#define ACPI_MAX_INIT_TABLES (16)
+static ACPI_TABLE_DESC		Tables[ACPI_MAX_INIT_TABLES];
+
 /*
  * Load DSDT data file and invoke debugger
  */
 
-static UINT32	DummyGlobalLock;
-
 static int
 load_dsdt(const char *dsdtfile)
 {
@@ -352,7 +354,7 @@ load_dsdt(const char *dsdtfile)
 	struct stat		 sb;
 	int			 fd, fd2;
 	int			 error;
-	ACPI_TABLE_HEADER	*tableptr;
+	ACPI_TABLE_HEADER	*Table;
 
 	fd = open(dsdtfile, O_RDONLY, 0);
 	if (fd == -1) {
@@ -368,7 +370,9 @@ load_dsdt(const char *dsdtfile)
 		perror("mmap");
 		return (-1);
 	}
+	mapped_rsdp = code;
 	if ((error = AcpiInitializeSubsystem()) != AE_OK) {
+		err(1, "AcpiInitializeSubsystem returned %d", error);
 		return (-1);
 	}
 
@@ -445,17 +449,22 @@ load_dsdt(const char *dsdtfile)
 		return (-1);
 	}
 
-	AcpiGbl_FACS = malloc(sizeof (ACPI_COMMON_FACS));
-	if (AcpiGbl_FACS == NULL) {
-		fprintf(stderr, "could not allocate memory for FACS\n");
+	AcpiGbl_GlobalLockPresent = TRUE;
+
+	error = AcpiDbReadTableFromFile (filetmp, &Table);
+	if (ACPI_FAILURE(error)) {
+		fprintf(stderr, "AcpiDbReadTableFromFile failed: %s\n",
+			AcpiFormatException(error));
+		return (-1);
+	}
+	AeBuildLocalTables(Table);
+	if (ACPI_FAILURE(error = AeInstallTables())) {
+		fprintf(stderr, "AeInstallTables failed: %s\n",
+			AcpiFormatException(error));
 		return (-1);
 	}
-	DummyGlobalLock = 0;
-	AcpiGbl_CommonFACS.GlobalLock = &DummyGlobalLock;
-	AcpiGbl_GlobalLockPresent = TRUE;
 
-	AcpiDbGetTableFromFile(filetmp, NULL);
-	AcpiUtSetIntegerWidth (AcpiGbl_DSDT->Revision);
+	AcpiUtSetIntegerWidth (Table->Revision);
 
 	AcpiDbInitialize();
 	AcpiGbl_DebuggerConfiguration = 0;
@@ -476,6 +485,8 @@ usage(const char *progname)
 	exit(1);
 }
 
+BOOLEAN		AcpiGbl_IgnoreErrors = FALSE;
+
 int
 main(int argc, char *argv[])
 {
@@ -488,6 +499,7 @@ main(int argc, char *argv[])
 	}
 
 	AcpiDbgLevel = ACPI_DEBUG_DEFAULT;
+	AcpiGbl_EnableInterpreterSlack = TRUE;
 
 	aml_simulation_regload("region.ini");
 	if (load_dsdt(argv[1]) == 0) {
Index: usr.sbin/acpi/acpidb/osunixxf.c.patch
===================================================================
RCS file: /home/source/dragonfly/cvs/src/usr.sbin/acpi/acpidb/osunixxf.c.patch,v
retrieving revision 1.1
diff -u -p -r1.1 osunixxf.c.patch
--- usr.sbin/acpi/acpidb/osunixxf.c.patch	12 Mar 2005 14:33:40 -0000	1.1
+++ usr.sbin/acpi/acpidb/osunixxf.c.patch	24 Nov 2006 15:24:52 -0000
@@ -1,16 +1,26 @@
 $DragonFly: src/usr.sbin/acpi/acpidb/osunixxf.c.patch,v 1.1 2005/03/12 14:33:40 y0netan1 Exp $
 
---- osunixxf.c.orig	2005-02-12 08:32:17.000000000 +0900
-+++ osunixxf.c	2005-03-05 20:47:12.000000000 +0900
-@@ -184,8 +184,10 @@
-     UINT32                  Flags,
-     ACPI_POINTER           *Address)
+--- osunixxf.c.orig	2006-09-13 02:49:37.000000000 +0900
++++ osunixxf.c	2006-11-17 15:53:31.000000000 +0900
+@@ -428,13 +428,19 @@
+ AcpiOsGetLine (
+     char                    *Buffer)
  {
--
-+#if 0
-+    /* AeLocalGetRootPointer is not properly implemented yet */
-     return (AeLocalGetRootPointer(Flags, Address));
-+#endif
- }
+-    UINT8                   Temp;
++    UINT8                  Temp;
++    int			    c;
+     UINT32                  i;
  
  
+     for (i = 0; ; i++)
+     {
+-        scanf ("%1c", &Temp);
++        c = scanf ("%1c", &Temp);
++	if (c != 1)
++	{
++	    AcpiGbl_DbTerminateThreads = TRUE;
++	    break;
++	}
+         if (!Temp || Temp == '\n')
+         {
+             break;
Index: usr.sbin/acpi/iasl/Makefile
===================================================================
RCS file: /home/source/dragonfly/cvs/src/usr.sbin/acpi/iasl/Makefile,v
retrieving revision 1.1
diff -u -p -r1.1 Makefile
--- usr.sbin/acpi/iasl/Makefile	5 Jul 2004 00:22:43 -0000	1.1
+++ usr.sbin/acpi/iasl/Makefile	5 Nov 2006 11:29:37 -0000
@@ -23,13 +23,15 @@ SRCS+=	dbfileio.c dmbuffer.c dmnames.c d
 	nsparse.c nssearch.c nsutils.c nswalk.c nsxfobj.c \
         psargs.c psopcode.c psparse.c psscope.c \
         pstree.c psutils.c pswalk.c \
-        tbinstal.c tbutils.c \
+        tbfadt.c tbinstal.c tbutils.c tbxface.c \
 	utalloc.c utcopy.c utdebug.c utdelete.c \
         utglobal.c utobject.c utmisc.c utmath.c
 
+SRCS+=	adfile.c adwalk.c dmrestag.c dmtbdump.c dmtbinfo.c dmtable.c psloop.c utcache.c utmutex.c utresrc.c utstate.c
+
 MAN=	iasl.8
 
-CFLAGS+= -D_ACPI_ASL_COMPILER -I.
+CFLAGS+= -D_ACPI_ASL_COMPILER -DACPI_ASL_COMPILER -I.
 
 CFLAGS+= -D_USE_BERKELEY_YACC
 LFLAGS=	-i -PAslCompiler
