Update ACPI build wrappers to use new ACPI-CA code.
authorYONETANI Tomokazu <y0netan1@dragonflybsd.org>
Wed, 17 Jan 2007 17:31:20 +0000 (17:31 +0000)
committerYONETANI Tomokazu <y0netan1@dragonflybsd.org>
Wed, 17 Jan 2007 17:31:20 +0000 (17:31 +0000)
* many fixes in ACPI-CA code (see changes.txt for detail)

* enable interpreter slack code
  relaxed checking on AML code to get fewer warnings

* use OS implementation of spinlock and cache object:
  OSL cache code by:
  Jeffrey Hsu <hsu@dragonflybsd.org>
  Fix to semaphore and locking code:
  Simon 'corecode' Schubert <corecode@fs.ei.tum.de>

* added a few debugging knobs(on make command line):
  ACPI_DEBUG_LOCKS=yes to activate debugging code for AcpiOs*Lock()
  ACPI_DEBUG_MEMMAP=yes to activate debugging code for AcpiOs*MapMemory()

33 files changed:
sys/boot/pc32/libi386/biosacpi.c
sys/conf/acpi.mk
sys/conf/files
sys/dev/acpica5/Makefile
sys/dev/acpica5/Makefile.inc
sys/dev/acpica5/Osd/OsdCache.c [new file with mode: 0644]
sys/dev/acpica5/Osd/OsdDebug.c
sys/dev/acpica5/Osd/OsdInterface.c [new file with mode: 0644]
sys/dev/acpica5/Osd/OsdMemory.c
sys/dev/acpica5/Osd/OsdSchedule.c
sys/dev/acpica5/Osd/OsdSynch.c
sys/dev/acpica5/acdragonfly.h
sys/dev/acpica5/acpi.c
sys/dev/acpica5/acpi_acad.c
sys/dev/acpica5/acpi_button.c
sys/dev/acpica5/acpi_cmbat.c
sys/dev/acpica5/acpi_cpu.c
sys/dev/acpica5/acpi_ec.c
sys/dev/acpica5/acpi_lid.c
sys/dev/acpica5/acpi_resource.c
sys/dev/acpica5/acpi_thermal.c
sys/dev/acpica5/acpi_timer.c
sys/dev/acpica5/acpivar.h
sys/dev/acpica5/hardware,hwsleep.c.patch [new file with mode: 0644]
sys/dev/acpica5/include,acglobal.h.patch [new file with mode: 0644]
sys/dev/acpica5/include,acpiosxf.h.patch [new file with mode: 0644]
sys/platform/pc32/acpica5/OsdEnvironment.c
sys/platform/pc32/acpica5/acpi_machdep.c
sys/platform/pc32/include/acpica_machdep.h
usr.sbin/acpi/acpidb/Makefile
usr.sbin/acpi/acpidb/acpidb.c
usr.sbin/acpi/acpidb/osunixxf.c.patch
usr.sbin/acpi/iasl/Makefile

index 82595f9..87d8902 100644 (file)
@@ -24,7 +24,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/boot/i386/libi386/biosacpi.c,v 1.7 2003/08/25 23:28:31 obrien Exp $
- * $DragonFly: src/sys/boot/pc32/libi386/biosacpi.c,v 1.4 2005/08/16 10:31:35 y0netan1 Exp $
+ * $DragonFly: src/sys/boot/pc32/libi386/biosacpi.c,v 1.5 2007/01/17 17:31:19 y0netan1 Exp $
  */
 
 #include <stand.h>
  * 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 677c043..cc7167d 100644 (file)
@@ -1,7 +1,7 @@
-# $DragonFly: src/sys/conf/acpi.mk,v 1.4 2006/11/07 06:43:22 dillon Exp $
+# $DragonFly: src/sys/conf/acpi.mk,v 1.5 2007/01/17 17:31:19 y0netan1 Exp $
 #
 
-ACPICA_VERSION=                20050309
+ACPICA_VERSION=                20061109
 ACPICA_DIR?=           contrib/dev/acpica-unix-${ACPICA_VERSION}
 OSACPI_MI_DIR?=                dev/acpica5
 OSACPI_MD_DIR?=                machine/${MACHINE}/acpica5
index 0da202a..c9c6f5d 100644 (file)
@@ -1,5 +1,5 @@
 # $FreeBSD: src/sys/conf/files,v 1.340.2.137 2003/06/04 17:10:30 sam Exp $
-# $DragonFly: src/sys/conf/files,v 1.149 2007/01/08 01:38:02 swildner Exp $
+# $DragonFly: src/sys/conf/files,v 1.150 2007/01/17 17:31:19 y0netan1 Exp $
 #
 # The long compile-with and dependency lines are required because of
 # limitations in config: backslash-newline doesn't work in strings, and
