Index: sys/arch/i386/acpi/acpi_wakeup.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/acpi/acpi_wakeup.c,v
retrieving revision 1.12
diff -u -r1.12 acpi_wakeup.c
--- sys/arch/i386/acpi/acpi_wakeup.c    14 Jun 2004 18:09:35 -0000      1.12
+++ sys/arch/i386/acpi/acpi_wakeup.c    17 Jun 2004 04:13:41 -0000
@@ -149,7 +149,8 @@
       ef = read_eflags();
       disable_intr();

-       AcpiHwDisableNonWakeupGpes();
+       AcpiHwDisableAllGpes();
+       AcpiHwEnableAllWakeupGpes();

       /* flush caches */

@@ -168,7 +169,8 @@
                       break;
       } while (!ret);

-       AcpiHwEnableNonWakeupGpes();
+       AcpiHwDisableAllGpes();
+       AcpiHwEnableAllRuntimeGpes();

       write_eflags(ef);

Index: sys/dev/acpi/acpi.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpi.c,v
retrieving revision 1.66
diff -u -r1.66 acpi.c
--- sys/dev/acpi/acpi.c 7 Jun 2004 15:33:17 -0000       1.66
+++ sys/dev/acpi/acpi.c 17 Jun 2004 04:16:17 -0000
@@ -954,6 +954,37 @@
       return 0;
}

+/*
+ * acpi_set_wake_gpe
+ *
+ *     Set GPE as both Runtime and Wake
+ */
+void
+acpi_set_wake_gpe(ACPI_HANDLE handle)
+{
+       ACPI_BUFFER buf;
+       ACPI_STATUS rv;
+       ACPI_OBJECT *p, *elt;
+
+
+       rv = acpi_eval_struct(handle, METHOD_NAME__PRW, &buf);
+       if (ACPI_FAILURE(rv))
+               return;                 /* just ignore */
+
+       p = buf.Pointer;
+       if (p->Type != ACPI_TYPE_PACKAGE || p->Package.Count < 2)
+               goto out;               /* just ignore */
+
+       elt = p->Package.Elements;
+
+       /* TBD: package support */
+       AcpiSetGpeType(NULL, elt[0].Integer.Value, ACPI_GPE_TYPE_WAKE_RUN);
+       AcpiEnableGpe(NULL, elt[0].Integer.Value, ACPI_NOT_ISR);
+
+ out:
+       AcpiOsFree(buf.Pointer);
+}
+

/*****************************************************************************
 * ACPI sleep support.
Index: sys/dev/acpi/acpi_button.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpi_button.c,v
retrieving revision 1.16
diff -u -r1.16 acpi_button.c
--- sys/dev/acpi/acpi_button.c  1 May 2004 12:03:48 -0000       1.16
+++ sys/dev/acpi/acpi_button.c  17 Jun 2004 04:16:17 -0000
@@ -146,6 +146,8 @@
               return;
       }

+       acpi_set_wake_gpe(sc->sc_node->ad_handle);
+
#ifdef ACPI_BUT_DEBUG
       /* Display the current state when it changes. */
       sc->sc_flags = ACPIBUT_F_VERBOSE;
Index: sys/dev/acpi/acpi_ec.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpi_ec.c,v
retrieving revision 1.31
diff -u -r1.31 acpi_ec.c
--- sys/dev/acpi/acpi_ec.c      1 May 2004 12:03:48 -0000       1.31
+++ sys/dev/acpi/acpi_ec.c      17 Jun 2004 04:16:17 -0000
@@ -246,7 +246,7 @@
       UINT8           Data;
} EC_REQUEST;

-static void            EcGpeHandler(void *Context);
+static UINT32          EcGpeHandler(void *Context);
static ACPI_STATUS     EcSpaceSetup(ACPI_HANDLE Region, UINT32 Function,
                           void *Context, void **return_Context);
static ACPI_STATUS     EcSpaceHandler(UINT32 Function,
@@ -426,14 +426,27 @@
               ecdt_sc->sc_glk = 1;

       rv = AcpiInstallGpeHandler(NULL, ecdt_sc->sc_gpebit,
-           ACPI_EVENT_EDGE_TRIGGERED, EcGpeHandler, ecdt_sc);
+           (UINT32)ACPI_GPE_EDGE_TRIGGERED, EcGpeHandler, ecdt_sc);
       if (ACPI_FAILURE(rv)) {
               printf("%s: unable to install GPE handler: %s\n",
-                   parent->dv_xname,
-                   AcpiFormatException(rv));
+                   parent->dv_xname, AcpiFormatException(rv));
               goto out3;
       }

+       rv = AcpiSetGpeType(NULL, ecdt_sc->sc_gpebit, ACPI_GPE_TYPE_RUNTIME);
+       if (ACPI_FAILURE(rv)) {
+               printf("%s: unable to set GPE type: %s\n",
+                   parent->dv_xname, AcpiFormatException(rv));
+               goto out4;
+       }
+
+       rv = AcpiEnableGpe(NULL, ecdt_sc->sc_gpebit, ACPI_NOT_ISR);
+       if (ACPI_FAILURE(rv)) {
+               printf("%s: unable to enable GPE: %s\n",
+                   parent->dv_xname, AcpiFormatException(rv));
+               goto out4;
+       }
+
       rv = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT,
           ACPI_ADR_SPACE_EC, EcSpaceHandler, EcSpaceSetup, ecdt_sc);
       if (ACPI_FAILURE(rv)) {
@@ -592,23 +605,41 @@
        * cleared before re-enabling the GPE.
        */
       rv = AcpiInstallGpeHandler(NULL, sc->sc_gpebit,
-            ACPI_EVENT_EDGE_TRIGGERED, EcGpeHandler, sc);
+           (UINT32)ACPI_GPE_EDGE_TRIGGERED, EcGpeHandler, sc);
       if (ACPI_FAILURE(rv)) {
               printf("%s: unable to install GPE handler: %s\n",
                   sc->sc_dev.dv_xname, AcpiFormatException(rv));
               goto out;
       }

+       rv = AcpiSetGpeType(NULL, sc->sc_gpebit, ACPI_GPE_TYPE_RUNTIME);
+       if (ACPI_FAILURE(rv)) {
+               printf("%s: unable to set GPE type: %s\n",
+                   sc->sc_dev.dv_xname, AcpiFormatException(rv));
+               goto out2;
+       }
+
+       rv = AcpiEnableGpe(NULL, sc->sc_gpebit, ACPI_NOT_ISR);
+       if (ACPI_FAILURE(rv)) {
+               printf("%s: unable to enable GPE: %s\n",
+                   sc->sc_dev.dv_xname, AcpiFormatException(rv));
+               goto out2;
+       }
+
       /* Install address space handler. */
       rv = AcpiInstallAddressSpaceHandler(sc->sc_handle,
            ACPI_ADR_SPACE_EC, EcSpaceHandler, EcSpaceSetup, sc);
       if (ACPI_FAILURE(rv)) {
               printf("%s: unable to install address space handler: %s\n",
                   sc->sc_dev.dv_xname, AcpiFormatException(rv));
-               (void)AcpiRemoveGpeHandler(NULL, sc->sc_gpebit,
-                   EcGpeHandler);
+               goto out2;
       }

+       return_VOID;
+ out2:
+       (void)AcpiRemoveGpeHandler(NULL, sc->sc_gpebit,
+           EcGpeHandler);
+
 out:
       acpi_resource_cleanup(&res);
       return_VOID;
@@ -685,7 +716,7 @@
       return_VOID;
}

-static void
+static UINT32
EcGpeHandler(void *Context)
{
       struct acpi_ec_softc *sc = Context;
@@ -716,6 +747,8 @@
                       printf("%s: failed to enqueue query handler: %s\n",
                           sc->sc_dev.dv_xname, AcpiFormatException(rv));
       }
+
+       return 0;                       /* XXX not used in ACPI-CA */
}

static ACPI_STATUS
Index: sys/dev/acpi/acpi_lid.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpi_lid.c,v
retrieving revision 1.15
diff -u -r1.15 acpi_lid.c
--- sys/dev/acpi/acpi_lid.c     1 May 2004 12:03:48 -0000       1.15
+++ sys/dev/acpi/acpi_lid.c     17 Jun 2004 04:16:17 -0000
@@ -119,6 +119,8 @@
                   sc->sc_dev.dv_xname, AcpiFormatException(rv));
               return;
       }
+
+       acpi_set_wake_gpe(sc->sc_node->ad_handle);
}

/*
Index: sys/dev/acpi/acpivar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpivar.h,v
retrieving revision 1.20
diff -u -r1.20 acpivar.h
--- sys/dev/acpi/acpivar.h      26 May 2004 17:15:17 -0000      1.20
+++ sys/dev/acpi/acpivar.h      17 Jun 2004 04:16:17 -0000
@@ -260,6 +260,7 @@

int            acpi_probe(void);
int            acpi_match_hid(ACPI_DEVICE_INFO *, const char * const *);
+void           acpi_set_wake_gpe(ACPI_HANDLE);

ACPI_STATUS    acpi_eval_integer(ACPI_HANDLE, char *, ACPI_INTEGER *);
ACPI_STATUS    acpi_eval_string(ACPI_HANDLE, char *, char **);
Index: sys/dev/acpi/acpica/Subsystem/acconfig.h
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/acconfig.h,v
retrieving revision 1.9
diff -u -r1.9 acconfig.h
--- sys/dev/acpi/acpica/Subsystem/acconfig.h    14 Feb 2004 16:57:24 -0000      1.9
+++ sys/dev/acpi/acpica/Subsystem/acconfig.h    17 Jun 2004 04:08:34 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Name: acconfig.h - Global configuration constants
- *       xRevision: 148 $
+ *       xRevision: 158 $
 *
 *****************************************************************************/

@@ -137,11 +137,21 @@

/* Version string */

-#define ACPI_CA_VERSION                 0x20040211
+#define ACPI_CA_VERSION                 0x20040527
+
+/*
+ * OS name, used for the _OS object.  The _OS object is essentially obsolete,
+ * but there is a large base of ASL/AML code in existing machines that check
+ * for the string below.  The use of this string usually guarantees that
+ * the ASL will execute down the most tested code path.  Also, there is some
+ * code that will not execute the _OSI method unless _OS matches the string
+ * below.  Therefore, change this string at your own risk.
+ */
+#define ACPI_OS_NAME                    "Microsoft Windows NT"

/* Maximum objects in the various object caches */

-#define ACPI_MAX_STATE_CACHE_DEPTH      64          /* State objects for stacks */
+#define ACPI_MAX_STATE_CACHE_DEPTH      64          /* State objects */
#define ACPI_MAX_PARSE_CACHE_DEPTH      96          /* Parse tree objects */
#define ACPI_MAX_EXTPARSE_CACHE_DEPTH   64          /* Parse tree objects */
#define ACPI_MAX_OBJECT_CACHE_DEPTH     64          /* Interpreter operand objects */
@@ -225,10 +235,11 @@

/* Constants used in searching for the RSDP in low memory */

-#define ACPI_LO_RSDP_WINDOW_BASE        0           /* Physical Address */
-#define ACPI_HI_RSDP_WINDOW_BASE        0xE0000     /* Physical Address */
-#define ACPI_LO_RSDP_WINDOW_SIZE        0x400
-#define ACPI_HI_RSDP_WINDOW_SIZE        0x20000
+#define ACPI_EBDA_PTR_LOCATION          0x0000040E     /* Physical Address */
+#define ACPI_EBDA_PTR_LENGTH            2
+#define ACPI_EBDA_WINDOW_SIZE           1024
+#define ACPI_HI_RSDP_WINDOW_BASE        0x000E0000     /* Physical Address */
+#define ACPI_HI_RSDP_WINDOW_SIZE        0x00020000
#define ACPI_RSDP_SCAN_STEP             16

/* Operation regions */
@@ -258,6 +269,10 @@

#define ACPI_SMBUS_BUFFER_SIZE          34

+/* Number of strings associated with the _OSI reserved method */
+
+#define ACPI_NUM_OSI_STRINGS            9
+

/******************************************************************************
 *
Index: sys/dev/acpi/acpica/Subsystem/acdebug.h
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/acdebug.h,v
retrieving revision 1.8
diff -u -r1.8 acdebug.h
--- sys/dev/acpi/acpica/Subsystem/acdebug.h     14 Feb 2004 16:57:24 -0000      1.8
+++ sys/dev/acpi/acpica/Subsystem/acdebug.h     17 Jun 2004 04:08:34 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Name: acdebug.h - ACPI/AML debugger
- *       xRevision: 73 $
+ *       xRevision: 74 $
 *
 *****************************************************************************/

@@ -239,6 +239,10 @@
AcpiDbSetScope (
    char                    *Name);

+ACPI_STATUS
+AcpiDbSleep (
+    char                    *ObjectArg);
+
void
AcpiDbFindReferences (
    char                    *ObjectArg);
Index: sys/dev/acpi/acpica/Subsystem/acdisasm.h
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/acdisasm.h,v
retrieving revision 1.5
diff -u -r1.5 acdisasm.h
--- sys/dev/acpi/acpica/Subsystem/acdisasm.h    14 Feb 2004 16:57:24 -0000      1.5
+++ sys/dev/acpi/acpica/Subsystem/acdisasm.h    17 Jun 2004 04:08:34 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Name: acdisasm.h - AML disassembler
- *       xRevision: 11 $
+ *       xRevision: 12 $
 *
 *****************************************************************************/

@@ -125,6 +125,14 @@
#define BLOCK_BRACE             2
#define BLOCK_COMMA_LIST        4

+typedef struct acpi_external_list
+{
+    char                        *Path;
+    struct acpi_external_list   *Next;
+
+} ACPI_EXTERNAL_LIST;
+
+extern ACPI_EXTERNAL_LIST       *AcpiGbl_ExternalList;
extern const char               *AcpiGbl_IoDecode[2];
extern const char               *AcpiGbl_WordDecode[4];
extern const char               *AcpiGbl_ConsumeDecode[2];
@@ -473,4 +481,12 @@
    UINT32                  Level);


+/*
+ * dmutils
+ */
+
+void
+AcpiDmAddToExternalList (
+    char                    *Path);
+
#endif  /* __ACDISASM_H__ */
Index: sys/dev/acpi/acpica/Subsystem/acdispat.h
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/acdispat.h,v
retrieving revision 1.7
diff -u -r1.7 acdispat.h
--- sys/dev/acpi/acpica/Subsystem/acdispat.h    14 Feb 2004 16:57:24 -0000      1.7
+++ sys/dev/acpi/acpica/Subsystem/acdispat.h    17 Jun 2004 04:08:34 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Name: acdispat.h - dispatcher (parser to interpreter interface)
- *       xRevision: 57 $
+ *       xRevision: 58 $
 *
 *****************************************************************************/

@@ -510,8 +510,7 @@
    ACPI_NAMESPACE_NODE     *MethodNode,
    UINT8                   *AmlStart,
    UINT32                  AmlLength,
-    ACPI_OPERAND_OBJECT     **Params,
-    ACPI_OPERAND_OBJECT     **ReturnObjDesc,
+    ACPI_PARAMETER_INFO     *Info,
    UINT32                  PassNumber);

ACPI_STATUS
Index: sys/dev/acpi/acpica/Subsystem/acenv.h
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/acenv.h,v
retrieving revision 1.11
diff -u -r1.11 acenv.h
--- sys/dev/acpi/acpica/Subsystem/acenv.h       14 Feb 2004 16:57:24 -0000      1.11
+++ sys/dev/acpi/acpica/Subsystem/acenv.h       17 Jun 2004 04:08:34 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Name: acenv.h - Generation environment specific items
- *       xRevision: 106 $
+ *       xRevision: 107 $
 *
 *****************************************************************************/

@@ -225,12 +225,8 @@
#define COMPILER_DEPENDENT_INT64   long long
#define COMPILER_DEPENDENT_UINT64  unsigned long long

-
-/* Name of host operating system (returned by the _OS_ namespace object) */
-
-#define ACPI_OS_NAME         "Intel ACPI/CA Core Subsystem"
-
-/* This macro is used to tag functions as "printf-like" because
+/*
+ * This macro is used to tag functions as "printf-like" because
 * some compilers can catch printf format string problems. MSVC
 * doesn't, so this is proprocessed away.
 */
Index: sys/dev/acpi/acpica/Subsystem/acevents.h
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/acevents.h,v
retrieving revision 1.9
diff -u -r1.9 acevents.h
--- sys/dev/acpi/acpica/Subsystem/acevents.h    14 Feb 2004 16:57:24 -0000      1.9
+++ sys/dev/acpi/acpica/Subsystem/acevents.h    17 Jun 2004 04:08:34 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Name: acevents.h - Event subcomponent prototypes and defines
- *       xRevision: 93 $
+ *       xRevision: 95 $
 *
 *****************************************************************************/

@@ -119,11 +119,11 @@


ACPI_STATUS
-AcpiEvInitialize (
+AcpiEvInitializeEvents (
    void);

ACPI_STATUS
-AcpiEvHandlerInitialize (
+AcpiEvInstallXruptHandlers (
    void);


@@ -190,6 +190,20 @@
AcpiEvValidGpeEvent (
    ACPI_GPE_EVENT_INFO     *GpeEventInfo);

+ACPI_STATUS
+AcpiEvUpdateGpeEnableMasks (
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo,
+    UINT8                   Type);
+
+ACPI_STATUS
+AcpiEvEnableGpe (
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo,
+    BOOLEAN                 WriteToHardware);
+
+ACPI_STATUS
+AcpiEvDisableGpe (
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo);
+
ACPI_GPE_EVENT_INFO *
AcpiEvGetGpeEventInfo (
    ACPI_HANDLE             GpeDevice,
@@ -212,6 +226,11 @@
AcpiEvDeleteGpeBlock (
    ACPI_GPE_BLOCK_INFO     *GpeBlock);

+ACPI_STATUS
+AcpiEvDeleteGpeHandlers (
+    ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
+    ACPI_GPE_BLOCK_INFO     *GpeBlock);
+
UINT32
AcpiEvGpeDispatch (
    ACPI_GPE_EVENT_INFO     *GpeEventInfo,
@@ -221,12 +240,25 @@
AcpiEvGpeDetect (
    ACPI_GPE_XRUPT_INFO     *GpeXruptList);

+ACPI_STATUS
+AcpiEvSetGpeType (
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo,
+    UINT8                   Type);
+
+ACPI_STATUS
+AcpiEvCheckForWakeOnlyGpe (
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo);
+
/*
 * Evregion - Address Space handling
 */

ACPI_STATUS
-AcpiEvInitAddressSpaces (
+AcpiEvInstallRegionHandlers (
+    void);
+
+ACPI_STATUS
+AcpiEvInitializeOpRegions (
    void);

ACPI_STATUS
@@ -256,6 +288,19 @@
    BOOLEAN                 AcpiNsIsLocked);

ACPI_STATUS
+AcpiEvInstallSpaceHandler (
+    ACPI_NAMESPACE_NODE     *Node,
+    ACPI_ADR_SPACE_TYPE     SpaceId,
+    ACPI_ADR_SPACE_HANDLER  Handler,
+    ACPI_ADR_SPACE_SETUP    Setup,
+    void                    *Context);
+
+ACPI_STATUS
+AcpiEvExecuteRegMethods (
+    ACPI_NAMESPACE_NODE     *Node,
+    ACPI_ADR_SPACE_TYPE     SpaceId);
+
+ACPI_STATUS
AcpiEvExecuteRegMethod (
    ACPI_OPERAND_OBJECT    *RegionObj,
    UINT32                  Function);
Index: sys/dev/acpi/acpica/Subsystem/acexcep.h
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/acexcep.h,v
retrieving revision 1.7
diff -u -r1.7 acexcep.h
--- sys/dev/acpi/acpica/Subsystem/acexcep.h     14 Feb 2004 16:57:24 -0000      1.7
+++ sys/dev/acpi/acpica/Subsystem/acexcep.h     17 Jun 2004 04:08:35 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Name: acexcep.h - Exception codes returned by the ACPI subsystem
- *       xRevision: 70 $
+ *       xRevision: 71 $
 *
 *****************************************************************************/

@@ -168,8 +168,9 @@
#define AE_LOGICAL_ADDRESS              (ACPI_STATUS) (0x001B | AE_CODE_ENVIRONMENTAL)
#define AE_ABORT_METHOD                 (ACPI_STATUS) (0x001C | AE_CODE_ENVIRONMENTAL)
#define AE_SAME_HANDLER                 (ACPI_STATUS) (0x001D | AE_CODE_ENVIRONMENTAL)
+#define AE_WAKE_ONLY_GPE                (ACPI_STATUS) (0x001E | AE_CODE_ENVIRONMENTAL)

-#define AE_CODE_ENV_MAX                 0x001D
+#define AE_CODE_ENV_MAX                 0x001E

/*
 * Programmer exceptions
@@ -295,7 +296,8 @@
    "AE_NO_GLOBAL_LOCK",
    "AE_LOGICAL_ADDRESS",
    "AE_ABORT_METHOD",
-    "AE_SAME_HANDLER"
+    "AE_SAME_HANDLER",
+    "AE_WAKE_ONLY_GPE"
};

char const   *AcpiGbl_ExceptionNames_Pgm[] =
Index: sys/dev/acpi/acpica/Subsystem/acglobal.h
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/acglobal.h,v
retrieving revision 1.9
diff -u -r1.9 acglobal.h
--- sys/dev/acpi/acpica/Subsystem/acglobal.h    14 Feb 2004 16:57:24 -0000      1.9
+++ sys/dev/acpi/acpica/Subsystem/acglobal.h    17 Jun 2004 04:08:35 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Name: acglobal.h - Declarations for global variables
- *       xRevision: 145 $
+ *       xRevision: 154 $
 *
 *****************************************************************************/

@@ -119,17 +119,26 @@


/*
- * Ensure that the globals are actually defined only once.
+ * Ensure that the globals are actually defined and initialized only once.
 *
- * The use of these defines allows a single list of globals (here) in order
+ * The use of these macros allows a single list of globals (here) in order
 * to simplify maintenance of the code.
 */
#ifdef DEFINE_ACPI_GLOBALS
#define ACPI_EXTERN
+#define ACPI_INIT_GLOBAL(a,b) a=b
#else
#define ACPI_EXTERN extern
+#define ACPI_INIT_GLOBAL(a,b) a
#endif

+/*
+ * Keep local copies of these FADT-based registers.  NOTE: These globals
+ * are first in this file for alignment reasons on 64-bit systems.
+ */
+ACPI_EXTERN ACPI_GENERIC_ADDRESS        AcpiGbl_XPm1aEnable;
+ACPI_EXTERN ACPI_GENERIC_ADDRESS        AcpiGbl_XPm1bEnable;
+

/*****************************************************************************
 *
@@ -149,6 +158,35 @@

/*****************************************************************************
 *
+ * Runtime configuration (static defaults that can be overriden at runtime)
+ *
+ ****************************************************************************/
+
+/*
+ * Create the predefined _OSI method in the namespace? Default is TRUE
+ * because ACPI CA is fully compatible with other ACPI implementations.
+ * Changing this will revert ACPI CA (and machine ASL) to pre-OSI behavior.
+ */
+ACPI_EXTERN UINT8       ACPI_INIT_GLOBAL (AcpiGbl_CreateOsiMethod, TRUE);
+
+/*
+ * Automatically serialize ALL control methods? Default is FALSE, meaning
+ * to use the Serialized/NotSerialized method flags on a per method basis.
+ * Only change this if the ASL code is poorly written and cannot handle
+ * reentrancy even though methods are marked "NotSerialized".
+ */
+ACPI_EXTERN UINT8       ACPI_INIT_GLOBAL (AcpiGbl_AllMethodsSerialized, FALSE);
+
+/*
+ * Disable wakeup GPEs during runtime? Default is TRUE because WAKE and
+ * RUNTIME GPEs should never be shared, and WAKE GPEs should typically only
+ * be enabled just before going to sleep.
+ */
+ACPI_EXTERN UINT8       ACPI_INIT_GLOBAL (AcpiGbl_LeaveWakeGpesDisabled, TRUE);
+
+
+/*****************************************************************************
+ *
 * ACPI Table globals
 *
 ****************************************************************************/
@@ -160,7 +198,6 @@
 *
 * These tables are single-table only; meaning that there can be at most one
 * of each in the system.  Each global points to the actual table.
- *
 */
ACPI_EXTERN UINT32                      AcpiGbl_TableFlags;
ACPI_EXTERN UINT32                      AcpiGbl_RsdtTableCount;
@@ -170,6 +207,11 @@
ACPI_EXTERN ACPI_TABLE_HEADER          *AcpiGbl_DSDT;
ACPI_EXTERN FACS_DESCRIPTOR            *AcpiGbl_FACS;
ACPI_EXTERN ACPI_COMMON_FACS            AcpiGbl_CommonFACS;
+/*
+ * Since there may be multiple SSDTs and PSDTS, a single pointer is not
+ * sufficient; Therefore, there isn't one!
+ */
+

/*
 * Handle both ACPI 1.0 and ACPI 2.0 Integer widths
@@ -180,17 +222,6 @@
ACPI_EXTERN UINT8                       AcpiGbl_IntegerByteWidth;
ACPI_EXTERN UINT8                       AcpiGbl_IntegerNybbleWidth;

-/* Keep local copies of these FADT-based registers */
-
-ACPI_EXTERN ACPI_GENERIC_ADDRESS        AcpiGbl_XPm1aEnable;
-ACPI_EXTERN ACPI_GENERIC_ADDRESS        AcpiGbl_XPm1bEnable;
-
-/*
- * Since there may be multiple SSDTs and PSDTS, a single pointer is not
- * sufficient; Therefore, there isn't one!
- */
-
-
/*
 * ACPI Table info arrays
 */
@@ -234,13 +265,16 @@
ACPI_EXTERN BOOLEAN                     AcpiGbl_AcpiHardwarePresent;
ACPI_EXTERN BOOLEAN                     AcpiGbl_GlobalLockPresent;
ACPI_EXTERN BOOLEAN                     AcpiGbl_EventsInitialized;
+ACPI_EXTERN BOOLEAN                     AcpiGbl_SystemAwakeAndRunning;

extern BOOLEAN                          AcpiGbl_Shutdown;
extern UINT32                           AcpiGbl_StartupFlags;
extern const UINT8                      AcpiGbl_DecodeTo8bit[8];
-extern const char                      *AcpiGbl_DbSleepStates[ACPI_S_STATE_COUNT];
+extern const char                      *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT];
+extern const char                      *AcpiGbl_HighestDstateNames[4];
extern const ACPI_OPCODE_INFO           AcpiGbl_AmlOpInfo[AML_NUM_OPCODES];
extern const char                      *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS];
+extern const char                      *AcpiGbl_ValidOsiStrings[ACPI_NUM_OSI_STRINGS];


/*****************************************************************************
@@ -251,7 +285,7 @@

#define NUM_NS_TYPES                    ACPI_TYPE_INVALID+1

-#if defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
+#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
#define NUM_PREDEFINED_NAMES            10
#else
#define NUM_PREDEFINED_NAMES            9
@@ -259,6 +293,7 @@

ACPI_EXTERN ACPI_NAMESPACE_NODE         AcpiGbl_RootNodeStruct;
ACPI_EXTERN ACPI_NAMESPACE_NODE        *AcpiGbl_RootNode;
+ACPI_EXTERN ACPI_NAMESPACE_NODE        *AcpiGbl_FadtGpeDevice;

extern const UINT8                      AcpiGbl_NsProperties[NUM_NS_TYPES];
extern const ACPI_PREDEFINED_NAMES      AcpiGbl_PreDefinedNames [NUM_PREDEFINED_NAMES];
Index: sys/dev/acpi/acpica/Subsystem/achware.h
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/achware.h,v
retrieving revision 1.8
diff -u -r1.8 achware.h
--- sys/dev/acpi/acpica/Subsystem/achware.h     14 Feb 2004 16:57:24 -0000      1.8
+++ sys/dev/acpi/acpica/Subsystem/achware.h     17 Jun 2004 04:08:35 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Name: achware.h -- hardware specific interfaces
- *       xRevision: 68 $
+ *       xRevision: 72 $
 *
 *****************************************************************************/

@@ -187,15 +187,7 @@
/* GPE support */

ACPI_STATUS
-AcpiHwEnableGpe (
-    ACPI_GPE_EVENT_INFO     *GpeEventInfo);
-
-void
-AcpiHwEnableGpeForWakeup (
-    ACPI_GPE_EVENT_INFO     *GpeEventInfo);
-
-ACPI_STATUS
-AcpiHwDisableGpe (
+AcpiHwWriteGpeEnableReg (
    ACPI_GPE_EVENT_INFO     *GpeEventInfo);

ACPI_STATUS
@@ -203,10 +195,6 @@
    ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
    ACPI_GPE_BLOCK_INFO     *GpeBlock);

-void
-AcpiHwDisableGpeForWakeup (
-    ACPI_GPE_EVENT_INFO     *GpeEventInfo);
-
ACPI_STATUS
AcpiHwClearGpe (
    ACPI_GPE_EVENT_INFO     *GpeEventInfo);
@@ -222,13 +210,27 @@
    ACPI_EVENT_STATUS       *EventStatus);

ACPI_STATUS
-AcpiHwDisableNonWakeupGpes (
+AcpiHwDisableAllGpes (
+    void);
+
+ACPI_STATUS
+AcpiHwEnableAllRuntimeGpes (
    void);

ACPI_STATUS
-AcpiHwEnableNonWakeupGpes (
+AcpiHwEnableAllWakeupGpes (
    void);

+ACPI_STATUS
+AcpiHwEnableRuntimeGpeBlock (
+    ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
+    ACPI_GPE_BLOCK_INFO     *GpeBlock);
+
+ACPI_STATUS
+AcpiHwEnableWakeupGpeBlock (
+    ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
+    ACPI_GPE_BLOCK_INFO     *GpeBlock);
+

/* ACPI Timer prototypes */

Index: sys/dev/acpi/acpica/Subsystem/acinterp.h
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/acinterp.h,v
retrieving revision 1.7
diff -u -r1.7 acinterp.h
--- sys/dev/acpi/acpica/Subsystem/acinterp.h    14 Feb 2004 16:57:24 -0000      1.7
+++ sys/dev/acpi/acpica/Subsystem/acinterp.h    17 Jun 2004 04:08:35 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Name: acinterp.h - Interpreter subcomponent prototypes and defines
- *       xRevision: 147 $
+ *       xRevision: 149 $
 *
 *****************************************************************************/

@@ -191,6 +191,12 @@
 */

ACPI_STATUS
+AcpiExCommonBufferSetup (
+    ACPI_OPERAND_OBJECT     *ObjDesc,
+    UINT32                  BufferLength,
+    UINT32                  *DatumCount);
+
+ACPI_STATUS
AcpiExExtractFromField (
    ACPI_OPERAND_OBJECT     *ObjDesc,
    void                    *Buffer,
@@ -636,8 +642,11 @@
AcpiExStoreObjectToNode (
    ACPI_OPERAND_OBJECT     *SourceDesc,
    ACPI_NAMESPACE_NODE     *Node,
-    ACPI_WALK_STATE         *WalkState);
+    ACPI_WALK_STATE         *WalkState,
+    UINT8                   ImplicitConversion);

+#define ACPI_IMPLICIT_CONVERSION        TRUE
+#define ACPI_NO_IMPLICIT_CONVERSION     FALSE

/*
 * exstoren
Index: sys/dev/acpi/acpica/Subsystem/aclocal.h
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/aclocal.h,v
retrieving revision 1.8
diff -u -r1.8 aclocal.h
--- sys/dev/acpi/acpica/Subsystem/aclocal.h     14 Feb 2004 16:57:24 -0000      1.8
+++ sys/dev/acpi/acpica/Subsystem/aclocal.h     17 Jun 2004 04:08:36 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Name: aclocal.h - Internal data types used across the ACPI subsystem
- *       xRevision: 198 $
+ *       xRevision: 201 $
 *
 *****************************************************************************/

@@ -264,8 +264,6 @@
    UINT8                       Type;           /* Type associated with this name */
    UINT16                      OwnerId;
    ACPI_NAME_UNION             Name;           /* ACPI Name, always 4 chars per ACPI spec */
-
-
    union acpi_operand_object   *Object;        /* Pointer to attached ACPI object (optional) */
    struct acpi_namespace_node  *Child;         /* First child */
    struct acpi_namespace_node  *Peer;          /* Next peer*/
@@ -287,10 +285,8 @@
#define ANOBJ_METHOD_LOCAL              0x10
#define ANOBJ_METHOD_NO_RETVAL          0x20
#define ANOBJ_METHOD_SOME_NO_RETVAL     0x40
-
#define ANOBJ_IS_BIT_OFFSET             0x80

-
/*
 * ACPI Table Descriptor.  One per ACPI table
 */
@@ -392,16 +388,33 @@
 *
 ****************************************************************************/

-/* Information about a GPE, one per each GPE in an array */
+/* Dispatch info for each GPE -- either a method or handler, cannot be both */

-typedef struct acpi_gpe_event_info
+typedef struct acpi_handler_info
{
-    ACPI_NAMESPACE_NODE             *MethodNode;    /* Method node for this GPE level */
-    ACPI_GPE_HANDLER                Handler;        /* Address of handler, if any */
+    ACPI_EVENT_HANDLER              Address;        /* Address of handler, if any */
    void                            *Context;       /* Context to be passed to handler */
+    ACPI_NAMESPACE_NODE             *MethodNode;    /* Method node for this GPE level (saved) */
+
+} ACPI_HANDLER_INFO;
+
+typedef union acpi_gpe_dispatch_info
+{
+    ACPI_NAMESPACE_NODE             *MethodNode;    /* Method node for this GPE level */
+    struct acpi_handler_info        *Handler;
+
+} ACPI_GPE_DISPATCH_INFO;
+
+/*
+ * Information about a GPE, one per each GPE in an array.
+ * NOTE: Important to keep this struct as small as possible.
+ */
+typedef struct acpi_gpe_event_info
+{
+    union acpi_gpe_dispatch_info    Dispatch;       /* Either Method or Handler */
    struct acpi_gpe_register_info   *RegisterInfo;  /* Backpointer to register info */
-    UINT8                           Flags;          /* Level or Edge */
-    UINT8                           BitMask;        /* This GPE within the register */
+    UINT8                           Flags;          /* Misc info about this GPE */
+    UINT8                           RegisterBit;    /* This GPE bit within the register */

} ACPI_GPE_EVENT_INFO;

@@ -411,9 +424,8 @@
{
    ACPI_GENERIC_ADDRESS            StatusAddress;  /* Address of status reg */
    ACPI_GENERIC_ADDRESS            EnableAddress;  /* Address of enable reg */
-    UINT8                           Status;         /* Current value of status reg */
-    UINT8                           Enable;         /* Current value of enable reg */
-    UINT8                           WakeEnable;     /* Mask of bits to keep enabled when sleeping */
+    UINT8                           EnableForWake;  /* GPEs to keep enabled when sleeping */
+    UINT8                           EnableForRun;   /* GPEs to keep enabled when running */
    UINT8                           BaseGpeNumber;  /* Base GPE number for this register */

} ACPI_GPE_REGISTER_INFO;
@@ -424,6 +436,7 @@
 */
typedef struct acpi_gpe_block_info
{
+    ACPI_NAMESPACE_NODE             *Node;
    struct acpi_gpe_block_info      *Previous;
    struct acpi_gpe_block_info      *Next;
    struct acpi_gpe_xrupt_info      *XruptBlock;    /* Backpointer to interrupt block */
@@ -447,6 +460,14 @@
} ACPI_GPE_XRUPT_INFO;


+typedef struct acpi_gpe_walk_info
+{
+    ACPI_NAMESPACE_NODE             *GpeDevice;
+    ACPI_GPE_BLOCK_INFO             *GpeBlock;
+
+} ACPI_GPE_WALK_INFO;
+
+
typedef ACPI_STATUS (*ACPI_GPE_CALLBACK) (
    ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
    ACPI_GPE_BLOCK_INFO     *GpeBlock);
@@ -590,7 +611,7 @@
    struct acpi_walk_state      *WalkStateList;         /* Head of list of WalkStates for this thread */
    union acpi_operand_object   *AcquiredMutexList;     /* List of all currently acquired mutexes */
    UINT32                      ThreadId;               /* Running thread ID */
-    UINT16                      CurrentSyncLevel;       /* Mutex Sync (nested acquire) level */
+    UINT8                       CurrentSyncLevel;       /* Mutex Sync (nested acquire) level */

} ACPI_THREAD_STATE;

Index: sys/dev/acpi/acpica/Subsystem/acmacros.h
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/acmacros.h,v
retrieving revision 1.8
diff -u -r1.8 acmacros.h
--- sys/dev/acpi/acpica/Subsystem/acmacros.h    14 Feb 2004 16:57:24 -0000      1.8
+++ sys/dev/acpi/acpica/Subsystem/acmacros.h    17 Jun 2004 04:08:36 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Name: acmacros.h - C macros for the entire subsystem.
- *       xRevision: 148 $
+ *       xRevision: 151 $
 *
 *****************************************************************************/

@@ -126,6 +126,9 @@
#define ACPI_LOBYTE(l)                  ((UINT8)(UINT16)(l))
#define ACPI_HIBYTE(l)                  ((UINT8)((((UINT16)(l)) >> 8) & 0xFF))

+#define ACPI_SET_BIT(target,bit)        ((target) |= (bit))
+#define ACPI_CLEAR_BIT(target,bit)      ((target) &= ~(bit))
+

#if ACPI_MACHINE_WIDTH == 16

@@ -170,7 +173,7 @@
 * printf() format helpers
 */

-/* Split 64-bit integer into two 32-bit values. Use with %8,8X%8.8X */
+/* Split 64-bit integer into two 32-bit values. Use with %8.8X%8.8X */

#define ACPI_FORMAT_UINT64(i)           ACPI_HIDWORD(i),ACPI_LODWORD(i)

@@ -754,7 +757,4 @@

#endif /* ACPI_DBG_TRACK_ALLOCATIONS */

-
-#define ACPI_GET_STACK_POINTER          _asm {mov eax, ebx}
-
#endif /* ACMACROS_H */
Index: sys/dev/acpi/acpica/Subsystem/acnamesp.h
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/acnamesp.h,v
retrieving revision 1.7
diff -u -r1.7 acnamesp.h
--- sys/dev/acpi/acpica/Subsystem/acnamesp.h    14 Feb 2004 16:57:24 -0000      1.7
+++ sys/dev/acpi/acpica/Subsystem/acnamesp.h    17 Jun 2004 04:08:36 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Name: acnamesp.h - Namespace subcomponent prototypes and defines
- *       xRevision: 135 $
+ *       xRevision: 136 $
 *
 *****************************************************************************/

@@ -351,33 +351,25 @@

ACPI_STATUS
AcpiNsEvaluateByHandle (
-    ACPI_NAMESPACE_NODE     *PrefixNode,
-    ACPI_OPERAND_OBJECT     **Params,
-    ACPI_OPERAND_OBJECT     **ReturnObject);
+    ACPI_PARAMETER_INFO     *Info);

ACPI_STATUS
AcpiNsEvaluateByName (
    char                    *Pathname,
-    ACPI_OPERAND_OBJECT     **Params,
-    ACPI_OPERAND_OBJECT     **ReturnObject);
+    ACPI_PARAMETER_INFO     *Info);

ACPI_STATUS
AcpiNsEvaluateRelative (
-    ACPI_NAMESPACE_NODE     *PrefixNode,
    char                    *Pathname,
-    ACPI_OPERAND_OBJECT     **Params,
-    ACPI_OPERAND_OBJECT     **ReturnObject);
+    ACPI_PARAMETER_INFO     *Info);

ACPI_STATUS
AcpiNsExecuteControlMethod (
-    ACPI_NAMESPACE_NODE     *MethodNode,
-    ACPI_OPERAND_OBJECT     **Params,
-    ACPI_OPERAND_OBJECT     **ReturnObjDesc);
+    ACPI_PARAMETER_INFO     *Info);

ACPI_STATUS
AcpiNsGetObjectValue (
-    ACPI_NAMESPACE_NODE     *ObjectNode,
-    ACPI_OPERAND_OBJECT     **ReturnObjDesc);
+    ACPI_PARAMETER_INFO     *Info);


/*
Index: sys/dev/acpi/acpica/Subsystem/acnetbsd.h
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/acnetbsd.h,v
retrieving revision 1.12
diff -u -r1.12 acnetbsd.h
--- sys/dev/acpi/acpica/Subsystem/acnetbsd.h    14 Feb 2004 16:57:24 -0000      1.12
+++ sys/dev/acpi/acpica/Subsystem/acnetbsd.h    17 Jun 2004 04:08:36 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Name: acnetbsd.h - OS specific defines, etc.
- *       $Revision: 1.12 $
+ *       xRevision: 5 $
 *
 *****************************************************************************/

@@ -117,24 +117,14 @@
#ifndef __ACNETBSD_H__
#define __ACNETBSD_H__

-#if 0
-/*
- * XXX this is technically correct, but will cause problems with some ASL
- *     which only works if the string names a Microsoft operating system.
- */
-#define ACPI_OS_NAME           "NetBSD"
-#else
-#define ACPI_OS_NAME           "Microsoft Windows NT"
-#endif
-
/* NetBSD uses GCC */

#include "acgcc.h"

#ifdef _LP64
-#define ACPI_MACHINE_WIDTH     64
+#define ACPI_MACHINE_WIDTH      64
#else
-#define ACPI_MACHINE_WIDTH     32
+#define ACPI_MACHINE_WIDTH      32
#endif

#define COMPILER_DEPENDENT_INT64  int64_t
@@ -176,7 +166,7 @@
static __inline int
isprint(int ch)
{
-       return(isspace(ch) || isascii(ch));
+        return(isspace(ch) || isascii(ch));
}

#else /* _KERNEL */
@@ -202,11 +192,11 @@
static __inline char *
strupr(char *str)
{
-       char *c = str;
-       while (*c) {
-               *c = toupper(*c);
-               c++;
-       }
-       return(str);
+    char *c = str;
+    while(*c) {
+        *c = toupper(*c);
+        c++;
+    }
+    return(str);
}
#endif /* __ACNETBSD_H__ */
Index: sys/dev/acpi/acpica/Subsystem/acobject.h
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/acobject.h,v
retrieving revision 1.9
diff -u -r1.9 acobject.h
--- sys/dev/acpi/acpica/Subsystem/acobject.h    7 Apr 2004 18:19:33 -0000       1.9
+++ sys/dev/acpi/acpica/Subsystem/acobject.h    17 Jun 2004 04:08:37 -0000
@@ -2,7 +2,7 @@
/******************************************************************************
 *
 * Name: acobject.h - Definition of ACPI_OPERAND_OBJECT  (Internal object only)
- *       xRevision: 123 $
+ *       xRevision: 125 $
 *
 *****************************************************************************/

@@ -259,7 +259,11 @@
} ACPI_OBJECT_EVENT;


-#define INFINITE_CONCURRENCY        0xFF
+#define ACPI_INFINITE_CONCURRENCY   0xFF
+
+typedef
+ACPI_STATUS (*ACPI_INTERNAL_METHOD) (
+    struct acpi_walk_state  *WalkState);

typedef struct acpi_object_method
{
@@ -269,6 +273,7 @@
    UINT32                          AmlLength;
    void                            *Semaphore;
    UINT8                           *AmlStart;
+    ACPI_INTERNAL_METHOD            Implementation;
    UINT8                           Concurrency;
    UINT8                           ThreadCount;
    ACPI_OWNER_ID                   OwningId;
@@ -279,14 +284,14 @@
typedef struct acpi_object_mutex
{
    ACPI_OBJECT_COMMON_HEADER
-    UINT16                          SyncLevel;
-    UINT16                          PreviousSyncLevel;
-    UINT16                          AcquisitionDepth;
-    struct acpi_thread_state        *OwnerThread;
-    void                            *Semaphore;
+    UINT8                           SyncLevel;          /* 0-15, specified in Mutex() call */
+    UINT16                          AcquisitionDepth;   /* Allow multiple Acquires, same thread */
+    struct acpi_thread_state        *OwnerThread;       /* Current owner of the mutex */
+    void                            *Semaphore;         /* Actual OS synchronization object */
    union acpi_operand_object       *Prev;              /* Link for list of acquired mutexes */
    union acpi_operand_object       *Next;              /* Link for list of acquired mutexes */
-    ACPI_NAMESPACE_NODE             *Node;              /* containing object */
+    ACPI_NAMESPACE_NODE             *Node;              /* Containing namespace node */
+    UINT8                           OriginalSyncLevel;  /* Owner's original sync level (0-15) */

} ACPI_OBJECT_MUTEX;

@@ -297,7 +302,7 @@

    UINT8                           SpaceId;
    union acpi_operand_object       *Handler;           /* Handler for region access */
-    ACPI_NAMESPACE_NODE             *Node;              /* containing object */
+    ACPI_NAMESPACE_NODE             *Node;              /* Containing namespace node */
    union acpi_operand_object       *Next;
    UINT32                          Length;
    ACPI_PHYSICAL_ADDRESS           Address;
Index: sys/dev/acpi/acpica/Subsystem/acparser.h
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/acparser.h,v
retrieving revision 1.7
diff -u -r1.7 acparser.h
--- sys/dev/acpi/acpica/Subsystem/acparser.h    14 Feb 2004 16:57:24 -0000      1.7
+++ sys/dev/acpi/acpica/Subsystem/acparser.h    17 Jun 2004 04:08:37 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Module Name: acparser.h - AML Parser subcomponent prototypes and defines
- *       xRevision: 66 $
+ *       xRevision: 67 $
 *
 *****************************************************************************/

@@ -146,9 +146,7 @@

ACPI_STATUS
AcpiPsxExecute (
-    ACPI_NAMESPACE_NODE     *MethodNode,
-    ACPI_OPERAND_OBJECT     **Params,
-    ACPI_OPERAND_OBJECT     **ReturnObjDesc);
+    ACPI_PARAMETER_INFO     *Info);


/******************************************************************************
Index: sys/dev/acpi/acpica/Subsystem/acpixf.h
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/acpixf.h,v
retrieving revision 1.7
diff -u -r1.7 acpixf.h
--- sys/dev/acpi/acpica/Subsystem/acpixf.h      14 Feb 2004 16:57:24 -0000      1.7
+++ sys/dev/acpi/acpica/Subsystem/acpixf.h      17 Jun 2004 04:08:37 -0000
@@ -368,7 +368,7 @@
    ACPI_HANDLE             GpeDevice,
    UINT32                  GpeNumber,
    UINT32                  Type,
-    ACPI_GPE_HANDLER        Handler,
+    ACPI_EVENT_HANDLER      Address,
    void                    *Context);

ACPI_STATUS
@@ -384,7 +384,7 @@
AcpiRemoveGpeHandler (
    ACPI_HANDLE             GpeDevice,
    UINT32                  GpeNumber,
-    ACPI_GPE_HANDLER        Handler);
+    ACPI_EVENT_HANDLER      Address);

ACPI_STATUS
AcpiEnableEvent (
@@ -406,6 +406,12 @@
    ACPI_EVENT_STATUS       *EventStatus);

ACPI_STATUS
+AcpiSetGpeType (
+    ACPI_HANDLE             GpeDevice,
+    UINT32                  GpeNumber,
+    UINT8                   Type);
+
+ACPI_STATUS
AcpiEnableGpe (
    ACPI_HANDLE             GpeDevice,
    UINT32                  GpeNumber,
Index: sys/dev/acpi/acpica/Subsystem/acstruct.h
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/acstruct.h,v
retrieving revision 1.7
diff -u -r1.7 acstruct.h
--- sys/dev/acpi/acpica/Subsystem/acstruct.h    14 Feb 2004 16:57:24 -0000      1.7
+++ sys/dev/acpi/acpica/Subsystem/acstruct.h    17 Jun 2004 04:08:37 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Name: acstruct.h - Internal structs
- *       xRevision: 27 $
+ *       xRevision: 28 $
 *
 *****************************************************************************/

@@ -142,13 +142,14 @@
typedef struct acpi_walk_state
{
    UINT8                       DataType;                           /* To differentiate various internal objs MUST BE FIRST!*/\
+    UINT8                       WalkType;
    ACPI_OWNER_ID               OwnerId;                            /* Owner of objects created during the walk */
    BOOLEAN                     LastPredicate;                      /* Result of last predicate */
+    UINT8                       Reserved;                           /* For alignment */
    UINT8                       CurrentResult;                      /* */
    UINT8                       NextOpInfo;                         /* Info about NextOp */
    UINT8                       NumOperands;                        /* Stack pointer for Operands[] array */
    UINT8                       ReturnUsed;
-    UINT8                       WalkType;
    UINT16                      Opcode;                             /* Current AML opcode */
    UINT8                       ScopeDepth;
    UINT8                       Reserved1;
@@ -164,7 +165,8 @@
    struct acpi_namespace_node  Arguments[ACPI_METHOD_NUM_ARGS];    /* Control method arguments */
    union acpi_operand_object   **CallerReturnDesc;
    ACPI_GENERIC_STATE          *ControlState;                      /* List of control states (nested IFs) */
-    struct acpi_namespace_node  *DeferredNode;                       /* Used when executing deferred opcodes */
+    struct acpi_namespace_node  *DeferredNode;                      /* Used when executing deferred opcodes */
+    struct acpi_gpe_event_info  *GpeEventInfo;                      /* Info for GPE (_Lxx/_Exx methods only */
    struct acpi_namespace_node  LocalVariables[ACPI_METHOD_NUM_LOCALS];     /* Control method locals */
    struct acpi_namespace_node  *MethodCallNode;                    /* Called method Node*/
    ACPI_PARSE_OBJECT           *MethodCallOp;                      /* MethodCall Op if running a method */
@@ -279,4 +281,22 @@
} ACPI_AML_OPERANDS;


+/* Internal method parameter list */
+
+typedef struct acpi_parameter_info
+{
+    ACPI_NAMESPACE_NODE     *Node;
+    ACPI_OPERAND_OBJECT     **Parameters;
+    ACPI_OPERAND_OBJECT     *ReturnObject;
+    UINT8                   ParameterType;
+    UINT8                   ReturnObjectType;
+
+} ACPI_PARAMETER_INFO;
+
+/* Types for ParameterType above */
+
+#define ACPI_PARAM_ARGS                 0
+#define ACPI_PARAM_GPE                  1
+
+
#endif
Index: sys/dev/acpi/acpica/Subsystem/actbl.h
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/actbl.h,v
retrieving revision 1.7
diff -u -r1.7 actbl.h
--- sys/dev/acpi/acpica/Subsystem/actbl.h       14 Feb 2004 16:57:24 -0000      1.7
+++ sys/dev/acpi/acpica/Subsystem/actbl.h       17 Jun 2004 04:08:37 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Name: actbl.h - Table data structures defined in ACPI specification
- *       xRevision: 64 $
+ *       xRevision: 66 $
 *
 *****************************************************************************/

@@ -375,20 +375,6 @@
} SMART_BATTERY_TABLE;


-/*
- * High performance timer
- */
-typedef struct hpet_table
-{
-    ACPI_TABLE_HEADER_DEF
-    UINT32                  HardwareId;
-    UINT32                  BaseAddress [3];
-    UINT8                   HpetNumber;
-    UINT16                  ClockTick;
-    UINT8                   Attributes;
-
-} HPET_TABLE;
-
#pragma pack()


@@ -433,4 +419,21 @@
#include "actbl2.h"   /* Acpi 2.0 table definitions */


+#pragma pack(1)
+/*
+ * High performance timer
+ */
+typedef struct hpet_table
+{
+    ACPI_TABLE_HEADER_DEF
+    UINT32                  HardwareId;
+    ACPI_GENERIC_ADDRESS    BaseAddress;
+    UINT8                   HpetNumber;
+    UINT16                  ClockTick;
+    UINT8                   Attributes;
+
+} HPET_TABLE;
+
+#pragma pack()
+
#endif /* __ACTBL_H__ */
Index: sys/dev/acpi/acpica/Subsystem/actbl2.h
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/actbl2.h,v
retrieving revision 1.7
diff -u -r1.7 actbl2.h
--- sys/dev/acpi/acpica/Subsystem/actbl2.h      14 Feb 2004 16:57:24 -0000      1.7
+++ sys/dev/acpi/acpica/Subsystem/actbl2.h      17 Jun 2004 04:08:37 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Name: actbl2.h - ACPI Specification Revision 2.0 Tables
- *       xRevision: 35 $
+ *       xRevision: 36 $
 *
 *****************************************************************************/

@@ -171,7 +171,7 @@
    UINT32                  HardwareSignature;      /* Hardware configuration signature */
    UINT32                  FirmwareWakingVector;   /* 32bit physical address of the Firmware Waking Vector. */
    UINT32                  GlobalLock;             /* Global Lock used to synchronize access to shared hardware resources */
-    UINT32                  S4Bios_f        : 1;    /* S4Bios_f - Indicates if S4BIOS support is present */
+    UINT32_BIT              S4Bios_f        : 1;    /* S4Bios_f - Indicates if S4BIOS support is present */
    UINT32_BIT              Reserved1       : 31;   /* Must be 0 */
    UINT64                  XFirmwareWakingVector;  /* 64bit physical address of the Firmware Waking Vector. */
    UINT8                   Version;                /* Version of this table */
Index: sys/dev/acpi/acpica/Subsystem/actypes.h
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/actypes.h,v
retrieving revision 1.11
diff -u -r1.11 actypes.h
--- sys/dev/acpi/acpica/Subsystem/actypes.h     14 Feb 2004 16:57:24 -0000      1.11
+++ sys/dev/acpi/acpica/Subsystem/actypes.h     17 Jun 2004 04:08:38 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Name: actypes.h - Common data types for the entire ACPI subsystem
- *       xRevision: 263 $
+ *       xRevision: 270 $
 *
 *****************************************************************************/

@@ -428,7 +428,6 @@
/*
 * Power state values
 */
-
#define ACPI_STATE_UNKNOWN              (UINT8) 0xFF

#define ACPI_STATE_S0                   (UINT8) 0
@@ -472,7 +471,6 @@
#define ACPI_NOTIFY_BUS_MODE_MISMATCH   (UINT8) 6
#define ACPI_NOTIFY_POWER_FAULT         (UINT8) 7

-
/*
 *  Table types.  These values are passed to the table related APIs
 */
@@ -488,14 +486,13 @@
#define ACPI_TABLE_MAX                  6
#define NUM_ACPI_TABLE_TYPES            (ACPI_TABLE_MAX+1)

-
/*
 * Types associated with ACPI names and objects.  The first group of
 * values (up to ACPI_TYPE_EXTERNAL_MAX) correspond to the definition
 * of the ACPI ObjectType() operator (See the ACPI Spec).  Therefore,
 * only add to the first group if the spec changes.
 *
- * Types must be kept in sync with the global AcpiNsProperties
+ * NOTE: Types must be kept in sync with the global AcpiNsProperties
 * and AcpiNsTypeNames arrays.
 */
typedef UINT32                          ACPI_OBJECT_TYPE;
@@ -532,26 +529,27 @@
#define ACPI_TYPE_LOCAL_INDEX_FIELD     0x13
#define ACPI_TYPE_LOCAL_REFERENCE       0x14  /* Arg#, Local#, Name, Debug, RefOf, Index */
#define ACPI_TYPE_LOCAL_ALIAS           0x15
-#define ACPI_TYPE_LOCAL_NOTIFY          0x16
-#define ACPI_TYPE_LOCAL_ADDRESS_HANDLER 0x17
-#define ACPI_TYPE_LOCAL_RESOURCE        0x18
-#define ACPI_TYPE_LOCAL_RESOURCE_FIELD  0x19
-#define ACPI_TYPE_LOCAL_SCOPE           0x1A  /* 1 Name, multiple ObjectList Nodes */
+#define ACPI_TYPE_LOCAL_METHOD_ALIAS    0x16
+#define ACPI_TYPE_LOCAL_NOTIFY          0x17
+#define ACPI_TYPE_LOCAL_ADDRESS_HANDLER 0x18
+#define ACPI_TYPE_LOCAL_RESOURCE        0x19
+#define ACPI_TYPE_LOCAL_RESOURCE_FIELD  0x1A
+#define ACPI_TYPE_LOCAL_SCOPE           0x1B  /* 1 Name, multiple ObjectList Nodes */

-#define ACPI_TYPE_NS_NODE_MAX           0x1A  /* Last typecode used within a NS Node */
+#define ACPI_TYPE_NS_NODE_MAX           0x1B  /* Last typecode used within a NS Node */

/*
 * These are special object types that never appear in
 * a Namespace node, only in an ACPI_OPERAND_OBJECT
 */
-#define ACPI_TYPE_LOCAL_EXTRA           0x1B
-#define ACPI_TYPE_LOCAL_DATA            0x1C
+#define ACPI_TYPE_LOCAL_EXTRA           0x1C
+#define ACPI_TYPE_LOCAL_DATA            0x1D

-#define ACPI_TYPE_LOCAL_MAX             0x1C
+#define ACPI_TYPE_LOCAL_MAX             0x1D

/* All types above here are invalid */

-#define ACPI_TYPE_INVALID               0x1D
+#define ACPI_TYPE_INVALID               0x1E
#define ACPI_TYPE_NOT_FOUND             0xFF


@@ -593,9 +591,8 @@
#define ACPI_WRITE                      1
#define ACPI_IO_MASK                    1

-
/*
- * Acpi Event Types: Fixed & General Purpose
+ * Event Types: Fixed & General Purpose
 */
typedef UINT32                          ACPI_EVENT_TYPE;

@@ -610,25 +607,8 @@
#define ACPI_EVENT_MAX                  4
#define ACPI_NUM_FIXED_EVENTS           ACPI_EVENT_MAX + 1

-#define ACPI_GPE_INVALID                0xFF
-#define ACPI_GPE_MAX                    0xFF
-#define ACPI_NUM_GPE                    256
-
-#define ACPI_EVENT_LEVEL_TRIGGERED      1
-#define ACPI_EVENT_EDGE_TRIGGERED       2
-
/*
- * Flags for GPE and Lock interfaces
- */
-#define ACPI_EVENT_WAKE_ENABLE          0x2
-#define ACPI_EVENT_WAKE_DISABLE         0x2
-
-#define ACPI_NOT_ISR                    0x1
-#define ACPI_ISR                        0x0
-
-
-/*
- * AcpiEvent Status:
+ * Event Status - Per event
 * -------------
 * The encoding of ACPI_EVENT_STATUS is illustrated below.
 * Note that a set bit (1) indicates the property is TRUE
@@ -649,12 +629,74 @@
#define ACPI_EVENT_FLAG_WAKE_ENABLED    (ACPI_EVENT_STATUS) 0x02
#define ACPI_EVENT_FLAG_SET             (ACPI_EVENT_STATUS) 0x04

+/*
+ * General Purpose Events (GPE)
+ */
+#define ACPI_GPE_INVALID                0xFF
+#define ACPI_GPE_MAX                    0xFF
+#define ACPI_NUM_GPE                    256
+
+#define ACPI_GPE_ENABLE                 0
+#define ACPI_GPE_DISABLE                1
+
+
+/*
+ * GPE info flags - Per GPE
+ * +-+-+-+---+---+-+
+ * |7|6|5|4:3|2:1|0|
+ * +-+-+-+---+---+-+
+ *  | | |  |   |  |
+ *  | | |  |   |  +--- Interrupt type: Edge or Level Triggered
+ *  | | |  |   +--- Type: Wake-only, Runtime-only, or wake/runtime
+ *  | | |  +--- Type of dispatch -- to method, handler, or none
+ *  | | +--- Enabled for runtime?
+ *  | +--- Enabled for wake?
+ *  +--- System state when GPE ocurred (running/waking)
+ */
+#define ACPI_GPE_XRUPT_TYPE_MASK        (UINT8) 0x01
+#define ACPI_GPE_LEVEL_TRIGGERED        (UINT8) 0x01
+#define ACPI_GPE_EDGE_TRIGGERED         (UINT8) 0x00
+
+#define ACPI_GPE_TYPE_MASK              (UINT8) 0x06
+#define ACPI_GPE_TYPE_WAKE_RUN          (UINT8) 0x06
+#define ACPI_GPE_TYPE_WAKE              (UINT8) 0x02
+#define ACPI_GPE_TYPE_RUNTIME           (UINT8) 0x04    /* Default */
+
+#define ACPI_GPE_DISPATCH_MASK          (UINT8) 0x18
+#define ACPI_GPE_DISPATCH_HANDLER       (UINT8) 0x08
+#define ACPI_GPE_DISPATCH_METHOD        (UINT8) 0x10
+#define ACPI_GPE_DISPATCH_NOT_USED      (UINT8) 0x00    /* Default */
+
+#define ACPI_GPE_RUN_ENABLE_MASK        (UINT8) 0x20
+#define ACPI_GPE_RUN_ENABLED            (UINT8) 0x20
+#define ACPI_GPE_RUN_DISABLED           (UINT8) 0x00    /* Default */
+
+#define ACPI_GPE_WAKE_ENABLE_MASK       (UINT8) 0x40
+#define ACPI_GPE_WAKE_ENABLED           (UINT8) 0x40
+#define ACPI_GPE_WAKE_DISABLED          (UINT8) 0x00    /* Default */
+
+#define ACPI_GPE_ENABLE_MASK            (UINT8) 0x60    /* Both run/wake */
+
+#define ACPI_GPE_SYSTEM_MASK            (UINT8) 0x80
+#define ACPI_GPE_SYSTEM_RUNNING         (UINT8) 0x80
+#define ACPI_GPE_SYSTEM_WAKING          (UINT8) 0x00
+
+/*
+ * Flags for GPE and Lock interfaces
+ */
+#define ACPI_EVENT_WAKE_ENABLE          0x2             /* AcpiGpeEnable */
+#define ACPI_EVENT_WAKE_DISABLE         0x2             /* AcpiGpeDisable */
+
+#define ACPI_NOT_ISR                    0x1
+#define ACPI_ISR                        0x0
+

/* Notify types */

-#define ACPI_SYSTEM_NOTIFY              0
-#define ACPI_DEVICE_NOTIFY              1
-#define ACPI_MAX_NOTIFY_HANDLER_TYPE    1
+#define ACPI_SYSTEM_NOTIFY              0x1
+#define ACPI_DEVICE_NOTIFY              0x2
+#define ACPI_ALL_NOTIFY                 0x3
+#define ACPI_MAX_NOTIFY_HANDLER_TYPE    0x3

#define ACPI_MAX_SYS_NOTIFY             0x7f

@@ -855,10 +897,6 @@
    void                        *Context);

typedef
-void (*ACPI_GPE_HANDLER) (
-    void                        *Context);
-
-typedef
void (*ACPI_NOTIFY_HANDLER) (
    ACPI_HANDLE                 Device,
    UINT32                      Value,
@@ -878,7 +916,7 @@
#define ACPI_INIT_DEVICE_INI        1


-/* Address Spaces (Operation Regions */
+/* Address Spaces (For Operation Regions) */

typedef
ACPI_STATUS (*ACPI_ADR_SPACE_HANDLER) (
@@ -948,6 +986,7 @@
#define ACPI_VALID_HID                  0x0004
#define ACPI_VALID_UID                  0x0008
#define ACPI_VALID_CID                  0x0010
+#define ACPI_VALID_SXDS                 0x0020


#define ACPI_COMMON_OBJ_INFO \
@@ -968,11 +1007,12 @@
{
    ACPI_COMMON_OBJ_INFO;

-    UINT32                      Valid;              /* Indicates which fields are valid */
+    UINT32                      Valid;              /* Indicates which fields below are valid */
    UINT32                      CurrentStatus;      /* _STA value */
    ACPI_INTEGER                Address;            /* _ADR value if any */
    ACPI_DEVICE_ID              HardwareId;         /* _HID value if any */
    ACPI_DEVICE_ID              UniqueId;           /* _UID value if any */
+    UINT8                       HighestDstates[4];  /* _SxD values: 0xFF indicates not valid */
    ACPI_COMPATIBLE_ID_LIST     CompatibilityId;    /* List of _CIDs if any */

} ACPI_DEVICE_INFO;
Index: sys/dev/acpi/acpica/Subsystem/acutils.h
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/acutils.h,v
retrieving revision 1.8
diff -u -r1.8 acutils.h
--- sys/dev/acpi/acpica/Subsystem/acutils.h     14 Feb 2004 16:57:24 -0000      1.8
+++ sys/dev/acpi/acpica/Subsystem/acutils.h     17 Jun 2004 04:08:38 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Name: acutils.h -- prototypes for the common (subsystem-wide) procedures
- *       xRevision: 158 $
+ *       xRevision: 161 $
 *
 *****************************************************************************/

@@ -125,7 +125,6 @@
    ACPI_GENERIC_STATE      *State,
    void                    *Context);

-
ACPI_STATUS
AcpiUtWalkPackageTree (
    ACPI_OPERAND_OBJECT     *SourceObject,
@@ -133,7 +132,6 @@
    ACPI_PKG_CALLBACK       WalkCallback,
    void                    *Context);

-
typedef struct acpi_pkg_info
{
    UINT8                   *FreeSpace;
@@ -547,9 +545,14 @@
#define METHOD_NAME__PRT        "_PRT"
#define METHOD_NAME__CRS        "_CRS"
#define METHOD_NAME__PRS        "_PRS"
+#define METHOD_NAME__PRW        "_PRW"


ACPI_STATUS
+AcpiUtOsiImplementation (
+    ACPI_WALK_STATE         *WalkState);
+
+ACPI_STATUS
AcpiUtEvaluateObject (
    ACPI_NAMESPACE_NODE     *PrefixNode,
    char                    *Path,
@@ -582,6 +585,10 @@
    ACPI_NAMESPACE_NODE     *DeviceNode,
    ACPI_DEVICE_ID          *Uid);

+ACPI_STATUS
+AcpiUtExecute_Sxds (
+    ACPI_NAMESPACE_NODE     *DeviceNode,
+    UINT8                   *Highest);

/*
 * UtMutex - mutual exclusion interfaces
Index: sys/dev/acpi/acpica/Subsystem/amlcode.h
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/amlcode.h,v
retrieving revision 1.8
diff -u -r1.8 amlcode.h
--- sys/dev/acpi/acpica/Subsystem/amlcode.h     14 Feb 2004 16:57:24 -0000      1.8
+++ sys/dev/acpi/acpica/Subsystem/amlcode.h     17 Jun 2004 04:08:38 -0000
@@ -3,7 +3,7 @@
 * Name: amlcode.h - Definitions for AML, as included in "definition blocks"
 *                   Declarations and definitions contained herein are derived
 *                   directly from the ACPI specification.
- *       xRevision: 74 $
+ *       xRevision: 75 $
 *
 *****************************************************************************/

@@ -569,11 +569,17 @@
} AML_ACCESS_ATTRIBUTE;


-/* bit fields in MethodFlags byte */
+/* Bit fields in MethodFlags byte */

-#define METHOD_FLAGS_ARG_COUNT      0x07
-#define METHOD_FLAGS_SERIALIZED     0x08
-#define METHOD_FLAGS_SYNCH_LEVEL    0xF0
+#define AML_METHOD_ARG_COUNT        0x07
+#define AML_METHOD_SERIALIZED       0x08
+#define AML_METHOD_SYNCH_LEVEL      0xF0
+
+/* METHOD_FLAGS_ARG_COUNT is not used internally, define additional flags */
+
+#define AML_METHOD_INTERNAL_ONLY    0x01
+#define AML_METHOD_RESERVED1        0x02
+#define AML_METHOD_RESERVED2        0x04


#endif /* __AMLCODE_H__ */
Index: sys/dev/acpi/acpica/Subsystem/dbcmds.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/dbcmds.c,v
retrieving revision 1.12
diff -u -r1.12 dbcmds.c
--- sys/dev/acpi/acpica/Subsystem/dbcmds.c      14 Feb 2004 16:57:24 -0000      1.12
+++ sys/dev/acpi/acpica/Subsystem/dbcmds.c      17 Jun 2004 04:08:39 -0000
@@ -1,7 +1,7 @@
/*******************************************************************************
 *
 * Module Name: dbcmds - debug commands and output routines
- *              xRevision: 110 $
+ *              xRevision: 113 $
 *
 ******************************************************************************/

@@ -160,6 +160,41 @@
};


+ACPI_STATUS
+AcpiDbSleep (
+    char                    *ObjectArg)
+{
+#if ACPI_MACHINE_WIDTH == 16
+    return (AE_OK);
+#else
+    ACPI_STATUS             Status;
+    UINT8                   SleepState;
+
+
+    SleepState = (UINT8) ACPI_STRTOUL (ObjectArg, NULL, 0);
+
+    AcpiOsPrintf ("**** Prepare to sleep ****\n");
+    Status = AcpiEnterSleepStatePrep (SleepState);
+    if (ACPI_FAILURE (Status))
+    {
+        return (Status);
+    }
+
+    AcpiOsPrintf ("**** Going to sleep ****\n");
+    Status = AcpiEnterSleepState (SleepState);
+    if (ACPI_FAILURE (Status))
+    {
+        return (Status);
+    }
+
+    AcpiOsPrintf ("**** returning from sleep ****\n");
+    Status = AcpiLeaveSleepState (SleepState);
+
+    return (Status);
+#endif
+}
+
+
/*******************************************************************************
 *
 * FUNCTION:    AcpiDbWalkForReferences
@@ -1301,7 +1336,7 @@
        return;
    }

-    AcpiEvGpeDispatch (GpeEventInfo, GpeNumber);
+    (void) AcpiEvGpeDispatch (GpeEventInfo, GpeNumber);
}

#endif /* ACPI_DEBUGGER */
Index: sys/dev/acpi/acpica/Subsystem/dbdisply.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/dbdisply.c,v
retrieving revision 1.12
diff -u -r1.12 dbdisply.c
--- sys/dev/acpi/acpica/Subsystem/dbdisply.c    14 Feb 2004 16:57:24 -0000      1.12
+++ sys/dev/acpi/acpica/Subsystem/dbdisply.c    17 Jun 2004 04:08:39 -0000
@@ -1,7 +1,7 @@
/*******************************************************************************
 *
 * Module Name: dbdisply - debug display commands
- *              xRevision: 100 $
+ *              xRevision: 106 $
 *
 ******************************************************************************/

@@ -680,7 +680,9 @@
    if (ACPI_SUCCESS (Status))
    {
        Info = Buffer.Pointer;
-        AcpiOsPrintf ("HID: %s, ADR: %8.8X%8.8X, Status %8.8X\n",
+        AcpiOsPrintf ("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X    HID: %s, ADR: %8.8X%8.8X, Status %8.8X\n",
+                        Info->HighestDstates[0], Info->HighestDstates[1],
+                        Info->HighestDstates[2], Info->HighestDstates[3],
                        Info->HardwareId.Value,
                        ACPI_FORMAT_UINT64 (Info->Address),
                        Info->CurrentStatus);
@@ -784,8 +786,23 @@
{
    ACPI_GPE_BLOCK_INFO     *GpeBlock;
    ACPI_GPE_XRUPT_INFO     *GpeXruptInfo;
-    UINT32                  i = 0;
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo;
+    ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
+    UINT32                  GpeIndex;
+    UINT32                  Block = 0;
+    UINT32                  i;
+    UINT32                  j;
+    char                    Buffer[80];
+    ACPI_BUFFER             RetBuf;
+    ACPI_STATUS             Status;
+
+
+    RetBuf.Length = sizeof (Buffer);
+    RetBuf.Pointer = Buffer;
+
+    Block = 0;

+    /* Walk the GPE lists */

    GpeXruptInfo = AcpiGbl_GpeXruptListHead;
    while (GpeXruptInfo)
@@ -793,17 +810,126 @@
        GpeBlock = GpeXruptInfo->GpeBlockListHead;
        while (GpeBlock)
        {
-            AcpiOsPrintf ("Block %d - %p\n", i, GpeBlock);
-            AcpiOsPrintf ("    Registers:    %d\n", GpeBlock->RegisterCount);
-            AcpiOsPrintf ("    GPE range:    %d to %d\n", GpeBlock->BlockBaseNumber,
-                            GpeBlock->BlockBaseNumber + (GpeBlock->RegisterCount * 8) -1);
-            AcpiOsPrintf ("    RegisterInfo: %p\n", GpeBlock->RegisterInfo);
+            Status = AcpiGetName (GpeBlock->Node, ACPI_FULL_PATHNAME, &RetBuf);
+            if (ACPI_FAILURE (Status))
+            {
+                AcpiOsPrintf ("Could not convert name to pathname\n");
+            }
+
+            AcpiOsPrintf ("\nBlock %d - Info %p  DeviceNode %p [%s]\n",
+                    Block, GpeBlock, GpeBlock->Node, Buffer);
+            AcpiOsPrintf ("    Registers:    %u (%u GPEs) \n",
+                    GpeBlock->RegisterCount,
+                    ACPI_MUL_8 (GpeBlock->RegisterCount));
+            AcpiOsPrintf ("    GPE range:    0x%X to 0x%X\n",
+                    GpeBlock->BlockBaseNumber,
+                    GpeBlock->BlockBaseNumber +
+                        (GpeBlock->RegisterCount * 8) -1);
+            AcpiOsPrintf ("    RegisterInfo: %p  Status %8.8X%8.8X Enable %8.8X%8.8X\n",
+                    GpeBlock->RegisterInfo,
+                    ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeBlock->RegisterInfo->StatusAddress.Address)),
+                    ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeBlock->RegisterInfo->EnableAddress.Address)));
            AcpiOsPrintf ("    EventInfo:    %p\n", GpeBlock->EventInfo);
-            i++;

+            /* Examine each GPE Register within the block */
+
+            for (i = 0; i < GpeBlock->RegisterCount; i++)
+            {
+                GpeRegisterInfo = &GpeBlock->RegisterInfo[i];
+
+                AcpiOsPrintf (
+                        "    Reg %u:  WakeEnable %2.2X, RunEnable %2.2X  Status %8.8X%8.8X Enable %8.8X%8.8X\n",
+                        i, GpeRegisterInfo->EnableForWake,
+                        GpeRegisterInfo->EnableForRun,
+                        ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeRegisterInfo->StatusAddress.Address)),
+                        ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeRegisterInfo->EnableAddress.Address)));
+
+                /* Now look at the individual GPEs in this byte register */
+
+                for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++)
+                {
+                    GpeIndex = (i * ACPI_GPE_REGISTER_WIDTH) + j;
+                    GpeEventInfo = &GpeBlock->EventInfo[GpeIndex];
+
+                    if (!(GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK))
+                    {
+                        /* This GPE is not used (no method or handler) */
+
+                        continue;
+                    }
+
+                    AcpiOsPrintf (
+                            "        GPE %.3X: %p  Bit %2.2X  Flags %2.2X: ",
+                            GpeBlock->BlockBaseNumber + GpeIndex,
+                            GpeEventInfo, GpeEventInfo->RegisterBit,
+                            GpeEventInfo->Flags);
+
+                    if (GpeEventInfo->Flags & ACPI_GPE_LEVEL_TRIGGERED)
+                    {
+                        AcpiOsPrintf ("Level, ");
+                    }
+                    else
+                    {
+                        AcpiOsPrintf ("Edge,  ");
+                    }
+
+                    switch (GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK)
+                    {
+                    case ACPI_GPE_TYPE_WAKE:
+                        AcpiOsPrintf ("WakeOnly: ");
+                        break;
+                    case ACPI_GPE_TYPE_RUNTIME:
+                        AcpiOsPrintf (" RunOnly: ");
+                        break;
+                    case ACPI_GPE_TYPE_WAKE_RUN:
+                        AcpiOsPrintf (" WakeRun: ");
+                        break;
+                    default:
+                        AcpiOsPrintf (" NotUsed: ");
+                        break;
+                    }
+
+                    if (GpeEventInfo->Flags & ACPI_GPE_WAKE_ENABLED)
+                    {
+                        AcpiOsPrintf ("[Wake 1 ");
+                    }
+                    else
+                    {
+                        AcpiOsPrintf ("[Wake 0 ");
+                    }
+
+                    if (GpeEventInfo->Flags & ACPI_GPE_RUN_ENABLED)
+                    {
+                        AcpiOsPrintf ("Run 1], ");
+                    }
+                    else
+                    {
+                        AcpiOsPrintf ("Run 0], ");
+                    }
+
+                    switch (GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK)
+                    {
+                    case ACPI_GPE_DISPATCH_NOT_USED:
+                        AcpiOsPrintf ("NotUsed");
+                        break;
+                    case ACPI_GPE_DISPATCH_HANDLER:
+                        AcpiOsPrintf ("Handler");
+                        break;
+                    case ACPI_GPE_DISPATCH_METHOD:
+                        AcpiOsPrintf ("Method");
+                        break;
+                    default:
+                        AcpiOsPrintf ("UNKNOWN: %X",
+                            GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK);
+                        break;
+                    }
+
+                    AcpiOsPrintf ("\n");
+                }
+            }
+            Block++;
            GpeBlock = GpeBlock->Next;
        }
-
        GpeXruptInfo = GpeXruptInfo->Next;
    }
}
Index: sys/dev/acpi/acpica/Subsystem/dbexec.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/dbexec.c,v
retrieving revision 1.12
diff -u -r1.12 dbexec.c
--- sys/dev/acpi/acpica/Subsystem/dbexec.c      14 Feb 2004 16:57:24 -0000      1.12
+++ sys/dev/acpi/acpica/Subsystem/dbexec.c      17 Jun 2004 04:08:39 -0000
@@ -1,7 +1,7 @@
/*******************************************************************************
 *
 * Module Name: dbexec - debugger control method execution
- *              xRevision: 57 $
+ *              xRevision: 60 $
 *
 ******************************************************************************/

@@ -477,15 +477,17 @@
#endif

        Status = AcpiDbExecuteMethod (Info, &ReturnObj);
-
        if (ACPI_FAILURE (Status))
        {
            AcpiOsPrintf ("%s During execution of %s at iteration %X\n",
                AcpiFormatException (Status), Info->Pathname, i);
-            break;
+            if (Status == AE_ABORT_METHOD)
+            {
+                break;
+            }
        }

-        if ((i % 1000) == 0)
+        if ((i % 100) == 0)
        {
            AcpiOsPrintf ("%d executions\n", i);
        }
Index: sys/dev/acpi/acpica/Subsystem/dbinput.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/dbinput.c,v
retrieving revision 1.12
diff -u -r1.12 dbinput.c
--- sys/dev/acpi/acpica/Subsystem/dbinput.c     14 Feb 2004 16:57:24 -0000      1.12
+++ sys/dev/acpi/acpica/Subsystem/dbinput.c     17 Jun 2004 04:08:40 -0000
@@ -1,7 +1,7 @@
/*******************************************************************************
 *
 * Module Name: dbinput - user front-end to the AML debugger
- *              xRevision: 98 $
+ *              xRevision: 100 $
 *
 ******************************************************************************/

@@ -178,6 +178,7 @@
    CMD_RESOURCES,
    CMD_RESULTS,
    CMD_SET,
+    CMD_SLEEP,
    CMD_STATS,
    CMD_STOP,
    CMD_TABLES,
@@ -236,6 +237,7 @@
    {"RESOURCES",    1},
    {"RESULTS",      0},
    {"SET",          3},
+    {"SLEEP",        1},
    {"STATS",        0},
    {"STOP",         0},
    {"TABLES",       0},
@@ -624,7 +626,7 @@
        break;

    case CMD_FIND:
-        AcpiDbFindNameInNamespace (AcpiGbl_DbArgs[1]);
+        Status = AcpiDbFindNameInNamespace (AcpiGbl_DbArgs[1]);
        break;

    case CMD_GO:
@@ -733,7 +735,7 @@
        break;

    case CMD_METHODS:
-        AcpiDbDisplayObjects ("METHOD", AcpiGbl_DbArgs[1]);
+        Status = AcpiDbDisplayObjects ("METHOD", AcpiGbl_DbArgs[1]);
        break;

    case CMD_NAMESPACE:
@@ -747,7 +749,7 @@

    case CMD_OBJECT:
        ACPI_STRUPR (AcpiGbl_DbArgs[1]);
-        AcpiDbDisplayObjects (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
+        Status = AcpiDbDisplayObjects (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
        break;

    case CMD_OPEN:
@@ -778,8 +780,12 @@
        AcpiDbSetMethodData (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], AcpiGbl_DbArgs[3]);
        break;

+    case CMD_SLEEP:
+        Status = AcpiDbSleep (AcpiGbl_DbArgs[1]);
+        break;
+
    case CMD_STATS:
-        AcpiDbDisplayStatistics (AcpiGbl_DbArgs[1]);
+        Status = AcpiDbDisplayStatistics (AcpiGbl_DbArgs[1]);
        break;

    case CMD_STOP:
Index: sys/dev/acpi/acpica/Subsystem/dmutils.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/dmutils.c,v
retrieving revision 1.5
diff -u -r1.5 dmutils.c
--- sys/dev/acpi/acpica/Subsystem/dmutils.c     14 Feb 2004 16:57:24 -0000      1.5
+++ sys/dev/acpi/acpica/Subsystem/dmutils.c     17 Jun 2004 04:08:40 -0000
@@ -1,7 +1,7 @@
/*******************************************************************************
 *
 * Module Name: dmutils - AML disassembler utilities
- *              xRevision: 9 $
+ *              xRevision: 10 $
 *
 ******************************************************************************/

@@ -121,6 +121,7 @@
#include "acpi.h"
#include "amlcode.h"
#include "acdisasm.h"
+#include "acnamesp.h"


#ifdef ACPI_DISASSEMBLER
@@ -129,6 +130,9 @@
        ACPI_MODULE_NAME    ("dmutils")


+ACPI_EXTERNAL_LIST              *AcpiGbl_ExternalList = NULL;
+
+
/* Data used in keeping track of fields */
#if 0
const char                      *AcpiGbl_FENames[ACPI_NUM_FIELD_NAMES] =
@@ -292,6 +296,56 @@

/*******************************************************************************
 *
+ * FUNCTION:    AcpiDmAddToExternalList
+ *
+ * PARAMETERS:  Path            - Internal (AML) path to the object
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Insert a new path into the list of Externals which will in
+ *              turn be emitted as an External() declaration in the disassembled
+ *              output.
+ *
+ ******************************************************************************/
+
+void
+AcpiDmAddToExternalList (
+    char                    *Path)
+{
+    char                    *ExternalPath;
+    ACPI_EXTERNAL_LIST      *NewExternal;
+    ACPI_STATUS             Status;
+
+
+    if (!Path)
+    {
+        return;
+    }
+
+    /* Externalize the ACPI path */
+
+    Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, Path,
+                    NULL, &ExternalPath);
+    if (ACPI_SUCCESS (Status))
+    {
+        /* Allocate and init a new External() descriptor */
+
+        NewExternal = ACPI_MEM_CALLOCATE (sizeof (ACPI_EXTERNAL_LIST));
+        NewExternal->Path = ExternalPath;
+
+        /* Link the new descriptor into the global list */
+
+        if (AcpiGbl_ExternalList)
+        {
+            NewExternal->Next = AcpiGbl_ExternalList;
+        }
+        AcpiGbl_ExternalList = NewExternal;
+    }
+}
+
+
+/*******************************************************************************
+ *
 * FUNCTION:    AcpiDmDecodeAttribute
 *
 * PARAMETERS:  Attribute       - Attribute field of AccessAs keyword
Index: sys/dev/acpi/acpica/Subsystem/dmwalk.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/dmwalk.c,v
retrieving revision 1.5
diff -u -r1.5 dmwalk.c
--- sys/dev/acpi/acpica/Subsystem/dmwalk.c      14 Feb 2004 16:57:24 -0000      1.5
+++ sys/dev/acpi/acpica/Subsystem/dmwalk.c      17 Jun 2004 04:08:40 -0000
@@ -1,7 +1,7 @@
/*******************************************************************************
 *
 * Module Name: dmwalk - AML disassembly tree walk
- *              xRevision: 11 $
+ *              xRevision: 13 $
 *
 ******************************************************************************/

@@ -437,6 +437,7 @@
    const ACPI_OPCODE_INFO  *OpInfo;
    UINT32                  Name;
    ACPI_PARSE_OBJECT       *NextOp;
+    ACPI_EXTERNAL_LIST      *NextExternal;


    if (Op->Common.DisasmFlags & ACPI_PARSEOP_IGNORE)
@@ -446,6 +447,7 @@
        return (AE_CTRL_DEPTH);
    }

+    /* Level 0 is at the Definition Block level */

    if (Level == 0)
    {
@@ -456,7 +458,30 @@

        if (Op->Common.AmlOpcode == AML_SCOPE_OP)
        {
+            /* This is the beginning of the Definition Block */
+
            AcpiOsPrintf ("{\n");
+
+            /* Emit all External() declarations here */
+
+            if (AcpiGbl_ExternalList)
+            {
+                AcpiOsPrintf ("    /*\n     * These objects were referenced but not defined in this table\n     */\n");
+
+                /* Walk the list of externals (unresolved references) found during parsing */
+
+                while (AcpiGbl_ExternalList)
+                {
+                    AcpiOsPrintf ("    External (%s)\n", AcpiGbl_ExternalList->Path);
+
+                    NextExternal = AcpiGbl_ExternalList->Next;
+                    ACPI_MEM_FREE (AcpiGbl_ExternalList->Path);
+                    ACPI_MEM_FREE (AcpiGbl_ExternalList);
+                    AcpiGbl_ExternalList = NextExternal;
+                }
+                AcpiOsPrintf ("\n");
+            }
+
            return (AE_OK);
        }
    }
Index: sys/dev/acpi/acpica/Subsystem/dsmethod.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/dsmethod.c,v
retrieving revision 1.11
diff -u -r1.11 dsmethod.c
--- sys/dev/acpi/acpica/Subsystem/dsmethod.c    14 Feb 2004 16:57:24 -0000      1.11
+++ sys/dev/acpi/acpica/Subsystem/dsmethod.c    17 Jun 2004 04:08:40 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Module Name: dsmethod - Parser/Interpreter interface - control method parsing
- *              xRevision: 93 $
+ *              xRevision: 97 $
 *
 *****************************************************************************/

@@ -185,7 +185,7 @@

    /* Create a mutex for the method if there is a concurrency limit */

-    if ((ObjDesc->Method.Concurrency != INFINITE_CONCURRENCY) &&
+    if ((ObjDesc->Method.Concurrency != ACPI_INFINITE_CONCURRENCY) &&
        (!ObjDesc->Method.Semaphore))
    {
        Status = AcpiOsCreateSemaphore (ObjDesc->Method.Concurrency,
@@ -228,8 +228,9 @@
        return_ACPI_STATUS (AE_NO_MEMORY);
    }

-    Status = AcpiDsInitAmlWalk (WalkState, Op, Node, ObjDesc->Method.AmlStart,
-                    ObjDesc->Method.AmlLength, NULL, NULL, 1);
+    Status = AcpiDsInitAmlWalk (WalkState, Op, Node,
+                    ObjDesc->Method.AmlStart,
+                    ObjDesc->Method.AmlLength, NULL, 1);
    if (ACPI_FAILURE (Status))
    {
        AcpiDsDeleteWalkState (WalkState);
@@ -356,8 +357,9 @@
{
    ACPI_STATUS             Status;
    ACPI_NAMESPACE_NODE     *MethodNode;
-    ACPI_OPERAND_OBJECT     *ObjDesc;
    ACPI_WALK_STATE         *NextWalkState;
+    ACPI_OPERAND_OBJECT     *ObjDesc;
+    ACPI_PARAMETER_INFO     Info;
    UINT32                  i;


@@ -392,37 +394,40 @@
        return_ACPI_STATUS (Status);
    }

-    /* 1) Parse: Create a new walk state for the preempting walk */
-
-    NextWalkState = AcpiDsCreateWalkState (ObjDesc->Method.OwningId,
-                                            Op, ObjDesc, NULL);
-    if (!NextWalkState)
+    if (!(ObjDesc->Method.MethodFlags & AML_METHOD_INTERNAL_ONLY))
    {
-        return_ACPI_STATUS (AE_NO_MEMORY);
-    }
+        /* 1) Parse: Create a new walk state for the preempting walk */

-    /* Create and init a Root Node */
+        NextWalkState = AcpiDsCreateWalkState (ObjDesc->Method.OwningId,
+                                                Op, ObjDesc, NULL);
+        if (!NextWalkState)
+        {
+            return_ACPI_STATUS (AE_NO_MEMORY);
+        }

-    Op = AcpiPsCreateScopeOp ();
-    if (!Op)
-    {
-        Status = AE_NO_MEMORY;
-        goto Cleanup;
-    }
+        /* Create and init a Root Node */

-    Status = AcpiDsInitAmlWalk (NextWalkState, Op, MethodNode,
-                    ObjDesc->Method.AmlStart,  ObjDesc->Method.AmlLength,
-                    NULL, NULL, 1);
-    if (ACPI_FAILURE (Status))
-    {
-        AcpiDsDeleteWalkState (NextWalkState);
-        goto Cleanup;
-    }
+        Op = AcpiPsCreateScopeOp ();
+        if (!Op)
+        {
+            Status = AE_NO_MEMORY;
+            goto Cleanup;
+        }
+
+        Status = AcpiDsInitAmlWalk (NextWalkState, Op, MethodNode,
+                        ObjDesc->Method.AmlStart,  ObjDesc->Method.AmlLength,
+                        NULL, 1);
+        if (ACPI_FAILURE (Status))
+        {
+            AcpiDsDeleteWalkState (NextWalkState);
+            goto Cleanup;
+        }

-    /* Begin AML parse */
+        /* Begin AML parse */

-    Status = AcpiPsParseAml (NextWalkState);
-    AcpiPsDeleteParseTree (Op);
+        Status = AcpiPsParseAml (NextWalkState);
+        AcpiPsDeleteParseTree (Op);
+    }

    /* 2) Execute: Create a new state for the preempting walk */

@@ -433,7 +438,6 @@
        Status = AE_NO_MEMORY;
        goto Cleanup;
    }
-
    /*
     * The resolved arguments were put on the previous walk state's operand
     * stack.  Operands on the previous walk state stack always
@@ -442,9 +446,12 @@
     */
    ThisWalkState->Operands [ThisWalkState->NumOperands] = NULL;

+    Info.Parameters = &ThisWalkState->Operands[0];
+    Info.ParameterType = ACPI_PARAM_ARGS;
+
    Status = AcpiDsInitAmlWalk (NextWalkState, NULL, MethodNode,
                    ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength,
-                    &ThisWalkState->Operands[0], NULL, 3);
+                    &Info, 3);
    if (ACPI_FAILURE (Status))
    {
        goto Cleanup;
@@ -467,16 +474,27 @@
    ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
        "Starting nested execution, newstate=%p\n", NextWalkState));

+    if (ObjDesc->Method.MethodFlags & AML_METHOD_INTERNAL_ONLY)
+    {
+        Status = ObjDesc->Method.Implementation (NextWalkState);
+        return_ACPI_STATUS (Status);
+    }
+
    return_ACPI_STATUS (AE_OK);


    /* On error, we must delete the new walk state */

Cleanup:
+    if (NextWalkState && (NextWalkState->MethodDesc))
+    {
+        /* Decrement the thread count on the method parse tree */
+
+       NextWalkState->MethodDesc->Method.ThreadCount--;
+    }
    (void) AcpiDsTerminateControlMethod (NextWalkState);
    AcpiDsDeleteWalkState (NextWalkState);
    return_ACPI_STATUS (Status);
-
}


@@ -607,12 +625,34 @@
        }
    }

-    /* Decrement the thread count on the method parse tree */
+    if (WalkState->MethodDesc->Method.ThreadCount)
+    {
+        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+            "*** Not deleting method namespace, there are still %d threads\n",
+            WalkState->MethodDesc->Method.ThreadCount));
+    }

-    WalkState->MethodDesc->Method.ThreadCount--;
    if (!WalkState->MethodDesc->Method.ThreadCount)
    {
        /*
+         * Support to dynamically change a method from NotSerialized to
+         * Serialized if it appears that the method is written foolishly and
+         * does not support multiple thread execution.  The best example of this
+         * is if such a method creates namespace objects and blocks.  A second
+         * thread will fail with an AE_ALREADY_EXISTS exception
+         *
+         * This code is here because we must wait until the last thread exits
+         * before creating the synchronization semaphore.
+         */
+        if ((WalkState->MethodDesc->Method.Concurrency == 1) &&
+            (!WalkState->MethodDesc->Method.Semaphore))
+        {
+            Status = AcpiOsCreateSemaphore (1,
+                                    1,
+                                    &WalkState->MethodDesc->Method.Semaphore);
+        }
+
+        /*
         * There are no more threads executing this method.  Perform
         * additional cleanup.
         *
Index: sys/dev/acpi/acpica/Subsystem/dsmthdat.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/dsmthdat.c,v
retrieving revision 1.11
diff -u -r1.11 dsmthdat.c
--- sys/dev/acpi/acpica/Subsystem/dsmthdat.c    14 Feb 2004 16:57:24 -0000      1.11
+++ sys/dev/acpi/acpica/Subsystem/dsmthdat.c    17 Jun 2004 04:08:40 -0000
@@ -1,7 +1,7 @@
/*******************************************************************************
 *
 * Module Name: dsmthdat - control method arguments and local variables
- *              xRevision: 77 $
+ *              xRevision: 78 $
 *
 ******************************************************************************/

@@ -763,11 +763,13 @@
                        NewObjDesc, CurrentObjDesc));

                /*
-                 * Store this object to the Node
-                 * (perform the indirect store)
+                 * Store this object to the Node (perform the indirect store)
+                 * NOTE: No implicit conversion is performed, as per the ACPI
+                 * specification rules on storing to Locals/Args.
                 */
                Status = AcpiExStoreObjectToNode (NewObjDesc,
-                            CurrentObjDesc->Reference.Object, WalkState);
+                            CurrentObjDesc->Reference.Object, WalkState,
+                            ACPI_NO_IMPLICIT_CONVERSION);

                /* Remove local reference if we copied the object above */

Index: sys/dev/acpi/acpica/Subsystem/dsopcode.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/dsopcode.c,v
retrieving revision 1.10
diff -u -r1.10 dsopcode.c
--- sys/dev/acpi/acpica/Subsystem/dsopcode.c    14 Feb 2004 16:57:24 -0000      1.10
+++ sys/dev/acpi/acpica/Subsystem/dsopcode.c    17 Jun 2004 04:08:41 -0000
@@ -2,7 +2,7 @@
 *
 * Module Name: dsopcode - Dispatcher Op Region support and handling of
 *                         "control" opcodes
- *              xRevision: 93 $
+ *              xRevision: 95 $
 *
 *****************************************************************************/

@@ -156,7 +156,6 @@
    ACPI_STATUS             Status;
    ACPI_PARSE_OBJECT       *Op;
    ACPI_WALK_STATE         *WalkState;
-    ACPI_PARSE_OBJECT       *Arg;


    ACPI_FUNCTION_TRACE ("DsExecuteArguments");
@@ -184,7 +183,7 @@
    }

    Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart,
-                    AmlLength, NULL, NULL, 1);
+                    AmlLength, NULL, 1);
    if (ACPI_FAILURE (Status))
    {
        AcpiDsDeleteWalkState (WalkState);
@@ -207,9 +206,7 @@

    /* Get and init the Op created above */

-    Arg = Op->Common.Value.Arg;
    Op->Common.Node = Node;
-    Arg->Common.Node = Node;
    AcpiPsDeleteParseTree (Op);

    /* Evaluate the deferred arguments */
@@ -233,7 +230,7 @@
    /* Execute the opcode and arguments */

    Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart,
-                    AmlLength, NULL, NULL, 3);
+                    AmlLength, NULL, 3);
    if (ACPI_FAILURE (Status))
    {
        AcpiDsDeleteWalkState (WalkState);
Index: sys/dev/acpi/acpica/Subsystem/dswload.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/dswload.c,v
retrieving revision 1.10
diff -u -r1.10 dswload.c
--- sys/dev/acpi/acpica/Subsystem/dswload.c     14 Feb 2004 16:57:24 -0000      1.10
+++ sys/dev/acpi/acpica/Subsystem/dswload.c     17 Jun 2004 04:08:41 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Module Name: dswload - Dispatcher namespace load callbacks
- *              xRevision: 86 $
+ *              xRevision: 87 $
 *
 *****************************************************************************/

@@ -127,6 +127,9 @@
#include "acnamesp.h"
#include "acevents.h"

+#ifdef _ACPI_ASL_COMPILER
+#include "acdisasm.h"
+#endif

#define _COMPONENT          ACPI_DISPATCHER
        ACPI_MODULE_NAME    ("dswload")
@@ -264,7 +267,19 @@
                        ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node));
        if (ACPI_FAILURE (Status))
        {
+#ifdef _ACPI_ASL_COMPILER
+            if (Status == AE_NOT_FOUND)
+            {
+                AcpiDmAddToExternalList (Path);
+                Status = AE_OK;
+            }
+            else
+            {
+                ACPI_REPORT_NSERROR (Path, Status);
+            }
+#else
            ACPI_REPORT_NSERROR (Path, Status);
+#endif
            return (Status);
        }

@@ -640,7 +655,18 @@
                        ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node));
        if (ACPI_FAILURE (Status))
        {
+#ifdef _ACPI_ASL_COMPILER
+            if (Status == AE_NOT_FOUND)
+            {
+                Status = AE_OK;
+            }
+            else
+            {
+                ACPI_REPORT_NSERROR (BufferPtr, Status);
+            }
+#else
            ACPI_REPORT_NSERROR (BufferPtr, Status);
+#endif
            return_ACPI_STATUS (Status);
        }
        /*
Index: sys/dev/acpi/acpica/Subsystem/dswstate.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/dswstate.c,v
retrieving revision 1.10
diff -u -r1.10 dswstate.c
--- sys/dev/acpi/acpica/Subsystem/dswstate.c    14 Feb 2004 16:57:24 -0000      1.10
+++ sys/dev/acpi/acpica/Subsystem/dswstate.c    17 Jun 2004 04:08:42 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Module Name: dswstate - Dispatcher parse tree walk management routines
- *              xRevision: 78 $
+ *              xRevision: 80 $
 *
 *****************************************************************************/

@@ -1020,8 +1020,7 @@
    ACPI_NAMESPACE_NODE     *MethodNode,
    UINT8                   *AmlStart,
    UINT32                  AmlLength,
-    ACPI_OPERAND_OBJECT     **Params,
-    ACPI_OPERAND_OBJECT     **ReturnObjDesc,
+    ACPI_PARAMETER_INFO     *Info,
    UINT32                  PassNumber)
{
    ACPI_STATUS             Status;
@@ -1040,8 +1039,20 @@
    /* The NextOp of the NextWalk will be the beginning of the method */

    WalkState->NextOp               = NULL;
-    WalkState->Params               = Params;
-    WalkState->CallerReturnDesc     = ReturnObjDesc;
+
+    if (Info)
+    {
+        if (Info->ParameterType == ACPI_PARAM_GPE)
+        {
+            WalkState->GpeEventInfo = ACPI_CAST_PTR (ACPI_GPE_EVENT_INFO,
+                                            Info->Parameters);
+        }
+        else
+        {
+            WalkState->Params               = Info->Parameters;
+            WalkState->CallerReturnDesc     = &Info->ReturnObject;
+        }
+    }

    Status = AcpiPsInitScope (&WalkState->ParserState, Op);
    if (ACPI_FAILURE (Status))
@@ -1066,7 +1077,7 @@

        /* Init the method arguments */

-        Status = AcpiDsMethodDataInitArgs (Params, ACPI_METHOD_NUM_ARGS, WalkState);
+        Status = AcpiDsMethodDataInitArgs (WalkState->Params, ACPI_METHOD_NUM_ARGS, WalkState);
        if (ACPI_FAILURE (Status))
        {
            return_ACPI_STATUS (Status);
Index: sys/dev/acpi/acpica/Subsystem/evevent.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/evevent.c,v
retrieving revision 1.10
diff -u -r1.10 evevent.c
--- sys/dev/acpi/acpica/Subsystem/evevent.c     14 Feb 2004 16:57:24 -0000      1.10
+++ sys/dev/acpi/acpica/Subsystem/evevent.c     17 Jun 2004 04:08:42 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Module Name: evevent - Fixed Event handling and dispatch
- *              xRevision: 112 $
+ *              xRevision: 113 $
 *
 *****************************************************************************/

@@ -126,7 +126,7 @@

/*******************************************************************************
 *
- * FUNCTION:    AcpiEvInitialize
+ * FUNCTION:    AcpiEvInitializeEvents
 *
 * PARAMETERS:  None
 *
@@ -137,13 +137,13 @@
 ******************************************************************************/

ACPI_STATUS
-AcpiEvInitialize (
+AcpiEvInitializeEvents (
    void)
{
    ACPI_STATUS             Status;


-    ACPI_FUNCTION_TRACE ("EvInitialize");
+    ACPI_FUNCTION_TRACE ("EvInitializeEvents");


    /* Make sure we have ACPI tables */
@@ -183,7 +183,7 @@

/*******************************************************************************
 *
- * FUNCTION:    AcpiEvHandlerInitialize
+ * FUNCTION:    AcpiEvInstallXruptHandlers
 *
 * PARAMETERS:  None
 *
@@ -194,13 +194,13 @@
 ******************************************************************************/

ACPI_STATUS
-AcpiEvHandlerInitialize (
+AcpiEvInstallXruptHandlers (
    void)
{
    ACPI_STATUS             Status;


-    ACPI_FUNCTION_TRACE ("EvHandlerInitialize");
+    ACPI_FUNCTION_TRACE ("EvInstallXruptHandlers");


    /* Install the SCI handler */
Index: sys/dev/acpi/acpica/Subsystem/evgpe.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/evgpe.c,v
retrieving revision 1.7
diff -u -r1.7 evgpe.c
--- sys/dev/acpi/acpica/Subsystem/evgpe.c       14 Feb 2004 16:57:24 -0000      1.7
+++ sys/dev/acpi/acpica/Subsystem/evgpe.c       17 Jun 2004 04:08:42 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Module Name: evgpe - General Purpose Event handling and dispatch
- *              xRevision: 33 $
+ *              xRevision: 42 $
 *
 *****************************************************************************/

@@ -127,6 +127,260 @@

/*******************************************************************************
 *
+ * FUNCTION:    AcpiEvSetGpeType
+ *
+ * PARAMETERS:  GpeEventInfo            - GPE to set
+ *              Type                    - New type
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Sets the new type for the GPE (wake, run, or wake/run)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvSetGpeType (
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo,
+    UINT8                   Type)
+{
+    ACPI_STATUS             Status;
+
+
+    ACPI_FUNCTION_TRACE ("EvSetGpeType");
+
+
+    /* Validate type and update register enable masks */
+
+    switch (Type)
+    {
+    case ACPI_GPE_TYPE_WAKE:
+    case ACPI_GPE_TYPE_RUNTIME:
+    case ACPI_GPE_TYPE_WAKE_RUN:
+        break;
+
+    default:
+        return_ACPI_STATUS (AE_BAD_PARAMETER);
+    }
+
+    /* Disable the GPE if currently enabled */
+
+    Status = AcpiEvDisableGpe (GpeEventInfo);
+
+    /* Type was validated above */
+
+    GpeEventInfo->Flags &= ~ACPI_GPE_TYPE_MASK; /* Clear type bits */
+    GpeEventInfo->Flags |= Type;                /* Insert type */
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvUpdateGpeEnableMasks
+ *
+ * PARAMETERS:  GpeEventInfo            - GPE to update
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Updates GPE register enable masks based on the GPE type
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvUpdateGpeEnableMasks (
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo,
+    UINT8                   Type)
+{
+    ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
+    UINT8                   RegisterBit;
+
+
+    ACPI_FUNCTION_TRACE ("EvUpdateGpeEnableMasks");
+
+
+    GpeRegisterInfo = GpeEventInfo->RegisterInfo;
+    if (!GpeRegisterInfo)
+    {
+        return_ACPI_STATUS (AE_NOT_EXIST);
+    }
+    RegisterBit = GpeEventInfo->RegisterBit;
+
+    /* 1) Disable case.  Simply clear all enable bits */
+
+    if (Type == ACPI_GPE_DISABLE)
+    {
+        ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForWake, RegisterBit);
+        ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForRun, RegisterBit);
+        return_ACPI_STATUS (AE_OK);
+    }
+
+    /* 2) Enable case.  Set/Clear the appropriate enable bits */
+
+    switch (GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK)
+    {
+    case ACPI_GPE_TYPE_WAKE:
+        ACPI_SET_BIT   (GpeRegisterInfo->EnableForWake, RegisterBit);
+        ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForRun, RegisterBit);
+        break;
+
+    case ACPI_GPE_TYPE_RUNTIME:
+        ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForWake, RegisterBit);
+        ACPI_SET_BIT   (GpeRegisterInfo->EnableForRun, RegisterBit);
+        break;
+
+    case ACPI_GPE_TYPE_WAKE_RUN:
+        ACPI_SET_BIT   (GpeRegisterInfo->EnableForWake, RegisterBit);
+        ACPI_SET_BIT   (GpeRegisterInfo->EnableForRun, RegisterBit);
+        break;
+
+    default:
+        return_ACPI_STATUS (AE_BAD_PARAMETER);
+    }
+
+    return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvEnableGpe
+ *
+ * PARAMETERS:  GpeEventInfo            - GPE to enable
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Enable a GPE based on the GPE type
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvEnableGpe (
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo,
+    BOOLEAN                 WriteToHardware)
+{
+    ACPI_STATUS             Status;
+
+
+    ACPI_FUNCTION_TRACE ("EvEnableGpe");
+
+
+    /* Make sure HW enable masks are updated */
+
+    Status = AcpiEvUpdateGpeEnableMasks (GpeEventInfo, ACPI_GPE_ENABLE);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    /* Mark wake-enabled or HW enable, or both */
+
+    switch (GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK)
+    {
+    case ACPI_GPE_TYPE_WAKE:
+
+        ACPI_SET_BIT (GpeEventInfo->Flags, ACPI_GPE_WAKE_ENABLED);
+        break;
+
+    case ACPI_GPE_TYPE_WAKE_RUN:
+
+        ACPI_SET_BIT (GpeEventInfo->Flags, ACPI_GPE_WAKE_ENABLED);
+
+        /*lint -fallthrough */
+
+    case ACPI_GPE_TYPE_RUNTIME:
+
+        ACPI_SET_BIT (GpeEventInfo->Flags, ACPI_GPE_RUN_ENABLED);
+
+        if (WriteToHardware)
+        {
+            /* Clear the GPE (of stale events), then enable it */
+
+            Status = AcpiHwClearGpe (GpeEventInfo);
+            if (ACPI_FAILURE (Status))
+            {
+                return_ACPI_STATUS (Status);
+            }
+
+            /* Enable the requested runtime GPE */
+
+            Status = AcpiHwWriteGpeEnableReg (GpeEventInfo);
+        }
+        break;
+
+    default:
+        return_ACPI_STATUS (AE_BAD_PARAMETER);
+    }
+
+    return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvDisableGpe
+ *
+ * PARAMETERS:  GpeEventInfo            - GPE to disable
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Disable a GPE based on the GPE type
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvDisableGpe (
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo)
+{
+    ACPI_STATUS             Status;
+
+
+    ACPI_FUNCTION_TRACE ("EvDisableGpe");
+
+
+    if (!(GpeEventInfo->Flags & ACPI_GPE_ENABLE_MASK))
+    {
+        return_ACPI_STATUS (AE_OK);
+    }
+
+    /* Make sure HW enable masks are updated */
+
+    Status = AcpiEvUpdateGpeEnableMasks (GpeEventInfo, ACPI_GPE_DISABLE);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    /* Mark wake-disabled or HW disable, or both */
+
+    switch (GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK)
+    {
+    case ACPI_GPE_TYPE_WAKE:
+        ACPI_CLEAR_BIT (GpeEventInfo->Flags, ACPI_GPE_WAKE_ENABLED);
+        break;
+
+    case ACPI_GPE_TYPE_WAKE_RUN:
+        ACPI_CLEAR_BIT (GpeEventInfo->Flags, ACPI_GPE_WAKE_ENABLED);
+
+        /*lint -fallthrough */
+
+    case ACPI_GPE_TYPE_RUNTIME:
+
+        /* Disable the requested runtime GPE */
+
+        ACPI_CLEAR_BIT (GpeEventInfo->Flags, ACPI_GPE_RUN_ENABLED);
+        Status = AcpiHwWriteGpeEnableReg (GpeEventInfo);
+        break;
+
+    default:
+        return_ACPI_STATUS (AE_BAD_PARAMETER);
+    }
+
+    return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
 * FUNCTION:    AcpiEvGetGpeEventInfo
 *
 * PARAMETERS:  GpeDevice           - Device node.  NULL for GPE0/GPE1
@@ -179,9 +433,8 @@
        return (NULL);
    }

-    /*
-     * A Non-null GpeDevice means this is a GPE Block Device.
-     */
+    /* A Non-NULL GpeDevice means this is a GPE Block Device */
+
    ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) GpeDevice);
    if (!ObjDesc ||
        !ObjDesc->Device.GpeBlock)
@@ -222,15 +475,22 @@
    UINT32                  IntStatus = ACPI_INTERRUPT_NOT_HANDLED;
    UINT8                   EnabledStatusByte;
    ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
-    UINT32                  InValue;
+    UINT32                  StatusReg;
+    UINT32                  EnableReg;
    ACPI_STATUS             Status;
    ACPI_GPE_BLOCK_INFO     *GpeBlock;
-    UINT32                  i;
-    UINT32                  j;
+    ACPI_NATIVE_UINT        i;
+    ACPI_NATIVE_UINT        j;


    ACPI_FUNCTION_NAME ("EvGpeDetect");

+    /* Check for the case where there are no GPEs */
+
+    if (!GpeXruptList)
+    {
+        return (IntStatus);
+    }

    /* Examine all GPE blocks attached to this interrupt level */

@@ -251,9 +511,8 @@

            /* Read the Status Register */

-            Status = AcpiHwLowLevelRead (ACPI_GPE_REGISTER_WIDTH, &InValue,
+            Status = AcpiHwLowLevelRead (ACPI_GPE_REGISTER_WIDTH, &StatusReg,
                        &GpeRegisterInfo->StatusAddress);
-            GpeRegisterInfo->Status = (UINT8) InValue;
            if (ACPI_FAILURE (Status))
            {
                goto UnlockAndExit;
@@ -261,9 +520,8 @@

            /* Read the Enable Register */

-            Status = AcpiHwLowLevelRead (ACPI_GPE_REGISTER_WIDTH, &InValue,
+            Status = AcpiHwLowLevelRead (ACPI_GPE_REGISTER_WIDTH, &EnableReg,
                        &GpeRegisterInfo->EnableAddress);
-            GpeRegisterInfo->Enable = (UINT8) InValue;
            if (ACPI_FAILURE (Status))
            {
                goto UnlockAndExit;
@@ -271,15 +529,16 @@

            ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS,
                "GPE pair: Status %8.8X%8.8X = %02X, Enable %8.8X%8.8X = %02X\n",
-                ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeRegisterInfo->StatusAddress.Address)),
-                GpeRegisterInfo->Status,
-                ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeRegisterInfo->EnableAddress.Address)),
-                GpeRegisterInfo->Enable));
+                ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (
+                    GpeRegisterInfo->StatusAddress.Address)),
+                    StatusReg,
+                ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (
+                    GpeRegisterInfo->EnableAddress.Address)),
+                    EnableReg));

            /* First check if there is anything active at all in this register */

-            EnabledStatusByte = (UINT8) (GpeRegisterInfo->Status &
-                                         GpeRegisterInfo->Enable);
+            EnabledStatusByte = (UINT8) (StatusReg & EnableReg);
            if (!EnabledStatusByte)
            {
                /* No active GPEs in this register, move on */
@@ -301,7 +560,7 @@
                     */
                    IntStatus |= AcpiEvGpeDispatch (
                                    &GpeBlock->EventInfo[(i * ACPI_GPE_REGISTER_WIDTH) + j],
-                                    j + GpeRegisterInfo->BaseGpeNumber);
+                                    (UINT32) j + GpeRegisterInfo->BaseGpeNumber);
                }
            }
        }
@@ -340,6 +599,7 @@
    UINT32                  GpeNumber = 0;
    ACPI_STATUS             Status;
    ACPI_GPE_EVENT_INFO     LocalGpeEventInfo;
+    ACPI_PARAMETER_INFO     Info;


    ACPI_FUNCTION_TRACE ("EvAsynchExecuteGpeMethod");
@@ -359,6 +619,10 @@
        return_VOID;
    }

+    /* Set the GPE flags for return to enabled state */
+
+    (void) AcpiEvEnableGpe (GpeEventInfo, FALSE);
+
    /*
     * Take a snapshot of the GPE info for this level - we copy the
     * info to prevent a race condition with RemoveHandler/RemoveBlock.
@@ -371,26 +635,36 @@
        return_VOID;
    }

-    if (LocalGpeEventInfo.MethodNode)
+    /*
+     * Must check for control method type dispatch one more
+     * time to avoid race with EvGpeInstallHandler
+     */
+    if ((LocalGpeEventInfo.Flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_METHOD)
    {
        /*
-         * Invoke the GPE Method (_Lxx, _Exx):
-         * (Evaluate the _Lxx/_Exx control method that corresponds to this GPE.)
+         * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx
+         * control method that corresponds to this GPE
         */
-        Status = AcpiNsEvaluateByHandle (LocalGpeEventInfo.MethodNode, NULL, NULL);
+        Info.Node = LocalGpeEventInfo.Dispatch.MethodNode;
+        Info.Parameters = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT *, GpeEventInfo);
+        Info.ParameterType = ACPI_PARAM_GPE;
+
+        Status = AcpiNsEvaluateByHandle (&Info);
        if (ACPI_FAILURE (Status))
        {
-            ACPI_REPORT_ERROR (("%s while evaluating method [%4.4s] for GPE[%2X]\n",
+            ACPI_REPORT_ERROR ((
+                "%s while evaluating method [%4.4s] for GPE[%2X]\n",
                AcpiFormatException (Status),
-                AcpiUtGetNodeName (LocalGpeEventInfo.MethodNode), GpeNumber));
+                AcpiUtGetNodeName (LocalGpeEventInfo.Dispatch.MethodNode),
+                GpeNumber));
        }
    }

-    if (LocalGpeEventInfo.Flags & ACPI_EVENT_LEVEL_TRIGGERED)
+    if ((LocalGpeEventInfo.Flags & ACPI_GPE_XRUPT_TYPE_MASK) == ACPI_GPE_LEVEL_TRIGGERED)
    {
        /*
-         * GPE is level-triggered, we clear the GPE status bit after handling
-         * the event.
+         * GPE is level-triggered, we clear the GPE status bit after
+         * handling the event.
         */
        Status = AcpiHwClearGpe (&LocalGpeEventInfo);
        if (ACPI_FAILURE (Status))
@@ -401,7 +675,7 @@

    /* Enable this GPE */

-    (void) AcpiHwEnableGpe (&LocalGpeEventInfo);
+    (void) AcpiHwWriteGpeEnableReg (&LocalGpeEventInfo);
    return_VOID;
}

@@ -437,7 +711,7 @@
     * If edge-triggered, clear the GPE status bit now.  Note that
     * level-triggered events are cleared after the GPE is serviced.
     */
-    if (GpeEventInfo->Flags & ACPI_EVENT_EDGE_TRIGGERED)
+    if ((GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK) == ACPI_GPE_EDGE_TRIGGERED)
    {
        Status = AcpiHwClearGpe (GpeEventInfo);
        if (ACPI_FAILURE (Status))
@@ -448,6 +722,17 @@
        }
    }

+    /* Save current system state */
+
+    if (AcpiGbl_SystemAwakeAndRunning)
+    {
+        ACPI_SET_BIT (GpeEventInfo->Flags, ACPI_GPE_SYSTEM_RUNNING);
+    }
+    else
+    {
+        ACPI_CLEAR_BIT (GpeEventInfo->Flags, ACPI_GPE_SYSTEM_RUNNING);
+    }
+
    /*
     * Dispatch the GPE to either an installed handler, or the control
     * method associated with this GPE (_Lxx or _Exx).
@@ -455,15 +740,20 @@
     * If there is neither a handler nor a method, we disable the level to
     * prevent further events from coming in here.
     */
-    if (GpeEventInfo->Handler)
+    switch (GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK)
    {
-        /* Invoke the installed handler (at interrupt level) */
+    case ACPI_GPE_DISPATCH_HANDLER:

-        GpeEventInfo->Handler (GpeEventInfo->Context);
+        /*
+         * Invoke the installed handler (at interrupt level)
+         * Ignore return status for now.  TBD: leave GPE disabled on error?
+         */
+        (void) GpeEventInfo->Dispatch.Handler->Address (
+                        GpeEventInfo->Dispatch.Handler->Context);

        /* It is now safe to clear level-triggered events. */

-        if (GpeEventInfo->Flags & ACPI_EVENT_LEVEL_TRIGGERED)
+        if ((GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK) == ACPI_GPE_LEVEL_TRIGGERED)
        {
            Status = AcpiHwClearGpe (GpeEventInfo);
            if (ACPI_FAILURE (Status))
@@ -474,14 +764,15 @@
                return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
            }
        }
-    }
-    else if (GpeEventInfo->MethodNode)
-    {
+        break;
+
+    case ACPI_GPE_DISPATCH_METHOD:
+
        /*
         * Disable GPE, so it doesn't keep firing before the method has a
         * chance to run.
         */
-        Status = AcpiHwDisableGpe (GpeEventInfo);
+        Status = AcpiEvDisableGpe (GpeEventInfo);
        if (ACPI_FAILURE (Status))
        {
            ACPI_REPORT_ERROR ((
@@ -502,9 +793,10 @@
                "AcpiEvGpeDispatch: Unable to queue handler for GPE[%2X], event is disabled\n",
                GpeNumber));
        }
-    }
-    else
-    {
+        break;
+
+    default:
+
        /* No handler or method to run! */

        ACPI_REPORT_ERROR ((
@@ -515,7 +807,7 @@
         * Disable the GPE.  The GPE will remain disabled until the ACPI
         * Core Subsystem is restarted, or a handler is installed.
         */
-        Status = AcpiHwDisableGpe (GpeEventInfo);
+        Status = AcpiEvDisableGpe (GpeEventInfo);
        if (ACPI_FAILURE (Status))
        {
            ACPI_REPORT_ERROR ((
@@ -523,8 +815,62 @@
                GpeNumber));
            return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
        }
+        break;
    }

    return_VALUE (ACPI_INTERRUPT_HANDLED);
}

+
+#ifdef ACPI_GPE_NOTIFY_CHECK
+
+/*******************************************************************************
+ * NOT USED, PROTOTYPE ONLY AND WILL PROBABLY BE REMOVED
+ *
+ * FUNCTION:    AcpiEvCheckForWakeOnlyGpe
+ *
+ * PARAMETERS:  GpeEventInfo    - info for this GPE
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Determine if a a GPE is "wake-only".
+ *
+ *              Called from Notify() code in interpreter when a "DeviceWake"
+ *              Notify comes in.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvCheckForWakeOnlyGpe (
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo)
+{
+    ACPI_STATUS             Status;
+
+
+    ACPI_FUNCTION_TRACE ("EvCheckForWakeOnlyGpe");
+
+
+    if ((GpeEventInfo)   &&  /* Only >0 for _Lxx/_Exx */
+       ((GpeEventInfo->Flags & ACPI_GPE_SYSTEM_MASK) == ACPI_GPE_SYSTEM_RUNNING)) /* System state at GPE time */
+    {
+        /* This must be a wake-only GPE, disable it */
+
+        Status = AcpiEvDisableGpe (GpeEventInfo);
+
+        /* Set GPE to wake-only.  Do not change wake disabled/enabled status */
+
+        AcpiEvSetGpeType (GpeEventInfo, ACPI_GPE_TYPE_WAKE);
+
+        ACPI_REPORT_INFO (("GPE %p was updated from wake/run to wake-only\n",
+                GpeEventInfo));
+
+        /* This was a wake-only GPE */
+
+        return_ACPI_STATUS (AE_WAKE_ONLY_GPE);
+    }
+
+    return_ACPI_STATUS (AE_OK);
+}
+#endif
+
+
Index: sys/dev/acpi/acpica/Subsystem/evgpeblk.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/evgpeblk.c,v
retrieving revision 1.7
diff -u -r1.7 evgpeblk.c
--- sys/dev/acpi/acpica/Subsystem/evgpeblk.c    14 Feb 2004 16:57:24 -0000      1.7
+++ sys/dev/acpi/acpica/Subsystem/evgpeblk.c    17 Jun 2004 04:08:43 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Module Name: evgpeblk - GPE block creation and initialization.
- *              xRevision: 27 $
+ *              xRevision: 36 $
 *
 *****************************************************************************/

@@ -129,7 +129,7 @@
 *
 * FUNCTION:    AcpiEvValidGpeEvent
 *
- * PARAMETERS:  GpeEventInfo - Info for this GPE
+ * PARAMETERS:  GpeEventInfo                - Info for this GPE
 *
 * RETURN:      TRUE if the GpeEvent is valid
 *
@@ -236,6 +236,56 @@
}


+/******************************************************************************
+ *
+ * FUNCTION:    AcpiEvDeleteGpeHandlers
+ *
+ * PARAMETERS:  GpeXruptInfo        - GPE Interrupt info
+ *              GpeBlock            - Gpe Block info
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Delete all Handler objects found in the GPE data structs.
+ *              Used only prior to termination.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvDeleteGpeHandlers (
+    ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
+    ACPI_GPE_BLOCK_INFO     *GpeBlock)
+{
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo;
+    ACPI_NATIVE_UINT        i;
+    ACPI_NATIVE_UINT        j;
+
+
+    ACPI_FUNCTION_TRACE ("EvDeleteGpeHandlers");
+
+
+    /* Examine each GPE Register within the block */
+
+    for (i = 0; i < GpeBlock->RegisterCount; i++)
+    {
+        /* Now look at the individual GPEs in this byte register */
+
+        for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++)
+        {
+            GpeEventInfo = &GpeBlock->EventInfo[(i * ACPI_GPE_REGISTER_WIDTH) + j];
+
+            if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_HANDLER)
+            {
+                ACPI_MEM_FREE (GpeEventInfo->Dispatch.Handler);
+                GpeEventInfo->Dispatch.Handler = NULL;
+                GpeEventInfo->Flags &= ~ACPI_GPE_DISPATCH_MASK;
+            }
+        }
+    }
+
+    return_ACPI_STATUS (AE_OK);
+}
+
+
/*******************************************************************************
 *
 * FUNCTION:    AcpiEvSaveMethodInfo
@@ -250,11 +300,11 @@
 *              information for quick lookup during GPE dispatch
 *
 *              The name of each GPE control method is of the form:
- *                  "_Lnn" or "_Enn"
- *                  Where:
- *                      L      - means that the GPE is level triggered
- *                      E      - means that the GPE is edge triggered
- *                      nn     - is the GPE number [in HEX]
+ *              "_Lxx" or "_Exx"
+ *              Where:
+ *                  L      - means that the GPE is level triggered
+ *                  E      - means that the GPE is edge triggered
+ *                  xx     - is the GPE number [in HEX]
 *
 ******************************************************************************/

@@ -276,31 +326,37 @@
    ACPI_FUNCTION_TRACE ("EvSaveMethodInfo");


-    /* Extract the name from the object and convert to a string */
-
+    /*
+     * _Lxx and _Exx GPE method support
+     *
+     * 1) Extract the name from the object and convert to a string
+     */
    ACPI_MOVE_32_TO_32 (Name,
                        &((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Integer);
    Name[ACPI_NAME_SIZE] = 0;

    /*
-     * Edge/Level determination is based on the 2nd character
-     * of the method name
+     * 2) Edge/Level determination is based on the 2nd character
+     *    of the method name
+     *
+     * NOTE: Default GPE type is RUNTIME.  May be changed later to WAKE
+     * if a _PRW object is found that points to this GPE.
     */
    switch (Name[1])
    {
    case 'L':
-        Type = ACPI_EVENT_LEVEL_TRIGGERED;
+        Type = ACPI_GPE_LEVEL_TRIGGERED;
        break;

    case 'E':
-        Type = ACPI_EVENT_EDGE_TRIGGERED;
+        Type = ACPI_GPE_EDGE_TRIGGERED;
        break;

    default:
        /* Unknown method type, just ignore it! */

        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-            "Unknown GPE method type: %s (name not of form _Lnn or _Enn)\n",
+            "Unknown GPE method type: %s (name not of form _Lxx or _Exx)\n",
            Name));
        return_ACPI_STATUS (AE_OK);
    }
@@ -313,7 +369,7 @@
        /* Conversion failed; invalid method, just ignore it */

        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-            "Could not extract GPE number from name: %s (name is not of form _Lnn or _Enn)\n",
+            "Could not extract GPE number from name: %s (name is not of form _Lxx or _Exx)\n",
            Name));
        return_ACPI_STATUS (AE_OK);
    }
@@ -333,24 +389,151 @@

    /*
     * Now we can add this information to the GpeEventInfo block
-     * for use during dispatch of this GPE.
+     * for use during dispatch of this GPE.  Default type is RUNTIME, although
+     * this may change when the _PRW methods are executed later.
     */
    GpeEventInfo = &GpeBlock->EventInfo[GpeNumber - GpeBlock->BlockBaseNumber];

-    GpeEventInfo->Flags      = Type;
-    GpeEventInfo->MethodNode = (ACPI_NAMESPACE_NODE *) ObjHandle;
+    GpeEventInfo->Flags = (UINT8) (Type | ACPI_GPE_DISPATCH_METHOD |
+                                          ACPI_GPE_TYPE_RUNTIME);

-    /* Enable the GPE (SCIs should be disabled at this point) */
+    GpeEventInfo->Dispatch.MethodNode = (ACPI_NAMESPACE_NODE *) ObjHandle;

-    Status = AcpiHwEnableGpe (GpeEventInfo);
-    if (ACPI_FAILURE (Status))
-    {
-        return_ACPI_STATUS (Status);
-    }
+    /* Update enable mask, but don't enable the HW GPE as of yet */
+
+    Status = AcpiEvEnableGpe (GpeEventInfo, FALSE);

    ACPI_DEBUG_PRINT ((ACPI_DB_LOAD,
        "Registered GPE method %s as GPE number 0x%.2X\n",
        Name, GpeNumber));
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvMatchPrwAndGpe
+ *
+ * PARAMETERS:  Callback from WalkNamespace
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Called from AcpiWalkNamespace.  Expects each object to be a
+ *              Device.  Run the _PRW method.  If present, extract the GPE
+ *              number and mark the GPE as a WAKE GPE.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiEvMatchPrwAndGpe (
+    ACPI_HANDLE             ObjHandle,
+    UINT32                  Level,
+    void                    *Info,
+    void                    **ReturnValue)
+{
+    ACPI_GPE_WALK_INFO      *GpeInfo = (void *) Info;
+    ACPI_NAMESPACE_NODE     *GpeDevice;
+    ACPI_GPE_BLOCK_INFO     *GpeBlock;
+    ACPI_NAMESPACE_NODE     *TargetGpeDevice;
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo;
+    ACPI_OPERAND_OBJECT     *PkgDesc;
+    ACPI_OPERAND_OBJECT     *ObjDesc;
+    UINT32                  GpeNumber;
+    ACPI_STATUS             Status;
+
+
+    ACPI_FUNCTION_TRACE ("EvMatchPrwAndGpe");
+
+
+    /* Check for a _PRW method under this device */
+
+    Status = AcpiUtEvaluateObject (ObjHandle, METHOD_NAME__PRW,
+                ACPI_BTYPE_PACKAGE, &PkgDesc);
+    if (ACPI_FAILURE (Status))
+    {
+        /* Ignore all errors from _PRW, we don't want to abort the subsystem */
+
+        return_ACPI_STATUS (AE_OK);
+    }
+
+    /* The returned _PRW package must have at least two elements */
+
+    if (PkgDesc->Package.Count < 2)
+    {
+        goto Cleanup;
+    }
+
+    /* Extract pointers from the input context */
+
+    GpeDevice = GpeInfo->GpeDevice;
+    GpeBlock = GpeInfo->GpeBlock;
+
+    /*
+     * The _PRW object must return a package, we are only interested
+     * in the first element
+     */
+    ObjDesc = PkgDesc->Package.Elements[0];
+
+    if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER)
+    {
+        /* Use FADT-defined GPE device (from definition of _PRW) */
+
+        TargetGpeDevice = AcpiGbl_FadtGpeDevice;
+
+        /* Integer is the GPE number in the FADT described GPE blocks */
+
+        GpeNumber = (UINT32) ObjDesc->Integer.Value;
+    }
+    else if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_PACKAGE)
+    {
+        /* Package contains a GPE reference and GPE number within a GPE block */
+
+        if ((ObjDesc->Package.Count < 2) ||
+            (ACPI_GET_OBJECT_TYPE (ObjDesc->Package.Elements[0]) != ACPI_TYPE_LOCAL_REFERENCE) ||
+            (ACPI_GET_OBJECT_TYPE (ObjDesc->Package.Elements[1]) != ACPI_TYPE_INTEGER))
+        {
+            goto Cleanup;
+        }
+
+        /* Get GPE block reference and decode */
+
+        TargetGpeDevice = ObjDesc->Package.Elements[0]->Reference.Node;
+        GpeNumber = (UINT32) ObjDesc->Package.Elements[1]->Integer.Value;
+    }
+    else
+    {
+        /* Unknown type, just ignore it */
+
+        goto Cleanup;
+    }
+
+    /*
+     * Is this GPE within this block?
+     *
+     * TRUE iff these conditions are true:
+     *     1) The GPE devices match.
+     *     2) The GPE index(number) is within the range of the Gpe Block
+     *          associated with the GPE device.
+     */
+    if ((GpeDevice == TargetGpeDevice) &&
+        (GpeNumber >= GpeBlock->BlockBaseNumber) &&
+        (GpeNumber < GpeBlock->BlockBaseNumber + (GpeBlock->RegisterCount * 8)))
+    {
+        GpeEventInfo = &GpeBlock->EventInfo[GpeNumber - GpeBlock->BlockBaseNumber];
+
+        /* Mark GPE for WAKE-ONLY but WAKE_DISABLED */
+
+        GpeEventInfo->Flags &= ~(ACPI_GPE_WAKE_ENABLED | ACPI_GPE_RUN_ENABLED);
+        Status = AcpiEvSetGpeType (GpeEventInfo, ACPI_GPE_TYPE_WAKE);
+        if (ACPI_FAILURE (Status))
+        {
+            goto Cleanup;
+        }
+        Status = AcpiEvUpdateGpeEnableMasks (GpeEventInfo, ACPI_GPE_DISABLE);
+    }
+
+Cleanup:
+    AcpiUtRemoveReference (PkgDesc);
    return_ACPI_STATUS (AE_OK);
}

@@ -742,7 +925,7 @@

        for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++)
        {
-            ThisEvent->BitMask = AcpiGbl_DecodeTo8bit[j];
+            ThisEvent->RegisterBit  = AcpiGbl_DecodeTo8bit[j];
            ThisEvent->RegisterInfo = ThisRegister;
            ThisEvent++;
        }
@@ -813,7 +996,13 @@
    ACPI_GPE_BLOCK_INFO     **ReturnGpeBlock)
{
    ACPI_GPE_BLOCK_INFO     *GpeBlock;
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo;
+    ACPI_NATIVE_UINT        i;
+    ACPI_NATIVE_UINT        j;
+    UINT32                  WakeGpeCount;
+    UINT32                  GpeEnabledCount;
    ACPI_STATUS             Status;
+    ACPI_GPE_WALK_INFO      GpeInfo;


    ACPI_FUNCTION_TRACE ("EvCreateGpeBlock");
@@ -836,6 +1025,7 @@

    GpeBlock->RegisterCount   = RegisterCount;
    GpeBlock->BlockBaseNumber = GpeBlockBaseNumber;
+    GpeBlock->Node            = GpeDevice;

    ACPI_MEMCPY (&GpeBlock->BlockAddress, GpeBlockAddress, sizeof (ACPI_GENERIC_ADDRESS));

@@ -857,10 +1047,66 @@
        return_ACPI_STATUS (Status);
    }

+    /* Find all GPE methods (_Lxx, _Exx) for this block */
+
+    Status = AcpiNsWalkNamespace (ACPI_TYPE_METHOD, GpeDevice,
+                    ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, AcpiEvSaveMethodInfo,
+                    GpeBlock, NULL);
+
+    /*
+     * Runtime option: Should Wake GPEs be enabled at runtime?  The default
+     * is No,they should only be enabled just as the machine goes to sleep.
+     */
+    if (AcpiGbl_LeaveWakeGpesDisabled)
+    {
+        /*
+         * Differentiate RUNTIME vs WAKE GPEs, via the _PRW control methods.
+         * (Each GPE that has one or more _PRWs that reference it is by
+         * definition a WAKE GPE and will not be enabled while the machine
+         * is running.)
+         */
+        GpeInfo.GpeBlock = GpeBlock;
+        GpeInfo.GpeDevice = GpeDevice;
+
+        Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
+                        ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, AcpiEvMatchPrwAndGpe,
+                        &GpeInfo, NULL);
+    }
+
+    /*
+     * Enable all GPEs in this block that are 1) "runtime" or "run/wake" GPEs,
+     * and 2) have a corresponding _Lxx or _Exx method.  All other GPEs must
+     * be enabled via the AcpiEnableGpe() external interface.
+     */
+    WakeGpeCount = 0;
+    GpeEnabledCount = 0;
+
+    for (i = 0; i < GpeBlock->RegisterCount; i++)
+    {
+        for (j = 0; j < 8; j++)
+        {
+            /* Get the info block for this particular GPE */
+
+            GpeEventInfo = &GpeBlock->EventInfo[(i * ACPI_GPE_REGISTER_WIDTH) + j];
+
+            if (((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_METHOD) &&
+                 (GpeEventInfo->Flags & ACPI_GPE_TYPE_RUNTIME))
+            {
+                GpeEnabledCount++;
+            }
+
+            if (GpeEventInfo->Flags & ACPI_GPE_TYPE_WAKE)
+            {
+                WakeGpeCount++;
+            }
+        }
+    }
+
    /* Dump info about this GPE block */

-    ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "GPE %02d to %02d [%4.4s] %d regs at %8.8X%8.8X on int %d\n",
-        GpeBlock->BlockBaseNumber,
+    ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
+        "GPE %02X to %02X [%4.4s] %u regs at %8.8X%8.8X on int 0x%X\n",
+        (UINT32) GpeBlock->BlockBaseNumber,
        (UINT32) (GpeBlock->BlockBaseNumber +
                ((GpeBlock->RegisterCount * ACPI_GPE_REGISTER_WIDTH) -1)),
        GpeDevice->Name.Ascii,
@@ -868,11 +1114,14 @@
        ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeBlock->BlockAddress.Address)),
        InterruptLevel));

-    /* Find all GPE methods (_Lxx, _Exx) for this block */

-    Status = AcpiNsWalkNamespace (ACPI_TYPE_METHOD, GpeDevice,
-                                ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, AcpiEvSaveMethodInfo,
-                                GpeBlock, NULL);
+    /* Enable all valid GPEs found above */
+
+    Status = AcpiHwEnableRuntimeGpeBlock (NULL, GpeBlock);
+
+    ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
+            "Found %u Wake, Enabled %u Runtime GPEs in this block\n",
+            WakeGpeCount, GpeEnabledCount));

    /* Return the new block */

@@ -898,28 +1147,26 @@
 ******************************************************************************/

ACPI_STATUS
-AcpiEvGpeInitialize (void)
+AcpiEvGpeInitialize (
+    void)
{
    UINT32                  RegisterCount0 = 0;
    UINT32                  RegisterCount1 = 0;
    UINT32                  GpeNumberMax = 0;
-    ACPI_HANDLE             GpeDevice;
    ACPI_STATUS             Status;


    ACPI_FUNCTION_TRACE ("EvGpeInitialize");


-    /* Get a handle to the predefined _GPE object */
-
-    Status = AcpiGetHandle (NULL, "\\_GPE", &GpeDevice);
+    Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
    if (ACPI_FAILURE (Status))
    {
        return_ACPI_STATUS (Status);
    }

    /*
-     * Initialize the GPE Blocks defined in the FADT
+     * Initialize the GPE Block(s) defined in the FADT
     *
     * Why the GPE register block lengths are divided by 2:  From the ACPI Spec,
     * section "General-Purpose Event Registers", we have:
@@ -954,8 +1201,9 @@

        /* Install GPE Block 0 */

-        Status = AcpiEvCreateGpeBlock (GpeDevice, &AcpiGbl_FADT->XGpe0Blk,
+        Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice, &AcpiGbl_FADT->XGpe0Blk,
                    RegisterCount0, 0, AcpiGbl_FADT->SciInt, &AcpiGbl_GpeFadtBlocks[0]);
+
        if (ACPI_FAILURE (Status))
        {
            ACPI_REPORT_ERROR ((
@@ -990,9 +1238,10 @@
        {
            /* Install GPE Block 1 */

-            Status = AcpiEvCreateGpeBlock (GpeDevice, &AcpiGbl_FADT->XGpe1Blk,
+            Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice, &AcpiGbl_FADT->XGpe1Blk,
                        RegisterCount1, AcpiGbl_FADT->Gpe1Base,
                        AcpiGbl_FADT->SciInt, &AcpiGbl_GpeFadtBlocks[1]);
+
            if (ACPI_FAILURE (Status))
            {
                ACPI_REPORT_ERROR ((
@@ -1015,8 +1264,10 @@
    {
        /* GPEs are not required by ACPI, this is OK */

-        ACPI_REPORT_INFO (("There are no GPE blocks defined in the FADT\n"));
-        return_ACPI_STATUS (AE_OK);
+        ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
+                "There are no GPE blocks defined in the FADT\n"));
+        Status = AE_OK;
+        goto Cleanup;
    }

    /* Check for Max GPE number out-of-range */
@@ -1025,9 +1276,12 @@
    {
        ACPI_REPORT_ERROR (("Maximum GPE number from FADT is too large: 0x%X\n",
            GpeNumberMax));
-        return_ACPI_STATUS (AE_BAD_VALUE);
+        Status = AE_BAD_VALUE;
+        goto Cleanup;
    }

+Cleanup:
+    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
    return_ACPI_STATUS (AE_OK);
}

Index: sys/dev/acpi/acpica/Subsystem/evmisc.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/evmisc.c,v
retrieving revision 1.10
diff -u -r1.10 evmisc.c
--- sys/dev/acpi/acpica/Subsystem/evmisc.c      14 Feb 2004 16:57:24 -0000      1.10
+++ sys/dev/acpi/acpica/Subsystem/evmisc.c      17 Jun 2004 04:08:43 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Module Name: evmisc - Miscellaneous event manager support functions
- *              xRevision: 70 $
+ *              xRevision: 75 $
 *
 *****************************************************************************/

@@ -174,6 +174,20 @@
 *
 ******************************************************************************/

+#ifdef ACPI_DEBUG_OUTPUT
+static const char        *AcpiNotifyValueNames[] =
+{
+    "Bus Check",
+    "Device Check",
+    "Device Wake",
+    "Eject request",
+    "Device Check Light",
+    "Frequency Mismatch",
+    "Bus Mode Mismatch",
+    "Power Fault"
+};
+#endif
+
ACPI_STATUS
AcpiEvQueueNotifyRequest (
    ACPI_NAMESPACE_NODE     *Node,
@@ -189,7 +203,7 @@


    /*
-     * For value 1 (Ejection Request), some device method may need to be run.
+     * For value 3 (Ejection Request), some device method may need to be run.
     * For value 2 (Device Wake) if _PRW exists, the _PS0 method may need to be run.
     * For value 0x80 (Status Change) on the power button or sleep button,
     * initiate soft-off or sleep operation?
@@ -197,27 +211,15 @@
    ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
        "Dispatching Notify(%X) on node %p\n", NotifyValue, Node));

-    switch (NotifyValue)
+    if (NotifyValue <= 7)
    {
-    case 0:
-        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Notify value: Re-enumerate Devices\n"));
-        break;
-
-    case 1:
-        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Notify value: Ejection Request\n"));
-        break;
-
-    case 2:
-        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Notify value: Device Wake\n"));
-        break;
-
-    case 0x80:
-        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Notify value: Status Change\n"));
-        break;
-
-    default:
-        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Unknown Notify Value: %X \n", NotifyValue));
-        break;
+        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Notify value: %s\n",
+                AcpiNotifyValueNames[NotifyValue]));
+    }
+    else
+    {
+        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Notify value: 0x%2.2X **Device Specific**\n",
+                NotifyValue));
    }

    /*
@@ -281,8 +283,8 @@
        /* There is no per-device notify handler for this device */

        ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-            "No notify handler for [%4.4s] node %p\n",
-            AcpiUtGetNodeName (Node), Node));
+            "No notify handler for Notify(%4.4s, %X) node %p\n",
+            AcpiUtGetNodeName (Node), NotifyValue, Node));
    }

    return (Status);
@@ -663,6 +665,10 @@
        }
    }

+    /* Deallocate all handler objects installed within GPE info structs */
+
+    Status = AcpiEvWalkGpeList (AcpiEvDeleteGpeHandlers);
+
    /* Return to original mode if necessary */

    if (AcpiGbl_OriginalMode == ACPI_SYS_MODE_LEGACY)
Index: sys/dev/acpi/acpica/Subsystem/evregion.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/evregion.c,v
retrieving revision 1.10
diff -u -r1.10 evregion.c
--- sys/dev/acpi/acpica/Subsystem/evregion.c    14 Feb 2004 16:57:24 -0000      1.10
+++ sys/dev/acpi/acpica/Subsystem/evregion.c    17 Jun 2004 04:08:43 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Module Name: evregion - ACPI AddressSpace (OpRegion) handler dispatch
- *              xRevision: 149 $
+ *              xRevision: 151 $
 *
 *****************************************************************************/

@@ -139,7 +139,7 @@

/*******************************************************************************
 *
- * FUNCTION:    AcpiEvInitAddressSpaces
+ * FUNCTION:    AcpiEvInstallRegionHandlers
 *
 * PARAMETERS:  None
 *
@@ -150,16 +150,22 @@
 ******************************************************************************/

ACPI_STATUS
-AcpiEvInitAddressSpaces (
+AcpiEvInstallRegionHandlers (
    void)
{
    ACPI_STATUS             Status;
    ACPI_NATIVE_UINT        i;


-    ACPI_FUNCTION_TRACE ("EvInitAddressSpaces");
+    ACPI_FUNCTION_TRACE ("EvInstallRegionHandlers");


+    Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
    /*
     * All address spaces (PCI Config, EC, SMBus) are scope dependent
     * and registration must occur for a specific device.
@@ -178,10 +184,9 @@
     * has already been installed (via AcpiInstallAddressSpaceHandler).
     * Similar for AE_SAME_HANDLER.
     */
-
    for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++)
    {
-        Status = AcpiInstallAddressSpaceHandler ((ACPI_HANDLE) AcpiGbl_RootNode,
+        Status = AcpiEvInstallSpaceHandler (AcpiGbl_RootNode,
                        AcpiGbl_DefaultAddressSpaces[i],
                        ACPI_DEFAULT_HANDLER, NULL, NULL);
        switch (Status)
@@ -192,15 +197,65 @@

            /* These exceptions are all OK */

+            Status = AE_OK;
            break;

        default:

-            return_ACPI_STATUS (Status);
+            goto UnlockAndExit;
        }
    }

-    return_ACPI_STATUS (AE_OK);
+UnlockAndExit:
+    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvInitializeOpRegions
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Execute _REG methods for all Operation Regions that have
+ *              an installed default region handler.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvInitializeOpRegions (
+    void)
+{
+    ACPI_STATUS             Status;
+    ACPI_NATIVE_UINT        i;
+
+
+    ACPI_FUNCTION_TRACE ("EvInitializeOpRegions");
+
+
+    Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    /*
+     * Run the _REG methods for OpRegions in each default address space
+     */
+    for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++)
+    {
+        /* TBD: Make sure handler is the DEFAULT handler, otherwise
+         * _REG will have already been run.
+         */
+        Status = AcpiEvExecuteRegMethods (AcpiGbl_RootNode,
+                        AcpiGbl_DefaultAddressSpaces[i]);
+    }
+
+    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+    return_ACPI_STATUS (Status);
}


@@ -219,11 +274,12 @@

ACPI_STATUS
AcpiEvExecuteRegMethod (
-    ACPI_OPERAND_OBJECT    *RegionObj,
+    ACPI_OPERAND_OBJECT     *RegionObj,
    UINT32                  Function)
{
-    ACPI_OPERAND_OBJECT    *Params[3];
-    ACPI_OPERAND_OBJECT    *RegionObj2;
+    ACPI_PARAMETER_INFO     Info;
+    ACPI_OPERAND_OBJECT     *Params[3];
+    ACPI_OPERAND_OBJECT     *RegionObj2;
    ACPI_STATUS             Status;


@@ -242,10 +298,11 @@
    }

    /*
-     * _REG method has two arguments
-     * Arg0:   Integer: Operation region space ID
+     * The _REG method has two arguments:
+     *
+     * Arg0, Integer: Operation region space ID
     *          Same value as RegionObj->Region.SpaceId
-     * Arg1:   Integer: connection status
+     * Arg1, Integer: connection status
     *          1 for connecting the handler,
     *          0 for disconnecting the handler
     *          Passed as a parameter
@@ -269,10 +326,15 @@
    Params[1]->Integer.Value = Function;
    Params[2] = NULL;

+    Info.Node = RegionObj2->Extra.Method_REG;
+    Info.Parameters = Params;
+    Info.ParameterType = ACPI_PARAM_ARGS;
+
    /* Execute the method, no return value */

-    ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD, RegionObj2->Extra.Method_REG, NULL));
-    Status = AcpiNsEvaluateByHandle (RegionObj2->Extra.Method_REG, Params, NULL);
+    ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (
+                        ACPI_TYPE_METHOD, Info.Node, NULL));
+    Status = AcpiNsEvaluateByHandle (&Info);

    AcpiUtRemoveReference (Params[1]);

@@ -420,7 +482,7 @@
        ACPI_FORMAT_UINT64 (Address),
        AcpiUtGetRegionName (RegionObj->Region.SpaceId)));

-    if (!(HandlerDesc->AddressSpace.Flags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED))
+    if (!(HandlerDesc->AddressSpace.Hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED))
    {
        /*
         * For handlers other than the default (supplied) handlers, we must
@@ -443,7 +505,7 @@
            AcpiFormatException (Status)));
    }

-    if (!(HandlerDesc->AddressSpace.Flags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED))
+    if (!(HandlerDesc->AddressSpace.Hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED))
    {
        /*
         * We just returned from a non-default handler, we must re-enter the
@@ -793,6 +855,288 @@
    return (Status);
}

+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvInstallSpaceHandler
+ *
+ * PARAMETERS:  Node            - Namespace node for the device
+ *              SpaceId         - The address space ID
+ *              Handler         - Address of the handler
+ *              Setup           - Address of the setup function
+ *              Context         - Value passed to the handler on each access
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Install a handler for all OpRegions of a given SpaceId.
+ *              Assumes namespace is locked
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvInstallSpaceHandler (
+    ACPI_NAMESPACE_NODE     *Node,
+    ACPI_ADR_SPACE_TYPE     SpaceId,
+    ACPI_ADR_SPACE_HANDLER  Handler,
+    ACPI_ADR_SPACE_SETUP    Setup,
+    void                    *Context)
+{
+    ACPI_OPERAND_OBJECT     *ObjDesc;
+    ACPI_OPERAND_OBJECT     *HandlerObj;
+    ACPI_STATUS             Status;
+    ACPI_OBJECT_TYPE        Type;
+    UINT16                  Flags = 0;
+
+
+    ACPI_FUNCTION_TRACE ("EvInstallSpaceHandler");
+
+
+    /*
+     * This registration is valid for only the types below
+     * and the root.  This is where the default handlers
+     * get placed.
+     */
+    if ((Node->Type != ACPI_TYPE_DEVICE)     &&
+        (Node->Type != ACPI_TYPE_PROCESSOR)  &&
+        (Node->Type != ACPI_TYPE_THERMAL)    &&
+        (Node != AcpiGbl_RootNode))
+    {
+        Status = AE_BAD_PARAMETER;
+        goto UnlockAndExit;
+    }
+
+    if (Handler == ACPI_DEFAULT_HANDLER)
+    {
+        Flags = ACPI_ADDR_HANDLER_DEFAULT_INSTALLED;
+
+        switch (SpaceId)
+        {
+        case ACPI_ADR_SPACE_SYSTEM_MEMORY:
+            Handler = AcpiExSystemMemorySpaceHandler;
+            Setup   = AcpiEvSystemMemoryRegionSetup;
+            break;
+
+        case ACPI_ADR_SPACE_SYSTEM_IO:
+            Handler = AcpiExSystemIoSpaceHandler;
+            Setup   = AcpiEvIoSpaceRegionSetup;
+            break;
+
+        case ACPI_ADR_SPACE_PCI_CONFIG:
+            Handler = AcpiExPciConfigSpaceHandler;
+            Setup   = AcpiEvPciConfigRegionSetup;
+            break;
+
+        case ACPI_ADR_SPACE_CMOS:
+            Handler = AcpiExCmosSpaceHandler;
+            Setup   = AcpiEvCmosRegionSetup;
+            break;
+
+        case ACPI_ADR_SPACE_PCI_BAR_TARGET:
+            Handler = AcpiExPciBarSpaceHandler;
+            Setup   = AcpiEvPciBarRegionSetup;
+            break;
+
+        case ACPI_ADR_SPACE_DATA_TABLE:
+            Handler = AcpiExDataTableSpaceHandler;
+            Setup   = NULL;
+            break;
+
+        default:
+            Status = AE_BAD_PARAMETER;
+            goto UnlockAndExit;
+        }
+    }
+
+    /* If the caller hasn't specified a setup routine, use the default */
+
+    if (!Setup)
+    {
+        Setup = AcpiEvDefaultRegionSetup;
+    }
+
+    /* Check for an existing internal object */
+
+    ObjDesc = AcpiNsGetAttachedObject (Node);
+    if (ObjDesc)
+    {
+        /*
+         * The attached device object already exists.
+         * Make sure the handler is not already installed.
+         */
+        HandlerObj = ObjDesc->Device.Handler;
+
+        /* Walk the handler list for this device */
+
+        while (HandlerObj)
+        {
+            /* Same SpaceId indicates a handler already installed */
+
+            if (HandlerObj->AddressSpace.SpaceId == SpaceId)
+            {
+                if (HandlerObj->AddressSpace.Handler == Handler)
+                {
+                    /*
+                     * It is (relatively) OK to attempt to install the SAME
+                     * handler twice. This can easily happen with PCI_Config space.
+                     */
+                    Status = AE_SAME_HANDLER;
+                    goto UnlockAndExit;
+                }
+                else
+                {
+                    /* A handler is already installed */
+
+                    Status = AE_ALREADY_EXISTS;
+                }
+                goto UnlockAndExit;
+            }
+
+            /* Walk the linked list of handlers */
+
+            HandlerObj = HandlerObj->AddressSpace.Next;
+        }
+    }
+    else
+    {
+        ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
+            "Creating object on Device %p while installing handler\n", Node));
+
+        /* ObjDesc does not exist, create one */
+
+        if (Node->Type == ACPI_TYPE_ANY)
+        {
+            Type = ACPI_TYPE_DEVICE;
+        }
+        else
+        {
+            Type = Node->Type;
+        }
+
+        ObjDesc = AcpiUtCreateInternalObject (Type);
+        if (!ObjDesc)
+        {
+            Status = AE_NO_MEMORY;
+            goto UnlockAndExit;
+        }
+
+        /* Init new descriptor */
+
+        ObjDesc->Common.Type = (UINT8) Type;
+
+        /* Attach the new object to the Node */
+
+        Status = AcpiNsAttachObject (Node, ObjDesc, Type);
+
+        /* Remove local reference to the object */
+
+        AcpiUtRemoveReference (ObjDesc);
+
+        if (ACPI_FAILURE (Status))
+        {
+            goto UnlockAndExit;
+        }
+    }
+
+    ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
+        "Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n",
+        AcpiUtGetRegionName (SpaceId), SpaceId,
+        AcpiUtGetNodeName (Node), Node, ObjDesc));
+
+    /*
+     * Install the handler
+     *
+     * At this point there is no existing handler.
+     * Just allocate the object for the handler and link it
+     * into the list.
+     */
+    HandlerObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_ADDRESS_HANDLER);
+    if (!HandlerObj)
+    {
+        Status = AE_NO_MEMORY;
+        goto UnlockAndExit;
+    }
+
+    /* Init handler obj */
+
+    HandlerObj->AddressSpace.SpaceId     = (UINT8) SpaceId;
+    HandlerObj->AddressSpace.Hflags      = Flags;
+    HandlerObj->AddressSpace.RegionList  = NULL;
+    HandlerObj->AddressSpace.Node        = Node;
+    HandlerObj->AddressSpace.Handler     = Handler;
+    HandlerObj->AddressSpace.Context     = Context;
+    HandlerObj->AddressSpace.Setup       = Setup;
+
+    /* Install at head of Device.AddressSpace list */
+
+    HandlerObj->AddressSpace.Next        = ObjDesc->Device.Handler;
+
+    /*
+     * The Device object is the first reference on the HandlerObj.
+     * Each region that uses the handler adds a reference.
+     */
+    ObjDesc->Device.Handler = HandlerObj;
+
+    /*
+     * Walk the namespace finding all of the regions this
+     * handler will manage.
+     *
+     * Start at the device and search the branch toward
+     * the leaf nodes until either the leaf is encountered or
+     * a device is detected that has an address handler of the
+     * same type.
+     *
+     * In either case, back up and search down the remainder
+     * of the branch
+     */
+    Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX,
+                    ACPI_NS_WALK_UNLOCK, AcpiEvInstallHandler,
+                    HandlerObj, NULL);
+
+UnlockAndExit:
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvExecuteRegMethods
+ *
+ * PARAMETERS:  Node            - Namespace node for the device
+ *              SpaceId         - The address space ID
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Run _REG methods for the Space ID;
+ *              Note: assumes namespace is locked, or system init time.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvExecuteRegMethods (
+    ACPI_NAMESPACE_NODE     *Node,
+    ACPI_ADR_SPACE_TYPE     SpaceId)
+{
+    ACPI_STATUS             Status;
+
+
+    ACPI_FUNCTION_TRACE ("EvExecuteRegMethods");
+
+
+    /*
+     * Run all _REG methods for all Operation Regions for this
+     * space ID.  This is a separate walk in order to handle any
+     * interdependencies between regions and _REG methods.  (i.e. handlers
+     * must be installed for all regions of this Space ID before we
+     * can run any _REG methods)
+     */
+    Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX,
+                    ACPI_NS_WALK_UNLOCK, AcpiEvRegRun,
+                    &SpaceId, NULL);
+
+    return_ACPI_STATUS (Status);
+}
+
+
/*******************************************************************************
 *
 * FUNCTION:    AcpiEvRegRun
@@ -810,20 +1154,13 @@
    void                    *Context,
    void                    **ReturnValue)
{
-    ACPI_OPERAND_OBJECT     *HandlerObj;
    ACPI_OPERAND_OBJECT     *ObjDesc;
    ACPI_NAMESPACE_NODE     *Node;
+    ACPI_ADR_SPACE_TYPE     SpaceId;
    ACPI_STATUS             Status;


-    HandlerObj = (ACPI_OPERAND_OBJECT  *) Context;
-
-    /* Parameter validation */
-
-    if (!HandlerObj)
-    {
-        return (AE_OK);
-    }
+    SpaceId = *ACPI_CAST_PTR (ACPI_ADR_SPACE_TYPE, Context);

    /* Convert and validate the device handle */

@@ -853,10 +1190,9 @@
        return (AE_OK);
    }

-
    /* Object is a Region */

-    if (ObjDesc->Region.SpaceId != HandlerObj->AddressSpace.SpaceId)
+    if (ObjDesc->Region.SpaceId != SpaceId)
    {
        /*
         * This region is for a different address space
Index: sys/dev/acpi/acpica/Subsystem/evxface.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/evxface.c,v
retrieving revision 1.10
diff -u -r1.10 evxface.c
--- sys/dev/acpi/acpica/Subsystem/evxface.c     14 Feb 2004 16:57:24 -0000      1.10
+++ sys/dev/acpi/acpica/Subsystem/evxface.c     17 Jun 2004 04:08:43 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Module Name: evxface - External interfaces for ACPI events
- *              xRevision: 142 $
+ *              xRevision: 145 $
 *
 *****************************************************************************/

@@ -275,6 +275,7 @@
 *              HandlerType     - The type of handler:
 *                                  ACPI_SYSTEM_NOTIFY: SystemHandler (00-7f)
 *                                  ACPI_DEVICE_NOTIFY: DriverHandler (80-ff)
+ *                                  ACPI_ALL_NOTIFY:  both system and device
 *              Handler         - Address of the handler
 *              Context         - Value passed to the handler on each GPE
 *
@@ -334,22 +335,23 @@
    {
        /* Make sure the handler is not already installed */

-        if (((HandlerType == ACPI_SYSTEM_NOTIFY) &&
-                AcpiGbl_SystemNotify.Handler)          ||
-            ((HandlerType == ACPI_DEVICE_NOTIFY) &&
+        if (((HandlerType & ACPI_SYSTEM_NOTIFY) &&
+                AcpiGbl_SystemNotify.Handler)       ||
+            ((HandlerType & ACPI_DEVICE_NOTIFY) &&
                AcpiGbl_DeviceNotify.Handler))
        {
            Status = AE_ALREADY_EXISTS;
            goto UnlockAndExit;
        }

-        if (HandlerType == ACPI_SYSTEM_NOTIFY)
+        if (HandlerType & ACPI_SYSTEM_NOTIFY)
        {
            AcpiGbl_SystemNotify.Node    = Node;
            AcpiGbl_SystemNotify.Handler = Handler;
            AcpiGbl_SystemNotify.Context = Context;
        }
-        else /* ACPI_DEVICE_NOTIFY */
+
+        if (HandlerType & ACPI_DEVICE_NOTIFY)
        {
            AcpiGbl_DeviceNotify.Node    = Node;
            AcpiGbl_DeviceNotify.Handler = Handler;
@@ -381,9 +383,9 @@
        {
            /* Object exists - make sure there's no handler */

-            if (((HandlerType == ACPI_SYSTEM_NOTIFY) &&
+            if (((HandlerType & ACPI_SYSTEM_NOTIFY) &&
                    ObjDesc->CommonNotify.SystemNotify)   ||
-                ((HandlerType == ACPI_DEVICE_NOTIFY) &&
+                ((HandlerType & ACPI_DEVICE_NOTIFY) &&
                    ObjDesc->CommonNotify.DeviceNotify))
            {
                Status = AE_ALREADY_EXISTS;
@@ -408,7 +410,6 @@
            /* Remove local reference to the object */

            AcpiUtRemoveReference (ObjDesc);
-
            if (ACPI_FAILURE (Status))
            {
                goto UnlockAndExit;
@@ -428,14 +429,22 @@
        NotifyObj->Notify.Handler = Handler;
        NotifyObj->Notify.Context = Context;

-        if (HandlerType == ACPI_SYSTEM_NOTIFY)
+        if (HandlerType & ACPI_SYSTEM_NOTIFY)
        {
            ObjDesc->CommonNotify.SystemNotify = NotifyObj;
        }
-        else /* ACPI_DEVICE_NOTIFY */
+
+        if (HandlerType & ACPI_DEVICE_NOTIFY)
        {
            ObjDesc->CommonNotify.DeviceNotify = NotifyObj;
        }
+
+        if (HandlerType == ACPI_ALL_NOTIFY)
+        {
+            /* Extra ref if installed in both */
+
+            AcpiUtAddReference (NotifyObj);
+        }
    }


@@ -453,6 +462,7 @@
 *              HandlerType     - The type of handler:
 *                                  ACPI_SYSTEM_NOTIFY: SystemHandler (00-7f)
 *                                  ACPI_DEVICE_NOTIFY: DriverHandler (80-ff)
+ *                                  ACPI_ALL_NOTIFY:  both system and device
 *              Handler         - Address of the handler
 * RETURN:      Status
 *
@@ -506,22 +516,23 @@
    {
        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Removing notify handler for ROOT object.\n"));

-        if (((HandlerType == ACPI_SYSTEM_NOTIFY) &&
-              !AcpiGbl_SystemNotify.Handler) ||
-            ((HandlerType == ACPI_DEVICE_NOTIFY) &&
+        if (((HandlerType & ACPI_SYSTEM_NOTIFY) &&
+              !AcpiGbl_SystemNotify.Handler)        ||
+            ((HandlerType & ACPI_DEVICE_NOTIFY) &&
              !AcpiGbl_DeviceNotify.Handler))
        {
            Status = AE_NOT_EXIST;
            goto UnlockAndExit;
        }

-        if (HandlerType == ACPI_SYSTEM_NOTIFY)
+        if (HandlerType & ACPI_SYSTEM_NOTIFY)
        {
            AcpiGbl_SystemNotify.Node    = NULL;
            AcpiGbl_SystemNotify.Handler = NULL;
            AcpiGbl_SystemNotify.Context = NULL;
        }
-        else
+
+        if (HandlerType & ACPI_DEVICE_NOTIFY)
        {
            AcpiGbl_DeviceNotify.Node    = NULL;
            AcpiGbl_DeviceNotify.Handler = NULL;
@@ -553,34 +564,37 @@

        /* Object exists - make sure there's an existing handler */

-        if (HandlerType == ACPI_SYSTEM_NOTIFY)
+        if (HandlerType & ACPI_SYSTEM_NOTIFY)
        {
            NotifyObj = ObjDesc->CommonNotify.SystemNotify;
-        }
-        else
-        {
-            NotifyObj = ObjDesc->CommonNotify.DeviceNotify;
-        }
-
-        if ((!NotifyObj) ||
-            (NotifyObj->Notify.Handler != Handler))
-        {
-            Status = AE_BAD_PARAMETER;
-            goto UnlockAndExit;
-        }
+            if ((!NotifyObj) ||
+                 (NotifyObj->Notify.Handler != Handler))
+            {
+                Status = AE_BAD_PARAMETER;
+                goto UnlockAndExit;
+            }

-        /* Remove the handler */
+            /* Remove the handler */

-        if (HandlerType == ACPI_SYSTEM_NOTIFY)
-        {
            ObjDesc->CommonNotify.SystemNotify = NULL;
+            AcpiUtRemoveReference (NotifyObj);
        }
-        else
+
+        if (HandlerType & ACPI_DEVICE_NOTIFY)
        {
+            NotifyObj = ObjDesc->CommonNotify.DeviceNotify;
+            if ((!NotifyObj) ||
+                 (NotifyObj->Notify.Handler != Handler))
+            {
+                Status = AE_BAD_PARAMETER;
+                goto UnlockAndExit;
+            }
+
+            /* Remove the handler */
+
            ObjDesc->CommonNotify.DeviceNotify = NULL;
+            AcpiUtRemoveReference (NotifyObj);
        }
-
-        AcpiUtRemoveReference (NotifyObj);
    }


@@ -598,7 +612,7 @@
 *              GpeBlock        - GPE block (NULL == FADT GPEs)
 *              Type            - Whether this GPE should be treated as an
 *                                edge- or level-triggered interrupt.
- *              Handler         - Address of the handler
+ *              Address         - Address of the handler
 *              Context         - Value passed to the handler on each GPE
 *
 * RETURN:      Status
@@ -612,11 +626,12 @@
    ACPI_HANDLE             GpeDevice,
    UINT32                  GpeNumber,
    UINT32                  Type,
-    ACPI_GPE_HANDLER        Handler,
+    ACPI_EVENT_HANDLER      Address,
    void                    *Context)
{
-    ACPI_STATUS             Status;
    ACPI_GPE_EVENT_INFO     *GpeEventInfo;
+    ACPI_HANDLER_INFO       *Handler;
+    ACPI_STATUS             Status;


    ACPI_FUNCTION_TRACE ("AcpiInstallGpeHandler");
@@ -624,7 +639,7 @@

    /* Parameter validation */

-    if (!Handler)
+    if ((!Address) || (Type > ACPI_GPE_XRUPT_TYPE_MASK))
    {
        return_ACPI_STATUS (AE_BAD_PARAMETER);
    }
@@ -646,29 +661,44 @@

    /* Make sure that there isn't a handler there already */

-    if (GpeEventInfo->Handler)
+    if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_HANDLER)
    {
        Status = AE_ALREADY_EXISTS;
        goto UnlockAndExit;
    }

-    /* Install the handler */
+    /* Allocate and init handler object */

-    AcpiOsAcquireLock (AcpiGbl_GpeLock, ACPI_NOT_ISR);
-    GpeEventInfo->Handler = Handler;
-    GpeEventInfo->Context = Context;
-    GpeEventInfo->Flags   = (UINT8) Type;
-    AcpiOsReleaseLock (AcpiGbl_GpeLock, ACPI_NOT_ISR);
+    Handler = ACPI_MEM_CALLOCATE (sizeof (ACPI_HANDLER_INFO));
+    if (!Handler)
+    {
+        Status = AE_NO_MEMORY;
+        goto UnlockAndExit;
+    }
+
+    Handler->Address    = Address;
+    Handler->Context    = Context;
+    Handler->MethodNode = GpeEventInfo->Dispatch.MethodNode;

-    /* Clear the GPE (of stale events), the enable it */
+    /* Disable the GPE before installing the handler */

-    Status = AcpiHwClearGpe (GpeEventInfo);
+    Status = AcpiEvDisableGpe (GpeEventInfo);
    if (ACPI_FAILURE (Status))
    {
        goto UnlockAndExit;
    }

-    Status = AcpiHwEnableGpe (GpeEventInfo);
+    /* Install the handler */
+
+    AcpiOsAcquireLock (AcpiGbl_GpeLock, ACPI_NOT_ISR);
+    GpeEventInfo->Dispatch.Handler = Handler;
+
+    /* Setup up dispatch flags to indicate handler (vs. method) */
+
+    GpeEventInfo->Flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK);  /* Clear bits */
+    GpeEventInfo->Flags |= (UINT8) (Type | ACPI_GPE_DISPATCH_HANDLER);
+
+    AcpiOsReleaseLock (AcpiGbl_GpeLock, ACPI_NOT_ISR);


UnlockAndExit:
@@ -683,7 +713,7 @@
 *
 * PARAMETERS:  GpeNumber       - The event to remove a handler
 *              GpeBlock        - GPE block (NULL == FADT GPEs)
- *              Handler         - Address of the handler
+ *              Address         - Address of the handler
 *
 * RETURN:      Status
 *
@@ -695,10 +725,11 @@
AcpiRemoveGpeHandler (
    ACPI_HANDLE             GpeDevice,
    UINT32                  GpeNumber,
-    ACPI_GPE_HANDLER        Handler)
+    ACPI_EVENT_HANDLER      Address)
{
-    ACPI_STATUS             Status;
    ACPI_GPE_EVENT_INFO     *GpeEventInfo;
+    ACPI_HANDLER_INFO       *Handler;
+    ACPI_STATUS             Status;


    ACPI_FUNCTION_TRACE ("AcpiRemoveGpeHandler");
@@ -706,7 +737,7 @@

    /* Parameter validation */

-    if (!Handler)
+    if (!Address)
    {
        return_ACPI_STATUS (AE_BAD_PARAMETER);
    }
@@ -726,30 +757,49 @@
        goto UnlockAndExit;
    }

-    /* Disable the GPE before removing the handler */
+    /* Make sure that a handler is indeed installed */

-    Status = AcpiHwDisableGpe (GpeEventInfo);
-    if (ACPI_FAILURE (Status))
+    if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) != ACPI_GPE_DISPATCH_HANDLER)
    {
+        Status = AE_NOT_EXIST;
        goto UnlockAndExit;
    }

    /* Make sure that the installed handler is the same */

-    if (GpeEventInfo->Handler != Handler)
+    if (GpeEventInfo->Dispatch.Handler->Address != Address)
    {
-        (void) AcpiHwEnableGpe (GpeEventInfo);
        Status = AE_BAD_PARAMETER;
        goto UnlockAndExit;
    }

+    /* Disable the GPE before removing the handler */
+
+    Status = AcpiEvDisableGpe (GpeEventInfo);
+    if (ACPI_FAILURE (Status))
+    {
+        goto UnlockAndExit;
+    }
+
    /* Remove the handler */

    AcpiOsAcquireLock (AcpiGbl_GpeLock, ACPI_NOT_ISR);
-    GpeEventInfo->Handler = NULL;
-    GpeEventInfo->Context = NULL;
+    Handler = GpeEventInfo->Dispatch.Handler;
+
+    /* Restore Method node (if any), set dispatch flags */
+
+    GpeEventInfo->Dispatch.MethodNode = Handler->MethodNode;
+    GpeEventInfo->Flags &= ~ACPI_GPE_DISPATCH_MASK;  /* Clear bits */
+    if (Handler->MethodNode)
+    {
+        GpeEventInfo->Flags |= ACPI_GPE_DISPATCH_METHOD;
+    }
    AcpiOsReleaseLock (AcpiGbl_GpeLock, ACPI_NOT_ISR);

+    /* Now we can free the handler object */
+
+    ACPI_MEM_FREE (Handler);
+

UnlockAndExit:
    (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
Index: sys/dev/acpi/acpica/Subsystem/evxfevnt.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/evxfevnt.c,v
retrieving revision 1.10
diff -u -r1.10 evxfevnt.c
--- sys/dev/acpi/acpica/Subsystem/evxfevnt.c    14 Feb 2004 16:57:24 -0000      1.10
+++ sys/dev/acpi/acpica/Subsystem/evxfevnt.c    17 Jun 2004 04:08:44 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable
- *              xRevision: 74 $
+ *              xRevision: 79 $
 *
 *****************************************************************************/

@@ -294,12 +294,11 @@

/*******************************************************************************
 *
- * FUNCTION:    AcpiEnableGpe
+ * FUNCTION:    AcpiSetGpeType
 *
 * PARAMETERS:  GpeDevice       - Parent GPE Device
 *              GpeNumber       - GPE level within the GPE block
- *              Flags           - Just enable, or also wake enable?
- *                                Called from ISR or not
+ *              Type            - New GPE type
 *
 * RETURN:      Status
 *
@@ -308,28 +307,17 @@
 ******************************************************************************/

ACPI_STATUS
-AcpiEnableGpe (
+AcpiSetGpeType (
    ACPI_HANDLE             GpeDevice,
    UINT32                  GpeNumber,
-    UINT32                  Flags)
+    UINT8                   Type)
{
    ACPI_STATUS             Status = AE_OK;
    ACPI_GPE_EVENT_INFO     *GpeEventInfo;


-    ACPI_FUNCTION_TRACE ("AcpiEnableGpe");
-
+    ACPI_FUNCTION_TRACE ("AcpiSetGpeType");

-    /* Use semaphore lock if not executing at interrupt level */
-
-    if (Flags & ACPI_NOT_ISR)
-    {
-        Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
-        if (ACPI_FAILURE (Status))
-        {
-            return_ACPI_STATUS (Status);
-        }
-    }

    /* Ensure that we have a valid GPE number */

@@ -340,85 +328,77 @@
        goto UnlockAndExit;
    }

-    /* Enable the requested GPE number */
-
-    Status = AcpiHwEnableGpe (GpeEventInfo);
-    if (ACPI_FAILURE (Status))
+    if ((GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) == Type)
    {
-        goto UnlockAndExit;
+        return_ACPI_STATUS (AE_OK);
    }

-    if (Flags & ACPI_EVENT_WAKE_ENABLE)
-    {
-        AcpiHwEnableGpeForWakeup (GpeEventInfo);
-    }
+    /* Set the new type (will disable GPE if currently enabled) */
+
+    Status = AcpiEvSetGpeType (GpeEventInfo, Type);

UnlockAndExit:
-    if (Flags & ACPI_NOT_ISR)
-    {
-        (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
-    }
    return_ACPI_STATUS (Status);
}


/*******************************************************************************
 *
- * FUNCTION:    AcpiDisableEvent
+ * FUNCTION:    AcpiEnableGpe
 *
- * PARAMETERS:  Event           - The fixed eventto be enabled
- *              Flags           - Reserved
+ * PARAMETERS:  GpeDevice       - Parent GPE Device
+ *              GpeNumber       - GPE level within the GPE block
+ *              Flags           - Just enable, or also wake enable?
+ *                                Called from ISR or not
 *
 * RETURN:      Status
 *
- * DESCRIPTION: Disable an ACPI event (fixed)
+ * DESCRIPTION: Enable an ACPI event (general purpose)
 *
 ******************************************************************************/

ACPI_STATUS
-AcpiDisableEvent (
-    UINT32                  Event,
+AcpiEnableGpe (
+    ACPI_HANDLE             GpeDevice,
+    UINT32                  GpeNumber,
    UINT32                  Flags)
{
    ACPI_STATUS             Status = AE_OK;
-    UINT32                  Value;
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo;


-    ACPI_FUNCTION_TRACE ("AcpiDisableEvent");
+    ACPI_FUNCTION_TRACE ("AcpiEnableGpe");


-    /* Decode the Fixed Event */
+    /* Use semaphore lock if not executing at interrupt level */

-    if (Event > ACPI_EVENT_MAX)
+    if (Flags & ACPI_NOT_ISR)
    {
-        return_ACPI_STATUS (AE_BAD_PARAMETER);
+        Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
+        if (ACPI_FAILURE (Status))
+        {
+            return_ACPI_STATUS (Status);
+        }
    }

-    /*
-     * Disable the requested fixed event (by writing a zero to the
-     * enable register bit)
-     */
-    Status = AcpiSetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
-                0, ACPI_MTX_LOCK);
-    if (ACPI_FAILURE (Status))
-    {
-        return_ACPI_STATUS (Status);
-    }
+    /* Ensure that we have a valid GPE number */

-    Status = AcpiGetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
-                &Value, ACPI_MTX_LOCK);
-    if (ACPI_FAILURE (Status))
+    GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
+    if (!GpeEventInfo)
    {
-        return_ACPI_STATUS (Status);
+        Status = AE_BAD_PARAMETER;
+        goto UnlockAndExit;
    }

-    if (Value != 0)
+    /* Perform the enable */
+
+    Status = AcpiEvEnableGpe (GpeEventInfo, TRUE);
+
+UnlockAndExit:
+    if (Flags & ACPI_NOT_ISR)
    {
-        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-            "Could not disable %s events\n", AcpiUtGetEventName (Event)));
-        return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
+        (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
    }
-
    return_ACPI_STATUS (Status);
}

@@ -429,7 +409,7 @@
 *
 * PARAMETERS:  GpeDevice       - Parent GPE Device
 *              GpeNumber       - GPE level within the GPE block
- *              Flags           - Just enable, or also wake enable?
+ *              Flags           - Just disable, or also wake disable?
 *                                Called from ISR or not
 *
 * RETURN:      Status
@@ -471,24 +451,74 @@
        goto UnlockAndExit;
    }

+    Status = AcpiEvDisableGpe (GpeEventInfo);
+
+UnlockAndExit:
+    if (Flags & ACPI_NOT_ISR)
+    {
+        (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
+    }
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDisableEvent
+ *
+ * PARAMETERS:  Event           - The fixed eventto be enabled
+ *              Flags           - Reserved
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Disable an ACPI event (fixed)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDisableEvent (
+    UINT32                  Event,
+    UINT32                  Flags)
+{
+    ACPI_STATUS             Status = AE_OK;
+    UINT32                  Value;
+
+
+    ACPI_FUNCTION_TRACE ("AcpiDisableEvent");
+
+
+    /* Decode the Fixed Event */
+
+    if (Event > ACPI_EVENT_MAX)
+    {
+        return_ACPI_STATUS (AE_BAD_PARAMETER);
+    }
+
    /*
-     * Only disable the requested GPE number for wake if specified.
-     * Otherwise, turn it totally off
+     * Disable the requested fixed event (by writing a zero to the
+     * enable register bit)
     */
-    if (Flags & ACPI_EVENT_WAKE_DISABLE)
+    Status = AcpiSetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
+                0, ACPI_MTX_LOCK);
+    if (ACPI_FAILURE (Status))
    {
-        AcpiHwDisableGpeForWakeup (GpeEventInfo);
+        return_ACPI_STATUS (Status);
    }
-    else
+
+    Status = AcpiGetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
+                &Value, ACPI_MTX_LOCK);
+    if (ACPI_FAILURE (Status))
    {
-        Status = AcpiHwDisableGpe (GpeEventInfo);
+        return_ACPI_STATUS (Status);
    }

-UnlockAndExit:
-    if (Flags & ACPI_NOT_ISR)
+    if (Value != 0)
    {
-        (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
+        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+            "Could not disable %s events\n", AcpiUtGetEventName (Event)));
+        return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
    }
+
    return_ACPI_STATUS (Status);
}

Index: sys/dev/acpi/acpica/Subsystem/evxfregn.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/evxfregn.c,v
retrieving revision 1.11
diff -u -r1.11 evxfregn.c
--- sys/dev/acpi/acpica/Subsystem/evxfregn.c    14 Feb 2004 16:57:24 -0000      1.11
+++ sys/dev/acpi/acpica/Subsystem/evxfregn.c    17 Jun 2004 04:08:44 -0000
@@ -2,7 +2,7 @@
 *
 * Module Name: evxfregn - External Interfaces, ACPI Operation Regions and
 *                         Address Spaces.
- *              xRevision: 61 $
+ *              xRevision: 63 $
 *
 *****************************************************************************/

@@ -123,7 +123,6 @@
#include "acpi.h"
#include "acnamesp.h"
#include "acevents.h"
-#include "acinterp.h"

#define _COMPONENT          ACPI_EVENTS
        ACPI_MODULE_NAME    ("evxfregn")
@@ -153,12 +152,8 @@
    ACPI_ADR_SPACE_SETUP    Setup,
    void                    *Context)
{
-    ACPI_OPERAND_OBJECT     *ObjDesc;
-    ACPI_OPERAND_OBJECT     *HandlerObj;
    ACPI_NAMESPACE_NODE     *Node;
    ACPI_STATUS             Status;
-    ACPI_OBJECT_TYPE        Type;
-    UINT16                  Flags = 0;


    ACPI_FUNCTION_TRACE ("AcpiInstallAddressSpaceHandler");
@@ -186,217 +181,17 @@
        goto UnlockAndExit;
    }

-    /*
-     * This registration is valid for only the types below
-     * and the root.  This is where the default handlers
-     * get placed.
-     */
-    if ((Node->Type != ACPI_TYPE_DEVICE)     &&
-        (Node->Type != ACPI_TYPE_PROCESSOR)  &&
-        (Node->Type != ACPI_TYPE_THERMAL)    &&
-        (Node != AcpiGbl_RootNode))
-    {
-        Status = AE_BAD_PARAMETER;
-        goto UnlockAndExit;
-    }
-
-    if (Handler == ACPI_DEFAULT_HANDLER)
-    {
-        Flags = ACPI_ADDR_HANDLER_DEFAULT_INSTALLED;
-
-        switch (SpaceId)
-        {
-        case ACPI_ADR_SPACE_SYSTEM_MEMORY:
-            Handler = AcpiExSystemMemorySpaceHandler;
-            Setup   = AcpiEvSystemMemoryRegionSetup;
-            break;
-
-        case ACPI_ADR_SPACE_SYSTEM_IO:
-            Handler = AcpiExSystemIoSpaceHandler;
-            Setup   = AcpiEvIoSpaceRegionSetup;
-            break;
-
-        case ACPI_ADR_SPACE_PCI_CONFIG:
-            Handler = AcpiExPciConfigSpaceHandler;
-            Setup   = AcpiEvPciConfigRegionSetup;
-            break;
-
-        case ACPI_ADR_SPACE_CMOS:
-            Handler = AcpiExCmosSpaceHandler;
-            Setup   = AcpiEvCmosRegionSetup;
-            break;
-
-        case ACPI_ADR_SPACE_PCI_BAR_TARGET:
-            Handler = AcpiExPciBarSpaceHandler;
-            Setup   = AcpiEvPciBarRegionSetup;
-            break;
-
-        case ACPI_ADR_SPACE_DATA_TABLE:
-            Handler = AcpiExDataTableSpaceHandler;
-            Setup   = NULL;
-            break;
-
-        default:
-            Status = AE_BAD_PARAMETER;
-            goto UnlockAndExit;
-        }
-    }
-
-    /* If the caller hasn't specified a setup routine, use the default */
-
-    if (!Setup)
-    {
-        Setup = AcpiEvDefaultRegionSetup;
-    }
-
-    /* Check for an existing internal object */
-
-    ObjDesc = AcpiNsGetAttachedObject (Node);
-    if (ObjDesc)
-    {
-        /*
-         * The attached device object already exists.
-         * Make sure the handler is not already installed.
-         */
-        HandlerObj = ObjDesc->Device.Handler;
-
-        /* Walk the handler list for this device */
-
-        while (HandlerObj)
-        {
-            /* Same SpaceId indicates a handler already installed */
-
-            if(HandlerObj->AddressSpace.SpaceId == SpaceId)
-            {
-                if (HandlerObj->AddressSpace.Handler == Handler)
-                {
-                    /*
-                     * It is (relatively) OK to attempt to install the SAME
-                     * handler twice. This can easily happen with PCI_Config space.
-                     */
-                    Status = AE_SAME_HANDLER;
-                    goto UnlockAndExit;
-                }
-                else
-                {
-                    /* A handler is already installed */
-
-                    Status = AE_ALREADY_EXISTS;
-                }
-                goto UnlockAndExit;
-            }
-
-            /* Walk the linked list of handlers */
-
-            HandlerObj = HandlerObj->AddressSpace.Next;
-        }
-    }
-    else
-    {
-        ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
-            "Creating object on Device %p while installing handler\n", Node));
-
-        /* ObjDesc does not exist, create one */
-
-        if (Node->Type == ACPI_TYPE_ANY)
-        {
-            Type = ACPI_TYPE_DEVICE;
-        }
-        else
-        {
-            Type = Node->Type;
-        }
-
-        ObjDesc = AcpiUtCreateInternalObject (Type);
-        if (!ObjDesc)
-        {
-            Status = AE_NO_MEMORY;
-            goto UnlockAndExit;
-        }
-
-        /* Init new descriptor */
-
-        ObjDesc->Common.Type = (UINT8) Type;
-
-        /* Attach the new object to the Node */
-
-        Status = AcpiNsAttachObject (Node, ObjDesc, Type);
-
-        /* Remove local reference to the object */
-
-        AcpiUtRemoveReference (ObjDesc);
+    /* Install the handler for all Regions for this Space ID */

-        if (ACPI_FAILURE (Status))
-        {
-            goto UnlockAndExit;
-        }
-    }
-
-    ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
-        "Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n",
-        AcpiUtGetRegionName (SpaceId), SpaceId,
-        AcpiUtGetNodeName (Node), Node, ObjDesc));
-
-    /*
-     * Install the handler
-     *
-     * At this point there is no existing handler.
-     * Just allocate the object for the handler and link it
-     * into the list.
-     */
-    HandlerObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_ADDRESS_HANDLER);
-    if (!HandlerObj)
+    Status = AcpiEvInstallSpaceHandler (Node, SpaceId, Handler, Setup, Context);
+    if (ACPI_FAILURE (Status))
    {
-        Status = AE_NO_MEMORY;
        goto UnlockAndExit;
    }

-    /* Init handler obj */
+    /* Run all _REG methods for this address space */

-    HandlerObj->AddressSpace.SpaceId     = (UINT8) SpaceId;
-    HandlerObj->AddressSpace.Hflags      = Flags;
-    HandlerObj->AddressSpace.RegionList  = NULL;
-    HandlerObj->AddressSpace.Node        = Node;
-    HandlerObj->AddressSpace.Handler     = Handler;
-    HandlerObj->AddressSpace.Context     = Context;
-    HandlerObj->AddressSpace.Setup       = Setup;
-
-    /* Install at head of Device.AddressSpace list */
-
-    HandlerObj->AddressSpace.Next        = ObjDesc->Device.Handler;
-
-    /*
-     * The Device object is the first reference on the HandlerObj.
-     * Each region that uses the handler adds a reference.
-     */
-    ObjDesc->Device.Handler = HandlerObj;
-
-    /*
-     * Walk the namespace finding all of the regions this
-     * handler will manage.
-     *
-     * Start at the device and search the branch toward
-     * the leaf nodes until either the leaf is encountered or
-     * a device is detected that has an address handler of the
-     * same type.
-     *
-     * In either case, back up and search down the remainder
-     * of the branch
-     */
-    Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Device, ACPI_UINT32_MAX,
-                    ACPI_NS_WALK_UNLOCK, AcpiEvInstallHandler,
-                    HandlerObj, NULL);
-
-    /*
-     * Now we can run the _REG methods for all Regions for this
-     * space ID.  This is a separate walk in order to handle any
-     * interdependencies between regions and _REG methods.  (i.e. handlers
-     * must be installed for all regions of this Space ID before we
-     * can run any _REG methods.
-     */
-    Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Device, ACPI_UINT32_MAX,
-                    ACPI_NS_WALK_UNLOCK, AcpiEvRegRun,
-                    HandlerObj, NULL);
+    Status = AcpiEvExecuteRegMethods (Node, SpaceId);

UnlockAndExit:
    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
Index: sys/dev/acpi/acpica/Subsystem/exconfig.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/exconfig.c,v
retrieving revision 1.10
diff -u -r1.10 exconfig.c
--- sys/dev/acpi/acpica/Subsystem/exconfig.c    14 Feb 2004 16:57:24 -0000      1.10
+++ sys/dev/acpi/acpica/Subsystem/exconfig.c    17 Jun 2004 04:08:44 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Module Name: exconfig - Namespace reconfiguration (Load/Unload opcodes)
- *              xRevision: 75 $
+ *              xRevision: 78 $
 *
 *****************************************************************************/

@@ -126,6 +126,7 @@
#include "acnamesp.h"
#include "acevents.h"
#include "actables.h"
+#include "acdispat.h"


#define _COMPONENT          ACPI_EXECUTER
@@ -378,7 +379,7 @@
    ACPI_OPERAND_OBJECT     *DdbHandle;
    ACPI_OPERAND_OBJECT     *BufferDesc = NULL;
    ACPI_TABLE_HEADER       *TablePtr = NULL;
-    UINT8                   *TableDataPtr;
+    ACPI_PHYSICAL_ADDRESS   Address;
    ACPI_TABLE_HEADER       TableHeader;
    UINT32                  i;

@@ -394,13 +395,30 @@
        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Load from Region %p %s\n",
            ObjDesc, AcpiUtGetObjectTypeName (ObjDesc)));

-        /* Get the table header */
+        /*
+         * If the Region Address and Length have not been previously evaluated,
+         * evaluate them now and save the results.
+         */
+        if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
+        {
+            Status = AcpiDsGetRegionArguments (ObjDesc);
+            if (ACPI_FAILURE (Status))
+            {
+                return_ACPI_STATUS (Status);
+            }
+        }
+
+        /* Get the base physical address of the region */
+
+        Address = ObjDesc->Region.Address;
+
+        /* Get the table length from the table header */

        TableHeader.Length = 0;
-        for (i = 0; i < sizeof (ACPI_TABLE_HEADER); i++)
+        for (i = 0; i < 8; i++)
        {
            Status = AcpiEvAddressSpaceDispatch (ObjDesc, ACPI_READ,
-                                (ACPI_PHYSICAL_ADDRESS) i, 8,
+                                (ACPI_PHYSICAL_ADDRESS) (i + Address), 8,
                                ((UINT8 *) &TableHeader) + i);
            if (ACPI_FAILURE (Status))
            {
@@ -408,6 +426,13 @@
            }
        }

+        /* Sanity check the table length */
+
+        if (TableHeader.Length < sizeof (ACPI_TABLE_HEADER))
+        {
+            return_ACPI_STATUS (AE_BAD_HEADER);
+        }
+
        /* Allocate a buffer for the entire table */

        TablePtr = ACPI_MEM_ALLOCATE (TableHeader.Length);
@@ -416,18 +441,13 @@
            return_ACPI_STATUS (AE_NO_MEMORY);
        }

-        /* Copy the header to the buffer */
-
-        ACPI_MEMCPY (TablePtr, &TableHeader, sizeof (ACPI_TABLE_HEADER));
-        TableDataPtr = ACPI_PTR_ADD (UINT8, TablePtr, sizeof (ACPI_TABLE_HEADER));
-
-        /* Get the table from the op region */
+        /* Get the entire table from the op region */

        for (i = 0; i < TableHeader.Length; i++)
        {
            Status = AcpiEvAddressSpaceDispatch (ObjDesc, ACPI_READ,
-                                (ACPI_PHYSICAL_ADDRESS) i, 8,
-                                ((UINT8 *) TableDataPtr + i));
+                                (ACPI_PHYSICAL_ADDRESS) (i + Address), 8,
+                                ((UINT8 *) TablePtr + i));
            if (ACPI_FAILURE (Status))
            {
                goto Cleanup;
@@ -455,6 +475,13 @@
        }

        TablePtr = ACPI_CAST_PTR (ACPI_TABLE_HEADER, BufferDesc->Buffer.Pointer);
+
+         /* Sanity check the table length */
+
+        if (TablePtr->Length < sizeof (ACPI_TABLE_HEADER))
+        {
+            return_ACPI_STATUS (AE_BAD_HEADER);
+        }
        break;


Index: sys/dev/acpi/acpica/Subsystem/excreate.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/excreate.c,v
retrieving revision 1.10
diff -u -r1.10 excreate.c
--- sys/dev/acpi/acpica/Subsystem/excreate.c    14 Feb 2004 16:57:24 -0000      1.10
+++ sys/dev/acpi/acpica/Subsystem/excreate.c    17 Jun 2004 04:08:44 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Module Name: excreate - Named object creation
- *              xRevision: 101 $
+ *              xRevision: 103 $
 *
 *****************************************************************************/

@@ -162,7 +162,8 @@
    AliasNode =  (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
    TargetNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[1];

-    if (TargetNode->Type == ACPI_TYPE_LOCAL_ALIAS)
+    if ((TargetNode->Type == ACPI_TYPE_LOCAL_ALIAS)  ||
+        (TargetNode->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS))
    {
        /*
         * Dereference an existing alias so that we don't create a chain
@@ -170,7 +171,7 @@
         * always exactly one level of indirection away from the
         * actual aliased name.
         */
-        TargetNode = (ACPI_NAMESPACE_NODE *) TargetNode->Object;
+        TargetNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, TargetNode->Object);
    }

    /*
@@ -197,6 +198,17 @@
        AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
        break;

+    case ACPI_TYPE_METHOD:
+
+        /*
+         * The new alias has the type ALIAS and points to the original
+         * NS node, not the object itself.  This is because for these
+         * types, the object can change dynamically via a Store.
+         */
+        AliasNode->Type = ACPI_TYPE_LOCAL_METHOD_ALIAS;
+        AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
+        break;
+
    default:

        /* Attach the original source object to the new Alias Node */
@@ -684,29 +696,36 @@
    ObjDesc->Method.AmlStart  = AmlStart;
    ObjDesc->Method.AmlLength = AmlLength;

-    /* disassemble the method flags */
-
+    /*
+     * Disassemble the method flags.  Split off the Arg Count
+     * for efficiency
+     */
    MethodFlags = (UINT8) Operand[1]->Integer.Value;

-    ObjDesc->Method.MethodFlags = MethodFlags;
-    ObjDesc->Method.ParamCount  = (UINT8) (MethodFlags & METHOD_FLAGS_ARG_COUNT);
+    ObjDesc->Method.MethodFlags = (UINT8) (MethodFlags & ~AML_METHOD_ARG_COUNT);
+    ObjDesc->Method.ParamCount  = (UINT8) (MethodFlags & AML_METHOD_ARG_COUNT);

    /*
     * Get the concurrency count.  If required, a semaphore will be
     * created for this method when it is parsed.
     */
-    if (MethodFlags & METHOD_FLAGS_SERIALIZED)
+    if (AcpiGbl_AllMethodsSerialized)
+    {
+        ObjDesc->Method.Concurrency = 1;
+        ObjDesc->Method.MethodFlags |= AML_METHOD_SERIALIZED;
+    }
+    else if (MethodFlags & AML_METHOD_SERIALIZED)
    {
        /*
         * ACPI 1.0: Concurrency = 1
         * ACPI 2.0: Concurrency = (SyncLevel (in method declaration) + 1)
         */
        ObjDesc->Method.Concurrency = (UINT8)
-                        (((MethodFlags & METHOD_FLAGS_SYNCH_LEVEL) >> 4) + 1);
+                        (((MethodFlags & AML_METHOD_SYNCH_LEVEL) >> 4) + 1);
    }
    else
    {
-        ObjDesc->Method.Concurrency = INFINITE_CONCURRENCY;
+        ObjDesc->Method.Concurrency = ACPI_INFINITE_CONCURRENCY;
    }

    /* Attach the new object to the method Node */
Index: sys/dev/acpi/acpica/Subsystem/exdump.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/exdump.c,v
retrieving revision 1.10
diff -u -r1.10 exdump.c
--- sys/dev/acpi/acpica/Subsystem/exdump.c      14 Feb 2004 16:57:24 -0000      1.10
+++ sys/dev/acpi/acpica/Subsystem/exdump.c      17 Jun 2004 04:08:45 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Module Name: exdump - Interpreter debug output routines
- *              xRevision: 172 $
+ *              xRevision: 173 $
 *
 *****************************************************************************/

@@ -884,6 +884,7 @@


    case ACPI_TYPE_LOCAL_ALIAS:
+    case ACPI_TYPE_LOCAL_METHOD_ALIAS:
    case ACPI_TYPE_LOCAL_EXTRA:
    case ACPI_TYPE_LOCAL_DATA:
    default:
Index: sys/dev/acpi/acpica/Subsystem/exfldio.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/exfldio.c,v
retrieving revision 1.11
diff -u -r1.11 exfldio.c
--- sys/dev/acpi/acpica/Subsystem/exfldio.c     14 Feb 2004 16:57:24 -0000      1.11
+++ sys/dev/acpi/acpica/Subsystem/exfldio.c     17 Jun 2004 04:08:45 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Module Name: exfldio - Aml Field I/O
- *              xRevision: 103 $
+ *              xRevision: 106 $
 *
 *****************************************************************************/

@@ -355,7 +355,7 @@
        }
        else if (Status == AE_NOT_EXIST)
        {
-            ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+            ACPI_REPORT_ERROR ((
                "Region %s(%X) has no handler\n",
                AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
                RgnDesc->Region.SpaceId));
@@ -868,14 +868,84 @@

/*******************************************************************************
 *
+ * FUNCTION:    AcpiExCommonBufferSetup
+ *
+ * PARAMETERS:  ObjDesc             - Field object
+ *              BufferLength        - Length of caller's buffer
+ *              DatumCount          - Where the DatumCount is returned
+ *
+ * RETURN:      Status, DatumCount
+ *
+ * DESCRIPTION: Common code to validate the incoming buffer size and compute
+ *              the number of field "datums" that must be read or written.
+ *              A "datum" is the smallest unit that can be read or written
+ *              to the field, it is either 1,2,4, or 8 bytes.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExCommonBufferSetup (
+    ACPI_OPERAND_OBJECT     *ObjDesc,
+    UINT32                  BufferLength,
+    UINT32                  *DatumCount)
+{
+    UINT32                  ByteFieldLength;
+    UINT32                  ActualByteFieldLength;
+
+
+    ACPI_FUNCTION_TRACE ("ExCommonBufferSetup");
+
+
+    /*
+     * Incoming buffer must be at least as long as the field, we do not
+     * allow "partial" field reads/writes.  We do not care if the buffer is
+     * larger than the field, this typically happens when an integer is
+     * read/written to a field that is actually smaller than an integer.
+     */
+    ByteFieldLength = ACPI_ROUND_BITS_UP_TO_BYTES (
+                            ObjDesc->CommonField.BitLength);
+    if (ByteFieldLength > BufferLength)
+    {
+        ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+            "Field size %X (bytes) is too large for buffer (%X)\n",
+            ByteFieldLength, BufferLength));
+
+        return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
+    }
+
+    /*
+     * Create "actual" field byte count (minimum number of bytes that
+     * must be read), then convert to datum count (minimum number
+     * of datum-sized units that must be read)
+     */
+    ActualByteFieldLength = ACPI_ROUND_BITS_UP_TO_BYTES (
+                                ObjDesc->CommonField.StartFieldBitOffset +
+                                ObjDesc->CommonField.BitLength);
+
+
+    *DatumCount = ACPI_ROUND_UP_TO (ActualByteFieldLength,
+                        ObjDesc->CommonField.AccessByteWidth);
+
+    ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+        "BufferBytes %X, ActualBytes %X, Datums %X, ByteGran %X\n",
+        ByteFieldLength, ActualByteFieldLength,
+        *DatumCount, ObjDesc->CommonField.AccessByteWidth));
+
+    return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
 * FUNCTION:    AcpiExExtractFromField
 *
- * PARAMETERS:  *ObjDesc            - Field to be read
- *              *Value              - Where to store value
+ * PARAMETERS:  ObjDesc             - Field to be read
+ *              Buffer              - Where to store the field data
+ *              BufferLength        - Length of Buffer
 *
 * RETURN:      Status
 *
- * DESCRIPTION: Retrieve the value of the given field
+ * DESCRIPTION: Retrieve the current value of the given field
 *
 ******************************************************************************/

@@ -891,7 +961,6 @@
    ACPI_INTEGER            PreviousRawDatum = 0;
    ACPI_INTEGER            ThisRawDatum = 0;
    ACPI_INTEGER            MergedDatum = 0;
-    UINT32                  ByteFieldLength;
    UINT32                  DatumCount;
    UINT32                  i;

@@ -899,41 +968,14 @@
    ACPI_FUNCTION_TRACE ("ExExtractFromField");


-    /*
-     * The field must fit within the caller's buffer
-     */
-    ByteFieldLength = ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength);
-    if (ByteFieldLength > BufferLength)
-    {
-        ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
-            "Field size %X (bytes) too large for buffer (%X)\n",
-            ByteFieldLength, BufferLength));
-
-        return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
-    }
-
-    /* Convert field byte count to datum count, round up if necessary */
-
-    DatumCount = ACPI_ROUND_UP_TO (ByteFieldLength,
-                              ObjDesc->CommonField.AccessByteWidth);
+    /* Validate buffer, compute number of datums */

-    /*
-     * If the field is not aligned on a datum boundary and does not
-     * fit within a single datum, we must read an extra datum.
-     *
-     * We could just split the aligned and non-aligned cases since the
-     * aligned case is so very simple, but this would require more code.
-     */
-    if ((ObjDesc->CommonField.EndFieldValidBits != 0)         &&
-        (!(ObjDesc->CommonField.Flags & AOPOBJ_SINGLE_DATUM)))
+    Status = AcpiExCommonBufferSetup (ObjDesc, BufferLength, &DatumCount);
+    if (ACPI_FAILURE (Status))
    {
-        DatumCount++;
+        return_ACPI_STATUS (Status);
    }

-    ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
-        "ByteLen %X, DatumLen %X, ByteGran %X\n",
-        ByteFieldLength, DatumCount,ObjDesc->CommonField.AccessByteWidth));
-
    /*
     * Clear the caller's buffer (the whole buffer length as given)
     * This is very important, especially in the cases where the buffer
@@ -1055,12 +1097,13 @@
 *
 * FUNCTION:    AcpiExInsertIntoField
 *
- * PARAMETERS:  *ObjDesc            - Field to be set
- *              Buffer              - Value to store
+ * PARAMETERS:  ObjDesc             - Field to be written
+ *              Buffer              - Data to be written
+ *              BufferLength        - Length of Buffer
 *
 * RETURN:      Status
 *
- * DESCRIPTION: Store the value into the given field
+ * DESCRIPTION: Store the Buffer contents into the given field
 *
 ******************************************************************************/

@@ -1077,43 +1120,20 @@
    ACPI_INTEGER            MergedDatum;
    ACPI_INTEGER            PreviousRawDatum;
    ACPI_INTEGER            ThisRawDatum;
-    UINT32                  ByteFieldLength;
    UINT32                  DatumCount;


    ACPI_FUNCTION_TRACE ("ExInsertIntoField");


-    /*
-     * Incoming buffer must be at least as long as the field, we do not
-     * allow "partial" field writes.  We do not care if the buffer is
-     * larger than the field, this typically happens when an integer is
-     * written to a field that is actually smaller than an integer.
-     */
-    ByteFieldLength = ACPI_ROUND_BITS_UP_TO_BYTES (
-                            ObjDesc->CommonField.BitLength);
-    if (BufferLength < ByteFieldLength)
-    {
-        ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
-            "Buffer length %X too small for field %X\n",
-            BufferLength, ByteFieldLength));
+    /* Validate buffer, compute number of datums */

-        return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
+    Status = AcpiExCommonBufferSetup (ObjDesc, BufferLength, &DatumCount);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
    }

-    ByteFieldLength = ACPI_ROUND_BITS_UP_TO_BYTES (
-                            ObjDesc->CommonField.StartFieldBitOffset +
-                            ObjDesc->CommonField.BitLength);
-
-    /* Convert byte count to datum count, round up if necessary */
-
-    DatumCount = ACPI_ROUND_UP_TO (ByteFieldLength,
-                                   ObjDesc->CommonField.AccessByteWidth);
-
-    ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
-        "Bytes %X, Datums %X, ByteGran %X\n",
-        ByteFieldLength, DatumCount, ObjDesc->CommonField.AccessByteWidth));
-
    /*
     * Break the request into up to three parts (similar to an I/O request):
     * 1) non-aligned part at start
Index: sys/dev/acpi/acpica/Subsystem/exmutex.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/exmutex.c,v
retrieving revision 1.13
diff -u -r1.13 exmutex.c
--- sys/dev/acpi/acpica/Subsystem/exmutex.c     7 Apr 2004 18:19:34 -0000       1.13
+++ sys/dev/acpi/acpica/Subsystem/exmutex.c     17 Jun 2004 04:08:45 -0000
@@ -2,7 +2,7 @@
/******************************************************************************
 *
 * Module Name: exmutex - ASL Mutex Acquire/Release functions
- *              xRevision: 20 $
+ *              xRevision: 24 $
 *
 *****************************************************************************/

@@ -131,7 +131,7 @@
 *
 * FUNCTION:    AcpiExUnlinkMutex
 *
- * PARAMETERS:  *ObjDesc            - The mutex to be unlinked
+ * PARAMETERS:  ObjDesc             - The mutex to be unlinked
 *
 * RETURN:      Status
 *
@@ -151,6 +151,8 @@
        return;
    }

+    /* Doubly linked list */
+
    if (ObjDesc->Mutex.Next)
    {
        (ObjDesc->Mutex.Next)->Mutex.Prev = ObjDesc->Mutex.Prev;
@@ -171,8 +173,8 @@
 *
 * FUNCTION:    AcpiExLinkMutex
 *
- * PARAMETERS:  *ObjDesc            - The mutex to be linked
- *              *ListHead           - head of the "AcquiredMutex" list
+ * PARAMETERS:  ObjDesc             - The mutex to be linked
+ *              ListHead            - head of the "AcquiredMutex" list
 *
 * RETURN:      Status
 *
@@ -212,8 +214,8 @@
 *
 * FUNCTION:    AcpiExAcquireMutex
 *
- * PARAMETERS:  *TimeDesc           - The 'time to delay' object descriptor
- *              *ObjDesc            - The object descriptor for this op
+ * PARAMETERS:  TimeDesc            - The 'time to delay' object descriptor
+ *              ObjDesc             - The object descriptor for this op
 *
 * RETURN:      Status
 *
@@ -258,19 +260,22 @@
        return_ACPI_STATUS (AE_AML_MUTEX_ORDER);
    }

-    /*
-     * Support for multiple acquires by the owning thread
-     */
+    /* Support for multiple acquires by the owning thread */

-    if ((ObjDesc->Mutex.OwnerThread) &&
-        (ObjDesc->Mutex.OwnerThread->ThreadId == WalkState->Thread->ThreadId))
+    if (ObjDesc->Mutex.OwnerThread)
    {
-        /*
-         * The mutex is already owned by this thread,
-         * just increment the acquisition depth
-         */
-        ObjDesc->Mutex.AcquisitionDepth++;
-        return_ACPI_STATUS (AE_OK);
+        /* Special case for Global Lock, allow all threads */
+
+        if ((ObjDesc->Mutex.OwnerThread->ThreadId == WalkState->Thread->ThreadId) ||
+            (ObjDesc->Mutex.Semaphore == AcpiGbl_GlobalLockSemaphore))
+        {
+            /*
+             * The mutex is already owned by this thread,
+             * just increment the acquisition depth
+             */
+            ObjDesc->Mutex.AcquisitionDepth++;
+            return_ACPI_STATUS (AE_OK);
+        }
    }

    /* Acquire the mutex, wait if necessary */
@@ -283,12 +288,12 @@
        return_ACPI_STATUS (Status);
    }

-    /* Have the mutex, update mutex and walk info */
+    /* Have the mutex: update mutex and walk info and save the SyncLevel */

-    ObjDesc->Mutex.OwnerThread      = WalkState->Thread;
-    ObjDesc->Mutex.AcquisitionDepth = 1;
+    ObjDesc->Mutex.OwnerThread       = WalkState->Thread;
+    ObjDesc->Mutex.AcquisitionDepth  = 1;
+    ObjDesc->Mutex.OriginalSyncLevel = WalkState->Thread->CurrentSyncLevel;

-    ObjDesc->Mutex.PreviousSyncLevel = WalkState->Thread->CurrentSyncLevel;
    WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.SyncLevel;

    /* Link the mutex to the current thread for force-unlock at method exit */
@@ -303,7 +308,7 @@
 *
 * FUNCTION:    AcpiExReleaseMutex
 *
- * PARAMETERS:  *ObjDesc            - The object descriptor for this op
+ * PARAMETERS:  ObjDesc             - The object descriptor for this op
 *
 * RETURN:      Status
 *
@@ -345,9 +350,12 @@
        return_ACPI_STATUS (AE_AML_INTERNAL);
    }

-    /* The Mutex is owned, but this thread must be the owner */
-
-    if (ObjDesc->Mutex.OwnerThread->ThreadId != WalkState->Thread->ThreadId)
+    /*
+     * The Mutex is owned, but this thread must be the owner.
+     * Special case for Global Lock, any thread can release
+     */
+    if ((ObjDesc->Mutex.OwnerThread->ThreadId != WalkState->Thread->ThreadId) &&
+        (ObjDesc->Mutex.Semaphore != AcpiGbl_GlobalLockSemaphore))
    {
        ACPI_REPORT_ERROR ((
            "Thread %X cannot release Mutex [%4.4s] acquired by thread %X\n",
@@ -368,9 +376,8 @@
        return_ACPI_STATUS (AE_AML_MUTEX_ORDER);
    }

-    /*
-     * Match multiple Acquires with multiple Releases
-     */
+    /* Match multiple Acquires with multiple Releases */
+
    ObjDesc->Mutex.AcquisitionDepth--;
    if (ObjDesc->Mutex.AcquisitionDepth != 0)
    {
@@ -387,10 +394,10 @@

    Status = AcpiExSystemReleaseMutex (ObjDesc);

-    /* Update the mutex and walk state */
+    /* Update the mutex and walk state, restore SyncLevel before acquire */

    ObjDesc->Mutex.OwnerThread = NULL;
-    WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.PreviousSyncLevel;
+    WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.OriginalSyncLevel;

    return_ACPI_STATUS (Status);
}
@@ -400,7 +407,7 @@
 *
 * FUNCTION:    AcpiExReleaseAllMutexes
 *
- * PARAMETERS:  *MutexList            - Head of the mutex list
+ * PARAMETERS:  MutexList             - Head of the mutex list
 *
 * RETURN:      Status
 *
@@ -420,9 +427,8 @@
    ACPI_FUNCTION_ENTRY ();


-    /*
-     * Traverse the list of owned mutexes, releasing each one.
-     */
+    /* Traverse the list of owned mutexes, releasing each one */
+
    while (Next)
    {
        This = Next;
@@ -442,7 +448,11 @@

        /* Mark mutex unowned */

-        This->Mutex.OwnerThread      = NULL;
+        This->Mutex.OwnerThread = NULL;
+
+        /* Update Thread SyncLevel (Last mutex is the important one) */
+
+        Thread->CurrentSyncLevel = This->Mutex.OriginalSyncLevel;
    }
}

Index: sys/dev/acpi/acpica/Subsystem/exoparg2.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/exoparg2.c,v
retrieving revision 1.9
diff -u -r1.9 exoparg2.c
--- sys/dev/acpi/acpica/Subsystem/exoparg2.c    14 Feb 2004 16:57:24 -0000      1.9
+++ sys/dev/acpi/acpica/Subsystem/exoparg2.c    17 Jun 2004 04:08:45 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Module Name: exoparg2 - AML execution - opcodes with 2 arguments
- *              xRevision: 119 $
+ *              xRevision: 121 $
 *
 *****************************************************************************/

@@ -175,6 +175,7 @@
{
    ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
    ACPI_NAMESPACE_NODE     *Node;
+    UINT32                  Value;
    ACPI_STATUS             Status = AE_OK;


@@ -192,17 +193,49 @@

        Node = (ACPI_NAMESPACE_NODE *) Operand[0];

+        /* Second value is the notify value */
+
+        Value = (UINT32) Operand[1]->Integer.Value;
+
        /* Notifies allowed on this object? */

        if (!AcpiEvIsNotifyObject (Node))
        {
-            ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unexpected notify object type [%s]\n",
+            ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+                    "Unexpected notify object type [%s]\n",
                    AcpiUtGetTypeName (Node->Type)));

            Status = AE_AML_OPERAND_TYPE;
            break;
        }

+#ifdef ACPI_GPE_NOTIFY_CHECK
+        /*
+         * GPE method wake/notify check.  Here, we want to ensure that we
+         * don't receive any "DeviceWake" Notifies from a GPE _Lxx or _Exx
+         * GPE method during system runtime.  If we do, the GPE is marked
+         * as "wake-only" and disabled.
+         *
+         * 1) Is the Notify() value == DeviceWake?
+         * 2) Is this a GPE deferred method?  (An _Lxx or _Exx method)
+         * 3) Did the original GPE happen at system runtime?
+         *    (versus during wake)
+         *
+         * If all three cases are true, this is a wake-only GPE that should
+         * be disabled at runtime.
+         */
+        if (Value == 2)     /* DeviceWake */
+        {
+            Status = AcpiEvCheckForWakeOnlyGpe (WalkState->GpeEventInfo);
+            if (ACPI_FAILURE (Status))
+            {
+                /* AE_WAKE_ONLY_GPE only error, means ignore this notify */
+
+                return_ACPI_STATUS (AE_OK)
+            }
+        }
+#endif
+
        /*
         * Dispatch the notify to the appropriate handler
         * NOTE: the request is queued for execution after this method
@@ -210,8 +243,7 @@
         * from this thread -- because handlers may in turn run other
         * control methods.
         */
-        Status = AcpiEvQueueNotifyRequest (Node,
-                        (UINT32) Operand[1]->Integer.Value);
+        Status = AcpiEvQueueNotifyRequest (Node, Value);
        break;


Index: sys/dev/acpi/acpica/Subsystem/exresnte.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/exresnte.c,v
retrieving revision 1.10
diff -u -r1.10 exresnte.c
--- sys/dev/acpi/acpica/Subsystem/exresnte.c    14 Feb 2004 16:57:24 -0000      1.10
+++ sys/dev/acpi/acpica/Subsystem/exresnte.c    17 Jun 2004 04:08:46 -0000
@@ -2,7 +2,7 @@
/******************************************************************************
 *
 * Module Name: exresnte - AML Interpreter object resolution
- *              xRevision: 64 $
+ *              xRevision: 65 $
 *
 *****************************************************************************/

@@ -185,11 +185,12 @@
    ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Entry=%p SourceDesc=%p [%s]\n",
         Node, SourceDesc, AcpiUtGetTypeName (EntryType)));

-    if (EntryType == ACPI_TYPE_LOCAL_ALIAS)
+    if ((EntryType == ACPI_TYPE_LOCAL_ALIAS) ||
+        (EntryType == ACPI_TYPE_LOCAL_METHOD_ALIAS))
    {
        /* There is always exactly one level of indirection */

-        Node       = (ACPI_NAMESPACE_NODE *) Node->Object;
+        Node       = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Node->Object);
        SourceDesc = AcpiNsGetAttachedObject (Node);
        EntryType  = AcpiNsGetType ((ACPI_HANDLE) Node);
        *ObjectPtr = Node;
Index: sys/dev/acpi/acpica/Subsystem/exresolv.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/exresolv.c,v
retrieving revision 1.10
diff -u -r1.10 exresolv.c
--- sys/dev/acpi/acpica/Subsystem/exresolv.c    14 Feb 2004 16:57:24 -0000      1.10
+++ sys/dev/acpi/acpica/Subsystem/exresolv.c    17 Jun 2004 04:08:46 -0000
@@ -2,7 +2,7 @@
/******************************************************************************
 *
 * Module Name: exresolv - AML Interpreter object resolution
- *              xRevision: 123 $
+ *              xRevision: 124 $
 *
 *****************************************************************************/

@@ -272,15 +272,15 @@
                return_ACPI_STATUS (Status);
            }

+            ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %X] ValueObj is %p\n",
+                StackDesc->Reference.Offset, ObjDesc));
+
            /*
             * Now we can delete the original Reference Object and
-             * replace it with the resolve value
+             * replace it with the resolved value
             */
            AcpiUtRemoveReference (StackDesc);
            *StackPtr = ObjDesc;
-
-            ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %d] ValueObj is %p\n",
-                StackDesc->Reference.Offset, ObjDesc));
            break;


Index: sys/dev/acpi/acpica/Subsystem/exstore.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/exstore.c,v
retrieving revision 1.11
diff -u -r1.11 exstore.c
--- sys/dev/acpi/acpica/Subsystem/exstore.c     14 Feb 2004 16:57:24 -0000      1.11
+++ sys/dev/acpi/acpica/Subsystem/exstore.c     17 Jun 2004 04:08:46 -0000
@@ -2,7 +2,7 @@
/******************************************************************************
 *
 * Module Name: exstore - AML Interpreter object store support
- *              xRevision: 180 $
+ *              xRevision: 182 $
 *
 *****************************************************************************/

@@ -181,7 +181,8 @@
         * Storing an object into a Named node.
         */
        Status = AcpiExStoreObjectToNode (SourceDesc,
-                    (ACPI_NAMESPACE_NODE *) DestDesc, WalkState);
+                    (ACPI_NAMESPACE_NODE *) DestDesc, WalkState,
+                    ACPI_IMPLICIT_CONVERSION);

        return_ACPI_STATUS (Status);
    }
@@ -235,7 +236,7 @@
        /* Storing an object into a Name "container" */

        Status = AcpiExStoreObjectToNode (SourceDesc, RefDesc->Reference.Object,
-                        WalkState);
+                        WalkState, ACPI_IMPLICIT_CONVERSION);
        break;


@@ -281,14 +282,14 @@

            ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length 0x%.2X",
                    (UINT32) SourceDesc->Buffer.Length));
-            ACPI_DUMP_BUFFER (SourceDesc->Buffer.Pointer,
+            ACPI_DUMP_BUFFER (SourceDesc->Buffer.Pointer,
                (SourceDesc->Buffer.Length < 32) ? SourceDesc->Buffer.Length : 32);
            break;


        case ACPI_TYPE_STRING:

-            ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length 0x%.2X, \"%s\"\n",
+            ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length 0x%.2X, \"%s\"\n",
                    SourceDesc->String.Length, SourceDesc->String.Pointer));
            break;

@@ -489,6 +490,7 @@
 * PARAMETERS:  SourceDesc              - Value to be stored
 *              Node                    - Named object to receive the value
 *              WalkState               - Current walk state
+ *              ImplicitConversion      - Perform implicit conversion (yes/no)
 *
 * RETURN:      Status
 *
@@ -511,7 +513,8 @@
AcpiExStoreObjectToNode (
    ACPI_OPERAND_OBJECT     *SourceDesc,
    ACPI_NAMESPACE_NODE     *Node,
-    ACPI_WALK_STATE         *WalkState)
+    ACPI_WALK_STATE         *WalkState,
+    UINT8                   ImplicitConversion)
{
    ACPI_STATUS             Status = AE_OK;
    ACPI_OPERAND_OBJECT     *TargetDesc;
@@ -542,6 +545,15 @@
        return_ACPI_STATUS (Status);
    }

+    /* If no implicit conversion, drop into the default case below */
+
+    if (!ImplicitConversion)
+    {
+        /* Force execution of default (no implicit conversion) */
+
+        TargetType = ACPI_TYPE_ANY;
+    }
+
    /*
     * Do the actual store operation
     */
Index: sys/dev/acpi/acpica/Subsystem/exstoren.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/exstoren.c,v
retrieving revision 1.10
diff -u -r1.10 exstoren.c
--- sys/dev/acpi/acpica/Subsystem/exstoren.c    14 Feb 2004 16:57:24 -0000      1.10
+++ sys/dev/acpi/acpica/Subsystem/exstoren.c    17 Jun 2004 04:08:46 -0000
@@ -3,7 +3,7 @@
 *
 * Module Name: exstoren - AML Interpreter object store support,
 *                        Store to Node (namespace object)
- *              xRevision: 58 $
+ *              xRevision: 59 $
 *
 *****************************************************************************/

@@ -220,6 +220,7 @@


    case ACPI_TYPE_LOCAL_ALIAS:
+    case ACPI_TYPE_LOCAL_METHOD_ALIAS:

        /*
         * Aliases are resolved by AcpiExPrepOperands
Index: sys/dev/acpi/acpica/Subsystem/hwgpe.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/hwgpe.c,v
retrieving revision 1.10
diff -u -r1.10 hwgpe.c
--- sys/dev/acpi/acpica/Subsystem/hwgpe.c       14 Feb 2004 16:57:24 -0000      1.10
+++ sys/dev/acpi/acpica/Subsystem/hwgpe.c       17 Jun 2004 04:08:46 -0000
@@ -2,7 +2,7 @@
/******************************************************************************
 *
 * Module Name: hwgpe - Low level GPE enable/disable/clear functions
- *              xRevision: 55 $
+ *              xRevision: 62 $
 *
 *****************************************************************************/

@@ -127,104 +127,24 @@

/******************************************************************************
 *
- * FUNCTION:    AcpiHwEnableGpe
+ * FUNCTION:    AcpiHwWriteGpeEnableReg
 *
- * PARAMETERS:  GpeNumber       - The GPE
+ * PARAMETERS:  GpeEventInfo        - Info block for the GPE to be enabled
 *
- * RETURN:      None
+ * RETURN:      Status
 *
- * DESCRIPTION: Enable a single GPE.
+ * DESCRIPTION: Write a GPE enable register.  Note: The bit for this GPE must
+ *              already be cleared or set in the parent register
+ *              EnableForRun mask.
 *
 ******************************************************************************/

ACPI_STATUS
-AcpiHwEnableGpe (
-    ACPI_GPE_EVENT_INFO     *GpeEventInfo)
-{
-    UINT32                  InByte;
-    ACPI_STATUS             Status;
-
-
-    ACPI_FUNCTION_ENTRY ();
-
-
-    /*
-     * Read the current value of the register, set the appropriate bit
-     * to enable the GPE, and write out the new register.
-     */
-    Status = AcpiHwLowLevelRead (8, &InByte,
-                    &GpeEventInfo->RegisterInfo->EnableAddress);
-    if (ACPI_FAILURE (Status))
-    {
-        return (Status);
-    }
-
-    /* Write with the new GPE bit enabled */
-
-    Status = AcpiHwLowLevelWrite (8, (InByte | GpeEventInfo->BitMask),
-                    &GpeEventInfo->RegisterInfo->EnableAddress);
-
-    return (Status);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    AcpiHwEnableGpeForWakeup
- *
- * PARAMETERS:  GpeNumber       - The GPE
- *
- * RETURN:      None
- *
- * DESCRIPTION: Keep track of which GPEs the OS has requested not be
- *              disabled when going to sleep.
- *
- ******************************************************************************/
-
-void
-AcpiHwEnableGpeForWakeup (
+AcpiHwWriteGpeEnableReg (
    ACPI_GPE_EVENT_INFO     *GpeEventInfo)
{
    ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
-
-
-    ACPI_FUNCTION_ENTRY ();
-
-
-    /* Get the info block for the entire GPE register */
-
-    GpeRegisterInfo = GpeEventInfo->RegisterInfo;
-    if (!GpeRegisterInfo)
-    {
-        return;
-    }
-
-    /*
-     * Set the bit so we will not disable this when sleeping
-     */
-    GpeRegisterInfo->WakeEnable |= GpeEventInfo->BitMask;
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    AcpiHwDisableGpe
- *
- * PARAMETERS:  GpeNumber       - The GPE
- *
- * RETURN:      None
- *
- * DESCRIPTION: Disable a single GPE.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiHwDisableGpe (
-    ACPI_GPE_EVENT_INFO     *GpeEventInfo)
-{
-    UINT32                  InByte;
    ACPI_STATUS             Status;
-    ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;


    ACPI_FUNCTION_ENTRY ();
@@ -235,69 +155,15 @@
    GpeRegisterInfo = GpeEventInfo->RegisterInfo;
    if (!GpeRegisterInfo)
    {
-        return (AE_BAD_PARAMETER);
-    }
-
-    /*
-     * Read the current value of the register, clear the appropriate bit,
-     * and write out the new register value to disable the GPE.
-     */
-    Status = AcpiHwLowLevelRead (8, &InByte,
-                    &GpeRegisterInfo->EnableAddress);
-    if (ACPI_FAILURE (Status))
-    {
-        return (Status);
+        return (AE_NOT_EXIST);
    }

-    /* Write the byte with this GPE bit cleared */
+    /* Write the entire GPE (runtime) enable register */

-    Status = AcpiHwLowLevelWrite (8, (InByte & ~(GpeEventInfo->BitMask)),
+    Status = AcpiHwLowLevelWrite (8, GpeRegisterInfo->EnableForRun,
                    &GpeRegisterInfo->EnableAddress);
-    if (ACPI_FAILURE (Status))
-    {
-        return (Status);
-    }
-
-    AcpiHwDisableGpeForWakeup (GpeEventInfo);
-    return (AE_OK);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    AcpiHwDisableGpeForWakeup
- *
- * PARAMETERS:  GpeNumber       - The GPE
- *
- * RETURN:      None
- *
- * DESCRIPTION: Keep track of which GPEs the OS has requested not be
- *              disabled when going to sleep.
- *
- ******************************************************************************/

-void
-AcpiHwDisableGpeForWakeup (
-    ACPI_GPE_EVENT_INFO     *GpeEventInfo)
-{
-    ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
-
-
-    ACPI_FUNCTION_ENTRY ();
-
-
-    /* Get the info block for the entire GPE register */
-
-    GpeRegisterInfo = GpeEventInfo->RegisterInfo;
-    if (!GpeRegisterInfo)
-    {
-        return;
-    }
-
-    /*
-     * Clear the bit so we will disable this when sleeping
-     */
-    GpeRegisterInfo->WakeEnable &= ~(GpeEventInfo->BitMask);
+    return (Status);
}


@@ -305,11 +171,11 @@
 *
 * FUNCTION:    AcpiHwClearGpe
 *
- * PARAMETERS:  GpeNumber       - The GPE
+ * PARAMETERS:  GpeEventInfo        - Info block for the GPE to be cleared
 *
- * RETURN:      None
+ * RETURN:      StatusStatus
 *
- * DESCRIPTION: Clear a single GPE.
+ * DESCRIPTION: Clear the status bit for a single GPE.
 *
 ******************************************************************************/

@@ -327,7 +193,7 @@
     * Write a one to the appropriate bit in the status register to
     * clear this GPE.
     */
-    Status = AcpiHwLowLevelWrite (8, GpeEventInfo->BitMask,
+    Status = AcpiHwLowLevelWrite (8, GpeEventInfo->RegisterBit,
                    &GpeEventInfo->RegisterInfo->StatusAddress);

    return (Status);
@@ -338,9 +204,10 @@
 *
 * FUNCTION:    AcpiHwGetGpeStatus
 *
- * PARAMETERS:  GpeNumber       - The GPE
+ * PARAMETERS:  GpeEventInfo        - Info block for the GPE to queried
+ *              EventStatus         - Where the GPE status is returned
 *
- * RETURN:      None
+ * RETURN:      Status
 *
 * DESCRIPTION: Return the status of a single GPE.
 *
@@ -352,7 +219,7 @@
    ACPI_EVENT_STATUS       *EventStatus)
{
    UINT32                  InByte;
-    UINT8                   BitMask;
+    UINT8                   RegisterBit;
    ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
    ACPI_STATUS             Status;
    ACPI_EVENT_STATUS       LocalEventStatus = 0;
@@ -372,29 +239,23 @@

    /* Get the register bitmask for this GPE */

-    BitMask = GpeEventInfo->BitMask;
+    RegisterBit = GpeEventInfo->RegisterBit;

-    /* GPE Enabled? */
+    /* GPE currently enabled? (enabled for runtime?) */

-    Status = AcpiHwLowLevelRead (8, &InByte, &GpeRegisterInfo->EnableAddress);
-    if (ACPI_FAILURE (Status))
-    {
-        goto UnlockAndExit;
-    }
-
-    if (BitMask & InByte)
+    if (RegisterBit & GpeRegisterInfo->EnableForRun)
    {
        LocalEventStatus |= ACPI_EVENT_FLAG_ENABLED;
    }

-    /* GPE Enabled for wake? */
+    /* GPE enabled for wake? */

-    if (BitMask & GpeRegisterInfo->WakeEnable)
+    if (RegisterBit & GpeRegisterInfo->EnableForWake)
    {
        LocalEventStatus |= ACPI_EVENT_FLAG_WAKE_ENABLED;
    }

-    /* GPE active (set)? */
+    /* GPE currently active (status bit == 1)? */

    Status = AcpiHwLowLevelRead (8, &InByte, &GpeRegisterInfo->StatusAddress);
    if (ACPI_FAILURE (Status))
@@ -402,7 +263,7 @@
        goto UnlockAndExit;
    }

-    if (BitMask & InByte)
+    if (RegisterBit & InByte)
    {
        LocalEventStatus |= ACPI_EVENT_FLAG_SET;
    }
@@ -466,7 +327,7 @@
 *
 * RETURN:      Status
 *
- * DESCRIPTION: Clear all GPEs within a GPE block
+ * DESCRIPTION: Clear status bits for all GPEs within a GPE block
 *
 ******************************************************************************/

@@ -483,7 +344,7 @@

    for (i = 0; i < GpeBlock->RegisterCount; i++)
    {
-        /* Clear all GPEs in this register */
+        /* Clear status on all GPEs in this register */

        Status = AcpiHwLowLevelWrite (8, 0xFF,
                    &GpeBlock->RegisterInfo[i].StatusAddress);
@@ -499,60 +360,46 @@

/******************************************************************************
 *
- * FUNCTION:    AcpiHwDisableNonWakeupGpeBlock
+ * FUNCTION:    AcpiHwEnableRuntimeGpeBlock
 *
 * PARAMETERS:  GpeXruptInfo        - GPE Interrupt info
 *              GpeBlock            - Gpe Block info
 *
 * RETURN:      Status
 *
- * DESCRIPTION: Disable all GPEs except wakeup GPEs in a GPE block
+ * DESCRIPTION: Enable all "runtime" GPEs within a GPE block. (Includes
+ *              combination wake/run GPEs.)
 *
 ******************************************************************************/

-static ACPI_STATUS
-AcpiHwDisableNonWakeupGpeBlock (
+ACPI_STATUS
+AcpiHwEnableRuntimeGpeBlock (
    ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
    ACPI_GPE_BLOCK_INFO     *GpeBlock)
{
    UINT32                  i;
-    ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
-    UINT32                  InValue;
    ACPI_STATUS             Status;


-    /* Get the register info for the entire GPE block */
-
-    GpeRegisterInfo = GpeBlock->RegisterInfo;
+    /* NOTE: assumes that all GPEs are currently disabled */

    /* Examine each GPE Register within the block */

    for (i = 0; i < GpeBlock->RegisterCount; i++)
    {
-        /*
-         * Read the enabled status of all GPEs. We
-         * will be using it to restore all the GPEs later.
-         */
-        Status = AcpiHwLowLevelRead (8, &InValue,
-                    &GpeRegisterInfo->EnableAddress);
-        if (ACPI_FAILURE (Status))
+        if (!GpeBlock->RegisterInfo[i].EnableForRun)
        {
-            return (Status);
+            continue;
        }

-        GpeRegisterInfo->Enable = (UINT8) InValue;
+        /* Enable all "runtime" GPEs in this register */

-        /*
-         * Disable all GPEs except wakeup GPEs.
-         */
-        Status = AcpiHwLowLevelWrite (8, GpeRegisterInfo->WakeEnable,
-                &GpeRegisterInfo->EnableAddress);
+        Status = AcpiHwLowLevelWrite (8, GpeBlock->RegisterInfo[i].EnableForRun,
+                    &GpeBlock->RegisterInfo[i].EnableAddress);
        if (ACPI_FAILURE (Status))
        {
            return (Status);
        }
-
-        GpeRegisterInfo++;
    }

    return (AE_OK);
@@ -561,111 +408,128 @@

/******************************************************************************
 *
- * FUNCTION:    AcpiHwDisableNonWakeupGpes
+ * FUNCTION:    AcpiHwEnableWakeupGpeBlock
 *
- * PARAMETERS:  None
+ * PARAMETERS:  GpeXruptInfo        - GPE Interrupt info
+ *              GpeBlock            - Gpe Block info
 *
- * RETURN:      None
+ * RETURN:      Status
 *
- * DESCRIPTION: Disable all non-wakeup GPEs
- *              Called with interrupts disabled. The interrupt handler also
- *              modifies GpeRegisterInfo->Enable, so it should not be
- *              given the chance to run until after non-wake GPEs are
- *              re-enabled.
+ * DESCRIPTION: Enable all "wake" GPEs within a GPE block.  (Includes
+ *              combination wake/run GPEs.)
 *
 ******************************************************************************/

ACPI_STATUS
-AcpiHwDisableNonWakeupGpes (
-    void)
+AcpiHwEnableWakeupGpeBlock (
+    ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
+    ACPI_GPE_BLOCK_INFO     *GpeBlock)
{
+    UINT32                  i;
    ACPI_STATUS             Status;


-    ACPI_FUNCTION_ENTRY ();
+    /* Examine each GPE Register within the block */

+    for (i = 0; i < GpeBlock->RegisterCount; i++)
+    {
+        if (!GpeBlock->RegisterInfo[i].EnableForWake)
+        {
+            continue;
+        }

-    Status = AcpiEvWalkGpeList (AcpiHwDisableNonWakeupGpeBlock);
+        /* Enable all "wake" GPEs in this register */

-    return (Status);
+        Status = AcpiHwLowLevelWrite (8, GpeBlock->RegisterInfo[i].EnableForWake,
+                    &GpeBlock->RegisterInfo[i].EnableAddress);
+        if (ACPI_FAILURE (Status))
+        {
+            return (Status);
+        }
+    }
+
+    return (AE_OK);
}


/******************************************************************************
 *
- * FUNCTION:    AcpiHwEnableNonWakeupGpeBlock
+ * FUNCTION:    AcpiHwDisableAllGpes
 *
- * PARAMETERS:  GpeXruptInfo        - GPE Interrupt info
- *              GpeBlock            - Gpe Block info
+ * PARAMETERS:  None
 *
 * RETURN:      Status
 *
- * DESCRIPTION: Enable a single GPE.
+ * DESCRIPTION: Disable and clear all GPEs
 *
 ******************************************************************************/

-static ACPI_STATUS
-AcpiHwEnableNonWakeupGpeBlock (
-    ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
-    ACPI_GPE_BLOCK_INFO     *GpeBlock)
+ACPI_STATUS
+AcpiHwDisableAllGpes (
+    void)
{
-    UINT32                  i;
-    ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
    ACPI_STATUS             Status;


-    /* This callback processes one entire GPE block */
+    ACPI_FUNCTION_TRACE ("HwDisableAllGpes");

-    /* Get the register info for the entire GPE block */

-    GpeRegisterInfo = GpeBlock->RegisterInfo;
+    Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock);
+    Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock);
+    return_ACPI_STATUS (Status);
+}

-    /* Examine each GPE register within the block */

-    for (i = 0; i < GpeBlock->RegisterCount; i++)
-    {
-        /*
-         * We previously stored the enabled status of all GPEs.
-         * Blast them back in.
-         */
-        Status = AcpiHwLowLevelWrite (8, GpeRegisterInfo->Enable,
-                    &GpeRegisterInfo->EnableAddress);
-        if (ACPI_FAILURE (Status))
-        {
-            return (Status);
-        }
+/******************************************************************************
+ *
+ * FUNCTION:    AcpiHwEnableAllRuntimeGpes
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Enable all GPEs of the given type
+ *
+ ******************************************************************************/

-        GpeRegisterInfo++;
-    }
+ACPI_STATUS
+AcpiHwEnableAllRuntimeGpes (
+    void)
+{
+    ACPI_STATUS             Status;


-    return (AE_OK);
+    ACPI_FUNCTION_TRACE ("HwEnableAllRuntimeGpes");
+
+
+    Status = AcpiEvWalkGpeList (AcpiHwEnableRuntimeGpeBlock);
+    return_ACPI_STATUS (Status);
}


/******************************************************************************
 *
- * FUNCTION:    AcpiHwEnableNonWakeupGpes
+ * FUNCTION:    AcpiHwEnableAllWakeupGpes
 *
 * PARAMETERS:  None
 *
- * RETURN:      None
+ * RETURN:      Status
 *
- * DESCRIPTION: Enable all non-wakeup GPEs we previously enabled.
+ * DESCRIPTION: Enable all GPEs of the given type
 *
 ******************************************************************************/

ACPI_STATUS
-AcpiHwEnableNonWakeupGpes (
+AcpiHwEnableAllWakeupGpes (
    void)
{
    ACPI_STATUS             Status;


-    ACPI_FUNCTION_ENTRY ();
-
+    ACPI_FUNCTION_TRACE ("HwEnableAllWakeupGpes");

-    Status = AcpiEvWalkGpeList (AcpiHwEnableNonWakeupGpeBlock);

-    return (Status);
+    Status = AcpiEvWalkGpeList (AcpiHwEnableWakeupGpeBlock);
+    return_ACPI_STATUS (Status);
}
+
Index: sys/dev/acpi/acpica/Subsystem/hwregs.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/hwregs.c,v
retrieving revision 1.13
diff -u -r1.13 hwregs.c
--- sys/dev/acpi/acpica/Subsystem/hwregs.c      14 Feb 2004 16:57:24 -0000      1.13
+++ sys/dev/acpi/acpica/Subsystem/hwregs.c      17 Jun 2004 04:08:47 -0000
@@ -3,7 +3,7 @@
 *
 * Module Name: hwregs - Read/write access functions for the various ACPI
 *                       control and status registers.
- *              xRevision: 153 $
+ *              xRevision: 156 $
 *
 ******************************************************************************/

@@ -218,7 +218,7 @@
    UINT8                   *SleepTypeB)
{
    ACPI_STATUS             Status = AE_OK;
-    ACPI_OPERAND_OBJECT     *ObjDesc;
+    ACPI_PARAMETER_INFO     Info;


    ACPI_FUNCTION_TRACE ("AcpiGetSleepTypeData");
@@ -236,19 +236,20 @@
    /*
     * Evaluate the namespace object containing the values for this state
     */
-    Status = AcpiNsEvaluateByName ((char *) AcpiGbl_DbSleepStates[SleepState],
-                    NULL, &ObjDesc);
+    Info.Parameters = NULL;
+    Status = AcpiNsEvaluateByName ((char *) AcpiGbl_SleepStateNames[SleepState],
+                    &Info);
    if (ACPI_FAILURE (Status))
    {
        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s while evaluating SleepState [%s]\n",
-            AcpiFormatException (Status), AcpiGbl_DbSleepStates[SleepState]));
+            AcpiFormatException (Status), AcpiGbl_SleepStateNames[SleepState]));

        return_ACPI_STATUS (Status);
    }

    /* Must have a return object */

-    if (!ObjDesc)
+    if (!Info.ReturnObject)
    {
        ACPI_REPORT_ERROR (("Missing Sleep State object\n"));
        Status = AE_NOT_EXIST;
@@ -256,7 +257,7 @@

    /* It must be of type Package */

-    else if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_PACKAGE)
+    else if (ACPI_GET_OBJECT_TYPE (Info.ReturnObject) != ACPI_TYPE_PACKAGE)
    {
        ACPI_REPORT_ERROR (("Sleep State object not a Package\n"));
        Status = AE_AML_OPERAND_TYPE;
@@ -264,7 +265,7 @@

    /* The package must have at least two elements */

-    else if (ObjDesc->Package.Count < 2)
+    else if (Info.ReturnObject->Package.Count < 2)
    {
        ACPI_REPORT_ERROR (("Sleep State package does not have at least two elements\n"));
        Status = AE_AML_NO_OPERAND;
@@ -272,12 +273,12 @@

    /* The first two elements must both be of type Integer */

-    else if ((ACPI_GET_OBJECT_TYPE (ObjDesc->Package.Elements[0]) != ACPI_TYPE_INTEGER) ||
-             (ACPI_GET_OBJECT_TYPE (ObjDesc->Package.Elements[1]) != ACPI_TYPE_INTEGER))
+    else if ((ACPI_GET_OBJECT_TYPE (Info.ReturnObject->Package.Elements[0]) != ACPI_TYPE_INTEGER) ||
+             (ACPI_GET_OBJECT_TYPE (Info.ReturnObject->Package.Elements[1]) != ACPI_TYPE_INTEGER))
    {
        ACPI_REPORT_ERROR (("Sleep State package elements are not both Integers (%s, %s)\n",
-            AcpiUtGetObjectTypeName (ObjDesc->Package.Elements[0]),
-            AcpiUtGetObjectTypeName (ObjDesc->Package.Elements[1])));
+            AcpiUtGetObjectTypeName (Info.ReturnObject->Package.Elements[0]),
+            AcpiUtGetObjectTypeName (Info.ReturnObject->Package.Elements[1])));
        Status = AE_AML_OPERAND_TYPE;
    }
    else
@@ -285,17 +286,19 @@
        /*
         * Valid _Sx_ package size, type, and value
         */
-        *SleepTypeA = (UINT8) (ObjDesc->Package.Elements[0])->Integer.Value;
-        *SleepTypeB = (UINT8) (ObjDesc->Package.Elements[1])->Integer.Value;
+        *SleepTypeA = (UINT8) (Info.ReturnObject->Package.Elements[0])->Integer.Value;
+        *SleepTypeB = (UINT8) (Info.ReturnObject->Package.Elements[1])->Integer.Value;
    }

    if (ACPI_FAILURE (Status))
    {
-        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "While evaluating SleepState [%s], bad Sleep object %p type %s\n",
-            AcpiGbl_DbSleepStates[SleepState], ObjDesc, AcpiUtGetObjectTypeName (ObjDesc)));
+        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+            "While evaluating SleepState [%s], bad Sleep object %p type %s\n",
+            AcpiGbl_SleepStateNames[SleepState], Info.ReturnObject,
+            AcpiUtGetObjectTypeName (Info.ReturnObject)));
    }

-    AcpiUtRemoveReference (ObjDesc);
+    AcpiUtRemoveReference (Info.ReturnObject);
    return_ACPI_STATUS (Status);
}

Index: sys/dev/acpi/acpica/Subsystem/hwsleep.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/hwsleep.c,v
retrieving revision 1.12
diff -u -r1.12 hwsleep.c
--- sys/dev/acpi/acpica/Subsystem/hwsleep.c     14 Feb 2004 16:57:24 -0000      1.12
+++ sys/dev/acpi/acpica/Subsystem/hwsleep.c     17 Jun 2004 04:08:47 -0000
@@ -2,7 +2,7 @@
/******************************************************************************
 *
 * Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface
- *              xRevision: 62 $
+ *              xRevision: 69 $
 *
 *****************************************************************************/

@@ -124,6 +124,19 @@
        ACPI_MODULE_NAME    ("hwsleep")


+#define METHOD_NAME__BFS        "\\_BFS"
+#define METHOD_NAME__GTS        "\\_GTS"
+#define METHOD_NAME__PTS        "\\_PTS"
+#define METHOD_NAME__SST        "\\_SI._SST"
+#define METHOD_NAME__WAK        "\\_WAK"
+
+#define ACPI_SST_INDICATOR_OFF  0
+#define ACPI_SST_WORKING        1
+#define ACPI_SST_WAKING         2
+#define ACPI_SST_SLEEPING       3
+#define ACPI_SST_SLEEP_CONTEXT  4
+
+
/******************************************************************************
 *
 * FUNCTION:    AcpiSetFirmwareWakingVector
@@ -253,43 +266,44 @@

    /* Run the _PTS and _GTS methods */

-    Status = AcpiEvaluateObject (NULL, "\\_PTS", &ArgList, NULL);
+    Status = AcpiEvaluateObject (NULL, METHOD_NAME__PTS, &ArgList, NULL);
    if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND)
    {
        return_ACPI_STATUS (Status);
    }

-    Status = AcpiEvaluateObject (NULL, "\\_GTS", &ArgList, NULL);
+    Status = AcpiEvaluateObject (NULL, METHOD_NAME__GTS, &ArgList, NULL);
    if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND)
    {
        return_ACPI_STATUS (Status);
    }

-    /* Set the system indicators to show the desired sleep state. */
+    /* Setup the argument to _SST */

    switch (SleepState)
    {
    case ACPI_STATE_S0:
-        /* _SST 1: Working */
-        Arg.Integer.Value = 1;
+        Arg.Integer.Value = ACPI_SST_WORKING;
        break;
+
    case ACPI_STATE_S1:
    case ACPI_STATE_S2:
    case ACPI_STATE_S3:
-        /* _SST 3: Sleeping. Used to indicate system state S1, S2 or S3. */
-        Arg.Integer.Value = 3;
+        Arg.Integer.Value = ACPI_SST_SLEEPING;
        break;
+
    case ACPI_STATE_S4:
-        /* _SST 4: Sleeping with context saved to non-volatile storage. */
-        Arg.Integer.Value = 4;
+        Arg.Integer.Value = ACPI_SST_SLEEP_CONTEXT;
        break;
-    case ACPI_STATE_S5:
-        /* _SST 0: No system state indication. Indicator off. */
-        Arg.Integer.Value = 0;
+
+    default:
+        Arg.Integer.Value = ACPI_SST_INDICATOR_OFF; /* Default is indicator off */
        break;
    }

-    Status = AcpiEvaluateObject (NULL, "\\_SI._SST", &ArgList, NULL);
+    /* Set the system indicators to show the desired sleep state. */
+
+    Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL);
    if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND)
    {
         ACPI_REPORT_ERROR (("Method _SST failed, %s\n", AcpiFormatException (Status)));
@@ -339,22 +353,24 @@
    SleepTypeRegInfo   = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_TYPE_A);
    SleepEnableRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_ENABLE);

-    if (SleepState != ACPI_STATE_S5)
+    /* Clear wake status */
+
+    Status = AcpiSetRegister (ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_DO_NOT_LOCK);
+    if (ACPI_FAILURE (Status))
    {
-        /* Clear wake status */
+        return_ACPI_STATUS (Status);
+    }

-        Status = AcpiSetRegister (ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_DO_NOT_LOCK);
-        if (ACPI_FAILURE (Status))
-        {
-            return_ACPI_STATUS (Status);
-        }
+    /* Clear all fixed and general purpose status bits */

-        Status = AcpiHwClearAcpiStatus (ACPI_MTX_DO_NOT_LOCK);
-        if (ACPI_FAILURE (Status))
-        {
-            return_ACPI_STATUS (Status);
-        }
+    Status = AcpiHwClearAcpiStatus (ACPI_MTX_DO_NOT_LOCK);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }

+    if (SleepState != ACPI_STATE_S5)
+    {
        /* Disable BM arbitration */

        Status = AcpiSetRegister (ACPI_BITREG_ARB_DISABLE, 1, ACPI_MTX_DO_NOT_LOCK);
@@ -364,7 +380,18 @@
        }
    }

-    Status = AcpiHwDisableNonWakeupGpes ();
+    /*
+     * 1) Disable/Clear all GPEs
+     * 2) Enable all wakeup GPEs
+     */
+    Status = AcpiHwDisableAllGpes ();
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+    AcpiGbl_SystemAwakeAndRunning = FALSE;
+
+    Status = AcpiHwEnableAllWakeupGpes ();
    if (ACPI_FAILURE (Status))
    {
        return_ACPI_STATUS (Status);
@@ -515,7 +542,18 @@
        return_ACPI_STATUS (Status);
    }

-    Status = AcpiHwDisableNonWakeupGpes ();
+    /*
+     * 1) Disable/Clear all GPEs
+     * 2) Enable all wakeup GPEs
+     */
+    Status = AcpiHwDisableAllGpes ();
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+    AcpiGbl_SystemAwakeAndRunning = FALSE;
+
+    Status = AcpiHwEnableAllWakeupGpes ();
    if (ACPI_FAILURE (Status))
    {
        return_ACPI_STATUS (Status);
@@ -616,42 +654,62 @@

    /* Ignore any errors from these methods */

-    /* _SST 2: Waking */
-    Arg.Integer.Value = 2;
-    Status = AcpiEvaluateObject (NULL, "\\_SI._SST", &ArgList, NULL);
+    Arg.Integer.Value = ACPI_SST_WAKING;
+    Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL);
    if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND)
    {
        ACPI_REPORT_ERROR (("Method _SST failed, %s\n", AcpiFormatException (Status)));
    }

    Arg.Integer.Value = SleepState;
-    Status = AcpiEvaluateObject (NULL, "\\_BFS", &ArgList, NULL);
+    Status = AcpiEvaluateObject (NULL, METHOD_NAME__BFS, &ArgList, NULL);
    if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND)
    {
        ACPI_REPORT_ERROR (("Method _BFS failed, %s\n", AcpiFormatException (Status)));
    }

-    Status = AcpiEvaluateObject (NULL, "\\_WAK", &ArgList, NULL);
+    Status = AcpiEvaluateObject (NULL, METHOD_NAME__WAK, &ArgList, NULL);
    if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND)
    {
        ACPI_REPORT_ERROR (("Method _WAK failed, %s\n", AcpiFormatException (Status)));
    }
+    /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */

-    /* _WAK returns stuff - do we want to look at it? */
+    /*
+     * Restore the GPEs:
+     * 1) Disable/Clear all GPEs
+     * 2) Enable all runtime GPEs
+     */
+    Status = AcpiHwDisableAllGpes ();
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+    AcpiGbl_SystemAwakeAndRunning = TRUE;

-    Status = AcpiHwEnableNonWakeupGpes ();
+    Status = AcpiHwEnableAllRuntimeGpes ();
    if (ACPI_FAILURE (Status))
    {
        return_ACPI_STATUS (Status);
    }

+    /* Enable power button */
+
+    (void) AcpiSetRegister(AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].EnableRegisterId,
+            1, ACPI_MTX_DO_NOT_LOCK);
+    (void) AcpiSetRegister(AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].StatusRegisterId,
+            1, ACPI_MTX_DO_NOT_LOCK);
+
    /* Enable BM arbitration */

    Status = AcpiSetRegister (ACPI_BITREG_ARB_DISABLE, 0, ACPI_MTX_LOCK);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }

-    /* _SST 1: Working */
-    Arg.Integer.Value = 1;
-    Status = AcpiEvaluateObject (NULL, "\\_SI._SST", &ArgList, NULL);
+    Arg.Integer.Value = ACPI_SST_WORKING;
+    Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL);
    if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND)
    {
        ACPI_REPORT_ERROR (("Method _SST failed, %s\n", AcpiFormatException (Status)));
Index: sys/dev/acpi/acpica/Subsystem/nsaccess.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/nsaccess.c,v
retrieving revision 1.10
diff -u -r1.10 nsaccess.c
--- sys/dev/acpi/acpica/Subsystem/nsaccess.c    14 Feb 2004 16:57:24 -0000      1.10
+++ sys/dev/acpi/acpica/Subsystem/nsaccess.c    17 Jun 2004 04:08:47 -0000
@@ -1,7 +1,7 @@
/*******************************************************************************
 *
 * Module Name: nsaccess - Top-level functions for accessing ACPI namespace
- *              xRevision: 177 $
+ *              xRevision: 182 $
 *
 ******************************************************************************/

@@ -185,8 +185,16 @@

    for (InitVal = AcpiGbl_PreDefinedNames; InitVal->Name; InitVal++)
    {
+        /* _OSI is optional for now, will be permanent later */
+
+        if (!ACPI_STRCMP (InitVal->Name, "_OSI") && !AcpiGbl_CreateOsiMethod)
+        {
+            continue;
+        }
+
        Status = AcpiNsLookup (NULL, InitVal->Name, InitVal->Type,
-                        ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, NULL, &NewNode);
+                        ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH,
+                        NULL, &NewNode);

        if (ACPI_FAILURE (Status) || (!NewNode)) /* Must be on same line for code converter */
        {
@@ -205,7 +213,8 @@
            Status = AcpiOsPredefinedOverride (InitVal, &Val);
            if (ACPI_FAILURE (Status))
            {
-                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not override predefined %s\n",
+                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+                    "Could not override predefined %s\n",
                    InitVal->Name));
            }

@@ -233,15 +242,20 @@
            switch (InitVal->Type)
            {
            case ACPI_TYPE_METHOD:
-                ObjDesc->Method.ParamCount =
-                        (UINT8) ACPI_STRTOUL (Val, NULL, 10);
+                ObjDesc->Method.ParamCount = (UINT8) ACPI_STRTOUL
+                                                        (Val, NULL, 10);
                ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID;

-#if defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
+#if defined (_ACPI_ASL_COMPILER) || defined (_ACPI_DUMP_APP)

-                /* Compiler cheats by putting parameter count in the OwnerID */
+                /* iASL Compiler cheats by putting parameter count in the OwnerID */

                NewNode->OwnerId = ObjDesc->Method.ParamCount;
+#else
+                /* Mark this as a very SPECIAL method */
+
+                ObjDesc->Method.MethodFlags = AML_METHOD_INTERNAL_ONLY;
+                ObjDesc->Method.Implementation = AcpiUtOsiImplementation;
#endif
                break;

@@ -266,8 +280,8 @@
            case ACPI_TYPE_MUTEX:

                ObjDesc->Mutex.Node = NewNode;
-                ObjDesc->Mutex.SyncLevel =
-                            (UINT16) ACPI_STRTOUL (Val, NULL, 10);
+                ObjDesc->Mutex.SyncLevel = (UINT8) ACPI_STRTOUL
+                                                        (Val, NULL, 10);

                if (ACPI_STRCMP (InitVal->Name, "_GL_") == 0)
                {
@@ -303,6 +317,7 @@


            default:
+
                ACPI_REPORT_ERROR (("Unsupported initial type value %X\n",
                    InitVal->Type));
                AcpiUtRemoveReference (ObjDesc);
@@ -323,6 +338,15 @@

UnlockAndExit:
    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+
+    /* Save a handle to "_GPE", it is always present */
+
+    if (ACPI_SUCCESS (Status))
+    {
+        Status = AcpiNsGetNodeByPath ("\\_GPE", NULL, ACPI_NS_NO_UPSEARCH,
+                        &AcpiGbl_FadtGpeDevice);
+    }
+
    return_ACPI_STATUS (Status);
}

@@ -673,6 +697,7 @@
        if ((NumSegments        == 0)                               &&
            (TypeToCheckFor     != ACPI_TYPE_ANY)                   &&
            (TypeToCheckFor     != ACPI_TYPE_LOCAL_ALIAS)           &&
+            (TypeToCheckFor     != ACPI_TYPE_LOCAL_METHOD_ALIAS)    &&
            (TypeToCheckFor     != ACPI_TYPE_LOCAL_SCOPE)           &&
            (ThisNode->Type     != ACPI_TYPE_ANY)                   &&
            (ThisNode->Type     != TypeToCheckFor))
Index: sys/dev/acpi/acpica/Subsystem/nsalloc.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/nsalloc.c,v
retrieving revision 1.14
diff -u -r1.14 nsalloc.c
--- sys/dev/acpi/acpica/Subsystem/nsalloc.c     23 Apr 2004 02:58:29 -0000      1.14
+++ sys/dev/acpi/acpica/Subsystem/nsalloc.c     17 Jun 2004 04:08:48 -0000
@@ -1,7 +1,7 @@
/*******************************************************************************
 *
 * Module Name: nsalloc - Namespace allocation and deletion utilities
- *              xRevision: 84 $
+ *              xRevision: 87 $
 *
 ******************************************************************************/

@@ -431,10 +431,11 @@
    Node->OwnerId = OwnerId;
    Node->Type = (UINT8) Type;

-    ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%4.4s (%s) added to %4.4s (%s) %p at %p\n",
-        AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type),
+    ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+        "%4.4s (%s) [Node %p Owner %X] added to %4.4s (%s) [Node %p]\n",
+        AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type), Node, OwnerId,
        AcpiUtGetNodeName (ParentNode), AcpiUtGetTypeName (ParentNode->Type),
-        ParentNode, Node));
+        ParentNode));

    /*
     * Increment the reference count(s) of all parents up to
Index: sys/dev/acpi/acpica/Subsystem/nsdump.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/nsdump.c,v
retrieving revision 1.12
diff -u -r1.12 nsdump.c
--- sys/dev/acpi/acpica/Subsystem/nsdump.c      14 Feb 2004 16:57:24 -0000      1.12
+++ sys/dev/acpi/acpica/Subsystem/nsdump.c      17 Jun 2004 04:08:48 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Module Name: nsdump - table dumping routines for debug
- *              xRevision: 157 $
+ *              xRevision: 158 $
 *
 *****************************************************************************/

@@ -450,6 +450,7 @@


        case ACPI_TYPE_LOCAL_ALIAS:
+        case ACPI_TYPE_LOCAL_METHOD_ALIAS:

            AcpiOsPrintf ("Target %4.4s (%p)\n", AcpiUtGetNodeName (ObjDesc), ObjDesc);
            break;
Index: sys/dev/acpi/acpica/Subsystem/nseval.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/nseval.c,v
retrieving revision 1.11
diff -u -r1.11 nseval.c
--- sys/dev/acpi/acpica/Subsystem/nseval.c      14 Feb 2004 16:57:24 -0000      1.11
+++ sys/dev/acpi/acpica/Subsystem/nseval.c      17 Jun 2004 04:08:48 -0000
@@ -2,7 +2,7 @@
 *
 * Module Name: nseval - Object evaluation interfaces -- includes control
 *                       method lookup and execution.
- *              xRevision: 122 $
+ *              xRevision: 127 $
 *
 ******************************************************************************/

@@ -155,16 +155,13 @@

ACPI_STATUS
AcpiNsEvaluateRelative (
-    ACPI_NAMESPACE_NODE     *Handle,
    char                    *Pathname,
-    ACPI_OPERAND_OBJECT     **Params,
-    ACPI_OPERAND_OBJECT     **ReturnObject)
+    ACPI_PARAMETER_INFO     *Info)
{
-    ACPI_NAMESPACE_NODE     *PrefixNode;
    ACPI_STATUS             Status;
    ACPI_NAMESPACE_NODE     *Node = NULL;
+    ACPI_GENERIC_STATE      *ScopeInfo;
    char                    *InternalPath = NULL;
-    ACPI_GENERIC_STATE      ScopeInfo;


    ACPI_FUNCTION_TRACE ("NsEvaluateRelative");
@@ -173,7 +170,7 @@
    /*
     * Must have a valid object handle
     */
-    if (!Handle)
+    if (!Info || !Info->Node)
    {
        return_ACPI_STATUS (AE_BAD_PARAMETER);
    }
@@ -186,6 +183,12 @@
        return_ACPI_STATUS (Status);
    }

+    ScopeInfo = AcpiUtCreateGenericState ();
+    if (!ScopeInfo)
+    {
+        goto Cleanup1;
+    }
+
    /* Get the prefix handle and Node */

    Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
@@ -194,8 +197,8 @@
        goto Cleanup;
    }

-    PrefixNode = AcpiNsMapHandleToNode (Handle);
-    if (!PrefixNode)
+    Info->Node = AcpiNsMapHandleToNode (Info->Node);
+    if (!Info->Node)
    {
        (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
        Status = AE_BAD_PARAMETER;
@@ -204,8 +207,8 @@

    /* Lookup the name in the namespace */

-    ScopeInfo.Scope.Node = PrefixNode;
-    Status = AcpiNsLookup (&ScopeInfo, InternalPath, ACPI_TYPE_ANY,
+    ScopeInfo->Scope.Node = Info->Node;
+    Status = AcpiNsLookup (ScopeInfo, InternalPath, ACPI_TYPE_ANY,
                            ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL,
                            &Node);

@@ -225,13 +228,16 @@
    ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n",
        Pathname, Node, AcpiNsGetAttachedObject (Node)));

-    Status = AcpiNsEvaluateByHandle (Node, Params, ReturnObject);
+    Info->Node = Node;
+    Status = AcpiNsEvaluateByHandle (Info);

    ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "*** Completed eval of object %s ***\n",
        Pathname));

Cleanup:
+    AcpiUtDeleteGenericState (ScopeInfo);

+Cleanup1:
    ACPI_MEM_FREE (InternalPath);
    return_ACPI_STATUS (Status);
}
@@ -242,6 +248,7 @@
 * FUNCTION:    AcpiNsEvaluateByName
 *
 * PARAMETERS:  Pathname            - Fully qualified pathname to the object
+ *              Info                - Contains:
 *              ReturnObject        - Where to put method's return value (if
 *                                    any).  If NULL, no value is returned.
 *              Params              - List of parameters to pass to the method,
@@ -260,11 +267,9 @@
ACPI_STATUS
AcpiNsEvaluateByName (
    char                    *Pathname,
-    ACPI_OPERAND_OBJECT     **Params,
-    ACPI_OPERAND_OBJECT     **ReturnObject)
+    ACPI_PARAMETER_INFO     *Info)
{
    ACPI_STATUS             Status;
-    ACPI_NAMESPACE_NODE     *Node = NULL;
    char                    *InternalPath = NULL;


@@ -289,7 +294,7 @@

    Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY,
                            ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL,
-                            &Node);
+                            &Info->Node);

    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);

@@ -305,9 +310,9 @@
     * to evaluate it.
     */
    ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n",
-        Pathname, Node, AcpiNsGetAttachedObject (Node)));
+        Pathname, Info->Node, AcpiNsGetAttachedObject (Info->Node)));

-    Status = AcpiNsEvaluateByHandle (Node, Params, ReturnObject);
+    Status = AcpiNsEvaluateByHandle (Info);

    ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "*** Completed eval of object %s ***\n",
        Pathname));
@@ -334,6 +339,7 @@
 *              Params              - List of parameters to pass to the method,
 *                                    terminated by NULL.  Params itself may be
 *                                    NULL if no parameters are being passed.
+ *              ParamType           - Type of Parameter list
 *              ReturnObject        - Where to put method's return value (if
 *                                    any).  If NULL, no value is returned.
 *
@@ -347,13 +353,9 @@

ACPI_STATUS
AcpiNsEvaluateByHandle (
-    ACPI_NAMESPACE_NODE     *Handle,
-    ACPI_OPERAND_OBJECT     **Params,
-    ACPI_OPERAND_OBJECT     **ReturnObject)
+    ACPI_PARAMETER_INFO     *Info)
{
-    ACPI_NAMESPACE_NODE     *Node;
    ACPI_STATUS             Status;
-    ACPI_OPERAND_OBJECT     *LocalReturnObject;


    ACPI_FUNCTION_TRACE ("NsEvaluateByHandle");
@@ -368,17 +370,14 @@

    /* Parameter Validation */

-    if (!Handle)
+    if (!Info)
    {
        return_ACPI_STATUS (AE_BAD_PARAMETER);
    }

-    if (ReturnObject)
-    {
-        /* Initialize the return value to an invalid object */
+    /* Initialize the return value to an invalid object */

-        *ReturnObject = NULL;
-    }
+    Info->ReturnObject = NULL;

    /* Get the prefix handle and Node */

@@ -388,14 +387,24 @@
        return_ACPI_STATUS (Status);
    }

-    Node = AcpiNsMapHandleToNode (Handle);
-    if (!Node)
+    Info->Node = AcpiNsMapHandleToNode (Info->Node);
+    if (!Info->Node)
    {
        (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
        return_ACPI_STATUS (AE_BAD_PARAMETER);
    }

    /*
+     * For a method alias, we must grab the actual method node
+     * so that proper scoping context will be established
+     * before execution.
+     */
+    if (AcpiNsGetType (Info->Node) == ACPI_TYPE_LOCAL_METHOD_ALIAS)
+    {
+        Info->Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Info->Node->Object);
+    }
+
+    /*
     * Two major cases here:
     * 1) The object is an actual control method -- execute it.
     * 2) The object is not a method -- just return it's current
@@ -404,13 +413,12 @@
     * In both cases, the namespace is unlocked by the
     *  AcpiNs* procedure
     */
-    if (AcpiNsGetType (Node) == ACPI_TYPE_METHOD)
+    if (AcpiNsGetType (Info->Node) == ACPI_TYPE_METHOD)
    {
        /*
         * Case 1) We have an actual control method to execute
         */
-        Status = AcpiNsExecuteControlMethod (Node, Params,
-                                            &LocalReturnObject);
+        Status = AcpiNsExecuteControlMethod (Info);
    }
    else
    {
@@ -418,7 +426,7 @@
         * Case 2) Object is NOT a method, just return its
         * current value
         */
-        Status = AcpiNsGetObjectValue (Node, &LocalReturnObject);
+        Status = AcpiNsGetObjectValue (Info);
    }

    /*
@@ -427,21 +435,6 @@
     */
    if (Status == AE_CTRL_RETURN_VALUE)
    {
-        /*
-         * If the Method returned a value and the caller
-         * provided a place to store a returned value, Copy
-         * the returned value to the object descriptor provided
-         * by the caller.
-         */
-        if (ReturnObject)
-        {
-            /*
-             * Valid return object, copy the pointer to
-             * the returned object
-             */
-            *ReturnObject = LocalReturnObject;
-        }
-
        /* Map AE_CTRL_RETURN_VALUE to AE_OK, we are done with it */

        Status = AE_OK;
@@ -476,9 +469,7 @@

ACPI_STATUS
AcpiNsExecuteControlMethod (
-    ACPI_NAMESPACE_NODE     *MethodNode,
-    ACPI_OPERAND_OBJECT     **Params,
-    ACPI_OPERAND_OBJECT     **ReturnObjDesc)
+    ACPI_PARAMETER_INFO     *Info)
{
    ACPI_STATUS             Status;
    ACPI_OPERAND_OBJECT     *ObjDesc;
@@ -489,7 +480,7 @@

    /* Verify that there is a method associated with this object */

-    ObjDesc = AcpiNsGetAttachedObject (MethodNode);
+    ObjDesc = AcpiNsGetAttachedObject (Info->Node);
    if (!ObjDesc)
    {
        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No attached method object\n"));
@@ -498,7 +489,7 @@
        return_ACPI_STATUS (AE_NULL_OBJECT);
    }

-    ACPI_DUMP_PATHNAME (MethodNode, "Execute Method:",
+    ACPI_DUMP_PATHNAME (Info->Node, "Execute Method:",
        ACPI_LV_INFO, _COMPONENT);

    ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Method at AML address %p Length %X\n",
@@ -527,7 +518,7 @@
        return_ACPI_STATUS (Status);
    }

-    Status = AcpiPsxExecute (MethodNode, Params, ReturnObjDesc);
+    Status = AcpiPsxExecute (Info);
    AcpiExExitInterpreter ();

    return_ACPI_STATUS (Status);
@@ -551,11 +542,10 @@

ACPI_STATUS
AcpiNsGetObjectValue (
-    ACPI_NAMESPACE_NODE     *Node,
-    ACPI_OPERAND_OBJECT     **ReturnObjDesc)
+    ACPI_PARAMETER_INFO     *Info)
{
    ACPI_STATUS             Status = AE_OK;
-    ACPI_NAMESPACE_NODE     *ResolvedNode = Node;
+    ACPI_NAMESPACE_NODE     *ResolvedNode = Info->Node;


    ACPI_FUNCTION_TRACE ("NsGetObjectValue");
@@ -604,9 +594,9 @@
        if (ACPI_SUCCESS (Status))
        {
            Status = AE_CTRL_RETURN_VALUE;
-            *ReturnObjDesc = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ResolvedNode);
+            Info->ReturnObject = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ResolvedNode);
            ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Returning object %p [%s]\n",
-                *ReturnObjDesc, AcpiUtGetObjectTypeName (*ReturnObjDesc)));
+                Info->ReturnObject, AcpiUtGetObjectTypeName (Info->ReturnObject)));
        }
    }

Index: sys/dev/acpi/acpica/Subsystem/nsinit.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/nsinit.c,v
retrieving revision 1.10
diff -u -r1.10 nsinit.c
--- sys/dev/acpi/acpica/Subsystem/nsinit.c      14 Feb 2004 16:57:24 -0000      1.10
+++ sys/dev/acpi/acpica/Subsystem/nsinit.c      17 Jun 2004 04:08:48 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Module Name: nsinit - namespace initialization
- *              xRevision: 58 $
+ *              xRevision: 60 $
 *
 *****************************************************************************/

@@ -229,7 +229,7 @@
        return_ACPI_STATUS (Status);
    }

-    /* Walk namespace for all objects of type Device or Processor */
+    /* Walk namespace for all objects */

    Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
                    ACPI_UINT32_MAX, TRUE, AcpiNsInitOneDevice, &Info, NULL);
@@ -425,26 +425,30 @@
    void                    *Context,
    void                    **ReturnValue)
{
-    ACPI_STATUS             Status;
-    ACPI_NAMESPACE_NODE    *Node;
-    UINT32                  Flags;
    ACPI_DEVICE_WALK_INFO  *Info = (ACPI_DEVICE_WALK_INFO *) Context;
+    ACPI_PARAMETER_INFO     Pinfo;
+    UINT32                  Flags;
+    ACPI_STATUS             Status;


    ACPI_FUNCTION_TRACE ("NsInitOneDevice");


-    Node = AcpiNsMapHandleToNode (ObjHandle);
-    if (!Node)
+    Pinfo.Parameters = NULL;
+    Pinfo.ParameterType = ACPI_PARAM_ARGS;
+
+    Pinfo.Node = AcpiNsMapHandleToNode (ObjHandle);
+    if (!Pinfo.Node)
    {
        return_ACPI_STATUS (AE_BAD_PARAMETER);
    }

    /*
-     * We will run _STA/_INI on Devices and Processors only
+     * We will run _STA/_INI on Devices, Processors and ThermalZones only
     */
-    if ((Node->Type != ACPI_TYPE_DEVICE) &&
-        (Node->Type != ACPI_TYPE_PROCESSOR))
+    if ((Pinfo.Node->Type != ACPI_TYPE_DEVICE)      &&
+        (Pinfo.Node->Type != ACPI_TYPE_PROCESSOR)   &&
+        (Pinfo.Node->Type != ACPI_TYPE_THERMAL))
    {
        return_ACPI_STATUS (AE_OK);
    }
@@ -459,19 +463,19 @@
    /*
     * Run _STA to determine if we can run _INI on the device.
     */
-    ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD, Node, "_STA"));
-    Status = AcpiUtExecute_STA (Node, &Flags);
+    ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD, Pinfo.Node, "_STA"));
+    Status = AcpiUtExecute_STA (Pinfo.Node, &Flags);

    if (ACPI_FAILURE (Status))
    {
-        if (Node->Type == ACPI_TYPE_DEVICE)
+        if (Pinfo.Node->Type == ACPI_TYPE_DEVICE)
        {
            /* Ignore error and move on to next device */

            return_ACPI_STATUS (AE_OK);
        }

-        /* _STA is not required for Processor objects */
+        /* _STA is not required for Processor or ThermalZone objects */
    }
    else
    {
@@ -488,8 +492,8 @@
    /*
     * The device is present. Run _INI.
     */
-    ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD, ObjHandle, "_INI"));
-    Status = AcpiNsEvaluateRelative (ObjHandle, "_INI", NULL, NULL);
+    ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD, Pinfo.Node, "_INI"));
+    Status = AcpiNsEvaluateRelative ("_INI", &Pinfo);
    if (ACPI_FAILURE (Status))
    {
        /* No _INI (AE_NOT_FOUND) means device requires no initialization */
@@ -498,14 +502,14 @@
        {
            /* Ignore error and move on to next device */

-    #ifdef ACPI_DEBUG_OUTPUT
-            char        *ScopeName = AcpiNsGetExternalPathname (ObjHandle);
+#ifdef ACPI_DEBUG_OUTPUT
+            char        *ScopeName = AcpiNsGetExternalPathname (Pinfo.Node);

            ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "%s._INI failed: %s\n",
                    ScopeName, AcpiFormatException (Status)));

            ACPI_MEM_FREE (ScopeName);
-    #endif
+#endif
        }

        Status = AE_OK;
@@ -521,7 +525,7 @@
    {
        /* External initialization handler is present, call it */

-        Status = AcpiGbl_InitHandler (ObjHandle, ACPI_INIT_DEVICE_INI);
+        Status = AcpiGbl_InitHandler (Pinfo.Node, ACPI_INIT_DEVICE_INI);
    }


Index: sys/dev/acpi/acpica/Subsystem/nsparse.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/nsparse.c,v
retrieving revision 1.5
diff -u -r1.5 nsparse.c
--- sys/dev/acpi/acpica/Subsystem/nsparse.c     14 Feb 2004 16:57:25 -0000      1.5
+++ sys/dev/acpi/acpica/Subsystem/nsparse.c     17 Jun 2004 04:08:48 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Module Name: nsparse - namespace interface to AML parser
- *              xRevision: 5 $
+ *              xRevision: 6 $
 *
 *****************************************************************************/

@@ -173,8 +173,9 @@
        return_ACPI_STATUS (AE_NO_MEMORY);
    }

-    Status = AcpiDsInitAmlWalk (WalkState, ParseRoot, NULL, TableDesc->AmlStart,
-                    TableDesc->AmlLength, NULL, NULL, PassNumber);
+    Status = AcpiDsInitAmlWalk (WalkState, ParseRoot, NULL,
+                    TableDesc->AmlStart, TableDesc->AmlLength,
+                    NULL, PassNumber);
    if (ACPI_FAILURE (Status))
    {
        AcpiDsDeleteWalkState (WalkState);
Index: sys/dev/acpi/acpica/Subsystem/nssearch.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/nssearch.c,v
retrieving revision 1.10
diff -u -r1.10 nssearch.c
--- sys/dev/acpi/acpica/Subsystem/nssearch.c    14 Feb 2004 16:57:25 -0000      1.10
+++ sys/dev/acpi/acpica/Subsystem/nssearch.c    17 Jun 2004 04:08:48 -0000
@@ -1,7 +1,7 @@
/*******************************************************************************
 *
 * Module Name: nssearch - Namespace search
- *              xRevision: 100 $
+ *              xRevision: 101 $
 *
 ******************************************************************************/

@@ -194,6 +194,13 @@

        if (NextNode->Name.Integer == TargetName)
        {
+            /* Resolve a control method alias if any */
+
+            if (AcpiNsGetType (NextNode) == ACPI_TYPE_LOCAL_METHOD_ALIAS)
+            {
+                NextNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, NextNode->Object);
+            }
+
            /*
             * Found matching entry.
             */
Index: sys/dev/acpi/acpica/Subsystem/nsutils.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/nsutils.c,v
retrieving revision 1.11
diff -u -r1.11 nsutils.c
--- sys/dev/acpi/acpica/Subsystem/nsutils.c     14 Feb 2004 16:57:25 -0000      1.11
+++ sys/dev/acpi/acpica/Subsystem/nsutils.c     17 Jun 2004 04:08:49 -0000
@@ -2,7 +2,7 @@
 *
 * Module Name: nsutils - Utilities for accessing ACPI namespace, accessing
 *                        parents and siblings and Scope manipulation
- *              xRevision: 132 $
+ *              xRevision: 134 $
 *
 *****************************************************************************/

@@ -344,7 +344,7 @@

    if (!Node)
    {
-        ACPI_REPORT_WARNING (("NsGetType: Null Node ptr"));
+        ACPI_REPORT_WARNING (("NsGetType: Null Node input pointer\n"));
        return_VALUE (ACPI_TYPE_ANY);
    }

@@ -1078,9 +1078,7 @@
    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);

Cleanup:
-
    /* Cleanup */
-
    if (InternalPath)
    {
        ACPI_MEM_FREE (InternalPath);
Index: sys/dev/acpi/acpica/Subsystem/nsxfeval.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/nsxfeval.c,v
retrieving revision 1.5
diff -u -r1.5 nsxfeval.c
--- sys/dev/acpi/acpica/Subsystem/nsxfeval.c    14 Feb 2004 16:57:25 -0000      1.5
+++ sys/dev/acpi/acpica/Subsystem/nsxfeval.c    17 Jun 2004 04:08:49 -0000
@@ -2,7 +2,7 @@
 *
 * Module Name: nsxfeval - Public interfaces to the ACPI subsystem
 *                         ACPI Object evaluation interfaces
- *              xRevision: 11 $
+ *              xRevision: 14 $
 *
 ******************************************************************************/

@@ -123,6 +123,7 @@

#include "acpi.h"
#include "acnamesp.h"
+#include "acinterp.h"


#define _COMPONENT          ACPI_NAMESPACE
@@ -234,11 +235,11 @@
 * FUNCTION:    AcpiEvaluateObject
 *
 * PARAMETERS:  Handle              - Object handle (optional)
- *              *Pathname           - Object pathname (optional)
- *              **ExternalParams    - List of parameters to pass to method,
+ *              Pathname            - Object pathname (optional)
+ *              ExternalParams      - List of parameters to pass to method,
 *                                    terminated by NULL.  May be NULL
 *                                    if no parameters are being passed.
- *              *ReturnBuffer       - Where to put method's return value (if
+ *              ReturnBuffer        - Where to put method's return value (if
 *                                    any).  If NULL, no value is returned.
 *
 * RETURN:      Status
@@ -257,8 +258,8 @@
    ACPI_BUFFER             *ReturnBuffer)
{
    ACPI_STATUS             Status;
-    ACPI_OPERAND_OBJECT     **InternalParams = NULL;
-    ACPI_OPERAND_OBJECT     *InternalReturnObj = NULL;
+    ACPI_STATUS             Status2;
+    ACPI_PARAMETER_INFO     Info;
    ACPI_SIZE               BufferSpaceNeeded;
    UINT32                  i;

@@ -266,6 +267,11 @@
    ACPI_FUNCTION_TRACE ("AcpiEvaluateObject");


+    Info.Node = Handle;
+    Info.Parameters = NULL;
+    Info.ReturnObject = NULL;
+    Info.ParameterType = ACPI_PARAM_ARGS;
+
    /*
     * If there are parameters to be passed to the object
     * (which must be a control method), the external objects
@@ -277,9 +283,10 @@
         * Allocate a new parameter block for the internal objects
         * Add 1 to count to allow for null terminated internal list
         */
-        InternalParams = ACPI_MEM_CALLOCATE (((ACPI_SIZE) ExternalParams->Count + 1) *
-                                                sizeof (void *));
-        if (!InternalParams)
+        Info.Parameters = ACPI_MEM_CALLOCATE (
+                                ((ACPI_SIZE) ExternalParams->Count + 1) *
+                                sizeof (void *));
+        if (!Info.Parameters)
        {
            return_ACPI_STATUS (AE_NO_MEMORY);
        }
@@ -291,16 +298,17 @@
        for (i = 0; i < ExternalParams->Count; i++)
        {
            Status = AcpiUtCopyEobjectToIobject (&ExternalParams->Pointer[i],
-                                                &InternalParams[i]);
+                                                 &Info.Parameters[i]);
            if (ACPI_FAILURE (Status))
            {
-                AcpiUtDeleteInternalObjectList (InternalParams);
+                AcpiUtDeleteInternalObjectList (Info.Parameters);
                return_ACPI_STATUS (Status);
            }
        }
-        InternalParams[ExternalParams->Count] = NULL;
+        Info.Parameters[ExternalParams->Count] = NULL;
    }

+
    /*
     * Three major cases:
     * 1) Fully qualified pathname
@@ -313,8 +321,7 @@
        /*
         *  The path is fully qualified, just evaluate by name
         */
-        Status = AcpiNsEvaluateByName (Pathname, InternalParams,
-                    &InternalReturnObj);
+        Status = AcpiNsEvaluateByName (Pathname, &Info);
    }
    else if (!Handle)
    {
@@ -349,16 +356,14 @@
             * The null pathname case means the handle is for
             * the actual object to be evaluated
             */
-            Status = AcpiNsEvaluateByHandle (Handle, InternalParams,
-                            &InternalReturnObj);
+            Status = AcpiNsEvaluateByHandle (&Info);
        }
        else
        {
           /*
            * Both a Handle and a relative Pathname
            */
-            Status = AcpiNsEvaluateRelative (Handle, Pathname, InternalParams,
-                            &InternalReturnObj);
+            Status = AcpiNsEvaluateRelative (Pathname, &Info);
        }
    }

@@ -369,13 +374,13 @@
     */
    if (ReturnBuffer)
    {
-        if (!InternalReturnObj)
+        if (!Info.ReturnObject)
        {
            ReturnBuffer->Length = 0;
        }
        else
        {
-            if (ACPI_GET_DESCRIPTOR_TYPE (InternalReturnObj) == ACPI_DESC_TYPE_NAMED)
+            if (ACPI_GET_DESCRIPTOR_TYPE (Info.ReturnObject) == ACPI_DESC_TYPE_NAMED)
            {
                /*
                 * If we received a NS Node as a return object, this means that
@@ -386,7 +391,7 @@
                 * support for various types at a later date if necessary.
                 */
                Status = AE_TYPE;
-                InternalReturnObj = NULL;   /* No need to delete a NS Node */
+                Info.ReturnObject = NULL;   /* No need to delete a NS Node */
                ReturnBuffer->Length = 0;
            }

@@ -396,7 +401,7 @@
                 * Find out how large a buffer is needed
                 * to contain the returned object
                 */
-                Status = AcpiUtGetObjectSize (InternalReturnObj,
+                Status = AcpiUtGetObjectSize (Info.ReturnObject,
                                                &BufferSpaceNeeded);
                if (ACPI_SUCCESS (Status))
                {
@@ -410,14 +415,15 @@
                         */
                        ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
                            "Needed buffer size %X, %s\n",
-                            (UINT32) BufferSpaceNeeded, AcpiFormatException (Status)));
+                            (UINT32) BufferSpaceNeeded,
+                            AcpiFormatException (Status)));
                    }
                    else
                    {
                        /*
                         *  We have enough space for the object, build it
                         */
-                        Status = AcpiUtCopyIobjectToEobject (InternalReturnObj,
+                        Status = AcpiUtCopyIobjectToEobject (Info.ReturnObject,
                                        ReturnBuffer);
                    }
                }
@@ -425,25 +431,32 @@
        }
    }

-    /* Delete the return and parameter objects */
-
-    if (InternalReturnObj)
+    if (Info.ReturnObject)
    {
        /*
-         * Delete the internal return object. (Or at least
-         * decrement the reference count by one)
+         * Delete the internal return object.  NOTE: Interpreter
+         * must be locked to avoid race condition.
         */
-        AcpiUtRemoveReference (InternalReturnObj);
+        Status2 = AcpiExEnterInterpreter ();
+        if (ACPI_SUCCESS (Status2))
+        {
+            /*
+             * Delete the internal return object. (Or at least
+             * decrement the reference count by one)
+             */
+            AcpiUtRemoveReference (Info.ReturnObject);
+            AcpiExExitInterpreter ();
+        }
    }

    /*
     * Free the input parameter list (if we created one),
     */
-    if (InternalParams)
+    if (Info.Parameters)
    {
        /* Free the allocated parameter block */

-        AcpiUtDeleteInternalObjectList (InternalParams);
+        AcpiUtDeleteInternalObjectList (Info.Parameters);
    }

    return_ACPI_STATUS (Status);
Index: sys/dev/acpi/acpica/Subsystem/nsxfname.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/nsxfname.c,v
retrieving revision 1.10
diff -u -r1.10 nsxfname.c
--- sys/dev/acpi/acpica/Subsystem/nsxfname.c    14 Feb 2004 16:57:25 -0000      1.10
+++ sys/dev/acpi/acpica/Subsystem/nsxfname.c    17 Jun 2004 04:08:49 -0000
@@ -2,7 +2,7 @@
 *
 * Module Name: nsxfname - Public interfaces to the ACPI subsystem
 *                         ACPI Namespace oriented interfaces
- *              xRevision: 99 $
+ *              xRevision: 101 $
 *
 *****************************************************************************/

@@ -377,7 +377,7 @@
    {
        /*
         * Get extra info for ACPI Devices objects only:
-         * Run the Device _HID, _UID, _CID, _STA, and _ADR methods.
+         * Run the Device _HID, _UID, _CID, _STA, _ADR and _SxD methods.
         *
         * Note: none of these methods are required, so they may or may
         * not be present for this device.  The Info.Valid bitfield is used
@@ -427,6 +427,14 @@
            Info.Valid |= ACPI_VALID_ADR;
        }

+        /* Execute the Device._SxD methods */
+
+        Status = AcpiUtExecute_Sxds (Node, Info.HighestDstates);
+        if (ACPI_SUCCESS (Status))
+        {
+            Info.Valid |= ACPI_VALID_SXDS;
+        }
+
        Status = AE_OK;
    }

Index: sys/dev/acpi/acpica/Subsystem/psparse.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/psparse.c,v
retrieving revision 1.11
diff -u -r1.11 psparse.c
--- sys/dev/acpi/acpica/Subsystem/psparse.c     14 Feb 2004 16:57:25 -0000      1.11
+++ sys/dev/acpi/acpica/Subsystem/psparse.c     17 Jun 2004 04:08:50 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Module Name: psparse - Parser top level AML parse routines
- *              xRevision: 143 $
+ *              xRevision: 144 $
 *
 *****************************************************************************/

@@ -525,7 +525,7 @@
    ACPI_STATUS             Status = AE_OK;
    ACPI_PARSE_OBJECT       *Op = NULL;     /* current op */
    ACPI_PARSE_OBJECT       *Arg = NULL;
-    ACPI_PARSE_OBJECT       PreOp;
+    ACPI_PARSE_OBJECT       *PreOp = NULL;
    ACPI_PARSE_STATE        *ParserState;
    UINT8                   *AmlOpStart = NULL;

@@ -657,8 +657,19 @@

            if (WalkState->OpInfo->Flags & AML_NAMED)
            {
-                PreOp.Common.Value.Arg = NULL;
-                PreOp.Common.AmlOpcode = WalkState->Opcode;
+                /* Allocate a new PreOp if necessary */
+
+                if (!PreOp)
+                {
+                    PreOp = AcpiPsAllocOp (WalkState->Opcode);
+                    if (!PreOp)
+                    {
+                        return_ACPI_STATUS (AE_NO_MEMORY);
+                    }
+                }
+
+                PreOp->Common.Value.Arg = NULL;
+                PreOp->Common.AmlOpcode = WalkState->Opcode;

                /*
                 * Get and append arguments until we find the node that contains
@@ -674,7 +685,7 @@
                        goto CloseThisOp;
                    }

-                    AcpiPsAppendArg (&PreOp, Arg);
+                    AcpiPsAppendArg (PreOp, Arg);
                    INCREMENT_ARG_LIST (WalkState->ArgTypes);
                }

@@ -720,7 +731,7 @@
                    goto CloseThisOp;
                }

-                AcpiPsAppendArg (Op, PreOp.Common.Value.Arg);
+                AcpiPsAppendArg (Op, PreOp->Common.Value.Arg);
                AcpiGbl_Depth++;

                if (Op->Common.AmlOpcode == AML_REGION_OP)
@@ -996,6 +1007,11 @@

        AcpiPsCompleteThisOp (WalkState, Op);
        Op = NULL;
+        if (PreOp)
+        {
+            AcpiPsFreeOp (PreOp);
+            PreOp = NULL;
+        }

        switch (Status)
        {
@@ -1288,6 +1304,30 @@
        {
            ACPI_REPORT_METHOD_ERROR ("Method execution failed",
                WalkState->MethodNode, NULL, Status);
+
+            /* Check for possible multi-thread reentrancy problem */
+
+            if ((Status == AE_ALREADY_EXISTS) &&
+                (!WalkState->MethodDesc->Method.Semaphore))
+            {
+                /*
+                 * This method is marked NotSerialized, but it tried to create a named
+                 * object, causing the second thread entrance to fail.  We will workaround
+                 * this by marking the method permanently as Serialized.
+                 */
+                WalkState->MethodDesc->Method.MethodFlags |= AML_METHOD_SERIALIZED;
+                WalkState->MethodDesc->Method.Concurrency = 1;
+            }
+        }
+
+        if (WalkState->MethodDesc)
+        {
+            /* Decrement the thread count on the method parse tree */
+
+            if (WalkState->MethodDesc->Method.ThreadCount)
+            {
+                WalkState->MethodDesc->Method.ThreadCount--;
+            }
        }

        /* We are done with this walk, move on to the parent if any */
Index: sys/dev/acpi/acpica/Subsystem/psscope.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/psscope.c,v
retrieving revision 1.10
diff -u -r1.10 psscope.c
--- sys/dev/acpi/acpica/Subsystem/psscope.c     14 Feb 2004 16:57:25 -0000      1.10
+++ sys/dev/acpi/acpica/Subsystem/psscope.c     17 Jun 2004 04:08:50 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Module Name: psscope - Parser scope stack management routines
- *              xRevision: 37 $
+ *              xRevision: 38 $
 *
 *****************************************************************************/

@@ -245,7 +245,6 @@
        return_ACPI_STATUS (AE_NO_MEMORY);
    }

-
    Scope->Common.DataType         = ACPI_DESC_TYPE_STATE_PSCOPE;
    Scope->ParseScope.Op           = Op;
    Scope->ParseScope.ArgList      = RemainingArgs;
@@ -256,14 +255,12 @@

    AcpiUtPushGenericState (&ParserState->Scope, Scope);

-
    if (ArgCount == ACPI_VAR_ARGS)
    {
        /* multiple arguments */

        Scope->ParseScope.ArgEnd = ParserState->PkgEnd;
    }
-
    else
    {
        /* single argument */
@@ -322,7 +319,6 @@

        AcpiUtDeleteGenericState (Scope);
    }
-
    else
    {
        /* empty parse stack, prepare to fetch next opcode */
@@ -332,7 +328,6 @@
        *ArgCount               = 0;
    }

-
    ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped Op %p Args %X\n", *Op, *ArgCount));
    return_VOID;
}
@@ -357,15 +352,15 @@
{
    ACPI_GENERIC_STATE      *Scope;

+
    ACPI_FUNCTION_TRACE_PTR ("PsCleanupScope", ParserState);


    if (!ParserState)
    {
-        return;
+        return_VOID;
    }

-
    /* Delete anything on the scope stack */

    while (ParserState->Scope)
Index: sys/dev/acpi/acpica/Subsystem/psxface.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/psxface.c,v
retrieving revision 1.10
diff -u -r1.10 psxface.c
--- sys/dev/acpi/acpica/Subsystem/psxface.c     14 Feb 2004 16:57:25 -0000      1.10
+++ sys/dev/acpi/acpica/Subsystem/psxface.c     17 Jun 2004 04:08:50 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Module Name: psxface - Parser external interfaces
- *              xRevision: 71 $
+ *              xRevision: 75 $
 *
 *****************************************************************************/

@@ -134,7 +134,7 @@
 *
 * FUNCTION:    AcpiPsxExecute
 *
- * PARAMETERS:  MethodNode          - A method object containing both the AML
+ * PARAMETERS:  Info->Node          - A method object containing both the AML
 *                                    address and length.
 *              **Params            - List of parameters to pass to method,
 *                                    terminated by NULL. Params itself may be
@@ -150,9 +150,7 @@

ACPI_STATUS
AcpiPsxExecute (
-    ACPI_NAMESPACE_NODE     *MethodNode,
-    ACPI_OPERAND_OBJECT     **Params,
-    ACPI_OPERAND_OBJECT     **ReturnObjDesc)
+    ACPI_PARAMETER_INFO     *Info)
{
    ACPI_STATUS             Status;
    ACPI_OPERAND_OBJECT     *ObjDesc;
@@ -166,12 +164,12 @@

    /* Validate the Node and get the attached object */

-    if (!MethodNode)
+    if (!Info || !Info->Node)
    {
        return_ACPI_STATUS (AE_NULL_ENTRY);
    }

-    ObjDesc = AcpiNsGetAttachedObject (MethodNode);
+    ObjDesc = AcpiNsGetAttachedObject (Info->Node);
    if (!ObjDesc)
    {
        return_ACPI_STATUS (AE_NULL_OBJECT);
@@ -179,21 +177,22 @@

    /* Init for new method, wait on concurrency semaphore */

-    Status = AcpiDsBeginMethodExecution (MethodNode, ObjDesc, NULL);
+    Status = AcpiDsBeginMethodExecution (Info->Node, ObjDesc, NULL);
    if (ACPI_FAILURE (Status))
    {
        return_ACPI_STATUS (Status);
    }

-    if (Params)
+    if ((Info->ParameterType == ACPI_PARAM_ARGS) &&
+        (Info->Parameters))
    {
        /*
         * The caller "owns" the parameters, so give each one an extra
         * reference
         */
-        for (i = 0; Params[i]; i++)
+        for (i = 0; Info->Parameters[i]; i++)
        {
-            AcpiUtAddReference (Params[i]);
+            AcpiUtAddReference (Info->Parameters[i]);
        }
    }

@@ -203,7 +202,7 @@
     */
    ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
        "**** Begin Method Parse **** Entry=%p obj=%p\n",
-        MethodNode, ObjDesc));
+        Info->Node, ObjDesc));

    /* Create and init a Root Node */

@@ -231,8 +230,9 @@
        goto Cleanup2;
    }

-    Status = AcpiDsInitAmlWalk (WalkState, Op, MethodNode, ObjDesc->Method.AmlStart,
-                    ObjDesc->Method.AmlLength, NULL, NULL, 1);
+    Status = AcpiDsInitAmlWalk (WalkState, Op, Info->Node,
+                    ObjDesc->Method.AmlStart,
+                    ObjDesc->Method.AmlLength, NULL, 1);
    if (ACPI_FAILURE (Status))
    {
        goto Cleanup3;
@@ -245,7 +245,6 @@
    if (ACPI_FAILURE (Status))
    {
        goto Cleanup1; /* Walk state is already deleted */
-
    }

    /*
@@ -253,7 +252,7 @@
     */
    ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
        "**** Begin Method Execution **** Entry=%p obj=%p\n",
-        MethodNode, ObjDesc));
+        Info->Node, ObjDesc));

    /* Create and init a Root Node */

@@ -266,8 +265,8 @@

    /* Init new op with the method name and pointer back to the NS node */

-    AcpiPsSetName (Op, MethodNode->Name.Integer);
-    Op->Common.Node = MethodNode;
+    AcpiPsSetName (Op, Info->Node->Name.Integer);
+    Op->Common.Node = Info->Node;

    /* Create and initialize a new walk state */

@@ -278,8 +277,9 @@
        goto Cleanup2;
    }

-    Status = AcpiDsInitAmlWalk (WalkState, Op, MethodNode, ObjDesc->Method.AmlStart,
-                    ObjDesc->Method.AmlLength, Params, ReturnObjDesc, 3);
+    Status = AcpiDsInitAmlWalk (WalkState, Op, Info->Node,
+                    ObjDesc->Method.AmlStart,
+                    ObjDesc->Method.AmlLength, Info, 3);
    if (ACPI_FAILURE (Status))
    {
        goto Cleanup3;
@@ -299,15 +299,16 @@
    AcpiPsDeleteParseTree (Op);

Cleanup1:
-    if (Params)
+    if ((Info->ParameterType == ACPI_PARAM_ARGS) &&
+        (Info->Parameters))
    {
        /* Take away the extra reference that we gave the parameters above */

-        for (i = 0; Params[i]; i++)
+        for (i = 0; Info->Parameters[i]; i++)
        {
            /* Ignore errors, just do them all */

-            (void) AcpiUtUpdateObjectReference (Params[i], REF_DECREMENT);
+            (void) AcpiUtUpdateObjectReference (Info->Parameters[i], REF_DECREMENT);
        }
    }

@@ -320,11 +321,11 @@
     * If the method has returned an object, signal this to the caller with
     * a control exception code
     */
-    if (*ReturnObjDesc)
+    if (Info->ReturnObject)
    {
        ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Method returned ObjDesc=%p\n",
-            *ReturnObjDesc));
-        ACPI_DUMP_STACK_ENTRY (*ReturnObjDesc);
+            Info->ReturnObject));
+        ACPI_DUMP_STACK_ENTRY (Info->ReturnObject);

        Status = AE_CTRL_RETURN_VALUE;
    }
Index: sys/dev/acpi/acpica/Subsystem/rsaddr.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/rsaddr.c,v
retrieving revision 1.10
diff -u -r1.10 rsaddr.c
--- sys/dev/acpi/acpica/Subsystem/rsaddr.c      14 Feb 2004 16:57:25 -0000      1.10
+++ sys/dev/acpi/acpica/Subsystem/rsaddr.c      17 Jun 2004 04:08:50 -0000
@@ -1,7 +1,7 @@
/*******************************************************************************
 *
 * Module Name: rsaddr - Address resource descriptors (16/32/64)
- *              xRevision: 34 $
+ *              xRevision: 35 $
 *
 ******************************************************************************/

@@ -165,6 +165,7 @@

    ACPI_FUNCTION_TRACE ("RsAddress16Resource");

+
    /*
     * Point past the Descriptor to get the number of bytes consumed
     */
@@ -229,7 +230,7 @@
        OutputStruct->Data.Address16.Attribute.Memory.ReadWriteAttribute =
                (UINT16) (Temp8 & 0x01);
        OutputStruct->Data.Address16.Attribute.Memory.CacheAttribute =
-                (UINT16) ((Temp8 >> 1) & 0x0F);
+                (UINT16) ((Temp8 >> 1) & 0x03);
    }
    else
    {
@@ -434,7 +435,7 @@

        Temp8 |=
            (LinkedList->Data.Address16.Attribute.Memory.CacheAttribute &
-             0x0F) << 1;
+             0x03) << 1;
    }
    else if (ACPI_IO_RANGE == LinkedList->Data.Address16.ResourceType)
    {
@@ -631,7 +632,7 @@
                (UINT16) (Temp8 & 0x01);

        OutputStruct->Data.Address32.Attribute.Memory.CacheAttribute =
-                (UINT16) ((Temp8 >> 1) & 0x0F);
+                (UINT16) ((Temp8 >> 1) & 0x03);
    }
    else
    {
@@ -834,7 +835,7 @@

        Temp8 |=
            (LinkedList->Data.Address32.Attribute.Memory.CacheAttribute &
-             0x0F) << 1;
+             0x03) << 1;
    }
    else if (ACPI_IO_RANGE == LinkedList->Data.Address32.ResourceType)
    {
@@ -1030,7 +1031,7 @@
                (UINT16) (Temp8 & 0x01);

        OutputStruct->Data.Address64.Attribute.Memory.CacheAttribute =
-                (UINT16) ((Temp8 >> 1) & 0x0F);
+                (UINT16) ((Temp8 >> 1) & 0x03);
    }
    else
    {
@@ -1235,7 +1236,7 @@

        Temp8 |=
            (LinkedList->Data.Address64.Attribute.Memory.CacheAttribute &
-             0x0F) << 1;
+             0x03) << 1;
    }
    else if (ACPI_IO_RANGE == LinkedList->Data.Address64.ResourceType)
    {
Index: sys/dev/acpi/acpica/Subsystem/rsutils.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/rsutils.c,v
retrieving revision 1.10
diff -u -r1.10 rsutils.c
--- sys/dev/acpi/acpica/Subsystem/rsutils.c     14 Feb 2004 16:57:25 -0000      1.10
+++ sys/dev/acpi/acpica/Subsystem/rsutils.c     17 Jun 2004 04:08:51 -0000
@@ -1,7 +1,7 @@
/*******************************************************************************
 *
 * Module Name: rsutils - Utilities for the resource manager
- *              xRevision: 38 $
+ *              xRevision: 39 $
 *
 ******************************************************************************/

@@ -370,6 +370,7 @@
    ACPI_HANDLE             Handle,
    ACPI_BUFFER             *InBuffer)
{
+    ACPI_PARAMETER_INFO     Info;
    ACPI_OPERAND_OBJECT     *Params[2];
    ACPI_STATUS             Status;
    ACPI_BUFFER             Buffer;
@@ -412,10 +413,14 @@
    Params[0]->Common.Flags   = AOPOBJ_DATA_VALID;
    Params[1] = NULL;

+    Info.Node = Handle;
+    Info.Parameters = Params;
+    Info.ParameterType = ACPI_PARAM_ARGS;
+
    /*
     * Execute the method, no return value
     */
-    Status = AcpiNsEvaluateRelative (Handle, "_SRS", Params, NULL);
+    Status = AcpiNsEvaluateRelative ("_SRS", &Info);

    /*
     * Clean up and return the status from AcpiNsEvaluateRelative
Index: sys/dev/acpi/acpica/Subsystem/rsxface.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/rsxface.c,v
retrieving revision 1.10
diff -u -r1.10 rsxface.c
--- sys/dev/acpi/acpica/Subsystem/rsxface.c     14 Feb 2004 16:57:25 -0000      1.10
+++ sys/dev/acpi/acpica/Subsystem/rsxface.c     17 Jun 2004 04:08:51 -0000
@@ -1,7 +1,7 @@
/*******************************************************************************
 *
 * Module Name: rsxface - Public interfaces to the resource manager
- *              xRevision: 28 $
+ *              xRevision: 30 $
 *
 ******************************************************************************/

@@ -323,6 +323,7 @@
    ACPI_STATUS                 Status;
    ACPI_BUFFER                 Buffer = {ACPI_ALLOCATE_BUFFER, NULL};
    ACPI_RESOURCE               *Resource;
+    ACPI_RESOURCE               *BufferEnd;


    ACPI_FUNCTION_TRACE ("AcpiWalkResources");
@@ -341,7 +342,14 @@
        return_ACPI_STATUS (Status);
    }

-    Resource = (ACPI_RESOURCE *) Buffer.Pointer;
+    /* Setup pointers */
+
+    Resource  = (ACPI_RESOURCE *) Buffer.Pointer;
+    BufferEnd = ACPI_CAST_PTR (ACPI_RESOURCE,
+                    ((UINT8 *) Buffer.Pointer + Buffer.Length));
+
+    /* Walk the resource list */
+
    for (;;)
    {
        if (!Resource || Resource->Id == ACPI_RSTYPE_END_TAG)
@@ -357,6 +365,7 @@
        case AE_CTRL_DEPTH:

            /* Just keep going */
+
            Status = AE_OK;
            break;

@@ -374,7 +383,16 @@
            goto Cleanup;
        }

+        /* Get the next resource descriptor */
+
        Resource = ACPI_NEXT_RESOURCE (Resource);
+
+        /* Check for end-of-buffer */
+
+        if (Resource >= BufferEnd)
+        {
+            goto Cleanup;
+        }
    }

Cleanup:
Index: sys/dev/acpi/acpica/Subsystem/tbxfroot.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/tbxfroot.c,v
retrieving revision 1.11
diff -u -r1.11 tbxfroot.c
--- sys/dev/acpi/acpica/Subsystem/tbxfroot.c    14 Feb 2004 16:57:25 -0000      1.11
+++ sys/dev/acpi/acpica/Subsystem/tbxfroot.c    17 Jun 2004 04:08:51 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Module Name: tbxfroot - Find the root ACPI table (RSDT)
- *              xRevision: 72 $
+ *              xRevision: 73 $
 *
 *****************************************************************************/

@@ -489,14 +489,17 @@
 *              Flags                   - Current memory mode (logical vs.
 *                                        physical addressing)
 *
- * RETURN:      Status
+ * RETURN:      Status, RSDP physical address
 *
 * DESCRIPTION: Search lower 1Mbyte of memory for the root system descriptor
 *              pointer structure.  If it is found, set *RSDP to point to it.
 *
- *              NOTE: The RSDP must be either in the first 1K of the Extended
- *              BIOS Data Area or between E0000 and FFFFF (ACPI 1.0 section
- *              5.2.2; assertion #421).
+ *              NOTE1: The RSDP must be either in the first 1K of the Extended
+ *              BIOS Data Area or between E0000 and FFFFF (From ACPI Spec.)
+ *              Only a 32-bit physical address is necessary.
+ *
+ *              NOTE2: This function is always available, regardless of the
+ *              initialization state of the rest of ACPI.
 *
 ******************************************************************************/

@@ -507,8 +510,8 @@
{
    UINT8                   *TablePtr;
    UINT8                   *MemRover;
-    UINT64                  PhysAddr;
-    ACPI_STATUS             Status = AE_OK;
+    UINT32                  PhysicalAddress;
+    ACPI_STATUS             Status;


    ACPI_FUNCTION_TRACE ("TbFindRsdp");
@@ -520,39 +523,62 @@
    if ((Flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING)
    {
        /*
-         * 1) Search EBDA (low memory) paragraphs
+         * 1a) Get the location of the EBDA
         */
-        Status = AcpiOsMapMemory ((UINT64) ACPI_LO_RSDP_WINDOW_BASE, ACPI_LO_RSDP_WINDOW_SIZE,
+        Status = AcpiOsMapMemory ((ACPI_PHYSICAL_ADDRESS) ACPI_EBDA_PTR_LOCATION,
+                                    ACPI_EBDA_PTR_LENGTH,
                                    (void *) &TablePtr);
        if (ACPI_FAILURE (Status))
        {
-            ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not map memory at %X for length %X\n",
-                ACPI_LO_RSDP_WINDOW_BASE, ACPI_LO_RSDP_WINDOW_SIZE));
+            ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not map memory at %8.8X for length %X\n",
+                ACPI_EBDA_PTR_LOCATION, ACPI_EBDA_PTR_LENGTH));
            return_ACPI_STATUS (Status);
        }

-        MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_LO_RSDP_WINDOW_SIZE);
-        AcpiOsUnmapMemory (TablePtr, ACPI_LO_RSDP_WINDOW_SIZE);
+        ACPI_MOVE_16_TO_32 (&PhysicalAddress, TablePtr);
+        PhysicalAddress <<= 4;                  /* Convert segment to physical address */
+        AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_PTR_LENGTH);
+
+        /* EBDA present? */
+
+        if (PhysicalAddress > 0x400)
+        {
+            /*
+             * 1b) Search EBDA paragraphs (EBDA is required to be a minimum of 1K length)
+             */
+            Status = AcpiOsMapMemory ((ACPI_PHYSICAL_ADDRESS) PhysicalAddress,
+                                        ACPI_EBDA_WINDOW_SIZE,
+                                        (void *) &TablePtr);
+            if (ACPI_FAILURE (Status))
+            {
+                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not map memory at %8.8X for length %X\n",
+                    PhysicalAddress, ACPI_EBDA_WINDOW_SIZE));
+                return_ACPI_STATUS (Status);
+            }

-        if (MemRover)
-        {
-            /* Found it, return the physical address */
+            MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_EBDA_WINDOW_SIZE);
+            AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_WINDOW_SIZE);
+
+            if (MemRover)
+            {
+                /* Found it, return the physical address */

-            PhysAddr = ACPI_LO_RSDP_WINDOW_BASE;
-            PhysAddr += ACPI_PTR_DIFF (MemRover,TablePtr);
+                PhysicalAddress += ACPI_PTR_DIFF (MemRover, TablePtr);

-            TableInfo->PhysicalAddress = PhysAddr;
-            return_ACPI_STATUS (AE_OK);
+                TableInfo->PhysicalAddress = (ACPI_PHYSICAL_ADDRESS) PhysicalAddress;
+                return_ACPI_STATUS (AE_OK);
+            }
        }

        /*
-         * 2) Search upper memory: 16-byte boundaries in E0000h-F0000h
+         * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh
         */
-        Status = AcpiOsMapMemory ((UINT64) ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE,
+        Status = AcpiOsMapMemory ((ACPI_PHYSICAL_ADDRESS) ACPI_HI_RSDP_WINDOW_BASE,
+                                    ACPI_HI_RSDP_WINDOW_SIZE,
                                    (void *) &TablePtr);
        if (ACPI_FAILURE (Status))
        {
-            ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not map memory at %X for length %X\n",
+            ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not map memory at %8.8X for length %X\n",
                ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE));
            return_ACPI_STATUS (Status);
        }
@@ -564,10 +590,9 @@
        {
            /* Found it, return the physical address */

-            PhysAddr = ACPI_HI_RSDP_WINDOW_BASE;
-            PhysAddr += ACPI_PTR_DIFF (MemRover, TablePtr);
+            PhysicalAddress = ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (MemRover, TablePtr);

-            TableInfo->PhysicalAddress = PhysAddr;
+            TableInfo->PhysicalAddress = (ACPI_PHYSICAL_ADDRESS) PhysicalAddress;
            return_ACPI_STATUS (AE_OK);
        }
    }
@@ -578,20 +603,31 @@
    else
    {
        /*
-         * 1) Search EBDA (low memory) paragraphs
+         * 1a) Get the location of the EBDA
         */
-        MemRover = AcpiTbScanMemoryForRsdp (ACPI_PHYSADDR_TO_PTR (ACPI_LO_RSDP_WINDOW_BASE),
-                        ACPI_LO_RSDP_WINDOW_SIZE);
-        if (MemRover)
+        ACPI_MOVE_16_TO_32 (&PhysicalAddress, ACPI_EBDA_PTR_LOCATION);
+        PhysicalAddress <<= 4;      /* Convert segment to physical address */
+
+        /* EBDA present? */
+
+        if (PhysicalAddress > 0x400)
        {
-            /* Found it, return the physical address */
+            /*
+             * 1b) Search EBDA paragraphs (EBDA is required to be a minimum of 1K length)
+             */
+            MemRover = AcpiTbScanMemoryForRsdp (ACPI_PHYSADDR_TO_PTR (PhysicalAddress),
+                            ACPI_EBDA_WINDOW_SIZE);
+            if (MemRover)
+            {
+                /* Found it, return the physical address */

-            TableInfo->PhysicalAddress = ACPI_TO_INTEGER (MemRover);
-            return_ACPI_STATUS (AE_OK);
+                TableInfo->PhysicalAddress = ACPI_TO_INTEGER (MemRover);
+                return_ACPI_STATUS (AE_OK);
+            }
        }

        /*
-         * 2) Search upper memory: 16-byte boundaries in E0000h-F0000h
+         * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh
         */
        MemRover = AcpiTbScanMemoryForRsdp (ACPI_PHYSADDR_TO_PTR (ACPI_HI_RSDP_WINDOW_BASE),
                        ACPI_HI_RSDP_WINDOW_SIZE);
Index: sys/dev/acpi/acpica/Subsystem/uteval.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/uteval.c,v
retrieving revision 1.10
diff -u -r1.10 uteval.c
--- sys/dev/acpi/acpica/Subsystem/uteval.c      14 Feb 2004 16:57:25 -0000      1.10
+++ sys/dev/acpi/acpica/Subsystem/uteval.c      17 Jun 2004 04:08:51 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Module Name: uteval - Object evaluation
- *              xRevision: 50 $
+ *              xRevision: 54 $
 *
 *****************************************************************************/

@@ -130,6 +130,66 @@

/*******************************************************************************
 *
+ * FUNCTION:    AcpiUtOsiImplementation
+ *
+ * PARAMETERS:  WalkState           - Current walk state
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Implementation of _OSI predefined control method
+ *              Supported = _OSI (String)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtOsiImplementation (
+    ACPI_WALK_STATE         *WalkState)
+{
+    ACPI_OPERAND_OBJECT     *StringDesc;
+    ACPI_OPERAND_OBJECT     *ReturnDesc;
+    ACPI_NATIVE_UINT        i;
+
+
+    ACPI_FUNCTION_TRACE ("UtOsiImplementation");
+
+
+    /* Validate the string input argument */
+
+    StringDesc = WalkState->Arguments[0].Object;
+    if (!StringDesc || (StringDesc->Common.Type != ACPI_TYPE_STRING))
+    {
+        return_ACPI_STATUS (AE_TYPE);
+    }
+
+    /* Create a return object (Default value = 0) */
+
+    ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+    if (!ReturnDesc)
+    {
+        return_ACPI_STATUS (AE_NO_MEMORY);
+    }
+
+    /* Compare input string to table of supported strings */
+
+    for (i = 0; i < ACPI_NUM_OSI_STRINGS; i++)
+    {
+        if (!ACPI_STRCMP (StringDesc->String.Pointer,
+                            (char *) AcpiGbl_ValidOsiStrings[i]))
+        {
+            /* This string is supported */
+
+            ReturnDesc->Integer.Value = 0xFFFFFFFF;
+            break;
+        }
+    }
+
+    WalkState->ReturnDesc = ReturnDesc;
+    return_ACPI_STATUS (AE_CTRL_TERMINATE);
+}
+
+
+/*******************************************************************************
+ *
 * FUNCTION:    AcpiUtEvaluateObject
 *
 * PARAMETERS:  PrefixNode          - Starting node
@@ -154,7 +214,7 @@
    UINT32                  ExpectedReturnBtypes,
    ACPI_OPERAND_OBJECT     **ReturnDesc)
{
-    ACPI_OPERAND_OBJECT     *ObjDesc;
+    ACPI_PARAMETER_INFO     Info;
    ACPI_STATUS             Status;
    UINT32                  ReturnBtype;

@@ -162,9 +222,13 @@
    ACPI_FUNCTION_TRACE ("UtEvaluateObject");


+    Info.Node = PrefixNode;
+    Info.Parameters = NULL;
+    Info.ParameterType = ACPI_PARAM_ARGS;
+
    /* Evaluate the object/method */

-    Status = AcpiNsEvaluateRelative (PrefixNode, Path, NULL, &ObjDesc);
+    Status = AcpiNsEvaluateRelative (Path, &Info);
    if (ACPI_FAILURE (Status))
    {
        if (Status == AE_NOT_FOUND)
@@ -183,7 +247,7 @@

    /* Did we get a return object? */

-    if (!ObjDesc)
+    if (!Info.ReturnObject)
    {
        if (ExpectedReturnBtypes)
        {
@@ -198,7 +262,7 @@

    /* Map the return object type to the bitmapped type */

-    switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
+    switch (ACPI_GET_OBJECT_TYPE (Info.ReturnObject))
    {
    case ACPI_TYPE_INTEGER:
        ReturnBtype = ACPI_BTYPE_INTEGER;
@@ -230,17 +294,17 @@

        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
            "Type returned from %s was incorrect: %X\n",
-            Path, ACPI_GET_OBJECT_TYPE (ObjDesc)));
+            Path, ACPI_GET_OBJECT_TYPE (Info.ReturnObject)));

        /* On error exit, we must delete the return object */

-        AcpiUtRemoveReference (ObjDesc);
+        AcpiUtRemoveReference (Info.ReturnObject);
        return_ACPI_STATUS (AE_TYPE);
    }

    /* Object type is OK, return it */

-    *ReturnDesc = ObjDesc;
+    *ReturnDesc = Info.ReturnObject;
    return_ACPI_STATUS (AE_OK);
}

@@ -667,3 +731,67 @@
    AcpiUtRemoveReference (ObjDesc);
    return_ACPI_STATUS (Status);
}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiUtExecute_Sxds
+ *
+ * PARAMETERS:  DeviceNode          - Node for the device
+ *              *Flags              - Where the status flags are returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Executes _STA for selected device and stores results in
+ *              *Flags.
+ *
+ *              NOTE: Internal function, no parameter validation
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtExecute_Sxds (
+    ACPI_NAMESPACE_NODE     *DeviceNode,
+    UINT8                   *Highest)
+{
+    ACPI_OPERAND_OBJECT     *ObjDesc;
+    ACPI_STATUS             Status;
+    UINT32                  i;
+
+
+    ACPI_FUNCTION_TRACE ("UtExecute_Sxds");
+
+
+    for (i = 0; i < 4; i++)
+    {
+        Highest[i] = 0xFF;
+        Status = AcpiUtEvaluateObject (DeviceNode,
+                    (char *) AcpiGbl_HighestDstateNames[i],
+                    ACPI_BTYPE_INTEGER, &ObjDesc);
+        if (ACPI_FAILURE (Status))
+        {
+            if (Status != AE_NOT_FOUND)
+            {
+                ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+                    "%s on Device %4.4s, %s\n",
+                    (char *) AcpiGbl_HighestDstateNames[i],
+                    AcpiUtGetNodeName (DeviceNode),
+                    AcpiFormatException (Status)));
+
+                return_ACPI_STATUS (Status);
+            }
+        }
+        else
+        {
+            /* Extract the Dstate value */
+
+            Highest[i] = (UINT8) ObjDesc->Integer.Value;
+
+            /* Delete the return object */
+
+            AcpiUtRemoveReference (ObjDesc);
+        }
+    }
+
+    return_ACPI_STATUS (AE_OK);
+}
Index: sys/dev/acpi/acpica/Subsystem/utglobal.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/utglobal.c,v
retrieving revision 1.11
diff -u -r1.11 utglobal.c
--- sys/dev/acpi/acpica/Subsystem/utglobal.c    14 Feb 2004 16:57:25 -0000      1.11
+++ sys/dev/acpi/acpica/Subsystem/utglobal.c    17 Jun 2004 04:08:52 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Module Name: utglobal - Global variables for the ACPI subsystem
- *              xRevision: 192 $
+ *              xRevision: 201 $
 *
 *****************************************************************************/

@@ -254,13 +254,40 @@

const UINT8                 AcpiGbl_DecodeTo8bit [8] = {1,2,4,8,16,32,64,128};

-const char                  *AcpiGbl_DbSleepStates[ACPI_S_STATE_COUNT] = {
-                                "\\_S0_",
-                                "\\_S1_",
-                                "\\_S2_",
-                                "\\_S3_",
-                                "\\_S4_",
-                                "\\_S5_"};
+const char                  *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT] =
+{
+    "\\_S0_",
+    "\\_S1_",
+    "\\_S2_",
+    "\\_S3_",
+    "\\_S4_",
+    "\\_S5_"
+};
+
+const char                  *AcpiGbl_HighestDstateNames[4] =
+{
+    "_S1D",
+    "_S2D",
+    "_S3D",
+    "_S4D"
+};
+
+/*
+ * Strings supported by the _OSI predefined (internal) method.
+ * When adding strings, be sure to update ACPI_NUM_OSI_STRINGS.
+ */
+const char                  *AcpiGbl_ValidOsiStrings[ACPI_NUM_OSI_STRINGS] =
+{
+    "Linux",
+    "Windows 2000",
+    "Windows 2001",
+    "Windows 2001.1",
+    "Windows 2001 SP0",
+    "Windows 2001 SP1",
+    "Windows 2001 SP2",
+    "Windows 2001 SP3",
+    "Windows 2001 SP4"
+};


/******************************************************************************
@@ -273,26 +300,22 @@
/*
 * Predefined ACPI Names (Built-in to the Interpreter)
 *
- * Initial values are currently supported only for types String and Number.
- * Both are specified as strings in this table.
- *
 * NOTES:
- * 1) _SB_ is defined to be a device to allow _SB_/_INI to be run
+ * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run
 *    during the initialization sequence.
 */
-
const ACPI_PREDEFINED_NAMES     AcpiGbl_PreDefinedNames[] =
{
    {"_GPE",    ACPI_TYPE_LOCAL_SCOPE,      NULL},
    {"_PR_",    ACPI_TYPE_LOCAL_SCOPE,      NULL},
    {"_SB_",    ACPI_TYPE_DEVICE,           NULL},
    {"_SI_",    ACPI_TYPE_LOCAL_SCOPE,      NULL},
-    {"_TZ_",    ACPI_TYPE_LOCAL_SCOPE,      NULL},
+    {"_TZ_",    ACPI_TYPE_THERMAL,          NULL},
    {"_REV",    ACPI_TYPE_INTEGER,          "2"},
    {"_OS_",    ACPI_TYPE_STRING,           ACPI_OS_NAME},
    {"_GL_",    ACPI_TYPE_MUTEX,            "0"},

-#if defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
+#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
    {"_OSI",    ACPI_TYPE_METHOD,           "1"},
#endif
    {NULL,      ACPI_TYPE_ANY,              NULL}              /* Table terminator */
@@ -303,7 +326,6 @@
 * Properties of the ACPI Object Types, both internal and external.
 * The table is indexed by values of ACPI_OBJECT_TYPE
 */
-
const UINT8                     AcpiGbl_NsProperties[] =
{
    ACPI_NS_NORMAL,                     /* 00 Any              */
@@ -328,14 +350,15 @@
    ACPI_NS_NORMAL,                     /* 19 IndexField       */
    ACPI_NS_NORMAL,                     /* 20 Reference        */
    ACPI_NS_NORMAL,                     /* 21 Alias            */
-    ACPI_NS_NORMAL,                     /* 22 Notify           */
-    ACPI_NS_NORMAL,                     /* 23 Address Handler  */
-    ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL,   /* 24 Resource Desc    */
-    ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL,   /* 25 Resource Field   */
-    ACPI_NS_NEWSCOPE,                   /* 26 Scope            */
-    ACPI_NS_NORMAL,                     /* 27 Extra            */
-    ACPI_NS_NORMAL,                     /* 28 Data             */
-    ACPI_NS_NORMAL                      /* 29 Invalid          */
+    ACPI_NS_NORMAL,                     /* 22 MethodAlias      */
+    ACPI_NS_NORMAL,                     /* 23 Notify           */
+    ACPI_NS_NORMAL,                     /* 24 Address Handler  */
+    ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL,   /* 25 Resource Desc    */
+    ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL,   /* 26 Resource Field   */
+    ACPI_NS_NEWSCOPE,                   /* 27 Scope            */
+    ACPI_NS_NORMAL,                     /* 28 Extra            */
+    ACPI_NS_NORMAL,                     /* 29 Data             */
+    ACPI_NS_NORMAL                      /* 30 Invalid          */
};


@@ -382,10 +405,8 @@
 *
 ******************************************************************************/

-
ACPI_TABLE_LIST             AcpiGbl_TableLists[NUM_ACPI_TABLE_TYPES];

-
ACPI_TABLE_SUPPORT          AcpiGbl_TableData[NUM_ACPI_TABLE_TYPES] =
{
    /***********    Name,   Signature, Global typed pointer     Signature size,      Type                  How many allowed?,    Contains valid AML? */
@@ -549,9 +570,8 @@
 *
 * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching; when
 * stored in a table it really means that we have thus far seen no evidence to
- * indicatewhat type is actually going to be stored for this entry.
+ * indicate what type is actually going to be stored for this entry.
 */
-
static const char           AcpiGbl_BadType[] = "UNDEFINED";
#define TYPE_NAME_LENGTH    12                           /* Maximum length of each string */

@@ -579,14 +599,15 @@
    /* 19 */ "IndexField",
    /* 20 */ "Reference",
    /* 21 */ "Alias",
-    /* 22 */ "Notify",
-    /* 23 */ "AddrHandler",
-    /* 24 */ "ResourceDesc",
-    /* 25 */ "ResourceFld",
-    /* 26 */ "Scope",
-    /* 27 */ "Extra",
-    /* 28 */ "Data",
-    /* 39 */ "Invalid"
+    /* 22 */ "MethodAlias",
+    /* 23 */ "Notify",
+    /* 24 */ "AddrHandler",
+    /* 25 */ "ResourceDesc",
+    /* 26 */ "ResourceFld",
+    /* 27 */ "Scope",
+    /* 28 */ "Extra",
+    /* 29 */ "Data",
+    /* 30 */ "Invalid"
};


@@ -634,26 +655,40 @@
AcpiUtGetNodeName (
    void                    *Object)
{
-    ACPI_NAMESPACE_NODE     *Node;
+    ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) Object;
+

+    /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */

    if (!Object)
    {
-        return ("NULL NODE");
+        return ("NULL");
+    }
+
+    /* Check for Root node */
+
+    if ((Object == ACPI_ROOT_OBJECT) ||
+        (Object == AcpiGbl_RootNode))
+    {
+        return ("\"\\\" ");
    }

-    Node = (ACPI_NAMESPACE_NODE *) Object;
+    /* Descriptor must be a namespace node */

    if (Node->Descriptor != ACPI_DESC_TYPE_NAMED)
    {
-        return ("****");
+        return ("####");
    }

+    /* Name must be a valid ACPI name */
+
    if (!AcpiUtValidAcpiName (* (UINT32 *) Node->Name.Ascii))
    {
-        return ("----");
+        return ("????");
    }

+    /* Return the name */
+
    return (Node->Name.Ascii);
}

@@ -856,6 +891,7 @@

    ACPI_FUNCTION_TRACE ("UtInitGlobals");

+
    /* Memory allocation and cache lists */

    ACPI_MEMSET (AcpiGbl_MemoryLists, 0, sizeof (ACPI_MEMORY_LIST) * ACPI_NUM_MEM_LISTS);
@@ -948,6 +984,7 @@
    /* Hardware oriented */

    AcpiGbl_EventsInitialized           = FALSE;
+    AcpiGbl_SystemAwakeAndRunning       = TRUE;

    /* Namespace */

Index: sys/dev/acpi/acpica/Subsystem/utmisc.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/utmisc.c,v
retrieving revision 1.10
diff -u -r1.10 utmisc.c
--- sys/dev/acpi/acpica/Subsystem/utmisc.c      14 Feb 2004 16:57:25 -0000      1.10
+++ sys/dev/acpi/acpica/Subsystem/utmisc.c      17 Jun 2004 04:08:52 -0000
@@ -1,7 +1,7 @@
/*******************************************************************************
 *
 * Module Name: utmisc - common utility procedures
- *              xRevision: 99 $
+ *              xRevision: 100 $
 *
 ******************************************************************************/

@@ -639,6 +639,7 @@
    return (SrcString);
}

+
/*******************************************************************************
 *
 * FUNCTION:    AcpiUtMutexInitialize
@@ -674,10 +675,8 @@
        }
    }

-
    Status = AcpiOsCreateLock (&AcpiGbl_GpeLock);
-
-    return_ACPI_STATUS (AE_OK);
+    return_ACPI_STATUS (Status);
}


Index: sys/dev/acpi/acpica/Subsystem/utxface.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpica/Subsystem/utxface.c,v
retrieving revision 1.11
diff -u -r1.11 utxface.c
--- sys/dev/acpi/acpica/Subsystem/utxface.c     14 Feb 2004 16:57:25 -0000      1.11
+++ sys/dev/acpi/acpica/Subsystem/utxface.c     17 Jun 2004 04:08:52 -0000
@@ -1,7 +1,7 @@
/******************************************************************************
 *
 * Module Name: utxface - External interfaces for "global" ACPI functions
- *              xRevision: 105 $
+ *              xRevision: 106 $
 *
 *****************************************************************************/

@@ -240,9 +240,8 @@
        }
    }

-    /*
-     * Enable ACPI mode
-     */
+    /* Enable ACPI mode */
+
    if (!(Flags & ACPI_NO_ACPI_ENABLE))
    {
        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n"));
@@ -258,7 +257,23 @@
    }

    /*
-     * Initialize ACPI Event handling
+     * Install the default OpRegion handlers.  These are installed unless
+     * other handlers have already been installed via the
+     * InstallAddressSpaceHandler interface.
+     */
+    if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT))
+    {
+        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Installing default address space handlers\n"));
+
+        Status = AcpiEvInstallRegionHandlers ();
+        if (ACPI_FAILURE (Status))
+        {
+            return_ACPI_STATUS (Status);
+        }
+    }
+
+    /*
+     * Initialize ACPI Event handling (Fixed and General Purpose)
     *
     * NOTE: We must have the hardware AND events initialized before we can execute
     * ANY control methods SAFELY.  Any control method can require ACPI hardware
@@ -268,20 +283,20 @@
    {
        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI events\n"));

-        Status = AcpiEvInitialize ();
+        Status = AcpiEvInitializeEvents ();
        if (ACPI_FAILURE (Status))
        {
            return_ACPI_STATUS (Status);
        }
    }

-    /* Install the SCI handler, Global Lock handler, and GPE handlers */
+    /* Install the SCI handler and Global Lock handler */

    if (!(Flags & ACPI_NO_HANDLER_INIT))
    {
-        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Installing SCI/GL/GPE handlers\n"));
+        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Installing SCI/GL handlers\n"));

-        Status = AcpiEvHandlerInitialize ();
+        Status = AcpiEvInstallXruptHandlers ();
        if (ACPI_FAILURE (Status))
        {
            return_ACPI_STATUS (Status);
@@ -315,19 +330,17 @@


    /*
-     * Install the default OpRegion handlers.  These are installed unless
-     * other handlers have already been installed via the
-     * InstallAddressSpaceHandler interface.
+     * Run all _REG methods
     *
-     * NOTE: This will cause _REG methods to be run.  Any objects accessed
+     * NOTE: Any objects accessed
     * by the _REG methods will be automatically initialized, even if they
     * contain executable AML (see call to AcpiNsInitializeObjects below).
     */
    if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT))
    {
-        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Installing default address space handlers\n"));
+        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Executing _REG OpRegion methods\n"));

-        Status = AcpiEvInitAddressSpaces ();
+        Status = AcpiEvInitializeOpRegions ();
        if (ACPI_FAILURE (Status))
        {
            return_ACPI_STATUS (Status);
@@ -341,7 +354,7 @@
     */
    if (!(Flags & ACPI_NO_OBJECT_INIT))
    {
-        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI Objects\n"));
+        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Completing Initialization of ACPI Objects\n"));

        Status = AcpiNsInitializeObjects ();
        if (ACPI_FAILURE (Status))