@@ -1364,8 +1364,10 @@ ${OSACPI_MI_DIR}/acpi_powerres.c optional acpi
 ${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
@@ -1442,6 +1444,7 @@ ${ACPICA_DIR}/interpreter/executer/exstorob.c     optional acpi
 ${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
@@ -1469,6 +1472,7 @@ ${ACPICA_DIR}/resources/rsaddr.c          optional acpi
 ${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
@@ -1476,11 +1480,9 @@ ${ACPICA_DIR}/resources/rsmemory.c               optional acpi
 ${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
@@ -1494,5 +1496,8 @@ ${ACPICA_DIR}/utilities/utglobal.c                optional acpi
 ${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 816cad8..5d785d7 100644 (file)
@@ -1,10 +1,26 @@
 # $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 $
+# $DragonFly: src/sys/dev/acpica5/Makefile,v 1.15 2007/01/17 17:31:19 y0netan1 Exp $
+
+CONTRIBDIR=    ${SYSDIR}/${ACPICA_DIR}
+PATCHES=       hardware,hwsleep.c.patch include,acglobal.h.patch
 
 SYSDIR?= ${.CURDIR}/../..
+.if ACPI_DEBUG_LOCKS || ACPI_DEBUG_MEMMAP
+CFLAGS+=       -I${.OBJDIR}/include
+.if ACPI_DEBUG_LOCKS
+CFLAGS+=       -DACPI_DEBUG_LOCKS=1
+.endif
+.if ACPI_DEBUG_MEMMAP
+CFLAGS+=       -DACPI_DEBUG_MEMMAP=1
+.endif
+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 +29,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 +44,15 @@ SRCS+=      hwacpi.c hwgpe.c hwregs.c hwsleep.c hwtimer.c
 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 +65,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 +88,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 +113,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 44b3581..fd95ef4 100644 (file)
@@ -1,8 +1,9 @@
-# $DragonFly: src/sys/dev/acpica5/Makefile.inc,v 1.7 2005/08/16 10:31:35 y0netan1 Exp $
+# $DragonFly: src/sys/dev/acpica5/Makefile.inc,v 1.8 2007/01/17 17:31:19 y0netan1 Exp $
 
 .include "${SYSDIR}/conf/acpi.mk"
 
 CFLAGS+=       -I${.OBJDIR}                    \
+               -I${.OBJDIR}/include            \
                -I${.CURDIR}                    \
                -I${SYSDIR}/${OSACPI_MI_DIR}    \
                -I${SYSDIR}/${ACPICA_DIR}/include
diff --git a/sys/dev/acpica5/Osd/OsdCache.c b/sys/dev/acpica5/Osd/OsdCache.c
new file mode 100644 (file)
index 0000000..ac09144
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * 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.
+ *
+ * $DragonFly: src/sys/dev/acpica5/Osd/OsdCache.c,v 1.1 2007/01/17 17:31:19 y0netan1 Exp $
+ */
+
+#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, NULL, 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 4329d62..b0a601c 100644 (file)
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/acpica/Osd/OsdDebug.c,v 1.9 2004/09/02 04:28:05 njl Exp $
- * $DragonFly: src/sys/dev/acpica5/Osd/OsdDebug.c,v 1.5 2006/12/22 23:26:14 swildner Exp $
+ * $DragonFly: src/sys/dev/acpica5/Osd/OsdDebug.c,v 1.6 2007/01/17 17:31:19 y0netan1 Exp $
  */
 
 /*
@@ -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, void *FileName, UINT32 LineNumber,
     kprintf("ACPI: %s:%d - %s\n", (char *)FileName, LineNumber, Message);
     kprintf("ACPI: assertion  %s\n", (char *)FailedAssertion);
 }
+#endif
 
 ACPI_STATUS
 AcpiOsSignal(UINT32 Function, void *Info)
diff --git a/sys/dev/acpica5/Osd/OsdInterface.c b/sys/dev/acpica5/Osd/OsdInterface.c
new file mode 100644 (file)
index 0000000..cc3c1de
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ *
+ * $DragonFly: src/sys/dev/acpica5/Osd/OsdInterface.c,v 1.1 2007/01/17 17:31:19 y0netan1 Exp $
+ */
+
+#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 ba6a7d8..97da035 100644 (file)
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/acpica/Osd/OsdMemory.c,v 1.11 2004/04/14 03:39:08 njl Exp $
- * $DragonFly: src/sys/dev/acpica5/Osd/OsdMemory.c,v 1.5 2006/12/22 23:26:14 swildner Exp $
+ * $DragonFly: src/sys/dev/acpica5/Osd/OsdMemory.c,v 1.6 2007/01/17 17:31:19 y0netan1 Exp $
  */
 
 /*
@@ -46,6 +46,13 @@ struct acpi_memtrack {
     struct acpi_memtrack *next;
     void *base;
     ACPI_SIZE size;
+#if ACPI_DEBUG_MEMMAP
+    int freed;
+    struct {
+       const char *func;
+       int line;
+    } mapper, unmapper;
+#endif
 };
 
 typedef struct acpi_memtrack *acpi_memtrack_t;
@@ -64,40 +71,79 @@ AcpiOsFree(void *Memory)
     kfree(Memory, M_ACPICA);
 }
 
-ACPI_STATUS
-AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS PhysicalAddress, ACPI_SIZE Length,
-    void **LogicalAddress)
+#if ACPI_DEBUG_MEMMAP
+void *
+_AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS Where, ACPI_SIZE Length,
+                const char *caller, int line)
+#else
+void *
+AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS Where, ACPI_SIZE Length)
+#endif
 {
     acpi_memtrack_t track;
+    void *map;
 
-    *LogicalAddress = pmap_mapdev((vm_offset_t)PhysicalAddress, Length);
-    if (*LogicalAddress == NULL)
-       return(AE_BAD_ADDRESS);
+    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;
+#if ACPI_DEBUG_MEMMAP
+       for (track = acpi_mapbase; track != NULL; track = track->next) {
+           if (track->base == map)
+               break;
+       }
+#else
+       track = NULL;
+#endif
+       if (track == NULL) {
+           track = kmalloc(sizeof(*track), M_ACPICA, M_INTWAIT);
+           track->next = acpi_mapbase;
+           track->base = map;
+       }
        track->size = Length;
+#if ACPI_DEBUG_MEMMAP
+       track->freed = 0;
+       track->mapper.func = caller;
+       track->mapper.line = line;
+       track->unmapper.func = "";
+       track->unmapper.line = 0;
+#endif
        acpi_mapbase = track;
     }
-    return(AE_OK);
+    return(map);
 }
 
+#if ACPI_DEBUG_MEMMAP
+void
+_AcpiOsUnmapMemory(void *LogicalAddress, ACPI_SIZE Length,
+                  const char *caller, int line)
+#else
 void
 AcpiOsUnmapMemory(void *LogicalAddress, ACPI_SIZE Length)
+#endif
 {
     struct acpi_memtrack **ptrack;
     acpi_memtrack_t track;
 
 again:
     for (ptrack = &acpi_mapbase; (track = *ptrack); ptrack = &track->next) {
+#if ACPI_DEBUG_MEMMAP
+       if (track->freed)
+           continue;
+#endif
        /*
         * Exact match, degenerate case
         */
        if (track->base == LogicalAddress && track->size == Length) {
            *ptrack = track->next;
            pmap_unmapdev((vm_offset_t)track->base, track->size);
+#if ACPI_DEBUG_MEMMAP
+           track->freed = 1;
+           track->unmapper.func = caller;
+           track->unmapper.line = line;
+#else
            kfree(track, M_ACPICA);
+#endif
            return;
        }
        /*
@@ -112,7 +158,13 @@ again:
                   " large! %p/%08x (actual was %p/%08x)\n",
                   LogicalAddress, Length,
                   track->base, track->size);
+#if ACPI_DEBUG_MEMMAP
+           track->freed = 1;
+           track->unmapper.func = caller;
+           track->unmapper.line = line;
+#else
            kfree(track, M_ACPICA);
+#endif
            goto again;
        }
 
@@ -130,6 +182,18 @@ again:
     }
     kprintf("AcpiOsUnmapMemory: Warning, broken ACPI, bad unmap: %p/%08x\n",
        LogicalAddress, Length);
+#if ACPI_DEBUG_MEMMAP
+    for (track = acpi_mapbase; track != NULL; track = track->next) {
+       if (track->freed && track->base == LogicalAddress) {
+           kprintf("%s: unmapping: %p/%08x, mapped by %s:%d,"
+                  "last unmapped by %s:%d\n",
+               __func__, LogicalAddress, Length,
+               track->mapper.func, track->mapper.line,
+               track->unmapper.func, track->unmapper.line
+           );
+       }
+    }
+#endif
 }
 
 ACPI_STATUS
@@ -161,7 +225,8 @@ AcpiOsReadMemory(ACPI_PHYSICAL_ADDRESS Address, UINT32 *Value, UINT32 Width)
 {
     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 +257,8 @@ AcpiOsWriteMemory(ACPI_PHYSICAL_ADDRESS Address, UINT32 Value, UINT32 Width)
 {
     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 +283,15 @@ AcpiOsWriteMemory(ACPI_PHYSICAL_ADDRESS Address, UINT32 Value, UINT32 Width)
 
     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 0bd51bb..d9198c1 100644 (file)
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/acpica/Osd/OsdSchedule.c,v 1.28 2004/05/06 02:18:58 njl Exp $
- * $DragonFly: src/sys/dev/acpica5/Osd/OsdSchedule.c,v 1.6 2006/09/05 00:55:36 dillon Exp $
+ * $DragonFly: src/sys/dev/acpica5/Osd/OsdSchedule.c,v 1.7 2007/01/17 17:31:19 y0netan1 Exp $
  */
 
 /*
@@ -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, ACPI_OSD_EXEC_CALLBACK Function,
                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 f16c006..65970f8 100644 (file)
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/acpica/Osd/OsdSynch.c,v 1.21 2004/05/05 20:07:52 njl Exp $
- * $DragonFly: src/sys/dev/acpica5/Osd/OsdSynch.c,v 1.9 2006/12/22 23:26:14 swildner Exp $
+ * $DragonFly: src/sys/dev/acpica5/Osd/OsdSynch.c,v 1.10 2007/01/17 17:31:19 y0netan1 Exp $
  */
 
 /*
 #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")
 
 MALLOC_DEFINE(M_ACPISEM, "acpisem", "ACPI semaphore");
 
-#if defined(__DragonFly__)
-# define AS_LOCK(as)           crit_enter()
-# define AS_UNLOCK(as)         crit_exit()
-# define AS_LOCK_DECL
-# define msleep(a, b, c, d, e) tsleep(a, c, d, e)
-#elif __FreeBSD_version < 500000
-# define AS_LOCK(as)           s = splhigh()
-# define AS_UNLOCK(as)         splx(s)
-# define AS_LOCK_DECL          int s
-# define msleep(a, b, c, d, e) tsleep(a, c, d, e)
-#else
-# define AS_LOCK(as)           mtx_lock(&(as)->as_mtx)
-# define AS_UNLOCK(as)         mtx_unlock(&(as)->as_mtx)
-# define AS_LOCK_DECL
-#endif
+#define AS_LOCK(as)            spin_lock_wr(&(as)->as_mtx)
+#define AS_UNLOCK(as)          spin_unlock_wr(&(as)->as_mtx)
+#define AS_LOCK_DECL
 
 /*
  * Simple counting semaphore implemented using a mutex.  (Subsequently used
  * in the OSI code to implement a mutex.  Go figure.)
  */
 struct acpi_semaphore {
-#if __FreeBSD_version >= 500000
-    struct mtx as_mtx;
-#endif
+    struct     spinlock as_mtx;
     UINT32     as_units;
     UINT32     as_maxunits;
     UINT32     as_pendings;
@@ -105,9 +92,7 @@ AcpiOsCreateSemaphore(UINT32 MaxUnits, UINT32 InitialUnits,
 
     as = kmalloc(sizeof(*as), M_ACPISEM, M_INTWAIT | M_ZERO);
 
-#if __FreeBSD_version >= 500000
-    mtx_init(&as->as_mtx, "ACPI semaphore", NULL, MTX_DEF);
-#endif
+    spin_init(&as->as_mtx);
     as->as_units = InitialUnits;
     as->as_maxunits = MaxUnits;
     as->as_pendings = as->as_resetting = as->as_timeouts = 0;
@@ -133,20 +118,13 @@ AcpiOsDeleteSemaphore(ACPI_HANDLE Handle)
     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
 
     ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "destroyed semaphore %p\n", as));
-#if __FreeBSD_version >= 500000
-    mtx_destroy(&as->as_mtx);
-#endif
+    spin_uninit(&as->as_mtx);
     kfree(as, M_ACPISEM);
 #endif /* !ACPI_NO_SEMAPHORES */
 
     return_ACPI_STATUS (AE_OK);
 }
 
-/*
- * This implementation has a bug, in that it has to stall for the entire
- * timeout before it will return AE_TIME.  A better implementation would
- * use getmicrotime() to correctly adjust the timeout after being woken up.
- */
 ACPI_STATUS
 AcpiOsWaitSemaphore(ACPI_HANDLE Handle, UINT32 Units, UINT16 Timeout)
 {
@@ -197,7 +175,7 @@ AcpiOsWaitSemaphore(ACPI_HANDLE Handle, UINT32 Units, UINT16 Timeout)
     }
 
     /* calculate timeout value in timeval */
-    getmicrotime(&currenttv);
+    getmicrouptime(&currenttv);
     timevaladd(&timeouttv, &currenttv);
 
     AS_LOCK(as);
@@ -227,11 +205,9 @@ AcpiOsWaitSemaphore(ACPI_HANDLE Handle, UINT32 Units, UINT16 Timeout)
            break;
        }
 
-#if __FreeBSD_version >= 500000
        ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
            "semaphore blocked, calling msleep(%p, %p, %d, \"acsem\", %d)\n",
            as, &as->as_mtx, PCATCH, tmo));
-#endif
 
        as->as_pendings++;
 
@@ -263,7 +239,7 @@ AcpiOsWaitSemaphore(ACPI_HANDLE Handle, UINT32 Units, UINT16 Timeout)
 
        /* check if we already awaited enough */
        timelefttv = timeouttv;
-       getmicrotime(&currenttv);
+       getmicrouptime(&currenttv);
        timevalsub(&timelefttv, &currenttv);
        if (timelefttv.tv_sec < 0) {
            ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "await semaphore %p timeout\n",
@@ -343,52 +319,95 @@ AcpiOsSignalSemaphore(ACPI_HANDLE Handle, UINT32 Units)
     return_ACPI_STATUS (AE_OK);
 }
 
+struct acpi_spinlock {
+    struct spinlock lock;
+#ifdef ACPI_DEBUG_LOCKS
+    thread_t   owner;
+    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_init(&spin->lock);
+#ifdef ACPI_DEBUG_LOCKS
+    spin->owner = NULL;
+    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)
+       return;
+    spin_uninit(&Spin->lock);
+    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);
+    thread_t td = curthread;
+
+    spin_lock_wr(&Spin->lock);
+#ifdef ACPI_DEBUG_LOCKS
+    if (Spin->owner) {
+       kprintf("%p(%s:%d): acpi_spinlock %p already held by %p(%s:%d)\n",
+               td, func, line, Spin, Spin->owner, Spin->func, Spin->line);
+       db_print_backtrace();
+    } else {
+       Spin->owner = td;
+       Spin->func = func;
+       Spin->line = line;
+    }
+#endif
+    return(0);
 }
 
 void
-AcpiOsReleaseLock (ACPI_HANDLE Handle, UINT32 Flags)
+AcpiOsReleaseLock (ACPI_SPINLOCK Spin, UINT32 Flags)
 {
-    struct lock *lock;
-
-    if ((lock = (struct lock *)Handle) != NULL)
-       lockmgr(lock, LK_RELEASE);
+#ifdef ACPI_DEBUG_LOCKS
+    if (Flags) {
+       if (Spin->owner != NULL) {
+           kprintf("%p: acpi_spinlock %p is unexectedly held by %p(%s:%d)\n",
+                   curthread, Spin, Spin->owner, Spin->func, Spin->line);
+           db_print_backtrace();
+       } else
+           return;
+    }
+    Spin->owner = NULL;
+    Spin->func = "";
+    Spin->line = 0;
+#endif
+    spin_unlock_wr(&Spin->lock);
 }
 
-#ifdef notyet
 /* Section 5.2.9.1:  global lock acquire/release functions */
 #define GL_ACQUIRED    (-1)
 #define GL_BUSY                0
@@ -410,7 +429,7 @@ acpi_acquire_global_lock(uint32_t *lock)
                old = *lock;
                new = ((old & ~GL_BIT_MASK) | GL_BIT_OWNED) |
                        ((old >> 1) & GL_BIT_PENDING);
-       } while (atomic_cmpset_acq_int(lock, old, new) == 0);
+       } while (atomic_cmpset_int(lock, old, new) == 0);
 
        return ((new < GL_BIT_MASK) ? GL_ACQUIRED : GL_BUSY);
 }
@@ -428,8 +447,7 @@ acpi_release_global_lock(uint32_t *lock)
        do {
                old = *lock;
                new = old & ~GL_BIT_MASK;
-       } while (atomic_cmpset_rel_int(lock, old, new) == 0);
+       } while (atomic_cmpset_int(lock, old, new) == 0);
 
        return (old & GL_BIT_PENDING);
 }
-#endif /* notyet */
index 48f81bd..11d3cf6 100644 (file)
@@ -2,7 +2,7 @@
  *
  * Name: acfreebsd.h - OS specific defines, etc.
  *       $Revision: 11 $
- *      $DragonFly: src/sys/dev/acpica5/acdragonfly.h,v 1.2 2004/07/05 00:07:35 dillon Exp $
+ *      $DragonFly: src/sys/dev/acpica5/acdragonfly.h,v 1.3 2007/01/17 17:31:19 y0netan1 Exp $
  *
  *****************************************************************************/
 
 /* DragonFly uses GCC */
 
 #include <platform/acgcc.h>
+#include <sys/types.h>
 #include <machine/acpica_machdep.h>
 
+#define ACPI_UINTPTR_T         uintptr_t
 #ifdef _KERNEL
 #include "opt_acpi.h"
 #endif
 #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 +208,5 @@ strstr(char *s, char *find)
 }
 #endif /* _KERNEL */
 
+#define inline         __inline
 #endif /* __ACDRAGONFLY_H_ */
index cdfc084..1b7bb59 100644 (file)
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *     $FreeBSD: src/sys/dev/acpica/acpi.c,v 1.157 2004/06/05 09:56:04 njl Exp $
- *     $DragonFly: src/sys/dev/acpica5/acpi.c,v 1.27 2007/01/13 21:58:11 tgen Exp $
+ *     $DragonFly: src/sys/dev/acpica5/acpi.c,v 1.28 2007/01/17 17:31:19 y0netan1 Exp $
  */
 
 #include "opt_acpi.h"
@@ -49,6 +49,7 @@
 #include <sys/rman.h>
 
 #include <sys/thread2.h>
+#include <sys/lock.h>
 
 #include <machine/clock.h>
 #include <machine/globaldata.h>
@@ -265,17 +266,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");
@@ -285,23 +275,11 @@ acpi_Startup(void)
        freeenv(debugpoint);
     }
 #endif
-    if (ACPI_FAILURE(error = AcpiInitializeSubsystem())) {
-       kprintf("ACPI: initialisation failed: %s\n", AcpiFormatException(error));
+    error = AcpiInitializeTables(NULL, 16, TRUE);
+    if (ACPI_FAILURE(error)) {
+       kprintf("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())) {
-       kprintf("ACPI: table load failed: %s\n", AcpiFormatException(error));
-       return_VALUE(error);
-    }
 
     /* Set up any quirks we have for this XSDT. */
     acpi_quirks_set();
@@ -352,17 +330,42 @@ acpi_identify(driver_t *driver, device_t parent)
     return (0);
 }
 
+/*
+ * 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__);
@@ -376,22 +379,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);
 }
@@ -405,29 +411,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())) {
+       kprintf("ACPI: initialisation failed: %s\n",
+              AcpiFormatException(status));
+       goto out;
+    }
+    if (ACPI_FAILURE(status = AcpiLoadTables())) {
+       kprintf("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)) {
@@ -548,8 +585,12 @@ 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;
+    }
 
     /*
      * Dispatch the default sleep state to devices.  The lid switch is set
@@ -650,7 +691,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;
@@ -676,10 +717,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)
@@ -690,6 +732,7 @@ acpi_quirks_set(void)
                break;
        }
     }
+    AcpiOsUnmapMemory(rsdt, sizeof(*rsdt));
 
 out:
     if (env)
@@ -904,11 +947,10 @@ acpi_bus_alloc_gas(device_t dev, int *rid, ACPI_GENERIC_ADDRESS *gas)
 {
     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;
@@ -919,7 +961,7 @@ acpi_bus_alloc_gas(device_t dev, int *rid, ACPI_GENERIC_ADDRESS *gas)
        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));
 }
 
@@ -1262,14 +1304,14 @@ acpi_enable_fixed_events(struct acpi_softc *sc)
     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);
@@ -1431,7 +1473,7 @@ acpi_TimerDelta(uint32_t end, uint32_t start)
 
     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);
@@ -1584,7 +1626,7 @@ acpi_FindIndexedResource(ACPI_BUFFER *buf, int index, ACPI_RESOURCE **resp)
            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);
     }
@@ -1616,7 +1658,7 @@ acpi_AppendBufferResource(ACPI_BUFFER *buf, ACPI_RESOURCE *res)
        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)
@@ -1632,7 +1674,7 @@ acpi_AppendBufferResource(ACPI_BUFFER *buf, ACPI_RESOURCE *res)
        /* 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);
     }
@@ -1649,8 +1691,8 @@ acpi_AppendBufferResource(ACPI_BUFFER *buf, ACPI_RESOURCE *res)
      * 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);
@@ -1662,11 +1704,11 @@ acpi_AppendBufferResource(ACPI_BUFFER *buf, ACPI_RESOURCE *res)
     }
     
     /* 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);
@@ -1759,14 +1801,10 @@ acpi_SetSleepState(struct acpi_softc *sc, int state)
 
        if (state != ACPI_STATE_S1) {
            acpi_sleep_machdep(sc, state);
-
+#if 0
            /* 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);
+#endif
            /* Re-enable ACPI hardware on wakeup from sleep state 4. */
            if (state == ACPI_STATE_S4)
                AcpiEnable();
index 541ab46..93fba35 100644 (file)
@@ -24,7 +24,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/acpica/acpi_acad.c,v 1.26 2004/05/30 20:08:23 phk Exp $
- * $DragonFly: src/sys/dev/acpica5/acpi_acad.c,v 1.6 2006/10/25 20:55:52 dillon Exp $
+ * $DragonFly: src/sys/dev/acpica5/acpi_acad.c,v 1.7 2007/01/17 17:31:19 y0netan1 Exp $
  */
 
 #include "opt_acpi.h"
@@ -124,7 +124,7 @@ acpi_acad_notify_handler(ACPI_HANDLE h, UINT32 notify, void *context)
     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 4c67f85..06b5cab 100644 (file)
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/acpica/acpi_button.c,v 1.26 2004/05/30 20:08:23 phk Exp $
- * $DragonFly: src/sys/dev/acpica5/acpi_button.c,v 1.3 2004/07/05 00:07:35 dillon Exp $
+ * $DragonFly: src/sys/dev/acpica5/acpi_button.c,v 1.4 2007/01/17 17:31:19 y0netan1 Exp $
  */
 
 #include "opt_acpi.h"
@@ -249,12 +249,10 @@ acpi_button_notify_handler(ACPI_HANDLE h, UINT32 notify, void *context)
     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 d6f2df8..9e87cd3 100644 (file)
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/acpica/acpi_cmbat.c,v 1.29 2004/05/30 20:08:23 phk Exp $
- * $DragonFly: src/sys/dev/acpica5/acpi_cmbat.c,v 1.9 2006/10/25 20:55:52 dillon Exp $
+ * $DragonFly: src/sys/dev/acpica5/acpi_cmbat.c,v 1.10 2007/01/17 17:31:19 y0netan1 Exp $
  */
 
 #include "opt_acpi.h"
@@ -280,7 +280,7 @@ acpi_cmbat_notify_handler(ACPI_HANDLE h, UINT32 notify, void *context)
     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 e5a17dd..b0e9e91 100644 (file)
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/acpica/acpi_cpu.c,v 1.41 2004/06/24 00:38:51 njl Exp $
- * $DragonFly: src/sys/dev/acpica5/acpi_cpu.c,v 1.17 2006/12/22 23:26:14 swildner Exp $
+ * $DragonFly: src/sys/dev/acpica5/acpi_cpu.c,v 1.18 2007/01/17 17:31:19 y0netan1 Exp $
  */
 
 #include "opt_acpi.h"
@@ -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_softc *sc)
 
     /* 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_softc *sc)
        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 *sc)
      * 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 *sc)
            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 *sc)
            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 *sc)
            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++;
            }
@@ -935,11 +936,9 @@ acpi_cpu_idle(void)
      * time if USB is loaded.
      */
     if ((cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0) {
-       AcpiGetRegister(ACPI_BITREG_BUS_MASTER_STATUS, &bm_active,
-           ACPI_MTX_DO_NOT_LOCK);
+       AcpiGetRegister(ACPI_BITREG_BUS_MASTER_STATUS, &bm_active);
        if (bm_active != 0) {
-           AcpiSetRegister(ACPI_BITREG_BUS_MASTER_STATUS, 1,
-               ACPI_MTX_DO_NOT_LOCK);
+           AcpiSetRegister(ACPI_BITREG_BUS_MASTER_STATUS, 1);
            cx_next_idx = min(cx_next_idx, cpu_non_c3);
        }
     }
@@ -966,9 +965,8 @@ acpi_cpu_idle(void)
      */
     if (cx_next->type == ACPI_STATE_C3) {
        if ((cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0) {
-           AcpiSetRegister(ACPI_BITREG_ARB_DISABLE, 1, ACPI_MTX_DO_NOT_LOCK);
-           AcpiSetRegister(ACPI_BITREG_BUS_MASTER_RLD, 1,
-               ACPI_MTX_DO_NOT_LOCK);
+           AcpiSetRegister(ACPI_BITREG_ARB_DISABLE, 1);
+           AcpiSetRegister(ACPI_BITREG_BUS_MASTER_RLD, 1);
        } else
            ACPI_FLUSH_CPU_CACHE();
     }
@@ -979,7 +977,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,14 +986,14 @@ 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 &&
        (cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0) {
-       AcpiSetRegister(ACPI_BITREG_ARB_DISABLE, 0, ACPI_MTX_DO_NOT_LOCK);
-       AcpiSetRegister(ACPI_BITREG_BUS_MASTER_RLD, 0, ACPI_MTX_DO_NOT_LOCK);
+       AcpiSetRegister(ACPI_BITREG_ARB_DISABLE, 0);
+       AcpiSetRegister(ACPI_BITREG_BUS_MASTER_RLD, 0);
     }
 
     /* Find the actual time asleep in microseconds, minus overhead. */
index 7bafe27..9a3809b 100644 (file)
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/acpica/acpi_ec.c,v 1.51 2004/05/30 20:08:23 phk Exp $
- * $DragonFly: src/sys/dev/acpica5/acpi_ec.c,v 1.11 2006/12/22 23:26:14 swildner Exp $
+ * $DragonFly: src/sys/dev/acpica5/acpi_ec.c,v 1.12 2007/01/17 17:31:19 y0netan1 Exp $
  */
 /******************************************************************************
  *
  *****************************************************************************/
  /*
   * $FreeBSD: src/sys/dev/acpica/acpi_ec.c,v 1.51 2004/05/30 20:08:23 phk Exp $
-  * $DragonFly: src/sys/dev/acpica5/acpi_ec.c,v 1.11 2006/12/22 23:26:14 swildner Exp $
+  * $DragonFly: src/sys/dev/acpica5/acpi_ec.c,v 1.12 2007/01/17 17:31:19 y0netan1 Exp $
   *
   */
 
@@ -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) {
        kprintf("%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);
        kprintf("%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);
@@ -715,14 +703,14 @@ EcGpeHandler(void *Context)
     KASSERT(Context != NULL, ("EcGpeHandler called with NULL"));
 
     /* Disable further GPEs while we handle this one. */
-    AcpiDisableGpe(sc->ec_gpehandle, sc->ec_gpebit, ACPI_NOT_ISR);
+    AcpiDisableGpe(sc->ec_gpehandle, sc->ec_gpebit, ACPI_ISR);
 
     /* Schedule the GPE query handler. */
-    Status = AcpiOsQueueForExecution(OSD_PRIORITY_GPE, EcGpeQueryHandler,
+    Status = AcpiOsExecute(OSL_GPE_HANDLER, EcGpeQueryHandler,
                Context);
     if (ACPI_FAILURE(Status)) {
        kprintf("Queuing GPE query handler failed.\n");
-       Status = AcpiEnableGpe(sc->ec_gpehandle, sc->ec_gpebit, ACPI_NOT_ISR);
+       Status = AcpiEnableGpe(sc->ec_gpehandle, sc->ec_gpebit, ACPI_ISR);
        if (ACPI_FAILURE(Status))
            kprintf("EcGpeHandler: AcpiEnableEvent failed\n");
     }
index 3659ba8..a8057b5 100644 (file)
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/acpica/acpi_lid.c,v 1.22 2004/05/30 20:08:23 phk Exp $
- * $DragonFly: src/sys/dev/acpica5/acpi_lid.c,v 1.3 2004/07/05 00:07:35 dillon Exp $
+ * $DragonFly: src/sys/dev/acpica5/acpi_lid.c,v 1.4 2007/01/17 17:31:19 y0netan1 Exp $
  */
 
 #include "opt_acpi.h"
@@ -183,8 +183,7 @@ acpi_lid_notify_handler(ACPI_HANDLE h, UINT32 notify, void *context)
     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 cf1fcc4..e94fc92 100644 (file)
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/acpica/acpi_resource.c,v 1.24 2004/05/30 20:08:23 phk Exp $
- * $DragonFly: src/sys/dev/acpica5/acpi_resource.c,v 1.5 2006/12/22 23:26:14 swildner Exp $
+ * $DragonFly: src/sys/dev/acpica5/acpi_resource.c,v 1.6 2007/01/17 17:31:19 y0netan1 Exp $
  */
 
 #include "opt_acpi.h"
@@ -94,129 +94,129 @@ acpi_parse_resources(device_t dev, ACPI_HANDLE handle,
        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_HANDLE handle,
                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_HANDLE handle,
                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 dev, void *context,
 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_parse_set = {
     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, void *context, u_int32_t low,
 }
 
 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 *context, u_int32_t *irq, int count,
 }
 
 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 6d758e4..3932752 100644 (file)
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/acpica/acpi_thermal.c,v 1.47 2004/05/30 20:08:23 phk Exp $
- * $DragonFly: src/sys/dev/acpica5/acpi_thermal.c,v 1.6 2006/12/20 18:14:38 dillon Exp $
+ * $DragonFly: src/sys/dev/acpica5/acpi_thermal.c,v 1.7 2007/01/17 17:31:19 y0netan1 Exp $
  */
 
 #include "opt_acpi.h"
@@ -685,12 +685,12 @@ acpi_tz_notify_handler(ACPI_HANDLE h, UINT32 notify, void *context)
     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 6e036c3..8a7a5a5 100644 (file)
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/acpica/acpi_timer.c,v 1.33 2004/05/30 20:08:23 phk Exp $
- * $DragonFly: src/sys/dev/acpica5/acpi_timer.c,v 1.11 2006/12/22 23:26:14 swildner Exp $
+ * $DragonFly: src/sys/dev/acpica5/acpi_timer.c,v 1.12 2007/01/17 17:31:19 y0netan1 Exp $
  */
 #include "opt_acpi.h"
 #include <sys/param.h>
@@ -132,7 +132,7 @@ acpi_timer_identify(driver_t *driver, device_t parent)
 
     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, device_t parent)
     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, device_t parent)
     }
     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, device_t parent)
     }
 
     ksprintf(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 a15a739..303162e 100644 (file)
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/acpica/acpivar.h,v 1.69 2004/05/28 07:15:55 njl Exp $
- * $DragonFly: src/sys/dev/acpica5/acpivar.h,v 1.10 2006/12/22 23:26:14 swildner Exp $
+ * $DragonFly: src/sys/dev/acpica5/acpivar.h,v 1.11 2007/01/17 17:31:19 y0netan1 Exp $
  */
 
 #include "bus_if.h"
@@ -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);
diff --git a/sys/dev/acpica5/hardware,hwsleep.c.patch b/sys/dev/acpica5/hardware,hwsleep.c.patch
new file mode 100644 (file)
index 0000000..bb7947b
--- /dev/null
@@ -0,0 +1,17 @@
+# $DragonFly: src/sys/dev/acpica5/hardware,hwsleep.c.patch,v 1.1 2007/01/17 17:31:19 y0netan1 Exp $
+
+--- hwsleep.c.orig     2006-11-10 05:56:25.000000000 +0900
++++ hwsleep.c  2007-01-14 13:02:22.000000000 +0900
+@@ -509,10 +509,12 @@
+         }
+     }
++    ACPI_FLUSH_CPU_CACHE ();
+     /* Wait until we enter sleep state */
+     do
+     {
++        AcpiOsStall(1000);
+         Status = AcpiGetRegister (ACPI_BITREG_WAKE_STATUS, &InValue);
+         if (ACPI_FAILURE (Status))
+         {
diff --git a/sys/dev/acpica5/include,acglobal.h.patch b/sys/dev/acpica5/include,acglobal.h.patch
new file mode 100644 (file)
index 0000000..bd6b6bd
--- /dev/null
@@ -0,0 +1,19 @@
+# $DragonFly: src/sys/dev/acpica5/include,acglobal.h.patch,v 1.1 2007/01/17 17:31:19 y0netan1 Exp $
+
+--- 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
+ /*****************************************************************************
diff --git a/sys/dev/acpica5/include,acpiosxf.h.patch b/sys/dev/acpica5/include,acpiosxf.h.patch
new file mode 100644 (file)
index 0000000..c582225
--- /dev/null
@@ -0,0 +1,57 @@
+# $DragonFly: src/sys/dev/acpica5/include,acpiosxf.h.patch,v 1.1 2007/01/17 17:31:19 y0netan1 Exp $
+
+--- acpiosxf.h.orig    2006-11-30 05:58:15.000000000 +0900
++++ acpiosxf.h 2006-11-30 06:02:56.000000000 +0900
+@@ -197,9 +197,18 @@
+ AcpiOsDeleteLock (
+     ACPI_SPINLOCK           Handle);
++#if ACPI_DEBUG_LOCKS
++#define AcpiOsAcquireLock(Handle) \
++_AcpiOsAcquireLock(Handle, __func__, __LINE__)
+ ACPI_CPU_FLAGS
+-AcpiOsAcquireLock (
++_AcpiOsAcquireLock (
++    ACPI_SPINLOCK           Handle,
++    const char *func, int line);
++#else
++ACPI_CPU_FLAGS
++AcpiOsAcquireLock (
+     ACPI_SPINLOCK           Handle);
++#endif
+ void
+ AcpiOsReleaseLock (
+@@ -271,6 +280,24 @@
+ AcpiOsFree (
+     void *                  Memory);
++#if ACPI_DEBUG_MEMMAP
++#define AcpiOsMapMemory(Where, Length) \
++_AcpiOsMapMemory((Where), (Length), __func__, __LINE__)
++#define AcpiOsUnmapMemory(LogicalAddress, Size) \
++_AcpiOsUnmapMemory((LogicalAddress), (Size), __func__, __LINE__)
++
++void *
++_AcpiOsMapMemory (
++    ACPI_PHYSICAL_ADDRESS   Where,
++    ACPI_NATIVE_UINT        Length,
++    const char *caller, int line);
++
++void
++_AcpiOsUnmapMemory (
++    void                    *LogicalAddress,
++    ACPI_SIZE               Size,
++    const char *caller, int line);
++#else
+ void *
+ AcpiOsMapMemory (
+     ACPI_PHYSICAL_ADDRESS   Where,
+@@ -280,6 +307,7 @@
+ AcpiOsUnmapMemory (
+     void                    *LogicalAddress,
+     ACPI_SIZE               Size);
++#endif
+ ACPI_STATUS
+ AcpiOsGetPhysicalAddress (
index 73e26bb..0e68087 100644 (file)
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/i386/acpica/OsdEnvironment.c,v 1.10 2004/05/06 02:18:58 njl Exp $
- * $DragonFly: src/sys/platform/pc32/acpica5/OsdEnvironment.c,v 1.2 2004/06/27 08:52:45 dillon Exp $
+ * $DragonFly: src/sys/platform/pc32/acpica5/OsdEnvironment.c,v 1.3 2007/01/17 17:31:19 y0netan1 Exp $
  */
 
 /*
@@ -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_POINTER *RsdpPhysicalAddress)
                 * 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 6703fc5..7d181d7 100644 (file)
@@ -24,7 +24,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/i386/acpica/acpi_machdep.c,v 1.20 2004/05/05 19:51:15 njl Exp $
- * $DragonFly: src/sys/platform/pc32/acpica5/acpi_machdep.c,v 1.12 2006/12/23 00:27:02 swildner Exp $
+ * $DragonFly: src/sys/platform/pc32/acpica5/acpi_machdep.c,v 1.13 2007/01/17 17:31:19 y0netan1 Exp $
  */
 
 #include <sys/param.h>
@@ -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 cf9ac8f..c78fbb8 100644 (file)
@@ -24,7 +24,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/i386/include/acpica_machdep.h,v 1.5 2003/09/10 01:14:42 jhb Exp $
- * $DragonFly: src/sys/platform/pc32/include/acpica_machdep.h,v 1.3 2006/05/20 02:42:06 dillon Exp $
+ * $DragonFly: src/sys/platform/pc32/include/acpica_machdep.h,v 1.4 2007/01/17 17:31:19 y0netan1 Exp $
  */
 
 /******************************************************************************
 
 #define ACPI_FLUSH_CPU_CACHE() wbinvd()
 
-#define asm         __asm
+/* Section 5.2.9.1:  global lock acquire/release functions */
+extern int     acpi_acquire_global_lock(uint32_t *lock);
+extern int     acpi_release_global_lock(uint32_t *lock);
+#define ACPI_ACQUIRE_GLOBAL_LOCK(FACSptr, Acq) \
+               ((Acq) = acpi_acquire_global_lock(&(FACSptr)->GlobalLock))
+#define ACPI_RELEASE_GLOBAL_LOCK(FACSptr, Acq) \
+               ((Acq) = acpi_release_global_lock(&(FACSptr)->GlobalLock))
+
 /*! [Begin] no source code translation
  *
- * A brief explanation as GNU inline assembly is a bit hairy
- *  %0 is the output parameter in EAX ("=a")
- *  %1 and %2 are the input parameters in ECX ("c")
- *  and an immediate value ("i") respectively
- *  All actual register references are preceded with "%%" as in "%%edx"
- *  Immediate values in the assembly are preceded by "$" as in "$0x1"
- *  The final asm parameter are the operation altered non-output registers.
- */
-#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \
-    do { \
-        asm("1:     movl %1,%%eax;" \
-            "movl   %%eax,%%edx;" \
-            "andl   %2,%%edx;" \
-            "btsl   $0x1,%%edx;" \
-            "adcl   $0x0,%%edx;" \
-            "lock;  cmpxchgl %%edx,%1;" \
-            "jnz    1b;" \
-            "cmpb   $0x3,%%dl;" \
-            "sbbl   %%eax,%%eax" \
-            : "=a" (Acq), "+m" (GLptr) : "i" (~1L) : "edx"); \
-    } while(0)
-
-#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \
-    do { \
-        asm("1:     movl %1,%%eax;" \
-            "movl   %%eax,%%edx;" \
-            "andl   %2,%%edx;" \
-            "lock;  cmpxchgl %%edx,%1;" \
-            "jnz    1b;" \
-            "andl   $0x1,%%eax" \
-            : "=a" (Acq), "+m" (GLptr) : "i" (~3L) : "edx"); \
-    } while(0)
-
-
-/*
  * Math helper asm macros
  */
+#define asm         __asm
 #define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \
         asm("divl %2;"        \
         :"=a"(q32), "=d"(r32) \
index 522a12b..84c716e 100644 (file)
@@ -1,5 +1,5 @@
 # $FreeBSD: src/usr.sbin/acpi/acpidb/Makefile,v 1.5 2004/05/25 02:56:55 njl Exp $
-# $DragonFly: src/usr.sbin/acpi/acpidb/Makefile,v 1.3 2005/08/16 10:31:35 y0netan1 Exp $
+# $DragonFly: src/usr.sbin/acpi/acpidb/Makefile,v 1.4 2007/01/17 17:31:19 y0netan1 Exp $
 
 PROG=  acpidb
 SRCS+= acpidb.c
@@ -24,25 +24,27 @@ SRCS+=      dbcmds.c dbdisply.c dbexec.c dbfileio.c \
        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 76b0d7d..4c4187c 100644 (file)
@@ -24,7 +24,7 @@
  * SUCH DAMAGE.
  *
  *     $FreeBSD: src/usr.sbin/acpi/acpidb/acpidb.c,v 1.1 2003/08/07 16:51:50 njl Exp $
- *     $DragonFly: src/usr.sbin/acpi/acpidb/acpidb.c,v 1.1 2004/07/05 00:22:43 dillon Exp $
+ *     $DragonFly: src/usr.sbin/acpi/acpidb/acpidb.c,v 1.2 2007/01/17 17:31:19 y0netan1 Exp $
  */
 
 #include <sys/param.h>
@@ -338,12 +338,14 @@ DECLARE_VM_SPACE_HANDLER(smbus,           ACPI_ADR_SPACE_SMBUS);
 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 e940f6d..43aaf62 100644 (file)
@@ -1,16 +1,26 @@
-$DragonFly: src/usr.sbin/acpi/acpidb/osunixxf.c.patch,v 1.1 2005/03/12 14:33:40 y0netan1 Exp $
+$DragonFly: src/usr.sbin/acpi/acpidb/osunixxf.c.patch,v 1.2 2007/01/17 17:31:19 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 f4e0a4b..8a40ca9 100644 (file)
@@ -1,5 +1,5 @@
 # $FreeBSD: src/usr.sbin/acpi/iasl/Makefile,v 1.5 2004/01/13 20:53:56 ru Exp $
-# $DragonFly: src/usr.sbin/acpi/iasl/Makefile,v 1.1 2004/07/05 00:22:43 dillon Exp $
+# $DragonFly: src/usr.sbin/acpi/iasl/Makefile,v 1.2 2007/01/17 17:31:20 y0netan1 Exp $
 
 PROG=  iasl
 SRCS=  aslcompiler.y.h aslcompilerlex.l aslcompilerparse.y \
@@ -23,13 +23,15 @@ SRCS+=      dbfileio.c dmbuffer.c dmnames.c dmopcode.c dmobject.c \
        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