]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] ACPI patch 5/9
authorAndy Grover <agrover@groveronline.com>
Fri, 15 Mar 2002 07:28:40 +0000 (23:28 -0800)
committerLinus Torvalds <torvalds@home.transmeta.com>
Fri, 15 Mar 2002 07:28:40 +0000 (23:28 -0800)
This is the update to the core interpreter code.

146 files changed:
drivers/acpi/debugger/Makefile
drivers/acpi/debugger/dbcmds.c
drivers/acpi/debugger/dbdisasm.c
drivers/acpi/debugger/dbdisply.c
drivers/acpi/debugger/dbexec.c
drivers/acpi/debugger/dbfileio.c
drivers/acpi/debugger/dbhistry.c
drivers/acpi/debugger/dbinput.c
drivers/acpi/debugger/dbstats.c
drivers/acpi/debugger/dbutils.c
drivers/acpi/debugger/dbxface.c
drivers/acpi/dispatcher/Makefile
drivers/acpi/dispatcher/dsfield.c
drivers/acpi/dispatcher/dsmethod.c
drivers/acpi/dispatcher/dsmthdat.c
drivers/acpi/dispatcher/dsobject.c
drivers/acpi/dispatcher/dsopcode.c
drivers/acpi/dispatcher/dsutils.c
drivers/acpi/dispatcher/dswexec.c
drivers/acpi/dispatcher/dswload.c
drivers/acpi/dispatcher/dswscope.c
drivers/acpi/dispatcher/dswstate.c
drivers/acpi/driver.c [deleted file]
drivers/acpi/events/Makefile
drivers/acpi/events/evevent.c
drivers/acpi/events/evmisc.c
drivers/acpi/events/evregion.c
drivers/acpi/events/evrgnini.c
drivers/acpi/events/evsci.c
drivers/acpi/events/evxface.c
drivers/acpi/events/evxfevnt.c
drivers/acpi/events/evxfregn.c
drivers/acpi/executer/Makefile
drivers/acpi/executer/exconfig.c
drivers/acpi/executer/exconvrt.c
drivers/acpi/executer/excreate.c
drivers/acpi/executer/exdump.c
drivers/acpi/executer/exfield.c
drivers/acpi/executer/exfldio.c
drivers/acpi/executer/exmisc.c
drivers/acpi/executer/exmutex.c
drivers/acpi/executer/exnames.c
drivers/acpi/executer/exoparg1.c
drivers/acpi/executer/exoparg2.c
drivers/acpi/executer/exoparg3.c
drivers/acpi/executer/exoparg6.c
drivers/acpi/executer/exprep.c
drivers/acpi/executer/exregion.c
drivers/acpi/executer/exresnte.c
drivers/acpi/executer/exresolv.c
drivers/acpi/executer/exresop.c
drivers/acpi/executer/exstore.c
drivers/acpi/executer/exstoren.c
drivers/acpi/executer/exstorob.c
drivers/acpi/executer/exsystem.c
drivers/acpi/executer/exutils.c
drivers/acpi/hardware/Makefile
drivers/acpi/hardware/hwacpi.c
drivers/acpi/hardware/hwgpe.c
drivers/acpi/hardware/hwregs.c
drivers/acpi/hardware/hwsleep.c
drivers/acpi/hardware/hwtimer.c
drivers/acpi/include/acconfig.h
drivers/acpi/include/acdebug.h
drivers/acpi/include/acdispat.h
drivers/acpi/include/acevents.h
drivers/acpi/include/acexcep.h
drivers/acpi/include/acglobal.h
drivers/acpi/include/achware.h
drivers/acpi/include/acinterp.h
drivers/acpi/include/aclocal.h
drivers/acpi/include/acmacros.h
drivers/acpi/include/acnamesp.h
drivers/acpi/include/acobject.h
drivers/acpi/include/acoutput.h
drivers/acpi/include/acparser.h
drivers/acpi/include/acpi.h
drivers/acpi/include/acpiosxf.h
drivers/acpi/include/acpixf.h
drivers/acpi/include/acresrc.h
drivers/acpi/include/acstruct.h
drivers/acpi/include/actables.h
drivers/acpi/include/actbl.h
drivers/acpi/include/actbl1.h
drivers/acpi/include/actbl2.h
drivers/acpi/include/actbl71.h
drivers/acpi/include/actypes.h
drivers/acpi/include/acutils.h
drivers/acpi/include/amlcode.h
drivers/acpi/include/platform/acenv.h
drivers/acpi/include/platform/acgcc.h
drivers/acpi/include/platform/aclinux.h
drivers/acpi/namespace/Makefile
drivers/acpi/namespace/nsaccess.c
drivers/acpi/namespace/nsalloc.c
drivers/acpi/namespace/nsdump.c
drivers/acpi/namespace/nseval.c
drivers/acpi/namespace/nsinit.c
drivers/acpi/namespace/nsload.c
drivers/acpi/namespace/nsnames.c
drivers/acpi/namespace/nsobject.c
drivers/acpi/namespace/nssearch.c
drivers/acpi/namespace/nsutils.c
drivers/acpi/namespace/nswalk.c
drivers/acpi/namespace/nsxfname.c
drivers/acpi/namespace/nsxfobj.c
drivers/acpi/parser/Makefile
drivers/acpi/parser/psargs.c
drivers/acpi/parser/psopcode.c
drivers/acpi/parser/psparse.c
drivers/acpi/parser/psscope.c
drivers/acpi/parser/pstree.c
drivers/acpi/parser/psutils.c
drivers/acpi/parser/pswalk.c
drivers/acpi/parser/psxface.c
drivers/acpi/resources/Makefile
drivers/acpi/resources/rsaddr.c
drivers/acpi/resources/rscalc.c
drivers/acpi/resources/rscreate.c
drivers/acpi/resources/rsdump.c
drivers/acpi/resources/rsio.c
drivers/acpi/resources/rsirq.c
drivers/acpi/resources/rslist.c
drivers/acpi/resources/rsmemory.c
drivers/acpi/resources/rsmisc.c
drivers/acpi/resources/rsutils.c
drivers/acpi/resources/rsxface.c
drivers/acpi/tables/Makefile
drivers/acpi/tables/tbconvrt.c
drivers/acpi/tables/tbget.c
drivers/acpi/tables/tbinstal.c
drivers/acpi/tables/tbutils.c
drivers/acpi/tables/tbxface.c
drivers/acpi/tables/tbxfroot.c
drivers/acpi/utilities/Makefile
drivers/acpi/utilities/utalloc.c
drivers/acpi/utilities/utcopy.c
drivers/acpi/utilities/utdebug.c
drivers/acpi/utilities/utdelete.c
drivers/acpi/utilities/uteval.c
drivers/acpi/utilities/utglobal.c
drivers/acpi/utilities/utinit.c
drivers/acpi/utilities/utmath.c
drivers/acpi/utilities/utmisc.c
drivers/acpi/utilities/utobject.c
drivers/acpi/utilities/utxface.c

index 0714c087172adf7cb040934c0602ec8c336b3ccd..d0bbc7655a46e95b304e00deeca0e7cf8e60f997 100644 (file)
@@ -1,11 +1,10 @@
 #
 # Makefile for all Linux ACPI interpreter subdirectories
-# EXCEPT for the ospm directory
 #
 
 O_TARGET := $(notdir $(CURDIR)).o
 
-obj-$(CONFIG_ACPI) := $(patsubst %.c,%.o,$(wildcard *.c))
+obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
 
index 6b57aed6cd39046a0ae1e8237c1412bcfc47bf83..11bdca2d2016dc54945efa3786ec448e5eb82fcf 100644 (file)
@@ -1,12 +1,12 @@
 /*******************************************************************************
  *
  * Module Name: dbcmds - debug commands and output routines
- *              $Revision: 66 $
+ *              $Revision: 79 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -39,7 +39,7 @@
 #ifdef ENABLE_DEBUGGER
 
 #define _COMPONENT          ACPI_DEBUGGER
-        MODULE_NAME         ("dbcmds")
+        ACPI_MODULE_NAME    ("dbcmds")
 
 
 /*
@@ -79,6 +79,8 @@ ARGUMENT_INFO         acpi_db_object_types [] =
  * DESCRIPTION: Check if this namespace object refers to the target object
  *              that is passed in as the context value.
  *
+ * Note: Currently doesn't check subobjects within the Node's object
+ *
  ******************************************************************************/
 
 acpi_status
@@ -100,17 +102,10 @@ acpi_db_walk_for_references (
 
        /* Check for match against the object attached to the node */
 
-       if (node->object == obj_desc) {
+       if (acpi_ns_get_attached_object (node) == obj_desc) {
                acpi_os_printf ("Reference at Node->Object %p [%4.4s]\n", node, &node->name);
        }
 
-       /* Check first child for a match */
-       /* TBD: [Investigate] probably now obsolete with new datastructure */
-
-       if (node->child == (void *) obj_desc) {
-               acpi_os_printf ("Reference at Node->Child %p [%4.4s]\n", node, &node->name);
-       }
-
        return (AE_OK);
 }
 
@@ -136,7 +131,7 @@ acpi_db_find_references (
 
        /* Convert string to object pointer */
 
-       obj_desc = (acpi_operand_object *) STRTOUL (object_arg, NULL, 16);
+       obj_desc = ACPI_TO_POINTER (ACPI_STRTOUL (object_arg, NULL, 16));
 
        /* Search all nodes in namespace */
 
@@ -227,7 +222,7 @@ acpi_db_unload_acpi_table (
        /* Search all tables for the target type */
 
        for (i = 0; i < NUM_ACPI_TABLES; i++) {
-               if (!STRNCMP (table_arg, acpi_gbl_acpi_table_data[i].signature,
+               if (!ACPI_STRNCMP (table_arg, acpi_gbl_acpi_table_data[i].signature,
                                acpi_gbl_acpi_table_data[i].sig_length)) {
                        /* Found the table, unload it */
 
@@ -279,14 +274,14 @@ acpi_db_set_method_breakpoint (
 
        /* Get and verify the breakpoint address */
 
-       address = STRTOUL (location, NULL, 16);
+       address = ACPI_STRTOUL (location, NULL, 16);
        if (address <= op->aml_offset) {
                acpi_os_printf ("Breakpoint %X is beyond current address %X\n", address, op->aml_offset);
        }
 
        /* Save breakpoint in current walk */
 
-       walk_state->method_breakpoint = address;
+       walk_state->user_breakpoint = address;
        acpi_os_printf ("Breakpoint set at AML offset %X\n", address);
 }
 
@@ -348,10 +343,9 @@ acpi_db_disassemble_aml (
        }
 
        if (statements) {
-               num_statements = STRTOUL (statements, NULL, 0);
+               num_statements = ACPI_STRTOUL (statements, NULL, 0);
        }
 
-
        acpi_db_display_op (NULL, op, num_statements);
 }
 
@@ -385,13 +379,13 @@ acpi_db_dump_namespace (
                /* Check if numeric argument, must be a Node */
 
                if ((start_arg[0] >= 0x30) && (start_arg[0] <= 0x39)) {
-                       subtree_entry = (acpi_handle) STRTOUL (start_arg, NULL, 16);
+                       subtree_entry = ACPI_TO_POINTER (ACPI_STRTOUL (start_arg, NULL, 16));
                        if (!acpi_os_readable (subtree_entry, sizeof (acpi_namespace_node))) {
                                acpi_os_printf ("Address %p is invalid in this address space\n", subtree_entry);
                                return;
                        }
 
-                       if (!VALID_DESCRIPTOR_TYPE ((subtree_entry), ACPI_DESC_TYPE_NAMED)) {
+                       if (ACPI_GET_DESCRIPTOR_TYPE (subtree_entry) != ACPI_DESC_TYPE_NAMED) {
                                acpi_os_printf ("Address %p is not a valid Named object\n", subtree_entry);
                                return;
                        }
@@ -411,19 +405,18 @@ acpi_db_dump_namespace (
                /* Now we can check for the depth argument */
 
                if (depth_arg) {
-                       max_depth = STRTOUL (depth_arg, NULL, 0);
+                       max_depth = ACPI_STRTOUL (depth_arg, NULL, 0);
                }
        }
 
-
-       acpi_db_set_output_destination (DB_DUPLICATE_OUTPUT);
+       acpi_db_set_output_destination (ACPI_DB_DUPLICATE_OUTPUT);
        acpi_os_printf ("ACPI Namespace (from %p subtree):\n", subtree_entry);
 
        /* Display the subtree */
 
-       acpi_db_set_output_destination (DB_REDIRECTABLE_OUTPUT);
+       acpi_db_set_output_destination (ACPI_DB_REDIRECTABLE_OUTPUT);
        acpi_ns_dump_objects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, max_depth, ACPI_UINT32_MAX, subtree_entry);
-       acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
+       acpi_db_set_output_destination (ACPI_DB_CONSOLE_OUTPUT);
 }
 
 
@@ -450,24 +443,22 @@ acpi_db_dump_namespace_by_owner (
        u16                     owner_id;
 
 
-       owner_id = (u16) STRTOUL (owner_arg, NULL, 0);
-
+       owner_id = (u16) ACPI_STRTOUL (owner_arg, NULL, 0);
 
        /* Now we can check for the depth argument */
 
        if (depth_arg) {
-               max_depth = STRTOUL (depth_arg, NULL, 0);
+               max_depth = ACPI_STRTOUL (depth_arg, NULL, 0);
        }
 
-
-       acpi_db_set_output_destination (DB_DUPLICATE_OUTPUT);
+       acpi_db_set_output_destination (ACPI_DB_DUPLICATE_OUTPUT);
        acpi_os_printf ("ACPI Namespace by owner %X:\n", owner_id);
 
        /* Display the subtree */
 
-       acpi_db_set_output_destination (DB_REDIRECTABLE_OUTPUT);
+       acpi_db_set_output_destination (ACPI_DB_REDIRECTABLE_OUTPUT);
        acpi_ns_dump_objects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, max_depth, owner_id, subtree_entry);
-       acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
+       acpi_db_set_output_destination (ACPI_DB_CONSOLE_OUTPUT);
 }
 
 
@@ -549,7 +540,7 @@ acpi_db_set_method_data (
 
        /* Validate Type_arg */
 
-       STRUPR (type_arg);
+       ACPI_STRUPR (type_arg);
        type = type_arg[0];
        if ((type != 'L') &&
                (type != 'A')) {
@@ -559,8 +550,8 @@ acpi_db_set_method_data (
 
        /* Get the index and value */
 
-       index = STRTOUL (index_arg, NULL, 16);
-       value = STRTOUL (value_arg, NULL, 16);
+       index = ACPI_STRTOUL (index_arg, NULL, 16);
+       value = ACPI_STRTOUL (value_arg, NULL, 16);
 
        walk_state = acpi_ds_get_current_walk_state (acpi_gbl_current_walk_list);
        if (!walk_state) {
@@ -642,23 +633,22 @@ acpi_db_walk_for_specific_objects (
 {
        acpi_operand_object     *obj_desc;
        acpi_status             status;
-       u32                     buf_size;
-       NATIVE_CHAR             buffer[64];
+       acpi_buffer             buffer;
 
 
-       obj_desc = ((acpi_namespace_node *)obj_handle)->object;
-       buf_size = sizeof (buffer) / sizeof (*buffer);
+       obj_desc = acpi_ns_get_attached_object ((acpi_namespace_node *) obj_handle);
 
        /* Get and display the full pathname to this object */
 
-       status = acpi_ns_handle_to_pathname (obj_handle, &buf_size, buffer);
-
+       buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
+       status = acpi_ns_handle_to_pathname (obj_handle, &buffer);
        if (ACPI_FAILURE (status)) {
                acpi_os_printf ("Could Not get pathname for object %p\n", obj_handle);
                return (AE_OK);
        }
 
-       acpi_os_printf ("%32s", buffer);
+       acpi_os_printf ("%32s", buffer.pointer);
+       ACPI_MEM_FREE (buffer.pointer);
 
 
        /* Display short information about the object */
@@ -714,7 +704,7 @@ acpi_db_display_objects (
        NATIVE_CHAR             *obj_type_arg,
        NATIVE_CHAR             *display_count_arg)
 {
-       acpi_object_type8       type;
+       acpi_object_type        type;
 
 
        /* Get the object type */
@@ -725,17 +715,17 @@ acpi_db_display_objects (
                return (AE_OK);
        }
 
-       acpi_db_set_output_destination (DB_DUPLICATE_OUTPUT);
+       acpi_db_set_output_destination (ACPI_DB_DUPLICATE_OUTPUT);
        acpi_os_printf ("Objects of type [%s] defined in the current ACPI Namespace: \n", acpi_ut_get_type_name (type));
 
-       acpi_db_set_output_destination (DB_REDIRECTABLE_OUTPUT);
+       acpi_db_set_output_destination (ACPI_DB_REDIRECTABLE_OUTPUT);
 
        /* Walk the namespace from the root */
 
        acpi_walk_namespace (type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
                           acpi_db_walk_for_specific_objects, (void *) &type, NULL);
 
-       acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
+       acpi_db_set_output_destination (ACPI_DB_CONSOLE_OUTPUT);
        return (AE_OK);
 }
 
@@ -763,8 +753,7 @@ acpi_db_walk_and_match_name (
        acpi_status             status;
        NATIVE_CHAR             *requested_name = (NATIVE_CHAR *) context;
        u32                     i;
-       u32                     buf_size;
-       NATIVE_CHAR             buffer[96];
+       acpi_buffer             buffer;
 
 
        /* Check for a name match */
@@ -783,16 +772,15 @@ acpi_db_walk_and_match_name (
 
        /* Get the full pathname to this object */
 
-       buf_size = sizeof (buffer) / sizeof (*buffer);
-
-       status = acpi_ns_handle_to_pathname (obj_handle, &buf_size, buffer);
+       buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
+       status = acpi_ns_handle_to_pathname (obj_handle, &buffer);
        if (ACPI_FAILURE (status)) {
                acpi_os_printf ("Could Not get pathname for object %p\n", obj_handle);
        }
-
        else {
-               acpi_os_printf ("%32s (%p) - %s\n", buffer, obj_handle,
+               acpi_os_printf ("%32s (%p) - %s\n", buffer.pointer, obj_handle,
                        acpi_ut_get_type_name (((acpi_namespace_node *) obj_handle)->type));
+               ACPI_MEM_FREE (buffer.pointer);
        }
 
        return (AE_OK);
@@ -817,7 +805,7 @@ acpi_db_find_name_in_namespace (
        NATIVE_CHAR             *name_arg)
 {
 
-       if (STRLEN (name_arg) > 4) {
+       if (ACPI_STRLEN (name_arg) > 4) {
                acpi_os_printf ("Name must be no longer than 4 characters\n");
                return (AE_OK);
        }
@@ -827,7 +815,7 @@ acpi_db_find_name_in_namespace (
        acpi_walk_namespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
                           acpi_db_walk_and_match_name, name_arg, NULL);
 
-       acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
+       acpi_db_set_output_destination (ACPI_DB_CONSOLE_OUTPUT);
        return (AE_OK);
 }
 
@@ -849,6 +837,9 @@ void
 acpi_db_set_scope (
        NATIVE_CHAR             *name)
 {
+       acpi_status             status;
+       acpi_namespace_node     *node;
+
 
        if (!name || name[0] == 0) {
                acpi_os_printf ("Current scope: %s\n", acpi_gbl_db_scope_buf);
@@ -857,19 +848,38 @@ acpi_db_set_scope (
 
        acpi_db_prep_namestring (name);
 
-       /* TBD: [Future] Validate scope here */
 
        if (name[0] == '\\') {
-               STRCPY (acpi_gbl_db_scope_buf, name);
-               STRCAT (acpi_gbl_db_scope_buf, "\\");
-       }
+               /* Validate new scope from the root */
 
+               status = acpi_ns_get_node_by_path (name, acpi_gbl_root_node, ACPI_NS_NO_UPSEARCH, &node);
+               if (ACPI_FAILURE (status)) {
+                       goto error_exit;
+               }
+
+               ACPI_STRCPY (acpi_gbl_db_scope_buf, name);
+               ACPI_STRCAT (acpi_gbl_db_scope_buf, "\\");
+       }
        else {
-               STRCAT (acpi_gbl_db_scope_buf, name);
-               STRCAT (acpi_gbl_db_scope_buf, "\\");
+               /* Validate new scope relative to old scope */
+
+               status = acpi_ns_get_node_by_path (name, acpi_gbl_db_scope_node, ACPI_NS_NO_UPSEARCH, &node);
+               if (ACPI_FAILURE (status)) {
+                       goto error_exit;
+               }
+
+               ACPI_STRCAT (acpi_gbl_db_scope_buf, name);
+               ACPI_STRCAT (acpi_gbl_db_scope_buf, "\\");
        }
 
+       acpi_gbl_db_scope_node = node;
        acpi_os_printf ("New scope: %s\n", acpi_gbl_db_scope_buf);
+       return;
+
+
+error_exit:
+
+       acpi_os_printf ("Could not attach scope: %s, %s\n", name, acpi_format_exception (status));
 }
 
 
@@ -895,18 +905,18 @@ acpi_db_display_resources (
        acpi_buffer             return_obj;
 
 
-       acpi_db_set_output_destination (DB_REDIRECTABLE_OUTPUT);
+       acpi_db_set_output_destination (ACPI_DB_REDIRECTABLE_OUTPUT);
+       acpi_dbg_level |= ACPI_LV_RESOURCES;
 
        /* Convert string to object pointer */
 
-       obj_desc = (acpi_operand_object *) STRTOUL (object_arg, NULL, 16);
+       obj_desc = ACPI_TO_POINTER (ACPI_STRTOUL (object_arg, NULL, 16));
 
        /* Prepare for a return object of arbitrary size */
 
        return_obj.pointer          = acpi_gbl_db_buffer;
        return_obj.length           = ACPI_DEBUG_BUFFER_SIZE;
 
-
        /* _PRT */
 
        acpi_os_printf ("Evaluating _PRT\n");
@@ -950,12 +960,19 @@ get_crs:
        status = acpi_get_current_resources (obj_desc, &return_obj);
        if (ACPI_FAILURE (status)) {
                acpi_os_printf ("Acpi_get_current_resources failed: %s\n", acpi_format_exception (status));
+               goto get_prs;
        }
 
        else {
                acpi_rs_dump_resource_list ((acpi_resource *) acpi_gbl_db_buffer);
        }
 
+       status = acpi_set_current_resources (obj_desc, &return_obj);
+       if (ACPI_FAILURE (status)) {
+               acpi_os_printf ("Acpi_set_current_resources failed: %s\n", acpi_format_exception (status));
+               goto get_prs;
+       }
+
 
        /* _PRS */
 
@@ -986,7 +1003,7 @@ get_prs:
 
 cleanup:
 
-       acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
+       acpi_db_set_output_destination (ACPI_DB_CONSOLE_OUTPUT);
        return;
 #endif
 
index deb3239800022844bae8bb799b807c7cd2163cda..22ebb184497a5c00c9fb2b521e4ec061cc989cf5 100644 (file)
@@ -1,12 +1,12 @@
 /*******************************************************************************
  *
  * Module Name: dbdisasm - parser op tree display routines
- *              $Revision: 50 $
+ *              $Revision: 61 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 #ifdef ENABLE_DEBUGGER
 
 #define _COMPONENT          ACPI_DEBUGGER
-        MODULE_NAME         ("dbdisasm")
+        ACPI_MODULE_NAME    ("dbdisasm")
 
 
-#define MAX_SHOW_ENTRY      128
 #define BLOCK_PAREN         1
 #define BLOCK_BRACE         2
 #define DB_NO_OP_INFO       "            [%2.2d]  "
@@ -67,14 +66,12 @@ acpi_db_block_type (
        switch (op->opcode) {
        case AML_METHOD_OP:
                return (BLOCK_BRACE);
-               break;
 
        default:
                break;
        }
 
        return (BLOCK_PAREN);
-
 }
 
 
@@ -101,11 +98,23 @@ acpi_ps_display_object_pathname (
        acpi_parse_object       *op)
 {
        acpi_parse_object       *target_op;
+       char                    *name;
 
 
+       if (op->flags & ACPI_PARSEOP_GENERIC) {
+               name = op->value.name;
+               if (name[0] == '\\') {
+                       acpi_os_printf (" (Fully Qualified Pathname)");
+                       return (AE_OK);
+               }
+       }
+       else {
+               name = (char *) &((acpi_parse2_object *) op)->name;
+       }
+
        /* Search parent tree up to the root if necessary */
 
-       target_op = acpi_ps_find (op, op->value.name, 0, 0);
+       target_op = acpi_ps_find (op, name, 0, 0);
        if (!target_op) {
                /*
                 * Didn't find the name in the parse tree.  This may be
@@ -115,7 +124,6 @@ acpi_ps_display_object_pathname (
                 */
                acpi_os_printf (" **** Path not found in parse tree");
        }
-
        else {
                /* The target was found, print the name and complete path */
 
@@ -136,8 +144,7 @@ acpi_ps_display_object_pathname (
 {
        acpi_status             status;
        acpi_namespace_node     *node;
-       NATIVE_CHAR             buffer[MAX_SHOW_ENTRY];
-       u32                     buffer_size = MAX_SHOW_ENTRY;
+       acpi_buffer             buffer;
        u32                     debug_level;
 
 
@@ -153,7 +160,7 @@ acpi_ps_display_object_pathname (
                /* Node not defined in this scope, look it up */
 
                status = acpi_ns_lookup (walk_state->scope_info, op->value.string, ACPI_TYPE_ANY,
-                                 IMODE_EXECUTE, NS_SEARCH_PARENT, walk_state, &(node));
+                                 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, walk_state, &(node));
 
                if (ACPI_FAILURE (status)) {
                        /*
@@ -172,13 +179,15 @@ acpi_ps_display_object_pathname (
 
        /* Convert Named_desc/handle to a full pathname */
 
-       status = acpi_ns_handle_to_pathname (node, &buffer_size, buffer);
+       buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
+       status = acpi_ns_handle_to_pathname (node, &buffer);
        if (ACPI_FAILURE (status)) {
                acpi_os_printf ("****Could not get pathname****)");
                goto exit;
        }
 
-       acpi_os_printf (" (Path %s)", buffer);
+       acpi_os_printf (" (Path %s)", buffer.pointer);
+       ACPI_MEM_FREE (buffer.pointer);
 
 
 exit:
@@ -219,118 +228,115 @@ acpi_db_display_op (
        u32                     j;
 
 
-       if (op) {
-               while (op) {
-                       /* indentation */
+       if (!op) {
+               acpi_db_display_opcode (walk_state, op);
+               return;
+       }
+
+
+       while (op) {
+               /* Indentation */
+
+               depth_count = 0;
+               if (!acpi_gbl_db_opt_verbose) {
+                       depth_count++;
+               }
 
-                       depth_count = 0;
-                       if (!acpi_gbl_db_opt_verbose) {
-                               depth_count++;
+               /* Determine the nesting depth of this argument */
+
+               for (depth = op->parent; depth; depth = depth->parent) {
+                       arg = acpi_ps_get_arg (depth, 0);
+                       while (arg && arg != origin) {
+                               arg = arg->next;
                        }
 
-                       /* Determine the nesting depth of this argument */
+                       if (arg) {
+                               break;
+                       }
 
-                       for (depth = op->parent; depth; depth = depth->parent) {
-                               arg = acpi_ps_get_arg (depth, 0);
-                               while (arg && arg != origin) {
-                                       arg = arg->next;
-                               }
+                       depth_count++;
+               }
 
-                               if (arg) {
-                                       break;
-                               }
+               /* Open a new block if we are nested further than last time */
 
-                               depth_count++;
+               if (depth_count > last_depth) {
+                       VERBOSE_PRINT ((DB_NO_OP_INFO, last_depth));
+                       for (i = 0; i < last_depth; i++) {
+                               acpi_os_printf ("%s", acpi_gbl_db_disasm_indent);
                        }
 
+                       if (acpi_db_block_type (op) == BLOCK_PAREN) {
+                               acpi_os_printf ("(\n");
+                       }
+                       else {
+                               acpi_os_printf ("{\n");
+                       }
+               }
 
-                       /* Open a new block if we are nested further than last time */
+               /* Close a block if we are nested less than last time */
 
-                       if (depth_count > last_depth) {
-                               VERBOSE_PRINT ((DB_NO_OP_INFO, last_depth));
-                               for (i = 0; i < last_depth; i++) {
+               else if (depth_count < last_depth) {
+                       for (j = 0; j < (last_depth - depth_count); j++) {
+                               VERBOSE_PRINT ((DB_NO_OP_INFO, last_depth - j));
+                               for (i = 0; i < (last_depth - j - 1); i++) {
                                        acpi_os_printf ("%s", acpi_gbl_db_disasm_indent);
                                }
 
                                if (acpi_db_block_type (op) == BLOCK_PAREN) {
-                                       acpi_os_printf ("(\n");
+                                       acpi_os_printf (")\n");
                                }
                                else {
-                                       acpi_os_printf ("{\n");
-                               }
-                       }
-
-                       /* Close a block if we are nested less than last time */
-
-                       else if (depth_count < last_depth) {
-                               for (j = 0; j < (last_depth - depth_count); j++) {
-                                       VERBOSE_PRINT ((DB_NO_OP_INFO, last_depth - j));
-                                       for (i = 0; i < (last_depth - j - 1); i++) {
-                                               acpi_os_printf ("%s", acpi_gbl_db_disasm_indent);
-                                       }
-
-                                       if (acpi_db_block_type (op) == BLOCK_PAREN) {
-                                               acpi_os_printf (")\n");
-                                       }
-                                       else {
-                                               acpi_os_printf ("}\n");
-                                       }
+                                       acpi_os_printf ("}\n");
                                }
                        }
+               }
 
-                       /* In verbose mode, print the AML offset, opcode and depth count */
-
-                       VERBOSE_PRINT ((DB_FULL_OP_INFO, (unsigned) op->aml_offset, op->opcode, depth_count));
+               /* In verbose mode, print the AML offset, opcode and depth count */
 
+               VERBOSE_PRINT ((DB_FULL_OP_INFO, (unsigned) op->aml_offset, op->opcode, depth_count));
 
-                       /* Indent the output according to the depth count */
 
-                       for (i = 0; i < depth_count; i++) {
-                               acpi_os_printf ("%s", acpi_gbl_db_disasm_indent);
-                       }
+               /* Indent the output according to the depth count */
 
+               for (i = 0; i < depth_count; i++) {
+                       acpi_os_printf ("%s", acpi_gbl_db_disasm_indent);
+               }
 
-                       /* Now print the opcode */
+               /* Now print the opcode */
 
-                       acpi_db_display_opcode (walk_state, op);
+               acpi_db_display_opcode (walk_state, op);
 
-                       /* Resolve a name reference */
+               /* Resolve a name reference */
 
-                       if ((op->opcode == AML_INT_NAMEPATH_OP && op->value.name)  &&
-                               (op->parent) &&
-                               (acpi_gbl_db_opt_verbose)) {
-                               acpi_ps_display_object_pathname (walk_state, op);
-                       }
+               if ((op->opcode == AML_INT_NAMEPATH_OP && op->value.name)  &&
+                       (op->parent) &&
+                       (acpi_gbl_db_opt_verbose)) {
+                       acpi_ps_display_object_pathname (walk_state, op);
+               }
 
-                       acpi_os_printf ("\n");
+               acpi_os_printf ("\n");
 
-                       /* Get the next node in the tree */
+               /* Get the next node in the tree */
 
-                       op = acpi_ps_get_depth_next (origin, op);
-                       last_depth = depth_count;
+               op = acpi_ps_get_depth_next (origin, op);
+               last_depth = depth_count;
 
-                       num_opcodes--;
-                       if (!num_opcodes) {
-                               op = NULL;
-                       }
+               num_opcodes--;
+               if (!num_opcodes) {
+                       op = NULL;
                }
+       }
 
-               /* Close the last block(s) */
+       /* Close the last block(s) */
 
-               depth_count = last_depth -1;
-               for (i = 0; i < last_depth; i++) {
-                       VERBOSE_PRINT ((DB_NO_OP_INFO, last_depth - i));
-                       for (j = 0; j < depth_count; j++) {
-                               acpi_os_printf ("%s", acpi_gbl_db_disasm_indent);
-                       }
-                       acpi_os_printf ("}\n");
-                       depth_count--;
+       depth_count = last_depth -1;
+       for (i = 0; i < last_depth; i++) {
+               VERBOSE_PRINT ((DB_NO_OP_INFO, last_depth - i));
+               for (j = 0; j < depth_count; j++) {
+                       acpi_os_printf ("%s", acpi_gbl_db_disasm_indent);
                }
-
-       }
-
-       else {
-               acpi_db_display_opcode (walk_state, op);
+               acpi_os_printf ("}\n");
+               depth_count--;
        }
 }
 
@@ -352,7 +358,6 @@ acpi_db_display_namestring (
        NATIVE_CHAR             *name)
 {
        u32                     seg_count;
-       u8                      do_dot = FALSE;
 
 
        if (!name) {
@@ -360,21 +365,27 @@ acpi_db_display_namestring (
                return;
        }
 
-       if (acpi_ps_is_prefix_char (GET8 (name))) {
-               /* append prefix character */
+       /* Handle all Scope Prefix operators */
+
+       while (acpi_ps_is_prefix_char (ACPI_GET8 (name))) {
+               /* Append prefix character */
 
-               acpi_os_printf ("%1c", GET8 (name));
+               acpi_os_printf ("%1c", ACPI_GET8 (name));
                name++;
        }
 
-       switch (GET8 (name)) {
+       switch (ACPI_GET8 (name)) {
+       case 0:
+               seg_count = 0;
+               break;
+
        case AML_DUAL_NAME_PREFIX:
                seg_count = 2;
                name++;
                break;
 
        case AML_MULTI_NAME_PREFIX_OP:
-               seg_count = (u32) GET8 (name + 1);
+               seg_count = (u32) ACPI_GET8 (name + 1);
                name += 2;
                break;
 
@@ -383,19 +394,18 @@ acpi_db_display_namestring (
                break;
        }
 
-       while (seg_count--) {
-               /* append Name segment */
+       while (seg_count) {
+               /* Append Name segment */
+
+               acpi_os_printf ("%4.4s", name);
 
-               if (do_dot) {
-                       /* append dot */
+               seg_count--;
+               if (seg_count) {
+                       /* Not last name, append dot separator */
 
                        acpi_os_printf (".");
                }
-
-               acpi_os_printf ("%4.4s", name);
-               do_dot = TRUE;
-
-               name += 4;
+               name += ACPI_NAME_SIZE;
        }
 }
 
@@ -433,7 +443,6 @@ acpi_db_display_path (
                return;
        }
 
-
        if (op_info->flags & AML_CREATE) {
                /* Field creation - check for a fully qualified namepath */
 
@@ -492,7 +501,6 @@ acpi_db_display_path (
                                                acpi_os_printf ("%4.4s", name_path->value.string);
                                        }
                                }
-
                                else {
                                        name = acpi_ps_get_name (search);
                                        acpi_os_printf ("%4.4s", &name);
@@ -538,21 +546,17 @@ acpi_db_display_opcode (
                acpi_os_printf ("<NULL OP PTR>");
        }
 
-
        /* op and arguments */
 
        switch (op->opcode) {
-
        case AML_BYTE_OP:
 
                if (acpi_gbl_db_opt_verbose) {
                        acpi_os_printf ("(u8) 0x%2.2X", op->value.integer8);
                }
-
                else {
                        acpi_os_printf ("0x%2.2X", op->value.integer8);
                }
-
                break;
 
 
@@ -561,11 +565,9 @@ acpi_db_display_opcode (
                if (acpi_gbl_db_opt_verbose) {
                        acpi_os_printf ("(u16) 0x%4.4X", op->value.integer16);
                }
-
                else {
                        acpi_os_printf ("0x%4.4X", op->value.integer16);
                }
-
                break;
 
 
@@ -574,11 +576,9 @@ acpi_db_display_opcode (
                if (acpi_gbl_db_opt_verbose) {
                        acpi_os_printf ("(u32) 0x%8.8X", op->value.integer32);
                }
-
                else {
                        acpi_os_printf ("0x%8.8X", op->value.integer32);
                }
-
                break;
 
 
@@ -588,12 +588,10 @@ acpi_db_display_opcode (
                        acpi_os_printf ("(u64) 0x%8.8X%8.8X", op->value.integer64.hi,
                                         op->value.integer64.lo);
                }
-
                else {
                        acpi_os_printf ("0x%8.8X%8.8X", op->value.integer64.hi,
                                         op->value.integer64.lo);
                }
-
                break;
 
 
@@ -602,11 +600,9 @@ acpi_db_display_opcode (
                if (op->value.string) {
                        acpi_os_printf ("\"%s\"", op->value.string);
                }
-
                else {
                        acpi_os_printf ("<\"NULL STRING PTR\">");
                }
-
                break;
 
 
@@ -615,11 +611,9 @@ acpi_db_display_opcode (
                if (op->value.string) {
                        acpi_os_printf ("\"%s\"", op->value.string);
                }
-
                else {
                        acpi_os_printf ("\"<NULL STATIC STRING PTR>\"");
                }
-
                break;
 
 
@@ -652,7 +646,6 @@ acpi_db_display_opcode (
                if (acpi_gbl_db_opt_verbose) {
                        acpi_os_printf ("Byte_list   (Length 0x%8.8X)  ", op->value.integer32);
                }
-
                else {
                        acpi_os_printf ("0x%2.2X", op->value.integer32);
 
@@ -663,7 +656,6 @@ acpi_db_display_opcode (
                                acpi_os_printf (", 0x%2.2X", byte_data[i]);
                        }
                }
-
                break;
 
 
@@ -682,7 +674,6 @@ acpi_db_display_opcode (
                        acpi_db_decode_internal_object (walk_state->results->results.obj_desc [walk_state->results->results.num_results-1]);
                }
 #endif
-
                break;
        }
 
@@ -702,14 +693,11 @@ acpi_db_display_opcode (
                name = acpi_ps_get_name (op);
                acpi_os_printf (" %4.4s", &name);
 
-               if (acpi_gbl_db_opt_verbose) {
-                       acpi_os_printf (" (Path \\");
-                       acpi_db_display_path (op);
-                       acpi_os_printf (")");
+               if ((acpi_gbl_db_opt_verbose) && (op->opcode != AML_INT_NAMEDFIELD_OP)) {
+                       acpi_ps_display_object_pathname (walk_state, op);
                }
        }
 }
 
-
 #endif  /* ENABLE_DEBUGGER */
 
index 3b4d9deeb91b09427970de459892d8fc516c156d..2aa7cc40e380007d8def6434fe64bbf3c230f964 100644 (file)
@@ -1,12 +1,12 @@
 /*******************************************************************************
  *
  * Module Name: dbdisply - debug display commands
- *              $Revision: 57 $
+ *              $Revision: 66 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -39,7 +39,7 @@
 
 
 #define _COMPONENT          ACPI_DEBUGGER
-        MODULE_NAME         ("dbdisply")
+        ACPI_MODULE_NAME    ("dbdisply")
 
 
 /******************************************************************************
@@ -75,8 +75,7 @@ acpi_db_get_pointer (
 
        /* Simple flat pointer */
 
-       obj_ptr = (void *) STRTOUL (target, NULL, 16);
-
+       obj_ptr = ACPI_TO_POINTER (ACPI_STRTOUL (target, NULL, 16));
 #endif
 
        return (obj_ptr);
@@ -107,7 +106,7 @@ acpi_db_dump_parser_descriptor (
        acpi_os_printf ("Parser Op Descriptor:\n");
        acpi_os_printf ("%20.20s : %4.4X\n", "Opcode", op->opcode);
 
-       DEBUG_ONLY_MEMBERS (acpi_os_printf ("%20.20s : %s\n", "Opcode Name", info->name));
+       ACPI_DEBUG_ONLY_MEMBERS (acpi_os_printf ("%20.20s : %s\n", "Opcode Name", info->name));
 
        acpi_os_printf ("%20.20s : %p\n", "Value/Arg_list", op->value);
        acpi_os_printf ("%20.20s : %p\n", "Parent", op->parent);
@@ -136,6 +135,7 @@ acpi_db_decode_and_display_object (
 {
        void                    *obj_ptr;
        acpi_namespace_node     *node;
+       acpi_operand_object     *obj_desc;
        u32                     display = DB_BYTE_DISPLAY;
        NATIVE_CHAR             buffer[80];
        acpi_buffer             ret_buf;
@@ -150,7 +150,7 @@ acpi_db_decode_and_display_object (
        /* Decode the output type */
 
        if (output_type) {
-               STRUPR (output_type);
+               ACPI_STRUPR (output_type);
                if (output_type[0] == 'W') {
                        display = DB_WORD_DISPLAY;
                }
@@ -162,7 +162,6 @@ acpi_db_decode_and_display_object (
                }
        }
 
-
        ret_buf.length = sizeof (buffer);
        ret_buf.pointer = buffer;
 
@@ -177,8 +176,10 @@ acpi_db_decode_and_display_object (
 
                /* Decode the object type */
 
-               if (VALID_DESCRIPTOR_TYPE ((obj_ptr), ACPI_DESC_TYPE_NAMED)) {
-                       /* This is a Node */
+               switch (ACPI_GET_DESCRIPTOR_TYPE (obj_ptr)) {
+               case ACPI_DESC_TYPE_NAMED:
+
+                       /* This is a namespace Node */
 
                        if (!acpi_os_readable (obj_ptr, sizeof (acpi_namespace_node))) {
                                acpi_os_printf ("Cannot read entire Named object at address %p\n", obj_ptr);
@@ -187,10 +188,11 @@ acpi_db_decode_and_display_object (
 
                        node = obj_ptr;
                        goto dump_nte;
-               }
 
-               else if (VALID_DESCRIPTOR_TYPE ((obj_ptr), ACPI_DESC_TYPE_INTERNAL)) {
-                       /* This is an ACPI OBJECT */
+
+               case ACPI_DESC_TYPE_INTERNAL:
+
+                       /* This is a ACPI OPERAND OBJECT */
 
                        if (!acpi_os_readable (obj_ptr, sizeof (acpi_operand_object))) {
                                acpi_os_printf ("Cannot read entire ACPI object at address %p\n", obj_ptr);
@@ -199,22 +201,27 @@ acpi_db_decode_and_display_object (
 
                        acpi_ut_dump_buffer (obj_ptr, sizeof (acpi_operand_object), display, ACPI_UINT32_MAX);
                        acpi_ex_dump_object_descriptor (obj_ptr, 1);
-               }
+                       break;
 
-               else if (VALID_DESCRIPTOR_TYPE ((obj_ptr), ACPI_DESC_TYPE_PARSER)) {
-                       /* This is an Parser Op object */
+
+               case ACPI_DESC_TYPE_PARSER:
+
+                       /* This is a Parser Op object */
 
                        if (!acpi_os_readable (obj_ptr, sizeof (acpi_parse_object))) {
                                acpi_os_printf ("Cannot read entire Parser object at address %p\n", obj_ptr);
                                return;
                        }
 
-
                        acpi_ut_dump_buffer (obj_ptr, sizeof (acpi_parse_object), display, ACPI_UINT32_MAX);
                        acpi_db_dump_parser_descriptor ((acpi_parse_object *) obj_ptr);
-               }
+                       break;
+
+
+               default:
+
+                       /* Is not a recognizeable object */
 
-               else {
                        size = 16;
                        if (acpi_os_readable (obj_ptr, 64)) {
                                size = 64;
@@ -223,12 +230,12 @@ acpi_db_decode_and_display_object (
                        /* Just dump some memory */
 
                        acpi_ut_dump_buffer (obj_ptr, size, display, ACPI_UINT32_MAX);
+                       break;
                }
 
                return;
        }
 
-
        /* The parameter is a name string that must be resolved to a Named obj */
 
        node = acpi_db_local_ns_lookup (target);
@@ -257,15 +264,16 @@ dump_nte:
        acpi_ut_dump_buffer ((void *) node, sizeof (acpi_namespace_node), display, ACPI_UINT32_MAX);
        acpi_ex_dump_node (node, 1);
 
-       if (node->object) {
-               acpi_os_printf ("\n_attached Object (%p):\n", node->object);
-               if (!acpi_os_readable (node->object, sizeof (acpi_operand_object))) {
-                       acpi_os_printf ("Invalid internal ACPI Object at address %p\n", node->object);
+       obj_desc = acpi_ns_get_attached_object (node);
+       if (obj_desc) {
+               acpi_os_printf ("\n_attached Object (%p):\n", obj_desc);
+               if (!acpi_os_readable (obj_desc, sizeof (acpi_operand_object))) {
+                       acpi_os_printf ("Invalid internal ACPI Object at address %p\n", obj_desc);
                        return;
                }
 
-               acpi_ut_dump_buffer ((void *) node->object, sizeof (acpi_operand_object), display, ACPI_UINT32_MAX);
-               acpi_ex_dump_object_descriptor (node->object, 1);
+               acpi_ut_dump_buffer ((void *) obj_desc, sizeof (acpi_operand_object), display, ACPI_UINT32_MAX);
+               acpi_ex_dump_object_descriptor (obj_desc, 1);
        }
 }
 
@@ -298,8 +306,8 @@ acpi_db_decode_internal_object (
        switch (obj_desc->common.type) {
        case ACPI_TYPE_INTEGER:
 
-               acpi_os_printf (" %.8X%.8X", HIDWORD (obj_desc->integer.value),
-                                LODWORD (obj_desc->integer.value));
+               acpi_os_printf (" %.8X%.8X", ACPI_HIDWORD (obj_desc->integer.value),
+                                ACPI_LODWORD (obj_desc->integer.value));
                break;
 
 
@@ -358,26 +366,32 @@ acpi_db_display_internal_object (
                return;
        }
 
-
        /* Decode the object type */
 
-       else if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_PARSER)) {
+       switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) {
+       case ACPI_DESC_TYPE_PARSER:
+
                acpi_os_printf ("<Parser> ");
-       }
+               break;
+
+
+       case ACPI_DESC_TYPE_NAMED:
 
-       else if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_NAMED)) {
                acpi_os_printf ("<Node>          Name %4.4s Type-%s",
                                  &((acpi_namespace_node *)obj_desc)->name,
                                  acpi_ut_get_type_name (((acpi_namespace_node *) obj_desc)->type));
+
                if (((acpi_namespace_node *) obj_desc)->flags & ANOBJ_METHOD_ARG) {
                        acpi_os_printf (" [Method Arg]");
                }
                if (((acpi_namespace_node *) obj_desc)->flags & ANOBJ_METHOD_LOCAL) {
                        acpi_os_printf (" [Method Local]");
                }
-       }
+               break;
+
+
+       case ACPI_DESC_TYPE_INTERNAL:
 
-       else if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_INTERNAL)) {
                type = obj_desc->common.type;
                if (type > INTERNAL_TYPE_MAX) {
                        acpi_os_printf (" Type %x [Invalid Type]", type);
@@ -428,7 +442,7 @@ acpi_db_display_internal_object (
                                break;
 
                        case AML_INDEX_OP:
-                               acpi_os_printf ("[Index]   ");
+                               acpi_os_printf ("[Index]         ");
                                acpi_db_decode_internal_object (obj_desc->reference.object);
                                break;
 
@@ -444,12 +458,16 @@ acpi_db_display_internal_object (
                        acpi_db_decode_internal_object (obj_desc);
                        break;
                }
-       }
+               break;
+
+
+       default:
 
-       else {
                acpi_os_printf ("<Not a valid ACPI Object Descriptor> ");
+               break;
        }
 
+
        acpi_os_printf ("\n");
 }
 
@@ -494,9 +512,9 @@ acpi_db_display_method_info (
        }
 
        obj_desc = walk_state->method_desc;
-       node = walk_state->method_node;
+       node    = walk_state->method_node;
 
-       num_args = obj_desc->method.param_count;
+       num_args    = obj_desc->method.param_count;
        concurrency = obj_desc->method.concurrency;
 
        acpi_os_printf ("Currently executing control method is [%4.4s]\n", &node->name);
@@ -546,7 +564,6 @@ acpi_db_display_method_info (
                        break;
                }
 
-
                op = acpi_ps_get_depth_next (start_op, op);
        }
 
@@ -587,8 +604,6 @@ acpi_db_display_locals (void)
 
        obj_desc = walk_state->method_desc;
        node = walk_state->method_node;
-
-
        acpi_os_printf ("Local Variables for method [%4.4s]:\n", &node->name);
 
        for (i = 0; i < MTH_NUM_LOCALS; i++) {
@@ -629,12 +644,13 @@ acpi_db_display_arguments (void)
        }
 
        obj_desc = walk_state->method_desc;
-       node = walk_state->method_node;
+       node    = walk_state->method_node;
 
-       num_args = obj_desc->method.param_count;
+       num_args    = obj_desc->method.param_count;
        concurrency = obj_desc->method.concurrency;
 
-       acpi_os_printf ("Method [%4.4s] has %X arguments, max concurrency = %X\n", &node->name, num_args, concurrency);
+       acpi_os_printf ("Method [%4.4s] has %X arguments, max concurrency = %X\n",
+                       &node->name, num_args, concurrency);
 
        for (i = 0; i < num_args; i++) {
                obj_desc = walk_state->arguments[i].object;
@@ -679,7 +695,8 @@ acpi_db_display_results (void)
                num_results = walk_state->results->results.num_results;
        }
 
-       acpi_os_printf ("Method [%4.4s] has %X stacked result objects\n", &node->name, num_results);
+       acpi_os_printf ("Method [%4.4s] has %X stacked result objects\n",
+               &node->name, num_results);
 
        for (i = 0; i < num_results; i++) {
                obj_desc = walk_state->results->results.obj_desc[i];
@@ -716,7 +733,6 @@ acpi_db_display_calling_tree (void)
        }
 
        node = walk_state->method_node;
-
        acpi_os_printf ("Current Control Method Call Tree\n");
 
        for (i = 0; walk_state; i++) {
@@ -740,6 +756,10 @@ acpi_db_display_calling_tree (void)
  *
  * DESCRIPTION: Display the result of an AML opcode
  *
+ * Note: Curently only displays the result object if we are single stepping.
+ * However, this output may be useful in other contexts and could be enabled
+ * to do so if needed.
+ *
  ******************************************************************************/
 
 void
@@ -748,10 +768,8 @@ acpi_db_display_result_object (
        acpi_walk_state         *walk_state)
 {
 
-       /* TBD: [Future] We don't always want to display the result.
-        * For now, only display if single stepping
-        * however, this output is very useful in other contexts also
-        */
+       /* Only display if single stepping */
+
        if (!acpi_gbl_cm_single_step) {
                return;
        }
@@ -781,7 +799,6 @@ acpi_db_display_argument_object (
        acpi_walk_state         *walk_state)
 {
 
-
        if (!acpi_gbl_cm_single_step) {
                return;
        }
index 817a3cce2836b44abaf4aa3819b15535ce392c06..8472f359b49874661a6d5c128251460aa4c3cd4a 100644 (file)
@@ -1,12 +1,12 @@
 /*******************************************************************************
  *
  * Module Name: dbexec - debugger control method execution
- *              $Revision: 34 $
+ *              $Revision: 39 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 #ifdef ENABLE_DEBUGGER
 
 #define _COMPONENT          ACPI_DEBUGGER
-        MODULE_NAME         ("dbexec")
+        ACPI_MODULE_NAME    ("dbexec")
 
 
-db_method_info              acpi_gbl_db_method_info;
+acpi_db_method_info         acpi_gbl_db_method_info;
 
 
 /*******************************************************************************
@@ -59,7 +59,7 @@ db_method_info              acpi_gbl_db_method_info;
 
 acpi_status
 acpi_db_execute_method (
-       db_method_info          *info,
+       acpi_db_method_info     *info,
        acpi_buffer             *return_obj)
 {
        acpi_status             status;
@@ -77,13 +77,12 @@ acpi_db_execute_method (
        if (info->args && info->args[0]) {
                for (i = 0; info->args[i] && i < MTH_NUM_ARGS; i++) {
                        params[i].type              = ACPI_TYPE_INTEGER;
-                       params[i].integer.value     = STRTOUL (info->args[i], NULL, 16);
+                       params[i].integer.value     = ACPI_STRTOUL (info->args[i], NULL, 16);
                }
 
                param_objects.pointer       = params;
                param_objects.count         = i;
        }
-
        else {
                /* Setup default parameters */
 
@@ -103,7 +102,6 @@ acpi_db_execute_method (
        return_obj->pointer          = acpi_gbl_db_buffer;
        return_obj->length           = ACPI_DEBUG_BUFFER_SIZE;
 
-
        /* Do the actual method execution */
 
        status = acpi_evaluate_object (NULL, info->pathname, &param_objects, return_obj);
@@ -129,7 +127,7 @@ acpi_db_execute_method (
 
 void
 acpi_db_execute_setup (
-       db_method_info          *info)
+       acpi_db_method_info         *info)
 {
 
        /* Catenate the current scope to the supplied name */
@@ -137,24 +135,24 @@ acpi_db_execute_setup (
        info->pathname[0] = 0;
        if ((info->name[0] != '\\') &&
                (info->name[0] != '/')) {
-               STRCAT (info->pathname, acpi_gbl_db_scope_buf);
+               ACPI_STRCAT (info->pathname, acpi_gbl_db_scope_buf);
        }
 
-       STRCAT (info->pathname, info->name);
+       ACPI_STRCAT (info->pathname, info->name);
        acpi_db_prep_namestring (info->pathname);
 
-       acpi_db_set_output_destination (DB_DUPLICATE_OUTPUT);
+       acpi_db_set_output_destination (ACPI_DB_DUPLICATE_OUTPUT);
        acpi_os_printf ("Executing %s\n", info->pathname);
 
        if (info->flags & EX_SINGLE_STEP) {
                acpi_gbl_cm_single_step = TRUE;
-               acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
+               acpi_db_set_output_destination (ACPI_DB_CONSOLE_OUTPUT);
        }
 
        else {
                /* No single step, allow redirection to a file */
 
-               acpi_db_set_output_destination (DB_REDIRECTABLE_OUTPUT);
+               acpi_db_set_output_destination (ACPI_DB_REDIRECTABLE_OUTPUT);
        }
 }
 
@@ -176,11 +174,11 @@ acpi_db_execute_setup (
 u32
 acpi_db_get_outstanding_allocations (void)
 {
-       u32                     i;
        u32                     outstanding = 0;
 
-
 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
+       u32                     i;
+
 
        for (i = ACPI_MEM_LIST_FIRST_CACHE_LIST; i < ACPI_NUM_MEM_LISTS; i++) {
                outstanding += (acpi_gbl_memory_lists[i].total_allocated -
@@ -248,7 +246,7 @@ acpi_db_execute (
 
        allocations = acpi_db_get_outstanding_allocations () - previous_allocations;
 
-       acpi_db_set_output_destination (DB_DUPLICATE_OUTPUT);
+       acpi_db_set_output_destination (ACPI_DB_DUPLICATE_OUTPUT);
 
        if (allocations > 0) {
                acpi_os_printf ("Outstanding: %ld allocations after execution\n",
@@ -271,7 +269,7 @@ acpi_db_execute (
                }
        }
 
-       acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
+       acpi_db_set_output_destination (ACPI_DB_CONSOLE_OUTPUT);
 }
 
 
@@ -288,12 +286,12 @@ acpi_db_execute (
  *
  ******************************************************************************/
 
-void
+void ACPI_SYSTEM_XFACE
 acpi_db_method_thread (
        void                    *context)
 {
        acpi_status             status;
-       db_method_info          *info = context;
+       acpi_db_method_info     *info = context;
        u32                     i;
        acpi_buffer             return_obj;
 
@@ -344,15 +342,14 @@ acpi_db_create_execution_threads (
 
        /* Get the arguments */
 
-       num_threads = STRTOUL (num_threads_arg, NULL, 0);
-       num_loops STRTOUL (num_loops_arg, NULL, 0);
+       num_threads = ACPI_STRTOUL (num_threads_arg, NULL, 0);
+       num_loops  = ACPI_STRTOUL (num_loops_arg, NULL, 0);
 
        if (!num_threads || !num_loops) {
                acpi_os_printf ("Bad argument: Threads %X, Loops %X\n", num_threads, num_loops);
                return;
        }
 
-
        /* Create the synchronization semaphore */
 
        status = acpi_os_create_semaphore (1, 0, &thread_gate);
@@ -371,7 +368,6 @@ acpi_db_create_execution_threads (
 
        acpi_db_execute_setup (&acpi_gbl_db_method_info);
 
-
        /* Create the threads */
 
        acpi_os_printf ("Creating %X threads to execute %X times each\n", num_threads, num_loops);
@@ -380,7 +376,6 @@ acpi_db_create_execution_threads (
                acpi_os_queue_for_execution (OSD_PRIORITY_MED, acpi_db_method_thread, &acpi_gbl_db_method_info);
        }
 
-
        /* Wait for all threads to complete */
 
        i = num_threads;
@@ -393,9 +388,9 @@ acpi_db_create_execution_threads (
 
        acpi_os_delete_semaphore (thread_gate);
 
-       acpi_db_set_output_destination (DB_DUPLICATE_OUTPUT);
+       acpi_db_set_output_destination (ACPI_DB_DUPLICATE_OUTPUT);
        acpi_os_printf ("All threads (%X) have completed\n", num_threads);
-       acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
+       acpi_db_set_output_destination (ACPI_DB_CONSOLE_OUTPUT);
 }
 
 
index 6a4d2896a07e5fa965e32425a75905f88dae93d1..c8eed78ded52cba74c4fcd7d681180ab09dc8a17 100644 (file)
@@ -2,12 +2,12 @@
  *
  * Module Name: dbfileio - Debugger file I/O commands.  These can't usually
  *              be used when running the debugger in Ring 0 (Kernel mode)
- *              $Revision: 53 $
+ *              $Revision: 59 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -35,7 +35,7 @@
 #ifdef ENABLE_DEBUGGER
 
 #define _COMPONENT          ACPI_DEBUGGER
-        MODULE_NAME         ("dbfileio")
+        ACPI_MODULE_NAME    ("dbfileio")
 
 
 /*
@@ -64,7 +64,7 @@ acpi_table_header           *acpi_gbl_db_table_ptr = NULL;
  *
  ******************************************************************************/
 
-acpi_object_type8
+acpi_object_type
 acpi_db_match_argument (
        NATIVE_CHAR             *user_argument,
        ARGUMENT_INFO           *arguments)
@@ -77,8 +77,8 @@ acpi_db_match_argument (
        }
 
        for (i = 0; arguments[i].name; i++) {
-               if (STRSTR (arguments[i].name, user_argument) == arguments[i].name) {
-                       return ((acpi_object_type8) i);
+               if (ACPI_STRSTR (arguments[i].name, user_argument) == arguments[i].name) {
+                       return (i);
                }
        }
 
@@ -141,7 +141,7 @@ acpi_db_open_debug_file (
        acpi_gbl_debug_file = fopen (name, "w+");
        if (acpi_gbl_debug_file) {
                acpi_os_printf ("Debug output file %s opened\n", name);
-               STRCPY (acpi_gbl_db_debug_filename, name);
+               ACPI_STRCPY (acpi_gbl_db_debug_filename, name);
                acpi_gbl_db_output_to_file = TRUE;
        }
        else {
@@ -200,11 +200,11 @@ acpi_db_load_table(
 
        /* We only support a limited number of table types */
 
-       if (STRNCMP ((char *) table_header.signature, DSDT_SIG, 4) &&
-               STRNCMP ((char *) table_header.signature, PSDT_SIG, 4) &&
-               STRNCMP ((char *) table_header.signature, SSDT_SIG, 4)) {
+       if (ACPI_STRNCMP ((char *) table_header.signature, DSDT_SIG, 4) &&
+               ACPI_STRNCMP ((char *) table_header.signature, PSDT_SIG, 4) &&
+               ACPI_STRNCMP ((char *) table_header.signature, SSDT_SIG, 4)) {
                acpi_os_printf ("Table signature is invalid\n");
-               DUMP_BUFFER (&table_header, sizeof (acpi_table_header));
+               ACPI_DUMP_BUFFER (&table_header, sizeof (acpi_table_header));
                return (AE_ERROR);
        }
 
@@ -224,7 +224,7 @@ acpi_db_load_table(
 
        /* Copy the header to the buffer */
 
-       MEMCPY (*table_ptr, &table_header, sizeof (table_header));
+       ACPI_MEMCPY (*table_ptr, &table_header, sizeof (table_header));
 
        /* Get the rest of the table */
 
@@ -275,7 +275,7 @@ ae_local_load_table (
        acpi_table_desc         table_info;
 
 
-       FUNCTION_TRACE ("Ae_local_load_table");
+       ACPI_FUNCTION_TRACE ("Ae_local_load_table");
 
        if (!table_ptr) {
                return_ACPI_STATUS (AE_BAD_PARAMETER);
@@ -354,7 +354,7 @@ acpi_db_load_acpi_table (
 
        status = ae_local_load_table (acpi_gbl_db_table_ptr);
        if (ACPI_FAILURE (status)) {
-               if (status == AE_EXIST) {
+               if (status == AE_ALREADY_EXISTS) {
                        acpi_os_printf ("Table %4.4s is already installed\n",
                                          &acpi_gbl_db_table_ptr->signature);
                }
@@ -363,7 +363,6 @@ acpi_db_load_acpi_table (
                                          acpi_format_exception (status));
                }
 
-               acpi_os_free (acpi_gbl_db_table_ptr);
                return (status);
        }
 
index 69e809a61054172f66fb770ab09b2537a8fc8832..d780bdd216fed5a170a9117c7c9c451dc59036db 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: dbhistry - debugger HISTORY command
- *              $Revision: 19 $
+ *              $Revision: 22 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -38,7 +38,7 @@
 #ifdef ENABLE_DEBUGGER
 
 #define _COMPONENT          ACPI_DEBUGGER
-        MODULE_NAME         ("dbhistry")
+        ACPI_MODULE_NAME    ("dbhistry")
 
 
 #define HI_NO_HISTORY       0
@@ -78,10 +78,9 @@ acpi_db_add_to_history (
        NATIVE_CHAR             *command_line)
 {
 
-
        /* Put command into the next available slot */
 
-       STRCPY (acpi_gbl_history_buffer[acpi_gbl_next_history_index].command, command_line);
+       ACPI_STRCPY (acpi_gbl_history_buffer[acpi_gbl_next_history_index].command, command_line);
 
        acpi_gbl_history_buffer[acpi_gbl_next_history_index].cmd_num = acpi_gbl_next_cmd_num;
 
@@ -100,12 +99,10 @@ acpi_db_add_to_history (
                acpi_gbl_next_history_index = 0;
        }
 
-
        acpi_gbl_next_cmd_num++;
        if (acpi_gbl_num_history < HISTORY_SIZE) {
                acpi_gbl_num_history++;
        }
-
 }
 
 
@@ -171,10 +168,9 @@ acpi_db_get_from_history (
        }
 
        else {
-               cmd_num = STRTOUL (command_num_arg, NULL, 0);
+               cmd_num = ACPI_STRTOUL (command_num_arg, NULL, 0);
        }
 
-
        /* Search history buffer */
 
        history_index = acpi_gbl_lo_history;
index 92789eb1e52539c1b39e5bfc097e53cc4f9e9250..bc7ef52f2882729c776faff28b23353e28926905 100644 (file)
@@ -1,12 +1,12 @@
 /*******************************************************************************
  *
  * Module Name: dbinput - user front-end to the AML debugger
- *              $Revision: 72 $
+ *              $Revision: 81 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 #ifdef ENABLE_DEBUGGER
 
 #define _COMPONENT          ACPI_DEBUGGER
-        MODULE_NAME         ("dbinput")
+        ACPI_MODULE_NAME    ("dbinput")
 
 
-/*
- * Globals that are specific to the debugger
- */
-
-NATIVE_CHAR                 acpi_gbl_db_line_buf[80];
-NATIVE_CHAR                 acpi_gbl_db_parsed_buf[80];
-NATIVE_CHAR                 acpi_gbl_db_scope_buf[40];
-NATIVE_CHAR                 acpi_gbl_db_debug_filename[40];
-NATIVE_CHAR                 *acpi_gbl_db_args[DB_MAX_ARGS];
-NATIVE_CHAR                 *acpi_gbl_db_buffer = NULL;
-NATIVE_CHAR                 *acpi_gbl_db_filename = NULL;
-u8                          acpi_gbl_db_output_to_file = FALSE;
-
-u32                         acpi_gbl_db_debug_level = ACPI_LV_VERBOSITY2;
-u32                         acpi_gbl_db_console_debug_level = NORMAL_DEFAULT | ACPI_LV_TABLES;
-u8                          acpi_gbl_db_output_flags = DB_CONSOLE_OUTPUT;
-
-
-u8                          acpi_gbl_db_opt_tables    = FALSE;
-u8                          acpi_gbl_db_opt_disasm    = FALSE;
-u8                          acpi_gbl_db_opt_stats     = FALSE;
-u8                          acpi_gbl_db_opt_parse_jit = FALSE;
-u8                          acpi_gbl_db_opt_verbose   = TRUE;
-u8                          acpi_gbl_db_opt_ini_methods = TRUE;
-
-/*
- * Statistic globals
- */
-u16                         acpi_gbl_obj_type_count[INTERNAL_TYPE_NODE_MAX+1];
-u16                         acpi_gbl_node_type_count[INTERNAL_TYPE_NODE_MAX+1];
-u16                         acpi_gbl_obj_type_count_misc;
-u16                         acpi_gbl_node_type_count_misc;
-u32                         acpi_gbl_num_nodes;
-u32                         acpi_gbl_num_objects;
-
-
-u32                         acpi_gbl_size_of_parse_tree;
-u32                         acpi_gbl_size_of_method_trees;
-u32                         acpi_gbl_size_of_node_entries;
-u32                         acpi_gbl_size_of_acpi_objects;
-
 /*
  * Top-level debugger commands.
  *
  * This list of commands must match the string table below it
  */
-
 enum acpi_ex_debugger_commands
 {
        CMD_NOT_FOUND = 0,
@@ -224,13 +182,11 @@ acpi_db_display_help (
 
        }
 
-
        /*
         * Parameter is the command class
         *
         * The idea here is to keep each class of commands smaller than a screenful
         */
-
        switch (help_type[0])
        {
        case 'G':
@@ -321,6 +277,7 @@ acpi_db_get_next_token (
 {
        NATIVE_CHAR             *start;
 
+
        /* At end of buffer? */
 
        if (!string || !(*string))
@@ -328,7 +285,6 @@ acpi_db_get_next_token (
                return (NULL);
        }
 
-
        /* Get rid of any spaces at the beginning */
 
        if (*string == ' ')
@@ -353,12 +309,10 @@ acpi_db_get_next_token (
                string++;
        }
 
-
        if (!(*string))
        {
                *next = NULL;
        }
-
        else
        {
                *string = 0;
@@ -392,11 +346,11 @@ acpi_db_get_line (
        NATIVE_CHAR             *this;
 
 
-       STRCPY (acpi_gbl_db_parsed_buf, input_buffer);
-       STRUPR (acpi_gbl_db_parsed_buf);
+       ACPI_STRCPY (acpi_gbl_db_parsed_buf, input_buffer);
+       ACPI_STRUPR (acpi_gbl_db_parsed_buf);
 
        this = acpi_gbl_db_parsed_buf;
-       for (i = 0; i < DB_MAX_ARGS; i++)
+       for (i = 0; i < ACPI_DEBUGGER_MAX_ARGS; i++)
        {
                acpi_gbl_db_args[i] = acpi_db_get_next_token (this, &next);
                if (!acpi_gbl_db_args[i])
@@ -407,12 +361,11 @@ acpi_db_get_line (
                this = next;
        }
 
-
        /* Uppercase the actual command */
 
        if (acpi_gbl_db_args[0])
        {
-               STRUPR (acpi_gbl_db_args[0]);
+               ACPI_STRUPR (acpi_gbl_db_args[0]);
        }
 
        count = i;
@@ -451,7 +404,8 @@ acpi_db_match_command (
 
        for (i = CMD_FIRST_VALID; acpi_gbl_db_commands[i].name; i++)
        {
-               if (STRSTR (acpi_gbl_db_commands[i].name, user_command) == acpi_gbl_db_commands[i].name)
+               if (ACPI_STRSTR (acpi_gbl_db_commands[i].name, user_command) ==
+                                  acpi_gbl_db_commands[i].name)
                {
                        return (i);
                }
@@ -601,7 +555,6 @@ acpi_db_command_dispatch (
                        status = AE_CTRL_TRUE;
                }
                return (status);
-               break;
 
        case CMD_HISTORY_LAST:
                command_line = acpi_db_get_from_history (NULL);
@@ -625,9 +578,6 @@ acpi_db_command_dispatch (
                if (op)
                {
                        acpi_gbl_cm_single_step = TRUE;
-
-/* TBD: Must get current walk state */
-                       /* Acpi_gbl_Method_breakpoint = 0; */
                        return (AE_OK);
                }
                break;
@@ -641,13 +591,13 @@ acpi_db_command_dispatch (
                else if (param_count == 2)
                {
                        temp = acpi_gbl_db_console_debug_level;
-                       acpi_gbl_db_console_debug_level = STRTOUL (acpi_gbl_db_args[1], NULL, 16);
+                       acpi_gbl_db_console_debug_level = ACPI_STRTOUL (acpi_gbl_db_args[1], NULL, 16);
                        acpi_os_printf ("Debug Level for console output was %8.8lX, now %8.8lX\n", temp, acpi_gbl_db_console_debug_level);
                }
                else
                {
                        temp = acpi_gbl_db_debug_level;
-                       acpi_gbl_db_debug_level = STRTOUL (acpi_gbl_db_args[1], NULL, 16);
+                       acpi_gbl_db_debug_level = ACPI_STRTOUL (acpi_gbl_db_args[1], NULL, 16);
                        acpi_os_printf ("Debug Level for file output was %8.8lX, now %8.8lX\n", temp, acpi_gbl_db_debug_level);
                }
                break;
@@ -681,12 +631,12 @@ acpi_db_command_dispatch (
                break;
 
        case CMD_NOTIFY:
-               temp = STRTOUL (acpi_gbl_db_args[2], NULL, 0);
+               temp = ACPI_STRTOUL (acpi_gbl_db_args[2], NULL, 0);
                acpi_db_send_notify (acpi_gbl_db_args[1], temp);
                break;
 
        case CMD_OBJECT:
-               acpi_db_display_objects (STRUPR (acpi_gbl_db_args[1]), acpi_gbl_db_args[2]);
+               acpi_db_display_objects (ACPI_STRUPR (acpi_gbl_db_args[1]), acpi_gbl_db_args[2]);
                break;
 
        case CMD_OPEN:
@@ -723,14 +673,13 @@ acpi_db_command_dispatch (
 
        case CMD_STOP:
                return (AE_AML_ERROR);
-               break;
 
        case CMD_TABLES:
                acpi_db_display_table_info (acpi_gbl_db_args[1]);
                break;
 
        case CMD_TERMINATE:
-               acpi_db_set_output_destination (DB_REDIRECTABLE_OUTPUT);
+               acpi_db_set_output_destination (ACPI_DB_REDIRECTABLE_OUTPUT);
                acpi_ut_subsystem_shutdown ();
 
                /* TBD: [Restructure] Need some way to re-initialize without re-creating the semaphores! */
@@ -798,11 +747,12 @@ acpi_db_command_dispatch (
  *
  ******************************************************************************/
 
-void
+void ACPI_SYSTEM_XFACE
 acpi_db_execute_thread (
        void                    *context)
 {
        acpi_status             status = AE_OK;
+       acpi_status             Mstatus;
 
 
        while (status != AE_CTRL_TERMINATE)
@@ -810,9 +760,19 @@ acpi_db_execute_thread (
                acpi_gbl_method_executing = FALSE;
                acpi_gbl_step_to_next_call = FALSE;
 
-               acpi_ut_acquire_mutex (ACPI_MTX_DEBUG_CMD_READY);
+               Mstatus = acpi_ut_acquire_mutex (ACPI_MTX_DEBUG_CMD_READY);
+               if (ACPI_FAILURE (Mstatus))
+               {
+                       return;
+               }
+
                status = acpi_db_command_dispatch (acpi_gbl_db_line_buf, NULL, NULL);
-               acpi_ut_release_mutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
+
+               Mstatus = acpi_ut_release_mutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
+               if (ACPI_FAILURE (Mstatus))
+               {
+                       return;
+               }
        }
 }
 
@@ -834,7 +794,7 @@ void
 acpi_db_single_thread (
        void)
 {
-       acpi_status             status = AE_OK;
+       acpi_status             status;
 
 
        acpi_gbl_method_executing = FALSE;
@@ -872,17 +832,17 @@ acpi_db_user_commands (
        {
                /* Force output to console until a command is entered */
 
-               acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
+               acpi_db_set_output_destination (ACPI_DB_CONSOLE_OUTPUT);
 
                /* Different prompt if method is executing */
 
                if (!acpi_gbl_method_executing)
                {
-                       acpi_os_printf ("%1c ", DB_COMMAND_PROMPT);
+                       acpi_os_printf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT);
                }
                else
                {
-                       acpi_os_printf ("%1c ", DB_EXECUTE_PROMPT);
+                       acpi_os_printf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT);
                }
 
                /* Get the user input line */
@@ -898,10 +858,18 @@ acpi_db_user_commands (
                         * Signal the debug thread that we have a command to execute,
                         * and wait for the command to complete.
                         */
-                       acpi_ut_release_mutex (ACPI_MTX_DEBUG_CMD_READY);
-                       acpi_ut_acquire_mutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
+                       status = acpi_ut_release_mutex (ACPI_MTX_DEBUG_CMD_READY);
+                       if (ACPI_FAILURE (status))
+                       {
+                               return (status);
+                       }
+
+                       status = acpi_ut_acquire_mutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
+                       if (ACPI_FAILURE (status))
+                       {
+                               return (status);
+                       }
                }
-
                else
                {
                        /* Just call to the command line interpreter */
@@ -910,7 +878,6 @@ acpi_db_user_commands (
                }
        }
 
-
        /*
         * Only this thread (the original thread) should actually terminate the subsystem,
         * because all the semaphores are deleted during termination
index 64ac628f6bc128ff336fae0139cb709075490d11..1c97a8d1ea1fe4edc804f65fa759824cbe6b919b 100644 (file)
@@ -1,12 +1,12 @@
 /*******************************************************************************
  *
  * Module Name: dbstats - Generation and display of ACPI table statistics
- *              $Revision: 47 $
+ *              $Revision: 55 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -33,7 +33,7 @@
 #ifdef ENABLE_DEBUGGER
 
 #define _COMPONENT          ACPI_DEBUGGER
-        MODULE_NAME         ("dbstats")
+        ACPI_MODULE_NAME    ("dbstats")
 
 /*
  * Statistics subcommands
@@ -67,9 +67,8 @@ ARGUMENT_INFO               acpi_db_stat_types [] =
  * RETURN:      None
  *
  * DESCRIPTION: Add this object to the global counts, by object type.
- *              Recursively handles subobjects and packages.
- *
- *              [TBD] Restructure - remove recursion.
+ *              Limited recursion handles subobjects and packages, and this
+ *              is probably acceptable within the AML debugger only.
  *
  ******************************************************************************/
 
@@ -77,7 +76,6 @@ void
 acpi_db_enumerate_object (
        acpi_operand_object     *obj_desc)
 {
-       u32                     type;
        u32                     i;
 
 
@@ -91,22 +89,21 @@ acpi_db_enumerate_object (
 
        acpi_gbl_num_objects++;
 
-       type = obj_desc->common.type;
-       if (type > INTERNAL_TYPE_NODE_MAX)
+       if (obj_desc->common.type > INTERNAL_TYPE_NODE_MAX)
        {
                acpi_gbl_obj_type_count_misc++;
        }
        else
        {
-               acpi_gbl_obj_type_count [type]++;
+               acpi_gbl_obj_type_count [obj_desc->common.type]++;
        }
 
        /* Count the sub-objects */
 
-       switch (type)
+       switch (obj_desc->common.type)
        {
        case ACPI_TYPE_PACKAGE:
-               for (i = 0; i< obj_desc->package.count; i++)
+               for (i = 0; i < obj_desc->package.count; i++)
                {
                        acpi_db_enumerate_object (obj_desc->package.elements[i]);
                }
@@ -118,7 +115,15 @@ acpi_db_enumerate_object (
                acpi_db_enumerate_object (obj_desc->device.addr_handler);
                break;
 
+       case ACPI_TYPE_BUFFER_FIELD:
+               if (acpi_ns_get_secondary_object (obj_desc))
+               {
+                       acpi_gbl_obj_type_count [ACPI_TYPE_BUFFER_FIELD]++;
+               }
+               break;
+
        case ACPI_TYPE_REGION:
+               acpi_gbl_obj_type_count [INTERNAL_TYPE_REGION_FIELD ]++;
                acpi_db_enumerate_object (obj_desc->region.addr_handler);
                break;
 
@@ -172,7 +177,7 @@ acpi_db_classify_one_object (
        acpi_gbl_num_nodes++;
 
        node = (acpi_namespace_node *) obj_handle;
-       obj_desc = ((acpi_namespace_node *) obj_handle)->object;
+       obj_desc = acpi_ns_get_attached_object (node);
 
        acpi_db_enumerate_object (obj_desc);
 
@@ -271,8 +276,10 @@ acpi_db_display_statistics (
 {
        u32                     i;
        u32                     type;
-       u32                     outstanding;
        u32                     size;
+#ifdef ACPI_DBG_TRACK_ALLOCATIONS
+       u32                     outstanding;
+#endif
 
 
        if (!acpi_gbl_DSDT)
@@ -286,7 +293,7 @@ acpi_db_display_statistics (
                return (AE_OK);
        }
 
-       STRUPR (type_arg);
+       ACPI_STRUPR (type_arg);
        type = acpi_db_match_argument (type_arg, acpi_db_stat_types);
        if (type == (u32) -1)
        {
@@ -368,11 +375,11 @@ acpi_db_display_statistics (
 
                        if (acpi_gbl_memory_lists[i].object_size)
                        {
-                               size = ROUND_UP_TO_1K (outstanding * acpi_gbl_memory_lists[i].object_size);
+                               size = ACPI_ROUND_UP_TO_1K (outstanding * acpi_gbl_memory_lists[i].object_size);
                        }
                        else
                        {
-                               size = ROUND_UP_TO_1K (acpi_gbl_memory_lists[i].current_total_size);
+                               size = ACPI_ROUND_UP_TO_1K (acpi_gbl_memory_lists[i].current_total_size);
                        }
 
                        acpi_os_printf ("  Mem:   [Alloc Free Outstanding Size]  % 7d % 7d % 7d % 7d Kb\n",
@@ -425,6 +432,7 @@ acpi_db_display_statistics (
                acpi_os_printf ("Notify_handler %3d\n", sizeof (ACPI_OBJECT_NOTIFY_HANDLER));
                acpi_os_printf ("Addr_handler   %3d\n", sizeof (ACPI_OBJECT_ADDR_HANDLER));
                acpi_os_printf ("Extra          %3d\n", sizeof (ACPI_OBJECT_EXTRA));
+               acpi_os_printf ("Data           %3d\n", sizeof (ACPI_OBJECT_DATA));
 
                acpi_os_printf ("\n");
 
index e22d80dcc293681b6e86c927bcffc10f86e1f755..71ccf2465beb314de7f3bf860c868818ff9983e4 100644 (file)
@@ -1,12 +1,12 @@
 /*******************************************************************************
  *
  * Module Name: dbutils - AML debugger utilities
- *              $Revision: 45 $
+ *              $Revision: 51 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -38,7 +38,7 @@
 #ifdef ENABLE_DEBUGGER
 
 #define _COMPONENT          ACPI_DEBUGGER
-        MODULE_NAME         ("dbutils")
+        ACPI_MODULE_NAME    ("dbutils")
 
 
 /*******************************************************************************
@@ -61,10 +61,8 @@ acpi_db_set_output_destination (
 
        acpi_gbl_db_output_flags = (u8) output_flags;
 
-       if (output_flags & DB_REDIRECTABLE_OUTPUT) {
-               if (acpi_gbl_db_output_to_file) {
-                       acpi_dbg_level = acpi_gbl_db_debug_level;
-               }
+       if ((output_flags & ACPI_DB_REDIRECTABLE_OUTPUT) && acpi_gbl_db_output_to_file) {
+               acpi_dbg_level = acpi_gbl_db_debug_level;
        }
        else {
                acpi_dbg_level = acpi_gbl_db_console_debug_level;
@@ -92,7 +90,7 @@ acpi_db_dump_buffer (
        acpi_os_printf ("\n_location %X:\n", address);
 
        acpi_dbg_level |= ACPI_LV_TABLES;
-       acpi_ut_dump_buffer ((u8 *) address, 64, DB_BYTE_DISPLAY, ACPI_UINT32_MAX);
+       acpi_ut_dump_buffer (ACPI_TO_POINTER (address), 64, DB_BYTE_DISPLAY, ACPI_UINT32_MAX);
 }
 
 
@@ -135,8 +133,9 @@ acpi_db_dump_object (
 
        case ACPI_TYPE_INTEGER:
 
-               acpi_os_printf ("[Integer] = %8.8X%8.8X\n", HIDWORD (obj_desc->integer.value),
-                                LODWORD (obj_desc->integer.value));
+               acpi_os_printf ("[Integer] = %8.8X%8.8X\n",
+                                ACPI_HIDWORD (obj_desc->integer.value),
+                                ACPI_LODWORD (obj_desc->integer.value));
                break;
 
 
@@ -215,7 +214,7 @@ acpi_db_prep_namestring (
                return;
        }
 
-       STRUPR (name);
+       ACPI_STRUPR (name);
 
        /* Convert a leading forward slash to a backslash */
 
@@ -268,7 +267,7 @@ acpi_db_second_pass_parse (
        acpi_walk_state         *walk_state;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        acpi_os_printf ("Pass two parse ....\n");
@@ -339,6 +338,9 @@ acpi_db_second_pass_parse (
  *
  * DESCRIPTION: Lookup a name in the ACPI namespace
  *
+ * Note: Currently begins search from the root.  Could be enhanced to use
+ * the current prefix (scope) node as the search beginning point.
+ *
  ******************************************************************************/
 
 acpi_namespace_node *
@@ -360,21 +362,17 @@ acpi_db_local_ns_lookup (
                return (NULL);
        }
 
-       /* Lookup the name */
-
-       /* TBD: [Investigate] what scope do we use? */
-       /* Use the root scope for the start of the search */
-
-       status = acpi_ns_lookup (NULL, internal_path, ACPI_TYPE_ANY, IMODE_EXECUTE,
-                          NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, NULL, &node);
-
+       /*
+        * Lookup the name.
+        * (Uses root node as the search starting point)
+        */
+       status = acpi_ns_lookup (NULL, internal_path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
+                          ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, NULL, &node);
        if (ACPI_FAILURE (status)) {
                acpi_os_printf ("Could not locate name: %s %s\n", name, acpi_format_exception (status));
        }
 
-
        ACPI_MEM_FREE (internal_path);
-
        return (node);
 }
 
index a21e23cf1e0181b20c43920540ea43530f6a0b95..44ea2e7cad7c49f7e9042288e91de51cb0de0c74 100644 (file)
@@ -1,12 +1,12 @@
 /*******************************************************************************
  *
  * Module Name: dbxface - AML Debugger external interfaces
- *              $Revision: 45 $
+ *              $Revision: 55 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -37,7 +37,7 @@
 #ifdef ENABLE_DEBUGGER
 
 #define _COMPONENT          ACPI_DEBUGGER
-        MODULE_NAME         ("dbxface")
+        ACPI_MODULE_NAME    ("dbxface")
 
 
 /*******************************************************************************
@@ -64,25 +64,33 @@ acpi_db_single_step (
        acpi_status             status = AE_OK;
        u32                     original_debug_level;
        acpi_parse_object       *display_op;
+       acpi_parse_object       *parent_op;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
-       /* Is there a breakpoint set? */
+       /* Check for single-step breakpoint */
 
-       if (walk_state->method_breakpoint) {
+       if (walk_state->method_breakpoint && (walk_state->method_breakpoint <= op->aml_offset)) {
                /* Check if the breakpoint has been reached or passed */
+               /* Hit the breakpoint, resume single step, reset breakpoint */
 
-               if (walk_state->method_breakpoint <= op->aml_offset) {
-                       /* Hit the breakpoint, resume single step, reset breakpoint */
+               acpi_os_printf ("***Break*** at AML offset %X\n", op->aml_offset);
+               acpi_gbl_cm_single_step = TRUE;
+               acpi_gbl_step_to_next_call = FALSE;
+               walk_state->method_breakpoint = 0;
+       }
 
-                       acpi_os_printf ("***Break*** at AML offset %X\n", op->aml_offset);
-                       acpi_gbl_cm_single_step = TRUE;
-                       acpi_gbl_step_to_next_call = FALSE;
-                       walk_state->method_breakpoint = 0;
-               }
+       /* Check for user breakpoint (Must be on exact Aml offset) */
+
+       else if (walk_state->user_breakpoint && (walk_state->user_breakpoint == op->aml_offset)) {
+               acpi_os_printf ("***User_breakpoint*** at AML offset %X\n", op->aml_offset);
+               acpi_gbl_cm_single_step = TRUE;
+               acpi_gbl_step_to_next_call = FALSE;
+               walk_state->method_breakpoint = 0;
        }
 
+
        /*
         * Check if this is an opcode that we are interested in --
         * namely, opcodes that have arguments
@@ -95,7 +103,6 @@ acpi_db_single_step (
        case AML_CLASS_UNKNOWN:
        case AML_CLASS_ARGUMENT:    /* constants, literals, etc.  do nothing */
                return (AE_OK);
-               break;
        }
 
        /*
@@ -121,10 +128,36 @@ acpi_db_single_step (
 
 
                display_op = op;
-               if (op->parent) {
-                       if ((op->parent->opcode == AML_IF_OP) ||
-                               (op->parent->opcode == AML_WHILE_OP)) {
-                               display_op = op->parent;
+               parent_op = op->parent;
+               if (parent_op) {
+                       if ((walk_state->control_state) &&
+                               (walk_state->control_state->common.state == ACPI_CONTROL_PREDICATE_EXECUTING)) {
+                               /*
+                                * We are executing the predicate of an IF or WHILE statement
+                                * Search upwards for the containing IF or WHILE so that the
+                                * entire predicate can be displayed.
+                                */
+                               while (parent_op) {
+                                       if ((parent_op->opcode == AML_IF_OP) ||
+                                               (parent_op->opcode == AML_WHILE_OP)) {
+                                               display_op = parent_op;
+                                               break;
+                                       }
+                                       parent_op = parent_op->parent;
+                               }
+                       }
+                       else {
+                               while (parent_op) {
+                                       if ((parent_op->opcode == AML_IF_OP)    ||
+                                               (parent_op->opcode == AML_ELSE_OP)  ||
+                                               (parent_op->opcode == AML_SCOPE_OP) ||
+                                               (parent_op->opcode == AML_METHOD_OP) ||
+                                               (parent_op->opcode == AML_WHILE_OP)) {
+                                               break;
+                                       }
+                                       display_op = parent_op;
+                                       parent_op = parent_op->parent;
+                               }
                        }
                }
 
@@ -135,15 +168,15 @@ acpi_db_single_step (
                if ((op->opcode == AML_IF_OP) ||
                        (op->opcode == AML_WHILE_OP)) {
                        if (walk_state->control_state->common.value) {
-                               acpi_os_printf ("Predicate was TRUE, executed block\n");
+                               acpi_os_printf ("Predicate = [True], IF block was executed\n");
                        }
                        else {
-                               acpi_os_printf ("Predicate is FALSE, skipping block\n");
+                               acpi_os_printf ("Predicate = [False], Skipping IF block\n");
                        }
                }
 
                else if (op->opcode == AML_ELSE_OP) {
-                       /* TBD */
+                       acpi_os_printf ("Predicate = [False], ELSE block was executed\n");
                }
 
                /* Restore everything */
@@ -159,7 +192,6 @@ acpi_db_single_step (
                return (AE_OK);
        }
 
-
        /*
         * If we are executing a step-to-call command,
         * Check if this is a method call.
@@ -176,7 +208,6 @@ acpi_db_single_step (
                acpi_gbl_step_to_next_call = FALSE;
        }
 
-
        /*
         * If the next opcode is a method call, we will "step over" it
         * by default.
@@ -184,11 +215,9 @@ acpi_db_single_step (
        if (op->opcode == AML_INT_METHODCALL_OP) {
                acpi_gbl_cm_single_step = FALSE; /* No more single step while executing called method */
 
-               /* Set the breakpoint on the call, it will stop execution as soon as we return */
+               /* Set the breakpoint on/before the call, it will stop execution as soon as we return */
 
-               /* TBD: [Future] don't kill the user breakpoint! */
-
-               walk_state->method_breakpoint = /* Op->Aml_offset + */ 1; /* Must be non-zero! */
+               walk_state->method_breakpoint = 1; /* Must be non-zero! */
        }
 
 
@@ -204,8 +233,14 @@ acpi_db_single_step (
                if (acpi_gbl_debugger_configuration == DEBUGGER_MULTI_THREADED) {
                        /* Handshake with the front-end that gets user command lines */
 
-                       acpi_ut_release_mutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
-                       acpi_ut_acquire_mutex (ACPI_MTX_DEBUG_CMD_READY);
+                       status = acpi_ut_release_mutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
+                       if (ACPI_FAILURE (status)) {
+                               return (status);
+                       }
+                       status = acpi_ut_acquire_mutex (ACPI_MTX_DEBUG_CMD_READY);
+                       if (ACPI_FAILURE (status)) {
+                               return (status);
+                       }
                }
 
                else {
@@ -213,15 +248,15 @@ acpi_db_single_step (
 
                        /* Force output to console until a command is entered */
 
-                       acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
+                       acpi_db_set_output_destination (ACPI_DB_CONSOLE_OUTPUT);
 
                        /* Different prompt if method is executing */
 
                        if (!acpi_gbl_method_executing) {
-                               acpi_os_printf ("%1c ", DB_COMMAND_PROMPT);
+                               acpi_os_printf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT);
                        }
                        else {
-                               acpi_os_printf ("%1c ", DB_EXECUTE_PROMPT);
+                               acpi_os_printf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT);
                        }
 
                        /* Get the user input line */
@@ -256,16 +291,33 @@ int
 acpi_db_initialize (void)
 {
 
-
        /* Init globals */
 
-       acpi_gbl_db_buffer = acpi_os_callocate (ACPI_DEBUG_BUFFER_SIZE);
+       acpi_gbl_db_buffer          = NULL;
+       acpi_gbl_db_filename        = NULL;
+       acpi_gbl_db_output_to_file  = FALSE;
+
+       acpi_gbl_db_debug_level     = ACPI_LV_VERBOSITY2;
+       acpi_gbl_db_console_debug_level = NORMAL_DEFAULT | ACPI_LV_TABLES;
+       acpi_gbl_db_output_flags    = ACPI_DB_CONSOLE_OUTPUT;
+
+       acpi_gbl_db_opt_tables      = FALSE;
+       acpi_gbl_db_opt_disasm      = FALSE;
+       acpi_gbl_db_opt_stats       = FALSE;
+       acpi_gbl_db_opt_verbose     = TRUE;
+       acpi_gbl_db_opt_ini_methods = TRUE;
+
+       acpi_gbl_db_buffer = acpi_os_allocate (ACPI_DEBUG_BUFFER_SIZE);
+       if (!acpi_gbl_db_buffer) {
+               return 0;
+       }
+       ACPI_MEMSET (acpi_gbl_db_buffer, 0, ACPI_DEBUG_BUFFER_SIZE);
 
        /* Initial scope is the root */
 
        acpi_gbl_db_scope_buf [0] = '\\';
        acpi_gbl_db_scope_buf [1] = 0;
-
+       acpi_gbl_db_scope_node = acpi_gbl_root_node;
 
        /*
         * If configured for multi-thread support, the debug executor runs in
index 0714c087172adf7cb040934c0602ec8c336b3ccd..d0bbc7655a46e95b304e00deeca0e7cf8e60f997 100644 (file)
@@ -1,11 +1,10 @@
 #
 # Makefile for all Linux ACPI interpreter subdirectories
-# EXCEPT for the ospm directory
 #
 
 O_TARGET := $(notdir $(CURDIR)).o
 
-obj-$(CONFIG_ACPI) := $(patsubst %.c,%.o,$(wildcard *.c))
+obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
 
index 322c0d19ba1d46f0e09d494d9216c94080e8edd0..c5c365cc9f9c926440c06c440b87c513912ddba3 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: dsfield - Dispatcher field routines
- *              $Revision: 46 $
+ *              $Revision: 62 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -33,7 +33,7 @@
 
 
 #define _COMPONENT          ACPI_DISPATCHER
-        MODULE_NAME         ("dsfield")
+        ACPI_MODULE_NAME    ("dsfield")
 
 
 /*******************************************************************************
@@ -65,9 +65,11 @@ acpi_ds_create_buffer_field (
        acpi_namespace_node     *node;
        acpi_status             status;
        acpi_operand_object     *obj_desc;
+       acpi_operand_object     *second_desc = NULL;
+       u32                     flags;
 
 
-       FUNCTION_TRACE ("Ds_create_buffer_field");
+       ACPI_FUNCTION_TRACE ("Ds_create_buffer_field");
 
 
        /* Get the Name_string argument */
@@ -85,13 +87,24 @@ acpi_ds_create_buffer_field (
                return_ACPI_STATUS (AE_AML_NO_OPERAND);
        }
 
+       /*
+        * During the load phase, we want to enter the name of the field into
+        * the namespace.  During the execute phase (when we evaluate the size
+        * operand), we want to lookup the name
+        */
+       if (walk_state->parse_flags & ACPI_PARSE_EXECUTE) {
+               flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE;
+       }
+       else {
+               flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND;
+       }
+
        /*
         * Enter the Name_string into the namespace
         */
        status = acpi_ns_lookup (walk_state->scope_info, arg->value.string,
-                        INTERNAL_TYPE_DEF_ANY, IMODE_LOAD_PASS1,
-                        NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE,
-                        walk_state, &(node));
+                        INTERNAL_TYPE_DEF_ANY, ACPI_IMODE_LOAD_PASS1,
+                        flags, walk_state, &(node));
        if (ACPI_FAILURE (status)) {
                return_ACPI_STATUS (status);
        }
@@ -107,7 +120,8 @@ acpi_ds_create_buffer_field (
         * we need to create the field object.  Otherwise, this was a lookup of an
         * existing node and we don't want to create the field object again.
         */
-       if (node->object) {
+       obj_desc = acpi_ns_get_attached_object (node);
+       if (obj_desc) {
                return_ACPI_STATUS (AE_OK);
        }
 
@@ -124,28 +138,22 @@ acpi_ds_create_buffer_field (
                goto cleanup;
        }
 
-       /*
-        * Allocate a method object for this field unit
-        */
-       obj_desc->buffer_field.extra = acpi_ut_create_internal_object (
-                          INTERNAL_TYPE_EXTRA);
-       if (!obj_desc->buffer_field.extra) {
-               status = AE_NO_MEMORY;
-               goto cleanup;
-       }
-
        /*
         * Remember location in AML stream of the field unit
         * opcode and operands -- since the buffer and index
         * operands must be evaluated.
         */
-       obj_desc->buffer_field.extra->extra.aml_start = ((acpi_parse2_object *) op)->data;
-       obj_desc->buffer_field.extra->extra.aml_length = ((acpi_parse2_object *) op)->length;
+       second_desc                 = obj_desc->common.next_object;
+       second_desc->extra.aml_start = ((acpi_parse2_object *) op)->data;
+       second_desc->extra.aml_length = ((acpi_parse2_object *) op)->length;
        obj_desc->buffer_field.node = node;
 
-       /* Attach constructed field descriptor to parent node */
+       /* Attach constructed field descriptors to parent node */
 
        status = acpi_ns_attach_object (node, obj_desc, ACPI_TYPE_BUFFER_FIELD);
+       if (ACPI_FAILURE (status)) {
+               goto cleanup;
+       }
 
 
 cleanup:
@@ -181,7 +189,7 @@ acpi_ds_get_field_names (
        acpi_status             status;
 
 
-       FUNCTION_TRACE_U32 ("Ds_get_field_names", info);
+       ACPI_FUNCTION_TRACE_PTR ("Ds_get_field_names", info);
 
 
        /* First field starts at bit zero */
@@ -200,6 +208,12 @@ acpi_ds_get_field_names (
                switch (arg->opcode) {
                case AML_INT_RESERVEDFIELD_OP:
 
+                       if (((acpi_integer) info->field_bit_position + arg->value.size) >
+                               ACPI_UINT32_MAX) {
+                               ACPI_REPORT_ERROR (("Bit offset within field too large (> 0xFFFFFFFF)\n"));
+                               return_ACPI_STATUS (AE_SUPPORT);
+                       }
+
                        info->field_bit_position += arg->value.size;
                        break;
 
@@ -207,38 +221,55 @@ acpi_ds_get_field_names (
                case AML_INT_ACCESSFIELD_OP:
 
                        /*
-                        * Get a new Access_type and Access_attribute for all
-                        * entries (until end or another Access_as keyword)
+                        * Get a new Access_type and Access_attribute -- to be used for all
+                        * field units that follow, until field end or another Access_as keyword.
+                        *
+                        * In Field_flags, preserve the flag bits other than the ACCESS_TYPE bits
                         */
-                       info->field_flags = (u8) ((info->field_flags & FIELD_ACCESS_TYPE_MASK) ||
-                                         ((u8) (arg->value.integer >> 8)));
+                       info->field_flags = (u8) ((info->field_flags & ~(AML_FIELD_ACCESS_TYPE_MASK)) |
+                                         ((u8) (arg->value.integer32 >> 8)));
+
+                       info->attribute = (u8) (arg->value.integer32);
                        break;
 
 
                case AML_INT_NAMEDFIELD_OP:
 
-                       /* Enter a new field name into the namespace */
+                       /* Lookup the name */
 
                        status = acpi_ns_lookup (walk_state->scope_info,
                                          (NATIVE_CHAR *) &((acpi_parse2_object *)arg)->name,
-                                         info->field_type, IMODE_LOAD_PASS1,
-                                         NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE,
-                                         NULL, &info->field_node);
+                                         info->field_type, ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE,
+                                         walk_state, &info->field_node);
                        if (ACPI_FAILURE (status)) {
-                               return_ACPI_STATUS (status);
-                       }
+                               if (status != AE_ALREADY_EXISTS) {
+                                       return_ACPI_STATUS (status);
+                               }
 
-                       /* Create and initialize an object for the new Field Node */
+                               ACPI_REPORT_ERROR (("Field name [%4.4s] already exists in current scope\n",
+                                                 &((acpi_parse2_object *)arg)->name));
+                       }
+                       else {
+                               arg->node = info->field_node;
+                               info->field_bit_length = arg->value.size;
 
-                       info->field_bit_length = arg->value.size;
+                               /* Create and initialize an object for the new Field Node */
 
-                       status = acpi_ex_prep_field_value (info);
-                       if (ACPI_FAILURE (status)) {
-                               return_ACPI_STATUS (status);
+                               status = acpi_ex_prep_field_value (info);
+                               if (ACPI_FAILURE (status)) {
+                                       return_ACPI_STATUS (status);
+                               }
                        }
 
                        /* Keep track of bit position for the next field */
 
+                       if (((acpi_integer) info->field_bit_position + arg->value.size) >
+                               ACPI_UINT32_MAX) {
+                               ACPI_REPORT_ERROR (("Field [%4.4s] bit offset too large (> 0xFFFFFFFF)\n",
+                                       &info->field_node->name));
+                               return_ACPI_STATUS (AE_SUPPORT);
+                       }
+
                        info->field_bit_position += info->field_bit_length;
                        break;
 
@@ -248,7 +279,6 @@ acpi_ds_get_field_names (
                        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid opcode in field list: %X\n",
                                arg->opcode));
                        return_ACPI_STATUS (AE_AML_ERROR);
-                       break;
                }
 
                arg = arg->next;
@@ -283,7 +313,7 @@ acpi_ds_create_field (
        ACPI_CREATE_FIELD_INFO  info;
 
 
-       FUNCTION_TRACE_PTR ("Ds_create_field", op);
+       ACPI_FUNCTION_TRACE_PTR ("Ds_create_field", op);
 
 
        /* First arg is the name of the parent Op_region (must already exist) */
@@ -291,8 +321,8 @@ acpi_ds_create_field (
        arg = op->value.arg;
        if (!region_node) {
                status = acpi_ns_lookup (walk_state->scope_info, arg->value.name,
-                                 ACPI_TYPE_REGION, IMODE_EXECUTE,
-                                 NS_SEARCH_PARENT, walk_state, &region_node);
+                                 ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE,
+                                 ACPI_NS_SEARCH_PARENT, walk_state, &region_node);
                if (ACPI_FAILURE (status)) {
                        return_ACPI_STATUS (status);
                }
@@ -302,6 +332,7 @@ acpi_ds_create_field (
 
        arg = arg->next;
        info.field_flags = arg->value.integer8;
+       info.attribute = 0;
 
        /* Each remaining arg is a Named Field */
 
@@ -314,6 +345,85 @@ acpi_ds_create_field (
 }
 
 
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ds_init_field_objects
+ *
+ * PARAMETERS:  Op              - Op containing the Field definition and args
+ *  `           Walk_state      - Current method state
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: For each "Field Unit" name in the argument list that is
+ *              part of the field declaration, enter the name into the
+ *              namespace.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ds_init_field_objects (
+       acpi_parse_object       *op,
+       acpi_walk_state         *walk_state)
+{
+       acpi_status             status = AE_AML_ERROR;
+       acpi_parse_object       *arg = NULL;
+       acpi_namespace_node     *node;
+       u8                      type = 0;
+
+
+       ACPI_FUNCTION_TRACE_PTR ("Ds_init_field_objects", op);
+
+
+       switch (walk_state->opcode) {
+       case AML_FIELD_OP:
+               arg = acpi_ps_get_arg (op, 2);
+               type = INTERNAL_TYPE_REGION_FIELD;
+               break;
+
+       case AML_BANK_FIELD_OP:
+               arg = acpi_ps_get_arg (op, 4);
+               type = INTERNAL_TYPE_BANK_FIELD;
+               break;
+
+       case AML_INDEX_FIELD_OP:
+               arg = acpi_ps_get_arg (op, 3);
+               type = INTERNAL_TYPE_INDEX_FIELD;
+               break;
+       }
+
+       /*
+        * Walk the list of entries in the Field_list
+        */
+       while (arg) {
+               /* Ignore OFFSET and ACCESSAS terms here */
+
+               if (arg->opcode == AML_INT_NAMEDFIELD_OP) {
+                       status = acpi_ns_lookup (walk_state->scope_info,
+                                         (NATIVE_CHAR *) &((acpi_parse2_object *)arg)->name,
+                                         type, ACPI_IMODE_LOAD_PASS1,
+                                         ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND,
+                                         walk_state, &node);
+                       if (ACPI_FAILURE (status)) {
+                               if (status != AE_ALREADY_EXISTS) {
+                                       return_ACPI_STATUS (status);
+                               }
+
+                               ACPI_REPORT_ERROR (("Field name [%4.4s] already exists in current scope\n",
+                                                 &((acpi_parse2_object *)arg)->name));
+                       }
+
+                       arg->node = node;
+               }
+
+               /* Move to next field in the list */
+
+               arg = arg->next;
+       }
+
+       return_ACPI_STATUS (status);
+}
+
+
 /*******************************************************************************
  *
  * FUNCTION:    Acpi_ds_create_bank_field
@@ -339,7 +449,7 @@ acpi_ds_create_bank_field (
        ACPI_CREATE_FIELD_INFO  info;
 
 
-       FUNCTION_TRACE_PTR ("Ds_create_bank_field", op);
+       ACPI_FUNCTION_TRACE_PTR ("Ds_create_bank_field", op);
 
 
        /* First arg is the name of the parent Op_region (must already exist) */
@@ -347,8 +457,8 @@ acpi_ds_create_bank_field (
        arg = op->value.arg;
        if (!region_node) {
                status = acpi_ns_lookup (walk_state->scope_info, arg->value.name,
-                                 ACPI_TYPE_REGION, IMODE_EXECUTE,
-                                 NS_SEARCH_PARENT, walk_state, &region_node);
+                                 ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE,
+                                 ACPI_NS_SEARCH_PARENT, walk_state, &region_node);
                if (ACPI_FAILURE (status)) {
                        return_ACPI_STATUS (status);
                }
@@ -358,8 +468,8 @@ acpi_ds_create_bank_field (
 
        arg = arg->next;
        status = acpi_ns_lookup (walk_state->scope_info, arg->value.string,
-                         INTERNAL_TYPE_BANK_FIELD_DEFN, IMODE_EXECUTE,
-                         NS_SEARCH_PARENT, walk_state, &info.register_node);
+                         INTERNAL_TYPE_BANK_FIELD_DEFN, ACPI_IMODE_EXECUTE,
+                         ACPI_NS_SEARCH_PARENT, walk_state, &info.register_node);
        if (ACPI_FAILURE (status)) {
                return_ACPI_STATUS (status);
        }
@@ -410,15 +520,15 @@ acpi_ds_create_index_field (
        ACPI_CREATE_FIELD_INFO  info;
 
 
-       FUNCTION_TRACE_PTR ("Ds_create_index_field", op);
+       ACPI_FUNCTION_TRACE_PTR ("Ds_create_index_field", op);
 
 
        /* First arg is the name of the Index register (must already exist) */
 
        arg = op->value.arg;
        status = acpi_ns_lookup (walk_state->scope_info, arg->value.string,
-                         ACPI_TYPE_ANY, IMODE_EXECUTE,
-                         NS_SEARCH_PARENT, walk_state, &info.register_node);
+                         ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
+                         ACPI_NS_SEARCH_PARENT, walk_state, &info.register_node);
        if (ACPI_FAILURE (status)) {
                return_ACPI_STATUS (status);
        }
@@ -427,8 +537,8 @@ acpi_ds_create_index_field (
 
        arg = arg->next;
        status = acpi_ns_lookup (walk_state->scope_info, arg->value.string,
-                         INTERNAL_TYPE_INDEX_FIELD_DEFN, IMODE_EXECUTE,
-                         NS_SEARCH_PARENT, walk_state, &info.data_register_node);
+                         INTERNAL_TYPE_INDEX_FIELD_DEFN, ACPI_IMODE_EXECUTE,
+                         ACPI_NS_SEARCH_PARENT, walk_state, &info.data_register_node);
        if (ACPI_FAILURE (status)) {
                return_ACPI_STATUS (status);
        }
index f5643b5f6c00a57a19ae0f06742c828f0c15c5dc..f10f412d6df0294c1f28045b89dc077deacb66ec 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: dsmethod - Parser/Interpreter interface - control method parsing
- *              $Revision: 69 $
+ *              $Revision: 79 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -35,7 +35,7 @@
 
 
 #define _COMPONENT          ACPI_DISPATCHER
-        MODULE_NAME         ("dsmethod")
+        ACPI_MODULE_NAME    ("dsmethod")
 
 
 /*******************************************************************************
@@ -68,7 +68,7 @@ acpi_ds_parse_method (
        acpi_walk_state         *walk_state;
 
 
-       FUNCTION_TRACE_PTR ("Ds_parse_method", obj_handle);
+       ACPI_FUNCTION_TRACE_PTR ("Ds_parse_method", obj_handle);
 
 
        /* Parameter Validation */
@@ -78,13 +78,12 @@ acpi_ds_parse_method (
        }
 
        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Parsing [%4.4s] **** Named_obj=%p\n",
-               (char*)&((acpi_namespace_node *)obj_handle)->name, obj_handle));
-
+               (char *) &((acpi_namespace_node *) obj_handle)->name, obj_handle));
 
        /* Extract the method object from the method Node */
 
        node = (acpi_namespace_node *) obj_handle;
-       obj_desc = node->object;
+       obj_desc = acpi_ns_get_attached_object (node);
        if (!obj_desc) {
                return_ACPI_STATUS (AE_NULL_OBJECT);
        }
@@ -115,9 +114,17 @@ acpi_ds_parse_method (
        acpi_ps_set_name (op, node->name);
        op->node = node;
 
+       /*
+        * Get a new Owner_id for objects created by this method. Namespace
+        * objects (such as Operation Regions) can be created during the
+        * first pass parse.
+        */
+       owner_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_METHOD);
+       obj_desc->method.owning_id = owner_id;
+
        /* Create and initialize a new walk state */
 
-       walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT,
+       walk_state = acpi_ds_create_walk_state (owner_id,
                           NULL, NULL, NULL);
        if (!walk_state) {
                return_ACPI_STATUS (AE_NO_MEMORY);
@@ -126,7 +133,7 @@ acpi_ds_parse_method (
        status = acpi_ds_init_aml_walk (walk_state, op, node, obj_desc->method.aml_start,
                          obj_desc->method.aml_length, NULL, NULL, 1);
        if (ACPI_FAILURE (status)) {
-               /* TBD: delete walk state */
+               acpi_ds_delete_walk_state (walk_state);
                return_ACPI_STATUS (status);
        }
 
@@ -145,16 +152,10 @@ acpi_ds_parse_method (
                return_ACPI_STATUS (status);
        }
 
-       /* Get a new Owner_id for objects created by this method */
-
-       owner_id = acpi_ut_allocate_owner_id (OWNER_TYPE_METHOD);
-       obj_desc->method.owning_id = owner_id;
-
        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** [%4.4s] Parsed **** Named_obj=%p Op=%p\n",
-               (char*)&((acpi_namespace_node *)obj_handle)->name, obj_handle, op));
+               (char *) &((acpi_namespace_node *) obj_handle)->name, obj_handle, op));
 
        acpi_ps_delete_parse_tree (op);
-
        return_ACPI_STATUS (status);
 }
 
@@ -186,14 +187,13 @@ acpi_ds_begin_method_execution (
        acpi_status             status = AE_OK;
 
 
-       FUNCTION_TRACE_PTR ("Ds_begin_method_execution", method_node);
+       ACPI_FUNCTION_TRACE_PTR ("Ds_begin_method_execution", method_node);
 
 
        if (!method_node) {
                return_ACPI_STATUS (AE_NULL_ENTRY);
        }
 
-
        /*
         * If there is a concurrency limit on this method, we need to
         * obtain a unit from the method semaphore.
@@ -221,13 +221,11 @@ acpi_ds_begin_method_execution (
                                 WAIT_FOREVER);
        }
 
-
        /*
         * Increment the method parse tree thread count since it has been
         * reentered one more time (even if it is the same thread)
         */
        obj_desc->method.thread_count++;
-
        return_ACPI_STATUS (status);
 }
 
@@ -247,9 +245,9 @@ acpi_ds_begin_method_execution (
 
 acpi_status
 acpi_ds_call_control_method (
-       acpi_walk_list          *walk_list,
+       ACPI_THREAD_STATE       *thread,
        acpi_walk_state         *this_walk_state,
-       acpi_parse_object       *op)  /* TBD: This operand is obsolete */
+       acpi_parse_object       *op)
 {
        acpi_status             status;
        acpi_namespace_node     *method_node;
@@ -258,7 +256,7 @@ acpi_ds_call_control_method (
        u32                     i;
 
 
-       FUNCTION_TRACE_PTR ("Ds_call_control_method", this_walk_state);
+       ACPI_FUNCTION_TRACE_PTR ("Ds_call_control_method", this_walk_state);
 
        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Execute method %p, currentstate=%p\n",
                this_walk_state->prev_op, this_walk_state));
@@ -284,14 +282,12 @@ acpi_ds_call_control_method (
                return_ACPI_STATUS (status);
        }
 
-
        /* 1) Parse: Create a new walk state for the preempting walk */
 
        next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id,
                          op, obj_desc, NULL);
        if (!next_walk_state) {
                return_ACPI_STATUS (AE_NO_MEMORY);
-               goto cleanup;
        }
 
        /* Create and init a Root Node */
@@ -306,7 +302,7 @@ acpi_ds_call_control_method (
                          obj_desc->method.aml_start, obj_desc->method.aml_length,
                          NULL, NULL, 1);
        if (ACPI_FAILURE (status)) {
-               /* TBD: delete walk state */
+               acpi_ds_delete_walk_state (next_walk_state);
                goto cleanup;
        }
 
@@ -315,11 +311,10 @@ acpi_ds_call_control_method (
        status = acpi_ps_parse_aml (next_walk_state);
        acpi_ps_delete_parse_tree (op);
 
-
        /* 2) Execute: Create a new state for the preempting walk */
 
        next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id,
-                         NULL, obj_desc, walk_list);
+                         NULL, obj_desc, thread);
        if (!next_walk_state) {
                status = AE_NO_MEMORY;
                goto cleanup;
@@ -390,7 +385,7 @@ acpi_ds_restart_control_method (
        acpi_status             status;
 
 
-       FUNCTION_TRACE_PTR ("Ds_restart_control_method", walk_state);
+       ACPI_FUNCTION_TRACE_PTR ("Ds_restart_control_method", walk_state);
 
 
        if (return_desc) {
@@ -405,7 +400,6 @@ acpi_ds_restart_control_method (
                                return_ACPI_STATUS (status);
                        }
                }
-
                else {
                        /*
                         * Delete the return value if it will not be used by the
@@ -413,7 +407,6 @@ acpi_ds_restart_control_method (
                         */
                        acpi_ut_remove_reference (return_desc);
                }
-
        }
 
        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
@@ -446,12 +439,13 @@ acpi_ds_terminate_control_method (
 {
        acpi_operand_object     *obj_desc;
        acpi_namespace_node     *method_node;
+       acpi_status             status;
 
 
-       FUNCTION_TRACE_PTR ("Ds_terminate_control_method", walk_state);
+       ACPI_FUNCTION_TRACE_PTR ("Ds_terminate_control_method", walk_state);
 
 
-       /* The method object should be stored in the walk state */
+       /* The current method object was saved in the walk state */
 
        obj_desc = walk_state->method_desc;
        if (!obj_desc) {
@@ -467,8 +461,10 @@ acpi_ds_terminate_control_method (
         * If this is the last thread executing the method,
         * we have additional cleanup to perform
         */
-       acpi_ut_acquire_mutex (ACPI_MTX_PARSER);
-
+       status = acpi_ut_acquire_mutex (ACPI_MTX_PARSER);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
 
        /* Signal completion of the execution of this method if necessary */
 
@@ -493,7 +489,11 @@ acpi_ds_terminate_control_method (
                 * Delete any namespace entries created immediately underneath
                 * the method
                 */
-               acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+               status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+               if (ACPI_FAILURE (status)) {
+                       return_ACPI_STATUS (status);
+               }
+
                if (method_node->child) {
                        acpi_ns_delete_namespace_subtree (method_node);
                }
@@ -503,11 +503,14 @@ acpi_ds_terminate_control_method (
                 * the namespace
                 */
                acpi_ns_delete_namespace_by_owner (walk_state->method_desc->method.owning_id);
-               acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+               status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+               if (ACPI_FAILURE (status)) {
+                       return_ACPI_STATUS (status);
+               }
        }
 
-       acpi_ut_release_mutex (ACPI_MTX_PARSER);
-       return_ACPI_STATUS (AE_OK);
+       status = acpi_ut_release_mutex (ACPI_MTX_PARSER);
+       return_ACPI_STATUS (status);
 }
 
 
index 29e3dac1001cbd4bb86438f1cdb243c0cb65fe41..6232e19e8977e2625689f27b44572f8b9503d08a 100644 (file)
@@ -1,12 +1,12 @@
 /*******************************************************************************
  *
  * Module Name: dsmthdat - control method arguments and local variables
- *              $Revision: 49 $
+ *              $Revision: 58 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -33,7 +33,7 @@
 
 
 #define _COMPONENT          ACPI_DISPATCHER
-        MODULE_NAME         ("dsmthdat")
+        ACPI_MODULE_NAME    ("dsmthdat")
 
 
 /*******************************************************************************
  *              This allows Ref_of and De_ref_of to work properly for these
  *              special data types.
  *
+ * NOTES:       Walk_state fields are initialized to zero by the
+ *              ACPI_MEM_CALLOCATE().
+ *
+ *              A pseudo-Namespace Node is assigned to each argument and local
+ *              so that Ref_of() can return a pointer to the Node.
+ *
  ******************************************************************************/
 
 acpi_status
@@ -58,37 +64,30 @@ acpi_ds_method_data_init (
        u32                     i;
 
 
-       FUNCTION_TRACE ("Ds_method_data_init");
+       ACPI_FUNCTION_TRACE ("Ds_method_data_init");
 
-       /*
-        * Walk_state fields are initialized to zero by the
-        * ACPI_MEM_CALLOCATE().
-        *
-        * An Node is assigned to each argument and local so
-        * that Ref_of() can return a pointer to the Node.
-        */
 
        /* Init the method arguments */
 
        for (i = 0; i < MTH_NUM_ARGS; i++) {
-               MOVE_UNALIGNED32_TO_32 (&walk_state->arguments[i].name,
+               ACPI_MOVE_UNALIGNED32_TO_32 (&walk_state->arguments[i].name,
                                 NAMEOF_ARG_NTE);
-               walk_state->arguments[i].name      |= (i << 24);
-               walk_state->arguments[i].data_type  = ACPI_DESC_TYPE_NAMED;
-               walk_state->arguments[i].type       = ACPI_TYPE_ANY;
-               walk_state->arguments[i].flags      = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG;
+               walk_state->arguments[i].name     |= (i << 24);
+               walk_state->arguments[i].descriptor = ACPI_DESC_TYPE_NAMED;
+               walk_state->arguments[i].type      = ACPI_TYPE_ANY;
+               walk_state->arguments[i].flags     = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG;
        }
 
        /* Init the method locals */
 
        for (i = 0; i < MTH_NUM_LOCALS; i++) {
-               MOVE_UNALIGNED32_TO_32 (&walk_state->local_variables[i].name,
+               ACPI_MOVE_UNALIGNED32_TO_32 (&walk_state->local_variables[i].name,
                                 NAMEOF_LOCAL_NTE);
 
-               walk_state->local_variables[i].name  |= (i << 24);
-               walk_state->local_variables[i].data_type = ACPI_DESC_TYPE_NAMED;
-               walk_state->local_variables[i].type   = ACPI_TYPE_ANY;
-               walk_state->local_variables[i].flags  = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL;
+               walk_state->local_variables[i].name    |= (i << 24);
+               walk_state->local_variables[i].descriptor = ACPI_DESC_TYPE_NAMED;
+               walk_state->local_variables[i].type     = ACPI_TYPE_ANY;
+               walk_state->local_variables[i].flags    = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL;
        }
 
        return_ACPI_STATUS (AE_OK);
@@ -113,48 +112,34 @@ acpi_ds_method_data_delete_all (
        acpi_walk_state         *walk_state)
 {
        u32                     index;
-       acpi_operand_object     *object;
-
 
-       FUNCTION_TRACE ("Ds_method_data_delete_all");
 
+       ACPI_FUNCTION_TRACE ("Ds_method_data_delete_all");
 
-       /* Delete the locals */
 
-       ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Deleting local variables in %p\n", walk_state));
+       /* Detach the locals */
 
        for (index = 0; index < MTH_NUM_LOCALS; index++) {
-               object = walk_state->local_variables[index].object;
-               if (object) {
-                       ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%d=%p\n", index, object));
-
-                       /* Remove first */
-
-                       walk_state->local_variables[index].object = NULL;
+               if (walk_state->local_variables[index].object) {
+                       ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%d=%p\n",
+                                       index, walk_state->local_variables[index].object));
 
-                       /* Was given a ref when stored */
+                       /* Detach object (if present) and remove a reference */
 
-                       acpi_ut_remove_reference (object);
+                       acpi_ns_detach_object (&walk_state->local_variables[index]);
           }
        }
 
-
-       /* Delete the arguments */
-
-       ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Deleting arguments in %p\n", walk_state));
+       /* Detach the arguments */
 
        for (index = 0; index < MTH_NUM_ARGS; index++) {
-               object = walk_state->arguments[index].object;
-               if (object) {
-                       ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%d=%p\n", index, object));
-
-                       /* Remove first */
-
-                       walk_state->arguments[index].object = NULL;
+               if (walk_state->arguments[index].object) {
+                       ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%d=%p\n",
+                                       index, walk_state->arguments[index].object));
 
-                        /* Was given a ref when stored */
+                       /* Detach object (if present) and remove a reference */
 
-                       acpi_ut_remove_reference (object);
+                       acpi_ns_detach_object (&walk_state->arguments[index]);
                }
        }
 
@@ -172,7 +157,9 @@ acpi_ds_method_data_delete_all (
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Initialize arguments for a method
+ * DESCRIPTION: Initialize arguments for a method.  The parameter list is a list
+ *              of ACPI operand objects, either null terminated or whose length
+ *              is defined by Max_param_count.
  *
  ******************************************************************************/
 
@@ -183,11 +170,10 @@ acpi_ds_method_data_init_args (
        acpi_walk_state         *walk_state)
 {
        acpi_status             status;
-       u32                     mindex;
-       u32                     pindex;
+       u32                     index = 0;
 
 
-       FUNCTION_TRACE_PTR ("Ds_method_data_init_args", params);
+       ACPI_FUNCTION_TRACE_PTR ("Ds_method_data_init_args", params);
 
 
        if (!params) {
@@ -197,106 +183,90 @@ acpi_ds_method_data_init_args (
 
        /* Copy passed parameters into the new method stack frame  */
 
-       for (pindex = mindex = 0;
-               (mindex < MTH_NUM_ARGS) && (pindex < max_param_count);
-               mindex++) {
-               if (params[pindex]) {
-                       /*
-                        * A valid parameter.
-                        * Set the current method argument to the
-                        * Params[Pindex++] argument object descriptor
-                        */
-                       status = acpi_ds_store_object_to_local (AML_ARG_OP, mindex,
-                                         params[pindex], walk_state);
-                       if (ACPI_FAILURE (status)) {
-                               break;
-                       }
-
-                       pindex++;
+       while ((index < MTH_NUM_ARGS) && (index < max_param_count) && params[index]) {
+               /*
+                * A valid parameter.
+                * Store the argument in the method/walk descriptor
+                */
+               status = acpi_ds_store_object_to_local (AML_ARG_OP, index, params[index],
+                                walk_state);
+               if (ACPI_FAILURE (status)) {
+                       return_ACPI_STATUS (status);
                }
 
-               else {
-                       break;
-               }
+               index++;
        }
 
-       ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%d args passed to method\n", pindex));
+       ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%d args passed to method\n", index));
        return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_method_data_get_entry
+ * FUNCTION:    Acpi_ds_method_data_get_node
  *
  * PARAMETERS:  Opcode              - Either AML_LOCAL_OP or AML_ARG_OP
- *              Index               - Which local_var or argument to get
- *              Entry               - Pointer to where a pointer to the stack
- *                                    entry is returned.
+ *              Index               - Which local_var or argument whose type
+ *                                      to get
  *              Walk_state          - Current walk state object
  *
- * RETURN:      Status
- *
- * DESCRIPTION: Get the address of the object entry given by Opcode:Index
+ * RETURN:      Get the Node associated with a local or arg.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_ds_method_data_get_entry (
+acpi_ds_method_data_get_node (
        u16                     opcode,
        u32                     index,
        acpi_walk_state         *walk_state,
-       acpi_operand_object     ***entry)
+       acpi_namespace_node     **node)
 {
-
-       FUNCTION_TRACE_U32 ("Ds_method_data_get_entry", index);
+       ACPI_FUNCTION_TRACE ("Ds_method_data_get_node");
 
 
        /*
-        * Get the requested object.
-        * The stack "Opcode" is either a Local_variable or an Argument
+        * Method Locals and Arguments are supported
         */
        switch (opcode) {
-
        case AML_LOCAL_OP:
 
                if (index > MTH_MAX_LOCAL) {
-                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Local_var index %d is invalid (max %d)\n",
+                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Local index %d is invalid (max %d)\n",
                                index, MTH_MAX_LOCAL));
-                       return_ACPI_STATUS (AE_BAD_PARAMETER);
+                       return_ACPI_STATUS (AE_AML_INVALID_INDEX);
                }
 
-               *entry = (acpi_operand_object  **)
-                                &walk_state->local_variables[index].object;
-               break;
+               /* Return a pointer to the pseudo-node */
 
+               *node = &walk_state->local_variables[index];
+               break;
 
        case AML_ARG_OP:
 
                if (index > MTH_MAX_ARG) {
                        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Arg index %d is invalid (max %d)\n",
                                index, MTH_MAX_ARG));
-                       return_ACPI_STATUS (AE_BAD_PARAMETER);
+                       return_ACPI_STATUS (AE_AML_INVALID_INDEX);
                }
 
-               *entry = (acpi_operand_object  **)
-                                &walk_state->arguments[index].object;
-               break;
+               /* Return a pointer to the pseudo-node */
 
+               *node = &walk_state->arguments[index];
+               break;
 
        default:
                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Opcode %d is invalid\n", opcode));
-               return_ACPI_STATUS (AE_BAD_PARAMETER);
+               return_ACPI_STATUS (AE_AML_BAD_OPCODE);
        }
 
-
        return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_method_data_set_entry
+ * FUNCTION:    Acpi_ds_method_data_set_value
  *
  * PARAMETERS:  Opcode              - Either AML_LOCAL_OP or AML_ARG_OP
  *              Index               - Which local_var or argument to get
@@ -310,22 +280,22 @@ acpi_ds_method_data_get_entry (
  ******************************************************************************/
 
 acpi_status
-acpi_ds_method_data_set_entry (
+acpi_ds_method_data_set_value (
        u16                     opcode,
        u32                     index,
        acpi_operand_object     *object,
        acpi_walk_state         *walk_state)
 {
        acpi_status             status;
-       acpi_operand_object     **entry;
+       acpi_namespace_node     *node;
 
 
-       FUNCTION_TRACE ("Ds_method_data_set_entry");
+       ACPI_FUNCTION_TRACE ("Ds_method_data_set_value");
 
 
-       /* Get a pointer to the stack entry to set */
+       /* Get the namespace node for the arg/local */
 
-       status = acpi_ds_method_data_get_entry (opcode, index, walk_state, &entry);
+       status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node);
        if (ACPI_FAILURE (status)) {
                return_ACPI_STATUS (status);
        }
@@ -336,8 +306,7 @@ acpi_ds_method_data_set_entry (
 
        /* Install the object into the stack entry */
 
-       *entry = object;
-
+       node->object = object;
        return_ACPI_STATUS (AE_OK);
 }
 
@@ -351,105 +320,43 @@ acpi_ds_method_data_set_entry (
  *                                      to get
  *              Walk_state          - Current walk state object
  *
- * RETURN:      Data type of selected Arg or Local
- *              Used only in Exec_monadic2()/Type_op.
+ * RETURN:      Data type of current value of the selected Arg or Local
  *
  ******************************************************************************/
 
-acpi_object_type8
+acpi_object_type
 acpi_ds_method_data_get_type (
        u16                     opcode,
        u32                     index,
        acpi_walk_state         *walk_state)
 {
        acpi_status             status;
-       acpi_operand_object     **entry;
+       acpi_namespace_node     *node;
        acpi_operand_object     *object;
 
 
-       FUNCTION_TRACE ("Ds_method_data_get_type");
+       ACPI_FUNCTION_TRACE ("Ds_method_data_get_type");
 
 
-       /* Get a pointer to the requested stack entry */
+       /* Get the namespace node for the arg/local */
 
-       status = acpi_ds_method_data_get_entry (opcode, index, walk_state, &entry);
+       status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node);
        if (ACPI_FAILURE (status)) {
                return_VALUE ((ACPI_TYPE_NOT_FOUND));
        }
 
-       /* Get the object from the method stack */
-
-       object = *entry;
-
-       /* Get the object type */
+       /* Get the object */
 
+       object = acpi_ns_get_attached_object (node);
        if (!object) {
-               /* Any == 0 => "uninitialized" -- see spec 15.2.3.5.2.28 */
-               return_VALUE (ACPI_TYPE_ANY);
-       }
-
-       return_VALUE (object->common.type);
-}
+               /* Uninitialized local/arg, return TYPE_ANY */
 
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ds_method_data_get_node
- *
- * PARAMETERS:  Opcode              - Either AML_LOCAL_OP or AML_ARG_OP
- *              Index               - Which local_var or argument whose type
- *                                      to get
- *              Walk_state          - Current walk state object
- *
- * RETURN:      Get the Node associated with a local or arg.
- *
- ******************************************************************************/
-
-acpi_namespace_node *
-acpi_ds_method_data_get_node (
-       u16                     opcode,
-       u32                     index,
-       acpi_walk_state         *walk_state)
-{
-       acpi_namespace_node     *node = NULL;
-
-
-       FUNCTION_TRACE ("Ds_method_data_get_node");
-
-
-       switch (opcode) {
-
-       case AML_LOCAL_OP:
-
-               if (index > MTH_MAX_LOCAL) {
-                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Local index %d is invalid (max %d)\n",
-                               index, MTH_MAX_LOCAL));
-                       return_PTR (node);
-               }
-
-               node =  &walk_state->local_variables[index];
-               break;
-
-
-       case AML_ARG_OP:
-
-               if (index > MTH_MAX_ARG) {
-                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Arg index %d is invalid (max %d)\n",
-                               index, MTH_MAX_ARG));
-                       return_PTR (node);
-               }
-
-               node = &walk_state->arguments[index];
-               break;
-
-
-       default:
-               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Opcode %d is invalid\n", opcode));
-               break;
+               return_VALUE (ACPI_TYPE_ANY);
        }
 
+       /* Get the object type */
 
-       return_PTR (node);
+       return_VALUE (object->common.type);
 }
 
 
@@ -479,11 +386,11 @@ acpi_ds_method_data_get_value (
        acpi_operand_object     **dest_desc)
 {
        acpi_status             status;
-       acpi_operand_object     **entry;
+       acpi_namespace_node     *node;
        acpi_operand_object     *object;
 
 
-       FUNCTION_TRACE ("Ds_method_data_get_value");
+       ACPI_FUNCTION_TRACE ("Ds_method_data_get_value");
 
 
        /* Validate the object descriptor */
@@ -493,24 +400,22 @@ acpi_ds_method_data_get_value (
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
+       /* Get the namespace node for the arg/local */
 
-       /* Get a pointer to the requested method stack entry */
-
-       status = acpi_ds_method_data_get_entry (opcode, index, walk_state, &entry);
+       status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node);
        if (ACPI_FAILURE (status)) {
                return_ACPI_STATUS (status);
        }
 
-       /* Get the object from the method stack */
-
-       object = *entry;
+       /* Get the object from the node */
 
+       object = node->object;
 
        /* Examine the returned object, it must be valid. */
 
        if (!object) {
                /*
-                * Index points to uninitialized object stack value.
+                * Index points to uninitialized object.
                 * This means that either 1) The expected argument was
                 * not passed to the method, or 2) A local variable
                 * was referenced by the method (via the ASL)
@@ -519,25 +424,22 @@ acpi_ds_method_data_get_value (
                switch (opcode) {
                case AML_ARG_OP:
 
-                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Arg[%d] at entry %p\n",
-                               index, entry));
+                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Arg[%d] at node %p\n",
+                               index, node));
 
                        return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG);
-                       break;
 
                case AML_LOCAL_OP:
 
-                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Local[%d] at entry %p\n",
-                               index, entry));
+                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Local[%d] at node %p\n",
+                               index, node));
 
                        return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL);
-                       break;
                }
        }
 
-
        /*
-        * Index points to initialized and valid object stack value.
+        * The Index points to an initialized and valid object.
         * Return an additional reference to the object
         */
        *dest_desc = object;
@@ -569,37 +471,37 @@ acpi_ds_method_data_delete_value (
        acpi_walk_state         *walk_state)
 {
        acpi_status             status;
-       acpi_operand_object     **entry;
+       acpi_namespace_node     *node;
        acpi_operand_object     *object;
 
 
-       FUNCTION_TRACE ("Ds_method_data_delete_value");
+       ACPI_FUNCTION_TRACE ("Ds_method_data_delete_value");
 
 
-       /* Get a pointer to the requested entry */
+       /* Get the namespace node for the arg/local */
 
-       status = acpi_ds_method_data_get_entry (opcode, index, walk_state, &entry);
+       status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node);
        if (ACPI_FAILURE (status)) {
                return_ACPI_STATUS (status);
        }
 
-       /* Get the current entry in this slot k */
+       /* Get the associated object */
 
-       object = *entry;
+       object = acpi_ns_get_attached_object (node);
 
        /*
         * Undefine the Arg or Local by setting its descriptor
         * pointer to NULL. Locals/Args can contain both
         * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs
         */
-       *entry = NULL;
+       node->object = NULL;
 
        if ((object) &&
-               (VALID_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_INTERNAL))) {
+               (ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_INTERNAL)) {
                /*
-                * There is a valid object in this slot
+                * There is a valid object.
                 * Decrement the reference count by one to balance the
-                * increment when the object was stored in the slot.
+                * increment when the object was stored.
                 */
                acpi_ut_remove_reference (object);
        }
@@ -614,14 +516,14 @@ acpi_ds_method_data_delete_value (
  *
  * PARAMETERS:  Opcode              - Either AML_LOCAL_OP or AML_ARG_OP
  *              Index               - Which local_var or argument to set
- *              Src_desc            - Value to be stored
+ *              Obj_desc            - Value to be stored
  *              Walk_state          - Current walk state
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Store a value in an Arg or Local.  The Src_desc is installed
+ * DESCRIPTION: Store a value in an Arg or Local.  The Obj_desc is installed
  *              as the new value for the Arg or Local and the reference count
- *              for Src_desc is incremented.
+ *              for Obj_desc is incremented.
  *
  ******************************************************************************/
 
@@ -629,45 +531,45 @@ acpi_status
 acpi_ds_store_object_to_local (
        u16                     opcode,
        u32                     index,
-       acpi_operand_object     *src_desc,
+       acpi_operand_object     *obj_desc,
        acpi_walk_state         *walk_state)
 {
        acpi_status             status;
-       acpi_operand_object     **entry;
+       acpi_namespace_node     *node;
+       acpi_operand_object     *current_obj_desc;
 
 
-       FUNCTION_TRACE ("Ds_method_data_set_value");
+       ACPI_FUNCTION_TRACE ("Ds_store_object_to_local");
        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode=%d Idx=%d Obj=%p\n",
-               opcode, index, src_desc));
+               opcode, index, obj_desc));
 
 
        /* Parameter validation */
 
-       if (!src_desc) {
+       if (!obj_desc) {
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
+       /* Get the namespace node for the arg/local */
 
-       /* Get a pointer to the requested method stack entry */
-
-       status = acpi_ds_method_data_get_entry (opcode, index, walk_state, &entry);
+       status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node);
        if (ACPI_FAILURE (status)) {
-               goto cleanup;
+               return_ACPI_STATUS (status);
        }
 
-       if (*entry == src_desc) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n", src_desc));
-               goto cleanup;
+       current_obj_desc = acpi_ns_get_attached_object (node);
+       if (current_obj_desc == obj_desc) {
+               ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n", obj_desc));
+               return_ACPI_STATUS (status);
        }
 
-
        /*
         * If there is an object already in this slot, we either
         * have to delete it, or if this is an argument and there
         * is an object reference stored there, we have to do
         * an indirect store!
         */
-       if (*entry) {
+       if (current_obj_desc) {
                /*
                 * Check for an indirect store if an argument
                 * contains an object reference (stored as an Node).
@@ -685,36 +587,24 @@ acpi_ds_store_object_to_local (
                 * Weird, but true.
                 */
                if ((opcode == AML_ARG_OP) &&
-                       (VALID_DESCRIPTOR_TYPE (*entry, ACPI_DESC_TYPE_NAMED))) {
+                       (ACPI_GET_DESCRIPTOR_TYPE (current_obj_desc) == ACPI_DESC_TYPE_NAMED)) {
                        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
-                               "Arg (%p) is an Obj_ref(Node), storing in %p\n",
-                               src_desc, *entry));
+                               "Arg (%p) is an Obj_ref(Node), storing in node %p\n",
+                               obj_desc, current_obj_desc));
 
                        /* Detach an existing object from the Node */
 
-                       acpi_ns_detach_object ((acpi_namespace_node *) *entry);
+                       acpi_ns_detach_object ((acpi_namespace_node *) current_obj_desc);
 
                        /*
                         * Store this object into the Node
-                        * (do the indirect store)
+                        * (perform the indirect store)
                         */
-                       status = acpi_ns_attach_object ((acpi_namespace_node *) *entry, src_desc,
-                                          src_desc->common.type);
+                       status = acpi_ns_attach_object ((acpi_namespace_node *) current_obj_desc,
+                                         obj_desc, obj_desc->common.type);
                        return_ACPI_STATUS (status);
                }
 
-
-#ifdef ACPI_ENABLE_IMPLICIT_CONVERSION
-               /*
-                * Perform "Implicit conversion" of the new object to the type of the
-                * existing object
-                */
-               status = acpi_ex_convert_to_target_type ((*entry)->common.type, &src_desc, walk_state);
-               if (ACPI_FAILURE (status)) {
-                       goto cleanup;
-               }
-#endif
-
                /*
                 * Delete the existing object
                 * before storing the new one
@@ -722,27 +612,14 @@ acpi_ds_store_object_to_local (
                acpi_ds_method_data_delete_value (opcode, index, walk_state);
        }
 
-
        /*
-        * Install the Obj_stack descriptor (*Src_desc) into
+        * Install the Obj_stack descriptor (*Obj_desc) into
         * the descriptor for the Arg or Local.
         * Install the new object in the stack entry
         * (increments the object reference count by one)
         */
-       status = acpi_ds_method_data_set_entry (opcode, index, src_desc, walk_state);
-       if (ACPI_FAILURE (status)) {
-               goto cleanup;
-       }
-
-       /* Normal exit */
-
-       return_ACPI_STATUS (AE_OK);
-
-
-       /* Error exit */
-
-cleanup:
-
+       status = acpi_ds_method_data_set_value (opcode, index, obj_desc, walk_state);
        return_ACPI_STATUS (status);
 }
 
+
index 2ef0daaf55ecd9e59b6e9722e3fc7e1c8758b0d2..bd70daff9b13f2323c4e5f17ff0c4b1294924b34 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: dsobject - Dispatcher object management routines
- *              $Revision: 81 $
+ *              $Revision: 90 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -32,7 +32,7 @@
 #include "acnamesp.h"
 
 #define _COMPONENT          ACPI_DISPATCHER
-        MODULE_NAME         ("dsobject")
+        ACPI_MODULE_NAME    ("dsobject")
 
 
 /*******************************************************************************
@@ -62,13 +62,13 @@ acpi_ds_init_one_object (
        void                    *context,
        void                    **return_value)
 {
-       acpi_object_type8       type;
+       acpi_object_type        type;
        acpi_status             status;
        acpi_init_walk_info     *info = (acpi_init_walk_info *) context;
        u8                      table_revision;
 
 
-       PROC_NAME ("Ds_init_one_object");
+       ACPI_FUNCTION_NAME ("Ds_init_one_object");
 
 
        info->object_count++;
@@ -89,7 +89,6 @@ acpi_ds_init_one_object (
        type = acpi_ns_get_type (obj_handle);
 
        switch (type) {
-
        case ACPI_TYPE_REGION:
 
                acpi_ds_initialize_region (obj_handle);
@@ -121,7 +120,7 @@ acpi_ds_init_one_object (
                status = acpi_ds_parse_method (obj_handle);
                if (ACPI_FAILURE (status)) {
                        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Method %p [%4.4s] - parse failure, %s\n",
-                               obj_handle, (char*)&((acpi_namespace_node *)obj_handle)->name,
+                               obj_handle, (char *) &((acpi_namespace_node *) obj_handle)->name,
                                acpi_format_exception (status)));
 
                        /* This parse failed, but we will continue parsing more methods */
@@ -134,6 +133,7 @@ acpi_ds_init_one_object (
                 * for every execution since there isn't much overhead
                 */
                acpi_ns_delete_namespace_subtree (obj_handle);
+               acpi_ns_delete_namespace_by_owner (((acpi_namespace_node *) obj_handle)->object->method.owning_id);
                break;
 
        default:
@@ -170,7 +170,7 @@ acpi_ds_initialize_objects (
        acpi_init_walk_info     info;
 
 
-       FUNCTION_TRACE ("Ds_initialize_objects");
+       ACPI_FUNCTION_TRACE ("Ds_initialize_objects");
 
 
        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
@@ -235,7 +235,7 @@ acpi_ds_init_object_from_op (
        acpi_operand_object     *obj_desc;
 
 
-       PROC_NAME ("Ds_init_object_from_op");
+       ACPI_FUNCTION_NAME ("Ds_init_object_from_op");
 
 
        obj_desc = *ret_obj_desc;
@@ -252,6 +252,8 @@ acpi_ds_init_object_from_op (
        switch (obj_desc->common.type) {
        case ACPI_TYPE_BUFFER:
 
+               obj_desc->buffer.node = (acpi_namespace_node *) walk_state->operands[0];
+
                /* First arg is a number */
 
                acpi_ds_create_operand (walk_state, op->value.arg, 0);
@@ -285,7 +287,7 @@ acpi_ds_init_object_from_op (
 
                if (obj_desc->buffer.length == 0) {
                        obj_desc->buffer.pointer = NULL;
-                       REPORT_WARNING (("Buffer created with zero length in AML\n"));
+                       ACPI_REPORT_WARNING (("Buffer created with zero length in AML\n"));
                        break;
                }
 
@@ -312,8 +314,8 @@ acpi_ds_init_object_from_op (
                                return (AE_TYPE);
                        }
 
-                       MEMCPY (obj_desc->buffer.pointer, byte_list->data,
-                                       obj_desc->buffer.length);
+                       ACPI_MEMCPY (obj_desc->buffer.pointer, byte_list->data,
+                                         obj_desc->buffer.length);
                }
 
                break;
@@ -339,7 +341,7 @@ acpi_ds_init_object_from_op (
 
        case ACPI_TYPE_STRING:
                obj_desc->string.pointer = op->value.string;
-               obj_desc->string.length = STRLEN (op->value.string);
+               obj_desc->string.length = ACPI_STRLEN (op->value.string);
 
                /*
                 * The string is contained in the ACPI table, don't ever try
@@ -422,42 +424,38 @@ acpi_ds_build_internal_simple_obj (
        acpi_operand_object     **obj_desc_ptr)
 {
        acpi_operand_object     *obj_desc;
-       acpi_object_type8       type;
        acpi_status             status;
-       u32                     length;
        char                    *name;
 
 
-       FUNCTION_TRACE ("Ds_build_internal_simple_obj");
+       ACPI_FUNCTION_TRACE ("Ds_build_internal_simple_obj");
 
 
        if (op->opcode == AML_INT_NAMEPATH_OP) {
                /*
-                * This is an object reference.  If The name was
-                * previously looked up in the NS, it is stored in this op.
+                * This is an object reference.  If this name was
+                * previously looked up in the namespace, it was stored in this op.
                 * Otherwise, go ahead and look it up now
                 */
                if (!op->node) {
-                       status = acpi_ns_lookup (walk_state->scope_info,
-                                         op->value.string, ACPI_TYPE_ANY,
-                                         IMODE_EXECUTE,
-                                         NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE,
-                                         NULL,
-                                         (acpi_namespace_node **)&(op->node));
+                       status = acpi_ns_lookup (walk_state->scope_info, op->value.string,
+                                         ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
+                                         ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL,
+                                         (acpi_namespace_node **) &(op->node));
 
                        if (ACPI_FAILURE (status)) {
                                if (status == AE_NOT_FOUND) {
                                        name = NULL;
-                                       acpi_ns_externalize_name (ACPI_UINT32_MAX, op->value.string, &length, &name);
+                                       acpi_ns_externalize_name (ACPI_UINT32_MAX, op->value.string, NULL, &name);
 
                                        if (name) {
-                                               REPORT_WARNING (("Reference %s at AML %X not found\n",
+                                               ACPI_REPORT_WARNING (("Reference %s at AML %X not found\n",
                                                                 name, op->aml_offset));
                                                ACPI_MEM_FREE (name);
                                        }
 
                                        else {
-                                               REPORT_WARNING (("Reference %s at AML %X not found\n",
+                                               ACPI_REPORT_WARNING (("Reference %s at AML %X not found\n",
                                                                   op->value.string, op->aml_offset));
                                        }
 
@@ -469,23 +467,11 @@ acpi_ds_build_internal_simple_obj (
                                }
                        }
                }
-
-               /*
-                * The reference will be a Reference
-                * TBD: [Restructure] unless we really need a separate
-                *  type of INTERNAL_TYPE_REFERENCE change
-                *  Acpi_ds_map_opcode_to_data_type to handle this case
-                */
-               type = INTERNAL_TYPE_REFERENCE;
-       }
-       else {
-               type = acpi_ds_map_opcode_to_data_type (op->opcode, NULL);
        }
 
-
        /* Create and init the internal ACPI object */
 
-       obj_desc = acpi_ut_create_internal_object (type);
+       obj_desc = acpi_ut_create_internal_object ((acpi_ps_get_opcode_info (op->opcode))->object_type);
        if (!obj_desc) {
                return_ACPI_STATUS (AE_NO_MEMORY);
        }
@@ -527,7 +513,7 @@ acpi_ds_build_internal_package_obj (
        acpi_status             status = AE_OK;
 
 
-       FUNCTION_TRACE ("Ds_build_internal_package_obj");
+       ACPI_FUNCTION_TRACE ("Ds_build_internal_package_obj");
 
 
        obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_PACKAGE);
@@ -651,7 +637,7 @@ acpi_ds_create_node (
        acpi_operand_object     *obj_desc;
 
 
-       FUNCTION_TRACE_PTR ("Ds_create_node", op);
+       ACPI_FUNCTION_TRACE_PTR ("Ds_create_node", op);
 
 
        /*
@@ -659,7 +645,7 @@ acpi_ds_create_node (
         * parts of the table, we can arrive here twice.  Only init
         * the named object node the first time through
         */
-       if (node->object) {
+       if (acpi_ns_get_attached_object (node)) {
                return_ACPI_STATUS (AE_OK);
        }
 
@@ -682,7 +668,7 @@ acpi_ds_create_node (
 
        /* Init obj */
 
-       status = acpi_ns_attach_object (node, obj_desc, (u8) node->type);
+       status = acpi_ns_attach_object (node, obj_desc, node->type);
 
        /* Remove local reference to the object */
 
index 32b78aefc8f62729b62d73a8eb703f32dd712c1a..24b24b8da684a3f7f7ef28eda71fd82c96b5e44a 100644 (file)
@@ -2,12 +2,12 @@
  *
  * Module Name: dsopcode - Dispatcher Op Region support and handling of
  *                         "control" opcodes
- *              $Revision: 56 $
+ *              $Revision: 73 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 #include "actables.h"
 
 #define _COMPONENT          ACPI_DISPATCHER
-        MODULE_NAME         ("dsopcode")
+        ACPI_MODULE_NAME    ("dsopcode")
 
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ds_get_buffer_field_arguments
+ * FUNCTION:    Acpi_ds_execute_arguments
  *
- * PARAMETERS:  Obj_desc        - A valid Buffer_field object
+ * PARAMETERS:  Node                - Parent NS node
+ *              Extra_desc          - Has AML pointer and length
  *
  * RETURN:      Status.
  *
- * DESCRIPTION: Get Buffer_field Buffer and Index. This implements the late
- *              evaluation of these field attributes.
+ * DESCRIPTION: Late execution of region or field arguments
  *
  ****************************************************************************/
 
 acpi_status
-acpi_ds_get_buffer_field_arguments (
-       acpi_operand_object     *obj_desc)
+acpi_ds_execute_arguments (
+       acpi_namespace_node     *node,
+       acpi_operand_object     *extra_desc)
 {
-       acpi_operand_object     *extra_desc;
-       acpi_namespace_node     *node;
-       acpi_parse_object       *op;
-       acpi_parse_object       *field_op;
        acpi_status             status;
-       acpi_table_desc         *table_desc;
+       acpi_parse_object       *op;
        acpi_walk_state         *walk_state;
+       acpi_parse_object       *arg;
 
 
-       FUNCTION_TRACE_PTR ("Ds_get_buffer_field_arguments", obj_desc);
-
-
-       if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
-               return_ACPI_STATUS (AE_OK);
-       }
-
-
-       /* Get the AML pointer (method object) and Buffer_field node */
-
-       extra_desc = obj_desc->buffer_field.extra;
-       node = obj_desc->buffer_field.node;
-
-       DEBUG_EXEC(acpi_ut_display_init_pathname (node, " [Field]"));
-       ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] Buffer_field JIT Init\n",
-               (char*)&node->name));
+       ACPI_FUNCTION_TRACE ("Acpi_ds_execute_arguments");
 
 
        /*
         * Allocate a new parser op to be the root of the parsed
-        * Op_region tree
+        * Buffer_field tree
         */
        op = acpi_ps_alloc_op (AML_SCOPE_OP);
        if (!op) {
-               return (AE_NO_MEMORY);
+               return_ACPI_STATUS (AE_NO_MEMORY);
        }
 
        /* Save the Node for use in Acpi_ps_parse_aml */
 
-       op->node = acpi_ns_get_parent_object (node);
-
-       /* Get a handle to the parent ACPI table */
-
-       status = acpi_tb_handle_to_object (node->owner_id, &table_desc);
-       if (ACPI_FAILURE (status)) {
-               return_ACPI_STATUS (status);
-       }
+       op->node = acpi_ns_get_parent_node (node);
 
        /* Create and initialize a new parser state */
 
-       walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT,
-                          NULL, NULL, NULL);
+       walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT, NULL, NULL, NULL);
        if (!walk_state) {
                return_ACPI_STATUS (AE_NO_MEMORY);
        }
@@ -113,12 +88,10 @@ acpi_ds_get_buffer_field_arguments (
        status = acpi_ds_init_aml_walk (walk_state, op, NULL, extra_desc->extra.aml_start,
                          extra_desc->extra.aml_length, NULL, NULL, 1);
        if (ACPI_FAILURE (status)) {
-               /* TBD: delete walk state */
+               acpi_ds_delete_walk_state (walk_state);
                return_ACPI_STATUS (status);
        }
 
-       /* TBD: No Walk flags?? */
-
        walk_state->parse_flags = 0;
 
        /* Pass1: Parse the entire Buffer_field declaration */
@@ -131,27 +104,23 @@ acpi_ds_get_buffer_field_arguments (
 
        /* Get and init the actual Field_unit Op created above */
 
-       field_op = op->value.arg;
+       arg = op->value.arg;
        op->node = node;
-
-
-       field_op = op->value.arg;
-       field_op->node = node;
+       arg->node = node;
        acpi_ps_delete_parse_tree (op);
 
-       /* Evaluate the address and length arguments for the Op_region */
+       /* Evaluate the address and length arguments for the Buffer Field */
 
        op = acpi_ps_alloc_op (AML_SCOPE_OP);
        if (!op) {
-               return (AE_NO_MEMORY);
+               return_ACPI_STATUS (AE_NO_MEMORY);
        }
 
-       op->node = acpi_ns_get_parent_object (node);
+       op->node = acpi_ns_get_parent_node (node);
 
        /* Create and initialize a new parser state */
 
-       walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT,
-                          NULL, NULL, NULL);
+       walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT, NULL, NULL, NULL);
        if (!walk_state) {
                return_ACPI_STATUS (AE_NO_MEMORY);
        }
@@ -159,152 +128,106 @@ acpi_ds_get_buffer_field_arguments (
        status = acpi_ds_init_aml_walk (walk_state, op, NULL, extra_desc->extra.aml_start,
                          extra_desc->extra.aml_length, NULL, NULL, 3);
        if (ACPI_FAILURE (status)) {
-               /* TBD: delete walk state */
+               acpi_ds_delete_walk_state (walk_state);
                return_ACPI_STATUS (status);
        }
 
        status = acpi_ps_parse_aml (walk_state);
        acpi_ps_delete_parse_tree (op);
-
-       /*
-        * The pseudo-method object is no longer needed since the region is
-        * now initialized
-        */
-       acpi_ut_remove_reference (obj_desc->buffer_field.extra);
-       obj_desc->buffer_field.extra = NULL;
-
        return_ACPI_STATUS (status);
 }
 
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ds_get_region_arguments
+ * FUNCTION:    Acpi_ds_get_buffer_field_arguments
  *
- * PARAMETERS:  Obj_desc        - A valid region object
+ * PARAMETERS:  Obj_desc        - A valid Buffer_field object
  *
  * RETURN:      Status.
  *
- * DESCRIPTION: Get region address and length.  This implements the late
- *              evaluation of these region attributes.
+ * DESCRIPTION: Get Buffer_field Buffer and Index. This implements the late
+ *              evaluation of these field attributes.
  *
  ****************************************************************************/
 
 acpi_status
-acpi_ds_get_region_arguments (
+acpi_ds_get_buffer_field_arguments (
        acpi_operand_object     *obj_desc)
 {
-       acpi_operand_object     *extra_desc = NULL;
+       acpi_operand_object     *extra_desc;
        acpi_namespace_node     *node;
-       acpi_parse_object       *op;
-       acpi_parse_object       *region_op;
        acpi_status             status;
-       acpi_table_desc         *table_desc;
-       acpi_walk_state         *walk_state;
 
 
-       FUNCTION_TRACE_PTR ("Ds_get_region_arguments", obj_desc);
+       ACPI_FUNCTION_TRACE_PTR ("Ds_get_buffer_field_arguments", obj_desc);
 
 
-       if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
+       if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
                return_ACPI_STATUS (AE_OK);
        }
 
+       /* Get the AML pointer (method object) and Buffer_field node */
 
-       /* Get the AML pointer (method object) and region node */
-
-       extra_desc = obj_desc->region.extra;
-       node = obj_desc->region.node;
-
-       DEBUG_EXEC(acpi_ut_display_init_pathname (node, " [Operation Region]"));
-
-       ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] Op_region Init at AML %p\n",
-               (char*)&node->name, extra_desc->extra.aml_start));
-
-       /*
-        * Allocate a new parser op to be the root of the parsed
-        * Op_region tree
-        */
-       op = acpi_ps_alloc_op (AML_SCOPE_OP);
-       if (!op) {
-               return (AE_NO_MEMORY);
-       }
-
-       /* Save the Node for use in Acpi_ps_parse_aml */
+       extra_desc = acpi_ns_get_secondary_object (obj_desc);
+       node = obj_desc->buffer_field.node;
 
-       op->node = acpi_ns_get_parent_object (node);
+       ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname (node, " [Field]"));
+       ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] Buffer_field JIT Init\n",
+               (char *) &node->name));
 
-       /* Get a handle to the parent ACPI table */
+       /* Execute the AML code for the Term_arg arguments */
 
-       status = acpi_tb_handle_to_object (node->owner_id, &table_desc);
-       if (ACPI_FAILURE (status)) {
-               return_ACPI_STATUS (status);
-       }
+       status = acpi_ds_execute_arguments (node, extra_desc);
+       return_ACPI_STATUS (status);
+}
 
-       /* Create and initialize a new parser state */
 
-       walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT,
-                          op, NULL, NULL);
-       if (!walk_state) {
-               return_ACPI_STATUS (AE_NO_MEMORY);
-       }
+/*****************************************************************************
+ *
+ * FUNCTION:    Acpi_ds_get_region_arguments
+ *
+ * PARAMETERS:  Obj_desc        - A valid region object
+ *
+ * RETURN:      Status.
+ *
+ * DESCRIPTION: Get region address and length.  This implements the late
+ *              evaluation of these region attributes.
+ *
+ ****************************************************************************/
 
-       status = acpi_ds_init_aml_walk (walk_state, op, NULL, extra_desc->extra.aml_start,
-                         extra_desc->extra.aml_length, NULL, NULL, 1);
-       if (ACPI_FAILURE (status)) {
-               /* TBD: delete walk state */
-               return_ACPI_STATUS (status);
-       }
+acpi_status
+acpi_ds_get_region_arguments (
+       acpi_operand_object     *obj_desc)
+{
+       acpi_namespace_node     *node;
+       acpi_status             status;
+       acpi_operand_object     *region_obj2;
 
-       /* TBD: No Walk flags?? */
 
-       walk_state->parse_flags = 0;
+       ACPI_FUNCTION_TRACE_PTR ("Ds_get_region_arguments", obj_desc);
 
-       /* Parse the entire Op_region declaration, creating a parse tree */
 
-       status = acpi_ps_parse_aml (walk_state);
-       if (ACPI_FAILURE (status)) {
-               acpi_ps_delete_parse_tree (op);
-               return_ACPI_STATUS (status);
+       if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
+               return_ACPI_STATUS (AE_OK);
        }
 
-       /* Get and init the actual Region_op created above */
-
-       region_op = op->value.arg;
-       op->node = node;
-
-
-       region_op = op->value.arg;
-       region_op->node = node;
-       acpi_ps_delete_parse_tree (op);
-
-       /* Evaluate the address and length arguments for the Op_region */
-
-       op = acpi_ps_alloc_op (AML_SCOPE_OP);
-       if (!op) {
-               return (AE_NO_MEMORY);
+       region_obj2 = acpi_ns_get_secondary_object (obj_desc);
+       if (!region_obj2) {
+               return_ACPI_STATUS (AE_NOT_EXIST);
        }
 
-       op->node = acpi_ns_get_parent_object (node);
+       /* Get the AML pointer (method object) and region node */
 
-       /* Create and initialize a new parser state */
+       node = obj_desc->region.node;
 
-       walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT,
-                          op, NULL, NULL);
-       if (!walk_state) {
-               return_ACPI_STATUS (AE_NO_MEMORY);
-       }
+       ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname (node, " [Operation Region]"));
 
-       status = acpi_ds_init_aml_walk (walk_state, op, NULL, extra_desc->extra.aml_start,
-                         extra_desc->extra.aml_length, NULL, NULL, 3);
-       if (ACPI_FAILURE (status)) {
-               /* TBD: delete walk state */
-               return_ACPI_STATUS (status);
-       }
+       ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] Op_region Init at AML %p\n",
+               (char *) &node->name, region_obj2->extra.aml_start));
 
-       status = acpi_ps_parse_aml (walk_state);
-       acpi_ps_delete_parse_tree (op);
 
+       status = acpi_ds_execute_arguments (node, region_obj2);
        return_ACPI_STATUS (status);
 }
 
@@ -334,7 +257,6 @@ acpi_ds_initialize_region (
        /* Namespace is NOT locked */
 
        status = acpi_ev_initialize_region (obj_desc, FALSE);
-
        return (status);
 }
 
@@ -350,21 +272,6 @@ acpi_ds_initialize_region (
  * DESCRIPTION: Get Buffer_field Buffer and Index
  *              Called from Acpi_ds_exec_end_op during Buffer_field parse tree walk
  *
- * ACPI SPECIFICATION REFERENCES:
- *  Each of the Buffer Field opcodes is defined as specified in in-line
- *  comments below. For each one, use the following definitions.
- *
- *  Def_bit_field   :=  Bit_field_op    Src_buf Bit_idx Destination
- *  Def_byte_field  :=  Byte_field_op   Src_buf Byte_idx Destination
- *  Def_create_field := Create_field_op Src_buf Bit_idx Num_bits Name_string
- *  Def_dWord_field :=  DWord_field_op  Src_buf Byte_idx Destination
- *  Def_word_field  :=  Word_field_op   Src_buf Byte_idx Destination
- *  Bit_index       :=  Term_arg=>Integer
- *  Byte_index      :=  Term_arg=>Integer
- *  Destination     :=  Name_string
- *  Num_bits        :=  Term_arg=>Integer
- *  Source_buf      :=  Term_arg=>Buffer
- *
  ****************************************************************************/
 
 acpi_status
@@ -386,7 +293,7 @@ acpi_ds_eval_buffer_field_operands (
        acpi_operand_object     *src_desc = NULL;
 
 
-       FUNCTION_TRACE_PTR ("Ds_eval_buffer_field_operands", op);
+       ACPI_FUNCTION_TRACE_PTR ("Ds_eval_buffer_field_operands", op);
 
 
        /*
@@ -411,11 +318,10 @@ acpi_ds_eval_buffer_field_operands (
                return_ACPI_STATUS (AE_NOT_EXIST);
        }
 
-
        /* Resolve the operands */
 
-       status = acpi_ex_resolve_operands (op->opcode, WALK_OPERANDS, walk_state);
-       DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, acpi_ps_get_opcode_name (op->opcode),
+       status = acpi_ex_resolve_operands (op->opcode, ACPI_WALK_OPERANDS, walk_state);
+       ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, acpi_ps_get_opcode_name (op->opcode),
                          walk_state->num_operands, "after Acpi_ex_resolve_operands");
 
        if (ACPI_FAILURE (status)) {
@@ -437,16 +343,14 @@ acpi_ds_eval_buffer_field_operands (
 
        off_desc = walk_state->operands[1];
        src_desc = walk_state->operands[0];
-
-
-       offset = (u32) off_desc->integer.value;
+       offset  = (u32) off_desc->integer.value;
 
        /*
         * If Res_desc is a Name, it will be a direct name pointer after
         * Acpi_ex_resolve_operands()
         */
-       if (!VALID_DESCRIPTOR_TYPE (res_desc, ACPI_DESC_TYPE_NAMED)) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) destination must be a Node\n",
+       if (ACPI_GET_DESCRIPTOR_TYPE (res_desc) != ACPI_DESC_TYPE_NAMED) {
+               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) destination must be a NS Node\n",
                        acpi_ps_get_opcode_name (op->opcode)));
 
                status = AE_AML_OPERAND_TYPE;
@@ -457,79 +361,60 @@ acpi_ds_eval_buffer_field_operands (
         * Setup the Bit offsets and counts, according to the opcode
         */
        switch (op->opcode) {
-
-       /* Def_create_field */
-
        case AML_CREATE_FIELD_OP:
 
                /* Offset is in bits, count is in bits */
 
                bit_offset  = offset;
                bit_count   = (u32) cnt_desc->integer.value;
-               field_flags = ACCESS_BYTE_ACC;
+               field_flags = AML_FIELD_ACCESS_BYTE;
                break;
 
-
-       /* Def_create_bit_field */
-
        case AML_CREATE_BIT_FIELD_OP:
 
                /* Offset is in bits, Field is one bit */
 
                bit_offset  = offset;
                bit_count   = 1;
-               field_flags = ACCESS_BYTE_ACC;
+               field_flags = AML_FIELD_ACCESS_BYTE;
                break;
 
-
-       /* Def_create_byte_field */
-
        case AML_CREATE_BYTE_FIELD_OP:
 
                /* Offset is in bytes, field is one byte */
 
                bit_offset  = 8 * offset;
                bit_count   = 8;
-               field_flags = ACCESS_BYTE_ACC;
+               field_flags = AML_FIELD_ACCESS_BYTE;
                break;
 
-
-       /* Def_create_word_field */
-
        case AML_CREATE_WORD_FIELD_OP:
 
                /* Offset is in bytes, field is one word */
 
                bit_offset  = 8 * offset;
                bit_count   = 16;
-               field_flags = ACCESS_WORD_ACC;
+               field_flags = AML_FIELD_ACCESS_WORD;
                break;
 
-
-       /* Def_create_dWord_field */
-
        case AML_CREATE_DWORD_FIELD_OP:
 
                /* Offset is in bytes, field is one dword */
 
                bit_offset  = 8 * offset;
                bit_count   = 32;
-               field_flags = ACCESS_DWORD_ACC;
+               field_flags = AML_FIELD_ACCESS_DWORD;
                break;
 
-
-       /* Def_create_qWord_field */
-
        case AML_CREATE_QWORD_FIELD_OP:
 
                /* Offset is in bytes, field is one qword */
 
                bit_offset  = 8 * offset;
                bit_count   = 64;
-               field_flags = ACCESS_QWORD_ACC;
+               field_flags = AML_FIELD_ACCESS_QWORD;
                break;
 
-
        default:
 
                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
@@ -539,7 +424,6 @@ acpi_ds_eval_buffer_field_operands (
                goto cleanup;
        }
 
-
        /*
         * Setup field according to the object type
         */
@@ -558,12 +442,11 @@ acpi_ds_eval_buffer_field_operands (
                        goto cleanup;
                }
 
-
                /*
                 * Initialize areas of the field object that are common to all fields
                 * For Field_flags, use LOCK_RULE = 0 (NO_LOCK), UPDATE_RULE = 0 (UPDATE_PRESERVE)
                 */
-               status = acpi_ex_prep_common_field_object (obj_desc, field_flags,
+               status = acpi_ex_prep_common_field_object (obj_desc, field_flags, 0,
                                  bit_offset, bit_count);
                if (ACPI_FAILURE (status)) {
                        return_ACPI_STATUS (status);
@@ -575,7 +458,6 @@ acpi_ds_eval_buffer_field_operands (
 
                src_desc->common.reference_count = (u16) (src_desc->common.reference_count +
                                  obj_desc->common.reference_count);
-
                break;
 
 
@@ -583,12 +465,11 @@ acpi_ds_eval_buffer_field_operands (
 
        default:
 
-               if ((src_desc->common.type > (u8) INTERNAL_TYPE_REFERENCE) || !acpi_ut_valid_object_type (src_desc->common.type)) /* TBD: This line MUST be a single line until Acpi_src can handle it (block deletion) */ {
+               if ((src_desc->common.type > (u8) INTERNAL_TYPE_REFERENCE) || !acpi_ut_valid_object_type (src_desc->common.type)) /* This line MUST be a single line until Acpi_src can handle it (block deletion) */ {
                        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
                                "Tried to create field in invalid object type %X\n",
                                src_desc->common.type));
                }
-
                else {
                        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
                                "Tried to create field in improper object type - %s\n",
@@ -624,7 +505,6 @@ cleanup:
        if (ACPI_FAILURE (status)) {
                acpi_ut_remove_reference (res_desc); /* Result descriptor */
        }
-
        else {
                /* Now the address and length are valid for this Buffer_field */
 
@@ -660,7 +540,7 @@ acpi_ds_eval_region_operands (
        acpi_parse_object       *next_op;
 
 
-       FUNCTION_TRACE_PTR ("Ds_eval_region_operands", op);
+       ACPI_FUNCTION_TRACE_PTR ("Ds_eval_region_operands", op);
 
 
        /*
@@ -685,16 +565,15 @@ acpi_ds_eval_region_operands (
 
        /* Resolve the length and address operands to numbers */
 
-       status = acpi_ex_resolve_operands (op->opcode, WALK_OPERANDS, walk_state);
+       status = acpi_ex_resolve_operands (op->opcode, ACPI_WALK_OPERANDS, walk_state);
        if (ACPI_FAILURE (status)) {
                return_ACPI_STATUS (status);
        }
 
-       DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE,
+       ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
                          acpi_ps_get_opcode_name (op->opcode),
                          1, "after Acpi_ex_resolve_operands");
 
-
        obj_desc = acpi_ns_get_attached_object (node);
        if (!obj_desc) {
                return_ACPI_STATUS (AE_NOT_EXIST);
@@ -718,9 +597,9 @@ acpi_ds_eval_region_operands (
        obj_desc->region.address = (ACPI_PHYSICAL_ADDRESS) operand_desc->integer.value;
        acpi_ut_remove_reference (operand_desc);
 
-
        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Rgn_obj %p Addr %8.8X%8.8X Len %X\n",
-               obj_desc, HIDWORD(obj_desc->region.address), LODWORD(obj_desc->region.address),
+               obj_desc,
+               ACPI_HIDWORD (obj_desc->region.address), ACPI_LODWORD (obj_desc->region.address),
                obj_desc->region.length));
 
        /* Now the address and length are valid for this opregion */
@@ -754,7 +633,7 @@ acpi_ds_exec_begin_control_op (
        acpi_generic_state      *control_state;
 
 
-       PROC_NAME ("Ds_exec_begin_control_op");
+       ACPI_FUNCTION_NAME ("Ds_exec_begin_control_op");
 
 
        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", op,
@@ -774,20 +653,20 @@ acpi_ds_exec_begin_control_op (
                        status = AE_NO_MEMORY;
                        break;
                }
-
-               acpi_ut_push_generic_state (&walk_state->control_state, control_state);
-
                /*
                 * Save a pointer to the predicate for multiple executions
                 * of a loop
                 */
-               walk_state->control_state->control.aml_predicate_start =
-                                walk_state->parser_state.aml - 1;
-                                /* TBD: can this be removed? */
-                                /*Acpi_ps_pkg_length_encoding_size (GET8 (Walk_state->Parser_state->Aml));*/
-               break;
+               control_state->control.aml_predicate_start = walk_state->parser_state.aml - 1;
+               control_state->control.package_end = walk_state->parser_state.pkg_end;
+               control_state->control.opcode = op->opcode;
 
 
+               /* Push the control state on this walk's control stack */
+
+               acpi_ut_push_generic_state (&walk_state->control_state, control_state);
+               break;
+
        case AML_ELSE_OP:
 
                /* Predicate is in the state object */
@@ -799,12 +678,10 @@ acpi_ds_exec_begin_control_op (
 
                break;
 
-
        case AML_RETURN_OP:
 
                break;
 
-
        default:
                break;
        }
@@ -825,7 +702,6 @@ acpi_ds_exec_begin_control_op (
  * DESCRIPTION: Handles all control ops encountered during control method
  *              execution.
  *
- *
  ******************************************************************************/
 
 acpi_status
@@ -837,7 +713,7 @@ acpi_ds_exec_end_control_op (
        acpi_generic_state      *control_state;
 
 
-       PROC_NAME ("Ds_exec_end_control_op");
+       ACPI_FUNCTION_NAME ("Ds_exec_end_control_op");
 
 
        switch (op->opcode) {
@@ -922,7 +798,6 @@ acpi_ds_exec_end_control_op (
                         */
                        walk_state->return_desc = walk_state->operands[0];
                }
-
                else if ((walk_state->results) &&
                                 (walk_state->results->results.num_results > 0)) {
                        /*
@@ -934,18 +809,17 @@ acpi_ds_exec_end_control_op (
                         *
                         * Allow references created by the Index operator to return unchanged.
                         */
-                       if (VALID_DESCRIPTOR_TYPE (walk_state->results->results.obj_desc [0], ACPI_DESC_TYPE_INTERNAL) &&
+                       if ((ACPI_GET_DESCRIPTOR_TYPE (walk_state->results->results.obj_desc[0]) == ACPI_DESC_TYPE_INTERNAL) &&
                                ((walk_state->results->results.obj_desc [0])->common.type == INTERNAL_TYPE_REFERENCE) &&
                                ((walk_state->results->results.obj_desc [0])->reference.opcode != AML_INDEX_OP)) {
-                                       status = acpi_ex_resolve_to_value (&walk_state->results->results.obj_desc [0], walk_state);
-                                       if (ACPI_FAILURE (status)) {
-                                               return (status);
-                                       }
+                               status = acpi_ex_resolve_to_value (&walk_state->results->results.obj_desc [0], walk_state);
+                               if (ACPI_FAILURE (status)) {
+                                       return (status);
+                               }
                        }
 
                        walk_state->return_desc = walk_state->results->results.obj_desc [0];
                }
-
                else {
                        /* No return operand */
 
@@ -987,30 +861,35 @@ acpi_ds_exec_end_control_op (
 
 
        case AML_BREAK_OP:
+       case AML_CONTINUE_OP: /* ACPI 2.0 */
 
-               ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-                       "Break to end of current package, Op=%p\n", op));
 
-               /* TBD: update behavior for ACPI 2.0 */
+               /* Pop and delete control states until we find a while */
 
-               /*
-                * As per the ACPI specification:
-                *      "The break operation causes the current package
-                *          execution to complete"
-                *      "Break -- Stop executing the current code package
-                *          at this point"
-                *
-                * Returning AE_FALSE here will cause termination of
-                * the current package, and execution will continue one
-                * level up, starting with the completion of the parent Op.
-                */
-               status = AE_CTRL_FALSE;
-               break;
+               while (walk_state->control_state &&
+                               (walk_state->control_state->control.opcode != AML_WHILE_OP)) {
+                       control_state = acpi_ut_pop_generic_state (&walk_state->control_state);
+                       acpi_ut_delete_generic_state (control_state);
+               }
 
+               /* No while found? */
 
-       case AML_CONTINUE_OP: /* ACPI 2.0 */
+               if (!walk_state->control_state) {
+                       return (AE_AML_NO_WHILE);
+               }
+
+               /* Was: Walk_state->Aml_last_while = Walk_state->Control_state->Control.Aml_predicate_start; */
+
+               walk_state->aml_last_while = walk_state->control_state->control.package_end;
 
-               status = AE_NOT_IMPLEMENTED;
+               /* Return status depending on opcode */
+
+               if (op->opcode == AML_BREAK_OP) {
+                       status = AE_CTRL_BREAK;
+               }
+               else {
+                       status = AE_CTRL_CONTINUE;
+               }
                break;
 
 
@@ -1023,7 +902,6 @@ acpi_ds_exec_end_control_op (
                break;
        }
 
-
        return (status);
 }
 
index eeb3d8cf0580e436b76a83edf50e502ed3a20351..9a8f5f27bbb4b5125a1baee119d5de84defbaf32 100644 (file)
@@ -1,12 +1,12 @@
 /*******************************************************************************
  *
  * Module Name: dsutils - Dispatcher utilities
- *              $Revision: 80 $
+ *              $Revision: 88 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -33,7 +33,7 @@
 #include "acdebug.h"
 
 #define _COMPONENT          ACPI_DISPATCHER
-        MODULE_NAME         ("dsutils")
+        ACPI_MODULE_NAME    ("dsutils")
 
 
 /*******************************************************************************
@@ -58,7 +58,7 @@ acpi_ds_is_result_used (
        const acpi_opcode_info  *parent_info;
 
 
-       FUNCTION_TRACE_PTR ("Ds_is_result_used", op);
+       ACPI_FUNCTION_TRACE_PTR ("Ds_is_result_used", op);
 
 
        /* Must have both an Op and a Result Object */
@@ -68,7 +68,6 @@ acpi_ds_is_result_used (
                return_VALUE (TRUE);
        }
 
-
        /*
         * If there is no parent, the result can't possibly be used!
         * (An executing method typically has no parent, since each
@@ -79,18 +78,15 @@ acpi_ds_is_result_used (
                return_VALUE (FALSE);
        }
 
-
        /*
         * Get info on the parent.  The root Op is AML_SCOPE
         */
-
        parent_info = acpi_ps_get_opcode_info (op->parent->opcode);
        if (parent_info->class == AML_CLASS_UNKNOWN) {
                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown parent opcode. Op=%p\n", op));
                return_VALUE (FALSE);
        }
 
-
        /*
         * Decide what to do with the result based on the parent.  If
         * the parent opcode will not use the result, delete the object.
@@ -98,78 +94,80 @@ acpi_ds_is_result_used (
         * as an operand later.
         */
        switch (parent_info->class) {
-       /*
-        * In these cases, the parent will never use the return object
-        */
-       case AML_CLASS_CONTROL:        /* IF, ELSE, WHILE only */
+       case AML_CLASS_CONTROL:
 
                switch (op->parent->opcode) {
                case AML_RETURN_OP:
 
                        /* Never delete the return value associated with a return opcode */
 
-                       ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
-                               "Result used, [RETURN] opcode=%X Op=%p\n", op->opcode, op));
-                       return_VALUE (TRUE);
-                       break;
+                       goto result_used;
 
                case AML_IF_OP:
                case AML_WHILE_OP:
 
                        /*
                         * If we are executing the predicate AND this is the predicate op,
-                        * we will use the return value!
+                        * we will use the return value
                         */
-                       if ((walk_state->control_state->common.state == CONTROL_PREDICATE_EXECUTING) &&
+                       if ((walk_state->control_state->common.state == ACPI_CONTROL_PREDICATE_EXECUTING) &&
                                (walk_state->control_state->control.predicate_op == op)) {
-                               ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
-                                       "Result used as a predicate, [IF/WHILE] opcode=%X Op=%p\n",
-                                       op->opcode, op));
-                               return_VALUE (TRUE);
+                               goto result_used;
                        }
-
-                       break;
                }
 
+               /* The general control opcode returns no result */
 
-               /* Fall through to not used case below */
+               goto result_not_used;
 
 
-       case AML_CLASS_NAMED_OBJECT:   /* Scope, method, etc. */
        case AML_CLASS_CREATE:
 
                /*
                 * These opcodes allow Term_arg(s) as operands and therefore
-                * method calls.  The result is used.
+                * the operands can be method calls.  The result is used.
                 */
-               if ((op->parent->opcode == AML_REGION_OP)               ||
-                       (op->parent->opcode == AML_CREATE_FIELD_OP)         ||
-                       (op->parent->opcode == AML_CREATE_BIT_FIELD_OP)     ||
-                       (op->parent->opcode == AML_CREATE_BYTE_FIELD_OP)    ||
-                       (op->parent->opcode == AML_CREATE_WORD_FIELD_OP)    ||
-                       (op->parent->opcode == AML_CREATE_DWORD_FIELD_OP)   ||
-                       (op->parent->opcode == AML_CREATE_QWORD_FIELD_OP)) {
-                       ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
-                               "Result used, [Region or Create_field] opcode=%X Op=%p\n",
-                               op->opcode, op));
-                       return_VALUE (TRUE);
+               goto result_used;
+
+
+       case AML_CLASS_NAMED_OBJECT:
+
+               if ((op->parent->opcode == AML_REGION_OP)       ||
+                       (op->parent->opcode == AML_DATA_REGION_OP)) {
+                       /*
+                        * These opcodes allow Term_arg(s) as operands and therefore
+                        * the operands can be method calls.  The result is used.
+                        */
+                       goto result_used;
                }
 
-               ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
-                       "Result not used, Parent opcode=%X Op=%p\n", op->opcode, op));
+               goto result_not_used;
 
-               return_VALUE (FALSE);
-               break;
 
        /*
         * In all other cases. the parent will actually use the return
         * object, so keep it.
         */
        default:
-               break;
+               goto result_used;
        }
 
+
+result_used:
+       ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Result of [%s] used by Parent [%s] Op=%p\n",
+                       acpi_ps_get_opcode_name (op->opcode),
+                       acpi_ps_get_opcode_name (op->parent->opcode), op));
+
        return_VALUE (TRUE);
+
+
+result_not_used:
+       ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Result of [%s] not used by Parent [%s] Op=%p\n",
+                       acpi_ps_get_opcode_name (op->opcode),
+                       acpi_ps_get_opcode_name (op->parent->opcode), op));
+
+       return_VALUE (FALSE);
+
 }
 
 
@@ -200,7 +198,7 @@ acpi_ds_delete_result_if_not_used (
        acpi_status             status;
 
 
-       FUNCTION_TRACE_PTR ("Ds_delete_result_if_not_used", result_obj);
+       ACPI_FUNCTION_TRACE_PTR ("Ds_delete_result_if_not_used", result_obj);
 
 
        if (!op) {
@@ -252,16 +250,15 @@ acpi_ds_create_operand (
        acpi_status             status = AE_OK;
        NATIVE_CHAR             *name_string;
        u32                     name_length;
-       acpi_object_type8       data_type;
        acpi_operand_object     *obj_desc;
        acpi_parse_object       *parent_op;
        u16                     opcode;
-       u32                     flags;
-       operating_mode          interpreter_mode;
+       acpi_interpreter_mode   interpreter_mode;
        const acpi_opcode_info  *op_info;
+       char                    *name;
 
 
-       FUNCTION_TRACE_PTR ("Ds_create_operand", arg);
+       ACPI_FUNCTION_TRACE_PTR ("Ds_create_operand", arg);
 
 
        /* A valid name must be looked up in the namespace */
@@ -298,25 +295,20 @@ acpi_ds_create_operand (
                        (parent_op->opcode != AML_INT_NAMEPATH_OP)) {
                        /* Enter name into namespace if not found */
 
-                       interpreter_mode = IMODE_LOAD_PASS2;
+                       interpreter_mode = ACPI_IMODE_LOAD_PASS2;
                }
 
                else {
                        /* Return a failure if name not found */
 
-                       interpreter_mode = IMODE_EXECUTE;
+                       interpreter_mode = ACPI_IMODE_EXECUTE;
                }
 
                status = acpi_ns_lookup (walk_state->scope_info, name_string,
                                 ACPI_TYPE_ANY, interpreter_mode,
-                                NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE,
+                                ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
                                 walk_state,
                                 (acpi_namespace_node **) &obj_desc);
-
-               /* Free the namestring created above */
-
-               ACPI_MEM_FREE (name_string);
-
                /*
                 * The only case where we pass through (ignore) a NOT_FOUND
                 * error is for the Cond_ref_of opcode.
@@ -340,13 +332,18 @@ acpi_ds_create_operand (
                                 */
                                status = AE_AML_NAME_NOT_FOUND;
 
-                               /* TBD: Externalize Name_string and print */
-
+                               name = NULL;
+                               acpi_ns_externalize_name (ACPI_UINT32_MAX, name_string, NULL, &name);
                                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-                                               "Object name was not found in namespace\n"));
+                                               "Object name [%s] was not found in namespace\n", name));
+                               ACPI_MEM_FREE (name);
                        }
                }
 
+               /* Free the namestring created above */
+
+               ACPI_MEM_FREE (name_string);
+
                /* Check status from the lookup */
 
                if (ACPI_FAILURE (status)) {
@@ -359,7 +356,7 @@ acpi_ds_create_operand (
                if (ACPI_FAILURE (status)) {
                        return_ACPI_STATUS (status);
                }
-               DEBUGGER_EXEC (acpi_db_display_argument_object (obj_desc, walk_state));
+               ACPI_DEBUGGER_EXEC (acpi_db_display_argument_object (obj_desc, walk_state));
        }
 
 
@@ -376,30 +373,25 @@ acpi_ds_create_operand (
                        opcode = AML_ZERO_OP;       /* Has no arguments! */
 
                        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Null namepath: Arg=%p\n", arg));
-
-                       /*
-                        * TBD: [Investigate] anything else needed for the
-                        * zero op lvalue?
-                        */
                }
 
                else {
                        opcode = arg->opcode;
                }
 
+               /* Get the object type of the argument */
 
-               /* Get the data type of the argument */
-
-               data_type = acpi_ds_map_opcode_to_data_type (opcode, &flags);
-               if (data_type == INTERNAL_TYPE_INVALID) {
+               op_info = acpi_ps_get_opcode_info (opcode);
+               if (op_info->object_type == INTERNAL_TYPE_INVALID) {
                        return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
                }
 
-               if (flags & OP_HAS_RETURN_VALUE) {
+               if (op_info->flags & AML_HAS_RETVAL) {
                        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
                                "Argument previously created, already stacked \n"));
 
-                       DEBUGGER_EXEC (acpi_db_display_argument_object (walk_state->operands [walk_state->num_operands - 1], walk_state));
+                       ACPI_DEBUGGER_EXEC (acpi_db_display_argument_object (
+                               walk_state->operands [walk_state->num_operands - 1], walk_state));
 
                        /*
                         * Use value that was already previously returned
@@ -415,13 +407,12 @@ acpi_ds_create_operand (
                                        acpi_format_exception (status)));
                                return_ACPI_STATUS (status);
                        }
-
                }
 
                else {
                        /* Create an ACPI_INTERNAL_OBJECT for the argument */
 
-                       obj_desc = acpi_ut_create_internal_object (data_type);
+                       obj_desc = acpi_ut_create_internal_object (op_info->object_type);
                        if (!obj_desc) {
                                return_ACPI_STATUS (AE_NO_MEMORY);
                        }
@@ -443,7 +434,7 @@ acpi_ds_create_operand (
                        return_ACPI_STATUS (status);
                }
 
-               DEBUGGER_EXEC (acpi_db_display_argument_object (obj_desc, walk_state));
+               ACPI_DEBUGGER_EXEC (acpi_db_display_argument_object (obj_desc, walk_state));
        }
 
        return_ACPI_STATUS (AE_OK);
@@ -474,7 +465,7 @@ acpi_ds_create_operands (
        u32                     arg_count = 0;
 
 
-       FUNCTION_TRACE_PTR ("Ds_create_operands", first_arg);
+       ACPI_FUNCTION_TRACE_PTR ("Ds_create_operands", first_arg);
 
 
        /* For all arguments in the list... */
@@ -534,18 +525,13 @@ acpi_ds_resolve_operands (
        acpi_status             status = AE_OK;
 
 
-       FUNCTION_TRACE_PTR ("Ds_resolve_operands", walk_state);
+       ACPI_FUNCTION_TRACE_PTR ("Ds_resolve_operands", walk_state);
 
 
        /*
         * Attempt to resolve each of the valid operands
         * Method arguments are passed by value, not by reference
         */
-
-       /*
-        * TBD: [Investigate] Note from previous parser:
-        *   Ref_of problem with Acpi_ex_resolve_to_value() conversion.
-        */
        for (i = 0; i < walk_state->num_operands; i++) {
                status = acpi_ex_resolve_to_value (&walk_state->operands[i], walk_state);
                if (ACPI_FAILURE (status)) {
@@ -556,263 +542,3 @@ acpi_ds_resolve_operands (
        return_ACPI_STATUS (status);
 }
 
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ds_map_opcode_to_data_type
- *
- * PARAMETERS:  Opcode          - AML opcode to map
- *              Out_flags       - Additional info about the opcode
- *
- * RETURN:      The ACPI type associated with the opcode
- *
- * DESCRIPTION: Convert a raw AML opcode to the associated ACPI data type,
- *              if any.  If the opcode returns a value as part of the
- *              intepreter execution, a flag is returned in Out_flags.
- *
- ******************************************************************************/
-
-acpi_object_type8
-acpi_ds_map_opcode_to_data_type (
-       u16                     opcode,
-       u32                     *out_flags)
-{
-       acpi_object_type8       data_type = INTERNAL_TYPE_INVALID;
-       const acpi_opcode_info  *op_info;
-       u32                     flags = 0;
-
-
-       PROC_NAME ("Ds_map_opcode_to_data_type");
-
-
-       op_info = acpi_ps_get_opcode_info (opcode);
-       if (op_info->class == AML_CLASS_UNKNOWN) {
-               /* Unknown opcode */
-
-               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown AML opcode: %x\n", opcode));
-               return (data_type);
-       }
-
-
-/*
- * TBD: Use op class
- */
-
-       switch (op_info->type) {
-
-       case AML_TYPE_LITERAL:
-
-               switch (opcode) {
-               case AML_BYTE_OP:
-               case AML_WORD_OP:
-               case AML_DWORD_OP:
-               case AML_QWORD_OP:
-
-                       data_type = ACPI_TYPE_INTEGER;
-                       break;
-
-
-               case AML_STRING_OP:
-
-                       data_type = ACPI_TYPE_STRING;
-                       break;
-
-               case AML_INT_NAMEPATH_OP:
-                       data_type = INTERNAL_TYPE_REFERENCE;
-                       break;
-
-               default:
-                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-                               "Unknown (type LITERAL) AML opcode: %x\n", opcode));
-                       break;
-               }
-               break;
-
-
-       case AML_TYPE_DATA_TERM:
-
-               switch (opcode) {
-               case AML_BUFFER_OP:
-
-                       data_type = ACPI_TYPE_BUFFER;
-                       break;
-
-               case AML_PACKAGE_OP:
-               case AML_VAR_PACKAGE_OP:
-
-                       data_type = ACPI_TYPE_PACKAGE;
-                       break;
-
-               default:
-                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-                               "Unknown (type DATA_TERM) AML opcode: %x\n", opcode));
-                       break;
-               }
-               break;
-
-
-       case AML_TYPE_CONSTANT:
-       case AML_TYPE_METHOD_ARGUMENT:
-       case AML_TYPE_LOCAL_VARIABLE:
-
-               data_type = INTERNAL_TYPE_REFERENCE;
-               break;
-
-
-       case AML_TYPE_EXEC_1A_0T_1R:
-       case AML_TYPE_EXEC_1A_1T_1R:
-       case AML_TYPE_EXEC_2A_0T_1R:
-       case AML_TYPE_EXEC_2A_1T_1R:
-       case AML_TYPE_EXEC_2A_2T_1R:
-       case AML_TYPE_EXEC_3A_1T_1R:
-       case AML_TYPE_EXEC_6A_0T_1R:
-       case AML_TYPE_RETURN:
-
-               flags = OP_HAS_RETURN_VALUE;
-               data_type = ACPI_TYPE_ANY;
-               break;
-
-
-       case AML_TYPE_METHOD_CALL:
-
-               flags = OP_HAS_RETURN_VALUE;
-               data_type = ACPI_TYPE_METHOD;
-               break;
-
-
-       case AML_TYPE_NAMED_FIELD:
-       case AML_TYPE_NAMED_SIMPLE:
-       case AML_TYPE_NAMED_COMPLEX:
-       case AML_TYPE_NAMED_NO_OBJ:
-
-               data_type = acpi_ds_map_named_opcode_to_data_type (opcode);
-               break;
-
-
-       case AML_TYPE_EXEC_1A_0T_0R:
-       case AML_TYPE_EXEC_2A_0T_0R:
-       case AML_TYPE_EXEC_3A_0T_0R:
-       case AML_TYPE_EXEC_1A_1T_0R:
-       case AML_TYPE_CONTROL:
-
-               /* No mapping needed at this time */
-
-               break;
-
-
-       default:
-
-               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-                       "Unimplemented data type opcode: %x\n", opcode));
-               break;
-       }
-
-       /* Return flags to caller if requested */
-
-       if (out_flags) {
-               *out_flags = flags;
-       }
-
-       return (data_type);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ds_map_named_opcode_to_data_type
- *
- * PARAMETERS:  Opcode              - The Named AML opcode to map
- *
- * RETURN:      The ACPI type associated with the named opcode
- *
- * DESCRIPTION: Convert a raw Named AML opcode to the associated data type.
- *              Named opcodes are a subsystem of the AML opcodes.
- *
- ******************************************************************************/
-
-acpi_object_type8
-acpi_ds_map_named_opcode_to_data_type (
-       u16                     opcode)
-{
-       acpi_object_type8       data_type;
-
-
-       FUNCTION_ENTRY ();
-
-
-       /* Decode Opcode */
-
-       switch (opcode) {
-       case AML_SCOPE_OP:
-               data_type = INTERNAL_TYPE_SCOPE;
-               break;
-
-       case AML_DEVICE_OP:
-               data_type = ACPI_TYPE_DEVICE;
-               break;
-
-       case AML_THERMAL_ZONE_OP:
-               data_type = ACPI_TYPE_THERMAL;
-               break;
-
-       case AML_METHOD_OP:
-               data_type = ACPI_TYPE_METHOD;
-               break;
-
-       case AML_POWER_RES_OP:
-               data_type = ACPI_TYPE_POWER;
-               break;
-
-       case AML_PROCESSOR_OP:
-               data_type = ACPI_TYPE_PROCESSOR;
-               break;
-
-       case AML_FIELD_OP:                              /* Field_op */
-               data_type = INTERNAL_TYPE_FIELD_DEFN;
-               break;
-
-       case AML_INDEX_FIELD_OP:                        /* Index_field_op */
-               data_type = INTERNAL_TYPE_INDEX_FIELD_DEFN;
-               break;
-
-       case AML_BANK_FIELD_OP:                         /* Bank_field_op */
-               data_type = INTERNAL_TYPE_BANK_FIELD_DEFN;
-               break;
-
-       case AML_INT_NAMEDFIELD_OP:                     /* NO CASE IN ORIGINAL  */
-               data_type = ACPI_TYPE_ANY;
-               break;
-
-       case AML_NAME_OP:                               /* Name_op - special code in original */
-       case AML_INT_NAMEPATH_OP:
-               data_type = ACPI_TYPE_ANY;
-               break;
-
-       case AML_ALIAS_OP:
-               data_type = INTERNAL_TYPE_ALIAS;
-               break;
-
-       case AML_MUTEX_OP:
-               data_type = ACPI_TYPE_MUTEX;
-               break;
-
-       case AML_EVENT_OP:
-               data_type = ACPI_TYPE_EVENT;
-               break;
-
-       case AML_DATA_REGION_OP:
-       case AML_REGION_OP:
-               data_type = ACPI_TYPE_REGION;
-               break;
-
-
-       default:
-               data_type = ACPI_TYPE_ANY;
-               break;
-
-       }
-
-       return (data_type);
-}
-
-
index 83de5a5b5551dafaede4e78d3c45406ec498667d..ef3bb509940d605ce0f9c147a3ff5f46666d374c 100644 (file)
@@ -2,12 +2,12 @@
  *
  * Module Name: dswexec - Dispatcher method execution callbacks;
  *                        dispatch to interpreter.
- *              $Revision: 79 $
+ *              $Revision: 89 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 
 
 #define _COMPONENT          ACPI_DISPATCHER
-        MODULE_NAME         ("dswexec")
+        ACPI_MODULE_NAME    ("dswexec")
 
 /*
- * Dispatch tables for opcode classes
+ * Dispatch table for opcode classes
  */
 ACPI_EXECUTE_OP         acpi_gbl_op_type_dispatch [] = {
                         acpi_ex_opcode_1A_0T_0R,
@@ -68,17 +68,17 @@ ACPI_EXECUTE_OP         acpi_gbl_op_type_dispatch [] = {
 acpi_status
 acpi_ds_get_predicate_value (
        acpi_walk_state         *walk_state,
-       u32                     has_result_obj) {
+       acpi_operand_object     *result_obj) {
        acpi_status             status = AE_OK;
        acpi_operand_object     *obj_desc;
 
 
-       FUNCTION_TRACE_PTR ("Ds_get_predicate_value", walk_state);
+       ACPI_FUNCTION_TRACE_PTR ("Ds_get_predicate_value", walk_state);
 
 
        walk_state->control_state->common.state = 0;
 
-       if (has_result_obj) {
+       if (result_obj) {
                status = acpi_ds_result_pop (&obj_desc, walk_state);
                if (ACPI_FAILURE (status)) {
                        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
@@ -88,7 +88,6 @@ acpi_ds_get_predicate_value (
                        return_ACPI_STATUS (status);
                }
        }
-
        else {
                status = acpi_ds_create_operand (walk_state, walk_state->op, 0);
                if (ACPI_FAILURE (status)) {
@@ -110,7 +109,6 @@ acpi_ds_get_predicate_value (
                return_ACPI_STATUS (AE_AML_NO_OPERAND);
        }
 
-
        /*
         * Result of predicate evaluation currently must
         * be a number
@@ -124,7 +122,6 @@ acpi_ds_get_predicate_value (
                goto cleanup;
        }
 
-
        /* Truncate the predicate to 32-bits if necessary */
 
        acpi_ex_truncate_for32bit_table (obj_desc, walk_state);
@@ -136,7 +133,6 @@ acpi_ds_get_predicate_value (
        if (obj_desc->integer.value) {
                walk_state->control_state->common.value = TRUE;
        }
-
        else {
                /*
                 * Predicate is FALSE, we will just toss the
@@ -149,12 +145,12 @@ acpi_ds_get_predicate_value (
 
 cleanup:
 
-       ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Completed a predicate eval=%X Op=%pn",
+       ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Completed a predicate eval=%X Op=%p\n",
                walk_state->control_state->common.value, walk_state->op));
 
         /* Break to debugger to display result */
 
-       DEBUGGER_EXEC (acpi_db_display_result_object (obj_desc, walk_state));
+       ACPI_DEBUGGER_EXEC (acpi_db_display_result_object (obj_desc, walk_state));
 
        /*
         * Delete the predicate result object (we know that
@@ -162,7 +158,7 @@ cleanup:
         */
        acpi_ut_remove_reference (obj_desc);
 
-       walk_state->control_state->common.state = CONTROL_NORMAL;
+       walk_state->control_state->common.state = ACPI_CONTROL_NORMAL;
        return_ACPI_STATUS (status);
 }
 
@@ -192,7 +188,7 @@ acpi_ds_exec_begin_op (
        u32                     opcode_class;
 
 
-       FUNCTION_TRACE_PTR ("Ds_exec_begin_op", walk_state);
+       ACPI_FUNCTION_TRACE_PTR ("Ds_exec_begin_op", walk_state);
 
 
        op = walk_state->op;
@@ -206,6 +202,12 @@ acpi_ds_exec_begin_op (
                walk_state->op = op;
                walk_state->op_info = acpi_ps_get_opcode_info (op->opcode);
                walk_state->opcode = op->opcode;
+
+               if (acpi_ns_opens_scope (walk_state->op_info->object_type)) {
+                       ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n",
+                               acpi_ut_get_type_name (walk_state->op_info->object_type), op));
+                       acpi_ds_scope_stack_pop (walk_state);
+               }
        }
 
        if (op == walk_state->origin) {
@@ -223,11 +225,11 @@ acpi_ds_exec_begin_op (
         */
        if ((walk_state->control_state) &&
                (walk_state->control_state->common.state ==
-                       CONTROL_CONDITIONAL_EXECUTING)) {
+                       ACPI_CONTROL_CONDITIONAL_EXECUTING)) {
                ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Exec predicate Op=%p State=%p\n",
                                  op, walk_state));
 
-               walk_state->control_state->common.state = CONTROL_PREDICATE_EXECUTING;
+               walk_state->control_state->common.state = ACPI_CONTROL_PREDICATE_EXECUTING;
 
                /* Save start of predicate */
 
@@ -260,7 +262,7 @@ acpi_ds_exec_begin_op (
 
        case AML_CLASS_NAMED_OBJECT:
 
-               if (walk_state->walk_type == WALK_METHOD) {
+               if (walk_state->walk_type == ACPI_WALK_METHOD) {
                        /*
                         * Found a named object declaration during method
                         * execution;  we must enter this object into the
@@ -271,19 +273,16 @@ acpi_ds_exec_begin_op (
                        status = acpi_ds_load2_begin_op (walk_state, NULL);
                }
 
-
                if (op->opcode == AML_REGION_OP) {
                        status = acpi_ds_result_stack_push (walk_state);
                }
-
                break;
 
 
-       /* most operators with arguments */
-
        case AML_CLASS_EXECUTE:
        case AML_CLASS_CREATE:
 
+               /* most operators with arguments */
                /* Start a new result/operand state */
 
                status = acpi_ds_result_stack_push (walk_state);
@@ -329,7 +328,7 @@ acpi_ds_exec_end_op (
        u32                     i;
 
 
-       FUNCTION_TRACE_PTR ("Ds_exec_end_op", walk_state);
+       ACPI_FUNCTION_TRACE_PTR ("Ds_exec_end_op", walk_state);
 
 
        op      = walk_state->op;
@@ -349,22 +348,19 @@ acpi_ds_exec_end_op (
        walk_state->return_desc = NULL;
        walk_state->result_obj = NULL;
 
-
        /* Call debugger for single step support (DEBUG build only) */
 
-       DEBUGGER_EXEC (status = acpi_db_single_step (walk_state, op, op_class));
-       DEBUGGER_EXEC (if (ACPI_FAILURE (status)) {return_ACPI_STATUS (status);});
-
+       ACPI_DEBUGGER_EXEC (status = acpi_db_single_step (walk_state, op, op_class));
+       ACPI_DEBUGGER_EXEC (if (ACPI_FAILURE (status)) {return_ACPI_STATUS (status);});
 
-       switch (op_class) {
        /* Decode the Opcode Class */
 
-       case AML_CLASS_ARGUMENT: /* constants, literals, etc.  do nothing */
+       switch (op_class) {
+       case AML_CLASS_ARGUMENT:    /* constants, literals, etc. -- do nothing */
                break;
 
-       /* most operators with arguments */
 
-       case AML_CLASS_EXECUTE:
+       case AML_CLASS_EXECUTE:     /* most operators with arguments */
 
                /* Build resolved operand stack */
 
@@ -385,37 +381,26 @@ acpi_ds_exec_end_op (
                status = acpi_ex_resolve_operands (walk_state->opcode,
                                  &(walk_state->operands [walk_state->num_operands -1]),
                                  walk_state);
-               if (ACPI_FAILURE (status)) {
-                       /* TBD: must pop and delete operands */
-
-                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "[%s]: Could not resolve operands, %s\n",
-                               acpi_ps_get_opcode_name (walk_state->opcode), acpi_format_exception (status)));
+               if (ACPI_SUCCESS (status)) {
+                       ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
+                                         acpi_ps_get_opcode_name (walk_state->opcode),
+                                         walk_state->num_operands, "after Ex_resolve_operands");
 
                        /*
-                        * On error, we must delete all the operands and clear the
-                        * operand stack
+                        * Dispatch the request to the appropriate interpreter handler
+                        * routine.  There is one routine per opcode "type" based upon the
+                        * number of opcode arguments and return type.
                         */
-                       for (i = 0; i < walk_state->num_operands; i++) {
-                               acpi_ut_remove_reference (walk_state->operands[i]);
-                               walk_state->operands[i] = NULL;
-                       }
-
-                       walk_state->num_operands = 0;
-                       goto cleanup;
+                       status = acpi_gbl_op_type_dispatch [op_type] (walk_state);
+               }
+               else {
+                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+                               "[%s]: Could not resolve operands, %s\n",
+                               acpi_ps_get_opcode_name (walk_state->opcode),
+                               acpi_format_exception (status)));
                }
 
-               DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, acpi_ps_get_opcode_name (walk_state->opcode),
-                                 walk_state->num_operands, "after Ex_resolve_operands");
-
-               /*
-                * Dispatch the request to the appropriate interpreter handler
-                * routine.  There is one routine per opcode "type" based upon the
-                * number of opcode arguments and return type.
-                */
-               status = acpi_gbl_op_type_dispatch [op_type] (walk_state);
-
-
-               /* Delete argument objects and clear the operand stack */
+               /* Always delete the argument objects and clear the operand stack */
 
                for (i = 0; i < walk_state->num_operands; i++) {
                        /*
@@ -425,7 +410,6 @@ acpi_ds_exec_end_op (
                        acpi_ut_remove_reference (walk_state->operands[i]);
                        walk_state->operands[i] = NULL;
                }
-
                walk_state->num_operands = 0;
 
                /*
@@ -478,10 +462,9 @@ acpi_ds_exec_end_op (
                        }
 
                        /*
-                        * Since the operands will be passed to another
-                        * control method, we must resolve all local
-                        * references here (Local variables, arguments
-                        * to *this* method, etc.)
+                        * Since the operands will be passed to another control method,
+                        * we must resolve all local references here (Local variables,
+                        * arguments to *this* method, etc.)
                         */
                        status = acpi_ds_resolve_operands (walk_state);
                        if (ACPI_FAILURE (status)) {
@@ -499,7 +482,6 @@ acpi_ds_exec_end_op (
                         * especially the operand count!
                         */
                        return_ACPI_STATUS (status);
-                       break;
 
 
                case AML_TYPE_CREATE_FIELD:
@@ -519,6 +501,7 @@ acpi_ds_exec_end_op (
                case AML_TYPE_NAMED_FIELD:
                case AML_TYPE_NAMED_COMPLEX:
                case AML_TYPE_NAMED_SIMPLE:
+               case AML_TYPE_NAMED_NO_OBJ:
 
                        status = acpi_ds_load2_end_op (walk_state);
                        if (ACPI_FAILURE (status)) {
@@ -539,18 +522,21 @@ acpi_ds_exec_end_op (
 
                        break;
 
+
                case AML_TYPE_UNDEFINED:
 
                        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Undefined opcode type Op=%p\n", op));
                        return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
-                       break;
 
 
                case AML_TYPE_BOGUS:
-                       ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Internal opcode=%X type Op=%p\n",
+
+                       ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+                               "Internal opcode=%X type Op=%p\n",
                                walk_state->opcode, op));
                        break;
 
+
                default:
 
                        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
@@ -563,8 +549,8 @@ acpi_ds_exec_end_op (
        }
 
        /*
-        * ACPI 2.0 support for 64-bit integers:
-        * Truncate numeric result value if we are executing from a 32-bit ACPI table
+        * ACPI 2.0 support for 64-bit integers: Truncate numeric
+        * result value if we are executing from a 32-bit ACPI table
         */
        acpi_ex_truncate_for32bit_table (walk_state->result_obj, walk_state);
 
@@ -575,9 +561,9 @@ acpi_ds_exec_end_op (
 
        if ((walk_state->control_state) &&
                (walk_state->control_state->common.state ==
-                       CONTROL_PREDICATE_EXECUTING) &&
+                       ACPI_CONTROL_PREDICATE_EXECUTING) &&
                (walk_state->control_state->control.predicate_op == op)) {
-               status = acpi_ds_get_predicate_value (walk_state, (u32) walk_state->result_obj);
+               status = acpi_ds_get_predicate_value (walk_state, walk_state->result_obj);
                walk_state->result_obj = NULL;
        }
 
@@ -586,7 +572,7 @@ cleanup:
        if (walk_state->result_obj) {
                /* Break to debugger to display result */
 
-               DEBUGGER_EXEC (acpi_db_display_result_object (walk_state->result_obj, walk_state));
+               ACPI_DEBUGGER_EXEC (acpi_db_display_result_object (walk_state->result_obj, walk_state));
 
                /*
                 * Delete the result op if and only if:
@@ -598,10 +584,7 @@ cleanup:
 
        /* Always clear the object stack */
 
-       /* TBD: [Investigate] Clear stack of return value,
-       but don't delete it */
        walk_state->num_operands = 0;
-
        return_ACPI_STATUS (status);
 }
 
index 068c33bf74af808c424777ca5eb5fcbc3e61dea6..36bf092b9256145db14db0d92ff33723a4967ac1 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: dswload - Dispatcher namespace load callbacks
- *              $Revision: 50 $
+ *              $Revision: 61 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -34,7 +34,7 @@
 
 
 #define _COMPONENT          ACPI_DISPATCHER
-        MODULE_NAME         ("dswload")
+        ACPI_MODULE_NAME    ("dswload")
 
 
 /*******************************************************************************
@@ -77,7 +77,6 @@ acpi_ds_init_callbacks (
 
        default:
                return (AE_BAD_PARAMETER);
-               break;
        }
 
        return (AE_OK);
@@ -106,16 +105,20 @@ acpi_ds_load1_begin_op (
        acpi_parse_object       *op;
        acpi_namespace_node     *node;
        acpi_status             status;
-       acpi_object_type8       data_type;
+       acpi_object_type        object_type;
        NATIVE_CHAR             *path;
 
 
-       PROC_NAME ("Ds_load1_begin_op");
+       ACPI_FUNCTION_NAME ("Ds_load1_begin_op");
 
        op = walk_state->op;
        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, walk_state));
 
 
+       if (op && (op->opcode == AML_INT_NAMEDFIELD_OP)) {
+               ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, walk_state));
+       }
+
        /* We are only interested in opcodes that have an associated name */
 
        if (walk_state->op) {
@@ -136,25 +139,18 @@ acpi_ds_load1_begin_op (
 
        /* Map the raw opcode into an internal object type */
 
-       data_type = acpi_ds_map_named_opcode_to_data_type (walk_state->opcode);
-
+       object_type = walk_state->op_info->object_type;
 
        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
-               "State=%p Op=%p Type=%x\n", walk_state, op, data_type));
-
-
-       if (walk_state->opcode == AML_SCOPE_OP) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
-                       "State=%p Op=%p Type=%x\n", walk_state, op, data_type));
-       }
+               "State=%p Op=%p Type=%x\n", walk_state, op, object_type));
 
        /*
         * Enter the named type into the internal namespace.  We enter the name
         * as we go downward in the parse tree.  Any necessary subobjects that involve
         * arguments to the opcode must be created as we go back up the parse tree later.
         */
-       status = acpi_ns_lookup (walk_state->scope_info, path, data_type,
-                         IMODE_LOAD_PASS1, NS_NO_UPSEARCH, walk_state, &(node));
+       status = acpi_ns_lookup (walk_state->scope_info, path, object_type,
+                         ACPI_IMODE_LOAD_PASS1, ACPI_NS_NO_UPSEARCH, walk_state, &(node));
 
        if (ACPI_FAILURE (status)) {
                return (status);
@@ -205,10 +201,10 @@ acpi_ds_load1_end_op (
        acpi_walk_state         *walk_state)
 {
        acpi_parse_object       *op;
-       acpi_object_type8       data_type;
+       acpi_object_type        object_type;
 
 
-       PROC_NAME ("Ds_load1_end_op");
+       ACPI_FUNCTION_NAME ("Ds_load1_end_op");
 
        op = walk_state->op;
        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, walk_state));
@@ -216,30 +212,44 @@ acpi_ds_load1_end_op (
 
        /* We are only interested in opcodes that have an associated name */
 
-       if (!(walk_state->op_info->flags & AML_NAMED)) {
+       if (!(walk_state->op_info->flags & (AML_NAMED | AML_FIELD))) {
+               return (AE_OK);
+       }
+
+       /* Get the object type to determine if we should pop the scope */
+
+       object_type = walk_state->op_info->object_type;
+
+       if (walk_state->op_info->flags & AML_FIELD) {
+               if (walk_state->opcode == AML_FIELD_OP         ||
+                       walk_state->opcode == AML_BANK_FIELD_OP    ||
+                       walk_state->opcode == AML_INDEX_FIELD_OP) {
+                       acpi_ds_init_field_objects (op, walk_state);
+               }
                return (AE_OK);
        }
 
-       /* Get the type to determine if we should pop the scope */
 
-       data_type = acpi_ds_map_named_opcode_to_data_type (op->opcode);
+       if (op->opcode == AML_REGION_OP) {
+               /*Status = */acpi_ex_create_region (((acpi_parse2_object *) op)->data,
+                                 ((acpi_parse2_object *) op)->length,
+                                                (ACPI_ADR_SPACE_TYPE) ((op->value.arg)->value.integer), walk_state);
+       }
 
        if (op->opcode == AML_NAME_OP) {
-               /* For Name opcode, check the argument */
+               /* For Name opcode, get the object type from the argument */
 
                if (op->value.arg) {
-                       data_type = acpi_ds_map_opcode_to_data_type (
-                                         (op->value.arg)->opcode, NULL);
-                       ((acpi_namespace_node *)op->node)->type =
-                                         (u8) data_type;
+                       object_type = (acpi_ps_get_opcode_info ((op->value.arg)->opcode))->object_type;
+                       op->node->type = (u8) object_type;
                }
        }
 
        /* Pop the scope stack */
 
-       if (acpi_ns_opens_scope (data_type)) {
+       if (acpi_ns_opens_scope (object_type)) {
                ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s): Popping scope for Op %p\n",
-                       acpi_ut_get_type_name (data_type), op));
+                       acpi_ut_get_type_name (object_type), op));
 
                acpi_ds_scope_stack_pop (walk_state);
        }
@@ -270,28 +280,22 @@ acpi_ds_load2_begin_op (
        acpi_parse_object       *op;
        acpi_namespace_node     *node;
        acpi_status             status;
-       acpi_object_type8       data_type;
+       acpi_object_type        object_type;
        NATIVE_CHAR             *buffer_ptr;
        void                    *original = NULL;
 
 
-       PROC_NAME ("Ds_load2_begin_op");
+       ACPI_FUNCTION_NAME ("Ds_load2_begin_op");
+
 
        op = walk_state->op;
        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, walk_state));
 
-
        if (op) {
                /* We only care about Namespace opcodes here */
 
-               if (!(walk_state->op_info->flags & AML_NSOPCODE) &&
-                       walk_state->opcode != AML_INT_NAMEPATH_OP) {
-                       return (AE_OK);
-               }
-
-               /* TBD: [Restructure] Temp! same code as in psparse */
-
-               if (!(walk_state->op_info->flags & AML_NAMED)) {
+               if ((!(walk_state->op_info->flags & AML_NSOPCODE) && (walk_state->opcode != AML_INT_NAMEPATH_OP)) ||
+                       (!(walk_state->op_info->flags & AML_NAMED))) {
                        return (AE_OK);
                }
 
@@ -315,16 +319,17 @@ acpi_ds_load2_begin_op (
                }
        }
        else {
+               /* Get the namestring from the raw AML */
+
                buffer_ptr = acpi_ps_get_next_namestring (&walk_state->parser_state);
        }
 
+       /* Map the opcode into an internal object type */
 
-       /* Map the raw opcode into an internal object type */
-
-       data_type = acpi_ds_map_named_opcode_to_data_type (walk_state->opcode);
+       object_type = walk_state->op_info->object_type;
 
        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
-               "State=%p Op=%p Type=%x\n", walk_state, op, data_type));
+               "State=%p Op=%p Type=%x\n", walk_state, op, object_type));
 
 
        if (walk_state->opcode == AML_FIELD_OP         ||
@@ -333,23 +338,21 @@ acpi_ds_load2_begin_op (
                node = NULL;
                status = AE_OK;
        }
-
        else if (walk_state->opcode == AML_INT_NAMEPATH_OP) {
                /*
                 * The Name_path is an object reference to an existing object. Don't enter the
                 * name into the namespace, but look it up for use later
                 */
-               status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, data_type,
-                                 IMODE_EXECUTE, NS_SEARCH_PARENT, walk_state, &(node));
+               status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type,
+                                 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, walk_state, &(node));
        }
-
        else {
                if (op && op->node) {
                        original = op->node;
                        node = op->node;
 
-                       if (acpi_ns_opens_scope (data_type)) {
-                               status = acpi_ds_scope_stack_push (node, data_type, walk_state);
+                       if (acpi_ns_opens_scope (object_type)) {
+                               status = acpi_ds_scope_stack_push (node, object_type, walk_state);
                                if (ACPI_FAILURE (status)) {
                                        return (status);
                                }
@@ -363,8 +366,8 @@ acpi_ds_load2_begin_op (
                 * as we go downward in the parse tree.  Any necessary subobjects that involve
                 * arguments to the opcode must be created as we go back up the parse tree later.
                 */
-               status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, data_type,
-                                 IMODE_EXECUTE, NS_NO_UPSEARCH, walk_state, &(node));
+               status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type,
+                                 ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, walk_state, &(node));
        }
 
        if (ACPI_SUCCESS (status)) {
@@ -376,7 +379,7 @@ acpi_ds_load2_begin_op (
                                return (AE_NO_MEMORY);
                        }
 
-                       /* Initialize */
+                       /* Initialize the new op */
 
                        ((acpi_parse2_object *)op)->name = node->name;
                        *out_op = op;
@@ -423,18 +426,18 @@ acpi_ds_load2_end_op (
 {
        acpi_parse_object       *op;
        acpi_status             status = AE_OK;
-       acpi_object_type8       data_type;
+       acpi_object_type        object_type;
        acpi_namespace_node     *node;
        acpi_parse_object       *arg;
        acpi_namespace_node     *new_node;
        u32                     i;
 
 
-       PROC_NAME ("Ds_load2_end_op");
+       ACPI_FUNCTION_NAME ("Ds_load2_end_op");
 
        op = walk_state->op;
-       ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, walk_state));
-
+       ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n",
+                       walk_state->op_info->name, op, walk_state));
 
        /* Only interested in opcodes that have namespace objects */
 
@@ -446,7 +449,7 @@ acpi_ds_load2_end_op (
                ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
                        "Ending scope Op=%p State=%p\n", op, walk_state));
 
-               if (((acpi_parse2_object *)op)->name == -1) {
+               if (((acpi_parse2_object *)op)->name == ACPI_UINT16_MAX) {
                        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unnamed scope! Op=%p State=%p\n",
                                op, walk_state));
                        return (AE_OK);
@@ -454,7 +457,7 @@ acpi_ds_load2_end_op (
        }
 
 
-       data_type = acpi_ds_map_named_opcode_to_data_type (op->opcode);
+       object_type = walk_state->op_info->object_type;
 
        /*
         * Get the Node/name from the earlier lookup
@@ -471,10 +474,9 @@ acpi_ds_load2_end_op (
 
        /* Pop the scope stack */
 
-       if (acpi_ns_opens_scope (data_type)) {
-
+       if (acpi_ns_opens_scope (object_type)) {
                ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n",
-                       acpi_ut_get_type_name (data_type), op));
+                       acpi_ut_get_type_name (object_type), op));
                acpi_ds_scope_stack_pop (walk_state);
        }
 
@@ -527,7 +529,6 @@ acpi_ds_load2_end_op (
 
         case AML_TYPE_NAMED_FIELD:
 
-               arg = op->value.arg;
                switch (op->opcode) {
                case AML_INDEX_FIELD_OP:
 
@@ -535,13 +536,11 @@ acpi_ds_load2_end_op (
                                           walk_state);
                        break;
 
-
                case AML_BANK_FIELD_OP:
 
                        status = acpi_ds_create_bank_field (op, arg->node, walk_state);
                        break;
 
-
                case AML_FIELD_OP:
 
                        status = acpi_ds_create_field (op, arg->node, walk_state);
@@ -563,25 +562,21 @@ acpi_ds_load2_end_op (
                        status = acpi_ex_create_processor (walk_state);
                        break;
 
-
                case AML_POWER_RES_OP:
 
                        status = acpi_ex_create_power_resource (walk_state);
                        break;
 
-
                case AML_MUTEX_OP:
 
                        status = acpi_ex_create_mutex (walk_state);
                        break;
 
-
                case AML_EVENT_OP:
 
                        status = acpi_ex_create_event (walk_state);
                        break;
 
-
                case AML_DATA_REGION_OP:
 
                        status = acpi_ex_create_table_region (walk_state);
@@ -597,7 +592,6 @@ acpi_ds_load2_end_op (
 
                        status = AE_OK;
                        goto cleanup;
-                       break;
                }
 
                /* Delete operands */
@@ -615,13 +609,13 @@ acpi_ds_load2_end_op (
                switch (op->opcode) {
                case AML_METHOD_OP:
                        /*
-                        * Method_op Pkg_length Names_string Method_flags Term_list
+                        * Method_op Pkg_length Name_string Method_flags Term_list
                         */
                        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
                                "LOADING-Method: State=%p Op=%p Named_obj=%p\n",
                                walk_state, op, node));
 
-                       if (!node->object) {
+                       if (!acpi_ns_get_attached_object (node)) {
                                status = acpi_ds_create_operands (walk_state, arg);
                                if (ACPI_FAILURE (status)) {
                                        goto cleanup;
@@ -639,9 +633,21 @@ acpi_ds_load2_end_op (
                         * The Op_region is not fully parsed at this time. Only valid argument is the Space_id.
                         * (We must save the address of the AML of the address and length operands)
                         */
-                       status = acpi_ex_create_region (((acpi_parse2_object *) op)->data,
-                                         ((acpi_parse2_object *) op)->length,
-                                                        (ACPI_ADR_SPACE_TYPE) arg->value.integer, walk_state);
+                       /*
+                        * If we have a valid region, initialize it
+                        * Namespace is NOT locked at this point.
+                        */
+                       status = acpi_ev_initialize_region (acpi_ns_get_attached_object (node), FALSE);
+                       if (ACPI_FAILURE (status)) {
+                               /*
+                                *  If AE_NOT_EXIST is returned, it is not fatal
+                                *  because many regions get created before a handler
+                                *  is installed for said region.
+                                */
+                               if (AE_NOT_EXIST == status) {
+                                       status = AE_OK;
+                               }
+                       }
                        break;
 
 
@@ -669,14 +675,17 @@ acpi_ds_load2_end_op (
                 * Lookup the method name and save the Node
                 */
                status = acpi_ns_lookup (walk_state->scope_info, arg->value.string,
-                                 ACPI_TYPE_ANY, IMODE_LOAD_PASS2,
-                                 NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE,
+                                 ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2,
+                                 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
                                  walk_state, &(new_node));
                if (ACPI_SUCCESS (status)) {
-                       /* TBD: has name already been resolved by here ??*/
-
-                       /* TBD: [Restructure] Make sure that what we found is indeed a method! */
-                       /* We didn't search for a method on purpose, to see if the name would resolve! */
+                       /*
+                        * Make sure that what we found is indeed a method
+                        * We didn't search for a method on purpose, to see if the name would resolve
+                        */
+                       if (new_node->type != ACPI_TYPE_METHOD) {
+                               status = AE_AML_OPERAND_TYPE;
+                       }
 
                        /* We could put the returned object (Node) on the object stack for later, but
                         * for now, we will put it in the "op" object that the parser uses, so we
index 0c27c015530aa1c4c168c2a01bee01bdb9e6dc09..600ce69a53482ce2a0b32f9529fa16e2f8d1a193 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: dswscope - Scope stack manipulation
- *              $Revision: 49 $
+ *              $Revision: 52 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@
 
 
 #define _COMPONENT          ACPI_DISPATCHER
-        MODULE_NAME         ("dswscope")
+        ACPI_MODULE_NAME    ("dswscope")
 
 
 #define STACK_POP(head) head
@@ -53,7 +53,7 @@ acpi_ds_scope_stack_clear (
 {
        acpi_generic_state      *scope_info;
 
-       PROC_NAME ("Ds_scope_stack_clear");
+       ACPI_FUNCTION_NAME ("Ds_scope_stack_clear");
 
 
        while (walk_state->scope_info) {
@@ -84,26 +84,26 @@ acpi_ds_scope_stack_clear (
 acpi_status
 acpi_ds_scope_stack_push (
        acpi_namespace_node     *node,
-       acpi_object_type8       type,
+       acpi_object_type        type,
        acpi_walk_state         *walk_state)
 {
        acpi_generic_state      *scope_info;
 
 
-       FUNCTION_TRACE ("Ds_scope_stack_push");
+       ACPI_FUNCTION_TRACE ("Ds_scope_stack_push");
 
 
        if (!node) {
                /* Invalid scope   */
 
-               REPORT_ERROR (("Ds_scope_stack_push: null scope passed\n"));
+               ACPI_REPORT_ERROR (("Ds_scope_stack_push: null scope passed\n"));
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
        /* Make sure object type is valid */
 
        if (!acpi_ex_validate_object_type (type)) {
-               REPORT_WARNING (("Ds_scope_stack_push: type code out of range\n"));
+               ACPI_REPORT_WARNING (("Ds_scope_stack_push: type code out of range\n"));
        }
 
 
@@ -152,7 +152,7 @@ acpi_ds_scope_stack_pop (
        acpi_generic_state      *scope_info;
 
 
-       FUNCTION_TRACE ("Ds_scope_stack_pop");
+       ACPI_FUNCTION_TRACE ("Ds_scope_stack_pop");
 
 
        /*
index b0581a7016490f205ddece4c6767c1d7f1be7c3d..ecff248de9b234efea46349e20612b1026b85556 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: dswstate - Dispatcher parse tree walk management routines
- *              $Revision: 54 $
+ *              $Revision: 59 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -32,7 +32,7 @@
 #include "acinterp.h"
 
 #define _COMPONENT          ACPI_DISPATCHER
-        MODULE_NAME         ("dswstate")
+        ACPI_MODULE_NAME    ("dswstate")
 
 
 /*******************************************************************************
@@ -57,7 +57,7 @@ acpi_ds_result_insert (
        acpi_generic_state      *state;
 
 
-       PROC_NAME ("Ds_result_insert");
+       ACPI_FUNCTION_NAME ("Ds_result_insert");
 
 
        state = walk_state->results;
@@ -116,7 +116,7 @@ acpi_ds_result_remove (
        acpi_generic_state      *state;
 
 
-       PROC_NAME ("Ds_result_remove");
+       ACPI_FUNCTION_NAME ("Ds_result_remove");
 
 
        state = walk_state->results;
@@ -181,7 +181,7 @@ acpi_ds_result_pop (
        acpi_generic_state      *state;
 
 
-       PROC_NAME ("Ds_result_pop");
+       ACPI_FUNCTION_NAME ("Ds_result_pop");
 
 
        state = walk_state->results;
@@ -241,7 +241,7 @@ acpi_ds_result_pop_from_bottom (
        acpi_generic_state      *state;
 
 
-       PROC_NAME ("Ds_result_pop_from_bottom");
+       ACPI_FUNCTION_NAME ("Ds_result_pop_from_bottom");
 
 
        state = walk_state->results;
@@ -307,7 +307,7 @@ acpi_ds_result_push (
        acpi_generic_state      *state;
 
 
-       PROC_NAME ("Ds_result_push");
+       ACPI_FUNCTION_NAME ("Ds_result_push");
 
 
        state = walk_state->results;
@@ -360,7 +360,7 @@ acpi_ds_result_stack_push (
 {
        acpi_generic_state      *state;
 
-       PROC_NAME ("Ds_result_stack_push");
+       ACPI_FUNCTION_NAME ("Ds_result_stack_push");
 
 
        state = acpi_ut_create_generic_state ();
@@ -396,7 +396,7 @@ acpi_ds_result_stack_pop (
 {
        acpi_generic_state      *state;
 
-       PROC_NAME ("Ds_result_stack_pop");
+       ACPI_FUNCTION_NAME ("Ds_result_stack_pop");
 
 
        /* Check for stack underflow */
@@ -440,7 +440,7 @@ acpi_ds_obj_stack_delete_all (
        u32                     i;
 
 
-       FUNCTION_TRACE_PTR ("Ds_obj_stack_delete_all", walk_state);
+       ACPI_FUNCTION_TRACE_PTR ("Ds_obj_stack_delete_all", walk_state);
 
 
        /* The stack size is configurable, but fixed */
@@ -474,7 +474,7 @@ acpi_ds_obj_stack_push (
        void                    *object,
        acpi_walk_state         *walk_state)
 {
-       PROC_NAME ("Ds_obj_stack_push");
+       ACPI_FUNCTION_NAME ("Ds_obj_stack_push");
 
 
        /* Check for stack overflow */
@@ -519,7 +519,7 @@ acpi_ds_obj_stack_pop_object (
        acpi_operand_object     **object,
        acpi_walk_state         *walk_state)
 {
-       PROC_NAME ("Ds_obj_stack_pop_object");
+       ACPI_FUNCTION_NAME ("Ds_obj_stack_pop_object");
 
 
        /* Check for stack underflow */
@@ -580,7 +580,7 @@ acpi_ds_obj_stack_pop (
 {
        u32                     i;
 
-       PROC_NAME ("Ds_obj_stack_pop");
+       ACPI_FUNCTION_NAME ("Ds_obj_stack_pop");
 
 
        for (i = 0; i < pop_count; i++) {
@@ -628,7 +628,7 @@ acpi_ds_obj_stack_pop_and_delete (
        u32                     i;
        acpi_operand_object     *obj_desc;
 
-       PROC_NAME ("Ds_obj_stack_pop_and_delete");
+       ACPI_FUNCTION_NAME ("Ds_obj_stack_pop_and_delete");
 
 
        for (i = 0; i < pop_count; i++) {
@@ -679,7 +679,7 @@ acpi_ds_obj_stack_get_value (
        acpi_walk_state         *walk_state)
 {
 
-       FUNCTION_TRACE_PTR ("Ds_obj_stack_get_value", walk_state);
+       ACPI_FUNCTION_TRACE_PTR ("Ds_obj_stack_get_value", walk_state);
 
 
        /* Can't do it if the stack is empty */
@@ -704,31 +704,32 @@ acpi_ds_obj_stack_get_value (
  *
  * FUNCTION:    Acpi_ds_get_current_walk_state
  *
- * PARAMETERS:  Walk_list       - Get current active state for this walk list
+ * PARAMETERS:  Thread          - Get current active state for this Thread
  *
  * RETURN:      Pointer to the current walk state
  *
  * DESCRIPTION: Get the walk state that is at the head of the list (the "current"
- *              walk state.
+ *              walk state.)
  *
  ******************************************************************************/
 
 acpi_walk_state *
 acpi_ds_get_current_walk_state (
-       acpi_walk_list          *walk_list)
+       ACPI_THREAD_STATE       *thread)
 
 {
-       PROC_NAME ("Ds_get_current_walk_state");
+       ACPI_FUNCTION_NAME ("Ds_get_current_walk_state");
 
 
-       ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Ds_get_current_walk_state, =%p\n",
-               walk_list->walk_state));
-
-       if (!walk_list) {
+       if (!thread) {
                return (NULL);
        }
 
-       return (walk_list->walk_state);
+       ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Ds_get_current_walk_state, =%p\n",
+               thread->walk_state_list));
+
+
+       return (thread->walk_state_list);
 }
 
 
@@ -748,13 +749,13 @@ acpi_ds_get_current_walk_state (
 void
 acpi_ds_push_walk_state (
        acpi_walk_state         *walk_state,
-       acpi_walk_list          *walk_list)
+       ACPI_THREAD_STATE       *thread)
 {
-       FUNCTION_TRACE ("Ds_push_walk_state");
+       ACPI_FUNCTION_TRACE ("Ds_push_walk_state");
 
 
-       walk_state->next    = walk_list->walk_state;
-       walk_list->walk_state = walk_state;
+       walk_state->next      = thread->walk_state_list;
+       thread->walk_state_list = walk_state;
 
        return_VOID;
 }
@@ -776,25 +777,25 @@ acpi_ds_push_walk_state (
 
 acpi_walk_state *
 acpi_ds_pop_walk_state (
-       acpi_walk_list          *walk_list)
+       ACPI_THREAD_STATE       *thread)
 {
        acpi_walk_state         *walk_state;
 
 
-       FUNCTION_TRACE ("Ds_pop_walk_state");
+       ACPI_FUNCTION_TRACE ("Ds_pop_walk_state");
 
 
-       walk_state = walk_list->walk_state;
+       walk_state = thread->walk_state_list;
 
        if (walk_state) {
                /* Next walk state becomes the current walk state */
 
-               walk_list->walk_state = walk_state->next;
+               thread->walk_state_list = walk_state->next;
 
                /*
                 * Don't clear the NEXT field, this serves as an indicator
                 * that there is a parent WALK STATE
-                *     Walk_state->Next = NULL;
+                *     NO: Walk_state->Next = NULL;
                 */
        }
 
@@ -807,12 +808,12 @@ acpi_ds_pop_walk_state (
  * FUNCTION:    Acpi_ds_create_walk_state
  *
  * PARAMETERS:  Origin          - Starting point for this walk
- *              Walk_list       - Owning walk list
+ *              Thread          - Current thread state
  *
  * RETURN:      Pointer to the new walk state.
  *
- * DESCRIPTION: Allocate and initialize a new walk state.  The current walk state
- *              is set to this new state.
+ * DESCRIPTION: Allocate and initialize a new walk state.  The current walk
+ *              state is set to this new state.
  *
  ******************************************************************************/
 
@@ -821,13 +822,13 @@ acpi_ds_create_walk_state (
        acpi_owner_id           owner_id,
        acpi_parse_object       *origin,
        acpi_operand_object     *mth_desc,
-       acpi_walk_list          *walk_list)
+       ACPI_THREAD_STATE       *thread)
 {
        acpi_walk_state         *walk_state;
        acpi_status             status;
 
 
-       FUNCTION_TRACE ("Ds_create_walk_state");
+       ACPI_FUNCTION_TRACE ("Ds_create_walk_state");
 
 
        walk_state = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_WALK);
@@ -839,7 +840,7 @@ acpi_ds_create_walk_state (
        walk_state->owner_id        = owner_id;
        walk_state->origin          = origin;
        walk_state->method_desc     = mth_desc;
-       walk_state->walk_list       = walk_list;
+       walk_state->thread          = thread;
 
        /* Init the method args/local */
 
@@ -856,8 +857,8 @@ acpi_ds_create_walk_state (
 
        /* Put the new state at the head of the walk list */
 
-       if (walk_list) {
-               acpi_ds_push_walk_state (walk_state, walk_list);
+       if (thread) {
+               acpi_ds_push_walk_state (walk_state, thread);
        }
 
        return_PTR (walk_state);
@@ -892,7 +893,7 @@ acpi_ds_init_aml_walk (
        acpi_parse_state        *parser_state = &walk_state->parser_state;
 
 
-       FUNCTION_TRACE ("Ds_init_aml_walk");
+       ACPI_FUNCTION_TRACE ("Ds_init_aml_walk");
 
 
        walk_state->parser_state.aml    =
@@ -901,7 +902,6 @@ acpi_ds_init_aml_walk (
        walk_state->parser_state.pkg_end = aml_start + aml_length;
 
        /* The Next_op of the Next_walk will be the beginning of the method */
-       /* TBD: [Restructure] -- obsolete? */
 
        walk_state->next_op             = NULL;
        walk_state->params              = params;
@@ -914,7 +914,7 @@ acpi_ds_init_aml_walk (
 
        if (method_node) {
                walk_state->parser_state.start_node = method_node;
-               walk_state->walk_type               = WALK_METHOD;
+               walk_state->walk_type               = ACPI_WALK_METHOD;
                walk_state->method_node             = method_node;
                walk_state->method_desc             = acpi_ns_get_attached_object (method_node);
 
@@ -972,7 +972,7 @@ acpi_ds_delete_walk_state (
        acpi_generic_state      *state;
 
 
-       FUNCTION_TRACE_PTR ("Ds_delete_walk_state", walk_state);
+       ACPI_FUNCTION_TRACE_PTR ("Ds_delete_walk_state", walk_state);
 
 
        if (!walk_state) {
@@ -1038,7 +1038,7 @@ void
 acpi_ds_delete_walk_state_cache (
        void)
 {
-       FUNCTION_TRACE ("Ds_delete_walk_state_cache");
+       ACPI_FUNCTION_TRACE ("Ds_delete_walk_state_cache");
 
 
        acpi_ut_delete_generic_cache (ACPI_MEM_LIST_WALK);
diff --git a/drivers/acpi/driver.c b/drivers/acpi/driver.c
deleted file mode 100644 (file)
index 5868bca..0000000
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- *  driver.c - ACPI driver
- *
- *  Copyright (C) 2000 Andrew Henroid
- *  Copyright (C) 2001 Andrew Grover
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-/*
- * Changes
- * David Woodhouse <dwmw2@redhat.com> 2000-12-6
- * - Fix interruptible_sleep_on() races
- * Andrew Grover <andrew.grover@intel.com> 2001-2-28
- * - Major revamping
- * Peter Breuer <ptb@it.uc3m.es> 2001-5-20
- * - parse boot time params.
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/proc_fs.h>
-#include <linux/sysctl.h>
-#include <linux/pm.h>
-#include <linux/acpi.h>
-#include <asm/uaccess.h>
-#include "acpi.h"
-
-
-#define _COMPONENT     OS_DEPENDENT
-       MODULE_NAME     ("driver")
-
-FADT_DESCRIPTOR acpi_fadt;
-
-static int acpi_disabled = 0;
-
-enum acpi_blacklist_predicates
-{
-       all_versions,
-       less_than_or_equal,
-       equal,
-       greater_than_or_equal,
-};
-
-struct acpi_blacklist_item
-{
-       char oem_id[7];
-       char oem_table_id[9];
-       u32  oem_revision;
-       enum acpi_blacklist_predicates oem_revision_predicate;
-};
-
-/*
- * Currently, this blacklists based on items in the FADT. We may want to
- * expand this to using other ACPI tables in the future, too.
- */
-static struct acpi_blacklist_item acpi_blacklist[] __initdata = 
-{
-       {"TOSHIB", "750     ", 0x970814, less_than_or_equal}, /* Portege 7020, BIOS 8.10 */
-       {""}
-};
-
-int
-acpi_blacklisted(FADT_DESCRIPTOR *fadt)
-{
-       int i = 0;
-
-       while (acpi_blacklist[i].oem_id[0] != '\0')
-       {
-               if (strncmp(acpi_blacklist[i].oem_id, fadt->header.oem_id, 6)) {
-                       i++;
-                       continue;
-               }
-
-               if (strncmp(acpi_blacklist[i].oem_table_id, fadt->header.oem_table_id, 8)) {
-                       i++;
-                       continue;
-               }
-
-               if (acpi_blacklist[i].oem_revision_predicate == all_versions)
-                       return TRUE;
-
-               if (acpi_blacklist[i].oem_revision_predicate == less_than_or_equal
-                   && fadt->header.oem_revision <= acpi_blacklist[i].oem_revision)
-                       return TRUE;
-
-               if (acpi_blacklist[i].oem_revision_predicate == greater_than_or_equal
-                   && fadt->header.oem_revision >= acpi_blacklist[i].oem_revision)
-                       return TRUE;
-
-               if (acpi_blacklist[i].oem_revision_predicate == equal
-                   && fadt->header.oem_revision == acpi_blacklist[i].oem_revision)
-                       return TRUE;
-
-               i++;
-       }
-
-       return FALSE;
-}
-
-/*
- * Start the interpreter
- */
-int
-acpi_init(void)
-{
-       acpi_buffer             buffer;
-       acpi_system_info        sys_info;
-
-       if (PM_IS_ACTIVE()) {
-               printk(KERN_NOTICE "ACPI: APM is already active, exiting\n");
-               return -ENODEV;
-       }
-
-       if (acpi_disabled) {
-               printk(KERN_NOTICE "ACPI: disabled by cmdline, exiting\n");
-               return -ENODEV;
-       }
-
-       if (!ACPI_SUCCESS(acpi_initialize_subsystem())) {
-               printk(KERN_ERR "ACPI: Driver initialization failed\n");
-               return -ENODEV;
-       }
-
-       /* from this point on, on error we must call acpi_terminate() */
-       if (!ACPI_SUCCESS(acpi_load_tables())) {
-               printk(KERN_ERR "ACPI: System description table load failed\n");
-               acpi_terminate();
-               return -ENODEV;
-       }
-
-       /* get a separate copy of the FADT for use by other drivers */
-       memset(&acpi_fadt, 0, sizeof(acpi_fadt));
-       buffer.pointer = &acpi_fadt;
-       buffer.length = sizeof(acpi_fadt);
-
-       if (!ACPI_SUCCESS(acpi_get_table(ACPI_TABLE_FADT, 1, &buffer))) {
-               printk(KERN_ERR "ACPI: Could not get FADT\n");
-               acpi_terminate();
-               return -ENODEV;
-       }
-
-       if (acpi_blacklisted(&acpi_fadt)) {
-               printk(KERN_ERR "ACPI: On blacklist -- BIOS not fully ACPI compliant\n");
-               acpi_terminate();
-               return -ENODEV;
-       }
-
-       buffer.length  = sizeof(sys_info);
-       buffer.pointer = &sys_info;
-
-       if (!ACPI_SUCCESS (acpi_get_system_info(&buffer))) {
-               printk(KERN_ERR "ACPI: Could not get system info\n");
-               acpi_terminate();
-               return -ENODEV;
-       }
-
-       printk(KERN_INFO "ACPI: Core Subsystem version [%x]\n", sys_info.acpi_ca_version);
-
-       if (!ACPI_SUCCESS(acpi_enable_subsystem(ACPI_FULL_INITIALIZATION))) {
-               printk(KERN_ERR "ACPI: Subsystem enable failed\n");
-               acpi_terminate();
-               return -ENODEV;
-       }
-
-       printk(KERN_INFO "ACPI: Subsystem enabled\n");
-
-       pm_active = 1;
-
-       return 0;
-}
-
-/*
- * Terminate the interpreter
- */
-void
-acpi_exit(void)
-{
-       acpi_terminate();
-
-       pm_active = 0;
-
-       printk(KERN_ERR "ACPI: Subsystem disabled\n");
-}
-
-module_init(acpi_init);
-module_exit(acpi_exit);
-
-#ifndef MODULE
-static int __init acpi_setup(char *str) {
-       while (str && *str) {
-       if (strncmp(str, "off", 3) == 0)
-               acpi_disabled = 1;
-       str = strchr(str, ',');
-       if (str)
-               str += strspn(str, ", \t");
-       }
-       return 1;
-}
-
-__setup("acpi=", acpi_setup);
-#endif
index 0714c087172adf7cb040934c0602ec8c336b3ccd..d0bbc7655a46e95b304e00deeca0e7cf8e60f997 100644 (file)
@@ -1,11 +1,10 @@
 #
 # Makefile for all Linux ACPI interpreter subdirectories
-# EXCEPT for the ospm directory
 #
 
 O_TARGET := $(notdir $(CURDIR)).o
 
-obj-$(CONFIG_ACPI) := $(patsubst %.c,%.o,$(wildcard *.c))
+obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
 
index 2b7b8aa8ccc568b5cf6ab5582a8a2b6c8cd972c9..bf90a459a74d7b8a03091e1c284d866ad6f40d1f 100644 (file)
@@ -1,13 +1,12 @@
 /******************************************************************************
  *
- * Module Name: evevent - Fixed and General Purpose Acpi_event
- *                          handling and dispatch
- *              $Revision: 51 $
+ * Module Name: evevent - Fixed and General Purpose Even handling and dispatch
+ *              $Revision: 71 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -30,7 +29,7 @@
 #include "acnamesp.h"
 
 #define _COMPONENT          ACPI_EVENTS
-        MODULE_NAME         ("evevent")
+        ACPI_MODULE_NAME    ("evevent")
 
 
 /*******************************************************************************
@@ -41,9 +40,7 @@
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Ensures that the system control interrupt (SCI) is properly
- *              configured, disables SCI event sources, installs the SCI
- *              handler
+ * DESCRIPTION: Initialize global data structures for events.
  *
  ******************************************************************************/
 
@@ -54,7 +51,7 @@ acpi_ev_initialize (
        acpi_status             status;
 
 
-       FUNCTION_TRACE ("Ev_initialize");
+       ACPI_FUNCTION_TRACE ("Ev_initialize");
 
 
        /* Make sure we have ACPI tables */
@@ -64,17 +61,6 @@ acpi_ev_initialize (
                return_ACPI_STATUS (AE_NO_ACPI_TABLES);
        }
 
-
-       /* Make sure the BIOS supports ACPI mode */
-
-       if (SYS_MODE_LEGACY == acpi_hw_get_mode_capabilities()) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "ACPI Mode is not supported!\n"));
-               return_ACPI_STATUS (AE_ERROR);
-       }
-
-
-       acpi_gbl_original_mode = acpi_hw_get_mode();
-
        /*
         * Initialize the Fixed and General Purpose Acpi_events prior. This is
         * done prior to enabling SCIs to prevent interrupts from occuring
@@ -82,30 +68,63 @@ acpi_ev_initialize (
         */
        status = acpi_ev_fixed_event_initialize ();
        if (ACPI_FAILURE (status)) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_FATAL, "Unable to initialize fixed events.\n"));
+               ACPI_DEBUG_PRINT ((ACPI_DB_FATAL,
+                               "Unable to initialize fixed events, %s\n",
+                               acpi_format_exception (status)));
                return_ACPI_STATUS (status);
        }
 
        status = acpi_ev_gpe_initialize ();
        if (ACPI_FAILURE (status)) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_FATAL, "Unable to initialize general purpose events.\n"));
+               ACPI_DEBUG_PRINT ((ACPI_DB_FATAL,
+                               "Unable to initialize general purpose events, %s\n",
+                               acpi_format_exception (status)));
                return_ACPI_STATUS (status);
        }
 
+       return_ACPI_STATUS (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ev_handler_initialize
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Install handlers for the SCI, Global Lock, and GPEs.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ev_handler_initialize (
+       void)
+{
+       acpi_status             status;
+
+
+       ACPI_FUNCTION_TRACE ("Ev_initialize");
+
+
        /* Install the SCI handler */
 
        status = acpi_ev_install_sci_handler ();
        if (ACPI_FAILURE (status)) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_FATAL, "Unable to install System Control Interrupt Handler\n"));
+               ACPI_DEBUG_PRINT ((ACPI_DB_FATAL,
+                               "Unable to install System Control Interrupt Handler, %s\n",
+                               acpi_format_exception (status)));
                return_ACPI_STATUS (status);
        }
 
-
        /* Install handlers for control method GPE handlers (_Lxx, _Exx) */
 
        status = acpi_ev_init_gpe_control_methods ();
        if (ACPI_FAILURE (status)) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_FATAL, "Unable to initialize Gpe control methods\n"));
+               ACPI_DEBUG_PRINT ((ACPI_DB_FATAL,
+                               "Unable to initialize GPE control methods, %s\n",
+                               acpi_format_exception (status)));
                return_ACPI_STATUS (status);
        }
 
@@ -113,11 +132,12 @@ acpi_ev_initialize (
 
        status = acpi_ev_init_global_lock_handler ();
        if (ACPI_FAILURE (status)) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_FATAL, "Unable to initialize Global Lock handler\n"));
+               ACPI_DEBUG_PRINT ((ACPI_DB_FATAL,
+                               "Unable to initialize Global Lock handler, %s\n",
+                               acpi_format_exception (status)));
                return_ACPI_STATUS (status);
        }
 
-
        return_ACPI_STATUS (status);
 }
 
@@ -130,27 +150,32 @@ acpi_ev_initialize (
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Initialize the Fixed Acpi_event data structures
+ * DESCRIPTION: Install the fixed event handlers and enable the fixed events.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_ev_fixed_event_initialize(void)
+acpi_ev_fixed_event_initialize (
+       void)
 {
-       int                     i = 0;
+       NATIVE_UINT             i;
 
-       /* Initialize the structure that keeps track of fixed event handlers */
 
+       /*
+        * Initialize the structure that keeps track of fixed event handlers
+        * and enable the fixed events.
+        */
        for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
                acpi_gbl_fixed_event_handlers[i].handler = NULL;
                acpi_gbl_fixed_event_handlers[i].context = NULL;
-       }
 
-       acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_LOCK, TMR_EN, 0);
-       acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_LOCK, GBL_EN, 0);
-       acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_LOCK, PWRBTN_EN, 0);
-       acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_LOCK, SLPBTN_EN, 0);
-       acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_LOCK, RTC_EN, 0);
+               /* Enable the fixed event */
+
+               if (acpi_gbl_fixed_event_info[i].enable_register_id != 0xFF) {
+                       acpi_hw_bit_register_write (acpi_gbl_fixed_event_info[i].enable_register_id,
+                                        0, ACPI_MTX_LOCK);
+               }
+       }
 
        return (AE_OK);
 }
@@ -169,54 +194,41 @@ acpi_ev_fixed_event_initialize(void)
  ******************************************************************************/
 
 u32
-acpi_ev_fixed_event_detect (void)
+acpi_ev_fixed_event_detect (
+       void)
 {
-       u32                     int_status = INTERRUPT_NOT_HANDLED;
-       u32                     status_register;
-       u32                     enable_register;
+       u32                     int_status = ACPI_INTERRUPT_NOT_HANDLED;
+       u32                     gpe_status;
+       u32                     gpe_enable;
+       NATIVE_UINT             i;
 
 
-       PROC_NAME ("Ev_fixed_event_detect");
+       ACPI_FUNCTION_NAME ("Ev_fixed_event_detect");
 
 
        /*
         * Read the fixed feature status and enable registers, as all the cases
         * depend on their values.
         */
-       status_register = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, PM1_STS);
-       enable_register = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, PM1_EN);
+       gpe_status = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_STATUS);
+       gpe_enable = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_ENABLE);
 
        ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS,
                "Fixed Acpi_event Block: Enable %08X Status %08X\n",
-               enable_register, status_register));
-
-
-       /* power management timer roll over */
-
-       if ((status_register & ACPI_STATUS_PMTIMER) &&
-               (enable_register & ACPI_ENABLE_PMTIMER)) {
-               int_status |= acpi_ev_fixed_event_dispatch (ACPI_EVENT_PMTIMER);
-       }
-
-       /* global event (BIOS wants the global lock) */
-
-       if ((status_register & ACPI_STATUS_GLOBAL) &&
-               (enable_register & ACPI_ENABLE_GLOBAL)) {
-               int_status |= acpi_ev_fixed_event_dispatch (ACPI_EVENT_GLOBAL);
-       }
-
-       /* power button event */
+               gpe_enable, gpe_status));
 
-       if ((status_register & ACPI_STATUS_POWER_BUTTON) &&
-               (enable_register & ACPI_ENABLE_POWER_BUTTON)) {
-               int_status |= acpi_ev_fixed_event_dispatch (ACPI_EVENT_POWER_BUTTON);
-       }
+       /*
+        * Check for all possible Fixed Events and dispatch those that are active
+        */
+       for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
+               /* Both the status and enable bits must be on for this event */
 
-       /* sleep button event */
+               if ((gpe_status & acpi_gbl_fixed_event_info[i].status_bit_mask) &&
+                       (gpe_enable & acpi_gbl_fixed_event_info[i].enable_bit_mask)) {
+                       /* Found an active (signalled) event */
 
-       if ((status_register & ACPI_STATUS_SLEEP_BUTTON) &&
-               (enable_register & ACPI_ENABLE_SLEEP_BUTTON)) {
-               int_status |= acpi_ev_fixed_event_dispatch (ACPI_EVENT_SLEEP_BUTTON);
+                       int_status |= acpi_ev_fixed_event_dispatch (i);
+               }
        }
 
        return (int_status);
@@ -240,60 +252,32 @@ u32
 acpi_ev_fixed_event_dispatch (
        u32                     event)
 {
-       u32                     register_id;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        /* Clear the status bit */
 
-       switch (event) {
-       case ACPI_EVENT_PMTIMER:
-               register_id = TMR_STS;
-               break;
-
-       case ACPI_EVENT_GLOBAL:
-               register_id = GBL_STS;
-               break;
-
-       case ACPI_EVENT_POWER_BUTTON:
-               register_id = PWRBTN_STS;
-               break;
-
-       case ACPI_EVENT_SLEEP_BUTTON:
-               register_id = SLPBTN_STS;
-               break;
-
-       case ACPI_EVENT_RTC:
-               register_id = RTC_STS;
-               break;
-
-       default:
-               return 0;
-               break;
-       }
-
-       acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_DO_NOT_LOCK, register_id, 1);
+       acpi_hw_bit_register_write (acpi_gbl_fixed_event_info[event].status_register_id,
+                        1, ACPI_MTX_DO_NOT_LOCK);
 
        /*
         * Make sure we've got a handler.  If not, report an error.
         * The event is disabled to prevent further interrupts.
         */
        if (NULL == acpi_gbl_fixed_event_handlers[event].handler) {
-               register_id = (PM1_EN | REGISTER_BIT_ID(register_id));
+               acpi_hw_bit_register_write (acpi_gbl_fixed_event_info[event].enable_register_id,
+                               0, ACPI_MTX_DO_NOT_LOCK);
 
-               acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_DO_NOT_LOCK,
-                                register_id, 0);
-
-               REPORT_ERROR (
+               ACPI_REPORT_ERROR (
                        ("Ev_gpe_dispatch: No installed handler for fixed event [%08X]\n",
                        event));
 
-               return (INTERRUPT_NOT_HANDLED);
+               return (ACPI_INTERRUPT_NOT_HANDLED);
        }
 
-       /* Invoke the handler */
+       /* Invoke the Fixed Event handler */
 
        return ((acpi_gbl_fixed_event_handlers[event].handler)(
                          acpi_gbl_fixed_event_handlers[event].context));
@@ -315,138 +299,171 @@ acpi_ev_fixed_event_dispatch (
 acpi_status
 acpi_ev_gpe_initialize (void)
 {
-       u32                     i;
-       u32                     j;
-       u32                     register_index;
+       NATIVE_UINT             i;
+       NATIVE_UINT             j;
+       NATIVE_UINT             gpe_block;
+       u32                     gpe_register;
+       u32                     gpe_number_index;
        u32                     gpe_number;
-       u16                     gpe0register_count;
-       u16                     gpe1_register_count;
+       ACPI_GPE_REGISTER_INFO  *gpe_register_info;
+
 
+       ACPI_FUNCTION_TRACE ("Ev_gpe_initialize");
 
-       FUNCTION_TRACE ("Ev_gpe_initialize");
 
        /*
-        * Set up various GPE counts
+        * Initialize the GPE Block globals
         *
-        * You may ask,why are the GPE register block lengths divided by 2?
-        * From the ACPI 2.0 Spec, section, 4.7.1.6 General-Purpose Event
-        * Registers, we have,
+        * Why the GPE register block lengths divided by 2:  From the ACPI Spec,
+        * section "General-Purpose Event Registers", we have:
         *
         * "Each register block contains two registers of equal length
-        * GPEx_STS and GPEx_EN (where x is 0 or 1). The length of the
-        * GPE0_STS and GPE0_EN registers is equal to half the GPE0_LEN
-        * The length of the GPE1_STS and GPE1_EN registers is equal to
-        * half the GPE1_LEN. If a generic register block is not supported
-        * then its respective block pointer and block length values in the
-        * FADT table contain zeros. The GPE0_LEN and GPE1_LEN do not need
-        * to be the same size."
+        *  GPEx_STS and GPEx_EN (where x is 0 or 1). The length of the
+        *  GPE0_STS and GPE0_EN registers is equal to half the GPE0_LEN
+        *  The length of the GPE1_STS and GPE1_EN registers is equal to
+        *  half the GPE1_LEN. If a generic register block is not supported
+        *  then its respective block pointer and block length values in the
+        *  FADT table contain zeros. The GPE0_LEN and GPE1_LEN do not need
+        *  to be the same size."
         */
-       gpe0register_count          = (u16) DIV_2 (acpi_gbl_FADT->gpe0blk_len);
-       gpe1_register_count         = (u16) DIV_2 (acpi_gbl_FADT->gpe1_blk_len);
-       acpi_gbl_gpe_register_count = gpe0register_count + gpe1_register_count;
+       acpi_gbl_gpe_block_info[0].register_count = (u16) ACPI_DIV_2 (acpi_gbl_FADT->gpe0_blk_len);
+       acpi_gbl_gpe_block_info[1].register_count = (u16) ACPI_DIV_2 (acpi_gbl_FADT->gpe1_blk_len);
+
+       acpi_gbl_gpe_block_info[0].block_address = (u16) ACPI_GET_ADDRESS (acpi_gbl_FADT->Xgpe0_blk.address);
+       acpi_gbl_gpe_block_info[1].block_address = (u16) ACPI_GET_ADDRESS (acpi_gbl_FADT->Xgpe1_blk.address);
 
+       acpi_gbl_gpe_block_info[0].block_base_number = 0;
+       acpi_gbl_gpe_block_info[1].block_base_number = acpi_gbl_FADT->gpe1_base;
+
+       acpi_gbl_gpe_register_count = acpi_gbl_gpe_block_info[0].register_count +
+                        acpi_gbl_gpe_block_info[1].register_count;
        if (!acpi_gbl_gpe_register_count) {
-               REPORT_WARNING (("Zero GPEs are defined in the FADT\n"));
+               ACPI_REPORT_WARNING (("Zero GPEs are defined in the FADT\n"));
                return_ACPI_STATUS (AE_OK);
        }
 
+       /* Determine the maximum GPE number for this machine */
+
+       acpi_gbl_gpe_number_max = ACPI_MUL_8 (acpi_gbl_gpe_block_info[0].register_count) - 1;
+
+       if (acpi_gbl_gpe_block_info[1].register_count) {
+               /* Check for GPE0/GPE1 overlap */
+
+               if (acpi_gbl_gpe_number_max >= acpi_gbl_FADT->gpe1_base) {
+                       ACPI_REPORT_ERROR (("GPE0 block overlaps the GPE1 block\n"));
+                       return_ACPI_STATUS (AE_BAD_VALUE);
+               }
+
+               /* GPE0 and GPE1 do not have to be contiguous in the GPE number space */
+
+               acpi_gbl_gpe_number_max = acpi_gbl_FADT->gpe1_base + (ACPI_MUL_8 (acpi_gbl_gpe_block_info[1].register_count) - 1);
+       }
+
+       /* Check for Max GPE number out-of-range */
+
+       if (acpi_gbl_gpe_number_max > ACPI_GPE_MAX) {
+               ACPI_REPORT_ERROR (("Maximum GPE number from FADT is too large: 0x%X\n", acpi_gbl_gpe_number_max));
+               return_ACPI_STATUS (AE_BAD_VALUE);
+       }
+
        /*
-        * Allocate the Gpe information block
+        * Allocate the GPE number-to-index translation table
         */
-       acpi_gbl_gpe_registers = ACPI_MEM_CALLOCATE (acpi_gbl_gpe_register_count *
-                         sizeof (acpi_gpe_registers));
-       if (!acpi_gbl_gpe_registers) {
+       acpi_gbl_gpe_number_to_index = ACPI_MEM_CALLOCATE (sizeof (ACPI_GPE_INDEX_INFO) *
+                          (acpi_gbl_gpe_number_max + 1));
+       if (!acpi_gbl_gpe_number_to_index) {
                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-                       "Could not allocate the Gpe_registers block\n"));
+                       "Could not allocate the Gpe_number_to_index table\n"));
                return_ACPI_STATUS (AE_NO_MEMORY);
        }
 
+       /* Set the Gpe index table to GPE_INVALID */
+
+       ACPI_MEMSET (acpi_gbl_gpe_number_to_index, (int) ACPI_GPE_INVALID,
+                       sizeof (ACPI_GPE_INDEX_INFO) * (acpi_gbl_gpe_number_max + 1));
+
        /*
-        * Allocate the Gpe dispatch handler block
-        * There are eight distinct GP events per register.
-        * Initialization to zeros is sufficient
+        * Allocate the GPE register information block
         */
-       acpi_gbl_gpe_info = ACPI_MEM_CALLOCATE (MUL_8 (acpi_gbl_gpe_register_count) *
-                         sizeof (acpi_gpe_level_info));
-       if (!acpi_gbl_gpe_info) {
-               ACPI_MEM_FREE (acpi_gbl_gpe_registers);
-               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not allocate the Gpe_info block\n"));
-               return_ACPI_STATUS (AE_NO_MEMORY);
+       acpi_gbl_gpe_register_info = ACPI_MEM_CALLOCATE (acpi_gbl_gpe_register_count *
+                         sizeof (ACPI_GPE_REGISTER_INFO));
+       if (!acpi_gbl_gpe_register_info) {
+               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+                       "Could not allocate the Gpe_register_info table\n"));
+               goto error_exit1;
        }
 
-       /* Set the Gpe validation table to GPE_INVALID */
-
-       MEMSET (acpi_gbl_gpe_valid, (int) ACPI_GPE_INVALID, ACPI_NUM_GPE);
+       /*
+        * Allocate the GPE dispatch handler block.  There are eight distinct GPEs
+        * per register.  Initialization to zeros is sufficient.
+        */
+       acpi_gbl_gpe_number_info = ACPI_MEM_CALLOCATE (ACPI_MUL_8 (acpi_gbl_gpe_register_count) *
+                         sizeof (ACPI_GPE_NUMBER_INFO));
+       if (!acpi_gbl_gpe_number_info) {
+               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not allocate the Gpe_number_info table\n"));
+               goto error_exit2;
+       }
 
        /*
-        * Initialize the Gpe information and validation blocks.  A goal of these
-        * blocks is to hide the fact that there are two separate GPE register sets
-        * In a given block, the status registers occupy the first half, and
-        * the enable registers occupy the second half.
+        * Initialize the GPE information and validation tables.  A goal of these
+        * tables is to hide the fact that there are two separate GPE register sets
+        * in a given gpe hardware block, the status registers occupy the first half,
+        * and the enable registers occupy the second half.  Another goal is to hide
+        * the fact that there may be multiple GPE hardware blocks.
         */
+       gpe_register = 0;
+       gpe_number_index = 0;
 
-       /* GPE Block 0 */
+       for (gpe_block = 0; gpe_block < ACPI_MAX_GPE_BLOCKS; gpe_block++) {
+               for (i = 0; i < acpi_gbl_gpe_block_info[gpe_block].register_count; i++) {
+                       gpe_register_info = &acpi_gbl_gpe_register_info[gpe_register];
 
-       register_index = 0;
+                       /* Init the Register info for this entire GPE register (8 GPEs) */
 
-       for (i = 0; i < gpe0register_count; i++) {
-               acpi_gbl_gpe_registers[register_index].status_addr =
-                                (u16) (ACPI_GET_ADDRESS (acpi_gbl_FADT->Xgpe0blk.address) + i);
+                       gpe_register_info->base_gpe_number = (u8) (acpi_gbl_gpe_block_info[gpe_block].block_base_number + (ACPI_MUL_8 (i)));
+                       gpe_register_info->status_addr = (u16) (acpi_gbl_gpe_block_info[gpe_block].block_address + i);
+                       gpe_register_info->enable_addr = (u16) (acpi_gbl_gpe_block_info[gpe_block].block_address + i +
+                                         acpi_gbl_gpe_block_info[gpe_block].register_count);
 
-               acpi_gbl_gpe_registers[register_index].enable_addr =
-                                (u16) (ACPI_GET_ADDRESS (acpi_gbl_FADT->Xgpe0blk.address) + i + gpe0register_count);
+                       /* Init the Index mapping info for each GPE number within this register */
 
-               acpi_gbl_gpe_registers[register_index].gpe_base = (u8) MUL_8 (i);
+                       for (j = 0; j < 8; j++) {
+                               gpe_number = gpe_register_info->base_gpe_number + j;
+                               acpi_gbl_gpe_number_to_index[gpe_number].number_index = (u8) gpe_number_index;
 
-               for (j = 0; j < 8; j++) {
-                       gpe_number = acpi_gbl_gpe_registers[register_index].gpe_base + j;
-                       acpi_gbl_gpe_valid[gpe_number] = (u8) register_index;
-               }
+                               acpi_gbl_gpe_number_info[gpe_number_index].bit_mask = acpi_gbl_decode_to8bit[j];
+                               gpe_number_index++;
+                       }
 
-               /*
-                * Clear the status/enable registers.  Note that status registers
-                * are cleared by writing a '1', while enable registers are cleared
-                * by writing a '0'.
-                */
-               acpi_os_write_port (acpi_gbl_gpe_registers[register_index].enable_addr, 0x00, 8);
-               acpi_os_write_port (acpi_gbl_gpe_registers[register_index].status_addr, 0xFF, 8);
+                       /*
+                        * Clear the status/enable registers.  Note that status registers
+                        * are cleared by writing a '1', while enable registers are cleared
+                        * by writing a '0'.
+                        */
+                       acpi_os_write_port (gpe_register_info->enable_addr, 0x00, 8);
+                       acpi_os_write_port (gpe_register_info->status_addr, 0xFF, 8);
 
-               register_index++;
+                       gpe_register++;
+               }
        }
 
-       /* GPE Block 1 */
-
-       for (i = 0; i < gpe1_register_count; i++) {
-               acpi_gbl_gpe_registers[register_index].status_addr =
-                                (u16) (ACPI_GET_ADDRESS (acpi_gbl_FADT->Xgpe1_blk.address) + i);
+       ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "GPE registers: %X@%8.8X%8.8X (Blk0) %X@%8.8X%8.8X (Blk1)\n",
+               acpi_gbl_gpe_block_info[0].register_count,
+               ACPI_HIDWORD (acpi_gbl_FADT->Xgpe0_blk.address), ACPI_LODWORD (acpi_gbl_FADT->Xgpe0_blk.address),
+               acpi_gbl_gpe_block_info[1].register_count,
+               ACPI_HIDWORD (acpi_gbl_FADT->Xgpe1_blk.address), ACPI_LODWORD (acpi_gbl_FADT->Xgpe1_blk.address)));
 
-               acpi_gbl_gpe_registers[register_index].enable_addr =
-                                (u16) (ACPI_GET_ADDRESS (acpi_gbl_FADT->Xgpe1_blk.address) + i + gpe1_register_count);
+       return_ACPI_STATUS (AE_OK);
 
-               acpi_gbl_gpe_registers[register_index].gpe_base =
-                                (u8) (acpi_gbl_FADT->gpe1_base + MUL_8 (i));
 
-               for (j = 0; j < 8; j++) {
-                       gpe_number = acpi_gbl_gpe_registers[register_index].gpe_base + j;
-                       acpi_gbl_gpe_valid[gpe_number] = (u8) register_index;
-               }
+       /* Error cleanup */
 
-               /*
-                * Clear the status/enable registers.  Note that status registers
-                * are cleared by writing a '1', while enable registers are cleared
-                * by writing a '0'.
-                */
-               acpi_os_write_port (acpi_gbl_gpe_registers[register_index].enable_addr, 0x00, 8);
-               acpi_os_write_port (acpi_gbl_gpe_registers[register_index].status_addr, 0xFF, 8);
+error_exit2:
+       ACPI_MEM_FREE (acpi_gbl_gpe_register_info);
 
-               register_index++;
-       }
-
-       ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "GPE registers: %X@%8.8X%8.8X (Blk0) %X@%8.8X%8.8X (Blk1)\n",
-               gpe0register_count, HIDWORD(acpi_gbl_FADT->Xgpe0blk.address), LODWORD(acpi_gbl_FADT->Xgpe0blk.address),
-               gpe1_register_count, HIDWORD(acpi_gbl_FADT->Xgpe1_blk.address), LODWORD(acpi_gbl_FADT->Xgpe1_blk.address)));
-
-       return_ACPI_STATUS (AE_OK);
+error_exit1:
+       ACPI_MEM_FREE (acpi_gbl_gpe_number_to_index);
+       return_ACPI_STATUS (AE_NO_MEMORY);
 }
 
 
@@ -468,7 +485,7 @@ acpi_ev_gpe_initialize (void)
  *              Where:
  *                  L      - means that the GPE is level triggered
  *                  E      - means that the GPE is edge triggered
- *                  nn     - is the GPE number
+ *                  nn     - is the GPE number [in HEX]
  *
  ******************************************************************************/
 
@@ -480,28 +497,33 @@ acpi_ev_save_method_info (
        void                    **return_value)
 {
        u32                     gpe_number;
+       u32                     gpe_number_index;
        NATIVE_CHAR             name[ACPI_NAME_SIZE + 1];
        u8                      type;
 
 
-       PROC_NAME ("Ev_save_method_info");
+       ACPI_FUNCTION_NAME ("Ev_save_method_info");
 
 
        /* Extract the name from the object and convert to a string */
 
-       MOVE_UNALIGNED32_TO_32 (name, &((acpi_namespace_node *) obj_handle)->name);
+       ACPI_MOVE_UNALIGNED32_TO_32 (name,
+                         &((acpi_namespace_node *) obj_handle)->name);
        name[ACPI_NAME_SIZE] = 0;
 
        /*
-        * Edge/Level determination is based on the 2nd s8 of the method name
+        * Edge/Level determination is based on the 2nd character of the method name
         */
-       if (name[1] == 'L') {
+       switch (name[1]) {
+       case 'L':
                type = ACPI_EVENT_LEVEL_TRIGGERED;
-       }
-       else if (name[1] == 'E') {
+               break;
+
+       case 'E':
                type = ACPI_EVENT_EDGE_TRIGGERED;
-       }
-       else {
+               break;
+
+       default:
                /* Unknown method type, just ignore it! */
 
                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
@@ -510,9 +532,9 @@ acpi_ev_save_method_info (
                return (AE_OK);
        }
 
-       /* Convert the last two characters of the name to the Gpe Number */
+       /* Convert the last two characters of the name to the GPE Number */
 
-       gpe_number = STRTOUL (&name[2], NULL, 16);
+       gpe_number = ACPI_STRTOUL (&name[2], NULL, 16);
        if (gpe_number == ACPI_UINT32_MAX) {
                /* Conversion failed; invalid method, just ignore it */
 
@@ -522,9 +544,10 @@ acpi_ev_save_method_info (
                return (AE_OK);
        }
 
-       /* Ensure that we have a valid GPE number */
+       /* Get GPE index and ensure that we have a valid GPE number */
 
-       if (acpi_gbl_gpe_valid[gpe_number] == ACPI_GPE_INVALID) {
+       gpe_number_index = acpi_ev_get_gpe_number_index (gpe_number);
+       if (gpe_number_index == ACPI_GPE_INVALID) {
                /* Not valid, all we can do here is ignore it */
 
                return (AE_OK);
@@ -534,9 +557,8 @@ acpi_ev_save_method_info (
         * Now we can add this information to the Gpe_info block
         * for use during dispatch of this GPE.
         */
-       acpi_gbl_gpe_info [gpe_number].type         = type;
-       acpi_gbl_gpe_info [gpe_number].method_handle = obj_handle;
-
+       acpi_gbl_gpe_number_info [gpe_number_index].type    = type;
+       acpi_gbl_gpe_number_info [gpe_number_index].method_handle = obj_handle;
 
        /*
         * Enable the GPE (SCIs should be disabled at this point)
@@ -555,10 +577,9 @@ acpi_ev_save_method_info (
  *
  * PARAMETERS:  None
  *
- * RETURN:      None
+ * RETURN:      Status
  *
  * DESCRIPTION: Obtain the control methods associated with the GPEs.
- *
  *              NOTE: Must be called AFTER namespace initialization!
  *
  ******************************************************************************/
@@ -569,7 +590,7 @@ acpi_ev_init_gpe_control_methods (void)
        acpi_status             status;
 
 
-       FUNCTION_TRACE ("Ev_init_gpe_control_methods");
+       ACPI_FUNCTION_TRACE ("Ev_init_gpe_control_methods");
 
 
        /* Get a permanent handle to the _GPE object */
@@ -597,21 +618,23 @@ acpi_ev_init_gpe_control_methods (void)
  *
  * RETURN:      INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
  *
- * DESCRIPTION: Detect if any GP events have occurred
+ * DESCRIPTION: Detect if any GP events have occurred.  This function is
+ *              executed at interrupt level.
  *
  ******************************************************************************/
 
 u32
 acpi_ev_gpe_detect (void)
 {
-       u32                     int_status = INTERRUPT_NOT_HANDLED;
+       u32                     int_status = ACPI_INTERRUPT_NOT_HANDLED;
        u32                     i;
        u32                     j;
        u8                      enabled_status_byte;
        u8                      bit_mask;
+       ACPI_GPE_REGISTER_INFO  *gpe_register_info;
 
 
-       PROC_NAME ("Ev_gpe_detect");
+       ACPI_FUNCTION_NAME ("Ev_gpe_detect");
 
 
        /*
@@ -620,23 +643,24 @@ acpi_ev_gpe_detect (void)
         * Find all currently active GP events.
         */
        for (i = 0; i < acpi_gbl_gpe_register_count; i++) {
-               acpi_os_read_port (acpi_gbl_gpe_registers[i].status_addr,
-                               &acpi_gbl_gpe_registers[i].status, 8);
+               gpe_register_info = &acpi_gbl_gpe_register_info[i];
+
+               acpi_os_read_port (gpe_register_info->status_addr,
+                                 &gpe_register_info->status, 8);
 
-               acpi_os_read_port (acpi_gbl_gpe_registers[i].enable_addr,
-                               &acpi_gbl_gpe_registers[i].enable, 8);
+               acpi_os_read_port (gpe_register_info->enable_addr,
+                                 &gpe_register_info->enable, 8);
 
                ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS,
                        "GPE block at %X - Enable %08X Status %08X\n",
-                       acpi_gbl_gpe_registers[i].enable_addr,
-                       acpi_gbl_gpe_registers[i].status,
-                       acpi_gbl_gpe_registers[i].enable));
+                       gpe_register_info->enable_addr,
+                       gpe_register_info->status,
+                       gpe_register_info->enable));
 
                /* First check if there is anything active at all in this register */
 
-               enabled_status_byte = (u8) (acpi_gbl_gpe_registers[i].status &
-                                  acpi_gbl_gpe_registers[i].enable);
-
+               enabled_status_byte = (u8) (gpe_register_info->status &
+                                  gpe_register_info->enable);
                if (!enabled_status_byte) {
                        /* No active GPEs in this register, move on */
 
@@ -654,7 +678,7 @@ acpi_ev_gpe_detect (void)
                                 * or method.
                                 */
                                int_status |= acpi_ev_gpe_dispatch (
-                                                 acpi_gbl_gpe_registers[i].gpe_base + j);
+                                                 gpe_register_info->base_gpe_number + j);
                        }
                }
        }
@@ -667,7 +691,7 @@ acpi_ev_gpe_detect (void)
  *
  * FUNCTION:    Acpi_ev_asynch_execute_gpe_method
  *
- * PARAMETERS:  Gpe_number      - The 0-based Gpe number
+ * PARAMETERS:  Gpe_number      - The 0-based GPE number
  *
  * RETURN:      None
  *
@@ -679,38 +703,49 @@ acpi_ev_gpe_detect (void)
  *
  ******************************************************************************/
 
-static void
+static void ACPI_SYSTEM_XFACE
 acpi_ev_asynch_execute_gpe_method (
        void                    *context)
 {
-       u32                     gpe_number = (u32) context;
-       acpi_gpe_level_info     gpe_info;
+       u32                     gpe_number = (u32) ACPI_TO_INTEGER (context);
+       u32                     gpe_number_index;
+       ACPI_GPE_NUMBER_INFO    gpe_info;
 
 
-       FUNCTION_TRACE ("Ev_asynch_execute_gpe_method");
+       ACPI_FUNCTION_TRACE ("Ev_asynch_execute_gpe_method");
 
-       /*
-        * Take a snapshot of the GPE info for this level
-        */
-       acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
-       gpe_info = acpi_gbl_gpe_info [gpe_number];
-       acpi_ut_release_mutex (ACPI_MTX_EVENTS);
+
+       gpe_number_index = acpi_ev_get_gpe_number_index (gpe_number);
+       if (gpe_number_index == ACPI_GPE_INVALID) {
+               return_VOID;
+       }
 
        /*
-        * Method Handler (_Lxx, _Exx):
-        * ----------------------------
-        * Evaluate the _Lxx/_Exx control method that corresponds to this GPE.
+        * Take a snapshot of the GPE info for this level - we copy the
+        * info to prevent a race condition with Remove_handler.
         */
+       if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_EVENTS))) {
+               return_VOID;
+       }
+
+       gpe_info = acpi_gbl_gpe_number_info [gpe_number_index];
+       if (ACPI_FAILURE (acpi_ut_release_mutex (ACPI_MTX_EVENTS))) {
+               return_VOID;
+       }
+
        if (gpe_info.method_handle) {
+               /*
+                * Invoke the GPE Method (_Lxx, _Exx):
+                * (Evaluate the _Lxx/_Exx control method that corresponds to this GPE.)
+                */
                acpi_ns_evaluate_by_handle (gpe_info.method_handle, NULL, NULL);
        }
 
-       /*
-        * Level-Triggered?
-        * ----------------
-        * If level-triggered we clear the GPE status bit after handling the event.
-        */
        if (gpe_info.type & ACPI_EVENT_LEVEL_TRIGGERED) {
+               /*
+                * GPE is level-triggered, we clear the GPE status bit after handling
+                * the event.
+                */
                acpi_hw_clear_gpe (gpe_number);
        }
 
@@ -718,7 +753,6 @@ acpi_ev_asynch_execute_gpe_method (
         * Enable the GPE.
         */
        acpi_hw_enable_gpe (gpe_number);
-
        return_VOID;
 }
 
@@ -727,18 +761,13 @@ acpi_ev_asynch_execute_gpe_method (
  *
  * FUNCTION:    Acpi_ev_gpe_dispatch
  *
- * PARAMETERS:  Gpe_number      - The 0-based Gpe number
+ * PARAMETERS:  Gpe_number      - The 0-based GPE number
  *
  * RETURN:      INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
  *
- * DESCRIPTION: Handle and dispatch a General Purpose Acpi_event.
- *              Clears the status bit for the requested event.
- *
- * TBD: [Investigate] is this still valid or necessary:
- * The Gpe handler differs from the fixed events in that it clears the enable
- * bit rather than the status bit to clear the interrupt.  This allows
- * software outside of interrupt context to determine what caused the SCI and
- * dispatch the correct AML.
+ * DESCRIPTION: Dispatch a General Purpose Event to either a function (e.g. EC)
+ *              or method (e.g. _Lxx/_Exx) handler.  This function executes
+ *              at interrupt level.
  *
  ******************************************************************************/
 
@@ -746,82 +775,79 @@ u32
 acpi_ev_gpe_dispatch (
        u32                     gpe_number)
 {
-       acpi_gpe_level_info     gpe_info;
+       u32                     gpe_number_index;
+       ACPI_GPE_NUMBER_INFO    *gpe_info;
 
 
-       FUNCTION_TRACE ("Ev_gpe_dispatch");
+       ACPI_FUNCTION_TRACE ("Ev_gpe_dispatch");
 
 
-       /*
-        * Valid GPE number?
-        */
-       if (acpi_gbl_gpe_valid[gpe_number] == ACPI_GPE_INVALID) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid GPE bit [%X].\n", gpe_number));
-               return_VALUE (INTERRUPT_NOT_HANDLED);
+       gpe_number_index = acpi_ev_get_gpe_number_index (gpe_number);
+       if (gpe_number_index == ACPI_GPE_INVALID) {
+               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid event, GPE[%X].\n", gpe_number));
+               return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
        }
 
        /*
-        * Disable the GPE.
+        * We don't have to worry about mutex on Gpe_info because we are
+        * executing at interrupt level.
         */
-       acpi_hw_disable_gpe (gpe_number);
-
-       gpe_info = acpi_gbl_gpe_info [gpe_number];
+       gpe_info = &acpi_gbl_gpe_number_info [gpe_number_index];
 
        /*
-        * Edge-Triggered?
-        * ---------------
         * If edge-triggered, clear the GPE status bit now.  Note that
         * level-triggered events are cleared after the GPE is serviced.
         */
-       if (gpe_info.type & ACPI_EVENT_EDGE_TRIGGERED) {
+       if (gpe_info->type & ACPI_EVENT_EDGE_TRIGGERED) {
                acpi_hw_clear_gpe (gpe_number);
        }
-               /*
-                * Function Handler (e.g. EC)?
-                */
-       if (gpe_info.handler) {
-               /* Invoke function handler (at interrupt level). */
-
-               gpe_info.handler (gpe_info.context);
 
-               /* Level-Triggered? */
-
-               if (gpe_info.type & ACPI_EVENT_LEVEL_TRIGGERED) {
-                       acpi_hw_clear_gpe (gpe_number);
-               }
-
-               /* Enable GPE */
+       /*
+        * Dispatch the GPE to either an installed handler, or the control
+        * method associated with this GPE (_Lxx or _Exx).
+        * If a handler exists, we invoke it and do not attempt to run the method.
+        * If there is neither a handler nor a method, we disable the level to
+        * prevent further events from coming in here.
+        */
+       if (gpe_info->handler) {
+               /* Invoke the installed handler (at interrupt level) */
 
-               acpi_hw_enable_gpe (gpe_number);
+               gpe_info->handler (gpe_info->context);
        }
+       else if (gpe_info->method_handle) {
+               /*
+                * Execute the method associated with the GPE.
+                */
+               if (ACPI_FAILURE (acpi_os_queue_for_execution (OSD_PRIORITY_GPE,
+                                acpi_ev_asynch_execute_gpe_method,
+                                ACPI_TO_POINTER (gpe_number)))) {
+                       ACPI_REPORT_ERROR (("Acpi_ev_gpe_dispatch: Unable to queue handler for GPE[%X], disabling event\n", gpe_number));
 
-       /*
-        * Method Handler (e.g. _Exx/_Lxx)?
-        */
-       else if (gpe_info.method_handle) {
-               if (ACPI_FAILURE(acpi_os_queue_for_execution (OSD_PRIORITY_GPE,
-                       acpi_ev_asynch_execute_gpe_method, (void*) gpe_number))) {
                        /*
-                        * Shoudn't occur, but if it does report an error. Note that
-                        * the GPE will remain disabled until the ACPI Core Subsystem
-                        * is restarted, or the handler is removed/reinstalled.
+                        * Disable the GPE on error.  The GPE will remain disabled until the ACPI
+                        * Core Subsystem is restarted, or the handler is reinstalled.
                         */
-                       REPORT_ERROR (("Acpi_ev_gpe_dispatch: Unable to queue handler for GPE bit [%X]\n", gpe_number));
+                       acpi_hw_disable_gpe (gpe_number);
                }
        }
-
-       /*
-        * No Handler? Report an error and leave the GPE disabled.
-        */
        else {
-               REPORT_ERROR (("Acpi_ev_gpe_dispatch: No installed handler for GPE [%X]\n", gpe_number));
+               /* No handler or method to run! */
 
-               /* Level-Triggered? */
+               ACPI_REPORT_ERROR (("Acpi_ev_gpe_dispatch: No handler or method for GPE[%X], disabling event\n", gpe_number));
 
-               if (gpe_info.type & ACPI_EVENT_LEVEL_TRIGGERED) {
-                       acpi_hw_clear_gpe (gpe_number);
-               }
+               /*
+                * Disable the GPE.  The GPE will remain disabled until the ACPI
+                * Core Subsystem is restarted, or the handler is reinstalled.
+                */
+               acpi_hw_disable_gpe (gpe_number);
+       }
+
+       /*
+        * It is now safe to clear level-triggered evnets.
+        */
+       if (gpe_info->type & ACPI_EVENT_LEVEL_TRIGGERED) {
+               acpi_hw_clear_gpe (gpe_number);
        }
 
-       return_VALUE (INTERRUPT_HANDLED);
+       return_VALUE (ACPI_INTERRUPT_HANDLED);
 }
index 4edfa2373d0765487379541490b5cadd3760a1f2..e8cb01dbd8b9a360c705f5bdec439adbcead2d13 100644 (file)
@@ -2,12 +2,12 @@
  *
  * Module Name: evmisc - ACPI device notification handler dispatch
  *                       and ACPI Global Lock support
- *              $Revision: 35 $
+ *              $Revision: 47 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 #include "achware.h"
 
 #define _COMPONENT          ACPI_EVENTS
-        MODULE_NAME         ("evmisc")
+        ACPI_MODULE_NAME    ("evmisc")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ev_get_gpe_register_index
+ *
+ * PARAMETERS:  Gpe_number      - Raw GPE number
+ *
+ * RETURN:      None.
+ *
+ * DESCRIPTION: Returns the register index (index into the GPE register info
+ *              table) associated with this GPE.
+ *
+ ******************************************************************************/
+
+u32
+acpi_ev_get_gpe_register_index (
+       u32                     gpe_number)
+{
+
+       if (gpe_number > acpi_gbl_gpe_number_max) {
+               return (ACPI_GPE_INVALID);
+       }
+
+       return (ACPI_DIV_8 (acpi_gbl_gpe_number_to_index[gpe_number].number_index));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ev_get_gpe_number_index
+ *
+ * PARAMETERS:  Gpe_number      - Raw GPE number
+ *
+ * RETURN:      None.
+ *
+ * DESCRIPTION: Returns the number index (index into the GPE number info table)
+ *              associated with this GPE.
+ *
+ ******************************************************************************/
+
+u32
+acpi_ev_get_gpe_number_index (
+       u32                     gpe_number)
+{
+
+       if (gpe_number > acpi_gbl_gpe_number_max) {
+               return (ACPI_GPE_INVALID);
+       }
+
+       return (acpi_gbl_gpe_number_to_index[gpe_number].number_index);
+}
 
 
 /*******************************************************************************
@@ -58,7 +110,7 @@ acpi_ev_queue_notify_request (
        acpi_status             status = AE_OK;
 
 
-       PROC_NAME ("Ev_queue_notify_request");
+       ACPI_FUNCTION_NAME ("Ev_queue_notify_request");
 
 
        /*
@@ -92,18 +144,17 @@ acpi_ev_queue_notify_request (
                break;
        }
 
-
        /*
         * Get the notify object attached to the device Node
         */
        obj_desc = acpi_ns_get_attached_object (node);
        if (obj_desc) {
-
                /* We have the notify object, Get the right handler */
 
                switch (node->type) {
                case ACPI_TYPE_DEVICE:
-                       if (notify_value <= MAX_SYS_NOTIFY) {
+
+                       if (notify_value <= ACPI_MAX_SYS_NOTIFY) {
                                handler_obj = obj_desc->device.sys_handler;
                        }
                        else {
@@ -111,8 +162,10 @@ acpi_ev_queue_notify_request (
                        }
                        break;
 
+
                case ACPI_TYPE_THERMAL:
-                       if (notify_value <= MAX_SYS_NOTIFY) {
+
+                       if (notify_value <= ACPI_MAX_SYS_NOTIFY) {
                                handler_obj = obj_desc->thermal_zone.sys_handler;
                        }
                        else {
@@ -122,13 +175,11 @@ acpi_ev_queue_notify_request (
                }
        }
 
-
        /* If there is any handler to run, schedule the dispatcher */
 
-       if ((acpi_gbl_sys_notify.handler && (notify_value <= MAX_SYS_NOTIFY)) ||
-               (acpi_gbl_drv_notify.handler && (notify_value > MAX_SYS_NOTIFY)) ||
+       if ((acpi_gbl_sys_notify.handler && (notify_value <= ACPI_MAX_SYS_NOTIFY)) ||
+               (acpi_gbl_drv_notify.handler && (notify_value > ACPI_MAX_SYS_NOTIFY)) ||
                handler_obj) {
-
                notify_info = acpi_ut_create_generic_state ();
                if (!notify_info) {
                        return (AE_NO_MEMORY);
@@ -169,7 +220,7 @@ acpi_ev_queue_notify_request (
  *
  ******************************************************************************/
 
-void
+void ACPI_SYSTEM_XFACE
 acpi_ev_notify_dispatch (
        void                    *context)
 {
@@ -179,14 +230,14 @@ acpi_ev_notify_dispatch (
        acpi_operand_object     *handler_obj;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        /*
         * We will invoke a global notify handler if installed.
         * This is done _before_ we invoke the per-device handler attached to the device.
         */
-       if (notify_info->notify.value <= MAX_SYS_NOTIFY) {
+       if (notify_info->notify.value <= ACPI_MAX_SYS_NOTIFY) {
                /* Global system notification handler */
 
                if (acpi_gbl_sys_notify.handler) {
@@ -194,7 +245,6 @@ acpi_ev_notify_dispatch (
                        global_context = acpi_gbl_sys_notify.context;
                }
        }
-
        else {
                /* Global driver notification handler */
 
@@ -204,7 +254,6 @@ acpi_ev_notify_dispatch (
                }
        }
 
-
        /* Invoke the system handler first, if present */
 
        if (global_handler) {
@@ -237,7 +286,7 @@ acpi_ev_notify_dispatch (
  *
  ******************************************************************************/
 
-static void
+static void ACPI_SYSTEM_XFACE
 acpi_ev_global_lock_thread (
        void                    *context)
 {
@@ -270,7 +319,6 @@ acpi_ev_global_lock_handler (
        void                    *context)
 {
        u8                      acquired = FALSE;
-       void                    *global_lock;
 
 
        /*
@@ -278,8 +326,7 @@ acpi_ev_global_lock_handler (
         * If we don't get it now, it will be marked pending and we will
         * take another interrupt when it becomes free.
         */
-       global_lock = acpi_gbl_FACS->global_lock;
-       ACPI_ACQUIRE_GLOBAL_LOCK (global_lock, acquired);
+       ACPI_ACQUIRE_GLOBAL_LOCK (acpi_gbl_common_fACS.global_lock, acquired);
        if (acquired) {
                /* Got the lock, now wake all threads waiting for it */
 
@@ -291,7 +338,7 @@ acpi_ev_global_lock_handler (
                                  context);
        }
 
-       return (INTERRUPT_HANDLED);
+       return (ACPI_INTERRUPT_HANDLED);
 }
 
 
@@ -311,7 +358,7 @@ acpi_ev_init_global_lock_handler (void)
        acpi_status             status;
 
 
-       FUNCTION_TRACE ("Ev_init_global_lock_handler");
+       ACPI_FUNCTION_TRACE ("Ev_init_global_lock_handler");
 
 
        acpi_gbl_global_lock_present = TRUE;
@@ -320,7 +367,7 @@ acpi_ev_init_global_lock_handler (void)
 
        /*
         * If the global lock does not exist on this platform, the attempt
-        * to enable GBL_STS will fail (the GBL_EN bit will not stick)
+        * to enable GBL_STATUS will fail (the GBL_ENABLE bit will not stick)
         * Map to AE_OK, but mark global lock as not present.
         * Any attempt to actually use the global lock will be flagged
         * with an error.
@@ -345,14 +392,15 @@ acpi_ev_init_global_lock_handler (void)
  *****************************************************************************/
 
 acpi_status
-acpi_ev_acquire_global_lock(void)
+acpi_ev_acquire_global_lock (
+       u32                     timeout)
 {
        acpi_status             status = AE_OK;
        u8                      acquired = FALSE;
-       void                    *global_lock;
 
 
-       FUNCTION_TRACE ("Ev_acquire_global_lock");
+       ACPI_FUNCTION_TRACE ("Ev_acquire_global_lock");
+
 
        /* Make sure that we actually have a global lock */
 
@@ -364,46 +412,36 @@ acpi_ev_acquire_global_lock(void)
 
        acpi_gbl_global_lock_thread_count++;
 
-
-       /* If we (OS side) have the hardware lock already, we are done */
+       /* If we (OS side vs. BIOS side) have the hardware lock already, we are done */
 
        if (acpi_gbl_global_lock_acquired) {
                return_ACPI_STATUS (AE_OK);
        }
 
-       /* Only if the FACS is valid */
-
-       if (!acpi_gbl_FACS) {
-               return_ACPI_STATUS (AE_OK);
-       }
-
-
        /* We must acquire the actual hardware lock */
 
-       global_lock = acpi_gbl_FACS->global_lock;
-       ACPI_ACQUIRE_GLOBAL_LOCK (global_lock, acquired);
+       ACPI_ACQUIRE_GLOBAL_LOCK (acpi_gbl_common_fACS.global_lock, acquired);
        if (acquired) {
           /* We got the lock */
 
-               ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Acquired the Global Lock\n"));
+               ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Acquired the HW Global Lock\n"));
 
                acpi_gbl_global_lock_acquired = TRUE;
                return_ACPI_STATUS (AE_OK);
        }
 
-
        /*
         * Did not get the lock.  The pending bit was set above, and we must now
         * wait until we get the global lock released interrupt.
         */
        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Waiting for the HW Global Lock\n"));
 
-        /*
-         * Acquire the global lock semaphore first.
-         * Since this wait will block, we must release the interpreter
-         */
+       /*
+        * Acquire the global lock semaphore first.
+        * Since this wait will block, we must release the interpreter
+        */
        status = acpi_ex_system_wait_semaphore (acpi_gbl_global_lock_semaphore,
-                         ACPI_UINT32_MAX);
+                         timeout);
        return_ACPI_STATUS (status);
 }
 
@@ -420,41 +458,81 @@ void
 acpi_ev_release_global_lock (void)
 {
        u8                      pending = FALSE;
-       void                    *global_lock;
 
 
-       FUNCTION_TRACE ("Ev_release_global_lock");
+       ACPI_FUNCTION_TRACE ("Ev_release_global_lock");
 
 
        if (!acpi_gbl_global_lock_thread_count) {
-               REPORT_WARNING(("Global Lock has not be acquired, cannot release\n"));
+               ACPI_REPORT_WARNING(("Cannot release HW Global Lock, it has not been acquired\n"));
                return_VOID;
        }
 
-   /* One fewer thread has the global lock */
+       /* One fewer thread has the global lock */
 
        acpi_gbl_global_lock_thread_count--;
+       if (acpi_gbl_global_lock_thread_count) {
+               /* There are still some threads holding the lock, cannot release */
+
+               return_VOID;
+       }
 
-       /* Have all threads released the lock? */
+       /*
+        * No more threads holding lock, we can do the actual hardware
+        * release
+        */
+       ACPI_RELEASE_GLOBAL_LOCK (acpi_gbl_common_fACS.global_lock, pending);
+       acpi_gbl_global_lock_acquired = FALSE;
 
-       if (!acpi_gbl_global_lock_thread_count) {
-               /*
-                * No more threads holding lock, we can do the actual hardware
-                * release
-                */
-               global_lock = acpi_gbl_FACS->global_lock;
-               ACPI_RELEASE_GLOBAL_LOCK (global_lock, pending);
-               acpi_gbl_global_lock_acquired = FALSE;
-
-               /*
-                * If the pending bit was set, we must write GBL_RLS to the control
-                * register
-                */
-               if (pending) {
-                       acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_LOCK,
-                                        GBL_RLS, 1);
-               }
+       /*
+        * If the pending bit was set, we must write GBL_RLS to the control
+        * register
+        */
+       if (pending) {
+               acpi_hw_bit_register_write (ACPI_BITREG_GLOBAL_LOCK_RELEASE, 1, ACPI_MTX_LOCK);
+       }
+
+       return_VOID;
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION:    Acpi_ev_terminate
+ *
+ * PARAMETERS:  none
+ *
+ * RETURN:      none
+ *
+ * DESCRIPTION: free memory allocated for table storage.
+ *
+ ******************************************************************************/
+
+void
+acpi_ev_terminate (void)
+{
+
+       ACPI_FUNCTION_TRACE ("Ev_terminate");
+
+
+       /*
+        * Free global tables, etc.
+        */
+       if (acpi_gbl_gpe_register_info) {
+               ACPI_MEM_FREE (acpi_gbl_gpe_register_info);
+               acpi_gbl_gpe_register_info = NULL;
+       }
+
+       if (acpi_gbl_gpe_number_info) {
+               ACPI_MEM_FREE (acpi_gbl_gpe_number_info);
+               acpi_gbl_gpe_number_info = NULL;
+       }
+
+       if (acpi_gbl_gpe_number_to_index) {
+               ACPI_MEM_FREE (acpi_gbl_gpe_number_to_index);
+               acpi_gbl_gpe_number_to_index = NULL;
        }
 
        return_VOID;
 }
+
index a275ca803fc28935e921d9e0c7101cefdfd822d5..c587ff0badd9fe0aa92027108199b602ef2fee8e 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: evregion - ACPI Address_space (Op_region) handler dispatch
- *              $Revision: 113 $
+ *              $Revision: 128 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -31,7 +31,7 @@
 #include "amlcode.h"
 
 #define _COMPONENT          ACPI_EVENTS
-        MODULE_NAME         ("evregion")
+        ACPI_MODULE_NAME    ("evregion")
 
 
 /*******************************************************************************
@@ -53,7 +53,7 @@ acpi_ev_install_default_address_space_handlers (
        acpi_status             status;
 
 
-       FUNCTION_TRACE ("Ev_install_default_address_space_handlers");
+       ACPI_FUNCTION_TRACE ("Ev_install_default_address_space_handlers");
 
 
        /*
@@ -68,40 +68,46 @@ acpi_ev_install_default_address_space_handlers (
         * space must be always available -- even though we are nowhere
         * near ready to find the PCI root buses at this point.
         *
-        * NOTE: We ignore AE_EXIST because this means that a handler has
-        * already been installed (via Acpi_install_address_space_handler)
+        * NOTE: We ignore AE_ALREADY_EXISTS because this means that a handler
+        * has already been installed (via Acpi_install_address_space_handler)
         */
-       status = acpi_install_address_space_handler (acpi_gbl_root_node,
+
+       status = acpi_install_address_space_handler ((acpi_handle) acpi_gbl_root_node,
                           ACPI_ADR_SPACE_SYSTEM_MEMORY,
                           ACPI_DEFAULT_HANDLER, NULL, NULL);
        if ((ACPI_FAILURE (status)) &&
-               (status != AE_EXIST)) {
+               (status != AE_ALREADY_EXISTS)) {
                return_ACPI_STATUS (status);
        }
 
-       status = acpi_install_address_space_handler (acpi_gbl_root_node,
+       status = acpi_install_address_space_handler ((acpi_handle) acpi_gbl_root_node,
                           ACPI_ADR_SPACE_SYSTEM_IO,
                           ACPI_DEFAULT_HANDLER, NULL, NULL);
        if ((ACPI_FAILURE (status)) &&
-               (status != AE_EXIST)) {
+               (status != AE_ALREADY_EXISTS)) {
                return_ACPI_STATUS (status);
        }
 
-       status = acpi_install_address_space_handler (acpi_gbl_root_node,
+       status = acpi_install_address_space_handler ((acpi_handle) acpi_gbl_root_node,
                           ACPI_ADR_SPACE_PCI_CONFIG,
                           ACPI_DEFAULT_HANDLER, NULL, NULL);
        if ((ACPI_FAILURE (status)) &&
-               (status != AE_EXIST)) {
+               (status != AE_ALREADY_EXISTS)) {
                return_ACPI_STATUS (status);
        }
 
+       status = acpi_install_address_space_handler ((acpi_handle) acpi_gbl_root_node,
+                          ACPI_ADR_SPACE_DATA_TABLE,
+                          ACPI_DEFAULT_HANDLER, NULL, NULL);
+       if ((ACPI_FAILURE (status)) &&
+               (status != AE_ALREADY_EXISTS)) {
+               return_ACPI_STATUS (status);
+       }
 
        return_ACPI_STATUS (AE_OK);
 }
 
 
-/* TBD: [Restructure] Move elsewhere */
-
 /*******************************************************************************
  *
  * FUNCTION:    Acpi_ev_execute_reg_method
@@ -121,13 +127,19 @@ acpi_ev_execute_reg_method (
        u32                     function)
 {
        acpi_operand_object    *params[3];
+       acpi_operand_object    *region_obj2;
        acpi_status             status;
 
 
-       FUNCTION_TRACE ("Ev_execute_reg_method");
+       ACPI_FUNCTION_TRACE ("Ev_execute_reg_method");
 
 
-       if (region_obj->region.extra->extra.method_REG == NULL) {
+       region_obj2 = acpi_ns_get_secondary_object (region_obj);
+       if (!region_obj2) {
+               return_ACPI_STATUS (AE_NOT_EXIST);
+       }
+
+       if (region_obj2->extra.method_REG == NULL) {
                return_ACPI_STATUS (AE_OK);
        }
 
@@ -161,8 +173,8 @@ acpi_ev_execute_reg_method (
        /*
         *  Execute the method, no return value
         */
-       DEBUG_EXEC(acpi_ut_display_init_pathname (region_obj->region.extra->extra.method_REG, " [Method]"));
-       status = acpi_ns_evaluate_by_handle (region_obj->region.extra->extra.method_REG, params, NULL);
+       ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname (region_obj2->extra.method_REG, " [Method]"));
+       status = acpi_ns_evaluate_by_handle (region_obj2->extra.method_REG, params, NULL);
 
        acpi_ut_remove_reference (params[1]);
 
@@ -181,7 +193,7 @@ cleanup:
  *              Space_id            - ID of the address space (0-255)
  *              Function            - Read or Write operation
  *              Address             - Where in the space to read or write
- *              Bit_width           - Field width in bits (8, 16, or 32)
+ *              Bit_width           - Field width in bits (8, 16, 32, or 64)
  *              Value               - Pointer to in or out value
  *
  * RETURN:      Status
@@ -197,18 +209,24 @@ acpi_ev_address_space_dispatch (
        u32                     function,
        ACPI_PHYSICAL_ADDRESS   address,
        u32                     bit_width,
-       u32                     *value)
+       acpi_integer            *value)
 {
        acpi_status             status;
        acpi_adr_space_handler  handler;
        acpi_adr_space_setup    region_setup;
        acpi_operand_object     *handler_desc;
+       acpi_operand_object     *region_obj2;
        void                    *region_context = NULL;
 
 
-       FUNCTION_TRACE ("Ev_address_space_dispatch");
+       ACPI_FUNCTION_TRACE ("Ev_address_space_dispatch");
 
 
+       region_obj2 = acpi_ns_get_secondary_object (region_obj);
+       if (!region_obj2) {
+               return_ACPI_STATUS (AE_NOT_EXIST);
+       }
+
        /*
         * Ensure that there is a handler associated with this region
         */
@@ -217,14 +235,14 @@ acpi_ev_address_space_dispatch (
                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "no handler for region(%p) [%s]\n",
                        region_obj, acpi_ut_get_region_name (region_obj->region.space_id)));
 
-               return_ACPI_STATUS(AE_NOT_EXIST);
+               return_ACPI_STATUS (AE_NOT_EXIST);
        }
 
        /*
         * It may be the case that the region has never been initialized
         * Some types of regions require special init code
         */
-       if (!(region_obj->region.flags & AOPOBJ_INITIALIZED)) {
+       if (!(region_obj->region.flags & AOPOBJ_SETUP_COMPLETE)) {
                /*
                 * This region has not been initialized yet, do it
                 */
@@ -258,16 +276,16 @@ acpi_ev_address_space_dispatch (
                        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Region Init: %s [%s]\n",
                                acpi_format_exception (status),
                                acpi_ut_get_region_name (region_obj->region.space_id)));
-                       return_ACPI_STATUS(status);
+                       return_ACPI_STATUS (status);
                }
 
-               region_obj->region.flags |= AOPOBJ_INITIALIZED;
+               region_obj->region.flags |= AOPOBJ_SETUP_COMPLETE;
 
                /*
                 *  Save the returned context for use in all accesses to
                 *  this particular region.
                 */
-               region_obj->region.extra->extra.region_context = region_context;
+               region_obj2->extra.region_context = region_context;
        }
 
        /*
@@ -277,10 +295,10 @@ acpi_ev_address_space_dispatch (
 
        ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
                "Addrhandler %p (%p), Address %8.8X%8.8X\n",
-               &region_obj->region.addr_handler->addr_handler, handler, HIDWORD(address),
-               LODWORD(address)));
+               &region_obj->region.addr_handler->addr_handler, handler,
+               ACPI_HIDWORD (address), ACPI_LODWORD (address)));
 
-       if (!(handler_desc->addr_handler.flags & ADDR_HANDLER_DEFAULT_INSTALLED)) {
+       if (!(handler_desc->addr_handler.flags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) {
                /*
                 *  For handlers other than the default (supplied) handlers, we must
                 *  exit the interpreter because the handler *might* block -- we don't
@@ -294,15 +312,15 @@ acpi_ev_address_space_dispatch (
         */
        status = handler (function, address, bit_width, value,
                         handler_desc->addr_handler.context,
-                        region_obj->region.extra->extra.region_context);
+                        region_obj2->extra.region_context);
 
        if (ACPI_FAILURE (status)) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Region handler: %s [%s]\n",
-                       acpi_format_exception (status),
-                       acpi_ut_get_region_name (region_obj->region.space_id)));
+               ACPI_REPORT_ERROR (("Handler for [%s] returned %s\n",
+                       acpi_ut_get_region_name (region_obj->region.space_id),
+                       acpi_format_exception (status)));
        }
 
-       if (!(handler_desc->addr_handler.flags & ADDR_HANDLER_DEFAULT_INSTALLED)) {
+       if (!(handler_desc->addr_handler.flags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) {
                /*
                 * We just returned from a non-default handler, we must re-enter the
                 * interpreter
@@ -337,13 +355,18 @@ acpi_ev_disassociate_region_from_handler(
        acpi_operand_object     **last_obj_ptr;
        acpi_adr_space_setup    region_setup;
        void                    *region_context;
+       acpi_operand_object     *region_obj2;
        acpi_status             status;
 
 
-       FUNCTION_TRACE ("Ev_disassociate_region_from_handler");
+       ACPI_FUNCTION_TRACE ("Ev_disassociate_region_from_handler");
 
 
-       region_context = region_obj->region.extra->extra.region_context;
+       region_obj2 = acpi_ns_get_secondary_object (region_obj);
+       if (!region_obj2) {
+               return;
+       }
+       region_context = region_obj2->extra.region_context;
 
        /*
         *  Get the address handler from the region object
@@ -378,7 +401,10 @@ acpi_ev_disassociate_region_from_handler(
                        obj_desc->region.next = NULL;           /* Must clear field */
 
                        if (acpi_ns_is_locked) {
-                               acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+                               status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+                               if (ACPI_FAILURE (status)) {
+                                       return_VOID;
+                               }
                        }
 
                        /*
@@ -387,7 +413,10 @@ acpi_ev_disassociate_region_from_handler(
                        acpi_ev_execute_reg_method (region_obj, 0);
 
                        if (acpi_ns_is_locked) {
-                               acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+                               status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+                               if (ACPI_FAILURE (status)) {
+                                       return_VOID;
+                               }
                        }
 
                        /*
@@ -406,7 +435,7 @@ acpi_ev_disassociate_region_from_handler(
                                        acpi_ut_get_region_name (region_obj->region.space_id)));
                        }
 
-                       region_obj->region.flags &= ~(AOPOBJ_INITIALIZED);
+                       region_obj->region.flags &= ~(AOPOBJ_SETUP_COMPLETE);
 
                        /*
                         *  Remove handler reference in the region
@@ -466,7 +495,7 @@ acpi_ev_associate_region_and_handler (
        acpi_status     status;
 
 
-       FUNCTION_TRACE ("Ev_associate_region_and_handler");
+       ACPI_FUNCTION_TRACE ("Ev_associate_region_and_handler");
 
 
        ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
@@ -475,18 +504,19 @@ acpi_ev_associate_region_and_handler (
 
 
        /*
-        *  Link this region to the front of the handler's list
+        * Link this region to the front of the handler's list
         */
        region_obj->region.next = handler_obj->addr_handler.region_list;
        handler_obj->addr_handler.region_list = region_obj;
 
        /*
-        *  set the region's handler
+        * Set the region's handler
         */
        region_obj->region.addr_handler = handler_obj;
 
        /*
-        *  Last thing, tell all users that this region is usable
+        * Tell all users that this region is usable by running the _REG
+        * method
         */
        if (acpi_ns_is_locked) {
                acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
@@ -495,7 +525,7 @@ acpi_ev_associate_region_and_handler (
        status = acpi_ev_execute_reg_method (region_obj, 1);
 
        if (acpi_ns_is_locked) {
-               acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+               (void) acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
        }
 
        return_ACPI_STATUS (status);
@@ -510,8 +540,8 @@ acpi_ev_associate_region_and_handler (
  *              Level               - Nesting level of the handle
  *              Context             - Passed into Acpi_ns_walk_namespace
  *
- * DESCRIPTION: This routine checks to see if the object is a Region if it
- *              is then the address handler is installed in it.
+ * DESCRIPTION: This routine installs an address handler into objects that are
+ *              of type Region.
  *
  *              If the Object is a Device, and the device has a handler of
  *              the same type then the search is terminated in that branch.
@@ -535,7 +565,7 @@ acpi_ev_addr_handler_helper (
        acpi_status             status;
 
 
-       PROC_NAME ("Ev_addr_handler_helper");
+       ACPI_FUNCTION_NAME ("Ev_addr_handler_helper");
 
 
        handler_obj = (acpi_operand_object *) context;
@@ -576,7 +606,7 @@ acpi_ev_addr_handler_helper (
        /*
         *  Devices are handled different than regions
         */
-       if (IS_THIS_OBJECT_TYPE (obj_desc, ACPI_TYPE_DEVICE)) {
+       if (obj_desc->common.type == ACPI_TYPE_DEVICE) {
                /*
                 *  See if this guy has any handlers
                 */
index 1019119bb84314eead0777f21a174ddd51fd784e..2382f31ccccaed68bffee2c6bdd96709d960d363 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: evrgnini- ACPI Address_space (Op_region) init
- *              $Revision: 48 $
+ *              $Revision: 57 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -31,7 +31,7 @@
 #include "amlcode.h"
 
 #define _COMPONENT          ACPI_EVENTS
-        MODULE_NAME         ("evrgnini")
+        ACPI_MODULE_NAME    ("evrgnini")
 
 
 /*******************************************************************************
@@ -56,7 +56,10 @@ acpi_ev_system_memory_region_setup (
        void                    *handler_context,
        void                    **region_context)
 {
-       FUNCTION_TRACE ("Ev_system_memory_region_setup");
+       acpi_operand_object     *region_desc = (acpi_operand_object *) handle;
+       acpi_mem_space_context  *local_region_context;
+
+       ACPI_FUNCTION_TRACE ("Ev_system_memory_region_setup");
 
 
        if (function == ACPI_REGION_DEACTIVATE) {
@@ -70,11 +73,17 @@ acpi_ev_system_memory_region_setup (
 
        /* Activate.  Create a new context */
 
-       *region_context = ACPI_MEM_CALLOCATE (sizeof (acpi_mem_space_context));
-       if (!(*region_context)) {
+       local_region_context = ACPI_MEM_CALLOCATE (sizeof (acpi_mem_space_context));
+       if (!(local_region_context)) {
                return_ACPI_STATUS (AE_NO_MEMORY);
        }
 
+       /* Save the region length and address for use in the handler */
+
+       local_region_context->length = region_desc->region.length;
+       local_region_context->address = region_desc->region.address;
+
+       *region_context = local_region_context;
        return_ACPI_STATUS (AE_OK);
 }
 
@@ -101,7 +110,7 @@ acpi_ev_io_space_region_setup (
        void                    *handler_context,
        void                    **region_context)
 {
-       FUNCTION_TRACE ("Ev_io_space_region_setup");
+       ACPI_FUNCTION_TRACE ("Ev_io_space_region_setup");
 
 
        if (function == ACPI_REGION_DEACTIVATE) {
@@ -148,7 +157,7 @@ acpi_ev_pci_config_region_setup (
        acpi_device_id          object_hID;
 
 
-       FUNCTION_TRACE ("Ev_pci_config_region_setup");
+       ACPI_FUNCTION_TRACE ("Ev_pci_config_region_setup");
 
 
        handler_obj = region_obj->region.addr_handler;
@@ -188,7 +197,7 @@ acpi_ev_pci_config_region_setup (
         *  First get device and function numbers from the _ADR object
         *  in the parent's scope.
         */
-       node = acpi_ns_get_parent_object (region_obj->region.node);
+       node = acpi_ns_get_parent_node (region_obj->region.node);
 
 
        /* Acpi_evaluate the _ADR object */
@@ -200,8 +209,8 @@ acpi_ev_pci_config_region_setup (
         *  do nothing on failures.
         */
        if (ACPI_SUCCESS (status)) {
-               pci_id->device HIWORD (temp);
-               pci_id->function = LOWORD (temp);
+               pci_id->device  = ACPI_HIWORD (temp);
+               pci_id->function = ACPI_LOWORD (temp);
        }
 
        /*
@@ -224,16 +233,16 @@ acpi_ev_pci_config_region_setup (
                while (node != acpi_gbl_root_node) {
                        status = acpi_ut_execute_HID (node, &object_hID);
                        if (ACPI_SUCCESS (status)) {
-                               if (!(STRNCMP (object_hID.buffer, PCI_ROOT_HID_STRING,
+                               if (!(ACPI_STRNCMP (object_hID.buffer, PCI_ROOT_HID_STRING,
                                                   sizeof (PCI_ROOT_HID_STRING)))) {
-                                       acpi_install_address_space_handler (node,
+                                       acpi_install_address_space_handler ((acpi_handle) node,
                                                           ACPI_ADR_SPACE_PCI_CONFIG,
                                                           ACPI_DEFAULT_HANDLER, NULL, NULL);
                                        break;
                                }
                        }
 
-                       node = acpi_ns_get_parent_object (node);
+                       node = acpi_ns_get_parent_node (node);
                }
        }
        else {
@@ -245,7 +254,7 @@ acpi_ev_pci_config_region_setup (
         */
        status = acpi_ut_evaluate_numeric_object (METHOD_NAME__SEG, node, &temp);
        if (ACPI_SUCCESS (status)) {
-               pci_id->segment = LOWORD (temp);
+               pci_id->segment = ACPI_LOWORD (temp);
        }
 
        /*
@@ -253,7 +262,7 @@ acpi_ev_pci_config_region_setup (
         */
        status = acpi_ut_evaluate_numeric_object (METHOD_NAME__BBN, node, &temp);
        if (ACPI_SUCCESS (status)) {
-               pci_id->bus = LOWORD (temp);
+               pci_id->bus = ACPI_LOWORD (temp);
        }
 
        *region_context = pci_id;
@@ -286,7 +295,7 @@ acpi_ev_pci_bar_region_setup (
        void                    **region_context)
 {
 
-       FUNCTION_TRACE ("Ev_pci_bar_region_setup");
+       ACPI_FUNCTION_TRACE ("Ev_pci_bar_region_setup");
 
 
        return_ACPI_STATUS (AE_OK);
@@ -318,7 +327,7 @@ acpi_ev_cmos_region_setup (
        void                    **region_context)
 {
 
-       FUNCTION_TRACE ("Ev_cmos_region_setup");
+       ACPI_FUNCTION_TRACE ("Ev_cmos_region_setup");
 
 
        return_ACPI_STATUS (AE_OK);
@@ -347,7 +356,7 @@ acpi_ev_default_region_setup (
        void                    *handler_context,
        void                    **region_context)
 {
-       FUNCTION_TRACE ("Ev_default_region_setup");
+       ACPI_FUNCTION_TRACE ("Ev_default_region_setup");
 
 
        if (function == ACPI_REGION_DEACTIVATE) {
@@ -394,21 +403,33 @@ acpi_ev_initialize_region (
        acpi_status             status;
        acpi_namespace_node     *method_node;
        acpi_name               *reg_name_ptr = (acpi_name *) METHOD_NAME__REG;
+       acpi_operand_object     *region_obj2;
 
 
-       FUNCTION_TRACE_U32 ("Ev_initialize_region", acpi_ns_locked);
+       ACPI_FUNCTION_TRACE_U32 ("Ev_initialize_region", acpi_ns_locked);
 
 
        if (!region_obj) {
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
-       node = acpi_ns_get_parent_object (region_obj->region.node);
+       if (region_obj->common.flags & AOPOBJ_OBJECT_INITIALIZED) {
+               return_ACPI_STATUS (AE_OK);
+       }
+
+       region_obj2 = acpi_ns_get_secondary_object (region_obj);
+       if (!region_obj2) {
+               return_ACPI_STATUS (AE_NOT_EXIST);
+       }
+       node = acpi_ns_get_parent_node (region_obj->region.node);
+
+
        space_id = region_obj->region.space_id;
 
        region_obj->region.addr_handler = NULL;
-       region_obj->region.extra->extra.method_REG = NULL;
-       region_obj->region.flags &= ~(AOPOBJ_INITIALIZED);
+       region_obj2->extra.method_REG = NULL;
+       region_obj->common.flags &= ~(AOPOBJ_SETUP_COMPLETE);
+       region_obj->common.flags |= AOPOBJ_OBJECT_INITIALIZED;
 
        /*
         *  Find any "_REG" associated with this region definition
@@ -421,7 +442,7 @@ acpi_ev_initialize_region (
                 *  definition.  This will be executed when the handler is attached
                 *  or removed
                 */
-               region_obj->region.extra->extra.method_REG = method_node;
+               region_obj2->extra.method_REG = method_node;
        }
 
        /*
@@ -470,6 +491,7 @@ acpi_ev_initialize_region (
                                         */
                                        acpi_ev_associate_region_and_handler (handler_obj, region_obj,
                                                        acpi_ns_locked);
+
                                        return_ACPI_STATUS (AE_OK);
                                }
 
@@ -482,7 +504,7 @@ acpi_ev_initialize_region (
                 *  This one does not have the handler we need
                 *  Pop up one level
                 */
-               node = acpi_ns_get_parent_object (node);
+               node = acpi_ns_get_parent_node (node);
 
        } /* while Node != ROOT */
 
index f49d1bd3a5d2534f834a68a797f77e803c3fcace..0cf6dbde0b3a2587c91bbf103a78b134eb236633 100644 (file)
@@ -2,12 +2,12 @@
  *
  * Module Name: evsci - System Control Interrupt configuration and
  *                      legacy to ACPI mode state transition functions
- *              $Revision: 74 $
+ *              $Revision: 83 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 
 
 #define _COMPONENT          ACPI_EVENTS
-        MODULE_NAME         ("evsci")
-
-
-/*
- * Elements correspond to counts for TMR, NOT_USED, GBL, PWR_BTN, SLP_BTN, RTC,
- * and GENERAL respectively.  These counts are modified by the ACPI interrupt
- * handler.
- *
- * TBD: [Investigate] Note that GENERAL should probably be split out into
- * one element for each bit in the GPE registers
- */
+        ACPI_MODULE_NAME    ("evsci")
 
 
 /*******************************************************************************
  *
  ******************************************************************************/
 
-static u32
-acpi_ev_sci_handler (void *context)
+static u32 ACPI_SYSTEM_XFACE
+acpi_ev_sci_handler (
+       void                    *context)
 {
-       u32                     interrupt_handled = INTERRUPT_NOT_HANDLED;
+       u32                     interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED;
 
 
-       FUNCTION_TRACE("Ev_sci_handler");
+       ACPI_FUNCTION_TRACE("Ev_sci_handler");
 
 
        /*
         * Make sure that ACPI is enabled by checking SCI_EN.  Note that we are
         * required to treat the SCI interrupt as sharable, level, active low.
         */
-       if (!acpi_hw_register_bit_access (ACPI_READ, ACPI_MTX_DO_NOT_LOCK, SCI_EN)) {
+       if (!acpi_hw_bit_register_read (ACPI_BITREG_SCI_ENABLE, ACPI_MTX_DO_NOT_LOCK)) {
                /* ACPI is not enabled;  this interrupt cannot be for us */
 
-               return_VALUE (INTERRUPT_NOT_HANDLED);
+               return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
        }
 
        /*
@@ -113,7 +104,7 @@ acpi_ev_install_sci_handler (void)
        u32                     status = AE_OK;
 
 
-       FUNCTION_TRACE ("Ev_install_sci_handler");
+       ACPI_FUNCTION_TRACE ("Ev_install_sci_handler");
 
 
        status = acpi_os_install_interrupt_handler ((u32) acpi_gbl_FADT->sci_int,
@@ -123,7 +114,6 @@ acpi_ev_install_sci_handler (void)
 
 
 /******************************************************************************
-
  *
  * FUNCTION:    Acpi_ev_remove_sci_handler
  *
@@ -132,43 +122,23 @@ acpi_ev_install_sci_handler (void)
  * RETURN:      E_OK if handler uninstalled OK, E_ERROR if handler was not
  *              installed to begin with
  *
- * DESCRIPTION: Restores original status of all fixed event enable bits and
- *              removes SCI handler.
+ * DESCRIPTION: Remove the SCI interrupt handler.  No further SCIs will be
+ *              taken.
+ *
+ * Note:  It doesn't seem important to disable all events or set the event
+ *        enable registers to their original values.  The OS should disable
+ *        the SCI interrupt level when the handler is removed, so no more
+ *        events will come in.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_ev_remove_sci_handler (void)
 {
-       FUNCTION_TRACE ("Ev_remove_sci_handler");
-
-
-#if 0
-       /* TBD:[Investigate] Figure this out!!  Disable all events first ???  */
-
-       if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (TMR_FIXED_EVENT)) {
-               acpi_event_disable_event (TMR_FIXED_EVENT);
-       }
-
-       if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (GBL_FIXED_EVENT)) {
-               acpi_event_disable_event (GBL_FIXED_EVENT);
-       }
-
-       if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (PWR_BTN_FIXED_EVENT)) {
-               acpi_event_disable_event (PWR_BTN_FIXED_EVENT);
-       }
-
-       if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (SLP_BTN_FIXED_EVENT)) {
-               acpi_event_disable_event (SLP_BTN_FIXED_EVENT);
-       }
-
-       if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (RTC_FIXED_EVENT)) {
-               acpi_event_disable_event (RTC_FIXED_EVENT);
-       }
+       ACPI_FUNCTION_TRACE ("Ev_remove_sci_handler");
 
-       original_fixed_enable_bit_status = 0;
 
-#endif
+       /* Just let the OS remove the handler and disable the level */
 
        acpi_os_remove_interrupt_handler ((u32) acpi_gbl_FADT->sci_int,
                           acpi_ev_sci_handler);
@@ -177,106 +147,3 @@ acpi_ev_remove_sci_handler (void)
 }
 
 
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ev_restore_acpi_state
- *
- * PARAMETERS:  none
- *
- * RETURN:      none
- *
- * DESCRIPTION: Restore the original ACPI state of the machine
- *
- ******************************************************************************/
-
-void
-acpi_ev_restore_acpi_state (void)
-{
-       u32                     index;
-
-
-       FUNCTION_TRACE ("Ev_restore_acpi_state");
-
-
-       /* Restore the state of the chipset enable bits. */
-
-       if (acpi_gbl_restore_acpi_chipset == TRUE) {
-               /* Restore the fixed events */
-
-               if (acpi_hw_register_read (ACPI_MTX_LOCK, PM1_EN) !=
-                               acpi_gbl_pm1_enable_register_save) {
-                       acpi_hw_register_write (ACPI_MTX_LOCK, PM1_EN,
-                               acpi_gbl_pm1_enable_register_save);
-               }
-
-
-               /* Ensure that all status bits are clear */
-
-               acpi_hw_clear_acpi_status ();
-
-
-               /* Now restore the GPEs */
-
-               for (index = 0; index < DIV_2 (acpi_gbl_FADT->gpe0blk_len); index++) {
-                       if (acpi_hw_register_read (ACPI_MTX_LOCK, GPE0_EN_BLOCK | index) !=
-                                       acpi_gbl_gpe0enable_register_save[index]) {
-                               acpi_hw_register_write (ACPI_MTX_LOCK, GPE0_EN_BLOCK | index,
-                                       acpi_gbl_gpe0enable_register_save[index]);
-                       }
-               }
-
-               /* GPE 1 present? */
-
-               if (acpi_gbl_FADT->gpe1_blk_len) {
-                       for (index = 0; index < DIV_2 (acpi_gbl_FADT->gpe1_blk_len); index++) {
-                               if (acpi_hw_register_read (ACPI_MTX_LOCK, GPE1_EN_BLOCK | index) !=
-                                       acpi_gbl_gpe1_enable_register_save[index]) {
-                                       acpi_hw_register_write (ACPI_MTX_LOCK, GPE1_EN_BLOCK | index,
-                                               acpi_gbl_gpe1_enable_register_save[index]);
-                               }
-                       }
-               }
-
-               if (acpi_hw_get_mode() != acpi_gbl_original_mode) {
-                       acpi_hw_set_mode (acpi_gbl_original_mode);
-               }
-       }
-
-       return_VOID;
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    Acpi_ev_terminate
- *
- * PARAMETERS:  none
- *
- * RETURN:      none
- *
- * DESCRIPTION: free memory allocated for table storage.
- *
- ******************************************************************************/
-
-void
-acpi_ev_terminate (void)
-{
-
-       FUNCTION_TRACE ("Ev_terminate");
-
-
-       /*
-        * Free global tables, etc.
-        */
-       if (acpi_gbl_gpe_registers) {
-               ACPI_MEM_FREE (acpi_gbl_gpe_registers);
-       }
-
-       if (acpi_gbl_gpe_info) {
-               ACPI_MEM_FREE (acpi_gbl_gpe_info);
-       }
-
-       return_VOID;
-}
-
-
index 36c99525f8ca11d528354978964d1e0b4ec55bbe..578a108225d0ffab4cd9442c7be7122ae7cd5be1 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: evxface - External interfaces for ACPI events
- *              $Revision: 116 $
+ *              $Revision: 125 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -32,7 +32,7 @@
 #include "acinterp.h"
 
 #define _COMPONENT          ACPI_EVENTS
-        MODULE_NAME         ("evxface")
+        ACPI_MODULE_NAME    ("evxface")
 
 
 /*******************************************************************************
@@ -60,7 +60,7 @@ acpi_install_fixed_event_handler (
        acpi_status             status;
 
 
-       FUNCTION_TRACE ("Acpi_install_fixed_event_handler");
+       ACPI_FUNCTION_TRACE ("Acpi_install_fixed_event_handler");
 
 
        /* Parameter validation */
@@ -69,12 +69,15 @@ acpi_install_fixed_event_handler (
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
-       acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
+       status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
 
        /* Don't allow two handlers. */
 
        if (NULL != acpi_gbl_fixed_event_handlers[event].handler) {
-               status = AE_EXIST;
+               status = AE_ALREADY_EXISTS;
                goto cleanup;
        }
 
@@ -85,7 +88,7 @@ acpi_install_fixed_event_handler (
        acpi_gbl_fixed_event_handlers[event].context = context;
 
        status = acpi_enable_event (event, ACPI_EVENT_FIXED, 0);
-       if (!ACPI_SUCCESS (status)) {
+       if (ACPI_FAILURE (status)) {
                ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Could not enable fixed event.\n"));
 
                /* Remove the handler */
@@ -93,7 +96,6 @@ acpi_install_fixed_event_handler (
                acpi_gbl_fixed_event_handlers[event].handler = NULL;
                acpi_gbl_fixed_event_handlers[event].context = NULL;
        }
-
        else {
                ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
                        "Enabled fixed event %X, Handler=%p\n", event, handler));
@@ -101,7 +103,7 @@ acpi_install_fixed_event_handler (
 
 
 cleanup:
-       acpi_ut_release_mutex (ACPI_MTX_EVENTS);
+       (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS);
        return_ACPI_STATUS (status);
 }
 
@@ -127,7 +129,7 @@ acpi_remove_fixed_event_handler (
        acpi_status             status = AE_OK;
 
 
-       FUNCTION_TRACE ("Acpi_remove_fixed_event_handler");
+       ACPI_FUNCTION_TRACE ("Acpi_remove_fixed_event_handler");
 
 
        /* Parameter validation */
@@ -136,7 +138,10 @@ acpi_remove_fixed_event_handler (
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
-       acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
+       status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
 
        /* Disable the event before removing the handler */
 
@@ -147,7 +152,7 @@ acpi_remove_fixed_event_handler (
        acpi_gbl_fixed_event_handlers[event].handler = NULL;
        acpi_gbl_fixed_event_handlers[event].context = NULL;
 
-       if (!ACPI_SUCCESS (status)) {
+       if (ACPI_FAILURE (status)) {
                ACPI_DEBUG_PRINT ((ACPI_DB_WARN,
                        "Could not write to fixed event enable register.\n"));
        }
@@ -155,7 +160,7 @@ acpi_remove_fixed_event_handler (
                ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Disabled fixed event %X.\n", event));
        }
 
-       acpi_ut_release_mutex (ACPI_MTX_EVENTS);
+       (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS);
        return_ACPI_STATUS (status);
 }
 
@@ -187,10 +192,10 @@ acpi_install_notify_handler (
        acpi_operand_object     *obj_desc;
        acpi_operand_object     *notify_obj;
        acpi_namespace_node     *device_node;
-       acpi_status             status = AE_OK;
+       acpi_status             status;
 
 
-       FUNCTION_TRACE ("Acpi_install_notify_handler");
+       ACPI_FUNCTION_TRACE ("Acpi_install_notify_handler");
 
 
        /* Parameter validation */
@@ -200,7 +205,10 @@ acpi_install_notify_handler (
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
-       acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
 
        /* Convert and validate the device handle */
 
@@ -223,7 +231,7 @@ acpi_install_notify_handler (
                          acpi_gbl_sys_notify.handler) ||
                        ((handler_type == ACPI_DEVICE_NOTIFY) &&
                          acpi_gbl_drv_notify.handler)) {
-                       status = AE_EXIST;
+                       status = AE_ALREADY_EXISTS;
                        goto unlock_and_exit;
                }
 
@@ -269,11 +277,10 @@ acpi_install_notify_handler (
                                  obj_desc->device.sys_handler) ||
                                ((handler_type == ACPI_DEVICE_NOTIFY) &&
                                  obj_desc->device.drv_handler)) {
-                               status = AE_EXIST;
+                               status = AE_ALREADY_EXISTS;
                                goto unlock_and_exit;
                        }
                }
-
                else {
                        /* Create a new object */
 
@@ -285,7 +292,7 @@ acpi_install_notify_handler (
 
                        /* Attach new object to the Node */
 
-                       status = acpi_ns_attach_object (device, obj_desc, (u8) device_node->type);
+                       status = acpi_ns_attach_object (device, obj_desc, device_node->type);
                        if (ACPI_FAILURE (status)) {
                                goto unlock_and_exit;
                        }
@@ -307,7 +314,6 @@ acpi_install_notify_handler (
                if (handler_type == ACPI_SYSTEM_NOTIFY) {
                        obj_desc->device.sys_handler = notify_obj;
                }
-
                else /* ACPI_DEVICE_NOTIFY */ {
                        obj_desc->device.drv_handler = notify_obj;
                }
@@ -315,7 +321,7 @@ acpi_install_notify_handler (
 
 
 unlock_and_exit:
-       acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+       (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
        return_ACPI_STATUS (status);
 }
 
@@ -344,10 +350,10 @@ acpi_remove_notify_handler (
        acpi_operand_object     *notify_obj;
        acpi_operand_object     *obj_desc;
        acpi_namespace_node     *device_node;
-       acpi_status             status = AE_OK;
+       acpi_status             status;
 
 
-       FUNCTION_TRACE ("Acpi_remove_notify_handler");
+       ACPI_FUNCTION_TRACE ("Acpi_remove_notify_handler");
 
 
        /* Parameter validation */
@@ -357,7 +363,10 @@ acpi_remove_notify_handler (
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
-       acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
 
        /* Convert and validate the device handle */
 
@@ -445,7 +454,7 @@ acpi_remove_notify_handler (
 
 
 unlock_and_exit:
-       acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+       (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
        return_ACPI_STATUS (status);
 }
 
@@ -474,38 +483,43 @@ acpi_install_gpe_handler (
        acpi_gpe_handler        handler,
        void                    *context)
 {
-       acpi_status             status = AE_OK;
+       acpi_status             status;
+       u32                     gpe_number_index;
 
 
-       FUNCTION_TRACE ("Acpi_install_gpe_handler");
+       ACPI_FUNCTION_TRACE ("Acpi_install_gpe_handler");
 
 
        /* Parameter validation */
 
-       if (!handler || (gpe_number > ACPI_GPE_MAX)) {
+       if (!handler) {
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
        /* Ensure that we have a valid GPE number */
 
-       if (acpi_gbl_gpe_valid[gpe_number] == ACPI_GPE_INVALID) {
+       gpe_number_index = acpi_ev_get_gpe_number_index (gpe_number);
+       if (gpe_number_index == ACPI_GPE_INVALID) {
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
-       acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
+       status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
 
        /* Make sure that there isn't a handler there already */
 
-       if (acpi_gbl_gpe_info[gpe_number].handler) {
-               status = AE_EXIST;
+       if (acpi_gbl_gpe_number_info[gpe_number_index].handler) {
+               status = AE_ALREADY_EXISTS;
                goto cleanup;
        }
 
        /* Install the handler */
 
-       acpi_gbl_gpe_info[gpe_number].handler = handler;
-       acpi_gbl_gpe_info[gpe_number].context = context;
-       acpi_gbl_gpe_info[gpe_number].type = (u8) type;
+       acpi_gbl_gpe_number_info[gpe_number_index].handler = handler;
+       acpi_gbl_gpe_number_info[gpe_number_index].context = context;
+       acpi_gbl_gpe_number_info[gpe_number_index].type = (u8) type;
 
        /* Clear the GPE (of stale events), the enable it */
 
@@ -514,7 +528,7 @@ acpi_install_gpe_handler (
 
 
 cleanup:
-       acpi_ut_release_mutex (ACPI_MTX_EVENTS);
+       (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS);
        return_ACPI_STATUS (status);
 }
 
@@ -537,21 +551,23 @@ acpi_remove_gpe_handler (
        u32                     gpe_number,
        acpi_gpe_handler        handler)
 {
-       acpi_status             status = AE_OK;
+       acpi_status             status;
+       u32                     gpe_number_index;
 
 
-       FUNCTION_TRACE ("Acpi_remove_gpe_handler");
+       ACPI_FUNCTION_TRACE ("Acpi_remove_gpe_handler");
 
 
        /* Parameter validation */
 
-       if (!handler || (gpe_number > ACPI_GPE_MAX)) {
+       if (!handler) {
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
        /* Ensure that we have a valid GPE number */
 
-       if (acpi_gbl_gpe_valid[gpe_number] == ACPI_GPE_INVALID) {
+       gpe_number_index = acpi_ev_get_gpe_number_index (gpe_number);
+       if (gpe_number_index == ACPI_GPE_INVALID) {
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
@@ -559,11 +575,14 @@ acpi_remove_gpe_handler (
 
        acpi_hw_disable_gpe (gpe_number);
 
-       acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
+       status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
 
        /* Make sure that the installed handler is the same */
 
-       if (acpi_gbl_gpe_info[gpe_number].handler != handler) {
+       if (acpi_gbl_gpe_number_info[gpe_number_index].handler != handler) {
                acpi_hw_enable_gpe (gpe_number);
                status = AE_BAD_PARAMETER;
                goto cleanup;
@@ -571,12 +590,12 @@ acpi_remove_gpe_handler (
 
        /* Remove the handler */
 
-       acpi_gbl_gpe_info[gpe_number].handler = NULL;
-       acpi_gbl_gpe_info[gpe_number].context = NULL;
+       acpi_gbl_gpe_number_info[gpe_number_index].handler = NULL;
+       acpi_gbl_gpe_number_info[gpe_number_index].context = NULL;
 
 
 cleanup:
-       acpi_ut_release_mutex (ACPI_MTX_EVENTS);
+       (void) acpi_ut_release_mutex (ACPI_MTX_EVENTS);
        return_ACPI_STATUS (status);
 }
 
@@ -596,23 +615,29 @@ cleanup:
 
 acpi_status
 acpi_acquire_global_lock (
-       void)
+       u32                     timeout,
+       u32                     *handle)
 {
        acpi_status             status;
 
 
+       if (!handle) {
+               return (AE_BAD_PARAMETER);
+       }
+
        status = acpi_ex_enter_interpreter ();
        if (ACPI_FAILURE (status)) {
                return (status);
        }
 
-       /*
-        * TBD: [Restructure] add timeout param to internal interface, and
-        * perhaps INTERPRETER_LOCKED
-        */
-       status = acpi_ev_acquire_global_lock ();
+       status = acpi_ev_acquire_global_lock (timeout);
        acpi_ex_exit_interpreter ();
 
+       if (ACPI_SUCCESS (status)) {
+               acpi_gbl_global_lock_handle++;
+               *handle = acpi_gbl_global_lock_handle;
+       }
+
        return (status);
 }
 
@@ -631,9 +656,13 @@ acpi_acquire_global_lock (
 
 acpi_status
 acpi_release_global_lock (
-       void)
+       u32                     handle)
 {
 
+       if (handle != acpi_gbl_global_lock_handle) {
+               return (AE_NOT_ACQUIRED);
+       }
+
        acpi_ev_release_global_lock ();
        return (AE_OK);
 }
index b0cb91ba34264da26c3f9793a20e455ab10fc00e..1cf5433caaf0769fc85147c39778565530da3b55 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable
- *              $Revision: 38 $
+ *              $Revision: 51 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -32,7 +32,7 @@
 #include "acinterp.h"
 
 #define _COMPONENT          ACPI_EVENTS
-        MODULE_NAME         ("evxfevnt")
+        ACPI_MODULE_NAME    ("evxfevnt")
 
 
 /*******************************************************************************
 acpi_status
 acpi_enable (void)
 {
-       acpi_status             status;
+       acpi_status             status = AE_OK;
 
 
-       FUNCTION_TRACE ("Acpi_enable");
+       ACPI_FUNCTION_TRACE ("Acpi_enable");
 
 
-       /* Make sure we've got ACPI tables */
+       /* Make sure we have ACPI tables */
 
        if (!acpi_gbl_DSDT) {
                ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "No ACPI tables present!\n"));
                return_ACPI_STATUS (AE_NO_ACPI_TABLES);
        }
 
-       /* Make sure the BIOS supports ACPI mode */
+       acpi_gbl_original_mode = acpi_hw_get_mode ();
 
-       if (SYS_MODE_LEGACY == acpi_hw_get_mode_capabilities()) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Only legacy mode supported!\n"));
-               return_ACPI_STATUS (AE_ERROR);
+       if (acpi_gbl_original_mode == ACPI_SYS_MODE_ACPI) {
+               ACPI_DEBUG_PRINT ((ACPI_DB_OK, "Already in ACPI mode.\n"));
        }
+       else {
+               /* Transition to ACPI mode */
 
-       /* Transition to ACPI mode */
+               status = acpi_hw_set_mode (ACPI_SYS_MODE_ACPI);
+               if (ACPI_FAILURE (status)) {
+                       ACPI_DEBUG_PRINT ((ACPI_DB_FATAL, "Could not transition to ACPI mode.\n"));
+                       return_ACPI_STATUS (status);
+               }
 
-       status = acpi_hw_set_mode (SYS_MODE_ACPI);
-       if (ACPI_FAILURE (status)) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_FATAL, "Could not transition to ACPI mode.\n"));
-               return_ACPI_STATUS (status);
+               ACPI_DEBUG_PRINT ((ACPI_DB_OK, "Transition to ACPI mode successful\n"));
        }
 
-       ACPI_DEBUG_PRINT ((ACPI_DB_OK, "Transition to ACPI mode successful\n"));
-
        return_ACPI_STATUS (status);
 }
 
@@ -100,25 +100,25 @@ acpi_enable (void)
 acpi_status
 acpi_disable (void)
 {
-       acpi_status             status;
+       acpi_status             status = AE_OK;
 
 
-       FUNCTION_TRACE ("Acpi_disable");
+       ACPI_FUNCTION_TRACE ("Acpi_disable");
 
 
-       /* Restore original mode  */
+       if (acpi_hw_get_mode () != acpi_gbl_original_mode) {
+               /* Restore original mode  */
 
-       status = acpi_hw_set_mode (acpi_gbl_original_mode);
-       if (ACPI_FAILURE (status)) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unable to transition to original mode"));
-               return_ACPI_STATUS (status);
+               status = acpi_hw_set_mode (acpi_gbl_original_mode);
+               if (ACPI_FAILURE (status)) {
+                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unable to transition to original mode"));
+                       return_ACPI_STATUS (status);
+               }
        }
 
        /* Unload the SCI interrupt handler  */
 
        acpi_ev_remove_sci_handler ();
-       acpi_ev_restore_acpi_state ();
-
        return_ACPI_STATUS (status);
 }
 
@@ -144,58 +144,37 @@ acpi_enable_event (
        u32                     flags)
 {
        acpi_status             status = AE_OK;
-       u32                     register_id;
 
 
-       FUNCTION_TRACE ("Acpi_enable_event");
+       ACPI_FUNCTION_TRACE ("Acpi_enable_event");
 
 
-       /* The Type must be either Fixed Acpi_event or GPE */
+       /* The Type must be either Fixed Event or GPE */
 
        switch (type) {
-
        case ACPI_EVENT_FIXED:
 
-               /* Decode the Fixed Acpi_event */
-
-               switch (event) {
-               case ACPI_EVENT_PMTIMER:
-                       register_id = TMR_EN;
-                       break;
-
-               case ACPI_EVENT_GLOBAL:
-                       register_id = GBL_EN;
-                       break;
-
-               case ACPI_EVENT_POWER_BUTTON:
-                       register_id = PWRBTN_EN;
-                       break;
-
-               case ACPI_EVENT_SLEEP_BUTTON:
-                       register_id = SLPBTN_EN;
-                       break;
-
-               case ACPI_EVENT_RTC:
-                       register_id = RTC_EN;
-                       break;
+               /* Decode the Fixed Event */
 
-               default:
+               if (event > ACPI_NUM_FIXED_EVENTS) {
                        return_ACPI_STATUS (AE_BAD_PARAMETER);
-                       break;
                }
 
                /*
                 * Enable the requested fixed event (by writing a one to the
                 * enable register bit)
                 */
-               acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_LOCK, register_id, 1);
+               acpi_hw_bit_register_write (acpi_gbl_fixed_event_info[event].enable_register_id,
+                               1, ACPI_MTX_LOCK);
 
-               if (1 != acpi_hw_register_bit_access(ACPI_READ, ACPI_MTX_LOCK, register_id)) {
+               /* Make sure that the hardware responded */
+
+               if (1 != acpi_hw_bit_register_read (acpi_gbl_fixed_event_info[event].enable_register_id,
+                                 ACPI_MTX_LOCK)) {
                        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-                               "Fixed event bit clear when it should be set\n"));
+                               "Could not enable %s event\n", acpi_ut_get_event_name (event)));
                        return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
                }
-
                break;
 
 
@@ -203,21 +182,17 @@ acpi_enable_event (
 
                /* Ensure that we have a valid GPE number */
 
-               if ((event > ACPI_GPE_MAX) ||
-                       (acpi_gbl_gpe_valid[event] == ACPI_GPE_INVALID)) {
+               if (acpi_ev_get_gpe_number_index (event) == ACPI_GPE_INVALID) {
                        return_ACPI_STATUS (AE_BAD_PARAMETER);
                }
 
-
                /* Enable the requested GPE number */
 
-               if (flags & ACPI_EVENT_ENABLE) {
-                       acpi_hw_enable_gpe (event);
-               }
+               acpi_hw_enable_gpe (event);
+
                if (flags & ACPI_EVENT_WAKE_ENABLE) {
                        acpi_hw_enable_gpe_for_wakeup (event);
                }
-
                break;
 
 
@@ -226,7 +201,6 @@ acpi_enable_event (
                status = AE_BAD_PARAMETER;
        }
 
-
        return_ACPI_STATUS (status);
 }
 
@@ -252,58 +226,35 @@ acpi_disable_event (
        u32                     flags)
 {
        acpi_status             status = AE_OK;
-       u32                     register_id;
 
 
-       FUNCTION_TRACE ("Acpi_disable_event");
+       ACPI_FUNCTION_TRACE ("Acpi_disable_event");
 
 
-       /* The Type must be either Fixed Acpi_event or GPE */
+       /* The Type must be either Fixed Event or GPE */
 
        switch (type) {
-
        case ACPI_EVENT_FIXED:
 
-               /* Decode the Fixed Acpi_event */
-
-               switch (event) {
-               case ACPI_EVENT_PMTIMER:
-                       register_id = TMR_EN;
-                       break;
-
-               case ACPI_EVENT_GLOBAL:
-                       register_id = GBL_EN;
-                       break;
-
-               case ACPI_EVENT_POWER_BUTTON:
-                       register_id = PWRBTN_EN;
-                       break;
-
-               case ACPI_EVENT_SLEEP_BUTTON:
-                       register_id = SLPBTN_EN;
-                       break;
+               /* Decode the Fixed Event */
 
-               case ACPI_EVENT_RTC:
-                       register_id = RTC_EN;
-                       break;
-
-               default:
+               if (event > ACPI_NUM_FIXED_EVENTS) {
                        return_ACPI_STATUS (AE_BAD_PARAMETER);
-                       break;
                }
 
                /*
                 * Disable the requested fixed event (by writing a zero to the
                 * enable register bit)
                 */
-               acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_LOCK, register_id, 0);
+               acpi_hw_bit_register_write (acpi_gbl_fixed_event_info[event].enable_register_id,
+                               0, ACPI_MTX_LOCK);
 
-               if (0 != acpi_hw_register_bit_access(ACPI_READ, ACPI_MTX_LOCK, register_id)) {
+               if (0 != acpi_hw_bit_register_read (acpi_gbl_fixed_event_info[event].enable_register_id,
+                                ACPI_MTX_LOCK)) {
                        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-                               "Fixed event bit set when it should be clear,\n"));
+                               "Could not disable %s events\n", acpi_ut_get_event_name (event)));
                        return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
                }
-
                break;
 
 
@@ -311,20 +262,21 @@ acpi_disable_event (
 
                /* Ensure that we have a valid GPE number */
 
-               if ((event > ACPI_GPE_MAX) ||
-                       (acpi_gbl_gpe_valid[event] == ACPI_GPE_INVALID)) {
+               if (acpi_ev_get_gpe_number_index (event) == ACPI_GPE_INVALID) {
                        return_ACPI_STATUS (AE_BAD_PARAMETER);
                }
 
-               /* Disable the requested GPE number */
+               /*
+                * Only disable the requested GPE number for wake if specified.
+                * Otherwise, turn it totally off
+                */
 
-               if (flags & ACPI_EVENT_DISABLE) {
-                       acpi_hw_disable_gpe (event);
-               }
                if (flags & ACPI_EVENT_WAKE_DISABLE) {
                        acpi_hw_disable_gpe_for_wakeup (event);
                }
-
+               else {
+                       acpi_hw_disable_gpe (event);
+               }
                break;
 
 
@@ -355,51 +307,28 @@ acpi_clear_event (
        u32                     type)
 {
        acpi_status             status = AE_OK;
-       u32                     register_id;
 
 
-       FUNCTION_TRACE ("Acpi_clear_event");
+       ACPI_FUNCTION_TRACE ("Acpi_clear_event");
 
 
-       /* The Type must be either Fixed Acpi_event or GPE */
+       /* The Type must be either Fixed Event or GPE */
 
        switch (type) {
-
        case ACPI_EVENT_FIXED:
 
-               /* Decode the Fixed Acpi_event */
-
-               switch (event) {
-               case ACPI_EVENT_PMTIMER:
-                       register_id = TMR_STS;
-                       break;
-
-               case ACPI_EVENT_GLOBAL:
-                       register_id = GBL_STS;
-                       break;
+               /* Decode the Fixed Event */
 
-               case ACPI_EVENT_POWER_BUTTON:
-                       register_id = PWRBTN_STS;
-                       break;
-
-               case ACPI_EVENT_SLEEP_BUTTON:
-                       register_id = SLPBTN_STS;
-                       break;
-
-               case ACPI_EVENT_RTC:
-                       register_id = RTC_STS;
-                       break;
-
-               default:
+               if (event > ACPI_NUM_FIXED_EVENTS) {
                        return_ACPI_STATUS (AE_BAD_PARAMETER);
-                       break;
                }
 
                /*
                 * Clear the requested fixed event (By writing a one to the
                 * status register bit)
                 */
-               acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_LOCK, register_id, 1);
+               acpi_hw_bit_register_write (acpi_gbl_fixed_event_info[event].status_register_id,
+                               1, ACPI_MTX_LOCK);
                break;
 
 
@@ -407,12 +336,10 @@ acpi_clear_event (
 
                /* Ensure that we have a valid GPE number */
 
-               if ((event > ACPI_GPE_MAX) ||
-                       (acpi_gbl_gpe_valid[event] == ACPI_GPE_INVALID)) {
+               if (acpi_ev_get_gpe_number_index (event) == ACPI_GPE_INVALID) {
                        return_ACPI_STATUS (AE_BAD_PARAMETER);
                }
 
-
                acpi_hw_clear_gpe (event);
                break;
 
@@ -449,10 +376,9 @@ acpi_get_event_status (
        acpi_event_status       *event_status)
 {
        acpi_status             status = AE_OK;
-       u32                     register_id;
 
 
-       FUNCTION_TRACE ("Acpi_get_event_status");
+       ACPI_FUNCTION_TRACE ("Acpi_get_event_status");
 
 
        if (!event_status) {
@@ -460,43 +386,21 @@ acpi_get_event_status (
        }
 
 
-       /* The Type must be either Fixed Acpi_event or GPE */
+       /* The Type must be either Fixed Event or GPE */
 
        switch (type) {
-
        case ACPI_EVENT_FIXED:
 
-               /* Decode the Fixed Acpi_event */
-
-               switch (event) {
-               case ACPI_EVENT_PMTIMER:
-                       register_id = TMR_STS;
-                       break;
+               /* Decode the Fixed Event */
 
-               case ACPI_EVENT_GLOBAL:
-                       register_id = GBL_STS;
-                       break;
-
-               case ACPI_EVENT_POWER_BUTTON:
-                       register_id = PWRBTN_STS;
-                       break;
-
-               case ACPI_EVENT_SLEEP_BUTTON:
-                       register_id = SLPBTN_STS;
-                       break;
-
-               case ACPI_EVENT_RTC:
-                       register_id = RTC_STS;
-                       break;
-
-               default:
+               if (event > ACPI_NUM_FIXED_EVENTS) {
                        return_ACPI_STATUS (AE_BAD_PARAMETER);
-                       break;
                }
 
                /* Get the status of the requested fixed event */
 
-               *event_status = acpi_hw_register_bit_access (ACPI_READ, ACPI_MTX_LOCK, register_id);
+               *event_status = acpi_hw_bit_register_read (acpi_gbl_fixed_event_info[event].status_register_id,
+                                  ACPI_MTX_LOCK);
                break;
 
 
@@ -504,12 +408,10 @@ acpi_get_event_status (
 
                /* Ensure that we have a valid GPE number */
 
-               if ((event > ACPI_GPE_MAX) ||
-                       (acpi_gbl_gpe_valid[event] == ACPI_GPE_INVALID)) {
+               if (acpi_ev_get_gpe_number_index (event) == ACPI_GPE_INVALID) {
                        return_ACPI_STATUS (AE_BAD_PARAMETER);
                }
 
-
                /* Obtain status on the requested GPE number */
 
                acpi_hw_get_gpe_status (event, event_status);
index bcf608df0fc20aa417a16b8bcbb41b2cf19f6699..13cc8c896788861bed9a45c104d7c6235a4ff409 100644 (file)
@@ -2,12 +2,12 @@
  *
  * Module Name: evxfregn - External Interfaces, ACPI Operation Regions and
  *                         Address Spaces.
- *              $Revision: 40 $
+ *              $Revision: 48 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -33,7 +33,7 @@
 #include "acinterp.h"
 
 #define _COMPONENT          ACPI_EVENTS
-        MODULE_NAME         ("evxfregn")
+        ACPI_MODULE_NAME    ("evxfregn")
 
 
 /*******************************************************************************
@@ -63,23 +63,24 @@ acpi_install_address_space_handler (
        acpi_operand_object     *obj_desc;
        acpi_operand_object     *handler_obj;
        acpi_namespace_node     *node;
-       acpi_status             status = AE_OK;
-       acpi_object_type8       type;
+       acpi_status             status;
+       acpi_object_type        type;
        u16                     flags = 0;
 
 
-       FUNCTION_TRACE ("Acpi_install_address_space_handler");
+       ACPI_FUNCTION_TRACE ("Acpi_install_address_space_handler");
 
 
        /* Parameter validation */
 
-       if ((!device)   ||
-               ((!handler)  && (handler != ACPI_DEFAULT_HANDLER)) ||
-               (space_id > ACPI_MAX_ADDRESS_SPACE)) {
+       if (!device) {
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
-       acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
 
        /* Convert and validate the device handle */
 
@@ -103,7 +104,7 @@ acpi_install_address_space_handler (
        }
 
        if (handler == ACPI_DEFAULT_HANDLER) {
-               flags = ADDR_HANDLER_DEFAULT_INSTALLED;
+               flags = ACPI_ADDR_HANDLER_DEFAULT_INSTALLED;
 
                switch (space_id) {
                case ACPI_ADR_SPACE_SYSTEM_MEMORY:
@@ -131,10 +132,14 @@ acpi_install_address_space_handler (
                        setup   = acpi_ev_pci_bar_region_setup;
                        break;
 
+               case ACPI_ADR_SPACE_DATA_TABLE:
+                       handler = acpi_ex_data_table_space_handler;
+                       setup   = NULL;
+                       break;
+
                default:
                        status = AE_NOT_EXIST;
                        goto unlock_and_exit;
-                       break;
                }
        }
 
@@ -164,7 +169,7 @@ acpi_install_address_space_handler (
                         * address space.
                         */
                        if(handler_obj->addr_handler.space_id == space_id) {
-                               status = AE_EXIST;
+                               status = AE_ALREADY_EXISTS;
                                goto unlock_and_exit;
                        }
 
@@ -174,7 +179,6 @@ acpi_install_address_space_handler (
                        handler_obj = handler_obj->addr_handler.next;
                }
        }
-
        else {
                ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
                        "Creating object on Device %p while installing handler\n", node));
@@ -200,7 +204,7 @@ acpi_install_address_space_handler (
 
                /* Attach the new object to the Node */
 
-               status = acpi_ns_attach_object (node, obj_desc, (u8) type);
+               status = acpi_ns_attach_object (node, obj_desc, type);
                if (ACPI_FAILURE (status)) {
                        acpi_ut_remove_reference (obj_desc);
                        goto unlock_and_exit;
@@ -246,7 +250,7 @@ acpi_install_address_space_handler (
         * of the branch
         */
        status = acpi_ns_walk_namespace (ACPI_TYPE_ANY, device,
-                        ACPI_UINT32_MAX, NS_WALK_UNLOCK,
+                        ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK,
                         acpi_ev_addr_handler_helper,
                         handler_obj, NULL);
 
@@ -260,7 +264,7 @@ acpi_install_address_space_handler (
 
 
 unlock_and_exit:
-       acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+       (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
        return_ACPI_STATUS (status);
 }
 
@@ -289,21 +293,22 @@ acpi_remove_address_space_handler (
        acpi_operand_object     *region_obj;
        acpi_operand_object     **last_obj_ptr;
        acpi_namespace_node     *node;
-       acpi_status             status = AE_OK;
+       acpi_status             status;
 
 
-       FUNCTION_TRACE ("Acpi_remove_address_space_handler");
+       ACPI_FUNCTION_TRACE ("Acpi_remove_address_space_handler");
 
 
        /* Parameter validation */
 
-       if ((!device)   ||
-               ((!handler)  && (handler != ACPI_DEFAULT_HANDLER)) ||
-               (space_id > ACPI_MAX_ADDRESS_SPACE)) {
+       if (!device) {
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
-       acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
 
        /* Convert and validate the device handle */
 
@@ -313,7 +318,6 @@ acpi_remove_address_space_handler (
                goto unlock_and_exit;
        }
 
-
        /* Make sure the internal object exists */
 
        obj_desc = acpi_ns_get_attached_object (node);
@@ -396,7 +400,7 @@ acpi_remove_address_space_handler (
 
 
 unlock_and_exit:
-       acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+       (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
        return_ACPI_STATUS (status);
 }
 
index 0714c087172adf7cb040934c0602ec8c336b3ccd..d0bbc7655a46e95b304e00deeca0e7cf8e60f997 100644 (file)
@@ -1,11 +1,10 @@
 #
 # Makefile for all Linux ACPI interpreter subdirectories
-# EXCEPT for the ospm directory
 #
 
 O_TARGET := $(notdir $(CURDIR)).o
 
-obj-$(CONFIG_ACPI) := $(patsubst %.c,%.o,$(wildcard *.c))
+obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
 
index 2a29c61b511e5cf63ac05650cd09bb59ee22ec29..423e5e57df7182db69fc18e1a988dd9c4a181ce5 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: exconfig - Namespace reconfiguration (Load/Unload opcodes)
- *              $Revision: 44 $
+ *              $Revision: 59 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 
 
 #define _COMPONENT          ACPI_EXECUTER
-        MODULE_NAME         ("exconfig")
+        ACPI_MODULE_NAME    ("exconfig")
 
 
-/*****************************************************************************
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ex_add_table
+ *
+ * PARAMETERS:  Table               - Pointer to raw table
+ *              Parent_node         - Where to load the table (scope)
+ *              Ddb_handle          - Where to return the table handle.
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Common function to Install and Load an ACPI table with a
+ *              returned table handle.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ex_add_table (
+       acpi_table_header       *table,
+       acpi_namespace_node     *parent_node,
+       acpi_operand_object     **ddb_handle)
+{
+       acpi_status             status;
+       acpi_table_desc         table_info;
+       acpi_operand_object     *obj_desc;
+
+
+       ACPI_FUNCTION_TRACE ("Ex_add_table");
+
+
+       /* Create an object to be the table handle */
+
+       obj_desc = acpi_ut_create_internal_object (INTERNAL_TYPE_REFERENCE);
+       if (!obj_desc) {
+               return_ACPI_STATUS (AE_NO_MEMORY);
+       }
+
+       /* Install the new table into the local data structures */
+
+       table_info.pointer     = table;
+       table_info.length      = table->length;
+       table_info.allocation  = ACPI_MEM_ALLOCATED;
+       table_info.base_pointer = table;
+
+       status = acpi_tb_install_table (NULL, &table_info);
+       if (ACPI_FAILURE (status)) {
+               goto cleanup;
+       }
+
+       /* Add the table to the namespace */
+
+       status = acpi_ns_load_table (table_info.installed_desc, parent_node);
+       if (ACPI_FAILURE (status)) {
+               /* Uninstall table on error */
+
+               acpi_tb_uninstall_table (table_info.installed_desc);
+               goto cleanup;
+       }
+
+       /* Init the table handle */
+
+       obj_desc->reference.opcode = AML_LOAD_OP;
+       obj_desc->reference.object = table_info.installed_desc;
+       *ddb_handle = obj_desc;
+       return_ACPI_STATUS (AE_OK);
+
+
+cleanup:
+       acpi_ut_remove_reference (obj_desc);
+       return_ACPI_STATUS (status);
+}
+
+
+/*******************************************************************************
  *
  * FUNCTION:    Acpi_ex_load_table_op
  *
- * PARAMETERS:  Rgn_desc        - Op region where the table will be obtained
- *              Ddb_handle      - Where a handle to the table will be returned
+ * PARAMETERS:  Walk_state          - Current state with operands
+ *              Return_desc         - Where to store the return object
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Load an ACPI table
  *
- ****************************************************************************/
+ ******************************************************************************/
 
 acpi_status
-acpi_ex_load_op (
-       acpi_operand_object     *rgn_desc,
-       acpi_operand_object     *ddb_handle)
+acpi_ex_load_table_op (
+       acpi_walk_state         *walk_state,
+       acpi_operand_object     **return_desc)
 {
        acpi_status             status;
-       acpi_operand_object     *table_desc = NULL;
-       u8                      *table_ptr;
-       u8                      *table_data_ptr;
-       acpi_table_header       table_header;
-       acpi_table_desc         table_info;
-       u32                     i;
+       acpi_operand_object     **operand = &walk_state->operands[0];
+       acpi_table_header       *table;
+       acpi_namespace_node     *parent_node;
+       acpi_namespace_node     *start_node;
+       acpi_namespace_node     *parameter_node = NULL;
+       acpi_operand_object     *ddb_handle;
+
+
+       ACPI_FUNCTION_TRACE ("Ex_load_table_op");
+
+
+       /*
+        * Make sure that the signature does not match one of the tables that
+        * is already loaded.
+        */
+       status = acpi_tb_match_signature (operand[0]->string.pointer, NULL);
+       if (status == AE_OK) {
+               /* Signature matched -- don't allow override */
+
+               return_ACPI_STATUS (AE_ALREADY_EXISTS);
+       }
+
+       /* Find the ACPI table */
+
+       status = acpi_tb_find_table (operand[0]->string.pointer,
+                          operand[1]->string.pointer,
+                          operand[2]->string.pointer, &table);
+       if (ACPI_FAILURE (status)) {
+               if (status != AE_NOT_FOUND) {
+                       return_ACPI_STATUS (status);
+               }
 
+               /* Not found, return an Integer=0 and AE_OK */
 
-       FUNCTION_TRACE ("Ex_load_op");
+               ddb_handle = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
+               if (!ddb_handle) {
+                       return_ACPI_STATUS (AE_NO_MEMORY);
+               }
+
+               ddb_handle->integer.value = 0;
+               *return_desc = ddb_handle;
 
-       /* TBD: [Unhandled] Object can be either a field or an opregion */
+               return_ACPI_STATUS (AE_OK);
+       }
 
+       /* Default nodes */
 
-       /* Get the table header */
+       start_node = walk_state->scope_info->scope.node;
+       parent_node = acpi_gbl_root_node;
 
-       table_header.length = 0;
-       for (i = 0; i < sizeof (acpi_table_header); i++) {
-               status = acpi_ev_address_space_dispatch (rgn_desc, ACPI_READ_ADR_SPACE,
-                                  (ACPI_PHYSICAL_ADDRESS) i, 8,
-                                  (u32 *) ((u8 *) &table_header + i));
+       /* Root_path (optional parameter) */
+
+       if (operand[3]->string.length > 0) {
+               /*
+                * Find the node referenced by the Root_path_string. This is the
+                * location within the namespace where the table will be loaded.
+                */
+               status = acpi_ns_get_node_by_path (operand[3]->string.pointer, start_node,
+                                  ACPI_NS_SEARCH_PARENT, &parent_node);
                if (ACPI_FAILURE (status)) {
                        return_ACPI_STATUS (status);
                }
        }
 
-       /* Allocate a buffer for the entire table */
+       /* Parameter_path (optional parameter) */
 
-       table_ptr = ACPI_MEM_ALLOCATE (table_header.length);
-       if (!table_ptr) {
-               return_ACPI_STATUS (AE_NO_MEMORY);
+       if (operand[4]->string.length > 0) {
+               if ((operand[4]->string.pointer[0] != '\\') &&
+                       (operand[4]->string.pointer[0] != '^')) {
+                       /*
+                        * Path is not absolute, so it will be relative to the node
+                        * referenced by the Root_path_string (or the NS root if omitted)
+                        */
+                       start_node = parent_node;
+               }
+
+               /*
+                * Find the node referenced by the Parameter_path_string
+                */
+               status = acpi_ns_get_node_by_path (operand[4]->string.pointer, start_node,
+                                  ACPI_NS_SEARCH_PARENT, &parameter_node);
+               if (ACPI_FAILURE (status)) {
+                       return_ACPI_STATUS (status);
+               }
        }
 
-       /* Copy the header to the buffer */
+       /* Load the table into the namespace */
 
-       MEMCPY (table_ptr, &table_header, sizeof (acpi_table_header));
-       table_data_ptr = table_ptr + sizeof (acpi_table_header);
+       status = acpi_ex_add_table (table, parent_node, &ddb_handle);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
 
+       /* Parameter Data (optional) */
 
-       /* Get the table from the op region */
+       if (parameter_node) {
+               /* Store the parameter data into the optional parameter object */
 
-       for (i = 0; i < table_header.length; i++) {
-               status = acpi_ev_address_space_dispatch (rgn_desc, ACPI_READ_ADR_SPACE,
-                                  (ACPI_PHYSICAL_ADDRESS) i, 8,
-                                  (u32 *) (table_data_ptr + i));
+               status = acpi_ex_store (operand[5], (acpi_operand_object *) parameter_node,
+                                walk_state);
                if (ACPI_FAILURE (status)) {
-                       goto cleanup;
+                       acpi_ex_unload_table (ddb_handle);
                }
        }
 
+       return_ACPI_STATUS  (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ex_load_op
+ *
+ * PARAMETERS:  Obj_desc        - Region or Field where the table will be
+ *                                obtained
+ *              Target          - Where a handle to the table will be stored
+ *              Walk_state      - Current state
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Load an ACPI table from a field or operation region
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ex_load_op (
+       acpi_operand_object     *obj_desc,
+       acpi_operand_object     *target,
+       acpi_walk_state         *walk_state)
+{
+       acpi_status             status;
+       acpi_operand_object     *ddb_handle;
+       acpi_operand_object     *buffer_desc = NULL;
+       acpi_table_header       *table_ptr = NULL;
+       u8                      *table_data_ptr;
+       acpi_table_header       table_header;
+       u32                     i;
+
+
+       ACPI_FUNCTION_TRACE ("Ex_load_op");
+
+
+       /* Object can be either an Op_region or a Field */
+
+       switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
+       case ACPI_TYPE_REGION:
+
+               ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Load from Region %p %s\n",
+                       obj_desc, acpi_ut_get_type_name (obj_desc->common.type)));
+
+               /* Get the table header */
+
+               table_header.length = 0;
+               for (i = 0; i < sizeof (acpi_table_header); i++) {
+                       status = acpi_ev_address_space_dispatch (obj_desc, ACPI_READ,
+                                          (ACPI_PHYSICAL_ADDRESS) i, 8,
+                                          (acpi_integer *) ((u8 *) &table_header + i));
+                       if (ACPI_FAILURE (status)) {
+                               return_ACPI_STATUS (status);
+                       }
+               }
+
+               /* Allocate a buffer for the entire table */
+
+               table_ptr = ACPI_MEM_ALLOCATE (table_header.length);
+               if (!table_ptr) {
+                       return_ACPI_STATUS (AE_NO_MEMORY);
+               }
+
+               /* Copy the header to the buffer */
+
+               ACPI_MEMCPY (table_ptr, &table_header, sizeof (acpi_table_header));
+               table_data_ptr = ACPI_PTR_ADD (u8, table_ptr, sizeof (acpi_table_header));
 
-       /* Table must be either an SSDT or a PSDT */
+               /* Get the table from the op region */
 
-       if ((!STRNCMP (table_header.signature,
+               for (i = 0; i < table_header.length; i++) {
+                       status = acpi_ev_address_space_dispatch (obj_desc, ACPI_READ,
+                                          (ACPI_PHYSICAL_ADDRESS) i, 8,
+                                          (acpi_integer *) (table_data_ptr + i));
+                       if (ACPI_FAILURE (status)) {
+                               goto cleanup;
+                       }
+               }
+               break;
+
+
+       case ACPI_TYPE_BUFFER_FIELD:
+       case INTERNAL_TYPE_REGION_FIELD:
+       case INTERNAL_TYPE_BANK_FIELD:
+       case INTERNAL_TYPE_INDEX_FIELD:
+
+               ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Load from Field %p %s\n",
+                       obj_desc, acpi_ut_get_type_name (obj_desc->common.type)));
+
+               /*
+                * The length of the field must be at least as large as the table.
+                * Read the entire field and thus the entire table.  Buffer is
+                * allocated during the read.
+                */
+               status = acpi_ex_read_data_from_field (obj_desc, &buffer_desc);
+               if (ACPI_FAILURE (status)) {
+                       goto cleanup;
+               }
+
+               table_ptr = (acpi_table_header *) buffer_desc->buffer.pointer;
+               break;
+
+
+       default:
+               return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+       }
+
+       /* The table must be either an SSDT or a PSDT */
+
+       if ((!ACPI_STRNCMP (table_ptr->signature,
                          acpi_gbl_acpi_table_data[ACPI_TABLE_PSDT].signature,
                          acpi_gbl_acpi_table_data[ACPI_TABLE_PSDT].sig_length)) &&
-               (!STRNCMP (table_header.signature,
+               (!ACPI_STRNCMP (table_ptr->signature,
                                 acpi_gbl_acpi_table_data[ACPI_TABLE_SSDT].signature,
                                 acpi_gbl_acpi_table_data[ACPI_TABLE_SSDT].sig_length))) {
                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
                        "Table has invalid signature [%4.4s], must be SSDT or PSDT\n",
-                       (char*)table_header.signature));
+                       (char *) &table_ptr->signature));
                status = AE_BAD_SIGNATURE;
                goto cleanup;
        }
 
-       /* Create an object to be the table handle */
-
-       table_desc = acpi_ut_create_internal_object (INTERNAL_TYPE_REFERENCE);
-       if (!table_desc) {
-               status = AE_NO_MEMORY;
-               goto cleanup;
-       }
-
-
        /* Install the new table into the local data structures */
 
-       table_info.pointer     = (acpi_table_header *) table_ptr;
-       table_info.length      = table_header.length;
-       table_info.allocation  = ACPI_MEM_ALLOCATED;
-       table_info.base_pointer = table_ptr;
-
-       status = acpi_tb_install_table (NULL, &table_info);
+       status = acpi_ex_add_table (table_ptr, acpi_gbl_root_node, &ddb_handle);
        if (ACPI_FAILURE (status)) {
                goto cleanup;
        }
 
-       /* Add the table to the namespace */
+       /* Store the Ddb_handle into the Target operand */
 
-       /* TBD: [Restructure] - change to whatever new interface is appropriate */
-/*
-       Status = Acpi_load_namespace ();
-       if (ACPI_FAILURE (Status))
-       {
-*/
-               /* TBD: [Errors] Unload the table on failure ? */
-/*
-               goto Cleanup;
+       status = acpi_ex_store (ddb_handle, target, walk_state);
+       if (ACPI_FAILURE (status)) {
+               acpi_ex_unload_table (ddb_handle);
        }
-*/
-
-
-       /* TBD: [Investigate] we need a pointer to the table desc */
-
-       /* Init the table handle */
-
-       table_desc->reference.opcode = AML_LOAD_OP;
-       table_desc->reference.object = table_info.installed_desc;
-
-       /* TBD: store the tabledesc into the Ddb_handle target */
-       /* Ddb_handle = Table_desc; */
 
        return_ACPI_STATUS (status);
 
 
 cleanup:
 
-       ACPI_MEM_FREE (table_desc);
-       ACPI_MEM_FREE (table_ptr);
+       if (buffer_desc) {
+               acpi_ut_remove_reference (buffer_desc);
+       }
+       else {
+               ACPI_MEM_FREE (table_ptr);
+       }
        return_ACPI_STATUS (status);
 }
 
 
-/*****************************************************************************
+/*******************************************************************************
  *
  * FUNCTION:    Acpi_ex_unload_table
  *
@@ -189,7 +396,7 @@ cleanup:
  *
  * DESCRIPTION: Unload an ACPI table
  *
- ****************************************************************************/
+ ******************************************************************************/
 
 acpi_status
 acpi_ex_unload_table (
@@ -200,7 +407,7 @@ acpi_ex_unload_table (
        acpi_table_desc         *table_info;
 
 
-       FUNCTION_TRACE ("Ex_unload_table");
+       ACPI_FUNCTION_TRACE ("Ex_unload_table");
 
 
        /*
@@ -210,7 +417,7 @@ acpi_ex_unload_table (
         * validated here.
         */
        if ((!ddb_handle) ||
-               (!VALID_DESCRIPTOR_TYPE (ddb_handle, ACPI_DESC_TYPE_INTERNAL)) ||
+               (ACPI_GET_DESCRIPTOR_TYPE (ddb_handle) != ACPI_DESC_TYPE_INTERNAL) ||
                (((acpi_operand_object  *)ddb_handle)->common.type !=
                                INTERNAL_TYPE_REFERENCE)) {
                return_ACPI_STATUS (AE_BAD_PARAMETER);
@@ -236,7 +443,6 @@ acpi_ex_unload_table (
        /* Delete the table descriptor (Ddb_handle) */
 
        acpi_ut_remove_reference (table_desc);
-
        return_ACPI_STATUS (status);
 }
 
index 7e72920679d51674ead636edeb354b6f79a2dae8..fe48f3144291edf7a66ad37049f0bd892b107b08 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: exconvrt - Object conversion routines
- *              $Revision: 24 $
+ *              $Revision: 30 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -34,7 +34,7 @@
 
 
 #define _COMPONENT          ACPI_EXECUTER
-        MODULE_NAME         ("exconvrt")
+        ACPI_MODULE_NAME    ("exconvrt")
 
 
 /*******************************************************************************
@@ -65,13 +65,13 @@ acpi_ex_convert_to_integer (
        u32                     integer_size = sizeof (acpi_integer);
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_TRACE_PTR ("Ex_convert_to_integer", obj_desc);
 
 
        switch (obj_desc->common.type) {
        case ACPI_TYPE_INTEGER:
                *result_desc = obj_desc;
-               return (AE_OK);
+               return_ACPI_STATUS (AE_OK);
 
        case ACPI_TYPE_STRING:
                pointer = obj_desc->string.pointer;
@@ -84,7 +84,7 @@ acpi_ex_convert_to_integer (
                break;
 
        default:
-               return (AE_TYPE);
+               return_ACPI_STATUS (AE_TYPE);
        }
 
        /*
@@ -92,10 +92,9 @@ acpi_ex_convert_to_integer (
         */
        ret_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
        if (!ret_desc) {
-               return (AE_NO_MEMORY);
+               return_ACPI_STATUS (AE_NO_MEMORY);
        }
 
-
        /* Handle both ACPI 1.0 and ACPI 2.0 Integer widths */
 
        if (walk_state->method_node->flags & ANOBJ_DATA_WIDTH_32) {
@@ -106,7 +105,6 @@ acpi_ex_convert_to_integer (
                integer_size = sizeof (u32);
        }
 
-
        /*
         * Convert the buffer/string to an integer.  Note that both buffers and
         * strings are treated as raw data - we don't convert ascii to hex for
@@ -130,13 +128,13 @@ acpi_ex_convert_to_integer (
        switch (obj_desc->common.type) {
        case ACPI_TYPE_STRING:
 
-               /* TBD: Need to use 64-bit STRTOUL */
+               /* TBD: Need to use 64-bit ACPI_STRTOUL */
 
                /*
                 * Convert string to an integer
                 * String must be hexadecimal as per the ACPI specification
                 */
-               result = STRTOUL (pointer, NULL, 16);
+               result = ACPI_STRTOUL (pointer, NULL, 16);
                break;
 
 
@@ -154,7 +152,6 @@ acpi_ex_convert_to_integer (
                         */
                        result |= (((acpi_integer) pointer[i]) << (i * 8));
                }
-
                break;
        }
 
@@ -169,7 +166,7 @@ acpi_ex_convert_to_integer (
        }
 
        *result_desc = ret_desc;
-       return (AE_OK);
+       return_ACPI_STATUS (AE_OK);
 }
 
 
@@ -199,7 +196,7 @@ acpi_ex_convert_to_buffer (
        u8                      *new_buf;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_TRACE_PTR ("Ex_convert_to_buffer", obj_desc);
 
 
        switch (obj_desc->common.type) {
@@ -210,7 +207,7 @@ acpi_ex_convert_to_buffer (
                 */
                ret_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER);
                if (!ret_desc) {
-                       return (AE_NO_MEMORY);
+                       return_ACPI_STATUS (AE_NO_MEMORY);
                }
 
                /* Handle both ACPI 1.0 and ACPI 2.0 Integer widths */
@@ -224,15 +221,15 @@ acpi_ex_convert_to_buffer (
                        integer_size = sizeof (u32);
                }
 
-               /* Need enough space for one integers */
+               /* Need enough space for one integer */
 
                ret_desc->buffer.length = integer_size;
                new_buf = ACPI_MEM_CALLOCATE (integer_size);
                if (!new_buf) {
-                       REPORT_ERROR
+                       ACPI_REPORT_ERROR
                                (("Ex_convert_to_buffer: Buffer allocation failure\n"));
                        acpi_ut_remove_reference (ret_desc);
-                       return (AE_NO_MEMORY);
+                       return_ACPI_STATUS (AE_NO_MEMORY);
                }
 
                /* Copy the integer to the buffer */
@@ -244,12 +241,6 @@ acpi_ex_convert_to_buffer (
 
                /* Return the new buffer descriptor */
 
-               if (*result_desc == obj_desc) {
-                       if (walk_state->opcode != AML_STORE_OP) {
-                               acpi_ut_remove_reference (obj_desc);
-                       }
-               }
-
                *result_desc = ret_desc;
                break;
 
@@ -265,11 +256,10 @@ acpi_ex_convert_to_buffer (
 
 
        default:
-               return (AE_TYPE);
-               break;
-   }
+               return_ACPI_STATUS (AE_TYPE);
+       }
 
-       return (AE_OK);
+       return_ACPI_STATUS (AE_OK);
 }
 
 
@@ -301,7 +291,7 @@ acpi_ex_convert_to_ascii (
        u8                      leading_zero = TRUE;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        switch (base) {
@@ -323,7 +313,7 @@ acpi_ex_convert_to_ascii (
                        }
 
                        if (!leading_zero) {
-                               string[k] = (u8) (ASCII_ZERO + remainder);
+                               string[k] = (u8) (ACPI_ASCII_ZERO + remainder);
                                k++;
                        }
                }
@@ -336,7 +326,7 @@ acpi_ex_convert_to_ascii (
                for (i = 0, j = ((length * 2) -1); i < (length * 2); i++, j--) {
 
                        hex_digit = acpi_ut_hex_to_ascii_char (integer, (j * 4));
-                       if (hex_digit != ASCII_ZERO) {
+                       if (hex_digit != ACPI_ASCII_ZERO) {
                                leading_zero = FALSE;
                        }
 
@@ -358,7 +348,7 @@ acpi_ex_convert_to_ascii (
         * Finally, null terminate the string and return the length
         */
        if (!k) {
-               string [0] = ASCII_ZERO;
+               string [0] = ACPI_ASCII_ZERO;
                k = 1;
        }
        string [k] = 0;
@@ -398,7 +388,7 @@ acpi_ex_convert_to_string (
        u8                      *pointer;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_TRACE_PTR ("Ex_convert_to_string", obj_desc);
 
 
        switch (obj_desc->common.type) {
@@ -425,17 +415,17 @@ acpi_ex_convert_to_string (
                 */
                ret_desc = acpi_ut_create_internal_object (ACPI_TYPE_STRING);
                if (!ret_desc) {
-                       return (AE_NO_MEMORY);
+                       return_ACPI_STATUS (AE_NO_MEMORY);
                }
 
                /* Need enough space for one ASCII integer plus null terminator */
 
                new_buf = ACPI_MEM_CALLOCATE (string_length + 1);
                if (!new_buf) {
-                       REPORT_ERROR
+                       ACPI_REPORT_ERROR
                                (("Ex_convert_to_string: Buffer allocation failure\n"));
                        acpi_ut_remove_reference (ret_desc);
-                       return (AE_NO_MEMORY);
+                       return_ACPI_STATUS (AE_NO_MEMORY);
                }
 
 
@@ -477,7 +467,7 @@ acpi_ex_convert_to_string (
 
                if (max_length > ACPI_MAX_STRING_CONVERSION) {
                        if (string_length > ACPI_MAX_STRING_CONVERSION) {
-                               return (AE_AML_STRING_LIMIT);
+                               return_ACPI_STATUS (AE_AML_STRING_LIMIT);
                        }
                }
 
@@ -486,7 +476,7 @@ acpi_ex_convert_to_string (
                 */
                ret_desc = acpi_ut_create_internal_object (ACPI_TYPE_STRING);
                if (!ret_desc) {
-                       return (AE_NO_MEMORY);
+                       return_ACPI_STATUS (AE_NO_MEMORY);
                }
 
                /* String length is the lesser of the Max or the actual length */
@@ -497,10 +487,10 @@ acpi_ex_convert_to_string (
 
                new_buf = ACPI_MEM_CALLOCATE (string_length + 1);
                if (!new_buf) {
-                       REPORT_ERROR
+                       ACPI_REPORT_ERROR
                                (("Ex_convert_to_string: Buffer allocation failure\n"));
                        acpi_ut_remove_reference (ret_desc);
-                       return (AE_NO_MEMORY);
+                       return_ACPI_STATUS (AE_NO_MEMORY);
                }
 
                /*
@@ -519,7 +509,7 @@ acpi_ex_convert_to_string (
 
                new_buf [index-1] = 0;
                ret_desc->buffer.pointer = new_buf;
-               ret_desc->string.length = STRLEN ((char *) new_buf);
+               ret_desc->string.length = ACPI_STRLEN ((char *) new_buf);
 
 
                /* Return the new buffer descriptor */
@@ -543,17 +533,16 @@ acpi_ex_convert_to_string (
                else {
                        /* Must copy the string first and then truncate it */
 
-                       return (AE_NOT_IMPLEMENTED);
+                       return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
                }
                break;
 
 
        default:
-               return (AE_TYPE);
-               break;
-   }
+               return_ACPI_STATUS (AE_TYPE);
+       }
 
-       return (AE_OK);
+       return_ACPI_STATUS (AE_OK);
 }
 
 
@@ -561,27 +550,33 @@ acpi_ex_convert_to_string (
  *
  * FUNCTION:    Acpi_ex_convert_to_target_type
  *
- * PARAMETERS:  *Obj_desc       - Object to be converted.
- *              Walk_state      - Current method state
+ * PARAMETERS:  Destination_type    - Current type of the destination
+ *              Source_desc         - Source object to be converted.
+ *              Walk_state          - Current method state
  *
  * RETURN:      Status
  *
- * DESCRIPTION:
+ * DESCRIPTION: Implements "implicit conversion" rules for storing an object.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_ex_convert_to_target_type (
-       acpi_object_type8       destination_type,
-       acpi_operand_object     **obj_desc,
+       acpi_object_type        destination_type,
+       acpi_operand_object     *source_desc,
+       acpi_operand_object     **result_desc,
        acpi_walk_state         *walk_state)
 {
        acpi_status             status = AE_OK;
 
 
-       FUNCTION_TRACE ("Ex_convert_to_target_type");
+       ACPI_FUNCTION_TRACE ("Ex_convert_to_target_type");
 
 
+       /* Default behavior */
+
+       *result_desc = source_desc;
+
        /*
         * If required by the target,
         * perform implicit conversion on the source before we store it.
@@ -601,10 +596,10 @@ acpi_ex_convert_to_target_type (
                default:
                        /* No conversion allowed for these types */
 
-                       if (destination_type != (*obj_desc)->common.type) {
+                       if (destination_type != source_desc->common.type) {
                                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
                                        "Target does not allow conversion of type %s to %s\n",
-                                       acpi_ut_get_type_name ((*obj_desc)->common.type),
+                                       acpi_ut_get_type_name ((source_desc)->common.type),
                                        acpi_ut_get_type_name (destination_type)));
                                status = AE_TYPE;
                        }
@@ -623,7 +618,7 @@ acpi_ex_convert_to_target_type (
                         * These types require an Integer operand.  We can convert
                         * a Buffer or a String to an Integer if necessary.
                         */
-                       status = acpi_ex_convert_to_integer (*obj_desc, obj_desc, walk_state);
+                       status = acpi_ex_convert_to_integer (source_desc, result_desc, walk_state);
                        break;
 
 
@@ -633,17 +628,17 @@ acpi_ex_convert_to_target_type (
                         * The operand must be a String.  We can convert an
                         * Integer or Buffer if necessary
                         */
-                       status = acpi_ex_convert_to_string (*obj_desc, obj_desc, 16, ACPI_UINT32_MAX, walk_state);
+                       status = acpi_ex_convert_to_string (source_desc, result_desc, 16, ACPI_UINT32_MAX, walk_state);
                        break;
 
 
                case ACPI_TYPE_BUFFER:
 
                        /*
-                        * The operand must be a String.  We can convert an
-                        * Integer or Buffer if necessary
+                        * The operand must be a Buffer.  We can convert an
+                        * Integer or String if necessary
                         */
-                       status = acpi_ex_convert_to_buffer (*obj_desc, obj_desc, walk_state);
+                       status = acpi_ex_convert_to_buffer (source_desc, result_desc, walk_state);
                        break;
                }
                break;
index be5e9c4e431d047e4fac6fee35f6c699aa5bba1f..1b876c70d5f5e32de0bd57ca6c143ea45c6b9a2d 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: excreate - Named object creation
- *              $Revision: 71 $
+ *              $Revision: 89 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 #include "acnamesp.h"
 #include "acevents.h"
 #include "acdispat.h"
+#include "actables.h"
 
 
 #define _COMPONENT          ACPI_EXECUTER
-        MODULE_NAME         ("excreate")
+        ACPI_MODULE_NAME    ("excreate")
 
 
 /*****************************************************************************
@@ -58,7 +59,7 @@ acpi_ex_create_alias (
        acpi_status             status;
 
 
-       FUNCTION_TRACE ("Ex_create_alias");
+       ACPI_FUNCTION_TRACE ("Ex_create_alias");
 
 
        /* Get the source/alias operands (both namespace nodes) */
@@ -69,7 +70,7 @@ acpi_ex_create_alias (
        /* Attach the original source object to the new Alias Node */
 
        status = acpi_ns_attach_object ((acpi_namespace_node *) walk_state->operands[0],
-                          source_node->object,
+                          acpi_ns_get_attached_object (source_node),
                           source_node->type);
 
        /*
@@ -105,7 +106,7 @@ acpi_ex_create_event (
        acpi_operand_object     *obj_desc;
 
 
-       FUNCTION_TRACE ("Ex_create_event");
+       ACPI_FUNCTION_TRACE ("Ex_create_event");
 
 
        obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_EVENT);
@@ -114,11 +115,11 @@ acpi_ex_create_event (
                goto cleanup;
        }
 
-       /* Create the actual OS semaphore */
-
-       /* TBD: [Investigate] should be created with 0 or 1 units? */
-
-       status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT, 1,
+       /*
+        * Create the actual OS semaphore, with zero initial units -- meaning
+        * that the event is created in an unsignalled state
+        */
+       status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT, 0,
                           &obj_desc->event.semaphore);
        if (ACPI_FAILURE (status)) {
                goto cleanup;
@@ -127,7 +128,7 @@ acpi_ex_create_event (
        /* Attach object to the Node */
 
        status = acpi_ns_attach_object ((acpi_namespace_node *) walk_state->operands[0],
-                          obj_desc, (u8) ACPI_TYPE_EVENT);
+                          obj_desc, ACPI_TYPE_EVENT);
 
 cleanup:
        /*
@@ -161,7 +162,7 @@ acpi_ex_create_mutex (
        acpi_operand_object     *obj_desc;
 
 
-       FUNCTION_TRACE_PTR ("Ex_create_mutex", WALK_OPERANDS);
+       ACPI_FUNCTION_TRACE_PTR ("Ex_create_mutex", ACPI_WALK_OPERANDS);
 
 
        /* Create the new mutex object */
@@ -172,8 +173,11 @@ acpi_ex_create_mutex (
                goto cleanup;
        }
 
-       /* Create the actual OS semaphore */
-
+       /*
+        * Create the actual OS semaphore.
+        * One unit max to make it a mutex, with one initial unit to allow
+        * the mutex to be acquired.
+        */
        status = acpi_os_create_semaphore (1, 1, &obj_desc->mutex.semaphore);
        if (ACPI_FAILURE (status)) {
                goto cleanup;
@@ -184,7 +188,7 @@ acpi_ex_create_mutex (
        obj_desc->mutex.sync_level = (u8) walk_state->operands[1]->integer.value;
 
        status = acpi_ns_attach_object ((acpi_namespace_node *) walk_state->operands[0],
-                         obj_desc, (u8) ACPI_TYPE_MUTEX);
+                         obj_desc, ACPI_TYPE_MUTEX);
 
 
 cleanup:
@@ -222,20 +226,21 @@ acpi_ex_create_region (
        acpi_status             status;
        acpi_operand_object     *obj_desc;
        acpi_namespace_node     *node;
+       acpi_operand_object     *region_obj2;
 
 
-       FUNCTION_TRACE ("Ex_create_region");
+       ACPI_FUNCTION_TRACE ("Ex_create_region");
 
 
        /* Get the Node from the object stack  */
 
-       node = (acpi_namespace_node *) walk_state->operands[0];
+       node = walk_state->op->node;
 
        /*
         * If the region object is already attached to this node,
         * just return
         */
-       if (node->object) {
+       if (acpi_ns_get_attached_object (node)) {
                return_ACPI_STATUS (AE_OK);
        }
 
@@ -243,9 +248,9 @@ acpi_ex_create_region (
         * Space ID must be one of the predefined IDs, or in the user-defined
         * range
         */
-       if ((region_space >= NUM_REGION_TYPES) &&
-               (region_space < USER_REGION_BEGIN)) {
-               REPORT_ERROR (("Invalid Address_space type %X\n", region_space));
+       if ((region_space >= ACPI_NUM_PREDEFINED_REGIONS) &&
+               (region_space < ACPI_USER_REGION_BEGIN)) {
+               ACPI_REPORT_ERROR (("Invalid Address_space type %X\n", region_space));
                return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID);
        }
 
@@ -261,21 +266,13 @@ acpi_ex_create_region (
                goto cleanup;
        }
 
-       /* Allocate a method object for this region */
-
-       obj_desc->region.extra = acpi_ut_create_internal_object (
-                        INTERNAL_TYPE_EXTRA);
-       if (!obj_desc->region.extra) {
-               status = AE_NO_MEMORY;
-               goto cleanup;
-       }
-
        /*
         * Remember location in AML stream of address & length
         * operands since they need to be evaluated at run time.
         */
-       obj_desc->region.extra->extra.aml_start = aml_start;
-       obj_desc->region.extra->extra.aml_length = aml_length;
+       region_obj2                 = obj_desc->common.next_object;
+       region_obj2->extra.aml_start = aml_start;
+       region_obj2->extra.aml_length = aml_length;
 
        /* Init the region from the operands */
 
@@ -286,34 +283,14 @@ acpi_ex_create_region (
 
        /* Install the new region object in the parent Node */
 
-       status = acpi_ns_attach_object (node, obj_desc,
-                         (u8) ACPI_TYPE_REGION);
-       if (ACPI_FAILURE (status)) {
-               goto cleanup;
-       }
+       status = acpi_ns_attach_object (node, obj_desc, ACPI_TYPE_REGION);
 
-       /*
-        * If we have a valid region, initialize it
-        * Namespace is NOT locked at this point.
-        */
-       status = acpi_ev_initialize_region (obj_desc, FALSE);
-       if (ACPI_FAILURE (status)) {
-               /*
-                *  If AE_NOT_EXIST is returned, it is not fatal
-                *  because many regions get created before a handler
-                *  is installed for said region.
-                */
-               if (AE_NOT_EXIST == status) {
-                       status = AE_OK;
-               }
-       }
 
 cleanup:
 
        /* Remove local reference to the object */
 
        acpi_ut_remove_reference (obj_desc);
-
        return_ACPI_STATUS (status);
 }
 
@@ -334,24 +311,81 @@ acpi_status
 acpi_ex_create_table_region (
        acpi_walk_state         *walk_state)
 {
-       acpi_status             status = AE_OK;
+       acpi_status             status;
+       acpi_operand_object     **operand = &walk_state->operands[0];
+       acpi_operand_object     *obj_desc;
+       acpi_namespace_node     *node;
+       acpi_table_header       *table;
+       acpi_operand_object     *region_obj2;
 
 
-       FUNCTION_TRACE ("Ex_create_table_region");
+       ACPI_FUNCTION_TRACE ("Ex_create_table_region");
 
-/*
-       acpi_operand_object     *Obj_desc;
-       Obj_desc = Acpi_ut_create_internal_object (ACPI_TYPE_REGION);
-       if (!Obj_desc)
-       {
-               Status = AE_NO_MEMORY;
-               goto Cleanup;
+       /* Get the Node from the object stack  */
+
+       node = walk_state->op->node;
+
+       /*
+        * If the region object is already attached to this node,
+        * just return
+        */
+       if (acpi_ns_get_attached_object (node)) {
+               return_ACPI_STATUS (AE_OK);
+       }
+
+       /* Find the ACPI table */
+
+       status = acpi_tb_find_table (operand[1]->string.pointer,
+                          operand[2]->string.pointer,
+                          operand[3]->string.pointer, &table);
+
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
        }
 
+       /* Create the region descriptor */
 
-Cleanup:
-*/
+       obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_REGION);
+       if (!obj_desc) {
+               return_ACPI_STATUS (AE_NO_MEMORY);
+       }
+
+       region_obj2                     = obj_desc->common.next_object;
+       region_obj2->extra.region_context = NULL;
+
+       /* Init the region from the operands */
+
+       obj_desc->region.space_id = REGION_DATA_TABLE;
+       obj_desc->region.address = (ACPI_PHYSICAL_ADDRESS) ACPI_TO_INTEGER (table);
+       obj_desc->region.length = table->length;
+       obj_desc->region.node   = node;
+       obj_desc->region.flags  = AOPOBJ_DATA_VALID;
+
+       /* Install the new region object in the parent Node */
 
+       status = acpi_ns_attach_object (node, obj_desc, ACPI_TYPE_REGION);
+       if (ACPI_FAILURE (status)) {
+               goto cleanup;
+       }
+
+       status = acpi_ev_initialize_region (obj_desc, FALSE);
+       if (ACPI_FAILURE (status)) {
+               if (status == AE_NOT_EXIST) {
+                       status = AE_OK;
+               }
+               else {
+                       goto cleanup;
+               }
+       }
+
+       obj_desc->region.flags |= AOPOBJ_SETUP_COMPLETE;
+
+
+cleanup:
+
+       /* Remove local reference to the object */
+
+       acpi_ut_remove_reference (obj_desc);
        return_ACPI_STATUS (status);
 }
 
@@ -381,7 +415,7 @@ acpi_ex_create_processor (
        acpi_status             status;
 
 
-       FUNCTION_TRACE_PTR ("Ex_create_processor", walk_state);
+       ACPI_FUNCTION_TRACE_PTR ("Ex_create_processor", walk_state);
 
 
        /* Create the processor object */
@@ -401,7 +435,7 @@ acpi_ex_create_processor (
        /* Install the processor object in the parent Node */
 
        status = acpi_ns_attach_object ((acpi_namespace_node *) operand[0],
-                         obj_desc, (u8) ACPI_TYPE_PROCESSOR);
+                         obj_desc, ACPI_TYPE_PROCESSOR);
 
 
        /* Remove local reference to the object */
@@ -436,7 +470,7 @@ acpi_ex_create_power_resource (
        acpi_operand_object     *obj_desc;
 
 
-       FUNCTION_TRACE_PTR ("Ex_create_power_resource", walk_state);
+       ACPI_FUNCTION_TRACE_PTR ("Ex_create_power_resource", walk_state);
 
 
        /* Create the power resource object */
@@ -454,7 +488,7 @@ acpi_ex_create_power_resource (
        /* Install the  power resource object in the parent Node */
 
        status = acpi_ns_attach_object ((acpi_namespace_node *) operand[0],
-                         obj_desc, (u8) ACPI_TYPE_POWER);
+                         obj_desc, ACPI_TYPE_POWER);
 
 
        /* Remove local reference to the object */
@@ -491,7 +525,7 @@ acpi_ex_create_method (
        u8                      method_flags;
 
 
-       FUNCTION_TRACE_PTR ("Ex_create_method", walk_state);
+       ACPI_FUNCTION_TRACE_PTR ("Ex_create_method", walk_state);
 
 
        /* Create a new method object */
@@ -533,7 +567,7 @@ acpi_ex_create_method (
        /* Attach the new object to the method Node */
 
        status = acpi_ns_attach_object ((acpi_namespace_node *) operand[0],
-                         obj_desc, (u8) ACPI_TYPE_METHOD);
+                         obj_desc, ACPI_TYPE_METHOD);
 
        /* Remove local reference to the object */
 
index 9811ee89f6a7592a6ba05b25ce3998d49261923e..70cbe293359eacfbb50677818e8327b4658b5514 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: exdump - Interpreter debug output routines
- *              $Revision: 126 $
+ *              $Revision: 145 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -32,7 +32,7 @@
 #include "acparser.h"
 
 #define _COMPONENT          ACPI_EXECUTER
-        MODULE_NAME         ("exdump")
+        ACPI_MODULE_NAME    ("exdump")
 
 
 /*
@@ -69,11 +69,16 @@ acpi_ex_show_hex_value (
        u8                      *current_aml_ptr = NULL; /* Pointer to current byte of AML value    */
 
 
-       FUNCTION_TRACE ("Ex_show_hex_value");
+       ACPI_FUNCTION_TRACE ("Ex_show_hex_value");
 
 
+       if (!((ACPI_LV_LOAD & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer))) {
+               return;
+       }
+
        if (!aml_start) {
-               REPORT_ERROR (("Ex_show_hex_value: null pointer\n"));
+               ACPI_REPORT_ERROR (("Ex_show_hex_value: null pointer\n"));
+               return;
        }
 
        /*
@@ -97,26 +102,25 @@ acpi_ex_show_hex_value (
        }
 
        for (length = lead_space; length; --length ) {
-               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_LOAD, " "));
+               acpi_os_printf (" ");
        }
 
        while (byte_count--) {
-               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_LOAD, "%02x", *aml_start++));
-
+               acpi_os_printf ("%02x", *aml_start++);
                if (byte_count) {
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_LOAD, " "));
+                       acpi_os_printf (" ");
                }
        }
 
        if (show_decimal_value) {
-               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_LOAD, " [%d]", value));
+               acpi_os_printf (" [%d]", value);
        }
 
        if (0 == lead_space) {
-               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_LOAD, " "));
+               acpi_os_printf (" ");
        }
 
-       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_LOAD, "\n"));
+       acpi_os_printf ("\n");
        return_VOID;
 }
 
@@ -125,27 +129,31 @@ acpi_ex_show_hex_value (
  *
  * FUNCTION:    Acpi_ex_dump_operand
  *
- * PARAMETERS:  *Entry_desc         - Pointer to entry to be dumped
+ * PARAMETERS:  *Obj_desc         - Pointer to entry to be dumped
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Dump a stack entry
+ * DESCRIPTION: Dump an operand object
  *
  ****************************************************************************/
 
 acpi_status
 acpi_ex_dump_operand (
-       acpi_operand_object     *entry_desc)
+       acpi_operand_object     *obj_desc)
 {
        u8                      *buf = NULL;
        u32                     length;
        u32                     i;
 
 
-       PROC_NAME ("Ex_dump_operand")
+       ACPI_FUNCTION_NAME ("Ex_dump_operand")
+
 
+       if (!((ACPI_LV_INFO & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer))) {
+               return (AE_OK);
+       }
 
-       if (!entry_desc) {
+       if (!obj_desc) {
                /*
                 * This usually indicates that something serious is wrong --
                 * since most (if not all)
@@ -155,117 +163,117 @@ acpi_ex_dump_operand (
                return (AE_OK);
        }
 
-       if (VALID_DESCRIPTOR_TYPE (entry_desc, ACPI_DESC_TYPE_NAMED)) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%p NS Node: ", entry_desc));
-               DUMP_ENTRY (entry_desc, ACPI_LV_INFO);
+       if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) {
+               ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%p NS Node: ", obj_desc));
+               ACPI_DUMP_ENTRY (obj_desc, ACPI_LV_INFO);
                return (AE_OK);
        }
 
-       if (!VALID_DESCRIPTOR_TYPE (entry_desc, ACPI_DESC_TYPE_INTERNAL)) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%p Is not a local object \n", entry_desc));
-               DUMP_BUFFER (entry_desc, sizeof (acpi_operand_object));
+       if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_INTERNAL) {
+               ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%p is not a local object\n", obj_desc));
+               ACPI_DUMP_BUFFER (obj_desc, sizeof (acpi_operand_object));
                return (AE_OK);
        }
 
-       /*  Entry_desc is a valid object */
+       /*  Obj_desc is a valid object */
 
-       ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%p ", entry_desc));
+       ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%p ", obj_desc));
 
-       switch (entry_desc->common.type) {
+       switch (obj_desc->common.type) {
        case INTERNAL_TYPE_REFERENCE:
 
-               switch (entry_desc->reference.opcode) {
+               switch (obj_desc->reference.opcode) {
                case AML_ZERO_OP:
 
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Reference: Zero\n"));
+                       acpi_os_printf ("Reference: Zero\n");
                        break;
 
 
                case AML_ONE_OP:
 
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Reference: One\n"));
+                       acpi_os_printf ("Reference: One\n");
                        break;
 
 
                case AML_ONES_OP:
 
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Reference: Ones\n"));
+                       acpi_os_printf ("Reference: Ones\n");
                        break;
 
 
                case AML_REVISION_OP:
 
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Reference: Revision\n"));
+                       acpi_os_printf ("Reference: Revision\n");
                        break;
 
 
                case AML_DEBUG_OP:
 
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Reference: Debug\n"));
+                       acpi_os_printf ("Reference: Debug\n");
                        break;
 
 
                case AML_NAME_OP:
 
-                       DUMP_PATHNAME (entry_desc->reference.object, "Reference: Name: ",
+                       ACPI_DUMP_PATHNAME (obj_desc->reference.object, "Reference: Name: ",
                                          ACPI_LV_INFO, _COMPONENT);
-                       DUMP_ENTRY (entry_desc->reference.object, ACPI_LV_INFO);
+                       ACPI_DUMP_ENTRY (obj_desc->reference.object, ACPI_LV_INFO);
                        break;
 
 
                case AML_INDEX_OP:
 
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Reference: Index %p\n",
-                                        entry_desc->reference.object));
+                       acpi_os_printf ("Reference: Index %p\n",
+                                        obj_desc->reference.object);
                        break;
 
 
                case AML_ARG_OP:
 
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Reference: Arg%d",
-                                        entry_desc->reference.offset));
+                       acpi_os_printf ("Reference: Arg%d",
+                                        obj_desc->reference.offset);
 
-                       if (ACPI_TYPE_INTEGER == entry_desc->common.type) {
+                       if (ACPI_TYPE_INTEGER == obj_desc->common.type) {
                                /* Value is a Number */
 
-                               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, " value is [%8.8X%8.8x]",
-                                                 HIDWORD(entry_desc->integer.value),
-                                                 LODWORD(entry_desc->integer.value)));
+                               acpi_os_printf (" value is [%8.8X%8.8x]",
+                                                ACPI_HIDWORD(obj_desc->integer.value),
+                                                ACPI_LODWORD(obj_desc->integer.value));
                        }
 
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "\n"));
+                       acpi_os_printf ("\n");
                        break;
 
 
                case AML_LOCAL_OP:
 
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Reference: Local%d",
-                                        entry_desc->reference.offset));
+                       acpi_os_printf ("Reference: Local%d",
+                                        obj_desc->reference.offset);
 
-                       if (ACPI_TYPE_INTEGER == entry_desc->common.type) {
+                       if (ACPI_TYPE_INTEGER == obj_desc->common.type) {
 
                                /* Value is a Number */
 
-                               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, " value is [%8.8X%8.8x]",
-                                                 HIDWORD(entry_desc->integer.value),
-                                                 LODWORD(entry_desc->integer.value)));
+                               acpi_os_printf (" value is [%8.8X%8.8x]",
+                                                ACPI_HIDWORD(obj_desc->integer.value),
+                                                ACPI_LODWORD(obj_desc->integer.value));
                        }
 
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "\n"));
+                       acpi_os_printf ("\n");
                        break;
 
 
                case AML_INT_NAMEPATH_OP:
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Reference.Node->Name %X\n",
-                                        entry_desc->reference.node->name));
+                       acpi_os_printf ("Reference.Node->Name %X\n",
+                                        obj_desc->reference.node->name);
                        break;
 
                default:
 
                        /*  unknown opcode  */
 
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Unknown opcode=%X\n",
-                               entry_desc->reference.opcode));
+                       acpi_os_printf ("Unknown opcode=%X\n",
+                               obj_desc->reference.opcode);
                        break;
 
                }
@@ -275,11 +283,11 @@ acpi_ex_dump_operand (
 
        case ACPI_TYPE_BUFFER:
 
-               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Buffer len %X @ %p \n",
-                                entry_desc->buffer.length,
-                                entry_desc->buffer.pointer));
+               acpi_os_printf ("Buffer len %X @ %p \n",
+                                obj_desc->buffer.length,
+                                obj_desc->buffer.pointer);
 
-               length = entry_desc->buffer.length;
+               length = obj_desc->buffer.length;
 
                if (length > 64) {
                        length = 64;
@@ -287,13 +295,13 @@ acpi_ex_dump_operand (
 
                /* Debug only -- dump the buffer contents */
 
-               if (entry_desc->buffer.pointer) {
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Buffer Contents: "));
+               if (obj_desc->buffer.pointer) {
+                       acpi_os_printf ("Buffer Contents: ");
 
-                       for (buf = entry_desc->buffer.pointer; length--; ++buf) {
-                               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, " %02x", *buf));
+                       for (buf = obj_desc->buffer.pointer; length--; ++buf) {
+                               acpi_os_printf (" %02x", *buf);
                        }
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO,"\n"));
+                       acpi_os_printf ("\n");
                }
 
                break;
@@ -301,135 +309,136 @@ acpi_ex_dump_operand (
 
        case ACPI_TYPE_INTEGER:
 
-               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Integer %8.8X%8.8X\n",
-                                HIDWORD (entry_desc->integer.value),
-                                LODWORD (entry_desc->integer.value)));
+               acpi_os_printf ("Integer %8.8X%8.8X\n",
+                                ACPI_HIDWORD (obj_desc->integer.value),
+                                ACPI_LODWORD (obj_desc->integer.value));
                break;
 
 
        case INTERNAL_TYPE_IF:
 
-               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "If [Integer] %8.8X%8.8X\n",
-                                HIDWORD (entry_desc->integer.value),
-                                LODWORD (entry_desc->integer.value)));
+               acpi_os_printf ("If [Integer] %8.8X%8.8X\n",
+                                ACPI_HIDWORD (obj_desc->integer.value),
+                                ACPI_LODWORD (obj_desc->integer.value));
                break;
 
 
        case INTERNAL_TYPE_WHILE:
 
-               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "While [Integer] %8.8X%8.8X\n",
-                                HIDWORD (entry_desc->integer.value),
-                                LODWORD (entry_desc->integer.value)));
+               acpi_os_printf ("While [Integer] %8.8X%8.8X\n",
+                                ACPI_HIDWORD (obj_desc->integer.value),
+                                ACPI_LODWORD (obj_desc->integer.value));
                break;
 
 
        case ACPI_TYPE_PACKAGE:
 
-               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Package count %X @ %p\n",
-                                entry_desc->package.count, entry_desc->package.elements));
+               acpi_os_printf ("Package count %X @ %p\n",
+                                obj_desc->package.count, obj_desc->package.elements);
 
                /*
                 * If elements exist, package vector pointer is valid,
                 * and debug_level exceeds 1, dump package's elements.
                 */
-               if (entry_desc->package.count &&
-                       entry_desc->package.elements &&
+               if (obj_desc->package.count &&
+                       obj_desc->package.elements &&
                        acpi_dbg_level > 1) {
                        acpi_operand_object**element;
                        u16                 element_index;
 
-                       for (element_index = 0, element = entry_desc->package.elements;
-                                 element_index < entry_desc->package.count;
+                       for (element_index = 0, element = obj_desc->package.elements;
+                                 element_index < obj_desc->package.count;
                                  ++element_index, ++element) {
                                acpi_ex_dump_operand (*element);
                        }
                }
 
-               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "\n"));
+               acpi_os_printf ("\n");
 
                break;
 
 
        case ACPI_TYPE_REGION:
 
-               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Region %s (%X)",
-                       acpi_ut_get_region_name (entry_desc->region.space_id),
-                       entry_desc->region.space_id));
+               acpi_os_printf ("Region %s (%X)",
+                       acpi_ut_get_region_name (obj_desc->region.space_id),
+                       obj_desc->region.space_id);
 
                /*
                 * If the address and length have not been evaluated,
                 * don't print them.
                 */
-               if (!(entry_desc->region.flags & AOPOBJ_DATA_VALID)) {
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "\n"));
+               if (!(obj_desc->region.flags & AOPOBJ_DATA_VALID)) {
+                       acpi_os_printf ("\n");
                }
                else {
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, " base %8.8X%8.8X Length %X\n",
-                               HIDWORD(entry_desc->region.address),
-                               LODWORD(entry_desc->region.address),
-                               entry_desc->region.length));
+                       acpi_os_printf (" base %8.8X%8.8X Length %X\n",
+                               ACPI_HIDWORD (obj_desc->region.address),
+                               ACPI_LODWORD (obj_desc->region.address),
+                               obj_desc->region.length);
                }
                break;
 
 
        case ACPI_TYPE_STRING:
 
-               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "String length %X @ %p \"",
-                                entry_desc->string.length, entry_desc->string.pointer));
+               acpi_os_printf ("String length %X @ %p \"",
+                                obj_desc->string.length, obj_desc->string.pointer);
 
-               for (i = 0; i < entry_desc->string.length; i++) {
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "%c",
-                                        entry_desc->string.pointer[i]));
+               for (i = 0; i < obj_desc->string.length; i++) {
+                       acpi_os_printf ("%c",
+                                        obj_desc->string.pointer[i]);
                }
 
-               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "\"\n"));
+               acpi_os_printf ("\"\n");
                break;
 
 
        case INTERNAL_TYPE_BANK_FIELD:
 
-               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Bank_field\n"));
+               acpi_os_printf ("Bank_field\n");
                break;
 
 
        case INTERNAL_TYPE_REGION_FIELD:
 
-               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO,
-                       "Region_field: bits=%X bitaccwidth=%X lock=%X update=%X at byte=%X bit=%X of below:\n",
-                       entry_desc->field.bit_length,    entry_desc->field.access_bit_width,
-                       entry_desc->field.lock_rule,     entry_desc->field.update_rule,
-                       entry_desc->field.base_byte_offset, entry_desc->field.start_field_bit_offset));
-               DUMP_STACK_ENTRY (entry_desc->field.region_obj);
+               acpi_os_printf (
+                       "Region_field: Bits=%X Acc_width=%X Lock=%X Update=%X at byte=%X bit=%X of below:\n",
+                       obj_desc->field.bit_length, obj_desc->field.access_byte_width,
+                       obj_desc->field.field_flags & AML_FIELD_LOCK_RULE_MASK,
+                       obj_desc->field.field_flags & AML_FIELD_UPDATE_RULE_MASK,
+                       obj_desc->field.base_byte_offset, obj_desc->field.start_field_bit_offset);
+               ACPI_DUMP_STACK_ENTRY (obj_desc->field.region_obj);
                break;
 
 
        case INTERNAL_TYPE_INDEX_FIELD:
 
-               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Index_field\n"));
+               acpi_os_printf ("Index_field\n");
                break;
 
 
        case ACPI_TYPE_BUFFER_FIELD:
 
-               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO,
+               acpi_os_printf (
                        "Buffer_field: %X bits at byte %X bit %X of \n",
-                       entry_desc->buffer_field.bit_length, entry_desc->buffer_field.base_byte_offset,
-                       entry_desc->buffer_field.start_field_bit_offset));
+                       obj_desc->buffer_field.bit_length, obj_desc->buffer_field.base_byte_offset,
+                       obj_desc->buffer_field.start_field_bit_offset);
 
-               if (!entry_desc->buffer_field.buffer_obj)
+               if (!obj_desc->buffer_field.buffer_obj)
                {
                        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "*NULL* \n"));
                }
 
                else if (ACPI_TYPE_BUFFER !=
-                                 entry_desc->buffer_field.buffer_obj->common.type)
+                                 obj_desc->buffer_field.buffer_obj->common.type)
                {
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "*not a Buffer* \n"));
+                       acpi_os_printf ("*not a Buffer* \n");
                }
 
                else
                {
-                       DUMP_STACK_ENTRY (entry_desc->buffer_field.buffer_obj);
+                       ACPI_DUMP_STACK_ENTRY (obj_desc->buffer_field.buffer_obj);
                }
 
                break;
@@ -437,68 +446,54 @@ acpi_ex_dump_operand (
 
        case ACPI_TYPE_EVENT:
 
-               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Event\n"));
+               acpi_os_printf ("Event\n");
                break;
 
 
        case ACPI_TYPE_METHOD:
 
-               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO,
+               acpi_os_printf (
                        "Method(%X) @ %p:%X\n",
-                       entry_desc->method.param_count,
-                       entry_desc->method.aml_start, entry_desc->method.aml_length));
+                       obj_desc->method.param_count,
+                       obj_desc->method.aml_start, obj_desc->method.aml_length);
                break;
 
 
        case ACPI_TYPE_MUTEX:
 
-               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Mutex\n"));
+               acpi_os_printf ("Mutex\n");
                break;
 
 
        case ACPI_TYPE_DEVICE:
 
-               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Device\n"));
+               acpi_os_printf ("Device\n");
                break;
 
 
        case ACPI_TYPE_POWER:
 
-               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Power\n"));
+               acpi_os_printf ("Power\n");
                break;
 
 
        case ACPI_TYPE_PROCESSOR:
 
-               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Processor\n"));
+               acpi_os_printf ("Processor\n");
                break;
 
 
        case ACPI_TYPE_THERMAL:
 
-               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Thermal\n"));
+               acpi_os_printf ("Thermal\n");
                break;
 
 
        default:
-               /*  unknown Entry_desc->Common.Type value   */
+               /*  unknown Obj_desc->Common.Type value   */
 
-               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "Unknown Type %X\n",
-                       entry_desc->common.type));
-
-               /* Back up to previous entry */
-
-               entry_desc--;
-
-
-               /* TBD: [Restructure]  Change to use dump object routine !! */
-               /*       What is all of this?? */
-
-               DUMP_BUFFER (entry_desc, sizeof (acpi_operand_object));
-               DUMP_BUFFER (++entry_desc, sizeof (acpi_operand_object));
-               DUMP_BUFFER (++entry_desc, sizeof (acpi_operand_object));
+               acpi_os_printf ("Unknown Type %X\n", obj_desc->common.type);
                break;
-
        }
 
        return (AE_OK);
@@ -521,7 +516,7 @@ acpi_ex_dump_operand (
 void
 acpi_ex_dump_operands (
        acpi_operand_object     **operands,
-       operating_mode          interpreter_mode,
+       acpi_interpreter_mode   interpreter_mode,
        NATIVE_CHAR             *ident,
        u32                     num_levels,
        NATIVE_CHAR             *note,
@@ -529,10 +524,10 @@ acpi_ex_dump_operands (
        u32                     line_number)
 {
        NATIVE_UINT             i;
-       acpi_operand_object     **entry_desc;
+       acpi_operand_object     **obj_desc;
 
 
-       PROC_NAME ("Ex_dump_operands");
+       ACPI_FUNCTION_NAME ("Ex_dump_operands");
 
 
        if (!ident)
@@ -559,9 +554,9 @@ acpi_ex_dump_operands (
 
        for (i = 0; num_levels > 0; i--, num_levels--)
        {
-               entry_desc = &operands[i];
+               obj_desc = &operands[i];
 
-               if (ACPI_FAILURE (acpi_ex_dump_operand (*entry_desc)))
+               if (ACPI_FAILURE (acpi_ex_dump_operand (*obj_desc)))
                {
                        break;
                }
@@ -574,6 +569,57 @@ acpi_ex_dump_operands (
 }
 
 
+/*****************************************************************************
+ *
+ * FUNCTION:    Acpi_ex_out*
+ *
+ * PARAMETERS:  Title               - Descriptive text
+ *              Value               - Value to be displayed
+ *
+ * DESCRIPTION: Object dump output formatting functions.  These functions
+ *              reduce the number of format strings required and keeps them
+ *              all in one place for easy modification.
+ *
+ ****************************************************************************/
+
+void
+acpi_ex_out_string (
+       char                    *title,
+       char                    *value)
+{
+       acpi_os_printf ("%20s : %s\n", title, value);
+}
+
+void
+acpi_ex_out_pointer (
+       char                    *title,
+       void                    *value)
+{
+       acpi_os_printf ("%20s : %p\n", title, value);
+}
+
+void
+acpi_ex_out_integer (
+       char                    *title,
+       u32                     value)
+{
+       acpi_os_printf ("%20s : %X\n", title, value);
+}
+
+void
+acpi_ex_out_address (
+       char                    *title,
+       ACPI_PHYSICAL_ADDRESS   value)
+{
+#ifdef _IA16
+       acpi_os_printf ("%20s : %p\n", title, value);
+#else
+       acpi_os_printf ("%20s : %8.8X%8.8X\n", title,
+                        ACPI_HIDWORD (value), ACPI_LODWORD (value));
+#endif
+}
+
+
 /*****************************************************************************
  *
  * FUNCTION:    Acpi_ex_dump_node
@@ -591,7 +637,7 @@ acpi_ex_dump_node (
        u32                     flags)
 {
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        if (!flags)
@@ -603,15 +649,15 @@ acpi_ex_dump_node (
        }
 
 
-       acpi_os_printf ("%20s : %4.4s\n", "Name",           (char*)&node->name);
-       acpi_os_printf ("%20s : %s\n",  "Type",             acpi_ut_get_type_name (node->type));
-       acpi_os_printf ("%20s : %X\n",  "Flags",            node->flags);
-       acpi_os_printf ("%20s : %X\n",  "Owner Id",         node->owner_id);
-       acpi_os_printf ("%20s : %X\n",  "Reference Count",  node->reference_count);
-       acpi_os_printf ("%20s : %p\n",  "Attached Object",  node->object);
-       acpi_os_printf ("%20s : %p\n",  "Child_list",       node->child);
-       acpi_os_printf ("%20s : %p\n",  "Next_peer",        node->peer);
-       acpi_os_printf ("%20s : %p\n",  "Parent",           acpi_ns_get_parent_object (node));
+       acpi_os_printf ("%20s : %4.4s\n",     "Name", (char *) &node->name);
+       acpi_ex_out_string ("Type",           acpi_ut_get_type_name (node->type));
+       acpi_ex_out_integer ("Flags",         node->flags);
+       acpi_ex_out_integer ("Owner Id",      node->owner_id);
+       acpi_ex_out_integer ("Reference Count", node->reference_count);
+       acpi_ex_out_pointer ("Attached Object", acpi_ns_get_attached_object (node));
+       acpi_ex_out_pointer ("Child_list",    node->child);
+       acpi_ex_out_pointer ("Next_peer",     node->peer);
+       acpi_ex_out_pointer ("Parent",        acpi_ns_get_parent_node (node));
 }
 
 
@@ -631,10 +677,10 @@ acpi_ex_dump_object_descriptor (
        acpi_operand_object     *obj_desc,
        u32                     flags)
 {
-       const acpi_opcode_info  *op_info;
+       u32                     i;
 
 
-       FUNCTION_TRACE ("Ex_dump_object_descriptor");
+       ACPI_FUNCTION_TRACE ("Ex_dump_object_descriptor");
 
 
        if (!flags)
@@ -645,16 +691,17 @@ acpi_ex_dump_object_descriptor (
                }
        }
 
-       if (!(VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_INTERNAL)))
+       if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_INTERNAL)
        {
-               acpi_os_printf ("%p is not a valid ACPI object\n", obj_desc);
+               acpi_os_printf ("Ex_dump_object_descriptor: %p is not a valid ACPI object\n", obj_desc);
                return;
        }
 
        /* Common Fields */
 
-       acpi_os_printf ("%20s : %X\n", "Reference Count", obj_desc->common.reference_count);
-       acpi_os_printf ("%20s : %X\n", "Flags", obj_desc->common.flags);
+       acpi_ex_out_string ("Type",          acpi_ut_get_type_name (obj_desc->common.type));
+       acpi_ex_out_integer ("Reference Count", obj_desc->common.reference_count);
+       acpi_ex_out_integer ("Flags",        obj_desc->common.flags);
 
        /* Object-specific Fields */
 
@@ -662,198 +709,189 @@ acpi_ex_dump_object_descriptor (
        {
        case ACPI_TYPE_INTEGER:
 
-               acpi_os_printf ("%20s : %s\n", "Type", "Integer");
-               acpi_os_printf ("%20s : %X%8.8X\n", "Value", HIDWORD (obj_desc->integer.value),
-                                 LODWORD (obj_desc->integer.value));
+               acpi_os_printf ("%20s : %X%8.8X\n", "Value",
+                                 ACPI_HIDWORD (obj_desc->integer.value),
+                                 ACPI_LODWORD (obj_desc->integer.value));
                break;
 
 
        case ACPI_TYPE_STRING:
 
-               acpi_os_printf ("%20s : %s\n", "Type", "String");
-               acpi_os_printf ("%20s : %X\n", "Length", obj_desc->string.length);
-               acpi_os_printf ("%20s : %p\n", "Pointer", obj_desc->string.pointer);
+               acpi_ex_out_integer ("Length",       obj_desc->string.length);
+               acpi_ex_out_pointer ("Pointer",      obj_desc->string.pointer);
                break;
 
 
        case ACPI_TYPE_BUFFER:
 
-               acpi_os_printf ("%20s : %s\n", "Type", "Buffer");
-               acpi_os_printf ("%20s : %X\n", "Length", obj_desc->buffer.length);
-               acpi_os_printf ("%20s : %p\n", "Pointer", obj_desc->buffer.pointer);
+               acpi_ex_out_integer ("Length",       obj_desc->buffer.length);
+               acpi_ex_out_pointer ("Pointer",      obj_desc->buffer.pointer);
                break;
 
 
        case ACPI_TYPE_PACKAGE:
 
-               acpi_os_printf ("%20s : %s\n", "Type", "Package");
-               acpi_os_printf ("%20s : %X\n", "Flags", obj_desc->package.flags);
-               acpi_os_printf ("%20s : %X\n", "Count", obj_desc->package.count);
-               acpi_os_printf ("%20s : %p\n", "Elements", obj_desc->package.elements);
-               acpi_os_printf ("%20s : %p\n", "Next_element", obj_desc->package.next_element);
-               break;
-
+               acpi_ex_out_integer ("Flags",        obj_desc->package.flags);
+               acpi_ex_out_integer ("Count",        obj_desc->package.count);
+               acpi_ex_out_pointer ("Elements",     obj_desc->package.elements);
+               acpi_ex_out_pointer ("Next_element", obj_desc->package.next_element);
 
-       case ACPI_TYPE_BUFFER_FIELD:
+               /* Dump the package contents */
 
-               acpi_os_printf ("%20s : %s\n", "Type", "Buffer_field");
-               acpi_os_printf ("%20s : %X\n", "Bit_length", obj_desc->buffer_field.bit_length);
-               acpi_os_printf ("%20s : %X\n", "Bit_offset", obj_desc->buffer_field.start_field_bit_offset);
-               acpi_os_printf ("%20s : %X\n", "Base_byte_offset",obj_desc->buffer_field.base_byte_offset);
-               acpi_os_printf ("%20s : %p\n", "Buffer_obj", obj_desc->buffer_field.buffer_obj);
+               if (obj_desc->package.count > 0)
+               {
+                       acpi_os_printf ("\n_package Contents:\n");
+                       for (i = 0; i < obj_desc->package.count; i++)
+                       {
+                               acpi_os_printf ("[%.3d] %p", i, obj_desc->package.elements[i]);
+                               if (obj_desc->package.elements[i])
+                               {
+                                       acpi_os_printf (" %s", acpi_ut_get_type_name ((obj_desc->package.elements[i])->common.type));
+                               }
+                               acpi_os_printf ("\n");
+                       }
+               }
                break;
 
 
        case ACPI_TYPE_DEVICE:
 
-               acpi_os_printf ("%20s : %s\n", "Type", "Device");
-               acpi_os_printf ("%20s : %p\n", "Addr_handler", obj_desc->device.addr_handler);
-               acpi_os_printf ("%20s : %p\n", "Sys_handler", obj_desc->device.sys_handler);
-               acpi_os_printf ("%20s : %p\n", "Drv_handler", obj_desc->device.drv_handler);
+               acpi_ex_out_pointer ("Addr_handler", obj_desc->device.addr_handler);
+               acpi_ex_out_pointer ("Sys_handler",  obj_desc->device.sys_handler);
+               acpi_ex_out_pointer ("Drv_handler",  obj_desc->device.drv_handler);
                break;
 
+
        case ACPI_TYPE_EVENT:
 
-               acpi_os_printf ("%20s : %s\n", "Type", "Event");
-               acpi_os_printf ("%20s : %X\n", "Semaphore", obj_desc->event.semaphore);
+               acpi_ex_out_pointer ("Semaphore",    obj_desc->event.semaphore);
                break;
 
 
        case ACPI_TYPE_METHOD:
 
-               acpi_os_printf ("%20s : %s\n", "Type", "Method");
-               acpi_os_printf ("%20s : %X\n", "Param_count", obj_desc->method.param_count);
-               acpi_os_printf ("%20s : %X\n", "Concurrency", obj_desc->method.concurrency);
-               acpi_os_printf ("%20s : %p\n", "Semaphore", obj_desc->method.semaphore);
-               acpi_os_printf ("%20s : %X\n", "Aml_length", obj_desc->method.aml_length);
-               acpi_os_printf ("%20s : %X\n", "Aml_start", obj_desc->method.aml_start);
+               acpi_ex_out_integer ("Param_count",  obj_desc->method.param_count);
+               acpi_ex_out_integer ("Concurrency",  obj_desc->method.concurrency);
+               acpi_ex_out_pointer ("Semaphore",    obj_desc->method.semaphore);
+               acpi_ex_out_integer ("Owning_id",    obj_desc->method.owning_id);
+               acpi_ex_out_integer ("Aml_length",   obj_desc->method.aml_length);
+               acpi_ex_out_pointer ("Aml_start",    obj_desc->method.aml_start);
                break;
 
 
        case ACPI_TYPE_MUTEX:
 
-               acpi_os_printf ("%20s : %s\n", "Type", "Mutex");
-               acpi_os_printf ("%20s : %X\n", "Sync_level", obj_desc->mutex.sync_level);
-               acpi_os_printf ("%20s : %p\n", "Owner", obj_desc->mutex.owner);
-               acpi_os_printf ("%20s : %X\n", "Acquisition_depth", obj_desc->mutex.acquisition_depth);
-               acpi_os_printf ("%20s : %p\n", "Semaphore", obj_desc->mutex.semaphore);
+               acpi_ex_out_integer ("Sync_level",   obj_desc->mutex.sync_level);
+               acpi_ex_out_pointer ("Owner_thread", obj_desc->mutex.owner_thread);
+               acpi_ex_out_integer ("Acquisition_depth",obj_desc->mutex.acquisition_depth);
+               acpi_ex_out_pointer ("Semaphore",    obj_desc->mutex.semaphore);
                break;
 
 
        case ACPI_TYPE_REGION:
 
-               acpi_os_printf ("%20s : %s\n", "Type", "Region");
-               acpi_os_printf ("%20s : %X\n", "Space_id", obj_desc->region.space_id);
-               acpi_os_printf ("%20s : %X\n", "Flags", obj_desc->region.flags);
-               acpi_os_printf ("%20s : %X\n", "Address", obj_desc->region.address);
-               acpi_os_printf ("%20s : %X\n", "Length", obj_desc->region.length);
-               acpi_os_printf ("%20s : %p\n", "Addr_handler", obj_desc->region.addr_handler);
-               acpi_os_printf ("%20s : %p\n", "Next", obj_desc->region.next);
+               acpi_ex_out_integer ("Space_id",     obj_desc->region.space_id);
+               acpi_ex_out_integer ("Flags",        obj_desc->region.flags);
+               acpi_ex_out_address ("Address",      obj_desc->region.address);
+               acpi_ex_out_integer ("Length",       obj_desc->region.length);
+               acpi_ex_out_pointer ("Addr_handler", obj_desc->region.addr_handler);
+               acpi_ex_out_pointer ("Next",         obj_desc->region.next);
                break;
 
 
        case ACPI_TYPE_POWER:
 
-               acpi_os_printf ("%20s : %s\n", "Type", "Power_resource");
-               acpi_os_printf ("%20s : %X\n", "System_level", obj_desc->power_resource.system_level);
-               acpi_os_printf ("%20s : %X\n", "Resource_order", obj_desc->power_resource.resource_order);
-               acpi_os_printf ("%20s : %p\n", "Sys_handler", obj_desc->power_resource.sys_handler);
-               acpi_os_printf ("%20s : %p\n", "Drv_handler", obj_desc->power_resource.drv_handler);
+               acpi_ex_out_integer ("System_level", obj_desc->power_resource.system_level);
+               acpi_ex_out_integer ("Resource_order", obj_desc->power_resource.resource_order);
+               acpi_ex_out_pointer ("Sys_handler",  obj_desc->power_resource.sys_handler);
+               acpi_ex_out_pointer ("Drv_handler",  obj_desc->power_resource.drv_handler);
                break;
 
 
        case ACPI_TYPE_PROCESSOR:
 
-               acpi_os_printf ("%20s : %s\n", "Type", "Processor");
-               acpi_os_printf ("%20s : %X\n", "Processor ID", obj_desc->processor.proc_id);
-               acpi_os_printf ("%20s : %X\n", "Length", obj_desc->processor.length);
-               acpi_os_printf ("%20s : %X\n", "Address", obj_desc->processor.address);
-               acpi_os_printf ("%20s : %p\n", "Sys_handler", obj_desc->processor.sys_handler);
-               acpi_os_printf ("%20s : %p\n", "Drv_handler", obj_desc->processor.drv_handler);
-               acpi_os_printf ("%20s : %p\n", "Addr_handler", obj_desc->processor.addr_handler);
+               acpi_ex_out_integer ("Processor ID", obj_desc->processor.proc_id);
+               acpi_ex_out_integer ("Length",       obj_desc->processor.length);
+               acpi_ex_out_integer ("Address",      obj_desc->processor.address);
+               acpi_ex_out_pointer ("Sys_handler",  obj_desc->processor.sys_handler);
+               acpi_ex_out_pointer ("Drv_handler",  obj_desc->processor.drv_handler);
+               acpi_ex_out_pointer ("Addr_handler", obj_desc->processor.addr_handler);
                break;
 
 
        case ACPI_TYPE_THERMAL:
 
-               acpi_os_printf ("%20s : %s\n", "Type", "Thermal_zone");
-               acpi_os_printf ("%20s : %p\n", "Sys_handler", obj_desc->thermal_zone.sys_handler);
-               acpi_os_printf ("%20s : %p\n", "Drv_handler", obj_desc->thermal_zone.drv_handler);
-               acpi_os_printf ("%20s : %p\n", "Addr_handler", obj_desc->thermal_zone.addr_handler);
+               acpi_ex_out_pointer ("Sys_handler",  obj_desc->thermal_zone.sys_handler);
+               acpi_ex_out_pointer ("Drv_handler",  obj_desc->thermal_zone.drv_handler);
+               acpi_ex_out_pointer ("Addr_handler", obj_desc->thermal_zone.addr_handler);
                break;
 
 
+       case ACPI_TYPE_BUFFER_FIELD:
        case INTERNAL_TYPE_REGION_FIELD:
-
-               acpi_os_printf ("%20s : %p\n", "Access_bit_width", obj_desc->field.access_bit_width);
-               acpi_os_printf ("%20s : %p\n", "Bit_length", obj_desc->field.bit_length);
-               acpi_os_printf ("%20s : %p\n", "Base_byte_offset",obj_desc->field.base_byte_offset);
-               acpi_os_printf ("%20s : %p\n", "Bit_offset", obj_desc->field.start_field_bit_offset);
-               acpi_os_printf ("%20s : %p\n", "Region_obj", obj_desc->field.region_obj);
-               break;
-
-
        case INTERNAL_TYPE_BANK_FIELD:
+       case INTERNAL_TYPE_INDEX_FIELD:
 
-               acpi_os_printf ("%20s : %s\n", "Type", "Bank_field");
-               acpi_os_printf ("%20s : %X\n", "Access_bit_width", obj_desc->bank_field.access_bit_width);
-               acpi_os_printf ("%20s : %X\n", "Lock_rule", obj_desc->bank_field.lock_rule);
-               acpi_os_printf ("%20s : %X\n", "Update_rule", obj_desc->bank_field.update_rule);
-               acpi_os_printf ("%20s : %X\n", "Bit_length", obj_desc->bank_field.bit_length);
-               acpi_os_printf ("%20s : %X\n", "Bit_offset", obj_desc->bank_field.start_field_bit_offset);
-               acpi_os_printf ("%20s : %X\n", "Base_byte_offset", obj_desc->bank_field.base_byte_offset);
-               acpi_os_printf ("%20s : %X\n", "Value", obj_desc->bank_field.value);
-               acpi_os_printf ("%20s : %p\n", "Region_obj", obj_desc->bank_field.region_obj);
-               acpi_os_printf ("%20s : %X\n", "Bank_register_obj", obj_desc->bank_field.bank_register_obj);
-               break;
+               acpi_ex_out_integer ("Field_flags",  obj_desc->common_field.field_flags);
+               acpi_ex_out_integer ("Access_byte_width", obj_desc->common_field.access_byte_width);
+               acpi_ex_out_integer ("Bit_length",   obj_desc->common_field.bit_length);
+               acpi_ex_out_integer ("Fld_bit_offset", obj_desc->common_field.start_field_bit_offset);
+               acpi_ex_out_integer ("Base_byte_offset", obj_desc->common_field.base_byte_offset);
+               acpi_ex_out_integer ("Datum_valid_bits", obj_desc->common_field.datum_valid_bits);
+               acpi_ex_out_integer ("End_fld_valid_bits", obj_desc->common_field.end_field_valid_bits);
+               acpi_ex_out_integer ("End_buf_valid_bits", obj_desc->common_field.end_buffer_valid_bits);
+               acpi_ex_out_pointer ("Parent_node",  obj_desc->common_field.node);
+
+               switch (obj_desc->common.type)
+               {
+               case ACPI_TYPE_BUFFER_FIELD:
+                       acpi_ex_out_pointer ("Buffer_obj",   obj_desc->buffer_field.buffer_obj);
+                       break;
 
+               case INTERNAL_TYPE_REGION_FIELD:
+                       acpi_ex_out_pointer ("Region_obj",   obj_desc->field.region_obj);
+                       break;
 
-       case INTERNAL_TYPE_INDEX_FIELD:
+               case INTERNAL_TYPE_BANK_FIELD:
+                       acpi_ex_out_integer ("Value",        obj_desc->bank_field.value);
+                       acpi_ex_out_pointer ("Region_obj",   obj_desc->bank_field.region_obj);
+                       acpi_ex_out_pointer ("Bank_obj",     obj_desc->bank_field.bank_obj);
+                       break;
 
-               acpi_os_printf ("%20s : %s\n", "Type", "Index_field");
-               acpi_os_printf ("%20s : %X\n", "Access_bit_width", obj_desc->index_field.access_bit_width);
-               acpi_os_printf ("%20s : %X\n", "Lock_rule", obj_desc->index_field.lock_rule);
-               acpi_os_printf ("%20s : %X\n", "Update_rule", obj_desc->index_field.update_rule);
-               acpi_os_printf ("%20s : %X\n", "Bit_length", obj_desc->index_field.bit_length);
-               acpi_os_printf ("%20s : %X\n", "Bit_offset", obj_desc->index_field.start_field_bit_offset);
-               acpi_os_printf ("%20s : %X\n", "Value", obj_desc->index_field.value);
-               acpi_os_printf ("%20s : %X\n", "Index", obj_desc->index_field.index_obj);
-               acpi_os_printf ("%20s : %X\n", "Data", obj_desc->index_field.data_obj);
+               case INTERNAL_TYPE_INDEX_FIELD:
+                       acpi_ex_out_integer ("Value",        obj_desc->index_field.value);
+                       acpi_ex_out_pointer ("Index",        obj_desc->index_field.index_obj);
+                       acpi_ex_out_pointer ("Data",         obj_desc->index_field.data_obj);
+                       break;
+               }
                break;
 
 
        case INTERNAL_TYPE_REFERENCE:
 
-               op_info = acpi_ps_get_opcode_info (obj_desc->reference.opcode);
-
-               acpi_os_printf ("%20s : %s\n", "Type", "Reference");
-               acpi_os_printf ("%20s : %X\n", "Target_type", obj_desc->reference.target_type);
-               acpi_os_printf ("%20s : %s\n", "Opcode", op_info->name);
-               acpi_os_printf ("%20s : %X\n", "Offset", obj_desc->reference.offset);
-               acpi_os_printf ("%20s : %p\n", "Obj_desc", obj_desc->reference.object);
-               acpi_os_printf ("%20s : %p\n", "Node", obj_desc->reference.node);
-               acpi_os_printf ("%20s : %p\n", "Where", obj_desc->reference.where);
+               acpi_ex_out_integer ("Target_type",  obj_desc->reference.target_type);
+               acpi_ex_out_string ("Opcode",        (acpi_ps_get_opcode_info (obj_desc->reference.opcode))->name);
+               acpi_ex_out_integer ("Offset",       obj_desc->reference.offset);
+               acpi_ex_out_pointer ("Obj_desc",     obj_desc->reference.object);
+               acpi_ex_out_pointer ("Node",         obj_desc->reference.node);
+               acpi_ex_out_pointer ("Where",        obj_desc->reference.where);
                break;
 
 
        case INTERNAL_TYPE_ADDRESS_HANDLER:
 
-               acpi_os_printf ("%20s : %s\n", "Type", "Address Handler");
-               acpi_os_printf ("%20s : %X\n", "Space_id", obj_desc->addr_handler.space_id);
-               acpi_os_printf ("%20s : %p\n", "Next", obj_desc->addr_handler.next);
-               acpi_os_printf ("%20s : %p\n", "Region_list", obj_desc->addr_handler.region_list);
-               acpi_os_printf ("%20s : %p\n", "Node", obj_desc->addr_handler.node);
-               acpi_os_printf ("%20s : %p\n", "Handler", obj_desc->addr_handler.handler);
-               acpi_os_printf ("%20s : %p\n", "Context", obj_desc->addr_handler.context);
+               acpi_ex_out_integer ("Space_id",     obj_desc->addr_handler.space_id);
+               acpi_ex_out_pointer ("Next",         obj_desc->addr_handler.next);
+               acpi_ex_out_pointer ("Region_list",  obj_desc->addr_handler.region_list);
+               acpi_ex_out_pointer ("Node",         obj_desc->addr_handler.node);
+               acpi_ex_out_pointer ("Context",      obj_desc->addr_handler.context);
                break;
 
 
        case INTERNAL_TYPE_NOTIFY:
 
-               acpi_os_printf ("%20s : %s\n", "Type", "Notify Handler");
-               acpi_os_printf ("%20s : %p\n", "Node", obj_desc->notify_handler.node);
-               acpi_os_printf ("%20s : %p\n", "Handler", obj_desc->notify_handler.handler);
-               acpi_os_printf ("%20s : %p\n", "Context", obj_desc->notify_handler.context);
+               acpi_ex_out_pointer ("Node",         obj_desc->notify_handler.node);
+               acpi_ex_out_pointer ("Context",      obj_desc->notify_handler.context);
                break;
 
 
@@ -866,15 +904,17 @@ acpi_ex_dump_object_descriptor (
        case INTERNAL_TYPE_WHILE:
        case INTERNAL_TYPE_SCOPE:
        case INTERNAL_TYPE_DEF_ANY:
+       case INTERNAL_TYPE_EXTRA:
+       case INTERNAL_TYPE_DATA:
 
-               acpi_os_printf ("*** Structure display not implemented for type %X! ***\n",
+               acpi_os_printf ("Ex_dump_object_descriptor: Display not implemented for object type %X\n",
                        obj_desc->common.type);
                break;
 
 
        default:
 
-               acpi_os_printf ("*** Cannot display unknown type %X! ***\n", obj_desc->common.type);
+               acpi_os_printf ("Ex_dump_object_descriptor: Unknown object type %X\n", obj_desc->common.type);
                break;
        }
 
index 8a65f02ead2aa1dbf0c33c1b8cb67e2b1f99882b..856a69980ff553d3ad2d056c1dd64e58eb5e1035 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: exfield - ACPI AML (p-code) execution - field manipulation
- *              $Revision: 95 $
+ *              $Revision: 105 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 
 
 #define _COMPONENT          ACPI_EXECUTER
-        MODULE_NAME         ("exfield")
+        ACPI_MODULE_NAME    ("exfield")
 
 
 /*******************************************************************************
  *
  * FUNCTION:    Acpi_ex_read_data_from_field
  *
- * PARAMETERS:  Mode                - ACPI_READ or ACPI_WRITE
- *              *Field_node         - Parent node for field to be accessed
- *              *Buffer             - Value(s) to be read or written
- *              Buffer_length       - Number of bytes to transfer
+ * PARAMETERS:  Obj_desc            - The named field
+ *              Ret_buffer_desc     - Where the return data object is stored
  *
- * RETURN:      Status3
+ * RETURN:      Status
  *
- * DESCRIPTION: Read or write a named field
+ * DESCRIPTION: Read from a named field.  Returns either an Integer or a
+ *              Buffer, depending on the size of the field.
  *
  ******************************************************************************/
 
@@ -61,9 +60,10 @@ acpi_ex_read_data_from_field (
        acpi_operand_object     *buffer_desc;
        u32                     length;
        void                    *buffer;
+       u8                      locked;
 
 
-       FUNCTION_TRACE_PTR ("Ex_read_data_from_field", obj_desc);
+       ACPI_FUNCTION_TRACE_PTR ("Ex_read_data_from_field", obj_desc);
 
 
        /* Parameter validation */
@@ -72,6 +72,19 @@ acpi_ex_read_data_from_field (
                return_ACPI_STATUS (AE_AML_NO_OPERAND);
        }
 
+       if (obj_desc->common.type == ACPI_TYPE_BUFFER_FIELD) {
+               /*
+                * If the Buffer_field arguments have not been previously evaluated,
+                * evaluate them now and save the results.
+                */
+               if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) {
+                       status = acpi_ds_get_buffer_field_arguments (obj_desc);
+                       if (ACPI_FAILURE (status)) {
+                               return_ACPI_STATUS (status);
+                       }
+               }
+       }
+
        /*
         * Allocate a buffer for the contents of the field.
         *
@@ -82,7 +95,7 @@ acpi_ex_read_data_from_field (
         *
         * Note: Field.length is in bits.
         */
-       length = ROUND_BITS_UP_TO_BYTES (obj_desc->field.bit_length);
+       length = ACPI_ROUND_BITS_UP_TO_BYTES (obj_desc->field.bit_length);
 
        if (length > sizeof (acpi_integer)) {
                /* Field is too large for an Integer, create a Buffer instead */
@@ -103,7 +116,6 @@ acpi_ex_read_data_from_field (
                buffer_desc->buffer.length = length;
                buffer = buffer_desc->buffer.pointer;
        }
-
        else {
                /* Field will fit within an Integer (normal case) */
 
@@ -116,35 +128,29 @@ acpi_ex_read_data_from_field (
                buffer = &buffer_desc->integer.value;
        }
 
+       ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+               "Obj=%p Type=%X Buf=%p Len=%X\n",
+               obj_desc, obj_desc->common.type, buffer, length));
+       ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+               "Field_write: Bit_len=%X Bit_off=%X Byte_off=%X\n",
+               obj_desc->common_field.bit_length,
+               obj_desc->common_field.start_field_bit_offset,
+               obj_desc->common_field.base_byte_offset));
 
-       /* Read from the appropriate field */
-
-       switch (obj_desc->common.type) {
-       case ACPI_TYPE_BUFFER_FIELD:
-               status = acpi_ex_access_buffer_field (ACPI_READ, obj_desc, buffer, length);
-               break;
-
-       case INTERNAL_TYPE_REGION_FIELD:
-               status = acpi_ex_access_region_field (ACPI_READ, obj_desc, buffer, length);
-               break;
-
-       case INTERNAL_TYPE_BANK_FIELD:
-               status = acpi_ex_access_bank_field (ACPI_READ, obj_desc, buffer, length);
-               break;
+       locked = acpi_ex_acquire_global_lock (obj_desc->common_field.field_flags);
 
-       case INTERNAL_TYPE_INDEX_FIELD:
-               status = acpi_ex_access_index_field (ACPI_READ, obj_desc, buffer, length);
-               break;
+       /* Read from the field */
 
-       default:
-               status = AE_AML_INTERNAL;
-       }
+       status = acpi_ex_extract_from_field (obj_desc, buffer, length);
 
+       /*
+        * Release global lock if we acquired it earlier
+        */
+       acpi_ex_release_global_lock (locked);
 
        if (ACPI_FAILURE (status)) {
                acpi_ut_remove_reference (buffer_desc);
        }
-
        else if (ret_buffer_desc) {
                *ret_buffer_desc = buffer_desc;
        }
@@ -157,18 +163,15 @@ acpi_ex_read_data_from_field (
  *
  * FUNCTION:    Acpi_ex_write_data_to_field
  *
- * PARAMETERS:  Mode                - ACPI_READ or ACPI_WRITE
- *              *Field_node         - Parent node for field to be accessed
- *              *Buffer             - Value(s) to be read or written
- *              Buffer_length       - Number of bytes to transfer
+ * PARAMETERS:  Source_desc         - Contains data to write
+ *              Obj_desc            - The named field
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Read or write a named field
+ * DESCRIPTION: Write to a named field
  *
  ******************************************************************************/
 
-
 acpi_status
 acpi_ex_write_data_to_field (
        acpi_operand_object     *source_desc,
@@ -176,10 +179,13 @@ acpi_ex_write_data_to_field (
 {
        acpi_status             status;
        u32                     length;
+       u32                     required_length;
        void                    *buffer;
+       void                    *new_buffer;
+       u8                      locked;
 
 
-       FUNCTION_TRACE_PTR ("Ex_write_data_to_field", obj_desc);
+       ACPI_FUNCTION_TRACE_PTR ("Ex_write_data_to_field", obj_desc);
 
 
        /* Parameter validation */
@@ -188,6 +194,18 @@ acpi_ex_write_data_to_field (
                return_ACPI_STATUS (AE_AML_NO_OPERAND);
        }
 
+       if (obj_desc->common.type == ACPI_TYPE_BUFFER_FIELD) {
+               /*
+                * If the Buffer_field arguments have not been previously evaluated,
+                * evaluate them now and save the results.
+                */
+               if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) {
+                       status = acpi_ds_get_buffer_field_arguments (obj_desc);
+                       if (ACPI_FAILURE (status)) {
+                               return_ACPI_STATUS (status);
+                       }
+               }
+       }
 
        /*
         * Get a pointer to the data to be written
@@ -212,315 +230,61 @@ acpi_ex_write_data_to_field (
                return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
        }
 
-
        /*
-        * Decode the type of field to be written
+        * We must have a buffer that is at least as long as the field
+        * we are writing to.  This is because individual fields are
+        * indivisible and partial writes are not supported -- as per
+        * the ACPI specification.
         */
-       switch (obj_desc->common.type) {
-       case ACPI_TYPE_BUFFER_FIELD:
-               status = acpi_ex_access_buffer_field (ACPI_WRITE, obj_desc, buffer, length);
-               break;
-
-       case INTERNAL_TYPE_REGION_FIELD:
-               status = acpi_ex_access_region_field (ACPI_WRITE, obj_desc, buffer, length);
-               break;
+       new_buffer = NULL;
+       required_length = ACPI_ROUND_BITS_UP_TO_BYTES (obj_desc->common_field.bit_length);
 
-       case INTERNAL_TYPE_BANK_FIELD:
-               status = acpi_ex_access_bank_field (ACPI_WRITE, obj_desc, buffer, length);
-               break;
-
-       case INTERNAL_TYPE_INDEX_FIELD:
-               status = acpi_ex_access_index_field (ACPI_WRITE, obj_desc, buffer, length);
-               break;
+       if (length < required_length) {
+               /* We need to create a new buffer */
 
-       default:
-               return_ACPI_STATUS (AE_AML_INTERNAL);
-       }
-
-
-       return_ACPI_STATUS (status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ex_access_buffer_field
- *
- * PARAMETERS:  Mode                - ACPI_READ or ACPI_WRITE
- *              *Field_node         - Parent node for field to be accessed
- *              *Buffer             - Value(s) to be read or written
- *              Buffer_length       - Number of bytes to transfer
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Read or write a named field
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ex_access_buffer_field (
-       u32                     mode,
-       acpi_operand_object     *obj_desc,
-       void                    *buffer,
-       u32                     buffer_length)
-{
-       acpi_status             status;
-
-
-       FUNCTION_TRACE_PTR ("Ex_access_buffer_field", obj_desc);
-
-
-       /*
-        * If the Buffer_field arguments have not been previously evaluated,
-        * evaluate them now and save the results.
-        */
-       if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) {
-               status = acpi_ds_get_buffer_field_arguments (obj_desc);
-               if (ACPI_FAILURE (status)) {
-                       return_ACPI_STATUS (status);
+               new_buffer = ACPI_MEM_CALLOCATE (required_length);
+               if (!new_buffer) {
+                       return_ACPI_STATUS (AE_NO_MEMORY);
                }
-       }
-
-
-       status = acpi_ex_common_access_field (mode, obj_desc, buffer, buffer_length);
-
-       return_ACPI_STATUS (status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ex_access_region_field
- *
- * PARAMETERS:  Mode                - ACPI_READ or ACPI_WRITE
- *              *Field_node         - Parent node for field to be accessed
- *              *Buffer             - Value(s) to be read or written
- *              Buffer_length       - Number of bytes to transfer
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Read or write a named field
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ex_access_region_field (
-       u32                     mode,
-       acpi_operand_object     *obj_desc,
-       void                    *buffer,
-       u32                     buffer_length)
-{
-       acpi_status             status;
-       u8                      locked;
-
-
-       FUNCTION_TRACE_PTR ("Ex_access_region_field", obj_desc);
-
-
-       /*
-        * Get the global lock if needed
-        */
-       locked = acpi_ex_acquire_global_lock (obj_desc->field.lock_rule);
-
-       status = acpi_ex_common_access_field (mode, obj_desc, buffer, buffer_length);
-
-
-       /*
-        * Release global lock if we acquired it earlier
-        */
-       acpi_ex_release_global_lock (locked);
-
-       return_ACPI_STATUS (status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ex_access_bank_field
- *
- * PARAMETERS:  Mode                - ACPI_READ or ACPI_WRITE
- *              *Field_node         - Parent node for field to be accessed
- *              *Buffer             - Value(s) to be read or written
- *              Buffer_length       - Number of bytes to transfer
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Read or write a Bank Field
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ex_access_bank_field (
-       u32                     mode,
-       acpi_operand_object     *obj_desc,
-       void                    *buffer,
-       u32                     buffer_length)
-{
-       acpi_status             status;
-       u8                      locked;
-
-
-       FUNCTION_TRACE_PTR ("Ex_access_bank_field", obj_desc);
-
-
-       /*
-        * Get the global lock if needed
-        */
-       locked = acpi_ex_acquire_global_lock (obj_desc->bank_field.lock_rule);
 
-
-       /*
-        * Write the Bank_value to the Bank_register to select the bank.
-        * The Bank_value for this Bank_field is specified in the
-        * Bank_field ASL declaration. The Bank_register is always a Field in
-        * an operation region.
-        */
-       status = acpi_ex_common_access_field (ACPI_WRITE,
-                        obj_desc->bank_field.bank_register_obj,
-                        &obj_desc->bank_field.value,
-                        sizeof (obj_desc->bank_field.value));
-       if (ACPI_FAILURE (status)) {
-               goto cleanup;
+               /*
+                * Copy the original data to the new buffer, starting
+                * at Byte zero.  All unused (upper) bytes of the
+                * buffer will be 0.
+                */
+               ACPI_MEMCPY ((char *) new_buffer, (char *) buffer, length);
+               buffer = new_buffer;
+               length = required_length;
        }
 
-       /*
-        * The bank was successfully selected, now read or write the actual
-        * data.
-        */
-       status = acpi_ex_common_access_field (mode, obj_desc, buffer, buffer_length);
-
-
-cleanup:
-       /*
-        * Release global lock if we acquired it earlier
-        */
-       acpi_ex_release_global_lock (locked);
-
-       return_ACPI_STATUS (status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ex_access_index_field
- *
- * PARAMETERS:  Mode                - ACPI_READ or ACPI_WRITE
- *              *Field_node         - Parent node for field to be accessed
- *              *Buffer             - Value(s) to be read or written
- *              Buffer_length       - Number of bytes to transfer
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Read or write a Index Field
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ex_access_index_field (
-       u32                     mode,
-       acpi_operand_object     *obj_desc,
-       void                    *buffer,
-       u32                     buffer_length)
-{
-       acpi_status             status;
-       u8                      locked;
-
-
-       FUNCTION_TRACE_PTR ("Ex_access_index_field", obj_desc);
-
-
-       /*
-        * Get the global lock if needed
-        */
-       locked = acpi_ex_acquire_global_lock (obj_desc->index_field.lock_rule);
+       ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+               "Obj=%p Type=%X Buf=%p Len=%X\n",
+               obj_desc, obj_desc->common.type, buffer, length));
+       ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+               "Field_read: Bit_len=%X Bit_off=%X Byte_off=%X\n",
+               obj_desc->common_field.bit_length,
+               obj_desc->common_field.start_field_bit_offset,
+               obj_desc->common_field.base_byte_offset));
 
+       locked = acpi_ex_acquire_global_lock (obj_desc->common_field.field_flags);
 
        /*
-        * Set Index value to select proper Data register
+        * Write to the field
         */
-       status = acpi_ex_common_access_field (ACPI_WRITE,
-                        obj_desc->index_field.index_obj,
-                        &obj_desc->index_field.value,
-                        sizeof (obj_desc->index_field.value));
-       if (ACPI_FAILURE (status)) {
-               goto cleanup;
-       }
+       status = acpi_ex_insert_into_field (obj_desc, buffer, length);
 
-       /* Now read/write the data register */
-
-       status = acpi_ex_common_access_field (mode, obj_desc->index_field.data_obj,
-                         buffer, buffer_length);
-
-cleanup:
        /*
         * Release global lock if we acquired it earlier
         */
        acpi_ex_release_global_lock (locked);
 
-       return_ACPI_STATUS (status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ex_common_access_field
- *
- * PARAMETERS:  Mode                - ACPI_READ or ACPI_WRITE
- *              *Field_node         - Parent node for field to be accessed
- *              *Buffer             - Value(s) to be read or written
- *              Buffer_length       - Size of buffer, in bytes.  Must be large
- *                                    enough for all bits of the field.
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Read or write a named field
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ex_common_access_field (
-       u32                     mode,
-       acpi_operand_object     *obj_desc,
-       void                    *buffer,
-       u32                     buffer_length)
-{
-       acpi_status             status;
-
-
-       FUNCTION_TRACE_PTR ("Ex_common_access_field", obj_desc);
-
-
-       ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Obj=%p Type=%X Buf=%p Len=%X\n",
-               obj_desc, obj_desc->common.type, buffer, buffer_length));
-       ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Mode=%d Bit_len=%X Bit_off=%X Byte_off=%X\n",
-               mode, obj_desc->common_field.bit_length,
-               obj_desc->common_field.start_field_bit_offset,
-               obj_desc->common_field.base_byte_offset));
-
-
-       /* Perform the actual read or write of the field */
-
-       switch (mode) {
-       case ACPI_READ:
+       /* Free temporary buffer if we used one */
 
-               status = acpi_ex_extract_from_field (obj_desc, buffer, buffer_length);
-               break;
-
-
-       case ACPI_WRITE:
-
-               status = acpi_ex_insert_into_field (obj_desc, buffer, buffer_length);
-               break;
-
-
-       default:
-
-               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown I/O Mode: %X\n", mode));
-               status = AE_BAD_PARAMETER;
-               break;
+       if (new_buffer) {
+               ACPI_MEM_FREE (new_buffer);
        }
 
-
        return_ACPI_STATUS (status);
 }
 
+
index ec09328d02ef70bff253168625b19ff31e168803..ee057a7796db32383cf607c40a4bf74d71a5a319 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: exfldio - Aml Field I/O
- *              $Revision: 66 $
+ *              $Revision: 82 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 
 
 #define _COMPONENT          ACPI_EXECUTER
-        MODULE_NAME         ("exfldio")
+        ACPI_MODULE_NAME    ("exfldio")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_setup_field
+ * FUNCTION:    Acpi_ex_setup_region
  *
- * PARAMETERS:  *Obj_desc           - Field to be read or written
- *              Field_datum_byte_offset  - Current offset into the field
+ * PARAMETERS:  *Obj_desc               - Field to be read or written
+ *              Field_datum_byte_offset - Byte offset of this datum within the
+ *                                        parent field
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Common processing for Acpi_ex_extract_from_field and
- *              Acpi_ex_insert_into_field
+ *              Acpi_ex_insert_into_field. Initialize the
  *
  ******************************************************************************/
 
 acpi_status
-acpi_ex_setup_field (
+acpi_ex_setup_region (
        acpi_operand_object     *obj_desc,
        u32                     field_datum_byte_offset)
 {
@@ -60,7 +61,7 @@ acpi_ex_setup_field (
        acpi_operand_object     *rgn_desc;
 
 
-       FUNCTION_TRACE_U32 ("Ex_setup_field", field_datum_byte_offset);
+       ACPI_FUNCTION_TRACE_U32 ("Ex_setup_region", field_datum_byte_offset);
 
 
        rgn_desc = obj_desc->common_field.region_obj;
@@ -76,7 +77,6 @@ acpi_ex_setup_field (
         * evaluate them now and save the results.
         */
        if (!(rgn_desc->region.flags & AOPOBJ_DATA_VALID)) {
-
                status = acpi_ds_get_region_arguments (rgn_desc);
                if (ACPI_FAILURE (status)) {
                        return_ACPI_STATUS (status);
@@ -88,9 +88,9 @@ acpi_ex_setup_field (
         * length of one field datum (access width) must fit within the region.
         * (Region length is specified in bytes)
         */
-       if (rgn_desc->region.length < (obj_desc->common_field.base_byte_offset +
-                          field_datum_byte_offset +
-                          obj_desc->common_field.access_byte_width)) {
+       if (rgn_desc->region.length < (obj_desc->common_field.base_byte_offset
+                          + field_datum_byte_offset
+                          obj_desc->common_field.access_byte_width)) {
                if (rgn_desc->region.length < obj_desc->common_field.access_byte_width) {
                        /*
                         * This is the case where the Access_type (Acc_word, etc.) is wider
@@ -98,8 +98,9 @@ acpi_ex_setup_field (
                         * byte, and a field with Dword access specified.
                         */
                        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-                               "Field access width (%d bytes) too large for region size (%X)\n",
-                               obj_desc->common_field.access_byte_width, rgn_desc->region.length));
+                               "Field [%4.4s] access width (%d bytes) too large for region [%4.4s] (length %X)\n",
+                               (char *) &obj_desc->common_field.node->name, obj_desc->common_field.access_byte_width,
+                               (char *) &rgn_desc->region.node->name, rgn_desc->region.length));
                }
 
                /*
@@ -107,10 +108,10 @@ acpi_ex_setup_field (
                 * exceeds region length, indicate an error
                 */
                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-                       "Field base+offset+width %X+%X+%X exceeds region size (%X bytes) field=%p region=%p\n",
-                       obj_desc->common_field.base_byte_offset, field_datum_byte_offset,
-                       obj_desc->common_field.access_byte_width,
-                       rgn_desc->region.length, obj_desc, rgn_desc));
+                       "Field [%4.4s] Base+Offset+Width %X+%X+%X is beyond end of region [%4.4s] (length %X)\n",
+                       (char *) &obj_desc->common_field.node->name, obj_desc->common_field.base_byte_offset,
+                       field_datum_byte_offset, obj_desc->common_field.access_byte_width,
+                       (char *) &rgn_desc->region.node->name, rgn_desc->region.length));
 
                return_ACPI_STATUS (AE_AML_REGION_LIMIT);
        }
@@ -121,116 +122,410 @@ acpi_ex_setup_field (
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_read_field_datum
+ * FUNCTION:    Acpi_ex_access_region
  *
- * PARAMETERS:  *Obj_desc           - Field to be read
- *              *Value              - Where to store value (must be 32 bits)
+ * PARAMETERS:  *Obj_desc               - Field to be read
+ *              Field_datum_byte_offset - Byte offset of this datum within the
+ *                                        parent field
+ *              *Value                  - Where to store value (must be 32 bits)
+ *              Read_write              - Read or Write flag
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Retrieve the value of the given field
+ * DESCRIPTION: Read or Write a single field datum to an Operation Region.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_ex_read_field_datum (
+acpi_ex_access_region (
        acpi_operand_object     *obj_desc,
        u32                     field_datum_byte_offset,
-       u32                     *value)
+       acpi_integer            *value,
+       u32                     read_write)
 {
        acpi_status             status;
        acpi_operand_object     *rgn_desc;
        ACPI_PHYSICAL_ADDRESS   address;
-       u32                     local_value;
 
 
-       FUNCTION_TRACE_U32 ("Ex_read_field_datum", field_datum_byte_offset);
+       ACPI_FUNCTION_TRACE ("Acpi_ex_access_region");
+
+
+       /*
+        * The physical address of this field datum is:
+        *
+        * 1) The base of the region, plus
+        * 2) The base offset of the field, plus
+        * 3) The current offset into the field
+        */
+       rgn_desc = obj_desc->common_field.region_obj;
+       address = rgn_desc->region.address
+                        + obj_desc->common_field.base_byte_offset
+                        + field_datum_byte_offset;
+
+       if (read_write == ACPI_READ) {
+               ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[READ]"));
+       }
+       else {
+               ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[WRITE]"));
+       }
 
+       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_BFIELD,
+               " Region[%s-%X] Access %X Base:Off %X:%X at %8.8X%8.8X\n",
+               acpi_ut_get_region_name (rgn_desc->region.space_id),
+               rgn_desc->region.space_id,
+               obj_desc->common_field.access_byte_width,
+               obj_desc->common_field.base_byte_offset,
+               field_datum_byte_offset,
+               ACPI_HIDWORD (address), ACPI_LODWORD (address)));
 
-       if (!value) {
-               local_value = 0;
-               value = &local_value;   /*  support reads without saving value  */
+       /* Invoke the appropriate Address_space/Op_region handler */
+
+       status = acpi_ev_address_space_dispatch (rgn_desc, read_write,
+                         address, ACPI_MUL_8 (obj_desc->common_field.access_byte_width), value);
+
+       if (ACPI_FAILURE (status)) {
+               if (status == AE_NOT_IMPLEMENTED) {
+                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+                               "Region %s(%X) not implemented\n",
+                               acpi_ut_get_region_name (rgn_desc->region.space_id),
+                               rgn_desc->region.space_id));
+               }
+
+               else if (status == AE_NOT_EXIST) {
+                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+                               "Region %s(%X) has no handler\n",
+                               acpi_ut_get_region_name (rgn_desc->region.space_id),
+                               rgn_desc->region.space_id));
+               }
        }
 
-       /* Clear the entire return buffer first, [Very Important!] */
+       return_ACPI_STATUS (status);
+}
 
-       *value = 0;
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ex_register_overflow
+ *
+ * PARAMETERS:  *Obj_desc               - Register(Field) to be written
+ *              Value                   - Value to be stored
+ *
+ * RETURN:      TRUE if value overflows the field, FALSE otherwise
+ *
+ * DESCRIPTION: Check if a value is out of range of the field being written.
+ *              Used to check if the values written to Index and Bank registers
+ *              are out of range.  Normally, the value is simply truncated
+ *              to fit the field, but this case is most likely a serious
+ *              coding error in the ASL.
+ *
+ ******************************************************************************/
+
+u8
+acpi_ex_register_overflow (
+       acpi_operand_object     *obj_desc,
+       acpi_integer            value)
+{
+
+       if (obj_desc->common_field.bit_length >= ACPI_INTEGER_BIT_SIZE) {
+               /*
+                * The field is large enough to hold the maximum integer, so we can
+                * never overflow it.
+                */
+               return (FALSE);
+       }
+
+       if (value >= (acpi_integer) (1 << obj_desc->common_field.bit_length)) {
+               /*
+                * The Value is larger than the maximum value that can fit into
+                * the register.
+                */
+               return (TRUE);
+       }
+
+       /* The Value will fit into the field with no truncation */
+
+       return (FALSE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ex_field_datum_io
+ *
+ * PARAMETERS:  *Obj_desc               - Field to be read
+ *              Field_datum_byte_offset - Byte offset of this datum within the
+ *                                        parent field
+ *              *Value                  - Where to store value (must be 64 bits)
+ *              Read_write              - Read or Write flag
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Read or Write a single datum of a field.  The Field_type is
+ *              demultiplexed here to handle the different types of fields
+ *              (Buffer_field, Region_field, Index_field, Bank_field)
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ex_field_datum_io (
+       acpi_operand_object     *obj_desc,
+       u32                     field_datum_byte_offset,
+       acpi_integer            *value,
+       u32                     read_write)
+{
+       acpi_status             status;
+       acpi_integer            local_value;
+
+
+       ACPI_FUNCTION_TRACE_U32 ("Ex_field_datum_io", field_datum_byte_offset);
+
+
+       if (read_write == ACPI_READ) {
+               if (!value) {
+                       local_value = 0;
+                       value = &local_value; /* To support reads without saving return value */
+               }
+
+               /* Clear the entire return buffer first, [Very Important!] */
+
+               *value = 0;
+       }
 
        /*
-        * Buffer_fields - Read from a Buffer
-        * Other Fields - Read from a Operation Region.
+        * The four types of fields are:
+        *
+        * Buffer_fields - Read/write from/to a Buffer
+        * Region_fields - Read/write from/to a Operation Region.
+        * Bank_fields  - Write to a Bank Register, then read/write from/to an Op_region
+        * Index_fields - Write to an Index Register, then read/write from/to a Data Register
         */
        switch (obj_desc->common.type) {
        case ACPI_TYPE_BUFFER_FIELD:
-
                /*
-                * For Buffer_fields, we only need to copy the data from the
-                * source buffer.  Length is the field width in bytes.
+                * If the Buffer_field arguments have not been previously evaluated,
+                * evaluate them now and save the results.
                 */
-               MEMCPY (value, (obj_desc->buffer_field.buffer_obj)->buffer.pointer
-                                 + obj_desc->buffer_field.base_byte_offset + field_datum_byte_offset,
-                                 obj_desc->common_field.access_byte_width);
+               if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) {
+                       status = acpi_ds_get_buffer_field_arguments (obj_desc);
+                       if (ACPI_FAILURE (status)) {
+                               return_ACPI_STATUS (status);
+                       }
+               }
+
+               if (read_write == ACPI_READ) {
+                       /*
+                        * Copy the data from the source buffer.
+                        * Length is the field width in bytes.
+                        */
+                       ACPI_MEMCPY (value, (obj_desc->buffer_field.buffer_obj)->buffer.pointer
+                                         + obj_desc->buffer_field.base_byte_offset
+                                         + field_datum_byte_offset,
+                                         obj_desc->common_field.access_byte_width);
+               }
+               else {
+                       /*
+                        * Copy the data to the target buffer.
+                        * Length is the field width in bytes.
+                        */
+                       ACPI_MEMCPY ((obj_desc->buffer_field.buffer_obj)->buffer.pointer
+                                       + obj_desc->buffer_field.base_byte_offset
+                                       + field_datum_byte_offset,
+                                       value, obj_desc->common_field.access_byte_width);
+               }
+
                status = AE_OK;
                break;
 
 
-       case INTERNAL_TYPE_REGION_FIELD:
        case INTERNAL_TYPE_BANK_FIELD:
 
+               /* Ensure that the Bank_value is not beyond the capacity of the register */
+
+               if (acpi_ex_register_overflow (obj_desc->bank_field.bank_obj,
+                                 obj_desc->bank_field.value)) {
+                       return_ACPI_STATUS (AE_AML_REGISTER_LIMIT);
+               }
+
                /*
-                * For other fields, we need to go through an Operation Region
-                * (Only types that will get here are Region_fields and Bank_fields)
+                * For Bank_fields, we must write the Bank_value to the Bank_register
+                * (itself a Region_field) before we can access the data.
                 */
-               status = acpi_ex_setup_field (obj_desc, field_datum_byte_offset);
+               status = acpi_ex_insert_into_field (obj_desc->bank_field.bank_obj,
+                                &obj_desc->bank_field.value,
+                                sizeof (obj_desc->bank_field.value));
                if (ACPI_FAILURE (status)) {
                        return_ACPI_STATUS (status);
                }
 
                /*
-                * The physical address of this field datum is:
-                *
-                * 1) The base of the region, plus
-                * 2) The base offset of the field, plus
-                * 3) The current offset into the field
+                * Now that the Bank has been selected, fall through to the
+                * Region_field case and write the datum to the Operation Region
                 */
-               rgn_desc = obj_desc->common_field.region_obj;
-               address = rgn_desc->region.address + obj_desc->common_field.base_byte_offset +
-                                field_datum_byte_offset;
 
-               ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Region %s(%X) width %X base:off %X:%X at %8.8X%8.8X\n",
-                       acpi_ut_get_region_name (rgn_desc->region.space_id),
-                       rgn_desc->region.space_id, obj_desc->common_field.access_bit_width,
-                       obj_desc->common_field.base_byte_offset, field_datum_byte_offset,
-                       HIDWORD(address), LODWORD(address)));
+               /* No break; ! */
 
-               /* Invoke the appropriate Address_space/Op_region handler */
 
-               status = acpi_ev_address_space_dispatch (rgn_desc, ACPI_READ_ADR_SPACE,
-                                 address, obj_desc->common_field.access_bit_width, value);
-               if (status == AE_NOT_IMPLEMENTED) {
-                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Region %s(%X) not implemented\n",
-                               acpi_ut_get_region_name (rgn_desc->region.space_id),
-                               rgn_desc->region.space_id));
+       case INTERNAL_TYPE_REGION_FIELD:
+               /*
+                * For simple Region_fields, we just directly access the owning
+                * Operation Region.
+                */
+               status = acpi_ex_setup_region (obj_desc, field_datum_byte_offset);
+               if (ACPI_FAILURE (status)) {
+                       return_ACPI_STATUS (status);
                }
 
-               else if (status == AE_NOT_EXIST) {
-                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Region %s(%X) has no handler\n",
-                               acpi_ut_get_region_name (rgn_desc->region.space_id),
-                               rgn_desc->region.space_id));
+               status = acpi_ex_access_region (obj_desc, field_datum_byte_offset, value,
+                                 read_write);
+               break;
+
+
+       case INTERNAL_TYPE_INDEX_FIELD:
+
+
+               /* Ensure that the Index_value is not beyond the capacity of the register */
+
+               if (acpi_ex_register_overflow (obj_desc->index_field.index_obj,
+                                 obj_desc->index_field.value)) {
+                       return_ACPI_STATUS (AE_AML_REGISTER_LIMIT);
+               }
+
+               /* Write the index value to the Index_register (itself a Region_field) */
+
+               status = acpi_ex_insert_into_field (obj_desc->index_field.index_obj,
+                                &obj_desc->index_field.value,
+                                sizeof (obj_desc->index_field.value));
+               if (ACPI_FAILURE (status)) {
+                       return_ACPI_STATUS (status);
+               }
+
+               if (read_write == ACPI_READ) {
+                       /* Read the datum from the Data_register */
+
+                       status = acpi_ex_extract_from_field (obj_desc->index_field.data_obj,
+                                         value, obj_desc->common_field.access_byte_width);
+               }
+               else {
+                       /* Write the datum to the Data register */
+
+                       status = acpi_ex_insert_into_field (obj_desc->index_field.data_obj,
+                                         value, obj_desc->common_field.access_byte_width);
                }
                break;
 
 
        default:
 
-               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p, wrong source type - %s\n",
+               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p, Wrong object type - %s\n",
                        obj_desc, acpi_ut_get_type_name (obj_desc->common.type)));
                status = AE_AML_INTERNAL;
                break;
        }
 
+       if (ACPI_SUCCESS (status)) {
+               if (read_write == ACPI_READ) {
+                       ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Value Read=%8.8X%8.8X\n",
+                                          ACPI_HIDWORD (*value), ACPI_LODWORD (*value)));
+               }
+               else {
+                       ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Value Written=%8.8X%8.8X\n",
+                                          ACPI_HIDWORD (*value), ACPI_LODWORD (*value)));
+               }
+       }
+
+       return_ACPI_STATUS (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ex_write_with_update_rule
+ *
+ * PARAMETERS:  *Obj_desc           - Field to be set
+ *              Value               - Value to store
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Apply the field update rule to a field write
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ex_write_with_update_rule (
+       acpi_operand_object     *obj_desc,
+       acpi_integer            mask,
+       acpi_integer            field_value,
+       u32                     field_datum_byte_offset)
+{
+       acpi_status             status = AE_OK;
+       acpi_integer            merged_value;
+       acpi_integer            current_value;
+
+
+       ACPI_FUNCTION_TRACE_U32 ("Ex_write_with_update_rule", mask);
+
+
+       /* Start with the new bits  */
+
+       merged_value = field_value;
+
+       /* If the mask is all ones, we don't need to worry about the update rule */
+
+       if (mask != ACPI_UINT32_MAX) {
+               /* Decode the update rule */
+
+               switch (obj_desc->common_field.field_flags & AML_FIELD_UPDATE_RULE_MASK) {
+               case AML_FIELD_UPDATE_PRESERVE:
+                       /*
+                        * Check if update rule needs to be applied (not if mask is all
+                        * ones)  The left shift drops the bits we want to ignore.
+                        */
+                       if ((~mask << (ACPI_MUL_8 (sizeof (mask)) -
+                                        ACPI_MUL_8 (obj_desc->common_field.access_byte_width))) != 0) {
+                               /*
+                                * Read the current contents of the byte/word/dword containing
+                                * the field, and merge with the new field value.
+                                */
+                               status = acpi_ex_field_datum_io (obj_desc, field_datum_byte_offset,
+                                                 &current_value, ACPI_READ);
+                               merged_value |= (current_value & ~mask);
+                       }
+                       break;
+
+               case AML_FIELD_UPDATE_WRITE_AS_ONES:
+
+                       /* Set positions outside the field to all ones */
+
+                       merged_value |= ~mask;
+                       break;
+
+               case AML_FIELD_UPDATE_WRITE_AS_ZEROS:
+
+                       /* Set positions outside the field to all zeros */
+
+                       merged_value &= mask;
+                       break;
+
+               default:
+                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+                               "Write_with_update_rule: Unknown Update_rule setting: %x\n",
+                               (obj_desc->common_field.field_flags & AML_FIELD_UPDATE_RULE_MASK)));
+                       return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
+               }
+       }
+
+       /* Write the merged value */
+
+       status = acpi_ex_field_datum_io (obj_desc, field_datum_byte_offset,
+                         &merged_value, ACPI_WRITE);
 
-       ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Returned value=%08X \n", *value));
+       ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+               "Mask %8.8X%8.8X Datum_offset %X Value %8.8X%8.8X, Merged_value %8.8X%8.8X\n",
+               ACPI_HIDWORD (mask), ACPI_LODWORD (mask),
+               field_datum_byte_offset,
+               ACPI_HIDWORD (field_value), ACPI_LODWORD (field_value),
+               ACPI_HIDWORD (merged_value),ACPI_LODWORD (merged_value)));
 
        return_ACPI_STATUS (status);
 }
@@ -240,41 +535,49 @@ acpi_ex_read_field_datum (
  *
  * FUNCTION:    Acpi_ex_get_buffer_datum
  *
- * PARAMETERS:  Merged_datum        - Value to store
- *              Buffer              - Receiving buffer
- *              Byte_granularity    - 1/2/4 Granularity of the field
+ * PARAMETERS:  Datum               - Where the Datum is returned
+ *              Buffer              - Raw field buffer
+ *              Byte_granularity    - 1/2/4/8 Granularity of the field
  *                                    (aka Datum Size)
  *              Offset              - Datum offset into the buffer
  *
  * RETURN:      none
  *
- * DESCRIPTION: Store the merged datum to the buffer according to the
+ * DESCRIPTION: Get a datum from the buffer according to the buffer field
  *              byte granularity
  *
  ******************************************************************************/
 
-static void
+void
 acpi_ex_get_buffer_datum(
-       u32                     *datum,
+       acpi_integer            *datum,
        void                    *buffer,
        u32                     byte_granularity,
        u32                     offset)
 {
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        switch (byte_granularity) {
        case ACPI_FIELD_BYTE_GRANULARITY:
+
                *datum = ((u8 *) buffer) [offset];
                break;
 
        case ACPI_FIELD_WORD_GRANULARITY:
-               MOVE_UNALIGNED16_TO_32 (datum, &(((u16 *) buffer) [offset]));
+
+               ACPI_MOVE_UNALIGNED16_TO_32 (datum, &(((u16 *) buffer) [offset]));
                break;
 
        case ACPI_FIELD_DWORD_GRANULARITY:
-               MOVE_UNALIGNED32_TO_32 (datum, &(((u32 *) buffer) [offset]));
+
+               ACPI_MOVE_UNALIGNED32_TO_32 (datum, &(((u32 *) buffer) [offset]));
+               break;
+
+       case ACPI_FIELD_QWORD_GRANULARITY:
+
+               ACPI_MOVE_UNALIGNED64_TO_64 (datum, &(((u64 *) buffer) [offset]));
                break;
        }
 }
@@ -286,7 +589,7 @@ acpi_ex_get_buffer_datum(
  *
  * PARAMETERS:  Merged_datum        - Value to store
  *              Buffer              - Receiving buffer
- *              Byte_granularity    - 1/2/4 Granularity of the field
+ *              Byte_granularity    - 1/2/4/8 Granularity of the field
  *                                    (aka Datum Size)
  *              Offset              - Datum offset into the buffer
  *
@@ -297,28 +600,36 @@ acpi_ex_get_buffer_datum(
  *
  ******************************************************************************/
 
-static void
+void
 acpi_ex_set_buffer_datum (
-       u32                     merged_datum,
+       acpi_integer            merged_datum,
        void                    *buffer,
        u32                     byte_granularity,
        u32                     offset)
 {
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        switch (byte_granularity) {
        case ACPI_FIELD_BYTE_GRANULARITY:
+
                ((u8 *) buffer) [offset] = (u8) merged_datum;
                break;
 
        case ACPI_FIELD_WORD_GRANULARITY:
-               MOVE_UNALIGNED16_TO_16 (&(((u16 *) buffer)[offset]), &merged_datum);
+
+               ACPI_MOVE_UNALIGNED16_TO_16 (&(((u16 *) buffer)[offset]), &merged_datum);
                break;
 
        case ACPI_FIELD_DWORD_GRANULARITY:
-               MOVE_UNALIGNED32_TO_32 (&(((u32 *) buffer)[offset]), &merged_datum);
+
+               ACPI_MOVE_UNALIGNED32_TO_32 (&(((u32 *) buffer)[offset]), &merged_datum);
+               break;
+
+       case ACPI_FIELD_QWORD_GRANULARITY:
+
+               ACPI_MOVE_UNALIGNED64_TO_64 (&(((u64 *) buffer)[offset]), &merged_datum);
                break;
        }
 }
@@ -346,22 +657,23 @@ acpi_ex_extract_from_field (
        acpi_status             status;
        u32                     field_datum_byte_offset;
        u32                     datum_offset;
-       u32                     previous_raw_datum;
-       u32                     this_raw_datum = 0;
-       u32                     merged_datum = 0;
+       acpi_integer            previous_raw_datum;
+       acpi_integer            this_raw_datum = 0;
+       acpi_integer            merged_datum = 0;
        u32                     byte_field_length;
        u32                     datum_count;
 
 
-       FUNCTION_TRACE ("Ex_extract_from_field");
+       ACPI_FUNCTION_TRACE ("Ex_extract_from_field");
 
 
        /*
         * The field must fit within the caller's buffer
         */
-       byte_field_length = ROUND_BITS_UP_TO_BYTES (obj_desc->common_field.bit_length);
+       byte_field_length = ACPI_ROUND_BITS_UP_TO_BYTES (obj_desc->common_field.bit_length);
        if (byte_field_length > buffer_length) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Field size %X (bytes) too large for buffer (%X)\n",
+               ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+                       "Field size %X (bytes) too large for buffer (%X)\n",
                        byte_field_length, buffer_length));
 
                return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
@@ -369,26 +681,27 @@ acpi_ex_extract_from_field (
 
        /* Convert field byte count to datum count, round up if necessary */
 
-       datum_count = ROUND_UP_TO (byte_field_length, obj_desc->common_field.access_byte_width);
+       datum_count = ACPI_ROUND_UP_TO (byte_field_length,
+                          obj_desc->common_field.access_byte_width);
 
        ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-               "Byte_len=%x, Datum_len=%x, Bit_gran=%x, Byte_gran=%x\n",
-               byte_field_length, datum_count, obj_desc->common_field.access_bit_width,
-               obj_desc->common_field.access_byte_width));
+               "Byte_len=%x, Datum_len=%x, Byte_gran=%x\n",
+               byte_field_length, datum_count,obj_desc->common_field.access_byte_width));
 
        /*
         * Clear the caller's buffer (the whole buffer length as given)
         * This is very important, especially in the cases where a byte is read,
         * but the buffer is really a u32 (4 bytes).
         */
-       MEMSET (buffer, 0, buffer_length);
+       ACPI_MEMSET (buffer, 0, buffer_length);
 
        /* Read the first raw datum to prime the loop */
 
        field_datum_byte_offset = 0;
        datum_offset= 0;
 
-       status = acpi_ex_read_field_datum (obj_desc, field_datum_byte_offset, &previous_raw_datum);
+       status = acpi_ex_field_datum_io (obj_desc, field_datum_byte_offset,
+                         &previous_raw_datum, ACPI_READ);
        if (ACPI_FAILURE (status)) {
                return_ACPI_STATUS (status);
        }
@@ -397,7 +710,7 @@ acpi_ex_extract_from_field (
        /* We might actually be done if the request fits in one datum */
 
        if ((datum_count == 1) &&
-               (obj_desc->common_field.access_flags & AFIELD_SINGLE_DATUM)) {
+               (obj_desc->common_field.flags & AOPOBJ_SINGLE_DATUM)) {
                /* 1) Shift the valid data bits down to start at bit 0 */
 
                merged_datum = (previous_raw_datum >> obj_desc->common_field.start_field_bit_offset);
@@ -405,7 +718,7 @@ acpi_ex_extract_from_field (
                /* 2) Mask off any upper unused bits (bits not part of the field) */
 
                if (obj_desc->common_field.end_buffer_valid_bits) {
-                       merged_datum &= MASK_BITS_ABOVE (obj_desc->common_field.end_buffer_valid_bits);
+                       merged_datum &= ACPI_MASK_BITS_ABOVE (obj_desc->common_field.end_buffer_valid_bits);
                }
 
                /* Store the datum to the caller buffer */
@@ -427,17 +740,18 @@ acpi_ex_extract_from_field (
                 * to perform a final read, since this would potentially read
                 * past the end of the region.
                 *
-                * TBD: [Investigate] It may make more sense to just split the aligned
-                * and non-aligned cases since the aligned case is so very simple,
+                * 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 ((obj_desc->common_field.start_field_bit_offset != 0)  ||
+               if ((obj_desc->common_field.start_field_bit_offset != 0) ||
                        ((obj_desc->common_field.start_field_bit_offset == 0) &&
                        (datum_offset < (datum_count -1)))) {
                        /*
                         * Get the next raw datum, it contains some or all bits
                         * of the current field datum
                         */
-                       status = acpi_ex_read_field_datum (obj_desc, field_datum_byte_offset, &this_raw_datum);
+                       status = acpi_ex_field_datum_io (obj_desc, field_datum_byte_offset,
+                                         &this_raw_datum, ACPI_READ);
                        if (ACPI_FAILURE (status)) {
                                return_ACPI_STATUS (status);
                        }
@@ -451,7 +765,6 @@ acpi_ex_extract_from_field (
 
                        merged_datum = previous_raw_datum;
                }
-
                else {
                        /*
                         * Put together the appropriate bits of the two raw data to make a
@@ -474,7 +787,7 @@ acpi_ex_extract_from_field (
                                 */
                                if (obj_desc->common_field.end_buffer_valid_bits) {
                                        merged_datum &=
-                                               MASK_BITS_ABOVE (obj_desc->common_field.end_buffer_valid_bits);
+                                               ACPI_MASK_BITS_ABOVE (obj_desc->common_field.end_buffer_valid_bits);
                                }
                        }
                }
@@ -483,8 +796,8 @@ acpi_ex_extract_from_field (
                 * Store the merged field datum in the caller's buffer, according to
                 * the granularity of the field (size of each datum).
                 */
-               acpi_ex_set_buffer_datum (merged_datum, buffer, obj_desc->common_field.access_byte_width,
-                               datum_offset);
+               acpi_ex_set_buffer_datum (merged_datum, buffer,
+                               obj_desc->common_field.access_byte_width, datum_offset);
 
                /*
                 * Save the raw datum that was just acquired since it may contain bits
@@ -498,211 +811,6 @@ acpi_ex_extract_from_field (
 }
 
 
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ex_write_field_datum
- *
- * PARAMETERS:  *Obj_desc           - Field to be set
- *              Value               - Value to store
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Store the value into the given field
- *
- ******************************************************************************/
-
-static acpi_status
-acpi_ex_write_field_datum (
-       acpi_operand_object     *obj_desc,
-       u32                     field_datum_byte_offset,
-       u32                     value)
-{
-       acpi_status             status = AE_OK;
-       acpi_operand_object     *rgn_desc = NULL;
-       ACPI_PHYSICAL_ADDRESS   address;
-
-
-       FUNCTION_TRACE_U32 ("Ex_write_field_datum", field_datum_byte_offset);
-
-
-       /*
-        * Buffer_fields - Read from a Buffer
-        * Other Fields - Read from a Operation Region.
-        */
-       switch (obj_desc->common.type) {
-       case ACPI_TYPE_BUFFER_FIELD:
-
-               /*
-                * For Buffer_fields, we only need to copy the data to the
-                * target buffer.  Length is the field width in bytes.
-                */
-               MEMCPY ((obj_desc->buffer_field.buffer_obj)->buffer.pointer
-                               + obj_desc->buffer_field.base_byte_offset + field_datum_byte_offset,
-                               &value, obj_desc->common_field.access_byte_width);
-               status = AE_OK;
-               break;
-
-
-       case INTERNAL_TYPE_REGION_FIELD:
-       case INTERNAL_TYPE_BANK_FIELD:
-
-               /*
-                * For other fields, we need to go through an Operation Region
-                * (Only types that will get here are Region_fields and Bank_fields)
-                */
-               status = acpi_ex_setup_field (obj_desc, field_datum_byte_offset);
-               if (ACPI_FAILURE (status)) {
-                       return_ACPI_STATUS (status);
-               }
-
-               /*
-                * The physical address of this field datum is:
-                *
-                * 1) The base of the region, plus
-                * 2) The base offset of the field, plus
-                * 3) The current offset into the field
-                */
-               rgn_desc = obj_desc->common_field.region_obj;
-               address = rgn_desc->region.address +
-                                obj_desc->common_field.base_byte_offset +
-                                field_datum_byte_offset;
-
-               ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
-                       "Store %X in Region %s(%X) at %8.8X%8.8X width %X\n",
-                       value, acpi_ut_get_region_name (rgn_desc->region.space_id),
-                       rgn_desc->region.space_id, HIDWORD(address), LODWORD(address),
-                       obj_desc->common_field.access_bit_width));
-
-               /* Invoke the appropriate Address_space/Op_region handler */
-
-               status = acpi_ev_address_space_dispatch (rgn_desc, ACPI_WRITE_ADR_SPACE,
-                                 address, obj_desc->common_field.access_bit_width, &value);
-
-               if (status == AE_NOT_IMPLEMENTED) {
-                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-                               "**** Region type %s(%X) not implemented\n",
-                               acpi_ut_get_region_name (rgn_desc->region.space_id),
-                               rgn_desc->region.space_id));
-               }
-
-               else if (status == AE_NOT_EXIST) {
-                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-                               "**** Region type %s(%X) does not have a handler\n",
-                               acpi_ut_get_region_name (rgn_desc->region.space_id),
-                               rgn_desc->region.space_id));
-               }
-
-               break;
-
-
-       default:
-
-               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p, wrong source type - %s\n",
-                       obj_desc, acpi_ut_get_type_name (obj_desc->common.type)));
-               status = AE_AML_INTERNAL;
-               break;
-       }
-
-
-       ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Value written=%08X \n", value));
-       return_ACPI_STATUS (status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ex_write_field_datum_with_update_rule
- *
- * PARAMETERS:  *Obj_desc           - Field to be set
- *              Value               - Value to store
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Apply the field update rule to a field write
- *
- ******************************************************************************/
-
-static acpi_status
-acpi_ex_write_field_datum_with_update_rule (
-       acpi_operand_object     *obj_desc,
-       u32                     mask,
-       u32                     field_value,
-       u32                     field_datum_byte_offset)
-{
-       acpi_status             status = AE_OK;
-       u32                     merged_value;
-       u32                     current_value;
-
-
-       FUNCTION_TRACE ("Ex_write_field_datum_with_update_rule");
-
-
-       /* Start with the new bits  */
-
-       merged_value = field_value;
-
-       /* If the mask is all ones, we don't need to worry about the update rule */
-
-       if (mask != ACPI_UINT32_MAX) {
-               /* Decode the update rule */
-
-               switch (obj_desc->common_field.update_rule) {
-               case UPDATE_PRESERVE:
-                       /*
-                        * Check if update rule needs to be applied (not if mask is all
-                        * ones)  The left shift drops the bits we want to ignore.
-                        */
-                       if ((~mask << (sizeof (mask) * 8 -
-                                         obj_desc->common_field.access_bit_width)) != 0) {
-                               /*
-                                * Read the current contents of the byte/word/dword containing
-                                * the field, and merge with the new field value.
-                                */
-                               status = acpi_ex_read_field_datum (obj_desc, field_datum_byte_offset,
-                                                 &current_value);
-                               merged_value |= (current_value & ~mask);
-                       }
-                       break;
-
-
-               case UPDATE_WRITE_AS_ONES:
-
-                       /* Set positions outside the field to all ones */
-
-                       merged_value |= ~mask;
-                       break;
-
-
-               case UPDATE_WRITE_AS_ZEROS:
-
-                       /* Set positions outside the field to all zeros */
-
-                       merged_value &= mask;
-                       break;
-
-
-               default:
-                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-                               "Write_with_update_rule: Unknown Update_rule setting: %x\n",
-                               obj_desc->common_field.update_rule));
-                       return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
-                       break;
-               }
-       }
-
-
-       /* Write the merged value */
-
-       status = acpi_ex_write_field_datum (obj_desc, field_datum_byte_offset,
-                         merged_value);
-
-       ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Mask %X Datum_offset %X Value %X, Merged_value %X\n",
-               mask, field_datum_byte_offset, field_value, merged_value));
-
-       return_ACPI_STATUS (status);
-}
-
-
 /*******************************************************************************
  *
  * FUNCTION:    Acpi_ex_insert_into_field
@@ -725,15 +833,15 @@ acpi_ex_insert_into_field (
        acpi_status             status;
        u32                     field_datum_byte_offset;
        u32                     datum_offset;
-       u32                     mask;
-       u32                     merged_datum;
-       u32                     previous_raw_datum;
-       u32                     this_raw_datum;
+       acpi_integer            mask;
+       acpi_integer            merged_datum;
+       acpi_integer            previous_raw_datum;
+       acpi_integer            this_raw_datum;
        u32                     byte_field_length;
        u32                     datum_count;
 
 
-       FUNCTION_TRACE ("Ex_insert_into_field");
+       ACPI_FUNCTION_TRACE ("Ex_insert_into_field");
 
 
        /*
@@ -742,24 +850,21 @@ acpi_ex_insert_into_field (
         * larger than the field, this typically happens when an integer is
         * written to a field that is actually smaller than an integer.
         */
-       byte_field_length = ROUND_BITS_UP_TO_BYTES (obj_desc->common_field.bit_length);
+       byte_field_length = ACPI_ROUND_BITS_UP_TO_BYTES (obj_desc->common_field.bit_length);
        if (buffer_length < byte_field_length) {
                ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Buffer length %X too small for field %X\n",
                        buffer_length, byte_field_length));
 
-               /* TBD: Need a better error code */
-
                return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
        }
 
        /* Convert byte count to datum count, round up if necessary */
 
-       datum_count = ROUND_UP_TO (byte_field_length, obj_desc->common_field.access_byte_width);
+       datum_count = ACPI_ROUND_UP_TO (byte_field_length, obj_desc->common_field.access_byte_width);
 
        ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-               "Byte_len=%x, Datum_len=%x, Bit_gran=%x, Byte_gran=%x\n",
-               byte_field_length, datum_count, obj_desc->common_field.access_bit_width,
-               obj_desc->common_field.access_byte_width));
+               "Byte_len=%x, Datum_len=%x, Byte_gran=%x\n",
+               byte_field_length, datum_count, obj_desc->common_field.access_byte_width));
 
        /*
         * Break the request into up to three parts (similar to an I/O request):
@@ -785,15 +890,15 @@ acpi_ex_insert_into_field (
         *
         * Mask off bits that are "below" the field (if any)
         */
-       mask = MASK_BITS_BELOW (obj_desc->common_field.start_field_bit_offset);
+       mask = ACPI_MASK_BITS_BELOW (obj_desc->common_field.start_field_bit_offset);
 
        /* If the field fits in one datum, may need to mask upper bits */
 
-       if ((obj_desc->common_field.access_flags & AFIELD_SINGLE_DATUM) &&
+       if ((obj_desc->common_field.flags & AOPOBJ_SINGLE_DATUM) &&
                 obj_desc->common_field.end_field_valid_bits) {
                /* There are bits above the field, mask them off also */
 
-               mask &= MASK_BITS_ABOVE (obj_desc->common_field.end_field_valid_bits);
+               mask &= ACPI_MASK_BITS_ABOVE (obj_desc->common_field.end_field_valid_bits);
        }
 
        /* Shift and mask the value into the field position */
@@ -803,7 +908,7 @@ acpi_ex_insert_into_field (
 
        /* Apply the update rule (if necessary) and write the datum to the field */
 
-       status = acpi_ex_write_field_datum_with_update_rule (obj_desc, mask, merged_datum,
+       status = acpi_ex_write_with_update_rule (obj_desc, mask, merged_datum,
                           field_datum_byte_offset);
        if (ACPI_FAILURE (status)) {
                return_ACPI_STATUS (status);
@@ -812,7 +917,7 @@ acpi_ex_insert_into_field (
        /* If the entire field fits within one datum, we are done. */
 
        if ((datum_count == 1) &&
-          (obj_desc->common_field.access_flags & AFIELD_SINGLE_DATUM)) {
+          (obj_desc->common_field.flags & AOPOBJ_SINGLE_DATUM)) {
                return_ACPI_STATUS (AE_OK);
        }
 
@@ -849,7 +954,6 @@ acpi_ex_insert_into_field (
                                (previous_raw_datum >> obj_desc->common_field.datum_valid_bits) |
                                (this_raw_datum << obj_desc->common_field.start_field_bit_offset);
                }
-
                else {
                        /* Field began aligned on datum boundary */
 
@@ -874,24 +978,23 @@ acpi_ex_insert_into_field (
                                 *
                                 * Mask off the unused bits above (after) the end-of-field
                                 */
-                               mask = MASK_BITS_ABOVE (obj_desc->common_field.end_field_valid_bits);
+                               mask = ACPI_MASK_BITS_ABOVE (obj_desc->common_field.end_field_valid_bits);
                                merged_datum &= mask;
 
                                /* Write the last datum with the update rule */
 
-                               status = acpi_ex_write_field_datum_with_update_rule (obj_desc, mask,
-                                                 merged_datum, field_datum_byte_offset);
+                               status = acpi_ex_write_with_update_rule (obj_desc, mask, merged_datum,
+                                                  field_datum_byte_offset);
                                if (ACPI_FAILURE (status)) {
                                        return_ACPI_STATUS (status);
                                }
                        }
                }
-
                else {
                        /* Normal case -- write the completed datum */
 
-                       status = acpi_ex_write_field_datum (obj_desc,
-                                         field_datum_byte_offset, merged_datum);
+                       status = acpi_ex_field_datum_io (obj_desc, field_datum_byte_offset,
+                                         &merged_datum, ACPI_WRITE);
                        if (ACPI_FAILURE (status)) {
                                return_ACPI_STATUS (status);
                        }
index acd14502ea3d4ba0aa58a7e53f9ccd080033e001..e447d0d81ba974ce48fc14b3a07f8fa3e0428f44 100644 (file)
@@ -2,12 +2,12 @@
 /******************************************************************************
  *
  * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes
- *              $Revision: 92 $
+ *              $Revision: 100 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -33,7 +33,7 @@
 
 
 #define _COMPONENT          ACPI_EXECUTER
-        MODULE_NAME         ("exmisc")
+        ACPI_MODULE_NAME    ("exmisc")
 
 
 /*******************************************************************************
@@ -59,10 +59,12 @@ acpi_ex_get_object_reference (
        acpi_status             status = AE_OK;
 
 
-       FUNCTION_TRACE_PTR ("Ex_get_object_reference", obj_desc);
+       ACPI_FUNCTION_TRACE_PTR ("Ex_get_object_reference", obj_desc);
 
 
-       if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_INTERNAL)) {
+       switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) {
+       case ACPI_DESC_TYPE_INTERNAL:
+
                if (obj_desc->common.type != INTERNAL_TYPE_REFERENCE) {
                        *return_desc = NULL;
                        status = AE_TYPE;
@@ -77,8 +79,9 @@ acpi_ex_get_object_reference (
                case AML_LOCAL_OP:
                case AML_ARG_OP:
 
-                       *return_desc = (void *) acpi_ds_method_data_get_node (obj_desc->reference.opcode,
-                                         obj_desc->reference.offset, walk_state);
+                       status = acpi_ds_method_data_get_node (obj_desc->reference.opcode,
+                                         obj_desc->reference.offset, walk_state,
+                                         (acpi_namespace_node **) return_desc);
                        break;
 
                default:
@@ -89,18 +92,22 @@ acpi_ex_get_object_reference (
                        status = AE_AML_INTERNAL;
                        goto cleanup;
                }
+               break;
 
-       }
 
-       else if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_NAMED)) {
+       case ACPI_DESC_TYPE_NAMED:
+
                /* Must be a named object;  Just return the Node */
 
                *return_desc = obj_desc;
-       }
+               break;
+
+
+       default:
 
-       else {
                *return_desc = NULL;
                status = AE_TYPE;
+               break;
        }
 
 
@@ -113,7 +120,7 @@ cleanup:
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_do_concatenate
+ * FUNCTION:    Acpi_ex_concat_template
  *
  * PARAMETERS:  *Obj_desc           - Object to be converted.  Must be an
  *                                    Integer, Buffer, or String
@@ -121,13 +128,106 @@ cleanup:
  *
  * RETURN:      Status
  *
+ * DESCRIPTION: Concatenate two resource templates
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ex_concat_template (
+       acpi_operand_object     *obj_desc1,
+       acpi_operand_object     *obj_desc2,
+       acpi_operand_object     **actual_return_desc,
+       acpi_walk_state         *walk_state)
+{
+       acpi_status             status;
+       acpi_operand_object     *return_desc;
+       NATIVE_CHAR             *new_buf;
+       u8                      *end_tag1;
+       u8                      *end_tag2;
+       ACPI_SIZE               length1;
+       ACPI_SIZE               length2;
+
+
+       ACPI_FUNCTION_TRACE ("Ex_concat_template");
+
+
+       /* Find the End_tags in each resource template */
+
+       end_tag1 = acpi_ut_get_resource_end_tag (obj_desc1);
+       end_tag2 = acpi_ut_get_resource_end_tag (obj_desc2);
+       if (!end_tag1 || !end_tag2) {
+               return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+       }
+
+       /* Create a new buffer object for the result */
+
+       return_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER);
+       if (!return_desc) {
+               return_ACPI_STATUS (AE_NO_MEMORY);
+       }
+
+       /* Allocate a new buffer for the result */
+
+       length1 = ACPI_PTR_DIFF (end_tag1, obj_desc1->buffer.pointer);
+       length2 = ACPI_PTR_DIFF (end_tag2, obj_desc2->buffer.pointer) +
+                         2; /* Size of END_TAG */
+
+       new_buf = ACPI_MEM_ALLOCATE (length1 + length2);
+       if (!new_buf) {
+               ACPI_REPORT_ERROR
+                       (("Ex_concat_template: Buffer allocation failure\n"));
+               status = AE_NO_MEMORY;
+               goto cleanup;
+       }
+
+       /* Copy the templates to the new descriptor */
+
+       ACPI_MEMCPY (new_buf, obj_desc1->buffer.pointer, length1);
+       ACPI_MEMCPY (new_buf + length1, obj_desc2->buffer.pointer, length2);
+
+       /*
+        * Point the return object to the new buffer
+        */
+       return_desc->buffer.pointer = (u8 *) new_buf;
+       return_desc->buffer.length = length1 + length2;
+
+       /* Compute the new checksum */
+
+       new_buf[return_desc->buffer.length - 1] =
+                       acpi_ut_generate_checksum (return_desc->buffer.pointer,
+                                        (return_desc->buffer.length - 1));
+
+       /* Return the completed template descriptor */
+
+       *actual_return_desc = return_desc;
+       return_ACPI_STATUS (AE_OK);
+
+
+cleanup:
+
+       acpi_ut_remove_reference (return_desc);
+       return_ACPI_STATUS (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ex_do_concatenate
+ *
+ * PARAMETERS:  Obj_desc1           - First source object
+ *              Obj_desc2           - Second source object
+ *              Actual_return_desc  - Where to place the return object
+ *              Walk_state          - Current walk state
+ *
+ * RETURN:      Status
+ *
  * DESCRIPTION: Concatenate two objects OF THE SAME TYPE.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_ex_do_concatenate (
-       acpi_operand_object     *obj_desc,
+       acpi_operand_object     *obj_desc1,
        acpi_operand_object     *obj_desc2,
        acpi_operand_object     **actual_return_desc,
        acpi_walk_state         *walk_state)
@@ -140,7 +240,7 @@ acpi_ex_do_concatenate (
        u32                     integer_size = sizeof (acpi_integer);
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        /*
@@ -149,7 +249,7 @@ acpi_ex_do_concatenate (
         * 2) Two Strings concatenated to produce a string
         * 3) Two Buffers concatenated to produce a buffer
         */
-       switch (obj_desc->common.type) {
+       switch (obj_desc1->common.type) {
        case ACPI_TYPE_INTEGER:
 
                /* Handle both ACPI 1.0 and ACPI 2.0 Integer widths */
@@ -175,7 +275,7 @@ acpi_ex_do_concatenate (
                return_desc->buffer.length = integer_size * 2;
                new_buf = ACPI_MEM_CALLOCATE (return_desc->buffer.length);
                if (!new_buf) {
-                       REPORT_ERROR
+                       ACPI_REPORT_ERROR
                                (("Ex_do_concatenate: Buffer allocation failure\n"));
                        status = AE_NO_MEMORY;
                        goto cleanup;
@@ -185,7 +285,7 @@ acpi_ex_do_concatenate (
 
                /* Convert the first integer */
 
-               this_integer = obj_desc->integer.value;
+               this_integer = obj_desc1->integer.value;
                for (i = 0; i < integer_size; i++) {
                        new_buf[i] = (u8) this_integer;
                        this_integer >>= 8;
@@ -211,24 +311,24 @@ acpi_ex_do_concatenate (
 
                /* Operand0 is string  */
 
-               new_buf = ACPI_MEM_ALLOCATE (obj_desc->string.length +
+               new_buf = ACPI_MEM_ALLOCATE (obj_desc1->string.length +
                                  obj_desc2->string.length + 1);
                if (!new_buf) {
-                       REPORT_ERROR
+                       ACPI_REPORT_ERROR
                                (("Ex_do_concatenate: String allocation failure\n"));
                        status = AE_NO_MEMORY;
                        goto cleanup;
                }
 
-               STRCPY (new_buf, obj_desc->string.pointer);
-               STRCPY (new_buf + obj_desc->string.length,
+               ACPI_STRCPY (new_buf, obj_desc1->string.pointer);
+               ACPI_STRCPY (new_buf + obj_desc1->string.length,
                                  obj_desc2->string.pointer);
 
                /* Point the return object to the new string */
 
                return_desc->string.pointer = new_buf;
-               return_desc->string.length = obj_desc->string.length +=
-                                 obj_desc2->string.length;
+               return_desc->string.length = obj_desc1->string.length +
+                                  obj_desc2->string.length;
                break;
 
 
@@ -241,27 +341,27 @@ acpi_ex_do_concatenate (
                        return (AE_NO_MEMORY);
                }
 
-               new_buf = ACPI_MEM_ALLOCATE (obj_desc->buffer.length +
+               new_buf = ACPI_MEM_ALLOCATE (obj_desc1->buffer.length +
                                  obj_desc2->buffer.length);
                if (!new_buf) {
-                       REPORT_ERROR
+                       ACPI_REPORT_ERROR
                                (("Ex_do_concatenate: Buffer allocation failure\n"));
                        status = AE_NO_MEMORY;
                        goto cleanup;
                }
 
-               MEMCPY (new_buf, obj_desc->buffer.pointer,
-                                 obj_desc->buffer.length);
-               MEMCPY (new_buf + obj_desc->buffer.length, obj_desc2->buffer.pointer,
+               ACPI_MEMCPY (new_buf, obj_desc1->buffer.pointer,
+                                 obj_desc1->buffer.length);
+               ACPI_MEMCPY (new_buf + obj_desc1->buffer.length, obj_desc2->buffer.pointer,
                                   obj_desc2->buffer.length);
 
                /*
                 * Point the return object to the new buffer
                 */
 
-               return_desc->buffer.pointer    = (u8 *) new_buf;
-               return_desc->buffer.length     = obj_desc->buffer.length +
-                                obj_desc2->buffer.length;
+               return_desc->buffer.pointer = (u8 *) new_buf;
+               return_desc->buffer.length = obj_desc1->buffer.length +
+                                 obj_desc2->buffer.length;
                break;
 
 
@@ -270,7 +370,6 @@ acpi_ex_do_concatenate (
                return_desc = NULL;
        }
 
-
        *actual_return_desc = return_desc;
        return (AE_OK);
 
@@ -288,7 +387,7 @@ cleanup:
  *
  * PARAMETERS:  Opcode              - AML opcode
  *              Operand0            - Integer operand #0
- *              Operand0            - Integer operand #1
+ *              Operand1            - Integer operand #1
  *
  * RETURN:      Integer result of the operation
  *
@@ -369,7 +468,7 @@ acpi_ex_do_math_op (
  *
  * PARAMETERS:  Opcode              - AML opcode
  *              Operand0            - Integer operand #0
- *              Operand0            - Integer operand #1
+ *              Operand1            - Integer operand #1
  *
  * RETURN:      TRUE/FALSE result of the operation
  *
index 41b3024c7f57a974c0ad0680bbcca5a16b632cf6..ceb9981dc3b0222941bb189e9f47f1ef19460d7b 100644 (file)
@@ -2,12 +2,12 @@
 /******************************************************************************
  *
  * Module Name: exmutex - ASL Mutex Acquire/Release functions
- *              $Revision: 7 $
+ *              $Revision: 10 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -32,7 +32,7 @@
 #include "acevents.h"
 
 #define _COMPONENT          ACPI_EXECUTER
-        MODULE_NAME         ("exmutex")
+        ACPI_MODULE_NAME    ("exmutex")
 
 
 /*******************************************************************************
@@ -51,13 +51,23 @@ void
 acpi_ex_unlink_mutex (
        acpi_operand_object     *obj_desc)
 {
+       ACPI_THREAD_STATE       *thread = obj_desc->mutex.owner_thread;
+
+
+       if (!thread) {
+               return;
+       }
 
        if (obj_desc->mutex.next) {
                (obj_desc->mutex.next)->mutex.prev = obj_desc->mutex.prev;
        }
+
        if (obj_desc->mutex.prev) {
                (obj_desc->mutex.prev)->mutex.next = obj_desc->mutex.next;
        }
+       else {
+               thread->acquired_mutex_list = obj_desc->mutex.next;
+       }
 }
 
 
@@ -77,23 +87,27 @@ acpi_ex_unlink_mutex (
 void
 acpi_ex_link_mutex (
        acpi_operand_object     *obj_desc,
-       acpi_operand_object     *list_head)
+       ACPI_THREAD_STATE       *thread)
 {
+       acpi_operand_object     *list_head;
+
+
+       list_head = thread->acquired_mutex_list;
 
        /* This object will be the first object in the list */
 
-       obj_desc->mutex.prev = list_head;
-       obj_desc->mutex.next = list_head->mutex.next;
+       obj_desc->mutex.prev = NULL;
+       obj_desc->mutex.next = list_head;
 
        /* Update old first object to point back to this object */
 
-       if (list_head->mutex.next) {
-               (list_head->mutex.next)->mutex.prev = obj_desc;
+       if (list_head) {
+               list_head->mutex.prev = obj_desc;
        }
 
        /* Update list head */
 
-       list_head->mutex.next = obj_desc;
+       thread->acquired_mutex_list = obj_desc;
 }
 
 
@@ -119,7 +133,7 @@ acpi_ex_acquire_mutex (
        acpi_status             status;
 
 
-       FUNCTION_TRACE_PTR ("Ex_acquire_mutex", obj_desc);
+       ACPI_FUNCTION_TRACE_PTR ("Ex_acquire_mutex", obj_desc);
 
        if (!obj_desc) {
                return_ACPI_STATUS (AE_BAD_PARAMETER);
@@ -129,15 +143,18 @@ acpi_ex_acquire_mutex (
         * Current Sync must be less than or equal to the sync level of the
         * mutex.  This mechanism provides some deadlock prevention
         */
-       if (walk_state->current_sync_level > obj_desc->mutex.sync_level) {
+       if (walk_state->thread->current_sync_level > obj_desc->mutex.sync_level) {
                return_ACPI_STATUS (AE_AML_MUTEX_ORDER);
        }
 
        /*
-        * If the mutex is already owned by this thread,
-        * just increment the acquisition depth
+        * Support for multiple acquires by the owning thread
         */
-       if (obj_desc->mutex.owner == walk_state) {
+       if (obj_desc->mutex.owner_thread == walk_state->thread) {
+               /*
+                * The mutex is already owned by this thread,
+                * just increment the acquisition depth
+                */
                obj_desc->mutex.acquisition_depth++;
                return_ACPI_STATUS (AE_OK);
        }
@@ -153,14 +170,14 @@ acpi_ex_acquire_mutex (
 
        /* Have the mutex, update mutex and walk info */
 
-       obj_desc->mutex.owner = walk_state;
+       obj_desc->mutex.owner_thread    = walk_state->thread;
        obj_desc->mutex.acquisition_depth = 1;
-       walk_state->current_sync_level = obj_desc->mutex.sync_level;
 
-       /* Link the mutex to the walk state for force-unlock at method exit */
+       walk_state->thread->current_sync_level = obj_desc->mutex.sync_level;
 
-       acpi_ex_link_mutex (obj_desc, (acpi_operand_object *)
-                        &(walk_state->walk_list->acquired_mutex_list));
+       /* Link the mutex to the current thread for force-unlock at method exit */
+
+       acpi_ex_link_mutex (obj_desc, walk_state->thread);
 
        return_ACPI_STATUS (AE_OK);
 }
@@ -186,7 +203,7 @@ acpi_ex_release_mutex (
        acpi_status             status;
 
 
-       FUNCTION_TRACE ("Ex_release_mutex");
+       ACPI_FUNCTION_TRACE ("Ex_release_mutex");
 
 
        if (!obj_desc) {
@@ -195,13 +212,13 @@ acpi_ex_release_mutex (
 
        /* The mutex must have been previously acquired in order to release it */
 
-       if (!obj_desc->mutex.owner) {
+       if (!obj_desc->mutex.owner_thread) {
                return_ACPI_STATUS (AE_AML_MUTEX_NOT_ACQUIRED);
        }
 
        /* The Mutex is owned, but this thread must be the owner */
 
-       if (obj_desc->mutex.owner != walk_state) {
+       if (obj_desc->mutex.owner_thread != walk_state->thread) {
                return_ACPI_STATUS (AE_AML_NOT_OWNER);
        }
 
@@ -209,7 +226,7 @@ acpi_ex_release_mutex (
         * The sync level of the mutex must be less than or
         * equal to the current sync level
         */
-       if (obj_desc->mutex.sync_level > walk_state->current_sync_level) {
+       if (obj_desc->mutex.sync_level > walk_state->thread->current_sync_level) {
                return_ACPI_STATUS (AE_AML_MUTEX_ORDER);
        }
 
@@ -223,6 +240,9 @@ acpi_ex_release_mutex (
                return_ACPI_STATUS (AE_OK);
        }
 
+       /* Unlink the mutex from the owner's list */
+
+       acpi_ex_unlink_mutex (obj_desc);
 
        /* Release the mutex */
 
@@ -230,12 +250,8 @@ acpi_ex_release_mutex (
 
        /* Update the mutex and walk state */
 
-       obj_desc->mutex.owner = NULL;
-       walk_state->current_sync_level = obj_desc->mutex.sync_level;
-
-       /* Unlink the mutex from the owner's list */
-
-       acpi_ex_unlink_mutex (obj_desc);
+       obj_desc->mutex.owner_thread = NULL;
+       walk_state->thread->current_sync_level = obj_desc->mutex.sync_level;
 
        return_ACPI_STATUS (status);
 }
@@ -255,13 +271,13 @@ acpi_ex_release_mutex (
 
 acpi_status
 acpi_ex_release_all_mutexes (
-       acpi_operand_object     *list_head)
+       ACPI_THREAD_STATE       *thread)
 {
-       acpi_operand_object     *next = list_head->mutex.next;
+       acpi_operand_object     *next = thread->acquired_mutex_list;
        acpi_operand_object     *this;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        /*
@@ -271,16 +287,17 @@ acpi_ex_release_all_mutexes (
                this = next;
                next = this->mutex.next;
 
-               /* Mark mutex un-owned */
-
-               this->mutex.owner = NULL;
-               this->mutex.prev = NULL;
-               this->mutex.next = NULL;
-               this->mutex.acquisition_depth = 0;
+               this->mutex.acquisition_depth = 1;
+               this->mutex.prev             = NULL;
+               this->mutex.next             = NULL;
 
                 /* Release the mutex */
 
                acpi_ex_system_release_mutex (this);
+
+               /* Mark mutex unowned */
+
+               this->mutex.owner_thread     = NULL;
        }
 
        return (AE_OK);
index 95df0aa8123e48e2a14f9db7bb79229099dab55b..9c73eee0532e41a0f4d7a0058d82bf863729ee2b 100644 (file)
@@ -2,12 +2,12 @@
 /******************************************************************************
  *
  * Module Name: exnames - interpreter/scanner name load/execute
- *              $Revision: 83 $
+ *              $Revision: 90 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -31,7 +31,7 @@
 #include "acnamesp.h"
 
 #define _COMPONENT          ACPI_EXECUTER
-        MODULE_NAME         ("exnames")
+        ACPI_MODULE_NAME    ("exnames")
 
 
 /* AML Package Length encodings */
@@ -67,7 +67,7 @@ acpi_ex_allocate_name_string (
        NATIVE_CHAR             *name_string;
        u32                      size_needed;
 
-       FUNCTION_TRACE ("Ex_allocate_name_string");
+       ACPI_FUNCTION_TRACE ("Ex_allocate_name_string");
 
 
        /*
@@ -75,7 +75,7 @@ acpi_ex_allocate_name_string (
         * Also, one byte for the null terminator.
         * This may actually be somewhat longer than needed.
         */
-       if (prefix_count == (u32) -1) {
+       if (prefix_count == ACPI_UINT32_MAX) {
                /* Special case for root */
 
                size_needed = 1 + (ACPI_NAME_SIZE * num_name_segs) + 2 + 1;
@@ -90,7 +90,7 @@ acpi_ex_allocate_name_string (
         */
        name_string = ACPI_MEM_ALLOCATE (size_needed);
        if (!name_string) {
-               REPORT_ERROR (("Ex_allocate_name_string: Could not allocate size %d\n", size_needed));
+               ACPI_REPORT_ERROR (("Ex_allocate_name_string: Could not allocate size %d\n", size_needed));
                return_PTR (NULL);
        }
 
@@ -98,10 +98,9 @@ acpi_ex_allocate_name_string (
 
        /* Set up Root or Parent prefixes if needed */
 
-       if (prefix_count == (u32) -1) {
+       if (prefix_count == ACPI_UINT32_MAX) {
                *temp_ptr++ = AML_ROOT_PREFIX;
        }
-
        else {
                while (prefix_count--) {
                        *temp_ptr++ = AML_PARENT_PREFIX;
@@ -117,7 +116,6 @@ acpi_ex_allocate_name_string (
                *temp_ptr++ = AML_MULTI_NAME_PREFIX_OP;
                *temp_ptr++ = (char) num_name_segs;
        }
-
        else if (2 == num_name_segs) {
                /* Set up dual prefixes */
 
@@ -156,7 +154,7 @@ acpi_ex_name_segment (
        NATIVE_CHAR             char_buf[5];
 
 
-       FUNCTION_TRACE ("Ex_name_segment");
+       ACPI_FUNCTION_TRACE ("Ex_name_segment");
 
 
        /*
@@ -174,7 +172,7 @@ acpi_ex_name_segment (
 
        for (index = 4;
                (index > 0) && (acpi_ut_valid_acpi_character (*aml_address));
-               --index) {
+               index--) {
                char_buf[4 - index] = *aml_address++;
                ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "%c\n", char_buf[4 - index]));
        }
@@ -188,17 +186,15 @@ acpi_ex_name_segment (
                char_buf[4] = '\0';
 
                if (name_string) {
-                       STRCAT (name_string, char_buf);
+                       ACPI_STRCAT (name_string, char_buf);
                        ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
                                "Appended to - %s \n", name_string));
                }
-
                else {
                        ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
                                "No Name string - %s \n", char_buf));
                }
        }
-
        else if (4 == index) {
                /*
                 * First character was not a valid name character,
@@ -209,7 +205,6 @@ acpi_ex_name_segment (
                        char_buf[0]));
                status = AE_CTRL_PENDING;
        }
-
        else {
                /* Segment started with one or more valid characters, but fewer than 4 */
 
@@ -235,10 +230,9 @@ acpi_ex_name_segment (
  *
  ******************************************************************************/
 
-
 acpi_status
 acpi_ex_get_name_string (
-       acpi_object_type8       data_type,
+       acpi_object_type        data_type,
        u8                      *in_aml_address,
        NATIVE_CHAR             **out_name_string,
        u32                     *out_name_length)
@@ -248,11 +242,10 @@ acpi_ex_get_name_string (
        NATIVE_CHAR             *name_string = NULL;
        u32                     num_segments;
        u32                     prefix_count = 0;
-       u8                      prefix = 0;
        u8                      has_prefix = FALSE;
 
 
-       FUNCTION_TRACE_PTR ("Ex_get_name_string", aml_address);
+       ACPI_FUNCTION_TRACE_PTR ("Ex_get_name_string", aml_address);
 
 
        if (INTERNAL_TYPE_REGION_FIELD == data_type  ||
@@ -268,24 +261,22 @@ acpi_ex_get_name_string (
                        status = acpi_ex_name_segment (&aml_address, name_string);
                }
        }
-
        else {
                /*
                 * Data_type is not a field name.
                 * Examine first character of name for root or parent prefix operators
                 */
                switch (*aml_address) {
-
                case AML_ROOT_PREFIX:
 
-                       prefix = *aml_address++;
-                       ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Root_prefix: %x\n", prefix));
+                       ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Root_prefix(\\) at %p\n", aml_address));
 
                        /*
                         * Remember that we have a Root_prefix --
                         * see comment in Acpi_ex_allocate_name_string()
                         */
-                       prefix_count = (u32) -1;
+                       aml_address++;
+                       prefix_count = ACPI_UINT32_MAX;
                        has_prefix = TRUE;
                        break;
 
@@ -295,18 +286,21 @@ acpi_ex_get_name_string (
                        /* Increment past possibly multiple parent prefixes */
 
                        do {
-                               prefix = *aml_address++;
-                               ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Parent_prefix: %x\n", prefix));
+                               ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Parent_prefix (^) at %p\n", aml_address));
 
-                               ++prefix_count;
+                               aml_address++;
+                               prefix_count++;
 
                        } while (*aml_address == AML_PARENT_PREFIX);
+
                        has_prefix = TRUE;
                        break;
 
 
                default:
 
+                       /* Not a prefix character */
+
                        break;
                }
 
@@ -314,12 +308,11 @@ acpi_ex_get_name_string (
                /* Examine first character of name for name segment prefix operator */
 
                switch (*aml_address) {
-
                case AML_DUAL_NAME_PREFIX:
 
-                       prefix = *aml_address++;
-                       ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Dual_name_prefix: %x\n", prefix));
+                       ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Dual_name_prefix at %p\n", aml_address));
 
+                       aml_address++;
                        name_string = acpi_ex_allocate_name_string (prefix_count, 2);
                        if (!name_string) {
                                status = AE_NO_MEMORY;
@@ -339,12 +332,12 @@ acpi_ex_get_name_string (
 
                case AML_MULTI_NAME_PREFIX_OP:
 
-                       prefix = *aml_address++;
-                       ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Multi_name_prefix: %x\n", prefix));
+                       ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Multi_name_prefix at %p\n", aml_address));
 
                        /* Fetch count of segments remaining in name path */
 
-                       num_segments = *aml_address++;
+                       aml_address++;
+                       num_segments = *aml_address;
 
                        name_string = acpi_ex_allocate_name_string (prefix_count, num_segments);
                        if (!name_string) {
@@ -354,11 +347,12 @@ acpi_ex_get_name_string (
 
                        /* Indicate that we processed a prefix */
 
+                       aml_address++;
                        has_prefix = TRUE;
 
                        while (num_segments &&
                                        (status = acpi_ex_name_segment (&aml_address, name_string)) == AE_OK) {
-                               --num_segments;
+                               num_segments--;
                        }
 
                        break;
@@ -368,7 +362,7 @@ acpi_ex_get_name_string (
 
                        /* Null_name valid as of 8-12-98 ASL/AML Grammar Update */
 
-                       if (-1 == prefix_count) {
+                       if (prefix_count == ACPI_UINT32_MAX) {
                                ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Name_seg is \"\\\" followed by NULL\n"));
                        }
 
@@ -396,20 +390,17 @@ acpi_ex_get_name_string (
 
                        status = acpi_ex_name_segment (&aml_address, name_string);
                        break;
-
-               }   /* Switch (Peek_op ())   */
+               }
        }
 
-
        if (AE_CTRL_PENDING == status && has_prefix) {
                /* Ran out of segments after processing a prefix */
 
-               REPORT_ERROR (
+               ACPI_REPORT_ERROR (
                        ("Ex_do_name: Malformed Name at %p\n", name_string));
                status = AE_AML_BAD_NAME;
        }
 
-
        *out_name_string = name_string;
        *out_name_length = (u32) (aml_address - in_aml_address);
 
index 51eefd56e5d564afd198b3ae19b68766bcbf8a40..d1092d09a69eaffcb522d3f0bccdd97fc8ced2e5 100644 (file)
@@ -2,12 +2,12 @@
 /******************************************************************************
  *
  * Module Name: exoparg1 - AML execution - opcodes with 1 argument
- *              $Revision: 120 $
+ *              $Revision: 134 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -34,7 +34,7 @@
 
 
 #define _COMPONENT          ACPI_EXECUTER
-        MODULE_NAME         ("exoparg1")
+        ACPI_MODULE_NAME    ("exoparg1")
 
 
 /*!
@@ -81,10 +81,10 @@ acpi_ex_opcode_1A_0T_0R (
        acpi_status             status = AE_OK;
 
 
-       FUNCTION_TRACE_STR ("Ex_opcode_1A_0T_0R", acpi_ps_get_opcode_name (walk_state->opcode));
+       ACPI_FUNCTION_TRACE_STR ("Ex_opcode_1A_0T_0R", acpi_ps_get_opcode_name (walk_state->opcode));
 
 
-       /* Examine the opcode */
+       /* Examine the AML opcode */
 
        switch (walk_state->opcode) {
        case AML_RELEASE_OP:    /*  Release (Mutex_object) */
@@ -107,13 +107,13 @@ acpi_ex_opcode_1A_0T_0R (
 
        case AML_SLEEP_OP:      /*  Sleep (Msec_time) */
 
-               acpi_ex_system_do_suspend ((u32) operand[0]->integer.value);
+               status = acpi_ex_system_do_suspend ((u32) operand[0]->integer.value);
                break;
 
 
        case AML_STALL_OP:      /*  Stall (Usec_time) */
 
-               acpi_ex_system_do_stall ((u32) operand[0]->integer.value);
+               status = acpi_ex_system_do_stall ((u32) operand[0]->integer.value);
                break;
 
 
@@ -125,7 +125,7 @@ acpi_ex_opcode_1A_0T_0R (
 
        default:                /*  Unknown opcode  */
 
-               REPORT_ERROR (("Acpi_ex_opcode_1A_0T_0R: Unknown opcode %X\n",
+               ACPI_REPORT_ERROR (("Acpi_ex_opcode_1A_0T_0R: Unknown opcode %X\n",
                        walk_state->opcode));
                status = AE_AML_BAD_OPCODE;
                break;
@@ -156,19 +156,20 @@ acpi_ex_opcode_1A_1T_0R (
        acpi_operand_object     **operand = &walk_state->operands[0];
 
 
-       FUNCTION_TRACE_STR ("Ex_opcode_1A_1T_0R", acpi_ps_get_opcode_name (walk_state->opcode));
+       ACPI_FUNCTION_TRACE_STR ("Ex_opcode_1A_1T_0R", acpi_ps_get_opcode_name (walk_state->opcode));
 
 
-       switch (walk_state->opcode) {
+       /* Examine the AML opcode */
 
+       switch (walk_state->opcode) {
        case AML_LOAD_OP:
 
-               status = acpi_ex_load_op (operand[0], operand[1]);
+               status = acpi_ex_load_op (operand[0], operand[1], walk_state);
                break;
 
        default:                        /* Unknown opcode */
 
-               REPORT_ERROR (("Acpi_ex_opcode_1A_1T_0R: Unknown opcode %X\n",
+               ACPI_REPORT_ERROR (("Acpi_ex_opcode_1A_1T_0R: Unknown opcode %X\n",
                        walk_state->opcode));
                status = AE_AML_BAD_OPCODE;
                goto cleanup;
@@ -208,7 +209,7 @@ acpi_ex_opcode_1A_1T_1R (
        acpi_integer            digit;
 
 
-       FUNCTION_TRACE_STR ("Ex_opcode_1A_1T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
+       ACPI_FUNCTION_TRACE_STR ("Ex_opcode_1A_1T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
 
 
        /* Create a return object of type Integer for most opcodes */
@@ -230,6 +231,7 @@ acpi_ex_opcode_1A_1T_1R (
                break;
        }
 
+       /* Examine the AML opcode */
 
        switch (walk_state->opcode) {
 
@@ -241,7 +243,6 @@ acpi_ex_opcode_1A_1T_1R (
 
        case AML_FIND_SET_LEFT_BIT_OP:  /* Find_set_left_bit (Operand, Result) */
 
-
                return_desc->integer.value = operand[0]->integer.value;
 
                /*
@@ -258,7 +259,6 @@ acpi_ex_opcode_1A_1T_1R (
 
        case AML_FIND_SET_RIGHT_BIT_OP: /* Find_set_right_bit (Operand, Result) */
 
-
                return_desc->integer.value = operand[0]->integer.value;
 
                /*
@@ -312,7 +312,8 @@ acpi_ex_opcode_1A_1T_1R (
 
                if (operand[0]->integer.value > ACPI_MAX_BCD_VALUE) {
                        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "BCD overflow: %8.8X%8.8X\n",
-                               HIDWORD(operand[0]->integer.value), LODWORD(operand[0]->integer.value)));
+                               ACPI_HIDWORD(operand[0]->integer.value),
+                               ACPI_LODWORD(operand[0]->integer.value)));
                        status = AE_AML_NUMERIC_OVERFLOW;
                        goto cleanup;
                }
@@ -330,7 +331,7 @@ acpi_ex_opcode_1A_1T_1R (
                        /* Create the BCD digit from the remainder above */
 
                        if (digit > 0) {
-                               return_desc->integer.value += (temp32 << (i * 4));
+                               return_desc->integer.value += ((acpi_integer) temp32 << (i * 4));
                        }
                }
                break;
@@ -371,7 +372,6 @@ acpi_ex_opcode_1A_1T_1R (
 
                return_desc->integer.value = ACPI_INTEGER_MAX;
                goto cleanup;
-               break;
 
 
        case AML_STORE_OP:              /* Store (Source, Target) */
@@ -395,7 +395,6 @@ acpi_ex_opcode_1A_1T_1R (
                walk_state->result_obj = operand[0];
                walk_state->operands[0] = NULL; /* Prevent deletion */
                return_ACPI_STATUS (status);
-               break;
 
 
        /*
@@ -403,8 +402,7 @@ acpi_ex_opcode_1A_1T_1R (
         */
        case AML_COPY_OP:               /* Copy (Source, Target) */
 
-               status = AE_NOT_IMPLEMENTED;
-               goto cleanup;
+               status = acpi_ut_copy_iobject_to_iobject (operand[0], &return_desc, walk_state);
                break;
 
 
@@ -432,29 +430,26 @@ acpi_ex_opcode_1A_1T_1R (
                break;
 
 
-       /*
-        * These are two obsolete opcodes
-        */
        case AML_SHIFT_LEFT_BIT_OP:     /*  Shift_left_bit (Source, Bit_num) */
        case AML_SHIFT_RIGHT_BIT_OP:    /*  Shift_right_bit (Source, Bit_num) */
 
-
+               /*
+                * These are two obsolete opcodes
+                */
                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s is obsolete and not implemented\n",
                                  acpi_ps_get_opcode_name (walk_state->opcode)));
                status = AE_SUPPORT;
                goto cleanup;
-               break;
 
 
        default:                        /* Unknown opcode */
 
-               REPORT_ERROR (("Acpi_ex_opcode_1A_1T_1R: Unknown opcode %X\n",
+               ACPI_REPORT_ERROR (("Acpi_ex_opcode_1A_1T_1R: Unknown opcode %X\n",
                        walk_state->opcode));
                status = AE_AML_BAD_OPCODE;
                goto cleanup;
        }
 
-
        /*
         * Store the return value computed above into the target object
         */
@@ -499,13 +494,12 @@ acpi_ex_opcode_1A_0T_1R (
        acpi_integer            value;
 
 
-       FUNCTION_TRACE_STR ("Ex_opcode_1A_0T_0R", acpi_ps_get_opcode_name (walk_state->opcode));
+       ACPI_FUNCTION_TRACE_STR ("Ex_opcode_1A_0T_0R", acpi_ps_get_opcode_name (walk_state->opcode));
 
 
-       /* Get the operand and decode the opcode */
+       /* Examine the AML opcode */
 
        switch (walk_state->opcode) {
-
        case AML_LNOT_OP:               /* LNot (Operand) */
 
                return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
@@ -523,10 +517,10 @@ acpi_ex_opcode_1A_0T_1R (
 
                /*
                 * Since we are expecting a Reference operand, it
-                * can be either a Node or an internal object.
+                * can be either a NS Node or an internal object.
                 */
                return_desc = operand[0];
-               if (VALID_DESCRIPTOR_TYPE (operand[0], ACPI_DESC_TYPE_INTERNAL)) {
+               if (ACPI_GET_DESCRIPTOR_TYPE (operand[0]) == ACPI_DESC_TYPE_INTERNAL) {
                        /* Internal reference object - prevent deletion */
 
                        acpi_ut_add_reference (return_desc);
@@ -582,7 +576,7 @@ acpi_ex_opcode_1A_0T_1R (
 
                        case AML_DEBUG_OP:
 
-                               /* Per 1.0b spec, Debug object is of type "Debug_object" */
+                               /* The Debug Object is of type "Debug_object" */
 
                                type = ACPI_TYPE_DEBUG_OBJECT;
                                break;
@@ -601,7 +595,6 @@ acpi_ex_opcode_1A_0T_1R (
                                         */
                                        type = (*(operand[0]->reference.where))->common.type;
                                }
-
                                break;
 
 
@@ -615,13 +608,12 @@ acpi_ex_opcode_1A_0T_1R (
 
                        default:
 
-                               REPORT_ERROR (("Acpi_ex_opcode_1A_0T_1R/Type_op: Internal error - Unknown Reference subtype %X\n",
+                               ACPI_REPORT_ERROR (("Acpi_ex_opcode_1A_0T_1R/Type_op: Internal error - Unknown Reference subtype %X\n",
                                        operand[0]->reference.opcode));
                                status = AE_AML_INTERNAL;
                                goto cleanup;
                        }
                }
-
                else {
                        /*
                         * It's not a Reference, so it must be a direct name pointer.
@@ -655,15 +647,19 @@ acpi_ex_opcode_1A_0T_1R (
        case AML_SIZE_OF_OP:            /* Size_of (Source_object) */
 
                temp_desc = operand[0];
-               if (VALID_DESCRIPTOR_TYPE (operand[0], ACPI_DESC_TYPE_NAMED)) {
+               if (ACPI_GET_DESCRIPTOR_TYPE (operand[0]) == ACPI_DESC_TYPE_NAMED) {
                        temp_desc = acpi_ns_get_attached_object ((acpi_namespace_node *) operand[0]);
                }
 
                if (!temp_desc) {
                        value = 0;
                }
-
                else {
+                       /*
+                        * Type is guaranteed to be a buffer, string, or package at this
+                        * point (even if the original operand was an object reference, it
+                        * will be resolved and typechecked during operand resolution.)
+                        */
                        switch (temp_desc->common.type) {
                        case ACPI_TYPE_BUFFER:
                                value = temp_desc->buffer.length;
@@ -677,16 +673,9 @@ acpi_ex_opcode_1A_0T_1R (
                                value = temp_desc->package.count;
                                break;
 
-                       case INTERNAL_TYPE_REFERENCE:
-
-                               /* TBD: this must be a reference to a buf/str/pkg?? */
-
-                               value = 4;
-                               break;
-
                        default:
-                               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Not Buf/Str/Pkg - found type %X\n",
-                                       temp_desc->common.type));
+                               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Size_of, Not Buf/Str/Pkg - found type %s\n",
+                                       acpi_ut_get_type_name (temp_desc->common.type)));
                                status = AE_AML_OPERAND_TYPE;
                                goto cleanup;
                        }
@@ -715,75 +704,93 @@ acpi_ex_opcode_1A_0T_1R (
                break;
 
 
-       case AML_DEREF_OF_OP:           /* Deref_of (Obj_reference) */
+       case AML_DEREF_OF_OP:           /* Deref_of (Obj_reference | String) */
 
-               /* Check for a method local or argument */
+               /* Check for a method local or argument, or standalone String */
 
-               if (!VALID_DESCRIPTOR_TYPE (operand[0], ACPI_DESC_TYPE_NAMED)) {
-                       /*
-                        * Must resolve/dereference the local/arg reference first
-                        */
-                       switch (operand[0]->reference.opcode) {
-                       /* Set Operand[0] to the value of the local/arg */
+               if (ACPI_GET_DESCRIPTOR_TYPE (operand[0]) != ACPI_DESC_TYPE_NAMED) {
+                       switch (ACPI_GET_OBJECT_TYPE (operand[0])) {
+                       case INTERNAL_TYPE_REFERENCE:
+                               /*
+                                * This is a Deref_of (Local_x | Arg_x)
+                                *
+                                * Must resolve/dereference the local/arg reference first
+                                */
+                               switch (operand[0]->reference.opcode) {
+                               case AML_LOCAL_OP:
+                               case AML_ARG_OP:
 
-                       case AML_LOCAL_OP:
-                       case AML_ARG_OP:
+                                       /* Set Operand[0] to the value of the local/arg */
 
-                               acpi_ds_method_data_get_value (operand[0]->reference.opcode,
-                                               operand[0]->reference.offset, walk_state, &temp_desc);
+                                       acpi_ds_method_data_get_value (operand[0]->reference.opcode,
+                                                       operand[0]->reference.offset, walk_state, &temp_desc);
 
-                               /*
-                                * Delete our reference to the input object and
-                                * point to the object just retrieved
-                                */
-                               acpi_ut_remove_reference (operand[0]);
-                               operand[0] = temp_desc;
-                               break;
+                                       /*
+                                        * Delete our reference to the input object and
+                                        * point to the object just retrieved
+                                        */
+                                       acpi_ut_remove_reference (operand[0]);
+                                       operand[0] = temp_desc;
+                                       break;
 
-                       default:
+                               default:
 
-                               /* Index op - handled below */
+                                       /* Must be an Index op - handled below */
+                                       break;
+                               }
                                break;
-                       }
-               }
 
 
-               /* Operand[0] may have changed from the code above */
-
-               if (VALID_DESCRIPTOR_TYPE (operand[0], ACPI_DESC_TYPE_NAMED)) {
-                       /* Get the actual object from the Node (This is the dereference) */
+                       case ACPI_TYPE_STRING:
 
-                       return_desc = ((acpi_namespace_node *) operand[0])->object;
+                               /*
+                                * This is a Deref_of (String). The string is a reference to a named ACPI object.
+                                *
+                                * 1) Find the owning Node
+                                * 2) Dereference the node to an actual object.  Could be a Field, so we nee
+                                *    to resolve the node to a value.
+                                */
+                               status = acpi_ns_get_node_by_path (operand[0]->string.pointer, walk_state->scope_info->scope.node,
+                                                 ACPI_NS_SEARCH_PARENT, (acpi_namespace_node **) &return_desc);
+                               if (ACPI_FAILURE (status)) {
+                                       goto cleanup;
+                               }
 
-                       /* Returning a pointer to the object, add another reference! */
+                               status = acpi_ex_resolve_node_to_value ((acpi_namespace_node **) &return_desc, walk_state);
+                               goto cleanup;
 
-                       acpi_ut_add_reference (return_desc);
-               }
 
-               else {
-                       /*
-                        * This must be a reference object produced by the Index
-                        * ASL operation -- check internal opcode
-                        */
-                       if ((operand[0]->reference.opcode != AML_INDEX_OP) &&
-                               (operand[0]->reference.opcode != AML_REF_OF_OP)) {
-                               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown opcode in ref(%p) - %X\n",
-                                       operand[0], operand[0]->reference.opcode));
+                       default:
 
-                               status = AE_TYPE;
+                               status = AE_AML_OPERAND_TYPE;
                                goto cleanup;
                        }
+               }
 
+               /* Operand[0] may have changed from the code above */
 
+               if (ACPI_GET_DESCRIPTOR_TYPE (operand[0]) == ACPI_DESC_TYPE_NAMED) {
+                       /*
+                        * This is a Deref_of (Object_reference)
+                        * Get the actual object from the Node (This is the dereference).
+                        * -- This case may only happen when a Local_x or Arg_x is dereferenced above.
+                        */
+                       return_desc = acpi_ns_get_attached_object ((acpi_namespace_node *) operand[0]);
+               }
+               else {
+                       /*
+                        * This must be a reference object produced by either the Index() or
+                        * Ref_of() operator
+                        */
                        switch (operand[0]->reference.opcode) {
                        case AML_INDEX_OP:
 
                                /*
-                                * Supported target types for the Index operator are
-                                * 1) A Buffer
-                                * 2) A Package
+                                * The target type for the Index operator must be
+                                * either a Buffer or a Package
                                 */
-                               if (operand[0]->reference.target_type == ACPI_TYPE_BUFFER_FIELD) {
+                               switch (operand[0]->reference.target_type) {
+                               case ACPI_TYPE_BUFFER_FIELD:
                                        /*
                                         * The target is a buffer, we must create a new object that
                                         * contains one element of the buffer, the element pointed
@@ -799,16 +806,19 @@ acpi_ex_opcode_1A_0T_1R (
                                                goto cleanup;
                                        }
 
+                                       /*
+                                        * Since we are returning the value of the buffer at the
+                                        * indexed location, we don't need to add an additional
+                                        * reference to the buffer itself.
+                                        */
                                        temp_desc = operand[0]->reference.object;
                                        return_desc->integer.value =
                                                temp_desc->buffer.pointer[operand[0]->reference.offset];
+                                       break;
 
-                                       /* TBD: [Investigate] (see below) Don't add an additional
-                                        * ref!
-                                        */
-                               }
 
-                               else if (operand[0]->reference.target_type == ACPI_TYPE_PACKAGE) {
+                               case ACPI_TYPE_PACKAGE:
+
                                        /*
                                         * The target is a package, we want to return the referenced
                                         * element of the package.  We must add another reference to
@@ -821,7 +831,6 @@ acpi_ex_opcode_1A_0T_1R (
                                                 * an uninitialized package element and is thus a
                                                 * severe error.
                                                 */
-
                                                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "NULL package element obj %p\n",
                                                        operand[0]));
                                                status = AE_AML_UNINITIALIZED_ELEMENT;
@@ -829,15 +838,16 @@ acpi_ex_opcode_1A_0T_1R (
                                        }
 
                                        acpi_ut_add_reference (return_desc);
-                               }
+                                       break;
+
+
+                               default:
 
-                               else {
-                                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Target_type %X in obj %p\n",
+                                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Index Target_type %X in obj %p\n",
                                                operand[0]->reference.target_type, operand[0]));
                                        status = AE_AML_OPERAND_TYPE;
                                        goto cleanup;
                                }
-
                                break;
 
 
@@ -849,15 +859,22 @@ acpi_ex_opcode_1A_0T_1R (
 
                                acpi_ut_add_reference (return_desc);
                                break;
+
+
+                       default:
+                               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown opcode in ref(%p) - %X\n",
+                                       operand[0], operand[0]->reference.opcode));
+
+                               status = AE_TYPE;
+                               goto cleanup;
                        }
                }
-
                break;
 
 
        default:
 
-               REPORT_ERROR (("Acpi_ex_opcode_1A_0T_1R: Unknown opcode %X\n",
+               ACPI_REPORT_ERROR (("Acpi_ex_opcode_1A_0T_1R: Unknown opcode %X\n",
                        walk_state->opcode));
                status = AE_AML_BAD_OPCODE;
                goto cleanup;
index 029b932901e5fba67c124f3bffdf02d737f5cd50..ee81683fded84e292586e2a437ee963e2737fe99 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: exoparg2 - AML execution - opcodes with 2 arguments
- *              $Revision: 97 $
+ *              $Revision: 104 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -34,7 +34,7 @@
 
 
 #define _COMPONENT          ACPI_EXECUTER
-        MODULE_NAME         ("exoparg2")
+        ACPI_MODULE_NAME    ("exoparg2")
 
 
 /*!
@@ -84,7 +84,7 @@ acpi_ex_opcode_2A_0T_0R (
        acpi_status             status = AE_OK;
 
 
-       FUNCTION_TRACE_STR ("Ex_opcode_2A_0T_0R", acpi_ps_get_opcode_name (walk_state->opcode));
+       ACPI_FUNCTION_TRACE_STR ("Ex_opcode_2A_0T_0R", acpi_ps_get_opcode_name (walk_state->opcode));
 
 
        /* Examine the opcode */
@@ -97,37 +97,36 @@ acpi_ex_opcode_2A_0T_0R (
 
                node = (acpi_namespace_node *) operand[0];
 
-               /* The node must refer to a device or thermal zone */
+               /* The node must refer to a device or thermal zone or processor */
 
-               if (node && operand[1])     /* TBD: is this check necessary? */ {
-                       switch (node->type) {
-                       case ACPI_TYPE_DEVICE:
-                       case ACPI_TYPE_THERMAL:
+               switch (node->type) {
+               case ACPI_TYPE_DEVICE:
+               case ACPI_TYPE_THERMAL:
+               case ACPI_TYPE_PROCESSOR:
 
-                               /*
-                                * Dispatch the notify to the appropriate handler
-                                * NOTE: the request is queued for execution after this method
-                                * completes.  The notify handlers are NOT invoked synchronously
-                                * from this thread -- because handlers may in turn run other
-                                * control methods.
-                                */
-                               status = acpi_ev_queue_notify_request (node,
-                                                (u32) operand[1]->integer.value);
-                               break;
+                       /*
+                        * Dispatch the notify to the appropriate handler
+                        * NOTE: the request is queued for execution after this method
+                        * completes.  The notify handlers are NOT invoked synchronously
+                        * from this thread -- because handlers may in turn run other
+                        * control methods.
+                        */
+                       status = acpi_ev_queue_notify_request (node,
+                                        (u32) operand[1]->integer.value);
+                       break;
 
-                       default:
-                               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unexpected notify object type %X\n",
-                                       node->type));
+               default:
+                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unexpected notify object type %X\n",
+                               node->type));
 
-                               status = AE_AML_OPERAND_TYPE;
-                               break;
-                       }
+                       status = AE_AML_OPERAND_TYPE;
+                       break;
                }
                break;
 
        default:
 
-               REPORT_ERROR (("Acpi_ex_opcode_2A_0T_0R: Unknown opcode %X\n", walk_state->opcode));
+               ACPI_REPORT_ERROR (("Acpi_ex_opcode_2A_0T_0R: Unknown opcode %X\n", walk_state->opcode));
                status = AE_AML_BAD_OPCODE;
        }
 
@@ -158,7 +157,7 @@ acpi_ex_opcode_2A_2T_1R (
        acpi_status             status;
 
 
-       FUNCTION_TRACE_STR ("Ex_opcode_2A_2T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
+       ACPI_FUNCTION_TRACE_STR ("Ex_opcode_2A_2T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
 
 
        /*
@@ -191,11 +190,10 @@ acpi_ex_opcode_2A_2T_1R (
 
        default:
 
-               REPORT_ERROR (("Acpi_ex_opcode_2A_2T_1R: Unknown opcode %X\n",
+               ACPI_REPORT_ERROR (("Acpi_ex_opcode_2A_2T_1R: Unknown opcode %X\n",
                                walk_state->opcode));
                status = AE_AML_BAD_OPCODE;
                goto cleanup;
-               break;
        }
 
 
@@ -257,7 +255,7 @@ acpi_ex_opcode_2A_1T_1R (
        acpi_status             status      = AE_OK;
 
 
-       FUNCTION_TRACE_STR ("Ex_opcode_2A_1T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
+       ACPI_FUNCTION_TRACE_STR ("Ex_opcode_2A_1T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
 
 
        /*
@@ -344,7 +342,7 @@ acpi_ex_opcode_2A_1T_1R (
 
        case AML_CONCAT_RES_OP:         /* Concatenate_res_template (Buffer, Buffer, Result) (ACPI 2.0) */
 
-               status = AE_NOT_IMPLEMENTED;
+               status = acpi_ex_concat_template (operand[0], operand[1], &return_desc, walk_state);
                break;
 
 
@@ -424,12 +422,11 @@ acpi_ex_opcode_2A_1T_1R (
 
                walk_state->result_obj = return_desc;
                goto cleanup;
-               break;
 
 
        default:
 
-               REPORT_ERROR (("Acpi_ex_opcode_2A_1T_1R: Unknown opcode %X\n",
+               ACPI_REPORT_ERROR (("Acpi_ex_opcode_2A_1T_1R: Unknown opcode %X\n",
                                walk_state->opcode));
                status = AE_AML_BAD_OPCODE;
                break;
@@ -486,7 +483,7 @@ acpi_ex_opcode_2A_0T_1R (
        u8                      logical_result = FALSE;
 
 
-       FUNCTION_TRACE_STR ("Ex_opcode_2A_0T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
+       ACPI_FUNCTION_TRACE_STR ("Ex_opcode_2A_0T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
 
 
        /* Create the internal return object */
@@ -531,10 +528,9 @@ acpi_ex_opcode_2A_0T_1R (
 
        default:
 
-               REPORT_ERROR (("Acpi_ex_opcode_2A_0T_1R: Unknown opcode %X\n", walk_state->opcode));
+               ACPI_REPORT_ERROR (("Acpi_ex_opcode_2A_0T_1R: Unknown opcode %X\n", walk_state->opcode));
                status = AE_AML_BAD_OPCODE;
                goto cleanup;
-               break;
        }
 
 
index 34531587725480ce8f7466e14e5bbe9fa6ae6462..b18a34700c8f646a5f731b974203e49c2b23c881 100644 (file)
@@ -2,12 +2,12 @@
 /******************************************************************************
  *
  * Module Name: exoparg3 - AML execution - opcodes with 3 arguments
- *              $Revision: 3 $
+ *              $Revision: 9 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -32,7 +32,7 @@
 
 
 #define _COMPONENT          ACPI_EXECUTER
-        MODULE_NAME         ("exoparg3")
+        ACPI_MODULE_NAME    ("exoparg3")
 
 
 /*!
@@ -79,7 +79,7 @@ acpi_ex_opcode_3A_0T_0R (
        acpi_status             status = AE_OK;
 
 
-       FUNCTION_TRACE_STR ("Ex_opcode_3A_0T_0R", acpi_ps_get_opcode_name (walk_state->opcode));
+       ACPI_FUNCTION_TRACE_STR ("Ex_opcode_3A_0T_0R", acpi_ps_get_opcode_name (walk_state->opcode));
 
 
        switch (walk_state->opcode) {
@@ -112,11 +112,10 @@ acpi_ex_opcode_3A_0T_0R (
 
        default:
 
-               REPORT_ERROR (("Acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n",
+               ACPI_REPORT_ERROR (("Acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n",
                                walk_state->opcode));
                status = AE_AML_BAD_OPCODE;
                goto cleanup;
-               break;
        }
 
 
@@ -150,7 +149,7 @@ acpi_ex_opcode_3A_1T_1R (
        u32                     length;
 
 
-       FUNCTION_TRACE_STR ("Ex_opcode_3A_1T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
+       ACPI_FUNCTION_TRACE_STR ("Ex_opcode_3A_1T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
 
 
        switch (walk_state->opcode) {
@@ -188,30 +187,29 @@ acpi_ex_opcode_3A_1T_1R (
 
                        buffer = ACPI_MEM_CALLOCATE (length + 1);
                        if (!buffer) {
-                               return (AE_NO_MEMORY);
+                               status = AE_NO_MEMORY;
+                               goto cleanup;
                        }
 
                        /* Copy the portion requested */
 
-                       MEMCPY (buffer, operand[0]->string.pointer + index,
-                                       length);
+                       ACPI_MEMCPY (buffer, operand[0]->string.pointer + index,
+                                         length);
 
                        /* Set the length of the new String/Buffer */
 
                        return_desc->string.pointer = buffer;
                        return_desc->string.length = length;
                }
-
                break;
 
 
        default:
 
-               REPORT_ERROR (("Acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n",
+               ACPI_REPORT_ERROR (("Acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n",
                                walk_state->opcode));
                status = AE_AML_BAD_OPCODE;
                goto cleanup;
-               break;
        }
 
        /* Store the result in the target */
index ceda2b488918b7442a6f9bc9dec92ed22610801c..36cf10a5c8a36290bd6a2bec3ef82315a692d516 100644 (file)
@@ -2,12 +2,12 @@
 /******************************************************************************
  *
  * Module Name: exoparg6 - AML execution - opcodes with 6 arguments
- *              $Revision: 4 $
+ *              $Revision: 10 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -32,7 +32,7 @@
 
 
 #define _COMPONENT          ACPI_EXECUTER
-        MODULE_NAME         ("exoparg6")
+        ACPI_MODULE_NAME    ("exoparg6")
 
 
 /*!
@@ -158,7 +158,7 @@ acpi_ex_opcode_6A_0T_1R (
        acpi_operand_object     *this_element;
 
 
-       FUNCTION_TRACE_STR ("Ex_opcode_6A_0T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
+       ACPI_FUNCTION_TRACE_STR ("Ex_opcode_6A_0T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
 
 
        switch (walk_state->opcode) {
@@ -199,6 +199,7 @@ acpi_ex_opcode_6A_0T_1R (
                 * Examine each element until a match is found.  Within the loop,
                 * "continue" signifies that the current element does not match
                 * and the next should be examined.
+                *
                 * Upon finding a match, the loop will terminate via "break" at
                 * the bottom.  If it terminates "normally", Match_value will be -1
                 * (its initial value) indicating that no match was found.  When
@@ -209,27 +210,21 @@ acpi_ex_opcode_6A_0T_1R (
 
                        /*
                         * Treat any NULL or non-numeric elements as non-matching.
-                        * TBD [Unhandled] - if an element is a Name,
-                        *      should we examine its value?
                         */
                        if (!this_element ||
                                this_element->common.type != ACPI_TYPE_INTEGER) {
                                continue;
                        }
 
-
                        /*
-                        * Within these switch statements:
-                        *      "break" (exit from the switch) signifies a match;
-                        *      "continue" (proceed to next iteration of enclosing
-                        *          "for" loop) signifies a non-match.
+                        * "continue" (proceed to next iteration of enclosing
+                        * "for" loop) signifies a non-match.
                         */
                        if (!acpi_ex_do_match ((u32) operand[1]->integer.value,
                                           this_element->integer.value, operand[2]->integer.value)) {
                                continue;
                        }
 
-
                        if (!acpi_ex_do_match ((u32) operand[3]->integer.value,
                                           this_element->integer.value, operand[4]->integer.value)) {
                                continue;
@@ -246,18 +241,16 @@ acpi_ex_opcode_6A_0T_1R (
 
        case AML_LOAD_TABLE_OP:
 
-               status = AE_NOT_IMPLEMENTED;
-               goto cleanup;
+               status = acpi_ex_load_table_op (walk_state, &return_desc);
                break;
 
 
        default:
 
-               REPORT_ERROR (("Acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n",
+               ACPI_REPORT_ERROR (("Acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n",
                                walk_state->opcode));
                status = AE_AML_BAD_OPCODE;
                goto cleanup;
-               break;
        }
 
 
index 0f1e4ae20eb8eb488f3d2416ad172b34c5ae523a..81d0199c4c8d3fc3ce8cbf548ae9274ffef693d0 100644 (file)
@@ -2,12 +2,12 @@
 /******************************************************************************
  *
  * Module Name: exprep - ACPI AML (p-code) execution - field prep utilities
- *              $Revision: 99 $
+ *              $Revision: 114 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 
 
 #define _COMPONENT          ACPI_EXECUTER
-        MODULE_NAME         ("exprep")
+        ACPI_MODULE_NAME    ("exprep")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_decode_field_access_type
+ * FUNCTION:    Acpi_ex_decode_field_access
  *
  * PARAMETERS:  Access          - Encoded field access bits
  *              Length          - Field length.
  *
- * RETURN:      Field granularity (8, 16, 32 or 64)
+ * RETURN:      Field granularity (8, 16, 32 or 64) and
+ *              Byte_alignment (1, 2, 3, or 4)
  *
  * DESCRIPTION: Decode the Access_type bits of a field definition.
  *
  ******************************************************************************/
 
 static u32
-acpi_ex_decode_field_access_type (
-       u32                     access,
-       u16                     length,
-       u32                     *alignment)
+acpi_ex_decode_field_access (
+       acpi_operand_object     *obj_desc,
+       u8                      field_flags,
+       u32                     *return_byte_alignment)
 {
-       PROC_NAME ("Ex_decode_field_access_type");
+       u32                     access;
+       u32                     length;
+       u8                      byte_alignment;
+       u8                      bit_length;
+
+
+       ACPI_FUNCTION_NAME ("Ex_decode_field_access");
+
 
+       access = (field_flags & AML_FIELD_ACCESS_TYPE_MASK);
+       length = obj_desc->common_field.bit_length;
 
        switch (access) {
-       case ACCESS_ANY_ACC:
+       case AML_FIELD_ACCESS_ANY:
 
-               *alignment = 8;
+               byte_alignment = 1;
+               bit_length = 8;
+
+#if 0
+               /*
+                * TBD: optimize
+                *
+                * Any attempt to optimize the access size to the size of the field
+                * must take into consideration the length of the region and take
+                * care that an access to the field will not attempt to access
+                * beyond the end of the region.
+                */
 
                /* Use the length to set the access type */
 
                if (length <= 8) {
-                       return (8);
+                       bit_length = 8;
                }
                else if (length <= 16) {
-                       return (16);
+                       bit_length = 16;
                }
                else if (length <= 32) {
-                       return (32);
+                       bit_length = 32;
                }
                else if (length <= 64) {
-                       return (64);
+                       bit_length = 64;
                }
+               else {
+                       /* Larger than Qword - just use byte-size chunks */
 
-               /* Default is 8 (byte) */
+                       bit_length = 8;
+               }
+#endif
+               break;
 
-               return (8);
+       case AML_FIELD_ACCESS_BYTE:
+               byte_alignment = 1;
+               bit_length = 8;
                break;
 
-       case ACCESS_BYTE_ACC:
-               *alignment = 8;
-               return (8);
+       case AML_FIELD_ACCESS_WORD:
+               byte_alignment = 2;
+               bit_length = 16;
                break;
 
-       case ACCESS_WORD_ACC:
-               *alignment = 16;
-               return (16);
+       case AML_FIELD_ACCESS_DWORD:
+               byte_alignment = 4;
+               bit_length = 32;
                break;
 
-       case ACCESS_DWORD_ACC:
-               *alignment = 32;
-               return (32);
+       case AML_FIELD_ACCESS_QWORD:  /* ACPI 2.0 */
+               byte_alignment = 8;
+               bit_length = 64;
                break;
 
-       case ACCESS_QWORD_ACC:  /* ACPI 2.0 */
-               *alignment = 64;
-               return (64);
+       case AML_FIELD_ACCESS_BUFFER:  /* ACPI 2.0 */
+               byte_alignment = 8;
+               bit_length = 8;
                break;
 
        default:
@@ -111,6 +139,18 @@ acpi_ex_decode_field_access_type (
                        access));
                return (0);
        }
+
+       if (obj_desc->common.type == ACPI_TYPE_BUFFER_FIELD) {
+               /*
+                * Buffer_field access can be on any byte boundary, so the
+                * Byte_alignment is always 1 byte -- regardless of any Byte_alignment
+                * implied by the field access type.
+                */
+               byte_alignment = 1;
+       }
+
+       *return_byte_alignment = byte_alignment;
+       return (bit_length);
 }
 
 
@@ -128,7 +168,9 @@ acpi_ex_decode_field_access_type (
  * RETURN:      Status
  *
  * DESCRIPTION: Initialize the areas of the field object that are common
- *              to the various types of fields.
+ *              to the various types of fields.  Note: This is very "sensitive"
+ *              code because we are solving the general case for field
+ *              alignment.
  *
  ******************************************************************************/
 
@@ -136,107 +178,90 @@ acpi_status
 acpi_ex_prep_common_field_object (
        acpi_operand_object     *obj_desc,
        u8                      field_flags,
+       u8                      field_attribute,
        u32                     field_bit_position,
        u32                     field_bit_length)
 {
        u32                     access_bit_width;
-       u32                     alignment;
+       u32                     byte_alignment;
        u32                     nearest_byte_address;
 
 
-       FUNCTION_TRACE ("Ex_prep_common_field_object");
+       ACPI_FUNCTION_TRACE ("Ex_prep_common_field_object");
 
 
        /*
         * Note: the structure being initialized is the
-        * ACPI_COMMON_FIELD_INFO;  No structure fields outside of the common area
-        * are initialized by this procedure.
+        * ACPI_COMMON_FIELD_INFO;  No structure fields outside of the common
+        * area are initialized by this procedure.
         */
-
-       /* Demultiplex the Field_flags byte */
-
-       obj_desc->common_field.lock_rule = (u8) ((field_flags & LOCK_RULE_MASK)
-                        >> LOCK_RULE_SHIFT);
-       obj_desc->common_field.update_rule = (u8) ((field_flags & UPDATE_RULE_MASK)
-                        >> UPDATE_RULE_SHIFT);
-       /* Other misc fields */
-
-       obj_desc->common_field.bit_length = (u16) field_bit_length;
+       obj_desc->common_field.field_flags = field_flags;
+       obj_desc->common_field.attribute = field_attribute;
+       obj_desc->common_field.bit_length = field_bit_length;
 
        /*
         * Decode the access type so we can compute offsets.  The access type gives
         * two pieces of information - the width of each field access and the
-        * necessary alignment of the access.  For Any_acc, the width used is the
-        * largest necessary/possible in an attempt to access the whole field in one
-        * I/O operation.  However, for Any_acc, the alignment is 8. For all other
-        * access types (Byte, Word, Dword, Qword), the width is the same as the
-        * alignment.
+        * necessary Byte_alignment (address granularity) of the access.
+        *
+        * For Any_acc, the Access_bit_width is the largest width that is both necessary
+        * and possible in an attempt to access the whole field in one
+        * I/O operation.  However, for Any_acc, the Byte_alignment is always one byte.
+        *
+        * For all Buffer Fields, the Byte_alignment is always one byte.
+        *
+        * For all other access types (Byte, Word, Dword, Qword), the Bitwidth is the
+        * same (equivalent) as the Byte_alignment.
         */
-       access_bit_width = acpi_ex_decode_field_access_type (
-                          ((field_flags & ACCESS_TYPE_MASK) >> ACCESS_TYPE_SHIFT),
-                          obj_desc->field.bit_length, &alignment);
+       access_bit_width = acpi_ex_decode_field_access (obj_desc, field_flags, &byte_alignment);
        if (!access_bit_width) {
                return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
        }
 
        /* Setup width (access granularity) fields */
 
-       obj_desc->common_field.access_bit_width = (u8) access_bit_width;         /* 8, 16, 32, 64 */
-       obj_desc->common_field.access_byte_width = (u8) DIV_8 (access_bit_width); /* 1, 2,  4,  8 */
-
-       if (obj_desc->common.type == ACPI_TYPE_BUFFER_FIELD) {
-               /*
-                * Buffer_field access can be on any byte boundary, so the
-                * alignment is always 8 (regardless of any alignment implied by the
-                * field access type.)
-                */
-               alignment = 8;
-       }
-
+       obj_desc->common_field.access_byte_width = (u8) ACPI_DIV_8 (access_bit_width); /* 1, 2, 4,  8 */
 
        /*
         * Base_byte_offset is the address of the start of the field within the region. It is
         * the byte address of the first *datum* (field-width data unit) of the field.
         * (i.e., the first datum that contains at least the first *bit* of the field.)
+        * Note: Byte_alignment is always either equal to the Access_bit_width or 8 (Byte access),
+        * and it defines the addressing granularity of the parent region or buffer.
         */
-       nearest_byte_address                      = ROUND_BITS_DOWN_TO_BYTES (field_bit_position);
-       obj_desc->common_field.base_byte_offset   = ROUND_DOWN (nearest_byte_address,
-                          DIV_8 (alignment));
+       nearest_byte_address                     = ACPI_ROUND_BITS_DOWN_TO_BYTES (field_bit_position);
+       obj_desc->common_field.base_byte_offset  = ACPI_ROUND_DOWN (nearest_byte_address, byte_alignment);
 
        /*
         * Start_field_bit_offset is the offset of the first bit of the field within a field datum.
-        * This is calculated as the number of bits from the Base_byte_offset. In other words,
-        * the start of the field is relative to a byte address, regardless of the access type
-        * of the field.
         */
-       obj_desc->common_field.start_field_bit_offset = (u8) (MOD_8 (field_bit_position));
-
-       /*
-        * Datum_valid_bits is the number of valid field bits in the first field datum.
-        */
-       obj_desc->common_field.datum_valid_bits   = (u8) (access_bit_width -
-                          obj_desc->common_field.start_field_bit_offset);
+       obj_desc->common_field.start_field_bit_offset = (u8) (field_bit_position -
+                         ACPI_MUL_8 (obj_desc->common_field.base_byte_offset));
 
        /*
         * Valid bits -- the number of bits that compose a partial datum,
         * 1) At the end of the field within the region (arbitrary starting bit offset)
         * 2) At the end of a buffer used to contain the field (starting offset always zero)
         */
-       obj_desc->common_field.end_field_valid_bits = (u8) ((obj_desc->common_field.start_field_bit_offset +
-                          field_bit_length) % access_bit_width);
+       obj_desc->common_field.end_field_valid_bits = (u8) ((obj_desc->common_field.start_field_bit_offset + field_bit_length) %
+                          access_bit_width);
        obj_desc->common_field.end_buffer_valid_bits = (u8) (field_bit_length % access_bit_width); /* Start_buffer_bit_offset always = 0 */
 
+       /*
+        * Datum_valid_bits is the number of valid field bits in the first field datum.
+        */
+       obj_desc->common_field.datum_valid_bits  = (u8) (access_bit_width -
+                         obj_desc->common_field.start_field_bit_offset);
 
        /*
-        * Does the entire field fit within a single field access element
-        * (datum)?  (without crossing a datum boundary)
+        * Does the entire field fit within a single field access element? (datum)
+        * (i.e., without crossing a datum boundary)
         */
-       if ((obj_desc->common_field.start_field_bit_offset + obj_desc->common_field.bit_length) <=
-               (u16) obj_desc->common_field.access_bit_width) {
-               obj_desc->common_field.access_flags |= AFIELD_SINGLE_DATUM;
+       if ((obj_desc->common_field.start_field_bit_offset + field_bit_length) <=
+               (u16) access_bit_width) {
+               obj_desc->common.flags |= AOPOBJ_SINGLE_DATUM;
        }
 
-
        return_ACPI_STATUS (AE_OK);
 }
 
@@ -267,7 +292,7 @@ acpi_ex_prep_field_value (
        acpi_status             status;
 
 
-       FUNCTION_TRACE ("Ex_prep_field_value");
+       ACPI_FUNCTION_TRACE ("Ex_prep_field_value");
 
 
        /* Parameter validation */
@@ -280,14 +305,15 @@ acpi_ex_prep_field_value (
 
                type = acpi_ns_get_type (info->region_node);
                if (type != ACPI_TYPE_REGION) {
-                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Needed Region, found type %X %s\n",
+                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+                               "Needed Region, found type %X %s\n",
                                type, acpi_ut_get_type_name (type)));
 
                        return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
                }
        }
 
-       /* Allocate a new region object */
+       /* Allocate a new field object */
 
        obj_desc = acpi_ut_create_internal_object (info->field_type);
        if (!obj_desc) {
@@ -296,8 +322,9 @@ acpi_ex_prep_field_value (
 
        /* Initialize areas of the object that are common to all fields */
 
+       obj_desc->common_field.node = info->field_node;
        status = acpi_ex_prep_common_field_object (obj_desc, info->field_flags,
-                         info->field_bit_position, info->field_bit_length);
+                        info->attribute, info->field_bit_position, info->field_bit_length);
        if (ACPI_FAILURE (status)) {
                acpi_ut_delete_object_desc (obj_desc);
                return_ACPI_STATUS (status);
@@ -308,33 +335,34 @@ acpi_ex_prep_field_value (
        switch (info->field_type) {
        case INTERNAL_TYPE_REGION_FIELD:
 
-               obj_desc->field.region_obj  = acpi_ns_get_attached_object (info->region_node);
+               obj_desc->field.region_obj   = acpi_ns_get_attached_object (info->region_node);
 
                /* An additional reference for the container */
 
                acpi_ut_add_reference (obj_desc->field.region_obj);
 
-               ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Region_field: Bitoff=%X Off=%X Gran=%X Region %p\n",
+               ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+                       "Region_field: Bitoff=%X Off=%X Gran=%X Region %p\n",
                        obj_desc->field.start_field_bit_offset, obj_desc->field.base_byte_offset,
-                       obj_desc->field.access_bit_width, obj_desc->field.region_obj));
+                       obj_desc->field.access_byte_width, obj_desc->field.region_obj));
                break;
 
 
        case INTERNAL_TYPE_BANK_FIELD:
 
-               obj_desc->bank_field.value         = info->bank_value;
-               obj_desc->bank_field.region_obj    = acpi_ns_get_attached_object (info->region_node);
-               obj_desc->bank_field.bank_register_obj = acpi_ns_get_attached_object (info->register_node);
+               obj_desc->bank_field.value   = info->bank_value;
+               obj_desc->bank_field.region_obj = acpi_ns_get_attached_object (info->region_node);
+               obj_desc->bank_field.bank_obj = acpi_ns_get_attached_object (info->register_node);
 
                /* An additional reference for the attached objects */
 
                acpi_ut_add_reference (obj_desc->bank_field.region_obj);
-               acpi_ut_add_reference (obj_desc->bank_field.bank_register_obj);
+               acpi_ut_add_reference (obj_desc->bank_field.bank_obj);
 
                ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Bank Field: Bit_off=%X Off=%X Gran=%X Region %p Bank_reg %p\n",
                        obj_desc->bank_field.start_field_bit_offset, obj_desc->bank_field.base_byte_offset,
-                       obj_desc->field.access_bit_width, obj_desc->bank_field.region_obj,
-                       obj_desc->bank_field.bank_register_obj));
+                       obj_desc->field.access_byte_width, obj_desc->bank_field.region_obj,
+                       obj_desc->bank_field.bank_obj));
                break;
 
 
@@ -343,7 +371,7 @@ acpi_ex_prep_field_value (
                obj_desc->index_field.index_obj = acpi_ns_get_attached_object (info->register_node);
                obj_desc->index_field.data_obj = acpi_ns_get_attached_object (info->data_register_node);
                obj_desc->index_field.value  = (u32) (info->field_bit_position /
-                                 obj_desc->field.access_bit_width);
+                                 ACPI_MUL_8 (obj_desc->field.access_byte_width));
 
                if (!obj_desc->index_field.data_obj || !obj_desc->index_field.index_obj) {
                        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Index Object\n"));
@@ -357,7 +385,7 @@ acpi_ex_prep_field_value (
 
                ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Index_field: bitoff=%X off=%X gran=%X Index %p Data %p\n",
                        obj_desc->index_field.start_field_bit_offset, obj_desc->index_field.base_byte_offset,
-                       obj_desc->field.access_bit_width, obj_desc->index_field.index_obj,
+                       obj_desc->field.access_byte_width, obj_desc->index_field.index_obj,
                        obj_desc->index_field.data_obj));
                break;
        }
@@ -367,10 +395,10 @@ acpi_ex_prep_field_value (
         * preserving the current type of that Named_obj.
         */
        status = acpi_ns_attach_object (info->field_node, obj_desc,
-                         (u8) acpi_ns_get_type (info->field_node));
+                         acpi_ns_get_type (info->field_node));
 
        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "set Named_obj %p (%4.4s) val = %p\n",
-               info->field_node, (char*)&(info->field_node->name), obj_desc));
+                       info->field_node, (char *) &(info->field_node->name), obj_desc));
 
        /* Remove local reference to the object */
 
index 30fee9097c81e2cf17677ee239bffc245334d4b2..26059f87583f7b01c57545809dc752dd04f29b69 100644 (file)
@@ -2,12 +2,12 @@
 /******************************************************************************
  *
  * Module Name: exregion - ACPI default Op_region (address space) handlers
- *              $Revision: 61 $
+ *              $Revision: 72 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -34,7 +34,7 @@
 
 
 #define _COMPONENT          ACPI_EXECUTER
-        MODULE_NAME         ("exregion")
+        ACPI_MODULE_NAME    ("exregion")
 
 
 /*******************************************************************************
@@ -60,7 +60,7 @@ acpi_ex_system_memory_space_handler (
        u32                     function,
        ACPI_PHYSICAL_ADDRESS   address,
        u32                     bit_width,
-       u32                     *value,
+       acpi_integer            *value,
        void                    *handler_context,
        void                    *region_context)
 {
@@ -68,9 +68,11 @@ acpi_ex_system_memory_space_handler (
        void                    *logical_addr_ptr = NULL;
        acpi_mem_space_context  *mem_info = region_context;
        u32                     length;
+       u32                     window_size;
+       u32                     remaining;
 
 
-       FUNCTION_TRACE ("Ex_system_memory_space_handler");
+       ACPI_FUNCTION_TRACE ("Ex_system_memory_space_handler");
 
 
        /* Validate and translate the bit width */
@@ -88,14 +90,16 @@ acpi_ex_system_memory_space_handler (
                length = 4;
                break;
 
+       case 64:
+               length = 8;
+               break;
+
        default:
                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid System_memory width %d\n",
                        bit_width));
                return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
-               break;
        }
 
-
        /*
         * Does the request fit into the cached memory mapping?
         * Is 1) Address below the current mapping? OR
@@ -115,61 +119,70 @@ acpi_ex_system_memory_space_handler (
                                           mem_info->mapped_length);
                }
 
-               mem_info->mapped_length = 0; /* In case of failure below */
+               /*
+                * Don't attempt to map memory beyond the end of the region, and
+                * constrain the maximum mapping size to something reasonable.
+                */
+               remaining = (u32) ((mem_info->address + (ACPI_PHYSICAL_ADDRESS) mem_info->length) - address);
+               if (remaining > SYSMEM_REGION_WINDOW_SIZE) {
+                       window_size = SYSMEM_REGION_WINDOW_SIZE;
+               }
+               else {
+                       window_size = remaining;
+               }
 
                /* Create a new mapping starting at the address given */
 
-               status = acpi_os_map_memory (address, SYSMEM_REGION_WINDOW_SIZE,
+               status = acpi_os_map_memory (address, window_size,
                                  (void **) &mem_info->mapped_logical_address);
                if (ACPI_FAILURE (status)) {
+                       mem_info->mapped_length = 0;
                        return_ACPI_STATUS (status);
                }
 
                /* Save the physical address and mapping size */
 
                mem_info->mapped_physical_address = address;
-               mem_info->mapped_length = SYSMEM_REGION_WINDOW_SIZE;
+               mem_info->mapped_length = window_size;
        }
 
-
        /*
         * Generate a logical pointer corresponding to the address we want to
         * access
         */
-
-       /* TBD: should these pointers go to 64-bit in all cases ? */
-
        logical_addr_ptr = mem_info->mapped_logical_address +
                          ((acpi_integer) address - (acpi_integer) mem_info->mapped_physical_address);
 
        ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
                "System_memory %d (%d width) Address=%8.8X%8.8X\n", function, bit_width,
-               HIDWORD (address), LODWORD (address)));
+               ACPI_HIDWORD (address), ACPI_LODWORD (address)));
 
    /* Perform the memory read or write */
 
        switch (function) {
+       case ACPI_READ:
 
-       case ACPI_READ_ADR_SPACE:
-
+               *value = 0;
                switch (bit_width) {
                case 8:
                        *value = (u32)* (u8 *) logical_addr_ptr;
                        break;
 
                case 16:
-                       MOVE_UNALIGNED16_TO_32 (value, logical_addr_ptr);
+                       ACPI_MOVE_UNALIGNED16_TO_16 (value, logical_addr_ptr);
                        break;
 
                case 32:
-                       MOVE_UNALIGNED32_TO_32 (value, logical_addr_ptr);
+                       ACPI_MOVE_UNALIGNED32_TO_32 (value, logical_addr_ptr);
                        break;
-               }
 
+               case 64:
+                       ACPI_MOVE_UNALIGNED64_TO_64 (value, logical_addr_ptr);
+                       break;
+               }
                break;
 
-
-       case ACPI_WRITE_ADR_SPACE:
+       case ACPI_WRITE:
 
                switch (bit_width) {
                case 8:
@@ -177,17 +190,19 @@ acpi_ex_system_memory_space_handler (
                        break;
 
                case 16:
-                       MOVE_UNALIGNED16_TO_16 (logical_addr_ptr, value);
+                       ACPI_MOVE_UNALIGNED16_TO_16 (logical_addr_ptr, value);
                        break;
 
                case 32:
-                       MOVE_UNALIGNED32_TO_32 (logical_addr_ptr, value);
+                       ACPI_MOVE_UNALIGNED32_TO_32 (logical_addr_ptr, value);
                        break;
-               }
 
+               case 64:
+                       ACPI_MOVE_UNALIGNED64_TO_64 (logical_addr_ptr, value);
+                       break;
+               }
                break;
 
-
        default:
                status = AE_BAD_PARAMETER;
                break;
@@ -220,37 +235,34 @@ acpi_ex_system_io_space_handler (
        u32                     function,
        ACPI_PHYSICAL_ADDRESS   address,
        u32                     bit_width,
-       u32                     *value,
+       acpi_integer            *value,
        void                    *handler_context,
        void                    *region_context)
 {
        acpi_status             status = AE_OK;
 
 
-       FUNCTION_TRACE ("Ex_system_io_space_handler");
+       ACPI_FUNCTION_TRACE ("Ex_system_io_space_handler");
 
 
        ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
                "System_iO %d (%d width) Address=%8.8X%8.8X\n", function, bit_width,
-               HIDWORD (address), LODWORD (address)));
+               ACPI_HIDWORD (address), ACPI_LODWORD (address)));
 
        /* Decode the function parameter */
 
        switch (function) {
-
-       case ACPI_READ_ADR_SPACE:
+       case ACPI_READ:
 
                *value = 0;
                status = acpi_os_read_port ((ACPI_IO_ADDRESS) address, value, bit_width);
                break;
 
-
-       case ACPI_WRITE_ADR_SPACE:
+       case ACPI_WRITE:
 
                status = acpi_os_write_port ((ACPI_IO_ADDRESS) address, *value, bit_width);
                break;
 
-
        default:
                status = AE_BAD_PARAMETER;
                break;
@@ -283,7 +295,7 @@ acpi_ex_pci_config_space_handler (
        u32                     function,
        ACPI_PHYSICAL_ADDRESS   address,
        u32                     bit_width,
-       u32                     *value,
+       acpi_integer            *value,
        void                    *handler_context,
        void                    *region_context)
 {
@@ -292,11 +304,11 @@ acpi_ex_pci_config_space_handler (
        u16                     pci_register;
 
 
-       FUNCTION_TRACE ("Ex_pci_config_space_handler");
+       ACPI_FUNCTION_TRACE ("Ex_pci_config_space_handler");
 
 
        /*
-        *  The arguments to Acpi_os(Read|Write)Pci_cfg(Byte|Word|Dword) are:
+        *  The arguments to Acpi_os(Read|Write)Pci_configuration are:
         *
         *  Pci_segment is the PCI bus segment range 0-31
         *  Pci_bus     is the PCI bus number range 0-255
@@ -308,7 +320,7 @@ acpi_ex_pci_config_space_handler (
         *
         */
        pci_id      = (acpi_pci_id *) region_context;
-       pci_register = (u16) address;
+       pci_register = (u16) (ACPI_SIZE) address;
 
        ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
                "Pci_config %d (%d) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n",
@@ -316,20 +328,17 @@ acpi_ex_pci_config_space_handler (
                pci_id->function, pci_register));
 
        switch (function) {
-
-       case ACPI_READ_ADR_SPACE:
+       case ACPI_READ:
 
                *value = 0;
                status = acpi_os_read_pci_configuration (pci_id, pci_register, value, bit_width);
                break;
 
-
-       case ACPI_WRITE_ADR_SPACE:
+       case ACPI_WRITE:
 
                status = acpi_os_write_pci_configuration (pci_id, pci_register, *value, bit_width);
                break;
 
-
        default:
 
                status = AE_BAD_PARAMETER;
@@ -363,14 +372,14 @@ acpi_ex_cmos_space_handler (
        u32                     function,
        ACPI_PHYSICAL_ADDRESS   address,
        u32                     bit_width,
-       u32                     *value,
+       acpi_integer            *value,
        void                    *handler_context,
        void                    *region_context)
 {
        acpi_status             status = AE_OK;
 
 
-       FUNCTION_TRACE ("Ex_cmos_space_handler");
+       ACPI_FUNCTION_TRACE ("Ex_cmos_space_handler");
 
 
        return_ACPI_STATUS (status);
@@ -400,16 +409,75 @@ acpi_ex_pci_bar_space_handler (
        u32                     function,
        ACPI_PHYSICAL_ADDRESS   address,
        u32                     bit_width,
-       u32                     *value,
+       acpi_integer            *value,
+       void                    *handler_context,
+       void                    *region_context)
+{
+       acpi_status             status = AE_OK;
+
+
+       ACPI_FUNCTION_TRACE ("Ex_pci_bar_space_handler");
+
+
+       return_ACPI_STATUS (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ex_data_table_space_handler
+ *
+ * PARAMETERS:  Function            - Read or Write operation
+ *              Address             - Where in the space to read or write
+ *              Bit_width           - Field width in bits (8, 16, or 32)
+ *              Value               - Pointer to in or out value
+ *              Handler_context     - Pointer to Handler's context
+ *              Region_context      - Pointer to context specific to the
+ *                                    accessed region
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Handler for the Data Table address space (Op Region)
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ex_data_table_space_handler (
+       u32                     function,
+       ACPI_PHYSICAL_ADDRESS   address,
+       u32                     bit_width,
+       acpi_integer            *value,
        void                    *handler_context,
        void                    *region_context)
 {
        acpi_status             status = AE_OK;
+       u32                     byte_width = ACPI_DIV_8 (bit_width);
+       u32                     i;
+       char                    *logical_addr_ptr;
+
+
+       ACPI_FUNCTION_TRACE ("Ex_data_table_space_handler");
+
+
+       logical_addr_ptr = ACPI_PHYSADDR_TO_PTR (address);
 
 
-       FUNCTION_TRACE ("Ex_pci_bar_space_handler");
+   /* Perform the memory read or write */
+
+       switch (function) {
+       case ACPI_READ:
 
+               for (i = 0; i < byte_width; i++) {
+                       ((char *) value) [i] = logical_addr_ptr[i];
+               }
+               break;
+
+       case ACPI_WRITE:
+
+               return_ACPI_STATUS (AE_SUPPORT);
+       }
 
        return_ACPI_STATUS (status);
 }
 
+
index 18cb0838ad8df623c1008b8fc7ef1be41f66d37b..c8b2f4b010c2b4247669af22d968c7e37a72227b 100644 (file)
@@ -2,12 +2,12 @@
 /******************************************************************************
  *
  * Module Name: exresnte - AML Interpreter object resolution
- *              $Revision: 43 $
+ *              $Revision: 50 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -36,7 +36,7 @@
 
 
 #define _COMPONENT          ACPI_EXECUTER
-        MODULE_NAME         ("exresnte")
+        ACPI_MODULE_NAME    ("exresnte")
 
 
 /*******************************************************************************
@@ -75,25 +75,24 @@ acpi_ex_resolve_node_to_value (
        acpi_operand_object     *source_desc;
        acpi_operand_object     *obj_desc = NULL;
        acpi_namespace_node     *node;
-       acpi_object_type8       entry_type;
+       acpi_object_type        entry_type;
        acpi_integer            temp_val;
 
 
-       FUNCTION_TRACE ("Ex_resolve_node_to_value");
+       ACPI_FUNCTION_TRACE ("Ex_resolve_node_to_value");
 
 
        /*
         * The stack pointer points to a acpi_namespace_node (Node).  Get the
         * object that is attached to the Node.
         */
-       node      = *object_ptr;
-       source_desc  = acpi_ns_get_attached_object (node);
+       node       = *object_ptr;
+       source_desc = acpi_ns_get_attached_object (node);
        entry_type = acpi_ns_get_type ((acpi_handle) node);
 
        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Entry=%p Source_desc=%p Type=%X\n",
                 node, source_desc, entry_type));
 
-
        /*
         * Several object types require no further processing:
         * 1) Devices rarely have an attached object, return the Node
@@ -115,7 +114,6 @@ acpi_ex_resolve_node_to_value (
         * of the attached object or pointer
         */
        switch (entry_type) {
-
        case ACPI_TYPE_PACKAGE:
 
                if (ACPI_TYPE_PACKAGE != source_desc->common.type) {
@@ -187,7 +185,6 @@ acpi_ex_resolve_node_to_value (
                status = acpi_ex_read_data_from_field (source_desc, &obj_desc);
                break;
 
-
        /*
         * For these objects, just return the object attached to the Node
         */
@@ -214,7 +211,6 @@ acpi_ex_resolve_node_to_value (
                        node));
 
                return_ACPI_STATUS (AE_AML_OPERAND_TYPE);  /* Cannot be AE_TYPE */
-               break;
 
 
        /*
index fe430310a59fff2fe424a94f01a7fe721b394620..0c843609ac429fab5f7b3cd3782cf2f81f606dba 100644 (file)
@@ -2,12 +2,12 @@
 /******************************************************************************
  *
  * Module Name: exresolv - AML Interpreter object resolution
- *              $Revision: 101 $
+ *              $Revision: 106 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 
 
 #define _COMPONENT          ACPI_EXECUTER
-        MODULE_NAME         ("exresolv")
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ex_get_buffer_field_value
- *
- * PARAMETERS:  *Obj_desc           - Pointer to a Buffer_field
- *              *Result_desc        - Pointer to an empty descriptor which will
- *                                    become an Integer with the field's value
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Retrieve the value from a Buffer_field
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ex_get_buffer_field_value (
-       acpi_operand_object     *obj_desc,
-       acpi_operand_object     *result_desc)
-{
-       acpi_status             status;
-       u32                     mask;
-       u8                      *location;
-
-
-       FUNCTION_TRACE ("Ex_get_buffer_field_value");
-
-
-       /*
-        * Parameter validation
-        */
-       if (!obj_desc) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null field pointer\n"));
-               return_ACPI_STATUS (AE_AML_NO_OPERAND);
-       }
-
-       if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) {
-               status = acpi_ds_get_buffer_field_arguments (obj_desc);
-               if (ACPI_FAILURE (status)) {
-                       return_ACPI_STATUS (status);
-               }
-       }
-
-       if (!obj_desc->buffer_field.buffer_obj) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null container pointer\n"));
-               return_ACPI_STATUS (AE_AML_INTERNAL);
-       }
-
-       if (ACPI_TYPE_BUFFER != obj_desc->buffer_field.buffer_obj->common.type) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - container is not a Buffer\n"));
-               return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
-       }
-
-       if (!result_desc) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null result pointer\n"));
-               return_ACPI_STATUS (AE_AML_INTERNAL);
-       }
-
-
-       /* Field location is (base of buffer) + (byte offset) */
-
-       location = obj_desc->buffer_field.buffer_obj->buffer.pointer
-                        + obj_desc->buffer_field.base_byte_offset;
-
-       /*
-        * Construct Mask with as many 1 bits as the field width
-        *
-        * NOTE: Only the bottom 5 bits are valid for a shift operation, so
-        *  special care must be taken for any shift greater than 31 bits.
-        *
-        * TBD: [Unhandled] Fields greater than 32 bits will not work.
-        */
-       if (obj_desc->buffer_field.bit_length < 32) {
-               mask = ((u32) 1 << obj_desc->buffer_field.bit_length) - (u32) 1;
-       }
-       else {
-               mask = ACPI_UINT32_MAX;
-       }
-
-       result_desc->integer.type = (u8) ACPI_TYPE_INTEGER;
-
-       /* Get the 32 bit value at the location */
-
-       MOVE_UNALIGNED32_TO_32 (&result_desc->integer.value, location);
-
-       /*
-        * Shift the 32-bit word containing the field, and mask off the
-        * resulting value
-        */
-       result_desc->integer.value =
-               (result_desc->integer.value >> obj_desc->buffer_field.start_field_bit_offset) & mask;
-
-       ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-               "** Read from buffer %p byte %d bit %d width %d addr %p mask %08X val %8.8X%8.8X\n",
-               obj_desc->buffer_field.buffer_obj->buffer.pointer,
-               obj_desc->buffer_field.base_byte_offset,
-               obj_desc->buffer_field.start_field_bit_offset,
-               obj_desc->buffer_field.bit_length,
-               location, mask,
-               HIDWORD(result_desc->integer.value),
-               LODWORD(result_desc->integer.value)));
-
-       return_ACPI_STATUS (AE_OK);
-}
+        ACPI_MODULE_NAME    ("exresolv")
 
 
 /*******************************************************************************
@@ -167,7 +62,7 @@ acpi_ex_resolve_to_value (
        acpi_status             status;
 
 
-       FUNCTION_TRACE_PTR ("Ex_resolve_to_value", stack_ptr);
+       ACPI_FUNCTION_TRACE_PTR ("Ex_resolve_to_value", stack_ptr);
 
 
        if (!stack_ptr || !*stack_ptr) {
@@ -175,13 +70,12 @@ acpi_ex_resolve_to_value (
                return_ACPI_STATUS (AE_AML_NO_OPERAND);
        }
 
-
        /*
         * The entity pointed to by the Stack_ptr can be either
         * 1) A valid acpi_operand_object, or
         * 2) A acpi_namespace_node (Named_obj)
         */
-       if (VALID_DESCRIPTOR_TYPE (*stack_ptr, ACPI_DESC_TYPE_INTERNAL)) {
+       if (ACPI_GET_DESCRIPTOR_TYPE (*stack_ptr) == ACPI_DESC_TYPE_INTERNAL) {
                status = acpi_ex_resolve_object_to_value (stack_ptr, walk_state);
                if (ACPI_FAILURE (status)) {
                        return_ACPI_STATUS (status);
@@ -192,7 +86,7 @@ acpi_ex_resolve_to_value (
         * Object on the stack may have changed if Acpi_ex_resolve_object_to_value()
         * was called (i.e., we can't use an _else_ here.)
         */
-       if (VALID_DESCRIPTOR_TYPE (*stack_ptr, ACPI_DESC_TYPE_NAMED)) {
+       if (ACPI_GET_DESCRIPTOR_TYPE (*stack_ptr) == ACPI_DESC_TYPE_NAMED) {
                status = acpi_ex_resolve_node_to_value ((acpi_namespace_node **) stack_ptr,
                                  walk_state);
                if (ACPI_FAILURE (status)) {
@@ -200,7 +94,6 @@ acpi_ex_resolve_to_value (
                }
        }
 
-
        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Resolved object %p\n", *stack_ptr));
        return_ACPI_STATUS (AE_OK);
 }
@@ -233,7 +126,7 @@ acpi_ex_resolve_object_to_value (
        u16                     opcode;
 
 
-       FUNCTION_TRACE ("Ex_resolve_object_to_value");
+       ACPI_FUNCTION_TRACE ("Ex_resolve_object_to_value");
 
 
        stack_desc = *stack_ptr;
@@ -241,13 +134,11 @@ acpi_ex_resolve_object_to_value (
        /* This is an acpi_operand_object  */
 
        switch (stack_desc->common.type) {
-
        case INTERNAL_TYPE_REFERENCE:
 
                opcode = stack_desc->reference.opcode;
 
                switch (opcode) {
-
                case AML_NAME_OP:
 
                        /*
@@ -290,7 +181,6 @@ acpi_ex_resolve_object_to_value (
                                stack_desc->reference.offset, obj_desc));
                        break;
 
-
                /*
                 * For constants, we must change the reference/constant object
                 * to a real integer object
@@ -359,7 +249,6 @@ acpi_ex_resolve_object_to_value (
                                        acpi_ut_add_reference (obj_desc);
                                        *stack_ptr = obj_desc;
                                }
-
                                else {
                                        /*
                                         * A NULL object descriptor means an unitialized element of
@@ -381,7 +270,6 @@ acpi_ex_resolve_object_to_value (
                                status = AE_AML_INTERNAL;
                                break;
                        }
-
                        break;
 
 
@@ -402,51 +290,24 @@ acpi_ex_resolve_object_to_value (
 
                break; /* case INTERNAL_TYPE_REFERENCE */
 
-
+       /*
+        * These cases may never happen here, but just in case..
+        */
        case ACPI_TYPE_BUFFER_FIELD:
-
-               obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_ANY);
-               if (!obj_desc) {
-                       return_ACPI_STATUS (AE_NO_MEMORY);
-               }
-
-               status = acpi_ex_get_buffer_field_value (stack_desc, obj_desc);
-               if (ACPI_FAILURE (status)) {
-                       acpi_ut_remove_reference (obj_desc);
-                       obj_desc = NULL;
-               }
-
-               *stack_ptr = (void *) obj_desc;
-               break;
-
-
+       case INTERNAL_TYPE_REGION_FIELD:
        case INTERNAL_TYPE_BANK_FIELD:
+       case INTERNAL_TYPE_INDEX_FIELD:
 
-               obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_ANY);
-               if (!obj_desc) {
-                       return_ACPI_STATUS (AE_NO_MEMORY);
-               }
-
-               /* TBD: WRONG! */
-
-               status = acpi_ex_get_buffer_field_value (stack_desc, obj_desc);
-               if (ACPI_FAILURE (status)) {
-                       acpi_ut_remove_reference (obj_desc);
-                       obj_desc = NULL;
-               }
+               ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Field_read Source_desc=%p Type=%X\n",
+                       stack_desc, stack_desc->common.type));
 
+               status = acpi_ex_read_data_from_field (stack_desc, &obj_desc);
                *stack_ptr = (void *) obj_desc;
                break;
 
-
-       /* TBD: [Future] - may need to handle Index_field, and Def_field someday */
-
        default:
-
                break;
-
-       }   /* switch (Stack_desc->Common.Type) */
-
+       }
 
        return_ACPI_STATUS (status);
 }
index 5917b4f9b470249c4bc74fc23fcf70db550bbab6..2ca39ae58d61a63a646ab78e163af83e2ccc18e4 100644 (file)
@@ -2,12 +2,12 @@
 /******************************************************************************
  *
  * Module Name: exresop - AML Interpreter operand/object resolution
- *              $Revision: 41 $
+ *              $Revision: 47 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -36,7 +36,7 @@
 
 
 #define _COMPONENT          ACPI_EXECUTER
-        MODULE_NAME         ("exresop")
+        ACPI_MODULE_NAME    ("exresop")
 
 
 /*******************************************************************************
@@ -59,7 +59,7 @@ acpi_ex_check_object_type (
        acpi_object_type        this_type,
        void                    *object)
 {
-       PROC_NAME ("Ex_check_object_type");
+       ACPI_FUNCTION_NAME ("Ex_check_object_type");
 
 
        if (type_needed == ACPI_TYPE_ANY) {
@@ -85,18 +85,21 @@ acpi_ex_check_object_type (
  *
  * FUNCTION:    Acpi_ex_resolve_operands
  *
- * PARAMETERS:  Opcode              Opcode being interpreted
- *              Stack_ptr           Top of operand stack
+ * PARAMETERS:  Opcode              - Opcode being interpreted
+ *              Stack_ptr           - Pointer to the operand stack to be
+ *                                    resolved
+ *              Walk_state          - Current stateu
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Convert stack entries to required types
+ * DESCRIPTION: Convert multiple input operands to the types required by the
+ *              target operator.
  *
- *      Each nibble in Arg_types represents one required operand
- *      and indicates the required Type:
+ *      Each nibble (actually 5 bits)  in Arg_types represents one required
+ *      operand and indicates the required Type:
  *
- *      The corresponding stack entry will be converted to the
- *      required type if possible, else return an exception
+ *      The corresponding operand will be converted to the required type if
+ *      possible, otherwise we abort with an exception.
  *
  ******************************************************************************/
 
@@ -116,7 +119,7 @@ acpi_ex_resolve_operands (
        acpi_object_type        type_needed;
 
 
-       FUNCTION_TRACE_U32 ("Ex_resolve_operands", opcode);
+       ACPI_FUNCTION_TRACE_U32 ("Ex_resolve_operands", opcode);
 
 
        op_info = acpi_ps_get_opcode_info (opcode);
@@ -124,7 +127,6 @@ acpi_ex_resolve_operands (
                return_ACPI_STATUS (AE_AML_BAD_OPCODE);
        }
 
-
        arg_types = op_info->runtime_args;
        if (arg_types == ARGI_INVALID_OPCODE) {
                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - %X is not a valid AML opcode\n",
@@ -136,7 +138,6 @@ acpi_ex_resolve_operands (
        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode %X Operand_types=%X \n",
                opcode, arg_types));
 
-
        /*
         * Normal exit is with (Arg_types == 0) at end of argument list.
         * Function will return an exception from within the loop upon
@@ -158,13 +159,17 @@ acpi_ex_resolve_operands (
 
                /* Decode the descriptor type */
 
-               if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_NAMED)) {
+               switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) {
+               case ACPI_DESC_TYPE_NAMED:
+
                        /* Node */
 
                        object_type = ((acpi_namespace_node *) obj_desc)->type;
-               }
+                       break;
+
+
+               case ACPI_DESC_TYPE_INTERNAL:
 
-               else if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_INTERNAL)) {
                        /* ACPI internal object */
 
                        object_type = obj_desc->common.type;
@@ -187,7 +192,6 @@ acpi_ex_resolve_operands (
                                        return_ACPI_STATUS (AE_AML_BAD_OPCODE);
                                }
 
-
                                switch (obj_desc->reference.opcode) {
                                case AML_ZERO_OP:
                                case AML_ONE_OP:
@@ -199,27 +203,28 @@ acpi_ex_resolve_operands (
                                case AML_LOCAL_OP:
                                case AML_REVISION_OP:
 
-                                       DEBUG_ONLY_MEMBERS (ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+                                       ACPI_DEBUG_ONLY_MEMBERS (ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
                                                "Reference Opcode: %s\n", op_info->name)));
                                        break;
 
                                default:
-                                       ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+                                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
                                                "Reference Opcode: Unknown [%02x]\n",
                                                obj_desc->reference.opcode));
 
                                        return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
-                                       break;
                                }
                        }
-               }
+                       break;
+
+
+               default:
 
-               else {
                        /* Invalid descriptor */
 
                        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
                                "Bad descriptor type %X in Obj %p\n",
-                               obj_desc->common.data_type, obj_desc));
+                               ACPI_GET_DESCRIPTOR_TYPE (obj_desc), obj_desc));
 
                        return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
                }
@@ -231,24 +236,35 @@ acpi_ex_resolve_operands (
                this_arg_type = GET_CURRENT_ARG_TYPE (arg_types);
                INCREMENT_ARG_LIST (arg_types);
 
-
                /*
                 * Handle cases where the object does not need to be
                 * resolved to a value
                 */
                switch (this_arg_type) {
+               case ARGI_REF_OR_STRING:        /* Can be a String or Reference */
+
+                       if ((ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_INTERNAL) &&
+                               (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_STRING)) {
+                               /*
+                                * String found - the string references a named object and must be
+                                * resolved to a node
+                                */
+                               goto next_operand;
+                       }
 
-               case ARGI_REFERENCE:            /* References */
+                       /* Else not a string - fall through to the normal Reference case below */
+
+               case ARGI_REFERENCE:            /* References: */
                case ARGI_INTEGER_REF:
                case ARGI_OBJECT_REF:
                case ARGI_DEVICE_REF:
-               case ARGI_TARGETREF:            /* TBD: must implement implicit conversion rules before store */
+               case ARGI_TARGETREF:            /* Allows implicit conversion rules before store */
                case ARGI_FIXED_TARGET:         /* No implicit conversion before store to target */
-               case ARGI_SIMPLE_TARGET:        /* Name, Local, or Arg - no implicit conversion */
+               case ARGI_SIMPLE_TARGET:        /* Name, Local, or Arg - no implicit conversion  */
 
                        /* Need an operand of type INTERNAL_TYPE_REFERENCE */
 
-                       if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_NAMED))            /* direct name ptr OK as-is */ {
+                       if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) /* Node (name) ptr OK as-is */ {
                                goto next_operand;
                        }
 
@@ -258,7 +274,6 @@ acpi_ex_resolve_operands (
                                return_ACPI_STATUS (status);
                        }
 
-
                        if (AML_NAME_OP == obj_desc->reference.opcode) {
                                /*
                                 * Convert an indirect name ptr to direct name ptr and put
@@ -268,9 +283,7 @@ acpi_ex_resolve_operands (
                                acpi_ut_remove_reference (obj_desc);
                                (*stack_ptr) = temp_node;
                        }
-
                        goto next_operand;
-                       break;
 
 
                case ARGI_ANYTYPE:
@@ -298,7 +311,6 @@ acpi_ex_resolve_operands (
                        return_ACPI_STATUS (status);
                }
 
-
                /*
                 * Check the resulting object (value) type
                 */
@@ -362,7 +374,7 @@ acpi_ex_resolve_operands (
                        status = acpi_ex_convert_to_integer (*stack_ptr, stack_ptr, walk_state);
                        if (ACPI_FAILURE (status)) {
                                if (status == AE_TYPE) {
-                                       ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+                                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
                                                "Needed [Integer/String/Buffer], found [%s] %p\n",
                                                acpi_ut_get_type_name ((*stack_ptr)->common.type), *stack_ptr));
 
@@ -371,9 +383,7 @@ acpi_ex_resolve_operands (
 
                                return_ACPI_STATUS (status);
                        }
-
                        goto next_operand;
-                       break;
 
 
                case ARGI_BUFFER:
@@ -385,7 +395,7 @@ acpi_ex_resolve_operands (
                        status = acpi_ex_convert_to_buffer (*stack_ptr, stack_ptr, walk_state);
                        if (ACPI_FAILURE (status)) {
                                if (status == AE_TYPE) {
-                                       ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+                                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
                                                "Needed [Integer/String/Buffer], found [%s] %p\n",
                                                acpi_ut_get_type_name ((*stack_ptr)->common.type), *stack_ptr));
 
@@ -394,9 +404,7 @@ acpi_ex_resolve_operands (
 
                                return_ACPI_STATUS (status);
                        }
-
                        goto next_operand;
-                       break;
 
 
                case ARGI_STRING:
@@ -408,7 +416,7 @@ acpi_ex_resolve_operands (
                        status = acpi_ex_convert_to_string (*stack_ptr, stack_ptr, 16, ACPI_UINT32_MAX, walk_state);
                        if (ACPI_FAILURE (status)) {
                                if (status == AE_TYPE) {
-                                       ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+                                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
                                                "Needed [Integer/String/Buffer], found [%s] %p\n",
                                                acpi_ut_get_type_name ((*stack_ptr)->common.type), *stack_ptr));
 
@@ -417,82 +425,109 @@ acpi_ex_resolve_operands (
 
                                return_ACPI_STATUS (status);
                        }
-
                        goto next_operand;
-                       break;
 
 
                case ARGI_COMPUTEDATA:
 
                        /* Need an operand of type INTEGER, STRING or BUFFER */
 
-                       if ((ACPI_TYPE_INTEGER != (*stack_ptr)->common.type) &&
-                               (ACPI_TYPE_STRING != (*stack_ptr)->common.type) &&
-                               (ACPI_TYPE_BUFFER != (*stack_ptr)->common.type)) {
-                               ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+                       switch ((*stack_ptr)->common.type) {
+                       case ACPI_TYPE_INTEGER:
+                       case ACPI_TYPE_STRING:
+                       case ACPI_TYPE_BUFFER:
+
+                               /* Valid operand */
+                          break;
+
+                       default:
+                               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
                                        "Needed [Integer/String/Buffer], found [%s] %p\n",
                                        acpi_ut_get_type_name ((*stack_ptr)->common.type), *stack_ptr));
 
                                return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
                        }
                        goto next_operand;
-                       break;
 
 
                case ARGI_DATAOBJECT:
                        /*
                         * ARGI_DATAOBJECT is only used by the Size_of operator.
+                        * Need a buffer, string, package, or Node reference.
                         *
-                        * The ACPI specification allows Size_of to return the size of
-                        *  a Buffer, String or Package.  However, the MS ACPI.SYS AML
-                        *  Interpreter also allows an Node reference to return without
-                        *  error with a size of 4.
-                        */
-
-                       /* Need a buffer, string, package or Node reference */
-
-                       if (((*stack_ptr)->common.type != ACPI_TYPE_BUFFER) &&
-                               ((*stack_ptr)->common.type != ACPI_TYPE_STRING) &&
-                               ((*stack_ptr)->common.type != ACPI_TYPE_PACKAGE) &&
-                               ((*stack_ptr)->common.type != INTERNAL_TYPE_REFERENCE)) {
-                               ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-                                       "Needed [Buf/Str/Pkg/Ref], found [%s] %p\n",
-                                       acpi_ut_get_type_name ((*stack_ptr)->common.type), *stack_ptr));
-
-                               return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
-                       }
-
-                       /*
-                        * If this is a reference, only allow a reference to an Node.
+                        * The only reference allowed here is a direct reference to
+                        * a namespace node.
                         */
                        if ((*stack_ptr)->common.type == INTERNAL_TYPE_REFERENCE) {
                                if (!(*stack_ptr)->reference.node) {
-                                       ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+                                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
                                                "Needed [Node Reference], found [%p]\n",
                                                *stack_ptr));
 
                                        return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
                                }
+
+                               /* Get the object attached to the node */
+
+                               temp_node = acpi_ns_get_attached_object ((*stack_ptr)->reference.node);
+                               if (!temp_node) {
+                                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+                                               "Node [%p] has no attached object\n",
+                                               (*stack_ptr)->reference.node));
+
+                                       return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+                               }
+
+                               /*
+                                * Swap the reference object with the node's object.  Must add
+                                * a reference to the node object, and remove a reference from
+                                * the original reference object.
+                                */
+                               acpi_ut_add_reference (temp_node);
+                               acpi_ut_remove_reference (*stack_ptr);
+                               (*stack_ptr) = temp_node;
+                       }
+
+                       /* Need a buffer, string, package */
+
+                       switch ((*stack_ptr)->common.type) {
+                       case ACPI_TYPE_PACKAGE:
+                       case ACPI_TYPE_STRING:
+                       case ACPI_TYPE_BUFFER:
+
+                               /* Valid operand */
+                               break;
+
+                       default:
+                               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+                                       "Needed [Buf/Str/Pkg], found [%s] %p\n",
+                                       acpi_ut_get_type_name ((*stack_ptr)->common.type), *stack_ptr));
+
+                               return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
                        }
                        goto next_operand;
-                       break;
 
 
                case ARGI_COMPLEXOBJ:
 
                        /* Need a buffer or package or (ACPI 2.0) String */
 
-                       if (((*stack_ptr)->common.type != ACPI_TYPE_BUFFER) &&
-                               ((*stack_ptr)->common.type != ACPI_TYPE_STRING) &&
-                               ((*stack_ptr)->common.type != ACPI_TYPE_PACKAGE)) {
-                               ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-                                       "Needed [Buf/Pkg], found [%s] %p\n",
+                       switch ((*stack_ptr)->common.type) {
+                       case ACPI_TYPE_PACKAGE:
+                       case ACPI_TYPE_STRING:
+                       case ACPI_TYPE_BUFFER:
+
+                               /* Valid operand */
+                               break;
+
+                       default:
+                               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+                                       "Needed [Buf/Str/Pkg], found [%s] %p\n",
                                        acpi_ut_get_type_name ((*stack_ptr)->common.type), *stack_ptr));
 
                                return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
                        }
                        goto next_operand;
-                       break;
 
 
                default:
@@ -506,7 +541,6 @@ acpi_ex_resolve_operands (
                        return_ACPI_STATUS (AE_BAD_PARAMETER);
                }
 
-
                /*
                 * Make sure that the original object was resolved to the
                 * required object type (Simple cases only).
@@ -517,7 +551,6 @@ acpi_ex_resolve_operands (
                        return_ACPI_STATUS (status);
                }
 
-
 next_operand:
                /*
                 * If more operands needed, decrement Stack_ptr to point
@@ -529,7 +562,6 @@ next_operand:
 
        }   /* while (*Types) */
 
-
        return_ACPI_STATUS (status);
 }
 
index de9e2e4781b7dfeb25e4105237ba10a7a5b0b7e0..52ef045d25377fa63dbb1c736e3bbb0b5a1fc5af 100644 (file)
@@ -2,12 +2,12 @@
 /******************************************************************************
  *
  * Module Name: exstore - AML Interpreter object store support
- *              $Revision: 150 $
+ *              $Revision: 162 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -35,7 +35,7 @@
 
 
 #define _COMPONENT          ACPI_EXECUTER
-        MODULE_NAME         ("exstore")
+        ACPI_MODULE_NAME    ("exstore")
 
 
 /*******************************************************************************
  *              *Dest_desc          - Where to store it.  Must be an NS node
  *                                    or an acpi_operand_object of type
  *                                    Reference;
+ *              Walk_state          - Current walk state
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Store the value described by Source_desc into the location
  *              described by Dest_desc. Called by various interpreter
  *              functions to store the result of an operation into
- *              the destination operand.
+ *              the destination operand -- not just simply the actual "Store"
+ *              ASL operator.
  *
  ******************************************************************************/
 
@@ -66,19 +68,19 @@ acpi_ex_store (
        acpi_operand_object     *ref_desc = dest_desc;
 
 
-       FUNCTION_TRACE_PTR ("Ex_store", dest_desc);
+       ACPI_FUNCTION_TRACE_PTR ("Ex_store", dest_desc);
 
 
        /* Validate parameters */
 
        if (!source_desc || !dest_desc) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null pointer\n"));
+               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null parameter\n"));
                return_ACPI_STATUS (AE_AML_NO_OPERAND);
        }
 
        /* Dest_desc can be either a namespace node or an ACPI object */
 
-       if (VALID_DESCRIPTOR_TYPE (dest_desc, ACPI_DESC_TYPE_NAMED)) {
+       if (ACPI_GET_DESCRIPTOR_TYPE (dest_desc) == ACPI_DESC_TYPE_NAMED) {
                /*
                 * Dest is a namespace node,
                 * Storing an object into a Name "container"
@@ -86,12 +88,9 @@ acpi_ex_store (
                status = acpi_ex_store_object_to_node (source_desc,
                                 (acpi_namespace_node *) dest_desc, walk_state);
 
-               /* All done, that's it */
-
                return_ACPI_STATUS (status);
        }
 
-
        /* Destination object must be an object of type Reference */
 
        if (dest_desc->common.type != INTERNAL_TYPE_REFERENCE) {
@@ -100,15 +99,14 @@ acpi_ex_store (
                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
                        "Destination is not a Reference_obj [%p]\n", dest_desc));
 
-               DUMP_STACK_ENTRY (source_desc);
-               DUMP_STACK_ENTRY (dest_desc);
-               DUMP_OPERANDS (&dest_desc, IMODE_EXECUTE, "Ex_store",
+               ACPI_DUMP_STACK_ENTRY (source_desc);
+               ACPI_DUMP_STACK_ENTRY (dest_desc);
+               ACPI_DUMP_OPERANDS (&dest_desc, ACPI_IMODE_EXECUTE, "Ex_store",
                                  2, "Target is not a Reference_obj");
 
                return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
        }
 
-
        /*
         * Examine the Reference opcode.  These cases are handled:
         *
@@ -119,7 +117,6 @@ acpi_ex_store (
         * 5) Store to a constant -- a noop
         */
        switch (ref_desc->reference.opcode) {
-
        case AML_NAME_OP:
 
                /* Storing an object into a Name "container" */
@@ -161,15 +158,16 @@ acpi_ex_store (
                switch (source_desc->common.type) {
                case ACPI_TYPE_INTEGER:
 
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%X (%d)\n",
-                               (u32) source_desc->integer.value, (u32) source_desc->integer.value));
+                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%8.8X%8.8X\n",
+                                       ACPI_HIWORD (source_desc->integer.value),
+                                       ACPI_LOWORD (source_desc->integer.value)));
                        break;
 
 
                case ACPI_TYPE_BUFFER:
 
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length 0x%X\n",
-                               (u32) source_desc->buffer.length));
+                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length %.2X\n",
+                                       (u32) source_desc->buffer.length));
                        break;
 
 
@@ -181,14 +179,15 @@ acpi_ex_store (
 
                case ACPI_TYPE_PACKAGE:
 
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Elements - 0x%X\n",
-                               (u32) source_desc->package.elements));
+                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Elements Ptr - %p\n",
+                                       source_desc->package.elements));
                        break;
 
 
                default:
 
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "@0x%p\n", source_desc));
+                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Type %s %p\n",
+                                       acpi_ut_get_type_name (source_desc->common.type), source_desc));
                        break;
                }
 
@@ -202,27 +201,23 @@ acpi_ex_store (
        case AML_REVISION_OP:
 
                /*
-                * Storing to a constant is a no-op -- see ACPI Specification
-                * Delete the reference descriptor, however
+                * Storing to a constant is a no-op according to the  ACPI
+                * Specification. (Delete the reference descriptor, however.)
                 */
                break;
 
 
        default:
 
-               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - Unknown Reference subtype %02x\n",
+               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Reference subtype %02x\n",
                        ref_desc->reference.opcode));
-
-               /* TBD: [Restructure] use object dump routine !! */
-
-               DUMP_BUFFER (ref_desc, sizeof (acpi_operand_object));
+               ACPI_DUMP_ENTRY (ref_desc, ACPI_LV_ERROR);
 
                status = AE_AML_INTERNAL;
                break;
 
        }   /* switch (Ref_desc->Reference.Opcode) */
 
-
        return_ACPI_STATUS (status);
 }
 
@@ -231,36 +226,36 @@ acpi_ex_store (
  *
  * FUNCTION:    Acpi_ex_store_object_to_index
  *
- * PARAMETERS:  *Source_desc          - Value to be stored
- *              *Node               - Named object to receive the value
+ * PARAMETERS:  *Source_desc            - Value to be stored
+ *              *Dest_desc              - Named object to receive the value
+ *              Walk_state              - Current walk state
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Store the object to the named object.
+ * DESCRIPTION: Store the object to indexed Buffer or Package element
  *
  ******************************************************************************/
 
 acpi_status
 acpi_ex_store_object_to_index (
        acpi_operand_object     *source_desc,
-       acpi_operand_object     *dest_desc,
+       acpi_operand_object     *index_desc,
        acpi_walk_state         *walk_state)
 {
        acpi_status             status = AE_OK;
        acpi_operand_object     *obj_desc;
-       u32                     length;
-       u32                     i;
+       acpi_operand_object     *new_desc;
        u8                      value = 0;
 
 
-       FUNCTION_TRACE ("Ex_store_object_to_index");
+       ACPI_FUNCTION_TRACE ("Ex_store_object_to_index");
 
 
        /*
         * Destination must be a reference pointer, and
         * must point to either a buffer or a package
         */
-       switch (dest_desc->reference.target_type) {
+       switch (index_desc->reference.target_type) {
        case ACPI_TYPE_PACKAGE:
                /*
                 * Storing to a package element is not simple.  The source must be
@@ -268,95 +263,48 @@ acpi_ex_store_object_to_index (
                 * source is copied into the destination - we can't just point to the
                 * source object.
                 */
-               if (dest_desc->reference.target_type == ACPI_TYPE_PACKAGE) {
-                       /*
-                        * The object at *(Dest_desc->Reference.Where) is the
-                        * element within the package that is to be modified.
-                        */
-                       obj_desc = *(dest_desc->reference.where);
-                       if (obj_desc) {
-                               /*
-                                * If the Destination element is a package, we will delete
-                                *  that object and construct a new one.
-                                *
-                                * TBD: [Investigate] Should both the src and dest be required
-                                *      to be packages?
-                                *       && (Source_desc->Common.Type == ACPI_TYPE_PACKAGE)
-                                */
-                               if (obj_desc->common.type == ACPI_TYPE_PACKAGE) {
-                                       /* Take away the reference for being part of a package */
-
-                                       acpi_ut_remove_reference (obj_desc);
-                                       obj_desc = NULL;
-                               }
-                       }
-
-                       if (!obj_desc) {
-                               /*
-                                * If the Obj_desc is NULL, it means that an uninitialized package
-                                * element has been used as a destination (this is OK), therefore,
-                                * we must create the destination element to match the type of the
-                                * source element NOTE: Source_desccan be of any type.
-                                */
-                               obj_desc = acpi_ut_create_internal_object (source_desc->common.type);
-                               if (!obj_desc) {
-                                       return_ACPI_STATUS (AE_NO_MEMORY);
-                               }
-
-                               /*
-                                * If the source is a package, copy the source to the new dest
-                                */
-                               if (ACPI_TYPE_PACKAGE == obj_desc->common.type) {
-                                       status = acpi_ut_copy_ipackage_to_ipackage (source_desc, obj_desc, walk_state);
-                                       if (ACPI_FAILURE (status)) {
-                                               acpi_ut_remove_reference (obj_desc);
-                                               return_ACPI_STATUS (status);
-                                       }
-                               }
-
-                               /* Install the new descriptor into the package */
-
-                               *(dest_desc->reference.where) = obj_desc;
-                       }
-
-                       if (ACPI_TYPE_PACKAGE != obj_desc->common.type) {
-                               /*
-                                * The destination element is not a package, so we need to
-                                * convert the contents of the source (Source_desc) and copy into
-                                * the destination (Obj_desc)
-                                */
-                               status = acpi_ex_store_object_to_object (source_desc, obj_desc,
-                                                 walk_state);
-                               if (ACPI_FAILURE (status)) {
-                                       /*
-                                        * An error occurrered when copying the internal object
-                                        * so delete the reference.
-                                        */
-                                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-                                               "Unable to copy the internal object\n"));
-                                       return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
-                               }
-                       }
+               /*
+                * The object at *(Index_desc->Reference.Where) is the
+                * element within the package that is to be modified.
+                */
+               obj_desc = *(index_desc->reference.where);
+
+               /* Do the conversion/store */
+
+               status = acpi_ex_store_object_to_object (source_desc, obj_desc, &new_desc,
+                                 walk_state);
+               if (ACPI_FAILURE (status)) {
+                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+                               "Could not store object to indexed package element\n"));
+                       return_ACPI_STATUS (status);
+               }
+
+               /*
+                * If a new object was created, we must install it as the new
+                * package element
+                */
+               if (new_desc != obj_desc) {
+                       acpi_ut_remove_reference (obj_desc);
+                       *(index_desc->reference.where) = new_desc;
                }
                break;
 
 
        case ACPI_TYPE_BUFFER_FIELD:
 
-
-               /* TBD: can probably call the generic Buffer/Field routines */
-
                /*
-                * Storing into a buffer at a location defined by an Index.
+                * Store into a Buffer (not actually a real Buffer_field) at a
+                * location defined by an Index.
                 *
-                * Each 8-bit element of the source object is written to the
-                * 8-bit Buffer Field of the Index destination object.
+                * The first 8-bit element of the source object is written to the
+                * 8-bit Buffer location defined by the Index destination object,
+                * according to the ACPI 2.0 specification.
                 */
 
                /*
-                * Set the Obj_desc to the destination object and type check.
+                * Make sure the target is a Buffer
                 */
-               obj_desc = dest_desc->reference.object;
+               obj_desc = index_desc->reference.object;
                if (obj_desc->common.type != ACPI_TYPE_BUFFER) {
                        return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
                }
@@ -367,65 +315,45 @@ acpi_ex_store_object_to_index (
                 */
                switch (source_desc->common.type) {
                case ACPI_TYPE_INTEGER:
-                       /*
-                        * Type is Integer, assign bytewise
-                        * This loop to assign each of the elements is somewhat
-                        * backward because of the Big Endian-ness of IA-64
-                        */
-                       length = sizeof (acpi_integer);
-                       for (i = length; i != 0; i--) {
-                               value = (u8)(source_desc->integer.value >> (MUL_8 (i - 1)));
-                               obj_desc->buffer.pointer[dest_desc->reference.offset] = value;
-                       }
-                       break;
 
+                       /* Use the least-significant byte of the integer */
 
-               case ACPI_TYPE_BUFFER:
-                       /*
-                        * Type is Buffer, the Length is in the structure.
-                        * Just loop through the elements and assign each one in turn.
-                        */
-                       length = source_desc->buffer.length;
-                       for (i = 0; i < length; i++) {
-                               value = source_desc->buffer.pointer[i];
-                               obj_desc->buffer.pointer[dest_desc->reference.offset] = value;
-                       }
+                       value = (u8) (source_desc->integer.value);
                        break;
 
+               case ACPI_TYPE_BUFFER:
 
-               case ACPI_TYPE_STRING:
-                       /*
-                        * Type is String, the Length is in the structure.
-                        * Just loop through the elements and assign each one in turn.
-                        */
-                       length = source_desc->string.length;
-                       for (i = 0; i < length; i++) {
-                               value = source_desc->string.pointer[i];
-                               obj_desc->buffer.pointer[dest_desc->reference.offset] = value;
-                       }
+                       value = source_desc->buffer.pointer[0];
                        break;
 
+               case ACPI_TYPE_STRING:
+
+                       value = source_desc->string.pointer[0];
+                       break;
 
                default:
 
-                       /* Other types are invalid */
+                       /* All other types are invalid */
 
                        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-                               "Source must be Number/Buffer/String type, not %X\n",
-                               source_desc->common.type));
-                       status = AE_AML_OPERAND_TYPE;
-                       break;
+                               "Source must be Integer/Buffer/String type, not %s\n",
+                               acpi_ut_get_type_name (source_desc->common.type)));
+                       return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
                }
+
+               /* Store the source value into the target buffer byte */
+
+               obj_desc->buffer.pointer[index_desc->reference.offset] = value;
                break;
 
 
        default:
-               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Target is not a Package or Buffer_field\n"));
+               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+                       "Target is not a Package or Buffer_field\n"));
                status = AE_AML_OPERAND_TYPE;
                break;
        }
 
-
        return_ACPI_STATUS (status);
 }
 
@@ -434,15 +362,16 @@ acpi_ex_store_object_to_index (
  *
  * FUNCTION:    Acpi_ex_store_object_to_node
  *
- * PARAMETERS:  *Source_desc           - Value to be stored
- *              *Node                  - Named object to receive the value
+ * PARAMETERS:  Source_desc             - Value to be stored
+ *              Node                    - Named object to receive the value
+ *              Walk_state              - Current walk state
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Store the object to the named object.
  *
  *              The Assignment of an object to a named object is handled here
- *              The val passed in will replace the current value (if any)
+ *              The value passed in will replace the current value (if any)
  *              with the input value.
  *
  *              When storing into an object the data is converted to the
@@ -450,10 +379,7 @@ acpi_ex_store_object_to_index (
  *              that the target object type (for an initialized target) will
  *              not be changed by a store operation.
  *
- *              NOTE: the global lock is acquired early.  This will result
- *              in the global lock being held a bit longer.  Also, if the
- *              function fails during set up we may get the lock when we
- *              don't really need it.  I don't think we care.
+ *              Assumes parameters are already validated.
  *
  ******************************************************************************/
 
@@ -465,16 +391,13 @@ acpi_ex_store_object_to_node (
 {
        acpi_status             status = AE_OK;
        acpi_operand_object     *target_desc;
-       acpi_object_type8       target_type = ACPI_TYPE_ANY;
+       acpi_operand_object     *new_desc;
+       acpi_object_type        target_type;
 
 
-       FUNCTION_TRACE ("Ex_store_object_to_node");
+       ACPI_FUNCTION_TRACE_PTR ("Ex_store_object_to_node", source_desc);
 
 
-       /*
-        * Assuming the parameters were already validated
-        */
-
        /*
         * Get current type of the node, and object attached to Node
         */
@@ -482,9 +405,8 @@ acpi_ex_store_object_to_node (
        target_desc = acpi_ns_get_attached_object (node);
 
        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Storing %p(%s) into node %p(%s)\n",
-               node, acpi_ut_get_type_name (source_desc->common.type),
-               source_desc, acpi_ut_get_type_name (target_type)));
-
+               source_desc, acpi_ut_get_type_name (source_desc->common.type),
+                         node, acpi_ut_get_type_name (target_type)));
 
        /*
         * Resolve the source object to an actual value
@@ -495,7 +417,6 @@ acpi_ex_store_object_to_node (
                return_ACPI_STATUS (status);
        }
 
-
        /*
         * Do the actual store operation
         */
@@ -522,22 +443,24 @@ acpi_ex_store_object_to_node (
                 *
                 * Copy and/or convert the source object to a new target object
                 */
-               status = acpi_ex_store_object (source_desc, target_type, &target_desc, walk_state);
+               status = acpi_ex_store_object_to_object (source_desc, target_desc, &new_desc, walk_state);
                if (ACPI_FAILURE (status)) {
                        return_ACPI_STATUS (status);
                }
 
-               /*
-                * Store the new Target_desc as the new value of the Name, and set
-                * the Name's type to that of the value being stored in it.
-                * Source_desc reference count is incremented by Attach_object.
-                */
-               status = acpi_ns_attach_object (node, target_desc, target_type);
+               if (new_desc != target_desc) {
+                       /*
+                        * Store the new New_desc as the new value of the Name, and set
+                        * the Name's type to that of the value being stored in it.
+                        * Source_desc reference count is incremented by Attach_object.
+                        */
+                       status = acpi_ns_attach_object (node, new_desc, target_type);
 
-               ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-                       "Store %s into %s via Convert/Attach\n",
-                       acpi_ut_get_type_name (target_desc->common.type),
-                       acpi_ut_get_type_name (target_type)));
+                       ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+                               "Store %s into %s via Convert/Attach\n",
+                               acpi_ut_get_type_name (source_desc->common.type),
+                               acpi_ut_get_type_name (new_desc->common.type)));
+               }
                break;
 
 
@@ -553,91 +476,7 @@ acpi_ex_store_object_to_node (
                break;
        }
 
-
        return_ACPI_STATUS (status);
 }
 
 
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ex_store_object_to_object
- *
- * PARAMETERS:  *Source_desc           - Value to be stored
- *              *Dest_desc          - Object to receive the value
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Store an object to another object.
- *
- *              The Assignment of an object to another (not named) object
- *              is handled here.
- *              The val passed in will replace the current value (if any)
- *              with the input value.
- *
- *              When storing into an object the data is converted to the
- *              target object type then stored in the object.  This means
- *              that the target object type (for an initialized target) will
- *              not be changed by a store operation.
- *
- *              This module allows destination types of Number, String,
- *              and Buffer.
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ex_store_object_to_object (
-       acpi_operand_object     *source_desc,
-       acpi_operand_object     *dest_desc,
-       acpi_walk_state         *walk_state)
-{
-       acpi_status             status = AE_OK;
-       acpi_object_type8       destination_type = dest_desc->common.type;
-
-
-       FUNCTION_TRACE ("Ex_store_object_to_object");
-
-
-       /*
-        *  Assuming the parameters are valid!
-        */
-       ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Storing %p(%s) to %p(%s)\n",
-                         source_desc, acpi_ut_get_type_name (source_desc->common.type),
-                         dest_desc, acpi_ut_get_type_name (dest_desc->common.type)));
-
-
-       /*
-        * From this interface, we only support Integers/Strings/Buffers
-        */
-       switch (destination_type) {
-       case ACPI_TYPE_INTEGER:
-       case ACPI_TYPE_STRING:
-       case ACPI_TYPE_BUFFER:
-               break;
-
-       default:
-               ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Store into %s not implemented\n",
-                       acpi_ut_get_type_name (dest_desc->common.type)));
-
-               return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
-       }
-
-
-       /*
-        * Resolve the source object to an actual value
-        * (If it is a reference object)
-        */
-       status = acpi_ex_resolve_object (&source_desc, destination_type, walk_state);
-       if (ACPI_FAILURE (status)) {
-               return_ACPI_STATUS (status);
-       }
-
-
-       /*
-        * Copy and/or convert the source object to the destination object
-        */
-       status = acpi_ex_store_object (source_desc, destination_type, &dest_desc, walk_state);
-
-
-       return_ACPI_STATUS (status);
-}
-
index 9c0e157c2c66ea60e3329395018e7dad6568a252..9f1eef0081b7f9894122d3bfe3ccbbc8f5c85ac8 100644 (file)
@@ -3,12 +3,12 @@
  *
  * Module Name: exstoren - AML Interpreter object store support,
  *                        Store to Node (namespace object)
- *              $Revision: 40 $
+ *              $Revision: 46 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -36,7 +36,7 @@
 
 
 #define _COMPONENT          ACPI_EXECUTER
-        MODULE_NAME         ("exstoren")
+        ACPI_MODULE_NAME    ("exstoren")
 
 
 /*******************************************************************************
 acpi_status
 acpi_ex_resolve_object (
        acpi_operand_object     **source_desc_ptr,
-       acpi_object_type8       target_type,
+       acpi_object_type        target_type,
        acpi_walk_state         *walk_state)
 {
        acpi_operand_object     *source_desc = *source_desc_ptr;
        acpi_status             status = AE_OK;
 
 
-       FUNCTION_TRACE ("Ex_resolve_object");
+       ACPI_FUNCTION_TRACE ("Ex_resolve_object");
 
 
        /*
-        * Ensure we have a Source that can be stored in the target
+        * Ensure we have a Target that can be stored to
         */
        switch (target_type) {
-
-       /* This case handles the "interchangeable" types Integer, String, and Buffer. */
-
-       /*
-        * These cases all require only Integers or values that
-        * can be converted to Integers (Strings or Buffers)
-        */
        case ACPI_TYPE_BUFFER_FIELD:
        case INTERNAL_TYPE_REGION_FIELD:
        case INTERNAL_TYPE_BANK_FIELD:
        case INTERNAL_TYPE_INDEX_FIELD:
+               /*
+                * These cases all require only Integers or values that
+                * can be converted to Integers (Strings or Buffers)
+                */
 
-       /*
-        * Stores into a Field/Region or into a Buffer/String
-        * are all essentially the same.
-        */
        case ACPI_TYPE_INTEGER:
        case ACPI_TYPE_STRING:
        case ACPI_TYPE_BUFFER:
 
+               /*
+                * Stores into a Field/Region or into a Integer/Buffer/String
+                * are all essentially the same.  This case handles the
+                * "interchangeable" types Integer, String, and Buffer.
+                */
+               if (source_desc->common.type == INTERNAL_TYPE_REFERENCE) {
+                       /* Resolve a reference object first */
 
-               /* TBD: FIX - check for source==REF, resolve, then check type */
+                       status = acpi_ex_resolve_to_value (source_desc_ptr, walk_state);
+                       if (ACPI_FAILURE (status)) {
+                               break;
+                       }
+               }
 
                /*
-                * If Source_desc is not a valid type, try to resolve it to one.
+                * Must have a Integer, Buffer, or String
                 */
                if ((source_desc->common.type != ACPI_TYPE_INTEGER)    &&
                        (source_desc->common.type != ACPI_TYPE_BUFFER)     &&
                        (source_desc->common.type != ACPI_TYPE_STRING)) {
                        /*
-                        * Initially not a valid type, convert
+                        * Conversion successful but still not a valid type
                         */
-                       status = acpi_ex_resolve_to_value (source_desc_ptr, walk_state);
-                       if (ACPI_SUCCESS (status) &&
-                               (source_desc->common.type != ACPI_TYPE_INTEGER)    &&
-                               (source_desc->common.type != ACPI_TYPE_BUFFER)     &&
-                               (source_desc->common.type != ACPI_TYPE_STRING)) {
-                               /*
-                                * Conversion successful but still not a valid type
-                                */
-                               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-                                       "Cannot assign type %s to %s (must be type Int/Str/Buf)\n",
-                                       acpi_ut_get_type_name ((*source_desc_ptr)->common.type),
-                                       acpi_ut_get_type_name (target_type)));
-                               status = AE_AML_OPERAND_TYPE;
-                       }
+                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+                               "Cannot assign type %s to %s (must be type Int/Str/Buf)\n",
+                               acpi_ut_get_type_name (source_desc->common.type),
+                               acpi_ut_get_type_name (target_type)));
+                       status = AE_AML_OPERAND_TYPE;
                }
                break;
 
@@ -147,11 +142,11 @@ acpi_ex_resolve_object (
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_store_object
+ * FUNCTION:    Acpi_ex_store_object_to_object
  *
  * PARAMETERS:  Source_desc         - Object to store
- *              Target_type         - Current type of the target
- *              Target_desc_ptr     - Pointer to the target
+ *              Dest_desc           - Object to recieve a copy of the source
+ *              New_desc            - New object if Dest_desc is obsoleted
  *              Walk_state          - Current walk state
  *
  * RETURN:      Status
@@ -161,93 +156,114 @@ acpi_ex_resolve_object (
  *              conversion), and a copy of the value of the source to
  *              the target.
  *
+ *              The Assignment of an object to another (not named) object
+ *              is handled here.
+ *              The Source passed in will replace the current value (if any)
+ *              with the input value.
+ *
+ *              When storing into an object the data is converted to the
+ *              target object type then stored in the object.  This means
+ *              that the target object type (for an initialized target) will
+ *              not be changed by a store operation.
+ *
+ *              This module allows destination types of Number, String,
+ *              Buffer, and Package.
+ *
+ *              Assumes parameters are already validated.  NOTE: Source_desc
+ *              resolution (from a reference object) must be performed by
+ *              the caller if necessary.
+ *
  ******************************************************************************/
 
 acpi_status
-acpi_ex_store_object (
+acpi_ex_store_object_to_object (
        acpi_operand_object     *source_desc,
-       acpi_object_type8       target_type,
-       acpi_operand_object     **target_desc_ptr,
+       acpi_operand_object     *dest_desc,
+       acpi_operand_object     **new_desc,
        acpi_walk_state         *walk_state)
 {
-       acpi_operand_object     *target_desc = *target_desc_ptr;
+       acpi_operand_object     *actual_src_desc;
        acpi_status             status = AE_OK;
 
 
-       FUNCTION_TRACE ("Ex_store_object");
+       ACPI_FUNCTION_TRACE_PTR ("Acpi_ex_store_object_to_object", source_desc);
 
 
-       /*
-        * Perform the "implicit conversion" of the source to the current type
-        * of the target - As per the ACPI specification.
-        *
-        * If no conversion performed, Source_desc is left alone, otherwise it
-        * is updated with a new object.
-        */
-       status = acpi_ex_convert_to_target_type (target_type, &source_desc, walk_state);
-       if (ACPI_FAILURE (status)) {
+       actual_src_desc = source_desc;
+       if (!dest_desc) {
+               /*
+                * There is no destination object (An uninitialized node or
+                * package element), so we can simply copy the source object
+                * creating a new destination object
+                */
+               status = acpi_ut_copy_iobject_to_iobject (actual_src_desc, new_desc, walk_state);
                return_ACPI_STATUS (status);
        }
 
+       if (source_desc->common.type != dest_desc->common.type) {
+               /*
+                * The source type does not match the type of the destination.
+                * Perform the "implicit conversion" of the source to the current type
+                * of the target as per the ACPI specification.
+                *
+                * If no conversion performed, Actual_src_desc = Source_desc.
+                * Otherwise, Actual_src_desc is a temporary object to hold the
+                * converted object.
+                */
+               status = acpi_ex_convert_to_target_type (dest_desc->common.type, source_desc,
+                                 &actual_src_desc, walk_state);
+               if (ACPI_FAILURE (status)) {
+                       return_ACPI_STATUS (status);
+               }
+       }
+
        /*
         * We now have two objects of identical types, and we can perform a
         * copy of the *value* of the source object.
         */
-       switch (target_type) {
-       case ACPI_TYPE_ANY:
-       case INTERNAL_TYPE_DEF_ANY:
-
-               /*
-                * The target namespace node is uninitialized (has no target object),
-                * and will take on the type of the source object
-                */
-               *target_desc_ptr = source_desc;
-               break;
-
-
+       switch (dest_desc->common.type) {
        case ACPI_TYPE_INTEGER:
 
-               target_desc->integer.value = source_desc->integer.value;
+               dest_desc->integer.value = actual_src_desc->integer.value;
 
                /* Truncate value if we are executing from a 32-bit ACPI table */
 
-               acpi_ex_truncate_for32bit_table (target_desc, walk_state);
+               acpi_ex_truncate_for32bit_table (dest_desc, walk_state);
                break;
 
        case ACPI_TYPE_STRING:
 
-               status = acpi_ex_copy_string_to_string (source_desc, target_desc);
+               status = acpi_ex_store_string_to_string (actual_src_desc, dest_desc);
                break;
 
-
        case ACPI_TYPE_BUFFER:
 
-               status = acpi_ex_copy_buffer_to_buffer (source_desc, target_desc);
+               status = acpi_ex_store_buffer_to_buffer (actual_src_desc, dest_desc);
                break;
 
-
        case ACPI_TYPE_PACKAGE:
 
-               /*
-                * TBD: [Unhandled] Not real sure what to do here
-                */
-               status = AE_NOT_IMPLEMENTED;
+               status = acpi_ut_copy_iobject_to_iobject (actual_src_desc, &dest_desc, walk_state);
                break;
 
-
        default:
-
                /*
                 * All other types come here.
                 */
                ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Store into type %s not implemented\n",
-                       acpi_ut_get_type_name (target_type)));
+                       acpi_ut_get_type_name (dest_desc->common.type)));
 
                status = AE_NOT_IMPLEMENTED;
                break;
        }
 
+       if (actual_src_desc != source_desc) {
+               /* Delete the intermediate (temporary) source object */
+
+               acpi_ut_remove_reference (actual_src_desc);
+       }
 
+       *new_desc = dest_desc;
        return_ACPI_STATUS (status);
 }
 
index 5a5c55605f210d44266f349900466525dfa5032b..8588b3e01ca3e948a96e8cafb1049ad5ff441ec1 100644 (file)
@@ -2,12 +2,12 @@
 /******************************************************************************
  *
  * Module Name: exstorob - AML Interpreter object store support, store to object
- *              $Revision: 37 $
+ *              $Revision: 41 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 
 
 #define _COMPONENT          ACPI_EXECUTER
-        MODULE_NAME         ("exstorob")
+        ACPI_MODULE_NAME    ("exstorob")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_copy_buffer_to_buffer
+ * FUNCTION:    Acpi_ex_store_buffer_to_buffer
  *
  * PARAMETERS:  Source_desc         - Source object to copy
  *              Target_desc         - Destination object of the copy
@@ -52,7 +52,7 @@
  ******************************************************************************/
 
 acpi_status
-acpi_ex_copy_buffer_to_buffer (
+acpi_ex_store_buffer_to_buffer (
        acpi_operand_object     *source_desc,
        acpi_operand_object     *target_desc)
 {
@@ -60,7 +60,7 @@ acpi_ex_copy_buffer_to_buffer (
        u8                      *buffer;
 
 
-       PROC_NAME ("Ex_copy_buffer_to_buffer");
+       ACPI_FUNCTION_NAME ("Ex_store_buffer_to_buffer");
 
 
        /*
@@ -89,15 +89,15 @@ acpi_ex_copy_buffer_to_buffer (
        if (length <= target_desc->buffer.length) {
                /* Clear existing buffer and copy in the new one */
 
-               MEMSET (target_desc->buffer.pointer, 0, target_desc->buffer.length);
-               MEMCPY (target_desc->buffer.pointer, buffer, length);
+               ACPI_MEMSET (target_desc->buffer.pointer, 0, target_desc->buffer.length);
+               ACPI_MEMCPY (target_desc->buffer.pointer, buffer, length);
        }
 
        else {
                /*
                 * Truncate the source, copy only what will fit
                 */
-               MEMCPY (target_desc->buffer.pointer, buffer, target_desc->buffer.length);
+               ACPI_MEMCPY (target_desc->buffer.pointer, buffer, target_desc->buffer.length);
 
                ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
                        "Truncating src buffer from %X to %X\n",
@@ -110,7 +110,7 @@ acpi_ex_copy_buffer_to_buffer (
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ex_copy_string_to_string
+ * FUNCTION:    Acpi_ex_store_string_to_string
  *
  * PARAMETERS:  Source_desc         - Source object to copy
  *              Target_desc         - Destination object of the copy
@@ -122,7 +122,7 @@ acpi_ex_copy_buffer_to_buffer (
  ******************************************************************************/
 
 acpi_status
-acpi_ex_copy_string_to_string (
+acpi_ex_store_string_to_string (
        acpi_operand_object     *source_desc,
        acpi_operand_object     *target_desc)
 {
@@ -130,7 +130,7 @@ acpi_ex_copy_string_to_string (
        u8                      *buffer;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        /*
@@ -145,8 +145,8 @@ acpi_ex_copy_string_to_string (
        if (length < target_desc->string.length) {
                /* Clear old string and copy in the new one */
 
-               MEMSET (target_desc->string.pointer, 0, target_desc->string.length);
-               MEMCPY (target_desc->string.pointer, buffer, length);
+               ACPI_MEMSET (target_desc->string.pointer, 0, target_desc->string.length);
+               ACPI_MEMCPY (target_desc->string.pointer, buffer, length);
        }
 
        else {
@@ -168,7 +168,7 @@ acpi_ex_copy_string_to_string (
                }
 
                target_desc->string.length = length;
-               MEMCPY (target_desc->string.pointer, buffer, length);
+               ACPI_MEMCPY (target_desc->string.pointer, buffer, length);
        }
 
        return (AE_OK);
index 10b504d122a543d586a97dbb7bc510f1651fc4a2..5789f4679680d644d15e589c3e5014f06a7166b5 100644 (file)
@@ -2,12 +2,12 @@
 /******************************************************************************
  *
  * Module Name: exsystem - Interface to OS services
- *              $Revision: 67 $
+ *              $Revision: 71 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -32,7 +32,7 @@
 #include "acevents.h"
 
 #define _COMPONENT          ACPI_EXECUTER
-        MODULE_NAME         ("exsystem")
+        ACPI_MODULE_NAME    ("exsystem")
 
 
 /*******************************************************************************
@@ -56,9 +56,10 @@ acpi_ex_system_wait_semaphore (
        u32                     timeout)
 {
        acpi_status             status;
+       acpi_status             status2;
 
 
-       FUNCTION_TRACE ("Ex_system_wait_semaphore");
+       ACPI_FUNCTION_TRACE ("Ex_system_wait_semaphore");
 
 
        status = acpi_os_wait_semaphore (semaphore, 1, 0);
@@ -78,11 +79,11 @@ acpi_ex_system_wait_semaphore (
 
                /* Reacquire the interpreter */
 
-               status = acpi_ex_enter_interpreter ();
-               if (ACPI_SUCCESS (status)) {
-                       /* Restore the timeout exception */
+               status2 = acpi_ex_enter_interpreter ();
+               if (ACPI_FAILURE (status2)) {
+                       /* Report fatal error, could not acquire interpreter */
 
-                       status = AE_TIME;
+                       return_ACPI_STATUS (status2);
                }
        }
 
@@ -96,17 +97,20 @@ acpi_ex_system_wait_semaphore (
  *
  * PARAMETERS:  How_long            - The amount of time to stall
  *
- * RETURN:      None
+ * RETURN:      Status
  *
  * DESCRIPTION: Suspend running thread for specified amount of time.
  *
  ******************************************************************************/
 
-void
+acpi_status
 acpi_ex_system_do_stall (
        u32                     how_long)
 {
-       FUNCTION_ENTRY ();
+       acpi_status             status = AE_OK;
+
+
+       ACPI_FUNCTION_ENTRY ();
 
 
        if (how_long > 1000) /* 1 millisecond */ {
@@ -118,12 +122,14 @@ acpi_ex_system_do_stall (
 
                /* And now we must get the interpreter again */
 
-               acpi_ex_enter_interpreter ();
+               status = acpi_ex_enter_interpreter ();
        }
 
        else {
                acpi_os_sleep (0, (how_long / 1000) + 1);
        }
+
+       return (status);
 }
 
 
@@ -139,12 +145,14 @@ acpi_ex_system_do_stall (
  *
  ******************************************************************************/
 
-void
+acpi_status
 acpi_ex_system_do_suspend (
        u32                     how_long)
 {
+       acpi_status             status;
 
-       FUNCTION_ENTRY ();
+
+       ACPI_FUNCTION_ENTRY ();
 
 
        /* Since this thread will sleep, we must release the interpreter */
@@ -156,7 +164,8 @@ acpi_ex_system_do_suspend (
 
        /* And now we must get the interpreter again */
 
-       acpi_ex_enter_interpreter ();
+       status = acpi_ex_enter_interpreter ();
+       return (status);
 }
 
 
@@ -183,7 +192,7 @@ acpi_ex_system_acquire_mutex (
        acpi_status             status = AE_OK;
 
 
-       FUNCTION_TRACE_PTR ("Ex_system_acquire_mutex", obj_desc);
+       ACPI_FUNCTION_TRACE_PTR ("Ex_system_acquire_mutex", obj_desc);
 
 
        if (!obj_desc) {
@@ -194,7 +203,7 @@ acpi_ex_system_acquire_mutex (
         * Support for the _GL_ Mutex object -- go get the global lock
         */
        if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) {
-               status = acpi_ev_acquire_global_lock ();
+               status = acpi_ev_acquire_global_lock ((u32) time_desc->integer.value);
                return_ACPI_STATUS (status);
        }
 
@@ -226,7 +235,7 @@ acpi_ex_system_release_mutex (
        acpi_status             status = AE_OK;
 
 
-       FUNCTION_TRACE ("Ex_system_release_mutex");
+       ACPI_FUNCTION_TRACE ("Ex_system_release_mutex");
 
 
        if (!obj_desc) {
@@ -266,7 +275,7 @@ acpi_ex_system_signal_event (
        acpi_status             status = AE_OK;
 
 
-       FUNCTION_TRACE ("Ex_system_signal_event");
+       ACPI_FUNCTION_TRACE ("Ex_system_signal_event");
 
 
        if (obj_desc) {
@@ -300,7 +309,7 @@ acpi_ex_system_wait_event (
        acpi_status             status = AE_OK;
 
 
-       FUNCTION_TRACE ("Ex_system_wait_event");
+       ACPI_FUNCTION_TRACE ("Ex_system_wait_event");
 
 
        if (obj_desc) {
@@ -308,7 +317,6 @@ acpi_ex_system_wait_event (
                                  (u32) time_desc->integer.value);
        }
 
-
        return_ACPI_STATUS (status);
 }
 
@@ -333,7 +341,7 @@ acpi_ex_system_reset_event (
        void                    *temp_semaphore;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        /*
index 844f52f5964a2b325d6e58624ed8468ec4d87bd7..13356fc19f7874d96550528b88c97026da596936 100644 (file)
@@ -2,12 +2,12 @@
 /******************************************************************************
  *
  * Module Name: exutils - interpreter/scanner utilities
- *              $Revision: 85 $
+ *              $Revision: 93 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -50,7 +50,7 @@
 #include "acparser.h"
 
 #define _COMPONENT          ACPI_EXECUTER
-        MODULE_NAME         ("exutils")
+        ACPI_MODULE_NAME    ("exutils")
 
 
 /*******************************************************************************
@@ -59,8 +59,8 @@
  *
  * PARAMETERS:  None
  *
- * DESCRIPTION: Enter the interpreter execution region
- *              TBD: should be a macro
+ * DESCRIPTION: Enter the interpreter execution region.  Failure to enter
+ *              the interpreter region is a fatal system error
  *
  ******************************************************************************/
 
@@ -69,10 +69,14 @@ acpi_ex_enter_interpreter (void)
 {
        acpi_status             status;
 
-       FUNCTION_TRACE ("Ex_enter_interpreter");
+       ACPI_FUNCTION_TRACE ("Ex_enter_interpreter");
 
 
        status = acpi_ut_acquire_mutex (ACPI_MTX_EXECUTE);
+       if (ACPI_FAILURE (status)) {
+               ACPI_REPORT_ERROR (("Fatal - Could not acquire interpreter lock\n"));
+       }
+
        return_ACPI_STATUS (status);
 }
 
@@ -95,17 +99,18 @@ acpi_ex_enter_interpreter (void)
  *          already executing
  *      7) About to invoke a user-installed opregion handler
  *
- *              TBD: should be a macro
- *
  ******************************************************************************/
 
 void
 acpi_ex_exit_interpreter (void)
 {
-       FUNCTION_TRACE ("Ex_exit_interpreter");
+       acpi_status             status;
+
 
+       ACPI_FUNCTION_TRACE ("Ex_exit_interpreter");
 
-       acpi_ut_release_mutex (ACPI_MTX_EXECUTE);
+
+       status = acpi_ut_release_mutex (ACPI_MTX_EXECUTE);
 
        return_VOID;
 }
@@ -126,7 +131,7 @@ acpi_ex_validate_object_type (
        acpi_object_type        type)
 {
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        if ((type > ACPI_TYPE_MAX && type < INTERNAL_TYPE_BEGIN) ||
@@ -159,7 +164,7 @@ acpi_ex_truncate_for32bit_table (
        acpi_walk_state         *walk_state)
 {
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        /*
@@ -186,7 +191,8 @@ acpi_ex_truncate_for32bit_table (
  *
  * FUNCTION:    Acpi_ex_acquire_global_lock
  *
- * PARAMETERS:  Rule            - Lock rule: Always_lock, Never_lock
+ * PARAMETERS:  Field_flags           - Flags with Lock rule:
+ *                                      Always_lock or Never_lock
  *
  * RETURN:      TRUE/FALSE indicating whether the lock was actually acquired
  *
@@ -198,25 +204,24 @@ acpi_ex_truncate_for32bit_table (
 
 u8
 acpi_ex_acquire_global_lock (
-       u32                     rule)
+       u32                     field_flags)
 {
        u8                      locked = FALSE;
        acpi_status             status;
 
 
-       FUNCTION_TRACE ("Ex_acquire_global_lock");
+       ACPI_FUNCTION_TRACE ("Ex_acquire_global_lock");
 
 
-       /* Only attempt lock if the Rule says so */
+       /* Only attempt lock if the Always_lock bit is set */
 
-       if (rule == (u32) GLOCK_ALWAYS_LOCK) {
-               /* We should attempt to get the lock */
+       if (field_flags & AML_FIELD_LOCK_RULE_MASK) {
+               /* We should attempt to get the lock, wait forever */
 
-               status = acpi_ev_acquire_global_lock ();
+               status = acpi_ev_acquire_global_lock (ACPI_UINT32_MAX);
                if (ACPI_SUCCESS (status)) {
                        locked = TRUE;
                }
-
                else {
                        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not acquire Global Lock, %s\n",
                                acpi_format_exception (status)));
@@ -245,7 +250,7 @@ acpi_ex_release_global_lock (
        u8                      locked_by_me)
 {
 
-       FUNCTION_TRACE ("Ex_release_global_lock");
+       ACPI_FUNCTION_TRACE ("Ex_release_global_lock");
 
 
        /* Only attempt unlock if the caller locked it */
@@ -256,7 +261,6 @@ acpi_ex_release_global_lock (
                acpi_ev_release_global_lock ();
        }
 
-
        return_ACPI_STATUS (AE_OK);
 }
 
@@ -280,13 +284,12 @@ acpi_ex_digits_needed (
        u32                     num_digits = 0;
 
 
-       FUNCTION_TRACE ("Ex_digits_needed");
+       ACPI_FUNCTION_TRACE ("Ex_digits_needed");
 
 
        if (base < 1) {
-               REPORT_ERROR (("Ex_digits_needed: Internal error - Invalid base\n"));
+               ACPI_REPORT_ERROR (("Ex_digits_needed: Internal error - Invalid base\n"));
        }
-
        else {
                /*
                 * acpi_integer is unsigned, which is why we don't worry about a '-'
@@ -325,7 +328,7 @@ _ntohl (
        } in;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        in.value = value;
@@ -358,7 +361,7 @@ acpi_ex_eisa_id_to_string (
        u32                     id;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        /* swap to big-endian to get contiguous bits */
@@ -399,7 +402,7 @@ acpi_ex_unsigned_integer_to_string (
        u32                     remainder;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        digits_needed = acpi_ex_digits_needed (value, 10);
index 0714c087172adf7cb040934c0602ec8c336b3ccd..d0bbc7655a46e95b304e00deeca0e7cf8e60f997 100644 (file)
@@ -1,11 +1,10 @@
 #
 # Makefile for all Linux ACPI interpreter subdirectories
-# EXCEPT for the ospm directory
 #
 
 O_TARGET := $(notdir $(CURDIR)).o
 
-obj-$(CONFIG_ACPI) := $(patsubst %.c,%.o,$(wildcard *.c))
+obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
 
index 7ea6a8fdab2b9a2e862a5bd743d0d6c6e2701b62..e5ca1e5bb7c482bbc7357adf7480afd2234b29f7 100644 (file)
@@ -2,12 +2,12 @@
 /******************************************************************************
  *
  * Module Name: hwacpi - ACPI Hardware Initialization/Mode Interface
- *              $Revision: 46 $
+ *              $Revision: 53 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@
 
 
 #define _COMPONENT          ACPI_HARDWARE
-        MODULE_NAME         ("hwacpi")
+        ACPI_MODULE_NAME    ("hwacpi")
 
 
 /******************************************************************************
@@ -49,131 +49,28 @@ acpi_status
 acpi_hw_initialize (
        void)
 {
-       acpi_status             status = AE_OK;
-       u32                     index;
+       acpi_status             status;
 
 
-       FUNCTION_TRACE ("Hw_initialize");
+       ACPI_FUNCTION_TRACE ("Hw_initialize");
 
 
        /* We must have the ACPI tables by the time we get here */
 
        if (!acpi_gbl_FADT) {
-               acpi_gbl_restore_acpi_chipset = FALSE;
-
-               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No FADT!\n"));
+               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "A FADT is not loaded\n"));
 
                return_ACPI_STATUS (AE_NO_ACPI_TABLES);
        }
 
-       /* Identify current ACPI/legacy mode   */
-
-       switch (acpi_gbl_system_flags & SYS_MODES_MASK) {
-       case (SYS_MODE_ACPI):
-
-               acpi_gbl_original_mode = SYS_MODE_ACPI;
-               ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "System supports ACPI mode only.\n"));
-               break;
-
-
-       case (SYS_MODE_LEGACY):
-
-               acpi_gbl_original_mode = SYS_MODE_LEGACY;
-               ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-                       "Tables loaded from buffer, hardware assumed to support LEGACY mode only.\n"));
-               break;
-
-
-       case (SYS_MODE_ACPI | SYS_MODE_LEGACY):
-
-               if (acpi_hw_get_mode () == SYS_MODE_ACPI) {
-                       acpi_gbl_original_mode = SYS_MODE_ACPI;
-               }
-               else {
-                       acpi_gbl_original_mode = SYS_MODE_LEGACY;
-               }
-
-               ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-                       "System supports both ACPI and LEGACY modes.\n"));
-
-               ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-                       "System is currently in %s mode.\n",
-                       (acpi_gbl_original_mode == SYS_MODE_ACPI) ? "ACPI" : "LEGACY"));
-               break;
-       }
-
-
-       if (acpi_gbl_system_flags & SYS_MODE_ACPI) {
-               /* Target system supports ACPI mode */
+       /* Sanity check the FADT for valid values */
 
-               /*
-                * The purpose of this code is to save the initial state
-                * of the ACPI event enable registers. An exit function will be
-                * registered which will restore this state when the application
-                * exits. The exit function will also clear all of the ACPI event
-                * status bits prior to restoring the original mode.
-                *
-                * The location of the PM1a_evt_blk enable registers is defined as the
-                * base of PM1a_evt_blk + DIV_2(PM1a_evt_blk_length). Since the spec further
-                * fully defines the PM1a_evt_blk to be a total of 4 bytes, the offset
-                * for the enable registers is always 2 from the base. It is hard
-                * coded here. If this changes in the spec, this code will need to
-                * be modified. The PM1b_evt_blk behaves as expected.
-                */
-               acpi_gbl_pm1_enable_register_save = (u16) acpi_hw_register_read (
-                                  ACPI_MTX_LOCK, PM1_EN);
-
-
-               /*
-                * The GPEs behave similarly, except that the length of the register
-                * block is not fixed, so the buffer must be allocated with malloc
-                */
-               if (ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xgpe0blk.address) &&
-                       acpi_gbl_FADT->gpe0blk_len) {
-                       /* GPE0 specified in FADT  */
-
-                       acpi_gbl_gpe0enable_register_save = ACPI_MEM_ALLOCATE (
-                                          DIV_2 (acpi_gbl_FADT->gpe0blk_len));
-                       if (!acpi_gbl_gpe0enable_register_save) {
-                               return_ACPI_STATUS (AE_NO_MEMORY);
-                       }
-
-                       /* Save state of GPE0 enable bits */
-
-                       for (index = 0; index < DIV_2 (acpi_gbl_FADT->gpe0blk_len); index++) {
-                               acpi_gbl_gpe0enable_register_save[index] =
-                                       (u8) acpi_hw_register_read (ACPI_MTX_LOCK, GPE0_EN_BLOCK | index);
-                       }
-               }
-
-               else {
-                       acpi_gbl_gpe0enable_register_save = NULL;
-               }
-
-               if (ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xgpe1_blk.address) &&
-                       acpi_gbl_FADT->gpe1_blk_len) {
-                       /* GPE1 defined */
-
-                       acpi_gbl_gpe1_enable_register_save = ACPI_MEM_ALLOCATE (
-                                          DIV_2 (acpi_gbl_FADT->gpe1_blk_len));
-                       if (!acpi_gbl_gpe1_enable_register_save) {
-                               return_ACPI_STATUS (AE_NO_MEMORY);
-                       }
-
-                       /* save state of GPE1 enable bits */
-
-                       for (index = 0; index < DIV_2 (acpi_gbl_FADT->gpe1_blk_len); index++) {
-                               acpi_gbl_gpe1_enable_register_save[index] =
-                                       (u8) acpi_hw_register_read (ACPI_MTX_LOCK, GPE1_EN_BLOCK | index);
-                       }
-               }
-
-               else {
-                       acpi_gbl_gpe1_enable_register_save = NULL;
-               }
+       status = acpi_ut_validate_fadt ();
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
        }
 
-       return_ACPI_STATUS (status);
+       return_ACPI_STATUS (AE_OK);
 }
 
 
@@ -185,8 +82,7 @@ acpi_hw_initialize (
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Transitions the system into the requested mode or does nothing
- *              if the system is already in that mode.
+ * DESCRIPTION: Transitions the system into the requested mode.
  *
  ******************************************************************************/
 
@@ -198,17 +94,16 @@ acpi_hw_set_mode (
        acpi_status             status = AE_NO_HARDWARE_RESPONSE;
 
 
-       FUNCTION_TRACE ("Hw_set_mode");
+       ACPI_FUNCTION_TRACE ("Hw_set_mode");
 
 
-       if (mode == SYS_MODE_ACPI) {
+       if (mode == ACPI_SYS_MODE_ACPI) {
                /* BIOS should have disabled ALL fixed and GP events */
 
                acpi_os_write_port (acpi_gbl_FADT->smi_cmd, acpi_gbl_FADT->acpi_enable, 8);
                ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Attempting to enable ACPI mode\n"));
        }
-
-       else if (mode == SYS_MODE_LEGACY) {
+       else if (mode == ACPI_SYS_MODE_LEGACY) {
                /*
                 * BIOS should clear all fixed status bits and restore fixed event
                 * enable bits to default
@@ -248,73 +143,13 @@ u32
 acpi_hw_get_mode (void)
 {
 
-       FUNCTION_TRACE ("Hw_get_mode");
+       ACPI_FUNCTION_TRACE ("Hw_get_mode");
 
 
-       if (acpi_hw_register_bit_access (ACPI_READ, ACPI_MTX_LOCK, SCI_EN)) {
-               return_VALUE (SYS_MODE_ACPI);
+       if (acpi_hw_bit_register_read (ACPI_BITREG_SCI_ENABLE, ACPI_MTX_LOCK)) {
+               return_VALUE (ACPI_SYS_MODE_ACPI);
        }
        else {
-               return_VALUE (SYS_MODE_LEGACY);
-       }
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    Acpi_hw_get_mode_capabilities
- *
- * PARAMETERS:  none
- *
- * RETURN:      logical OR of SYS_MODE_ACPI and SYS_MODE_LEGACY determined at initial
- *              system state.
- *
- * DESCRIPTION: Returns capablities of system
- *
- ******************************************************************************/
-
-u32
-acpi_hw_get_mode_capabilities (void)
-{
-
-       FUNCTION_TRACE ("Hw_get_mode_capabilities");
-
-
-       if (!(acpi_gbl_system_flags & SYS_MODES_MASK)) {
-               if (acpi_hw_get_mode () == SYS_MODE_LEGACY) {
-                       /*
-                        * Assume that if this call is being made, Acpi_init has been called
-                        * and ACPI support has been established by the presence of the
-                        * tables.  Therefore since we're in SYS_MODE_LEGACY, the system
-                        * must support both modes
-                        */
-                       acpi_gbl_system_flags |= (SYS_MODE_ACPI | SYS_MODE_LEGACY);
-               }
-
-               else {
-                       /* TBD: [Investigate] !!! this may be unsafe... */
-                       /*
-                        * system is is ACPI mode, so try to switch back to LEGACY to see if
-                        * it is supported
-                        */
-                       acpi_hw_set_mode (SYS_MODE_LEGACY);
-
-                       if (acpi_hw_get_mode () == SYS_MODE_LEGACY) {
-                               /* Now in SYS_MODE_LEGACY, so both are supported */
-
-                               acpi_gbl_system_flags |= (SYS_MODE_ACPI | SYS_MODE_LEGACY);
-                               acpi_hw_set_mode (SYS_MODE_ACPI);
-                       }
-
-                       else {
-                               /* Still in SYS_MODE_ACPI so this must be an ACPI only system */
-
-                               acpi_gbl_system_flags |= SYS_MODE_ACPI;
-                       }
-               }
+               return_VALUE (ACPI_SYS_MODE_LEGACY);
        }
-
-       return_VALUE (acpi_gbl_system_flags & SYS_MODES_MASK);
 }
-
-
index 9c9c1e19c31980e6049dd0ec56d602977ca13c1c..1016b2cf452780de8993444fe3ea46147bb18400 100644 (file)
@@ -2,12 +2,12 @@
 /******************************************************************************
  *
  * Module Name: hwgpe - Low level GPE enable/disable/clear functions
- *              $Revision: 35 $
+ *              $Revision: 39 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 #include "acevents.h"
 
 #define _COMPONENT          ACPI_HARDWARE
-        MODULE_NAME         ("hwgpe")
+        ACPI_MODULE_NAME    ("hwgpe")
+
+
+/******************************************************************************
+ *
+ * FUNCTION:    Acpi_hw_get_gpe_bit_mask
+ *
+ * PARAMETERS:  Gpe_number      - The GPE
+ *
+ * RETURN:      Gpe register bitmask for this gpe level
+ *
+ * DESCRIPTION: Get the bitmask for this GPE
+ *
+ ******************************************************************************/
+
+u32
+acpi_hw_get_gpe_bit_mask (
+       u32                     gpe_number)
+{
+       return (acpi_gbl_gpe_number_info [acpi_ev_get_gpe_number_index (gpe_number)].bit_mask);
+}
 
 
 /******************************************************************************
@@ -54,29 +74,28 @@ acpi_hw_enable_gpe (
        u32                     bit_mask;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
-       /*
-        * Translate GPE number to index into global registers array.
-        */
-       register_index = acpi_gbl_gpe_valid[gpe_number];
+       /* Translate GPE number to index into global registers array. */
 
-       /*
-        * Figure out the bit offset for this GPE within the target register.
-        */
-       bit_mask = acpi_gbl_decode_to8bit [MOD_8 (gpe_number)];
+       register_index = acpi_ev_get_gpe_register_index (gpe_number);
+
+       /* Get the register bitmask for this GPE */
+
+       bit_mask = acpi_hw_get_gpe_bit_mask (gpe_number);
 
        /*
         * Read the current value of the register, set the appropriate bit
         * to enable the GPE, and write out the new register.
         */
        in_byte = 0;
-       acpi_os_read_port (acpi_gbl_gpe_registers[register_index].enable_addr, &in_byte, 8);
-       acpi_os_write_port (acpi_gbl_gpe_registers[register_index].enable_addr,
-                          (in_byte | bit_mask), 8);
+       acpi_os_read_port (acpi_gbl_gpe_register_info[register_index].enable_addr, &in_byte, 8);
+       acpi_os_write_port (acpi_gbl_gpe_register_info[register_index].enable_addr,
+                         (in_byte | bit_mask), 8);
 }
 
+
 /******************************************************************************
  *
  * FUNCTION:    Acpi_hw_enable_gpe_for_wakeup
@@ -98,25 +117,24 @@ acpi_hw_enable_gpe_for_wakeup (
        u32                     bit_mask;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
-       /*
-        * Translate GPE number to index into global registers array.
-        */
-       register_index = acpi_gbl_gpe_valid[gpe_number];
+       /* Translate GPE number to index into global registers array. */
 
-       /*
-        * Figure out the bit offset for this GPE within the target register.
-        */
-       bit_mask = acpi_gbl_decode_to8bit [MOD_8 (gpe_number)];
+       register_index = acpi_ev_get_gpe_register_index (gpe_number);
+
+       /* Get the register bitmask for this GPE */
+
+       bit_mask = acpi_hw_get_gpe_bit_mask (gpe_number);
 
        /*
         * Set the bit so we will not disable this when sleeping
         */
-       acpi_gbl_gpe_registers[register_index].wake_enable |= bit_mask;
+       acpi_gbl_gpe_register_info[register_index].wake_enable |= bit_mask;
 }
 
+
 /******************************************************************************
  *
  * FUNCTION:    Acpi_hw_disable_gpe
@@ -138,31 +156,30 @@ acpi_hw_disable_gpe (
        u32                     bit_mask;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
-       /*
-        * Translate GPE number to index into global registers array.
-        */
-       register_index = acpi_gbl_gpe_valid[gpe_number];
+       /* Translate GPE number to index into global registers array. */
 
-       /*
-        * Figure out the bit offset for this GPE within the target register.
-        */
-       bit_mask = acpi_gbl_decode_to8bit [MOD_8 (gpe_number)];
+       register_index = acpi_ev_get_gpe_register_index (gpe_number);
+
+       /* Get the register bitmask for this GPE */
+
+       bit_mask = acpi_hw_get_gpe_bit_mask (gpe_number);
 
        /*
         * Read the current value of the register, clear the appropriate bit,
         * and write out the new register value to disable the GPE.
         */
        in_byte = 0;
-       acpi_os_read_port (acpi_gbl_gpe_registers[register_index].enable_addr, &in_byte, 8);
-       acpi_os_write_port (acpi_gbl_gpe_registers[register_index].enable_addr,
+       acpi_os_read_port (acpi_gbl_gpe_register_info[register_index].enable_addr, &in_byte, 8);
+       acpi_os_write_port (acpi_gbl_gpe_register_info[register_index].enable_addr,
                         (in_byte & ~bit_mask), 8);
 
        acpi_hw_disable_gpe_for_wakeup(gpe_number);
 }
 
+
 /******************************************************************************
  *
  * FUNCTION:    Acpi_hw_disable_gpe_for_wakeup
@@ -184,25 +201,24 @@ acpi_hw_disable_gpe_for_wakeup (
        u32                     bit_mask;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
-       /*
-        * Translate GPE number to index into global registers array.
-        */
-       register_index = acpi_gbl_gpe_valid[gpe_number];
+       /* Translate GPE number to index into global registers array. */
 
-       /*
-        * Figure out the bit offset for this GPE within the target register.
-        */
-       bit_mask = acpi_gbl_decode_to8bit [MOD_8 (gpe_number)];
+       register_index = acpi_ev_get_gpe_register_index (gpe_number);
+
+       /* Get the register bitmask for this GPE */
+
+       bit_mask = acpi_hw_get_gpe_bit_mask (gpe_number);
 
        /*
         * Clear the bit so we will disable this when sleeping
         */
-       acpi_gbl_gpe_registers[register_index].wake_enable &= ~bit_mask;
+       acpi_gbl_gpe_register_info[register_index].wake_enable &= ~bit_mask;
 }
 
+
 /******************************************************************************
  *
  * FUNCTION:    Acpi_hw_clear_gpe
@@ -223,24 +239,22 @@ acpi_hw_clear_gpe (
        u32                     bit_mask;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
-       /*
-        * Translate GPE number to index into global registers array.
-        */
-       register_index = acpi_gbl_gpe_valid[gpe_number];
+       /* Translate GPE number to index into global registers array. */
 
-       /*
-        * Figure out the bit offset for this GPE within the target register.
-        */
-       bit_mask = acpi_gbl_decode_to8bit [MOD_8 (gpe_number)];
+       register_index = acpi_ev_get_gpe_register_index (gpe_number);
+
+       /* Get the register bitmask for this GPE */
+
+       bit_mask = acpi_hw_get_gpe_bit_mask (gpe_number);
 
        /*
         * Write a one to the appropriate bit in the status register to
         * clear this GPE.
         */
-       acpi_os_write_port (acpi_gbl_gpe_registers[register_index].status_addr, bit_mask, 8);
+       acpi_os_write_port (acpi_gbl_gpe_register_info[register_index].status_addr, bit_mask, 8);
 }
 
 
@@ -264,9 +278,10 @@ acpi_hw_get_gpe_status (
        u32                     in_byte = 0;
        u32                     register_index = 0;
        u32                     bit_mask = 0;
+       ACPI_GPE_REGISTER_INFO  *gpe_register_info;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        if (!event_status) {
@@ -275,42 +290,39 @@ acpi_hw_get_gpe_status (
 
        (*event_status) = 0;
 
-       /*
-        * Translate GPE number to index into global registers array.
-        */
-       register_index = acpi_gbl_gpe_valid[gpe_number];
+       /* Translate GPE number to index into global registers array. */
 
-       /*
-        * Figure out the bit offset for this GPE within the target register.
-        */
-       bit_mask = acpi_gbl_decode_to8bit [MOD_8 (gpe_number)];
+       register_index = acpi_ev_get_gpe_register_index (gpe_number);
+       gpe_register_info = &acpi_gbl_gpe_register_info[register_index];
+
+       /* Get the register bitmask for this GPE */
+
+       bit_mask = acpi_hw_get_gpe_bit_mask (gpe_number);
+
+       /* GPE Enabled? */
 
-       /*
-        * Enabled?:
-        */
        in_byte = 0;
-       acpi_os_read_port (acpi_gbl_gpe_registers[register_index].enable_addr, &in_byte, 8);
+       acpi_os_read_port (gpe_register_info->enable_addr, &in_byte, 8);
        if (bit_mask & in_byte) {
                (*event_status) |= ACPI_EVENT_FLAG_ENABLED;
        }
 
-       /*
-        * Enabled for wake?:
-        */
-       if (bit_mask & acpi_gbl_gpe_registers[register_index].wake_enable) {
+       /* GPE Enabled for wake? */
+
+       if (bit_mask & gpe_register_info->wake_enable) {
                (*event_status) |= ACPI_EVENT_FLAG_WAKE_ENABLED;
        }
 
-       /*
-        * Set?
-        */
+       /* GPE active (set)? */
+
        in_byte = 0;
-       acpi_os_read_port (acpi_gbl_gpe_registers[register_index].status_addr, &in_byte, 8);
+       acpi_os_read_port (gpe_register_info->status_addr, &in_byte, 8);
        if (bit_mask & in_byte) {
                (*event_status) |= ACPI_EVENT_FLAG_SET;
        }
 }
 
+
 /******************************************************************************
  *
  * FUNCTION:    Acpi_hw_disable_non_wakeup_gpes
@@ -321,7 +333,7 @@ acpi_hw_get_gpe_status (
  *
  * DESCRIPTION: Disable all non-wakeup GPEs
  *              Call with interrupts disabled. The interrupt handler also
- *              modifies Acpi_gbl_Gpe_registers[i].Enable, so it should not be
+ *              modifies Acpi_gbl_Gpe_register_info[i].Enable, so it should not be
  *              given the chance to run until after non-wake GPEs are
  *              re-enabled.
  *
@@ -332,25 +344,31 @@ acpi_hw_disable_non_wakeup_gpes (
        void)
 {
        u32                     i;
+       ACPI_GPE_REGISTER_INFO  *gpe_register_info;
+
+
+       ACPI_FUNCTION_ENTRY ();
 
-       FUNCTION_ENTRY ();
 
        for (i = 0; i < acpi_gbl_gpe_register_count; i++) {
+               gpe_register_info = &acpi_gbl_gpe_register_info[i];
+
                /*
                 * Read the enabled status of all GPEs. We
                 * will be using it to restore all the GPEs later.
                 */
-               acpi_os_read_port (acpi_gbl_gpe_registers[i].enable_addr,
-                               &acpi_gbl_gpe_registers[i].enable, 8);
+               acpi_os_read_port (gpe_register_info->enable_addr,
+                                 &gpe_register_info->enable, 8);
 
                /*
-                * Disable all GPEs but wakeup GPEs.
+                * Disable all GPEs except wakeup GPEs.
                 */
-               acpi_os_write_port(acpi_gbl_gpe_registers[i].enable_addr,
-                               acpi_gbl_gpe_registers[i].wake_enable, 8);
+               acpi_os_write_port(gpe_register_info->enable_addr,
+                                 gpe_register_info->wake_enable, 8);
        }
 }
 
+
 /******************************************************************************
  *
  * FUNCTION:    Acpi_hw_enable_non_wakeup_gpes
@@ -368,15 +386,20 @@ acpi_hw_enable_non_wakeup_gpes (
        void)
 {
        u32                     i;
+       ACPI_GPE_REGISTER_INFO  *gpe_register_info;
+
+
+       ACPI_FUNCTION_ENTRY ();
 
-       FUNCTION_ENTRY ();
 
        for (i = 0; i < acpi_gbl_gpe_register_count; i++) {
+               gpe_register_info = &acpi_gbl_gpe_register_info[i];
+
                /*
                 * We previously stored the enabled status of all GPEs.
                 * Blast them back in.
                 */
-               acpi_os_write_port(acpi_gbl_gpe_registers[i].enable_addr,
-                               acpi_gbl_gpe_registers[i].enable, 8);
+               acpi_os_write_port(gpe_register_info->enable_addr,
+                                 gpe_register_info->enable, 8);
        }
 }
index 5a1ad0a20f4a06f81ac292e29039a759458bfb6d..b4cbf9b2385c802ff0c3b1289d90126e5885e4ad 100644 (file)
@@ -3,12 +3,12 @@
  *
  * Module Name: hwregs - Read/write access functions for the various ACPI
  *                       control and status registers.
- *              $Revision: 110 $
+ *              $Revision: 120 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 #include "acnamesp.h"
 
 #define _COMPONENT          ACPI_HARDWARE
-        MODULE_NAME         ("hwregs")
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_hw_get_bit_shift
- *
- * PARAMETERS:  Mask            - Input mask to determine bit shift from.
- *                                Must have at least 1 bit set.
- *
- * RETURN:      Bit location of the lsb of the mask
- *
- * DESCRIPTION: Returns the bit number for the low order bit that's set.
- *
- ******************************************************************************/
-
-u32
-acpi_hw_get_bit_shift (
-       u32                     mask)
-{
-       u32                     shift;
-
-
-       FUNCTION_TRACE ("Hw_get_bit_shift");
-
-
-       for (shift = 0; ((mask >> shift) & 1) == 0; shift++) { ; }
-
-       return_VALUE (shift);
-}
+        ACPI_MODULE_NAME    ("hwregs")
 
 
 /*******************************************************************************
@@ -78,89 +49,83 @@ acpi_hw_get_bit_shift (
 void
 acpi_hw_clear_acpi_status (void)
 {
-       u16                     gpe_length;
-       u16                     index;
+       NATIVE_UINT             i;
+       NATIVE_UINT             gpe_block;
+       acpi_status             status;
 
 
-       FUNCTION_TRACE ("Hw_clear_acpi_status");
+       ACPI_FUNCTION_TRACE ("Hw_clear_acpi_status");
 
 
        ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %04X to %04X\n",
-               ALL_FIXED_STS_BITS,
+               ACPI_BITMASK_ALL_FIXED_STATUS,
                (u16) ACPI_GET_ADDRESS (acpi_gbl_FADT->Xpm1a_evt_blk.address)));
 
 
-       acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE);
+       status = acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE);
+       if (ACPI_FAILURE (status)) {
+               return_VOID;
+       }
 
-       acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, PM1_STS, ALL_FIXED_STS_BITS);
+       acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_STATUS,
+                       ACPI_BITMASK_ALL_FIXED_STATUS);
 
+       /* Clear the fixed events */
 
        if (ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xpm1b_evt_blk.address)) {
                acpi_os_write_port ((ACPI_IO_ADDRESS)
                        ACPI_GET_ADDRESS (acpi_gbl_FADT->Xpm1b_evt_blk.address),
-                       ALL_FIXED_STS_BITS, 16);
+                       ACPI_BITMASK_ALL_FIXED_STATUS, 16);
        }
 
-       /* now clear the GPE Bits */
+       /* Clear the GPE Bits */
 
-       if (acpi_gbl_FADT->gpe0blk_len) {
-               gpe_length = (u16) DIV_2 (acpi_gbl_FADT->gpe0blk_len);
-
-               for (index = 0; index < gpe_length; index++) {
-                       acpi_os_write_port ((ACPI_IO_ADDRESS) (
-                               ACPI_GET_ADDRESS (acpi_gbl_FADT->Xgpe0blk.address) + index),
-                                       0xFF, 8);
-               }
-       }
-
-       if (acpi_gbl_FADT->gpe1_blk_len) {
-               gpe_length = (u16) DIV_2 (acpi_gbl_FADT->gpe1_blk_len);
-
-               for (index = 0; index < gpe_length; index++) {
-                       acpi_os_write_port ((ACPI_IO_ADDRESS) (
-                               ACPI_GET_ADDRESS (acpi_gbl_FADT->Xgpe1_blk.address) + index),
+       for (gpe_block = 0; gpe_block < ACPI_MAX_GPE_BLOCKS; gpe_block++) {
+               for (i = 0; i < acpi_gbl_gpe_block_info[gpe_block].register_count; i++) {
+                       acpi_os_write_port ((ACPI_IO_ADDRESS)
+                               (acpi_gbl_gpe_block_info[gpe_block].block_address + i),
                                0xFF, 8);
                }
        }
 
-       acpi_ut_release_mutex (ACPI_MTX_HARDWARE);
+       (void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE);
        return_VOID;
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_hw_obtain_sleep_type_register_data
+ * FUNCTION:    Acpi_hw_get_sleep_type_data
  *
- * PARAMETERS:  Sleep_state       - Numeric state requested
- *              *Slp_Typ_a         - Pointer to byte to receive SLP_TYPa value
- *              *Slp_Typ_b         - Pointer to byte to receive SLP_TYPb value
+ * PARAMETERS:  Sleep_state         - Numeric sleep state
+ *              *Sleep_type_a        - Where SLP_TYPa is returned
+ *              *Sleep_type_b        - Where SLP_TYPb is returned
  *
  * RETURN:      Status - ACPI status
  *
- * DESCRIPTION: Acpi_hw_obtain_sleep_type_register_data() obtains the SLP_TYP and
- *              SLP_TYPb values for the sleep state requested.
+ * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested sleep
+ *              state.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_hw_obtain_sleep_type_register_data (
+acpi_hw_get_sleep_type_data (
        u8                      sleep_state,
-       u8                      *slp_typ_a,
-       u8                      *slp_typ_b)
+       u8                      *sleep_type_a,
+       u8                      *sleep_type_b)
 {
        acpi_status             status = AE_OK;
        acpi_operand_object     *obj_desc;
 
 
-       FUNCTION_TRACE ("Hw_obtain_sleep_type_register_data");
+       ACPI_FUNCTION_TRACE ("Hw_get_sleep_type_data");
 
 
        /*
         *  Validate parameters
         */
        if ((sleep_state > ACPI_S_STATES_MAX) ||
-               !slp_typ_a || !slp_typ_b) {
+               !sleep_type_a || !sleep_type_b) {
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
@@ -174,7 +139,7 @@ acpi_hw_obtain_sleep_type_register_data (
        }
 
        if (!obj_desc) {
-               REPORT_ERROR (("Missing Sleep State object\n"));
+               ACPI_REPORT_ERROR (("Missing Sleep State object\n"));
                return_ACPI_STATUS (AE_NOT_EXIST);
        }
 
@@ -185,386 +150,251 @@ acpi_hw_obtain_sleep_type_register_data (
         */
 
        /* Even though Acpi_evaluate_object resolves package references,
-        * Ns_evaluate dpesn't. So, we do it here.
+        * Ns_evaluate doesn't. So, we do it here.
         */
        status = acpi_ut_resolve_package_references(obj_desc);
 
        if (obj_desc->package.count < 2) {
                /* Must have at least two elements */
 
-               REPORT_ERROR (("Sleep State package does not have at least two elements\n"));
-               status = AE_ERROR;
+               ACPI_REPORT_ERROR (("Sleep State package does not have at least two elements\n"));
+               status = AE_AML_NO_OPERAND;
        }
-
-       else if (((obj_desc->package.elements[0])->common.type !=
-                        ACPI_TYPE_INTEGER) ||
-                        ((obj_desc->package.elements[1])->common.type !=
-                               ACPI_TYPE_INTEGER)) {
+       else if (((obj_desc->package.elements[0])->common.type != ACPI_TYPE_INTEGER) ||
+                        ((obj_desc->package.elements[1])->common.type != ACPI_TYPE_INTEGER)) {
                /* Must have two  */
 
-               REPORT_ERROR (("Sleep State package elements are not both of type Number\n"));
-               status = AE_ERROR;
+               ACPI_REPORT_ERROR (("Sleep State package elements are not both of type Number\n"));
+               status = AE_AML_OPERAND_TYPE;
        }
-
        else {
                /*
                 *  Valid _Sx_ package size, type, and value
                 */
-               *slp_typ_a = (u8) (obj_desc->package.elements[0])->integer.value;
-
-               *slp_typ_b = (u8) (obj_desc->package.elements[1])->integer.value;
+               *sleep_type_a = (u8) (obj_desc->package.elements[0])->integer.value;
+               *sleep_type_b = (u8) (obj_desc->package.elements[1])->integer.value;
        }
 
-
        if (ACPI_FAILURE (status)) {
                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Bad Sleep object %p type %X\n",
                        obj_desc, obj_desc->common.type));
        }
 
        acpi_ut_remove_reference (obj_desc);
-
        return_ACPI_STATUS (status);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_hw_register_bit_access
+ * FUNCTION:    Acpi_hw_get_register_bit_mask
  *
- * PARAMETERS:  Read_write      - Either ACPI_READ or ACPI_WRITE.
- *              Use_lock        - Lock the hardware
- *              Register_id     - index of ACPI Register to access
- *              Value           - (only used on write) value to write to the
- *                                Register.  Shifted all the way right.
+ * PARAMETERS:  Register_id     - index of ACPI Register to access
  *
- * RETURN:      Value written to or read from specified Register.  This value
- *              is shifted all the way right.
+ * RETURN:      The bit mask to be used when accessing the register
  *
- * DESCRIPTION: Generic ACPI Register read/write function.
+ * DESCRIPTION: Map Register_id into a register bit mask.
  *
  ******************************************************************************/
 
-u32
-acpi_hw_register_bit_access (
-       NATIVE_UINT             read_write,
-       u8                      use_lock,
-       u32                     register_id,
-       ...)                    /* Value (only used on write) */
+ACPI_BIT_REGISTER_INFO *
+acpi_hw_get_bit_register_info (
+       u32                     register_id)
 {
-       u32                     register_value = 0;
-       u32                     mask = 0;
-       u32                     value = 0;
-       va_list                 marker;
+       ACPI_FUNCTION_NAME ("Hw_get_bit_register_info");
 
 
-       FUNCTION_TRACE ("Hw_register_bit_access");
+       if (register_id > ACPI_BITREG_MAX) {
+               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid Bit_register ID: %X\n", register_id));
+               return (NULL);
+       }
 
+       return (&acpi_gbl_bit_register_info[register_id]);
+}
 
-       if (read_write == ACPI_WRITE) {
-               va_start (marker, register_id);
-               value = va_arg (marker, u32);
-               va_end (marker);
-       }
 
-       if (ACPI_MTX_LOCK == use_lock) {
-               acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE);
-       }
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_hw_bit_register_read
+ *
+ * PARAMETERS:  Register_id     - index of ACPI Register to access
+ *              Use_lock        - Lock the hardware
+ *
+ * RETURN:      Value is read from specified Register.  Value returned is
+ *              normalized to bit0 (is shifted all the way right)
+ *
+ * DESCRIPTION: ACPI Bit_register read function.
+ *
+ ******************************************************************************/
 
-       /*
-        * Decode the Register ID
-        * Register id = Register block id | bit id
-        *
-        * Check bit id to fine locate Register offset.
-        * Check Mask to determine Register offset, and then read-write.
-        */
-       switch (REGISTER_BLOCK_ID (register_id)) {
-       case PM1_STS:
+u32
+acpi_hw_bit_register_read (
+       u32                     register_id,
+       u32                     flags)
+{
+       u32                     register_value = 0;
+       ACPI_BIT_REGISTER_INFO  *bit_reg_info;
 
-               switch (register_id) {
-               case TMR_STS:
-                       mask = TMR_STS_MASK;
-                       break;
 
-               case BM_STS:
-                       mask = BM_STS_MASK;
-                       break;
+       ACPI_FUNCTION_TRACE ("Hw_bit_register_read");
 
-               case GBL_STS:
-                       mask = GBL_STS_MASK;
-                       break;
 
-               case PWRBTN_STS:
-                       mask = PWRBTN_STS_MASK;
-                       break;
+       if (flags & ACPI_MTX_LOCK) {
+               if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE))) {
+                       return_VALUE (0);
+               }
+       }
 
-               case SLPBTN_STS:
-                       mask = SLPBTN_STS_MASK;
-                       break;
+       /* Get the info structure corresponding to the requested ACPI Register */
 
-               case RTC_STS:
-                       mask = RTC_STS_MASK;
-                       break;
+       bit_reg_info = acpi_hw_get_bit_register_info (register_id);
+       if (!bit_reg_info) {
+               return_ACPI_STATUS (AE_BAD_PARAMETER);
+       }
 
-               case WAK_STS:
-                       mask = WAK_STS_MASK;
-                       break;
+       register_value = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, bit_reg_info->parent_register);
 
-               default:
-                       mask = 0;
-                       break;
-               }
+       if (flags & ACPI_MTX_LOCK) {
+               (void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE);
+       }
 
-               register_value = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, PM1_STS);
-
-               if (read_write == ACPI_WRITE) {
-                       /*
-                        * Status Registers are different from the rest.  Clear by
-                        * writing 1, writing 0 has no effect.  So, the only relevent
-                        * information is the single bit we're interested in, all
-                        * others should be written as 0 so they will be left
-                        * unchanged
-                        */
-                       value <<= acpi_hw_get_bit_shift (mask);
-                       value &= mask;
-
-                       if (value) {
-                               acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, PM1_STS,
-                                       (u16) value);
-                               register_value = 0;
-                       }
-               }
+       /* Normalize the value that was read */
 
-               break;
+       register_value = ((register_value & bit_reg_info->access_bit_mask) >> bit_reg_info->bit_position);
 
+       ACPI_DEBUG_PRINT ((ACPI_DB_IO, "ACPI Register_read: got %X\n", register_value));
+       return_VALUE (register_value);
+}
 
-       case PM1_EN:
 
-               switch (register_id) {
-               case TMR_EN:
-                       mask = TMR_EN_MASK;
-                       break;
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_hw_bit_register_write
+ *
+ * PARAMETERS:  Register_id     - ID of ACPI Bit_register to access
+ *              Value           - (only used on write) value to write to the
+ *                                Register, NOT pre-normalized to the bit pos.
+ *              Flags           - Lock the hardware or not
+ *
+ * RETURN:      Value written to from specified Register.  This value
+ *              is shifted all the way right.
+ *
+ * DESCRIPTION: ACPI Bit Register write function.
+ *
+ ******************************************************************************/
 
-               case GBL_EN:
-                       mask = GBL_EN_MASK;
-                       break;
+u32
+acpi_hw_bit_register_write (
+       u32                     register_id,
+       u32                     value,
+       u32                     flags)
+{
+       u32                     register_value = 0;
+       ACPI_BIT_REGISTER_INFO  *bit_reg_info;
 
-               case PWRBTN_EN:
-                       mask = PWRBTN_EN_MASK;
-                       break;
 
-               case SLPBTN_EN:
-                       mask = SLPBTN_EN_MASK;
-                       break;
+       ACPI_FUNCTION_TRACE_U32 ("Hw_bit_register_write", register_id);
 
-               case RTC_EN:
-                       mask = RTC_EN_MASK;
-                       break;
 
-               default:
-                       mask = 0;
-                       break;
+       if (flags & ACPI_MTX_LOCK) {
+               if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE))) {
+                       return_VALUE (0);
                }
+       }
 
-               register_value = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, PM1_EN);
-
-               if (read_write == ACPI_WRITE) {
-                       register_value &= ~mask;
-                       value          <<= acpi_hw_get_bit_shift (mask);
-                       value          &= mask;
-                       register_value |= value;
+       /* Get the info structure corresponding to the requested ACPI Register */
 
-                       acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, PM1_EN, (u16) register_value);
-               }
+       bit_reg_info = acpi_hw_get_bit_register_info (register_id);
+       if (!bit_reg_info) {
+               return_ACPI_STATUS (AE_BAD_PARAMETER);
+       }
 
-               break;
+       /* Always do a register read first so we can insert the new bits  */
 
+       register_value = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, bit_reg_info->parent_register);
 
-       case PM1_CONTROL:
+       /*
+        * Decode the Register ID
+        * Register id = Register block id | bit id
+        *
+        * Check bit id to fine locate Register offset.
+        * Check Mask to determine Register offset, and then read-write.
+        */
+       switch (bit_reg_info->parent_register) {
+       case ACPI_REGISTER_PM1_STATUS:
 
-               switch (register_id) {
-               case SCI_EN:
-                       mask = SCI_EN_MASK;
-                       break;
+               /*
+                * Status Registers are different from the rest.  Clear by
+                * writing 1, writing 0 has no effect.  So, the only relevent
+                * information is the single bit we're interested in, all others should
+                * be written as 0 so they will be left unchanged
+                */
+               value = ACPI_REGISTER_PREPARE_BITS (value, bit_reg_info->bit_position, bit_reg_info->access_bit_mask);
+               if (value) {
+                       acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_STATUS,
+                               (u16) value);
+                       register_value = 0;
+               }
+               break;
 
-               case BM_RLD:
-                       mask = BM_RLD_MASK;
-                       break;
 
-               case GBL_RLS:
-                       mask = GBL_RLS_MASK;
-                       break;
+       case ACPI_REGISTER_PM1_ENABLE:
 
-               case SLP_TYPE_A:
-               case SLP_TYPE_B:
-                       mask = SLP_TYPE_X_MASK;
-                       break;
+               ACPI_REGISTER_INSERT_VALUE (register_value, bit_reg_info->bit_position, bit_reg_info->access_bit_mask, value);
 
-               case SLP_EN:
-                       mask = SLP_EN_MASK;
-                       break;
+               acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_ENABLE, (u16) register_value);
+               break;
 
-               default:
-                       mask = 0;
-                       break;
-               }
 
+       case ACPI_REGISTER_PM1_CONTROL:
 
                /*
                 * Read the PM1 Control register.
                 * Note that at this level, the fact that there are actually TWO
-                * registers (A and B) and that B may not exist, are abstracted.
+                * registers (A and B - and that B may not exist) is abstracted.
                 */
-               register_value = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, PM1_CONTROL);
-
                ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM1 control: Read %X\n", register_value));
 
-               if (read_write == ACPI_WRITE) {
-                       register_value &= ~mask;
-                       value          <<= acpi_hw_get_bit_shift (mask);
-                       value          &= mask;
-                       register_value |= value;
-
-                       /*
-                        * SLP_TYPE_x Registers are written differently
-                        * than any other control Registers with
-                        * respect to A and B Registers.  The value
-                        * for A may be different than the value for B
-                        *
-                        * Therefore, pass the Register_id, not just generic PM1_CONTROL,
-                        * because we need to do different things. Yuck.
-                        */
-                       acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, register_id,
-                                       (u16) register_value);
-               }
-               break;
-
+               ACPI_REGISTER_INSERT_VALUE (register_value, bit_reg_info->bit_position, bit_reg_info->access_bit_mask, value);
 
-       case PM2_CONTROL:
+               acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, register_id,
+                               (u16) register_value);
+               break;
 
-               switch (register_id) {
-               case ARB_DIS:
-                       mask = ARB_DIS_MASK;
-                       break;
 
-               default:
-                       mask = 0;
-                       break;
-               }
+       case ACPI_REGISTER_PM2_CONTROL:
 
-               register_value = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, PM2_CONTROL);
+               register_value = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM2_CONTROL);
 
                ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM2 control: Read %X from %8.8X%8.8X\n",
-                       register_value, HIDWORD(acpi_gbl_FADT->Xpm2_cnt_blk.address),
-                       LODWORD(acpi_gbl_FADT->Xpm2_cnt_blk.address)));
-
-               if (read_write == ACPI_WRITE) {
-                       register_value &= ~mask;
-                       value          <<= acpi_hw_get_bit_shift (mask);
-                       value          &= mask;
-                       register_value |= value;
-
-                       ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %04X to %8.8X%8.8X\n",
-                               register_value,
-                               HIDWORD(acpi_gbl_FADT->Xpm2_cnt_blk.address),
-                               LODWORD(acpi_gbl_FADT->Xpm2_cnt_blk.address)));
-
-                       acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK,
-                                          PM2_CONTROL, (u8) (register_value));
-               }
-               break;
-
+                       register_value, ACPI_HIDWORD (acpi_gbl_FADT->Xpm2_cnt_blk.address),
+                       ACPI_LODWORD (acpi_gbl_FADT->Xpm2_cnt_blk.address)));
 
-       case PM_TIMER:
+               ACPI_REGISTER_INSERT_VALUE (register_value, bit_reg_info->bit_position, bit_reg_info->access_bit_mask, value);
 
-               mask = TMR_VAL_MASK;
-               register_value = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK,
-                                PM_TIMER);
-               ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM_TIMER: Read %X from %8.8X%8.8X\n",
+               ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %04X to %8.8X%8.8X\n",
                        register_value,
-                       HIDWORD(acpi_gbl_FADT->Xpm_tmr_blk.address),
-                       LODWORD(acpi_gbl_FADT->Xpm_tmr_blk.address)));
+                       ACPI_HIDWORD (acpi_gbl_FADT->Xpm2_cnt_blk.address),
+                       ACPI_LODWORD (acpi_gbl_FADT->Xpm2_cnt_blk.address)));
 
+               acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK,
+                                  ACPI_REGISTER_PM2_CONTROL, (u8) (register_value));
                break;
 
 
-       case GPE1_EN_BLOCK:
-       case GPE1_STS_BLOCK:
-       case GPE0_EN_BLOCK:
-       case GPE0_STS_BLOCK:
-
-               /* Determine the bit to be accessed
-                *
-                *  (u32) Register_id:
-                *      31      24       16       8        0
-                *      +--------+--------+--------+--------+
-                *      |  gpe_block_id   |  gpe_bit_number |
-                *      +--------+--------+--------+--------+
-                *
-                *     gpe_block_id is one of GPE[01]_EN_BLOCK and GPE[01]_STS_BLOCK
-                *     gpe_bit_number is relative from the gpe_block (0x00~0xFF)
-                */
-               mask = REGISTER_BIT_ID(register_id); /* gpe_bit_number */
-               register_id = REGISTER_BLOCK_ID(register_id) | (mask >> 3);
-               mask = acpi_gbl_decode_to8bit [mask % 8];
-
-               /*
-                * The base address of the GPE 0 Register Block
-                * Plus 1/2 the length of the GPE 0 Register Block
-                * The enable Register is the Register following the Status Register
-                * and each Register is defined as 1/2 of the total Register Block
-                */
-
-               /*
-                * This sets the bit within Enable_bit that needs to be written to
-                * the Register indicated in Mask to a 1, all others are 0
-                */
-
-               /* Now get the current Enable Bits in the selected Reg */
-
-               register_value = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, register_id);
-               ACPI_DEBUG_PRINT ((ACPI_DB_IO, "GPE Enable bits: Read %X from %X\n",
-                       register_value, register_id));
-
-               if (read_write == ACPI_WRITE) {
-                       register_value &= ~mask;
-                       value          <<= acpi_hw_get_bit_shift (mask);
-                       value          &= mask;
-                       register_value |= value;
-
-                       /*
-                        * This write will put the Action state into the General Purpose
-                        * Enable Register indexed by the value in Mask
-                        */
-                       ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %04X to %04X\n",
-                               register_value, register_id));
-                       acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, register_id,
-                               (u8) register_value);
-                       register_value = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK,
-                                          register_id);
-               }
-               break;
-
-
-       case SMI_CMD_BLOCK:
-       case PROCESSOR_BLOCK:
-
-               /* Not used by any callers at this time - therefore, not implemented */
-
        default:
-
-               mask = 0;
                break;
        }
 
-       if (ACPI_MTX_LOCK == use_lock) {
-               acpi_ut_release_mutex (ACPI_MTX_HARDWARE);
+       if (flags & ACPI_MTX_LOCK) {
+               (void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE);
        }
 
+       /* Normalize the value that was read */
 
-       register_value &= mask;
-       register_value >>= acpi_hw_get_bit_shift (mask);
+       register_value = ((register_value & bit_reg_info->access_bit_mask) >> bit_reg_info->bit_position);
 
-       ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Register I/O: returning %X\n", register_value));
+       ACPI_DEBUG_PRINT ((ACPI_DB_IO, "ACPI Register_write actual %X\n", register_value));
        return_VALUE (register_value);
 }
 
@@ -592,79 +422,50 @@ acpi_hw_register_read (
        u32                     bank_offset;
 
 
-       FUNCTION_TRACE ("Hw_register_read");
+       ACPI_FUNCTION_TRACE ("Hw_register_read");
 
 
        if (ACPI_MTX_LOCK == use_lock) {
-               acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE);
+               if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE))) {
+                       return_VALUE (0);
+               }
        }
 
-
-       switch (REGISTER_BLOCK_ID(register_id)) {
-       case PM1_STS: /* 16-bit access */
+       switch (register_id) {
+       case ACPI_REGISTER_PM1_STATUS:           /* 16-bit access */
 
                value =  acpi_hw_low_level_read (16, &acpi_gbl_FADT->Xpm1a_evt_blk, 0);
                value |= acpi_hw_low_level_read (16, &acpi_gbl_FADT->Xpm1b_evt_blk, 0);
                break;
 
 
-       case PM1_EN: /* 16-bit access*/
+       case ACPI_REGISTER_PM1_ENABLE:           /* 16-bit access*/
 
-               bank_offset = DIV_2 (acpi_gbl_FADT->pm1_evt_len);
+               bank_offset = ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len);
                value =  acpi_hw_low_level_read (16, &acpi_gbl_FADT->Xpm1a_evt_blk, bank_offset);
                value |= acpi_hw_low_level_read (16, &acpi_gbl_FADT->Xpm1b_evt_blk, bank_offset);
                break;
 
 
-       case PM1_CONTROL: /* 16-bit access */
+       case ACPI_REGISTER_PM1_CONTROL:          /* 16-bit access */
 
                value =  acpi_hw_low_level_read (16, &acpi_gbl_FADT->Xpm1a_cnt_blk, 0);
                value |= acpi_hw_low_level_read (16, &acpi_gbl_FADT->Xpm1b_cnt_blk, 0);
                break;
 
 
-       case PM2_CONTROL: /* 8-bit access */
+       case ACPI_REGISTER_PM2_CONTROL:          /* 8-bit access */
 
                value =  acpi_hw_low_level_read (8, &acpi_gbl_FADT->Xpm2_cnt_blk, 0);
                break;
 
 
-       case PM_TIMER: /* 32-bit access */
+       case ACPI_REGISTER_PM_TIMER:             /* 32-bit access */
 
                value =  acpi_hw_low_level_read (32, &acpi_gbl_FADT->Xpm_tmr_blk, 0);
                break;
 
-
-       /*
-        * For the GPE? Blocks, the lower word of Register_id contains the
-        * byte offset for which to read, as each part of each block may be
-        * several bytes long.
-        */
-       case GPE0_STS_BLOCK: /* 8-bit access */
-
-               bank_offset = REGISTER_BIT_ID(register_id);
-               value = acpi_hw_low_level_read (8, &acpi_gbl_FADT->Xgpe0blk, bank_offset);
-               break;
-
-       case GPE0_EN_BLOCK: /* 8-bit access */
-
-               bank_offset = DIV_2 (acpi_gbl_FADT->gpe0blk_len) + REGISTER_BIT_ID(register_id);
-               value = acpi_hw_low_level_read (8, &acpi_gbl_FADT->Xgpe0blk, bank_offset);
-               break;
-
-       case GPE1_STS_BLOCK: /* 8-bit access */
-
-               bank_offset = REGISTER_BIT_ID(register_id);
-               value = acpi_hw_low_level_read (8, &acpi_gbl_FADT->Xgpe1_blk, bank_offset);
-               break;
-
-       case GPE1_EN_BLOCK: /* 8-bit access */
-
-               bank_offset = DIV_2 (acpi_gbl_FADT->gpe1_blk_len) + REGISTER_BIT_ID(register_id);
-               value = acpi_hw_low_level_read (8, &acpi_gbl_FADT->Xgpe1_blk, bank_offset);
-               break;
-
-       case SMI_CMD_BLOCK: /* 8bit */
+       case ACPI_REGISTER_SMI_COMMAND_BLOCK:    /* 8-bit access */
 
                acpi_os_read_port (acpi_gbl_FADT->smi_cmd, &value, 8);
                break;
@@ -674,9 +475,8 @@ acpi_hw_register_read (
                break;
        }
 
-
        if (ACPI_MTX_LOCK == use_lock) {
-               acpi_ut_release_mutex (ACPI_MTX_HARDWARE);
+               (void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE);
        }
 
        return_VALUE (value);
@@ -706,93 +506,65 @@ acpi_hw_register_write (
        u32                     bank_offset;
 
 
-       FUNCTION_TRACE ("Hw_register_write");
+       ACPI_FUNCTION_TRACE ("Hw_register_write");
 
 
        if (ACPI_MTX_LOCK == use_lock) {
-               acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE);
+               if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE))) {
+                       return_VOID;
+               }
        }
 
-
-       switch (REGISTER_BLOCK_ID (register_id)) {
-       case PM1_STS: /* 16-bit access */
+       switch (register_id) {
+       case ACPI_REGISTER_PM1_STATUS:           /* 16-bit access */
 
                acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->Xpm1a_evt_blk, 0);
                acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->Xpm1b_evt_blk, 0);
                break;
 
 
-       case PM1_EN: /* 16-bit access*/
+       case ACPI_REGISTER_PM1_ENABLE:           /* 16-bit access*/
 
-               bank_offset = DIV_2 (acpi_gbl_FADT->pm1_evt_len);
+               bank_offset = ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len);
                acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->Xpm1a_evt_blk, bank_offset);
                acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->Xpm1b_evt_blk, bank_offset);
                break;
 
 
-       case PM1_CONTROL: /* 16-bit access */
+       case ACPI_REGISTER_PM1_CONTROL:          /* 16-bit access */
 
                acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->Xpm1a_cnt_blk, 0);
                acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->Xpm1b_cnt_blk, 0);
                break;
 
 
-       case PM1A_CONTROL: /* 16-bit access */
+       case ACPI_REGISTER_PM1A_CONTROL:         /* 16-bit access */
 
                acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->Xpm1a_cnt_blk, 0);
                break;
 
 
-       case PM1B_CONTROL: /* 16-bit access */
+       case ACPI_REGISTER_PM1B_CONTROL:         /* 16-bit access */
 
                acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->Xpm1b_cnt_blk, 0);
                break;
 
 
-       case PM2_CONTROL: /* 8-bit access */
+       case ACPI_REGISTER_PM2_CONTROL:          /* 8-bit access */
 
                acpi_hw_low_level_write (8, value, &acpi_gbl_FADT->Xpm2_cnt_blk, 0);
                break;
 
 
-       case PM_TIMER: /* 32-bit access */
+       case ACPI_REGISTER_PM_TIMER:             /* 32-bit access */
 
                acpi_hw_low_level_write (32, value, &acpi_gbl_FADT->Xpm_tmr_blk, 0);
                break;
 
 
-       case GPE0_STS_BLOCK: /* 8-bit access */
-
-               bank_offset = REGISTER_BIT_ID(register_id);
-               acpi_hw_low_level_write (8, value, &acpi_gbl_FADT->Xgpe0blk, bank_offset);
-               break;
-
-
-       case GPE0_EN_BLOCK: /* 8-bit access */
+       case ACPI_REGISTER_SMI_COMMAND_BLOCK:    /* 8-bit access */
 
-               bank_offset = DIV_2 (acpi_gbl_FADT->gpe0blk_len) + REGISTER_BIT_ID(register_id);
-               acpi_hw_low_level_write (8, value, &acpi_gbl_FADT->Xgpe0blk, bank_offset);
-               break;
-
-
-       case GPE1_STS_BLOCK: /* 8-bit access */
-
-               bank_offset = REGISTER_BIT_ID(register_id);
-               acpi_hw_low_level_write (8, value, &acpi_gbl_FADT->Xgpe1_blk, bank_offset);
-               break;
-
-
-       case GPE1_EN_BLOCK: /* 8-bit access */
-
-               bank_offset = DIV_2 (acpi_gbl_FADT->gpe1_blk_len) + REGISTER_BIT_ID(register_id);
-               acpi_hw_low_level_write (8, value, &acpi_gbl_FADT->Xgpe1_blk, bank_offset);
-               break;
-
-
-       case SMI_CMD_BLOCK: /* 8bit */
-
-               /* For 2.0, SMI_CMD is always in IO space */
-               /* TBD: what about 1.0? 0.71? */
+               /* SMI_CMD is currently always in IO space */
 
                acpi_os_write_port (acpi_gbl_FADT->smi_cmd, value, 8);
                break;
@@ -803,9 +575,8 @@ acpi_hw_register_write (
                break;
        }
 
-
        if (ACPI_MTX_LOCK == use_lock) {
-               acpi_ut_release_mutex (ACPI_MTX_HARDWARE);
+               (void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE);
        }
 
        return_VOID;
@@ -839,7 +610,7 @@ acpi_hw_low_level_read (
        u16                     pci_register;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        /*
@@ -851,7 +622,6 @@ acpi_hw_low_level_read (
                return 0;
        }
 
-
        /*
         * Three address spaces supported:
         * Memory, Io, or PCI config.
@@ -918,7 +688,7 @@ acpi_hw_low_level_write (
        u16                     pci_register;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        /*
@@ -930,7 +700,6 @@ acpi_hw_low_level_write (
                return;
        }
 
-
        /*
         * Three address spaces supported:
         * Memory, Io, or PCI config.
index 16a1cc49b80ec64b9277118f39f160fd8d736af0..d15f3b50fc4b871090035a3ad9f0c3da6007439b 100644 (file)
@@ -2,12 +2,12 @@
 /******************************************************************************
  *
  * Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface
- *              $Revision: 22 $
+ *              $Revision: 35 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -29,7 +29,7 @@
 #include "achware.h"
 
 #define _COMPONENT          ACPI_HARDWARE
-        MODULE_NAME         ("hwsleep")
+        ACPI_MODULE_NAME    ("hwsleep")
 
 
 /******************************************************************************
@@ -39,7 +39,7 @@
  * PARAMETERS:  Physical_address    - Physical address of ACPI real mode
  *                                    entry point.
  *
- * RETURN:      AE_OK or AE_ERROR
+ * RETURN:      Status
  *
  * DESCRIPTION: Access function for d_firmware_waking_vector field in FACS
  *
@@ -50,22 +50,16 @@ acpi_set_firmware_waking_vector (
        ACPI_PHYSICAL_ADDRESS physical_address)
 {
 
-       FUNCTION_TRACE ("Acpi_set_firmware_waking_vector");
-
+       ACPI_FUNCTION_TRACE ("Acpi_set_firmware_waking_vector");
 
-       /* Make sure that we have an FACS */
-
-       if (!acpi_gbl_FACS) {
-               return_ACPI_STATUS (AE_NO_ACPI_TABLES);
-       }
 
        /* Set the vector */
 
-       if (acpi_gbl_FACS->vector_width == 32) {
-               * (u32 *) acpi_gbl_FACS->firmware_waking_vector = (u32) physical_address;
+       if (acpi_gbl_common_fACS.vector_width == 32) {
+               *(u32 *) acpi_gbl_common_fACS.firmware_waking_vector = (u32) physical_address;
        }
        else {
-               *acpi_gbl_FACS->firmware_waking_vector = physical_address;
+               *acpi_gbl_common_fACS.firmware_waking_vector = physical_address;
        }
 
        return_ACPI_STATUS (AE_OK);
@@ -82,7 +76,7 @@ acpi_set_firmware_waking_vector (
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Access function for d_firmware_waking_vector field in FACS
+ * DESCRIPTION: Access function for Firmware_waking_vector field in FACS
  *
  ******************************************************************************/
 
@@ -91,141 +85,177 @@ acpi_get_firmware_waking_vector (
        ACPI_PHYSICAL_ADDRESS *physical_address)
 {
 
-       FUNCTION_TRACE ("Acpi_get_firmware_waking_vector");
+       ACPI_FUNCTION_TRACE ("Acpi_get_firmware_waking_vector");
 
 
        if (!physical_address) {
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
-       /* Make sure that we have an FACS */
-
-       if (!acpi_gbl_FACS) {
-               return_ACPI_STATUS (AE_NO_ACPI_TABLES);
-       }
-
        /* Get the vector */
 
-       if (acpi_gbl_FACS->vector_width == 32) {
-               *physical_address = * (u32 *) acpi_gbl_FACS->firmware_waking_vector;
+       if (acpi_gbl_common_fACS.vector_width == 32) {
+               *physical_address = *(u32 *) acpi_gbl_common_fACS.firmware_waking_vector;
        }
        else {
-               *physical_address = *acpi_gbl_FACS->firmware_waking_vector;
+               *physical_address = *acpi_gbl_common_fACS.firmware_waking_vector;
        }
 
        return_ACPI_STATUS (AE_OK);
 }
 
+
 /******************************************************************************
  *
- * FUNCTION:    Acpi_enter_sleep_state
+ * FUNCTION:    Acpi_enter_sleep_state_prep
  *
  * PARAMETERS:  Sleep_state         - Which sleep state to enter
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Enter a system sleep state (see ACPI 2.0 spec p 231)
+ * DESCRIPTION: Prepare to enter a system sleep state (see ACPI 2.0 spec p 231)
+ *              This function must execute with interrupts enabled.
+ *              We break sleeping into 2 stages so that OSPM can handle
+ *              various OS-specific tasks between the two steps.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_enter_sleep_state (
+acpi_enter_sleep_state_prep (
        u8                  sleep_state)
 {
        acpi_status         status;
        acpi_object_list    arg_list;
        acpi_object         arg;
-       u8                  type_a;
-       u8                  type_b;
-       u16                 PM1Acontrol;
-       u16                 PM1Bcontrol;
 
 
-       FUNCTION_TRACE ("Acpi_enter_sleep_state");
+       ACPI_FUNCTION_TRACE ("Acpi_enter_sleep_state_prep");
 
 
        /*
         * _PSW methods could be run here to enable wake-on keyboard, LAN, etc.
         */
-       status = acpi_hw_obtain_sleep_type_register_data (sleep_state, &type_a, &type_b);
-       if (!ACPI_SUCCESS (status)) {
-               return status;
+       status = acpi_hw_get_sleep_type_data (sleep_state,
+                         &acpi_gbl_sleep_type_a, &acpi_gbl_sleep_type_b);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
        }
 
-       /* run the _PTS and _GTS methods */
+       /* Setup parameter object */
 
-       MEMSET(&arg_list, 0, sizeof(arg_list));
        arg_list.count = 1;
        arg_list.pointer = &arg;
 
-       MEMSET(&arg, 0, sizeof(arg));
        arg.type = ACPI_TYPE_INTEGER;
        arg.integer.value = sleep_state;
 
-       acpi_evaluate_object (NULL, "\\_PTS", &arg_list, NULL);
-       acpi_evaluate_object (NULL, "\\_GTS", &arg_list, NULL);
+       /* Run the _PTS and _GTS methods */
+
+       status = acpi_evaluate_object (NULL, "\\_PTS", &arg_list, NULL);
+       if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) {
+               return_ACPI_STATUS (status);
+       }
+
+       status = acpi_evaluate_object (NULL, "\\_GTS", &arg_list, NULL);
+       if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) {
+               return_ACPI_STATUS (status);
+       }
+
+       return_ACPI_STATUS (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION:    Acpi_enter_sleep_state
+ *
+ * PARAMETERS:  Sleep_state         - Which sleep state to enter
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Enter a system sleep state (see ACPI 2.0 spec p 231)
+ *              THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_enter_sleep_state (
+       u8                      sleep_state)
+{
+       u16                     PM1Acontrol;
+       u16                     PM1Bcontrol;
+       ACPI_BIT_REGISTER_INFO  *sleep_type_reg_info;
+       ACPI_BIT_REGISTER_INFO  *sleep_enable_reg_info;
+
+
+       ACPI_FUNCTION_TRACE ("Acpi_enter_sleep_state");
+
+
+       if ((acpi_gbl_sleep_type_a > ACPI_SLEEP_TYPE_MAX) ||
+               (acpi_gbl_sleep_type_b > ACPI_SLEEP_TYPE_MAX)) {
+               ACPI_REPORT_ERROR (("Sleep values out of range: A=%x B=%x\n",
+                       acpi_gbl_sleep_type_a, acpi_gbl_sleep_type_b));
+               return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
+       }
+
 
-       /* clear wake status */
+       sleep_type_reg_info = acpi_hw_get_bit_register_info (ACPI_BITREG_SLEEP_TYPE_A);
+       sleep_enable_reg_info = acpi_hw_get_bit_register_info (ACPI_BITREG_SLEEP_ENABLE);
 
-       acpi_hw_register_bit_access (ACPI_WRITE, ACPI_MTX_LOCK, WAK_STS, 1);
+       /* Clear wake status */
 
-       disable ();
+       acpi_hw_bit_register_write (ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_LOCK);
+       acpi_hw_clear_acpi_status();
+
+       /* TBD: Disable arbitration here? */
 
        acpi_hw_disable_non_wakeup_gpes();
 
-       PM1Acontrol = (u16) acpi_hw_register_read (ACPI_MTX_LOCK, PM1_CONTROL);
+       /* Get current value of PM1A control */
 
+       PM1Acontrol = (u16) acpi_hw_register_read (ACPI_MTX_LOCK, ACPI_REGISTER_PM1_CONTROL);
        ACPI_DEBUG_PRINT ((ACPI_DB_OK, "Entering S%d\n", sleep_state));
 
-       /* mask off SLP_EN and SLP_TYP fields */
+       /* Clear SLP_EN and SLP_TYP fields */
 
-       PM1Acontrol &= ~(SLP_TYPE_X_MASK | SLP_EN_MASK);
+       PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask | sleep_enable_reg_info->access_bit_mask);
        PM1Bcontrol = PM1Acontrol;
 
-       /* mask in SLP_TYP */
-
-       PM1Acontrol |= (type_a << acpi_hw_get_bit_shift (SLP_TYPE_X_MASK));
-       PM1Bcontrol |= (type_b << acpi_hw_get_bit_shift (SLP_TYPE_X_MASK));
+       /* Insert SLP_TYP bits */
 
-       /* write #1: fill in SLP_TYP data */
+       PM1Acontrol |= (acpi_gbl_sleep_type_a << sleep_type_reg_info->bit_position);
+       PM1Bcontrol |= (acpi_gbl_sleep_type_b << sleep_type_reg_info->bit_position);
 
-       acpi_hw_register_write (ACPI_MTX_LOCK, PM1A_CONTROL, PM1Acontrol);
-       acpi_hw_register_write (ACPI_MTX_LOCK, PM1B_CONTROL, PM1Bcontrol);
+       /* Write #1: fill in SLP_TYP data */
 
-       /* mask in SLP_EN */
+       acpi_hw_register_write (ACPI_MTX_LOCK, ACPI_REGISTER_PM1A_CONTROL, PM1Acontrol);
+       acpi_hw_register_write (ACPI_MTX_LOCK, ACPI_REGISTER_PM1B_CONTROL, PM1Bcontrol);
 
-       PM1Acontrol |= (1 << acpi_hw_get_bit_shift (SLP_EN_MASK));
-       PM1Bcontrol |= (1 << acpi_hw_get_bit_shift (SLP_EN_MASK));
+       /* Insert SLP_ENABLE bit */
 
-       /* flush caches */
+       PM1Acontrol |= sleep_enable_reg_info->access_bit_mask;
+       PM1Bcontrol |= sleep_enable_reg_info->access_bit_mask;
 
-       wbinvd();
+       /* Write #2: SLP_TYP + SLP_EN */
 
-       /* write #2: SLP_TYP + SLP_EN */
-
-       acpi_hw_register_write (ACPI_MTX_LOCK, PM1A_CONTROL, PM1Acontrol);
-       acpi_hw_register_write (ACPI_MTX_LOCK, PM1B_CONTROL, PM1Bcontrol);
+       acpi_hw_register_write (ACPI_MTX_LOCK, ACPI_REGISTER_PM1A_CONTROL, PM1Acontrol);
+       acpi_hw_register_write (ACPI_MTX_LOCK, ACPI_REGISTER_PM1B_CONTROL, PM1Bcontrol);
 
        /*
         * Wait a second, then try again. This is to get S4/5 to work on all machines.
         */
        if (sleep_state > ACPI_STATE_S3) {
-               acpi_os_stall(1000000);
+               acpi_os_stall (1000000);
 
-               acpi_hw_register_write (ACPI_MTX_LOCK, PM1_CONTROL,
-                       (1 << acpi_hw_get_bit_shift (SLP_EN_MASK)));
+               acpi_hw_register_write (ACPI_MTX_LOCK, ACPI_REGISTER_PM1_CONTROL,
+                               sleep_enable_reg_info->access_bit_mask);
        }
 
-       /* wait until we enter sleep state */
+       /* Wait until we enter sleep state */
 
-       do {
-               acpi_os_stall(10000);
+       while (!acpi_hw_bit_register_read (ACPI_BITREG_WAKE_STATUS, ACPI_MTX_LOCK)) {
+               /* Spin until we wake */
        }
-       while (!acpi_hw_register_bit_access (ACPI_READ, ACPI_MTX_LOCK, WAK_STS));
-
-       acpi_hw_enable_non_wakeup_gpes();
-
-       enable ();
 
        return_ACPI_STATUS (AE_OK);
 }
@@ -248,21 +278,35 @@ acpi_leave_sleep_state (
 {
        acpi_object_list    arg_list;
        acpi_object         arg;
+       acpi_status         status;
 
 
-       FUNCTION_TRACE ("Acpi_leave_sleep_state");
+       ACPI_FUNCTION_TRACE ("Acpi_leave_sleep_state");
 
 
-       MEMSET (&arg_list, 0, sizeof(arg_list));
+       /* Ensure Enter_sleep_state_prep -> Enter_sleep_state ordering */
+
+       acpi_gbl_sleep_type_a = ACPI_SLEEP_TYPE_INVALID;
+
+       /* Setup parameter object */
+
        arg_list.count = 1;
        arg_list.pointer = &arg;
 
-       MEMSET (&arg, 0, sizeof(arg));
        arg.type = ACPI_TYPE_INTEGER;
        arg.integer.value = sleep_state;
 
-       acpi_evaluate_object (NULL, "\\_BFS", &arg_list, NULL);
-       acpi_evaluate_object (NULL, "\\_WAK", &arg_list, NULL);
+       /* Ignore any errors from these methods */
+
+       status = acpi_evaluate_object (NULL, "\\_BFS", &arg_list, NULL);
+       if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) {
+               ACPI_REPORT_ERROR (("Method _BFS failed, %s\n", acpi_format_exception (status)));
+       }
+
+       status = acpi_evaluate_object (NULL, "\\_WAK", &arg_list, NULL);
+       if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) {
+               ACPI_REPORT_ERROR (("Method _WAK failed, %s\n", acpi_format_exception (status)));
+       }
 
        /* _WAK returns stuff - do we want to look at it? */
 
index ea82bc51136448d09b9e1653b35abf27af0556b9..7f1efef60ebb5c683e27c29c54aebe1953bd0062 100644 (file)
@@ -2,12 +2,12 @@
 /******************************************************************************
  *
  * Name: hwtimer.c - ACPI Power Management Timer Interface
- *              $Revision: 14 $
+ *              $Revision: 19 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -28,7 +28,7 @@
 #include "achware.h"
 
 #define _COMPONENT          ACPI_HARDWARE
-        MODULE_NAME         ("hwtimer")
+        ACPI_MODULE_NAME    ("hwtimer")
 
 
 /******************************************************************************
@@ -47,7 +47,7 @@ acpi_status
 acpi_get_timer_resolution (
        u32                     *resolution)
 {
-       FUNCTION_TRACE ("Acpi_get_timer_resolution");
+       ACPI_FUNCTION_TRACE ("Acpi_get_timer_resolution");
 
 
        if (!resolution) {
@@ -57,7 +57,6 @@ acpi_get_timer_resolution (
        if (0 == acpi_gbl_FADT->tmr_val_ext) {
                *resolution = 24;
        }
-
        else {
                *resolution = 32;
        }
@@ -82,7 +81,7 @@ acpi_status
 acpi_get_timer (
        u32                     *ticks)
 {
-       FUNCTION_TRACE ("Acpi_get_timer");
+       ACPI_FUNCTION_TRACE ("Acpi_get_timer");
 
 
        if (!ticks) {
@@ -129,13 +128,12 @@ acpi_get_timer_duration (
        u32                     *time_elapsed)
 {
        u32                     delta_ticks = 0;
-       u32                     seconds = 0;
-       u32                     milliseconds = 0;
-       u32                     microseconds = 0;
-       u32                     remainder = 0;
+       uint64_overlay          normalized_ticks;
+       acpi_status             status;
+       acpi_integer            out_quotient;
 
 
-       FUNCTION_TRACE ("Acpi_get_timer_duration");
+       ACPI_FUNCTION_TRACE ("Acpi_get_timer_duration");
 
 
        if (!time_elapsed) {
@@ -150,21 +148,18 @@ acpi_get_timer_duration (
        if (start_ticks < end_ticks) {
                delta_ticks = end_ticks - start_ticks;
        }
-
        else if (start_ticks > end_ticks) {
-               /* 24-bit Timer */
-
                if (0 == acpi_gbl_FADT->tmr_val_ext) {
+                       /* 24-bit Timer */
+
                        delta_ticks = (((0x00FFFFFF - start_ticks) + end_ticks) & 0x00FFFFFF);
                }
-
-               /* 32-bit Timer */
-
                else {
+                       /* 32-bit Timer */
+
                        delta_ticks = (0xFFFFFFFF - start_ticks) + end_ticks;
                }
        }
-
        else {
                *time_elapsed = 0;
                return_ACPI_STATUS (AE_OK);
@@ -173,49 +168,18 @@ acpi_get_timer_duration (
        /*
         * Compute Duration:
         * -----------------
-        * Since certain compilers (gcc/Linux, argh!) don't support 64-bit
-        * divides in kernel-space we have to do some trickery to preserve
-        * accuracy while using 32-bit math.
-        *
-        * TBD: Change to use 64-bit math when supported.
         *
-        * The process is as follows:
-        *  1. Compute the number of seconds by dividing Delta Ticks by
-        *     the timer frequency.
-        *  2. Compute the number of milliseconds in the remainder from step #1
-        *     by multiplying by 1000 and then dividing by the timer frequency.
-        *  3. Compute the number of microseconds in the remainder from step #2
-        *     by multiplying by 1000 and then dividing by the timer frequency.
-        *  4. Add the results from steps 1, 2, and 3 to get the total duration.
+        * Requires a 64-bit divide:
         *
-        * Example: The time elapsed for Delta_ticks = 0xFFFFFFFF should be
-        *          1199864031 microseconds.  This is computed as follows:
-        *          Step #1: Seconds = 1199; Remainder = 3092840
-        *          Step #2: Milliseconds = 864; Remainder = 113120
-        *          Step #3: Microseconds = 31; Remainder = <don't care!>
+        * Time_elapsed = (Delta_ticks * 1000000) / PM_TIMER_FREQUENCY;
         */
+       normalized_ticks.full = ((u64) delta_ticks) * 1000000;
 
-       /* Step #1 */
+       status = acpi_ut_short_divide (&normalized_ticks.full, PM_TIMER_FREQUENCY,
+                          &out_quotient, NULL);
 
-       seconds = delta_ticks / PM_TIMER_FREQUENCY;
-       remainder = delta_ticks % PM_TIMER_FREQUENCY;
-
-       /* Step #2 */
-
-       milliseconds = (remainder * 1000) / PM_TIMER_FREQUENCY;
-       remainder = (remainder * 1000) % PM_TIMER_FREQUENCY;
-
-       /* Step #3 */
-
-       microseconds = (remainder * 1000) / PM_TIMER_FREQUENCY;
-
-       /* Step #4 */
-
-       *time_elapsed = seconds * 1000000;
-       *time_elapsed += milliseconds * 1000;
-       *time_elapsed += microseconds;
-
-       return_ACPI_STATUS (AE_OK);
+       *time_elapsed = (u32) out_quotient;
+       return_ACPI_STATUS (status);
 }
 
 
index 081c10fb34cc3e8f76411197b3a7d68833dd2a2a..363bc6f6d8df4c0dfa35366b30c4adc92eea2c3a 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Name: acconfig.h - Global configuration constants
- *       $Revision: 74 $
+ *       $Revision: 94 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *****************************************************************************/
 
 /*
- * ACPI_DEBUG           - This switch enables all the debug facilities of the ACPI
- *                          subsystem.  This includes the DEBUG_PRINT output statements
- *                          When disabled, all DEBUG_PRINT statements are compiled out.
+ * ACPI_DEBUG           - This switch enables all the debug facilities of the
+ *                        ACPI subsystem.  This includes the DEBUG_PRINT output
+ *                        statements.  When disabled, all DEBUG_PRINT
+ *                        statements are compiled out.
  *
  * ACPI_APPLICATION     - Use this switch if the subsystem is going to be run
- *                          at the application level.
+ *                        at the application level.
  *
  */
 
 
 /* Version string */
 
-#define ACPI_CA_VERSION             0x20011018
+#define ACPI_CA_VERSION             0x20020308
 
 /* Version of ACPI supported */
 
 #define ACPI_CA_SUPPORT_LEVEL       2
 
-
 /* Maximum objects in the various object caches */
 
-#define MAX_STATE_CACHE_DEPTH       64         /* State objects for stacks */
+#define MAX_STATE_CACHE_DEPTH       64          /* State objects for stacks */
 #define MAX_PARSE_CACHE_DEPTH       96          /* Parse tree objects */
 #define MAX_EXTPARSE_CACHE_DEPTH    64          /* Parse tree objects */
 #define MAX_OBJECT_CACHE_DEPTH      64          /* Interpreter operand objects */
-#define MAX_WALK_CACHE_DEPTH        4           /* Objects for parse tree walks (method execution) */
-
+#define MAX_WALK_CACHE_DEPTH        4           /* Objects for parse tree walks */
 
 /* String size constants */
 
 #define MAX_STRING_LENGTH           512
-#define PATHNAME_MAX                256     /* A full namespace pathname */
-
+#define PATHNAME_MAX                256         /* A full namespace pathname */
 
 /* Maximum count for a semaphore object */
 
 #define MAX_SEMAPHORE_COUNT         256
 
-
 /* Max reference count (for debug only) */
 
 #define MAX_REFERENCE_COUNT         0x400
 
-
 /* Size of cached memory mapping for system memory operation region */
 
 #define SYSMEM_REGION_WINDOW_SIZE   4096
 
 
+/******************************************************************************
+ *
+ * Configuration of subsystem behavior
+ *
+ *****************************************************************************/
+
 /*
  * Debugger threading model
  * Use single threaded if the entire subsystem is contained in an application
  * By default the model is single threaded if ACPI_APPLICATION is set,
  * multi-threaded if ACPI_APPLICATION is not set.
  */
-
 #define DEBUGGER_SINGLE_THREADED    0
 #define DEBUGGER_MULTI_THREADED     1
 
 #define DEBUGGER_THREADING          DEBUGGER_MULTI_THREADED
 #endif
 
+/*
+ * Should the subystem abort the loading of an ACPI table if the
+ * table checksum is incorrect?
+ */
+#define ACPI_CHECKSUM_ABORT         FALSE
+
 
 /******************************************************************************
  *
  *
  *****************************************************************************/
 
+/* Number of distinct GPE register blocks */
+
+#define ACPI_MAX_GPE_BLOCKS         2
+
 /*
  * Method info (in WALK_STATE), containing local variables and argumetns
  */
-
 #define MTH_NUM_LOCALS              8
 #define MTH_MAX_LOCAL               7
 
 /*
  * Operand Stack (in WALK_STATE), Must be large enough to contain MTH_MAX_ARG
  */
-
 #define OBJ_NUM_OPERANDS            8
 #define OBJ_MAX_OPERAND             7
 
 /* Names within the namespace are 4 bytes long */
 
 #define ACPI_NAME_SIZE              4
-#define PATH_SEGMENT_LENGTH         5           /* 4 chars for name + 1 s8 for separator */
+#define PATH_SEGMENT_LENGTH         5           /* 4 chars for name + 1 char for separator */
 #define PATH_SEPARATOR              '.'
 
-
 /* Constants used in searching for the RSDP in low memory */
 
 #define LO_RSDP_WINDOW_BASE         0           /* Physical Address */
 #define HI_RSDP_WINDOW_SIZE         0x20000
 #define RSDP_SCAN_STEP              16
 
+/* Operation regions */
+
+#define ACPI_NUM_PREDEFINED_REGIONS 8
+#define ACPI_USER_REGION_BEGIN      0x80
+
 /* Maximum Space_ids for Operation Regions */
 
 #define ACPI_MAX_ADDRESS_SPACE      255
-#define ACPI_NUM_ADDRESS_SPACES     256
+
+/* RSDP checksums */
+
+#define ACPI_RSDP_CHECKSUM_LENGTH   20
+#define ACPI_RSDP_XCHECKSUM_LENGTH  36
+
+
+/******************************************************************************
+ *
+ * ACPI AML Debugger
+ *
+ *****************************************************************************/
+
+
+#define ACPI_DEBUGGER_MAX_ARGS             8  /* Must be max method args + 1 */
+
+#define ACPI_DEBUGGER_COMMAND_PROMPT      '-'
+#define ACPI_DEBUGGER_EXECUTE_PROMPT      '%'
 
 
 #endif /* _ACCONFIG_H */
index 0f28380dc66083c91a4ee44272a279f1863914e2..d3cc056fe62e095bcffa3b00580fd341718d2529 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Name: acdebug.h - ACPI/AML debugger
- *       $Revision: 50 $
+ *       $Revision: 57 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 #define __ACDEBUG_H__
 
 
-#define DB_MAX_ARGS             8  /* Must be max method args + 1 */
-
-#define DB_COMMAND_PROMPT      '-'
-#define DB_EXECUTE_PROMPT      '%'
-
-
-extern int                      optind;
-extern NATIVE_CHAR              *optarg;
-extern u8                       *aml_start;
-extern u32                      aml_length;
-
-extern u8                       acpi_gbl_db_opt_tables;
-extern u8                       acpi_gbl_db_opt_disasm;
-extern u8                       acpi_gbl_db_opt_stats;
-extern u8                       acpi_gbl_db_opt_parse_jit;
-extern u8                       acpi_gbl_db_opt_verbose;
-extern u8                       acpi_gbl_db_opt_ini_methods;
-
-
-extern NATIVE_CHAR              *acpi_gbl_db_args[DB_MAX_ARGS];
-extern NATIVE_CHAR              acpi_gbl_db_line_buf[80];
-extern NATIVE_CHAR              acpi_gbl_db_scope_buf[40];
-extern NATIVE_CHAR              acpi_gbl_db_debug_filename[40];
-extern u8                       acpi_gbl_db_output_to_file;
-extern NATIVE_CHAR              *acpi_gbl_db_buffer;
-extern NATIVE_CHAR              *acpi_gbl_db_filename;
-extern NATIVE_CHAR              *acpi_gbl_db_disasm_indent;
-extern u8                       acpi_gbl_db_output_flags;
-extern u32                      acpi_gbl_db_debug_level;
-extern u32                      acpi_gbl_db_console_debug_level;
-extern acpi_table_header        *acpi_gbl_db_table_ptr;
-
-/*
- * Statistic globals
- */
-extern u16                      acpi_gbl_obj_type_count[INTERNAL_TYPE_NODE_MAX+1];
-extern u16                      acpi_gbl_node_type_count[INTERNAL_TYPE_NODE_MAX+1];
-extern u16                      acpi_gbl_obj_type_count_misc;
-extern u16                      acpi_gbl_node_type_count_misc;
-extern u32                      acpi_gbl_num_nodes;
-extern u32                      acpi_gbl_num_objects;
-
-
-extern u32                      acpi_gbl_size_of_parse_tree;
-extern u32                      acpi_gbl_size_of_method_trees;
-extern u32                      acpi_gbl_size_of_node_entries;
-extern u32                      acpi_gbl_size_of_acpi_objects;
-
-
 #define ACPI_DEBUG_BUFFER_SIZE  4196
 
-#define DB_REDIRECTABLE_OUTPUT  0x01
-#define DB_CONSOLE_OUTPUT       0x02
-#define DB_DUPLICATE_OUTPUT     0x03
-
 
 typedef struct command_info
 {
@@ -306,7 +253,7 @@ acpi_db_create_execution_threads (
  * dbfileio - Debugger file I/O commands
  */
 
-acpi_object_type8
+acpi_object_type
 acpi_db_match_argument (
        NATIVE_CHAR             *user_argument,
        ARGUMENT_INFO           *arguments);
@@ -351,7 +298,7 @@ acpi_db_command_dispatch (
        acpi_walk_state         *walk_state,
        acpi_parse_object       *op);
 
-void
+void ACPI_SYSTEM_XFACE
 acpi_db_execute_thread (
        void                    *context);
 
index e89e1fb6d90bcd88289c9131ca35f622415ec674..828b38f7b4d394acc6ae562e5076f07a9f4f181b 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Name: acdispat.h - dispatcher (parser to interpreter interface)
- *       $Revision: 45 $
+ *       $Revision: 51 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -86,7 +86,7 @@ acpi_ds_exec_end_control_op (
 acpi_status
 acpi_ds_get_predicate_value (
        acpi_walk_state         *walk_state,
-       u32                     has_result_obj);
+       acpi_operand_object     *result_obj);
 
 acpi_status
 acpi_ds_exec_begin_op (
@@ -123,6 +123,11 @@ acpi_ds_create_buffer_field (
        acpi_parse_object       *op,
        acpi_walk_state         *walk_state);
 
+acpi_status
+acpi_ds_init_field_objects (
+       acpi_parse_object       *op,
+       acpi_walk_state         *walk_state);
+
 
 /* dsload - Parser/Interpreter interface, namespace load callbacks */
 
@@ -175,7 +180,7 @@ u8
 acpi_ds_is_method_value (
        acpi_operand_object     *obj_desc);
 
-acpi_object_type8
+acpi_object_type
 acpi_ds_method_data_get_type (
        u16                     opcode,
        u32                     index,
@@ -200,18 +205,19 @@ acpi_ds_method_data_init_args (
        u32                     max_param_count,
        acpi_walk_state         *walk_state);
 
-acpi_namespace_node *
+acpi_status
 acpi_ds_method_data_get_node (
        u16                     opcode,
        u32                     index,
-       acpi_walk_state         *walk_state);
+       acpi_walk_state         *walk_state,
+       acpi_namespace_node     **node);
 
 acpi_status
 acpi_ds_method_data_init (
        acpi_walk_state         *walk_state);
 
 acpi_status
-acpi_ds_method_data_set_entry (
+acpi_ds_method_data_set_value (
        u16                     opcode,
        u32                     index,
        acpi_operand_object     *object,
@@ -226,7 +232,7 @@ acpi_ds_parse_method (
 
 acpi_status
 acpi_ds_call_control_method (
-       acpi_walk_list          *walk_list,
+       ACPI_THREAD_STATE       *thread,
        acpi_walk_state         *walk_state,
        acpi_parse_object       *op);
 
@@ -331,15 +337,6 @@ acpi_status
 acpi_ds_resolve_operands (
        acpi_walk_state         *walk_state);
 
-acpi_object_type8
-acpi_ds_map_opcode_to_data_type (
-       u16                     opcode,
-       u32                     *out_flags);
-
-acpi_object_type8
-acpi_ds_map_named_opcode_to_data_type (
-       u16                     opcode);
-
 
 /*
  * dswscope - Scope Stack manipulation
@@ -348,7 +345,7 @@ acpi_ds_map_named_opcode_to_data_type (
 acpi_status
 acpi_ds_scope_stack_push (
        acpi_namespace_node     *node,
-       acpi_object_type8       type,
+       acpi_object_type        type,
        acpi_walk_state         *walk_state);
 
 
@@ -368,7 +365,7 @@ acpi_ds_create_walk_state (
        acpi_owner_id           owner_id,
        acpi_parse_object       *origin,
        acpi_operand_object     *mth_desc,
-       acpi_walk_list          *walk_list);
+       ACPI_THREAD_STATE       *thread);
 
 acpi_status
 acpi_ds_init_aml_walk (
@@ -396,12 +393,12 @@ acpi_ds_delete_walk_state (
 
 acpi_walk_state *
 acpi_ds_pop_walk_state (
-       acpi_walk_list          *walk_list);
+       ACPI_THREAD_STATE       *thread);
 
 void
 acpi_ds_push_walk_state (
        acpi_walk_state         *walk_state,
-       acpi_walk_list          *walk_list);
+       ACPI_THREAD_STATE       *thread);
 
 acpi_status
 acpi_ds_result_stack_pop (
@@ -417,7 +414,7 @@ acpi_ds_result_stack_clear (
 
 acpi_walk_state *
 acpi_ds_get_current_walk_state (
-       acpi_walk_list          *walk_list);
+       ACPI_THREAD_STATE       *thread);
 
 void
 acpi_ds_delete_walk_state_cache (
index 8e86c8cd0acab00ddc7a6aa927c6e77f30c050bb..92053b56bc8af22c7543929d87dde7612c4cd5f7 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Name: acevents.h - Event subcomponent prototypes and defines
- *       $Revision: 66 $
+ *       $Revision: 75 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -31,9 +31,13 @@ acpi_status
 acpi_ev_initialize (
        void);
 
+acpi_status
+acpi_ev_handler_initialize (
+       void);
+
 
 /*
- * Acpi_evfixed - Fixed event handling
+ * Evfixed - Fixed event handling
  */
 
 acpi_status
@@ -46,16 +50,16 @@ acpi_ev_fixed_event_detect (
 
 u32
 acpi_ev_fixed_event_dispatch (
-       u32                     acpi_event);
+       u32                     event);
 
 
 /*
- * Acpi_evglock - Global Lock support
+ * Evmisc
  */
 
 acpi_status
 acpi_ev_acquire_global_lock(
-       void);
+       u32                     timeout);
 
 void
 acpi_ev_release_global_lock(
@@ -65,9 +69,26 @@ acpi_status
 acpi_ev_init_global_lock_handler (
        void);
 
+u32
+acpi_ev_get_gpe_register_index (
+       u32                     gpe_number);
+
+u32
+acpi_ev_get_gpe_number_index (
+       u32                     gpe_number);
+
+acpi_status
+acpi_ev_queue_notify_request (
+       acpi_namespace_node     *node,
+       u32                     notify_value);
+
+void ACPI_SYSTEM_XFACE
+acpi_ev_notify_dispatch (
+       void                    *context);
+
 
 /*
- * Acpi_evgpe - GPE handling and dispatch
+ * Evgpe - GPE handling and dispatch
  */
 
 acpi_status
@@ -86,22 +107,8 @@ u32
 acpi_ev_gpe_detect (
        void);
 
-
-/*
- * Acpi_evnotify - Device Notify handling and dispatch
- */
-
-acpi_status
-acpi_ev_queue_notify_request (
-       acpi_namespace_node     *node,
-       u32                     notify_value);
-
-void
-acpi_ev_notify_dispatch (
-       void                    *context);
-
 /*
- * Acpi_evregion - Address Space handling
+ * Evregion - Address Space handling
  */
 
 acpi_status
@@ -114,8 +121,7 @@ acpi_ev_address_space_dispatch (
        u32                     function,
        ACPI_PHYSICAL_ADDRESS   address,
        u32                     bit_width,
-       u32                     *value);
-
+       acpi_integer            *value);
 
 acpi_status
 acpi_ev_addr_handler_helper (
@@ -129,7 +135,6 @@ acpi_ev_disassociate_region_from_handler(
        acpi_operand_object    *region_obj,
        u8                      acpi_ns_is_locked);
 
-
 acpi_status
 acpi_ev_associate_region_and_handler (
        acpi_operand_object     *handler_obj,
@@ -138,7 +143,7 @@ acpi_ev_associate_region_and_handler (
 
 
 /*
- * Acpi_evregini - Region initialization and setup
+ * Evregini - Region initialization and setup
  */
 
 acpi_status
@@ -205,10 +210,6 @@ u32
 acpi_ev_initialize_sCI (
        u32                     program_sCI);
 
-void
-acpi_ev_restore_acpi_state (
-       void);
-
 void
 acpi_ev_terminate (
        void);
index 2020e45cd627cc5feee1a0b7286a36663e9408e3..3731a9fdc4967bc45a0abdde4e4733eaff4fa2f7 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Name: acexcep.h - Exception codes returned by the ACPI subsystem
- *       $Revision: 50 $
+ *       $Revision: 57 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -54,7 +54,7 @@
 #define AE_NO_MEMORY                    (acpi_status) (0x0004 | AE_CODE_ENVIRONMENTAL)
 #define AE_NOT_FOUND                    (acpi_status) (0x0005 | AE_CODE_ENVIRONMENTAL)
 #define AE_NOT_EXIST                    (acpi_status) (0x0006 | AE_CODE_ENVIRONMENTAL)
-#define AE_EXIST                        (acpi_status) (0x0007 | AE_CODE_ENVIRONMENTAL)
+#define AE_ALREADY_EXISTS               (acpi_status) (0x0007 | AE_CODE_ENVIRONMENTAL)
 #define AE_TYPE                         (acpi_status) (0x0008 | AE_CODE_ENVIRONMENTAL)
 #define AE_NULL_OBJECT                  (acpi_status) (0x0009 | AE_CODE_ENVIRONMENTAL)
 #define AE_NULL_ENTRY                   (acpi_status) (0x000A | AE_CODE_ENVIRONMENTAL)
@@ -85,8 +85,9 @@
 #define AE_BAD_PATHNAME                 (acpi_status) (0x0003 | AE_CODE_PROGRAMMER)
 #define AE_BAD_DATA                     (acpi_status) (0x0004 | AE_CODE_PROGRAMMER)
 #define AE_BAD_ADDRESS                  (acpi_status) (0x0005 | AE_CODE_PROGRAMMER)
+#define AE_ALIGNMENT                    (acpi_status) (0x0006 | AE_CODE_PROGRAMMER)
 
-#define AE_CODE_PGM_MAX                 0x0005
+#define AE_CODE_PGM_MAX                 0x0006
 
 
 /*
@@ -96,8 +97,9 @@
 #define AE_BAD_HEADER                   (acpi_status) (0x0002 | AE_CODE_ACPI_TABLES)
 #define AE_BAD_CHECKSUM                 (acpi_status) (0x0003 | AE_CODE_ACPI_TABLES)
 #define AE_BAD_VALUE                    (acpi_status) (0x0004 | AE_CODE_ACPI_TABLES)
+#define AE_TABLE_NOT_SUPPORTED          (acpi_status) (0x0005 | AE_CODE_ACPI_TABLES)
 
-#define AE_CODE_TBL_MAX                 0x0003
+#define AE_CODE_TBL_MAX                 0x0005
 
 
 /*
 #define AE_AML_MUTEX_ORDER              (acpi_status) (0x0017 | AE_CODE_AML)
 #define AE_AML_MUTEX_NOT_ACQUIRED       (acpi_status) (0x0018 | AE_CODE_AML)
 #define AE_AML_INVALID_RESOURCE_TYPE    (acpi_status) (0x0019 | AE_CODE_AML)
+#define AE_AML_INVALID_INDEX            (acpi_status) (0x001A | AE_CODE_AML)
+#define AE_AML_REGISTER_LIMIT           (acpi_status) (0x001B | AE_CODE_AML)
+#define AE_AML_NO_WHILE                 (acpi_status) (0x001C | AE_CODE_AML)
 
-#define AE_CODE_AML_MAX                 0x0019
+#define AE_CODE_AML_MAX                 0x001C
 
 /*
  * Internal exceptions used for control
 #define AE_CTRL_DEPTH                   (acpi_status) (0x0006 | AE_CODE_CONTROL)
 #define AE_CTRL_END                     (acpi_status) (0x0007 | AE_CODE_CONTROL)
 #define AE_CTRL_TRANSFER                (acpi_status) (0x0008 | AE_CODE_CONTROL)
+#define AE_CTRL_BREAK                   (acpi_status) (0x0009 | AE_CODE_CONTROL)
+#define AE_CTRL_CONTINUE                (acpi_status) (0x000A | AE_CODE_CONTROL)
 
-#define AE_CODE_CTRL_MAX                0x0008
+#define AE_CODE_CTRL_MAX                0x000A
 
 
 #ifdef DEFINE_ACPI_GLOBALS
@@ -162,7 +169,7 @@ NATIVE_CHAR const   *acpi_gbl_exception_names_env[] =
        "AE_NO_MEMORY",
        "AE_NOT_FOUND",
        "AE_NOT_EXIST",
-       "AE_EXIST",
+       "AE_ALREADY_EXISTS",
        "AE_TYPE",
        "AE_NULL_OBJECT",
        "AE_NULL_ENTRY",
@@ -181,7 +188,7 @@ NATIVE_CHAR const   *acpi_gbl_exception_names_env[] =
        "AE_NOT_ACQUIRED",
        "AE_ALREADY_ACQUIRED",
        "AE_NO_HARDWARE_RESPONSE",
-       "AE_NO_GLOBAL_LOCK",
+       "AE_NO_GLOBAL_LOCK"
 };
 
 NATIVE_CHAR const   *acpi_gbl_exception_names_pgm[] =
@@ -191,6 +198,7 @@ NATIVE_CHAR const   *acpi_gbl_exception_names_pgm[] =
        "AE_BAD_PATHNAME",
        "AE_BAD_DATA",
        "AE_BAD_ADDRESS",
+       "AE_ALIGNMENT"
 };
 
 NATIVE_CHAR const   *acpi_gbl_exception_names_tbl[] =
@@ -199,6 +207,7 @@ NATIVE_CHAR const   *acpi_gbl_exception_names_tbl[] =
        "AE_BAD_HEADER",
        "AE_BAD_CHECKSUM",
        "AE_BAD_VALUE",
+       "AE_TABLE_NOT_SUPPORTED"
 };
 
 NATIVE_CHAR const   *acpi_gbl_exception_names_aml[] =
@@ -228,6 +237,9 @@ NATIVE_CHAR const   *acpi_gbl_exception_names_aml[] =
        "AE_AML_MUTEX_ORDER",
        "AE_AML_MUTEX_NOT_ACQUIRED",
        "AE_AML_INVALID_RESOURCE_TYPE",
+       "AE_AML_INVALID_INDEX",
+       "AE_AML_REGISTER_LIMIT",
+       "AE_AML_NO_WHILE"
 };
 
 NATIVE_CHAR const   *acpi_gbl_exception_names_ctrl[] =
@@ -240,6 +252,8 @@ NATIVE_CHAR const   *acpi_gbl_exception_names_ctrl[] =
        "AE_CTRL_DEPTH",
        "AE_CTRL_END",
        "AE_CTRL_TRANSFER",
+       "AE_CTRL_BREAK",
+       "AE_CTRL_CONTINUE"
 };
 
 #endif /* ACPI GLOBALS */
index 6d326dff9d4f9bae51124c3272bd285218b2a0d3..63565be7772f81d37e23d5a453514a88dfaf3b72 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Name: acglobal.h - Declarations for global variables
- *       $Revision: 106 $
+ *       $Revision: 120 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -71,11 +71,12 @@ extern      u32                         acpi_gbl_nesting_level;
  * of each in the system.  Each global points to the actual table.
  *
  */
-ACPI_EXTERN RSDP_DESCRIPTOR             *acpi_gbl_RSDP;
-ACPI_EXTERN xsdt_descriptor             *acpi_gbl_XSDT;
-ACPI_EXTERN FADT_DESCRIPTOR             *acpi_gbl_FADT;
-ACPI_EXTERN acpi_table_header           *acpi_gbl_DSDT;
-ACPI_EXTERN acpi_common_facs            *acpi_gbl_FACS;
+ACPI_EXTERN RSDP_DESCRIPTOR            *acpi_gbl_RSDP;
+ACPI_EXTERN xsdt_descriptor            *acpi_gbl_XSDT;
+ACPI_EXTERN FADT_DESCRIPTOR            *acpi_gbl_FADT;
+ACPI_EXTERN acpi_table_header          *acpi_gbl_DSDT;
+ACPI_EXTERN FACS_DESCRIPTOR            *acpi_gbl_FACS;
+ACPI_EXTERN acpi_common_facs            acpi_gbl_common_fACS;
 
 /*
  * Since there may be multiple SSDTs and PSDTS, a single pointer is not
@@ -107,22 +108,18 @@ ACPI_EXTERN acpi_mutex_info             acpi_gbl_acpi_mutex_info [NUM_MTX];
 ACPI_EXTERN ACPI_MEMORY_LIST            acpi_gbl_memory_lists[ACPI_NUM_MEM_LISTS];
 ACPI_EXTERN ACPI_OBJECT_NOTIFY_HANDLER  acpi_gbl_drv_notify;
 ACPI_EXTERN ACPI_OBJECT_NOTIFY_HANDLER  acpi_gbl_sys_notify;
-ACPI_EXTERN u8                         *acpi_gbl_gpe0enable_register_save;
-ACPI_EXTERN u8                         *acpi_gbl_gpe1_enable_register_save;
 ACPI_EXTERN acpi_walk_state            *acpi_gbl_breakpoint_walk;
 ACPI_EXTERN acpi_handle                 acpi_gbl_global_lock_semaphore;
 
 ACPI_EXTERN u32                         acpi_gbl_global_lock_thread_count;
-ACPI_EXTERN u32                         acpi_gbl_restore_acpi_chipset;
 ACPI_EXTERN u32                         acpi_gbl_original_mode;
-ACPI_EXTERN u32                         acpi_gbl_edge_level_save;
-ACPI_EXTERN u32                         acpi_gbl_irq_enable_save;
 ACPI_EXTERN u32                         acpi_gbl_rsdp_original_location;
 ACPI_EXTERN u32                         acpi_gbl_ns_lookup_count;
 ACPI_EXTERN u32                         acpi_gbl_ps_find_count;
 ACPI_EXTERN u16                         acpi_gbl_pm1_enable_register_save;
 ACPI_EXTERN u16                         acpi_gbl_next_table_owner_id;
 ACPI_EXTERN u16                         acpi_gbl_next_method_owner_id;
+ACPI_EXTERN u16                         acpi_gbl_global_lock_handle;
 ACPI_EXTERN u8                          acpi_gbl_debugger_configuration;
 ACPI_EXTERN u8                          acpi_gbl_global_lock_acquired;
 ACPI_EXTERN u8                          acpi_gbl_step_to_next_call;
@@ -130,7 +127,6 @@ ACPI_EXTERN u8                          acpi_gbl_acpi_hardware_present;
 ACPI_EXTERN u8                          acpi_gbl_global_lock_present;
 
 extern u8                               acpi_gbl_shutdown;
-extern u32                              acpi_gbl_system_flags;
 extern u32                              acpi_gbl_startup_flags;
 extern const u8                         acpi_gbl_decode_to8bit[8];
 extern const NATIVE_CHAR                *acpi_gbl_db_sleep_states[ACPI_NUM_SLEEP_STATES];
@@ -150,14 +146,14 @@ ACPI_EXTERN acpi_namespace_node         acpi_gbl_root_node_struct;
 ACPI_EXTERN acpi_namespace_node        *acpi_gbl_root_node;
 
 extern const u8                         acpi_gbl_ns_properties[NUM_NS_TYPES];
-extern const predefined_names           acpi_gbl_pre_defined_names [NUM_PREDEFINED_NAMES];
+extern const acpi_predefined_names      acpi_gbl_pre_defined_names [NUM_PREDEFINED_NAMES];
 
 #ifdef ACPI_DEBUG
 ACPI_EXTERN u32                         acpi_gbl_current_node_count;
 ACPI_EXTERN u32                         acpi_gbl_current_node_size;
 ACPI_EXTERN u32                         acpi_gbl_max_concurrent_node_count;
-ACPI_EXTERN u32                         acpi_gbl_entry_stack_pointer;
-ACPI_EXTERN u32                         acpi_gbl_lowest_stack_pointer;
+ACPI_EXTERN ACPI_SIZE                   acpi_gbl_entry_stack_pointer;
+ACPI_EXTERN ACPI_SIZE                   acpi_gbl_lowest_stack_pointer;
 ACPI_EXTERN u32                         acpi_gbl_deepest_nesting;
 #endif
 
@@ -168,11 +164,7 @@ ACPI_EXTERN u32                         acpi_gbl_deepest_nesting;
  ****************************************************************************/
 
 
-ACPI_EXTERN acpi_walk_list             *acpi_gbl_current_walk_list;
-
-/* Address Space handlers */
-
-ACPI_EXTERN acpi_adr_space_info         acpi_gbl_address_spaces[ACPI_NUM_ADDRESS_SPACES];
+ACPI_EXTERN ACPI_THREAD_STATE           *acpi_gbl_current_walk_list;
 
 /* Control method single step flag */
 
@@ -187,34 +179,41 @@ ACPI_EXTERN u8                          acpi_gbl_cm_single_step;
 
 ACPI_EXTERN acpi_parse_object           *acpi_gbl_parsed_namespace_root;
 
+/*****************************************************************************
+ *
+ * Hardware globals
+ *
+ ****************************************************************************/
+
+ACPI_EXTERN ACPI_BIT_REGISTER_INFO      acpi_gbl_bit_register_info[ACPI_NUM_BITREG];
+ACPI_EXTERN u8                          acpi_gbl_sleep_type_a;
+ACPI_EXTERN u8                          acpi_gbl_sleep_type_b;
+
 
 /*****************************************************************************
  *
- * Event globals
+ * Event and GPE globals
  *
  ****************************************************************************/
 
-ACPI_EXTERN acpi_fixed_event_info       acpi_gbl_fixed_event_handlers[ACPI_NUM_FIXED_EVENTS];
+extern      acpi_fixed_event_info       acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS];
+ACPI_EXTERN ACPI_FIXED_EVENT_HANDLER    acpi_gbl_fixed_event_handlers[ACPI_NUM_FIXED_EVENTS];
+
 ACPI_EXTERN acpi_handle                 acpi_gbl_gpe_obj_handle;
 ACPI_EXTERN u32                         acpi_gbl_gpe_register_count;
-ACPI_EXTERN acpi_gpe_registers         *acpi_gbl_gpe_registers;
-ACPI_EXTERN acpi_gpe_level_info        *acpi_gbl_gpe_info;
+ACPI_EXTERN u32                         acpi_gbl_gpe_number_max;
+ACPI_EXTERN ACPI_GPE_REGISTER_INFO     *acpi_gbl_gpe_register_info;
+ACPI_EXTERN ACPI_GPE_NUMBER_INFO       *acpi_gbl_gpe_number_info;
+ACPI_EXTERN ACPI_GPE_BLOCK_INFO         acpi_gbl_gpe_block_info[ACPI_MAX_GPE_BLOCKS];
 
 /*
- * Gpe validation and translation table
- * Indexed by the GPE number, returns GPE_INVALID if the GPE is not supported.
- * Otherwise, returns a valid index into the global GPE table.
+ * GPE translation table
+ * Indexed by the GPE number, returns a valid index into the global GPE tables.
  *
  * This table is needed because the GPE numbers supported by block 1 do not
  * have to be contiguous with the GPE numbers supported by block 0.
  */
-ACPI_EXTERN u8                          acpi_gbl_gpe_valid [ACPI_NUM_GPE];
-
-/* Acpi_event counter for debug only */
-
-#ifdef ACPI_DEBUG
-ACPI_EXTERN u32                         acpi_gbl_event_count[ACPI_NUM_FIXED_EVENTS];
-#endif
+ACPI_EXTERN ACPI_GPE_INDEX_INFO        *acpi_gbl_gpe_number_to_index;
 
 
 /*****************************************************************************
@@ -223,10 +222,58 @@ ACPI_EXTERN u32                         acpi_gbl_event_count[ACPI_NUM_FIXED_EVEN
  *
  ****************************************************************************/
 
+
+ACPI_EXTERN u8                          acpi_gbl_db_output_flags;
+
+
 #ifdef ENABLE_DEBUGGER
+
 ACPI_EXTERN u8                          acpi_gbl_method_executing;
 ACPI_EXTERN u8                          acpi_gbl_db_terminate_threads;
-#endif
+
+ACPI_EXTERN int                         optind;
+ACPI_EXTERN NATIVE_CHAR                *optarg;
+ACPI_EXTERN u8                         *aml_start;
+ACPI_EXTERN u32                         aml_length;
+
+ACPI_EXTERN u8                          acpi_gbl_db_opt_tables;
+ACPI_EXTERN u8                          acpi_gbl_db_opt_disasm;
+ACPI_EXTERN u8                          acpi_gbl_db_opt_stats;
+ACPI_EXTERN u8                          acpi_gbl_db_opt_verbose;
+ACPI_EXTERN u8                          acpi_gbl_db_opt_ini_methods;
+
+
+ACPI_EXTERN NATIVE_CHAR                *acpi_gbl_db_args[ACPI_DEBUGGER_MAX_ARGS];
+ACPI_EXTERN NATIVE_CHAR                 acpi_gbl_db_line_buf[80];
+ACPI_EXTERN NATIVE_CHAR                 acpi_gbl_db_parsed_buf[80];
+ACPI_EXTERN NATIVE_CHAR                 acpi_gbl_db_scope_buf[40];
+ACPI_EXTERN NATIVE_CHAR                 acpi_gbl_db_debug_filename[40];
+ACPI_EXTERN u8                          acpi_gbl_db_output_to_file;
+ACPI_EXTERN NATIVE_CHAR                *acpi_gbl_db_buffer;
+ACPI_EXTERN NATIVE_CHAR                *acpi_gbl_db_filename;
+ACPI_EXTERN NATIVE_CHAR                *acpi_gbl_db_disasm_indent;
+ACPI_EXTERN u32                         acpi_gbl_db_debug_level;
+ACPI_EXTERN u32                         acpi_gbl_db_console_debug_level;
+ACPI_EXTERN acpi_table_header          *acpi_gbl_db_table_ptr;
+ACPI_EXTERN acpi_namespace_node        *acpi_gbl_db_scope_node;
+
+/*
+ * Statistic globals
+ */
+ACPI_EXTERN u16                         acpi_gbl_obj_type_count[INTERNAL_TYPE_NODE_MAX+1];
+ACPI_EXTERN u16                         acpi_gbl_node_type_count[INTERNAL_TYPE_NODE_MAX+1];
+ACPI_EXTERN u16                         acpi_gbl_obj_type_count_misc;
+ACPI_EXTERN u16                         acpi_gbl_node_type_count_misc;
+ACPI_EXTERN u32                         acpi_gbl_num_nodes;
+ACPI_EXTERN u32                         acpi_gbl_num_objects;
+
+
+ACPI_EXTERN u32                         acpi_gbl_size_of_parse_tree;
+ACPI_EXTERN u32                         acpi_gbl_size_of_method_trees;
+ACPI_EXTERN u32                         acpi_gbl_size_of_node_entries;
+ACPI_EXTERN u32                         acpi_gbl_size_of_acpi_objects;
+
+#endif /* ENABLE_DEBUGGER */
 
 
 #endif /* __ACGLOBAL_H__ */
index ec153bdf3e220e10fc48b41d6ccefd5ffaba16a9..f0c39513028f3855e0830b0e0f16b1a41c832094 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Name: achware.h -- hardware specific interfaces
- *       $Revision: 56 $
+ *       $Revision: 58 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -60,13 +60,20 @@ acpi_hw_get_mode_capabilities (
 
 /* Register I/O Prototypes */
 
+ACPI_BIT_REGISTER_INFO *
+acpi_hw_get_bit_register_info (
+       u32                     register_id);
 
 u32
-acpi_hw_register_bit_access (
-       NATIVE_UINT             read_write,
-       u8                      use_lock,
+acpi_hw_bit_register_read (
+       u32                     register_id,
+       u32                     flags);
+
+u32
+acpi_hw_bit_register_write (
        u32                     register_id,
-       ... /* DWORD Write Value */);
+       u32                     value,
+       u32                     flags);
 
 u32
 acpi_hw_register_read (
@@ -96,10 +103,6 @@ void
 acpi_hw_clear_acpi_status (
    void);
 
-u32
-acpi_hw_get_bit_shift (
-       u32                     mask);
-
 
 /* GPE support */
 
@@ -140,7 +143,7 @@ acpi_hw_enable_non_wakeup_gpes (
 /* Sleep Prototypes */
 
 acpi_status
-acpi_hw_obtain_sleep_type_register_data (
+acpi_hw_get_sleep_type_data (
        u8                      sleep_state,
        u8                      *slp_typ_a,
        u8                      *slp_typ_b);
index 0030b239d622e2d952aa6cbc4a4dc9a4a2cb6e19..a62019b9bc79c9dc92bde5590c6ce519e45db1c8 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Name: acinterp.h - Interpreter subcomponent prototypes and defines
- *       $Revision: 116 $
+ *       $Revision: 132 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 #define __ACINTERP_H__
 
 
-#define WALK_OPERANDS       &(walk_state->operands [walk_state->num_operands -1])
-
-
-/* Interpreter constants */
-
-#define AML_END_OF_BLOCK            -1
-#define PUSH_PKG_LENGTH             1
-#define DO_NOT_PUSH_PKG_LENGTH      0
-
-
-#define STACK_TOP                   0
-#define STACK_BOTTOM                (u32) -1
-
-/* Constants for global "When_to_parse_methods" */
-
-#define METHOD_PARSE_AT_INIT        0x0
-#define METHOD_PARSE_JUST_IN_TIME   0x1
-#define METHOD_DELETE_AT_COMPLETION 0x2
+#define ACPI_WALK_OPERANDS       (&(walk_state->operands [walk_state->num_operands -1]))
 
 
 acpi_status
@@ -55,7 +38,7 @@ acpi_ex_resolve_operands (
 
 
 /*
- * amxface - External interpreter interfaces
+ * exxface - External interpreter interfaces
  */
 
 acpi_status
@@ -70,7 +53,7 @@ acpi_ex_execute_method (
 
 
 /*
- * amconvrt - object conversion
+ * exconvrt - object conversion
  */
 
 acpi_status
@@ -95,13 +78,14 @@ acpi_ex_convert_to_string (
 
 acpi_status
 acpi_ex_convert_to_target_type (
-       acpi_object_type8       destination_type,
-       acpi_operand_object     **obj_desc,
+       acpi_object_type        destination_type,
+       acpi_operand_object     *source_desc,
+       acpi_operand_object     **result_desc,
        acpi_walk_state         *walk_state);
 
 
 /*
- * amfield - ACPI AML (p-code) execution - field manipulation
+ * exfield - ACPI AML (p-code) execution - field manipulation
  */
 
 acpi_status
@@ -117,52 +101,49 @@ acpi_ex_insert_into_field (
        u32                     buffer_length);
 
 acpi_status
-acpi_ex_setup_field (
+acpi_ex_setup_region (
        acpi_operand_object     *obj_desc,
-       u32                     field_byte_offset);
+       u32                     field_datum_byte_offset);
 
 acpi_status
-acpi_ex_read_field_datum (
+acpi_ex_access_region (
        acpi_operand_object     *obj_desc,
-       u32                     field_byte_offset,
-       u32                     *value);
+       u32                     field_datum_byte_offset,
+       acpi_integer            *value,
+       u32                     read_write);
 
-acpi_status
-acpi_ex_common_access_field (
-       u32                     mode,
+u8
+acpi_ex_register_overflow (
        acpi_operand_object     *obj_desc,
-       void                    *buffer,
-       u32                     buffer_length);
-
+       acpi_integer            value);
 
 acpi_status
-acpi_ex_access_index_field (
-       u32                     mode,
+acpi_ex_field_datum_io (
        acpi_operand_object     *obj_desc,
-       void                    *buffer,
-       u32                     buffer_length);
+       u32                     field_datum_byte_offset,
+       acpi_integer            *value,
+       u32                     read_write);
 
 acpi_status
-acpi_ex_access_bank_field (
-       u32                     mode,
+acpi_ex_write_with_update_rule (
        acpi_operand_object     *obj_desc,
-       void                    *buffer,
-       u32                     buffer_length);
+       acpi_integer            mask,
+       acpi_integer            field_value,
+       u32                     field_datum_byte_offset);
 
-acpi_status
-acpi_ex_access_region_field (
-       u32                     mode,
-       acpi_operand_object     *obj_desc,
+void
+acpi_ex_get_buffer_datum(
+       acpi_integer            *datum,
        void                    *buffer,
-       u32                     buffer_length);
-
+       u32                     byte_granularity,
+       u32                     offset);
 
-acpi_status
-acpi_ex_access_buffer_field (
-       u32                     mode,
-       acpi_operand_object     *obj_desc,
+void
+acpi_ex_set_buffer_datum (
+       acpi_integer            merged_datum,
        void                    *buffer,
-       u32                     buffer_length);
+       u32                     byte_granularity,
+       u32                     offset);
 
 acpi_status
 acpi_ex_read_data_from_field (
@@ -175,7 +156,7 @@ acpi_ex_write_data_to_field (
        acpi_operand_object     *obj_desc);
 
 /*
- * ammisc - ACPI AML (p-code) execution - specific opcodes
+ * exmisc - ACPI AML (p-code) execution - specific opcodes
  */
 
 acpi_status
@@ -196,6 +177,13 @@ acpi_ex_get_object_reference (
        acpi_operand_object     **return_desc,
        acpi_walk_state         *walk_state);
 
+acpi_status
+acpi_ex_concat_template (
+       acpi_operand_object     *obj_desc,
+       acpi_operand_object     *obj_desc2,
+       acpi_operand_object     **actual_return_desc,
+       acpi_walk_state         *walk_state);
+
 acpi_status
 acpi_ex_do_concatenate (
        acpi_operand_object     *obj_desc,
@@ -215,15 +203,6 @@ acpi_ex_do_math_op (
        acpi_integer            operand0,
        acpi_integer            operand1);
 
-acpi_status
-acpi_ex_load_op (
-       acpi_operand_object     *rgn_desc,
-       acpi_operand_object     *ddb_handle);
-
-acpi_status
-acpi_ex_unload_table (
-       acpi_operand_object     *ddb_handle);
-
 acpi_status
 acpi_ex_create_mutex (
        acpi_walk_state         *walk_state);
@@ -263,7 +242,33 @@ acpi_ex_create_method (
 
 
 /*
- * ammutex - mutex support
+ * exconfig - dynamic table load/unload
+ */
+
+acpi_status
+acpi_ex_add_table (
+       acpi_table_header       *table,
+       acpi_namespace_node     *parent_node,
+       acpi_operand_object     **ddb_handle);
+
+acpi_status
+acpi_ex_load_op (
+       acpi_operand_object     *obj_desc,
+       acpi_operand_object     *target,
+       acpi_walk_state         *walk_state);
+
+acpi_status
+acpi_ex_load_table_op (
+       acpi_walk_state         *walk_state,
+       acpi_operand_object     **return_desc);
+
+acpi_status
+acpi_ex_unload_table (
+       acpi_operand_object     *ddb_handle);
+
+
+/*
+ * exmutex - mutex support
  */
 
 acpi_status
@@ -279,57 +284,35 @@ acpi_ex_release_mutex (
 
 acpi_status
 acpi_ex_release_all_mutexes (
-       acpi_operand_object     *mutex_list);
+       ACPI_THREAD_STATE       *thread);
 
 void
 acpi_ex_unlink_mutex (
        acpi_operand_object     *obj_desc);
 
+void
+acpi_ex_link_mutex (
+       acpi_operand_object     *obj_desc,
+       ACPI_THREAD_STATE       *thread);
 
 /*
- * amprep - ACPI AML (p-code) execution - prep utilities
+ * exprep - ACPI AML (p-code) execution - prep utilities
  */
 
 acpi_status
 acpi_ex_prep_common_field_object (
        acpi_operand_object     *obj_desc,
        u8                      field_flags,
-       u32                     field_position,
-       u32                     field_length);
-
-acpi_status
-acpi_ex_prep_region_field_value (
-       acpi_namespace_node     *node,
-       acpi_handle             region,
-       u8                      field_flags,
-       u32                     field_position,
-       u32                     field_length);
-
-acpi_status
-acpi_ex_prep_bank_field_value (
-       acpi_namespace_node     *node,
-       acpi_namespace_node     *region_node,
-       acpi_namespace_node     *bank_register_node,
-       u32                     bank_val,
-       u8                      field_flags,
-       u32                     field_position,
-       u32                     field_length);
-
-acpi_status
-acpi_ex_prep_index_field_value (
-       acpi_namespace_node     *node,
-       acpi_namespace_node     *index_reg,
-       acpi_namespace_node     *data_reg,
-       u8                      field_flags,
-       u32                     field_position,
-       u32                     field_length);
+       u8                      field_attribute,
+       u32                     field_bit_position,
+       u32                     field_bit_length);
 
 acpi_status
 acpi_ex_prep_field_value (
        ACPI_CREATE_FIELD_INFO  *info);
 
 /*
- * amsystem - Interface to OS services
+ * exsystem - Interface to OS services
  */
 
 acpi_status
@@ -337,11 +320,11 @@ acpi_ex_system_do_notify_op (
        acpi_operand_object     *value,
        acpi_operand_object     *obj_desc);
 
-void
+acpi_status
 acpi_ex_system_do_suspend(
        u32                     time);
 
-void
+acpi_status
 acpi_ex_system_do_stall (
        u32                     time);
 
@@ -374,7 +357,7 @@ acpi_ex_system_wait_semaphore (
 
 
 /*
- * ammonadic - ACPI AML (p-code) execution, monadic operators
+ * exmonadic - ACPI AML (p-code) execution, monadic operators
  */
 
 acpi_status
@@ -394,7 +377,7 @@ acpi_ex_opcode_1A_1T_0R (
        acpi_walk_state         *walk_state);
 
 /*
- * amdyadic - ACPI AML (p-code) execution, dyadic operators
+ * exdyadic - ACPI AML (p-code) execution, dyadic operators
  */
 
 acpi_status
@@ -415,7 +398,7 @@ acpi_ex_opcode_2A_2T_1R (
 
 
 /*
- * amresolv  - Object resolution and get value functions
+ * exresolv  - Object resolution and get value functions
  */
 
 acpi_status
@@ -433,14 +416,9 @@ acpi_ex_resolve_object_to_value (
        acpi_operand_object     **stack_ptr,
        acpi_walk_state         *walk_state);
 
-acpi_status
-acpi_ex_get_buffer_field_value (
-       acpi_operand_object     *field_desc,
-       acpi_operand_object     *result_desc);
-
 
 /*
- * amdump - Scanner debug output routines
+ * exdump - Scanner debug output routines
  */
 
 void
@@ -457,7 +435,7 @@ acpi_ex_dump_operand (
 void
 acpi_ex_dump_operands (
        acpi_operand_object     **operands,
-       operating_mode          interpreter_mode,
+       acpi_interpreter_mode   interpreter_mode,
        NATIVE_CHAR             *ident,
        u32                     num_levels,
        NATIVE_CHAR             *note,
@@ -477,7 +455,7 @@ acpi_ex_dump_node (
 
 
 /*
- * amnames - interpreter/scanner name load/execute
+ * exnames - interpreter/scanner name load/execute
  */
 
 NATIVE_CHAR *
@@ -496,7 +474,7 @@ acpi_ex_name_segment (
 
 acpi_status
 acpi_ex_get_name_string (
-       acpi_object_type8       data_type,
+       acpi_object_type        data_type,
        u8                      *in_aml_address,
        NATIVE_CHAR             **out_name_string,
        u32                     *out_name_length);
@@ -504,11 +482,11 @@ acpi_ex_get_name_string (
 acpi_status
 acpi_ex_do_name (
        acpi_object_type        data_type,
-       operating_mode          load_exec_mode);
+       acpi_interpreter_mode   load_exec_mode);
 
 
 /*
- * amstore - Object store support
+ * exstore - Object store support
  */
 
 acpi_status
@@ -529,42 +507,36 @@ acpi_ex_store_object_to_node (
        acpi_namespace_node     *node,
        acpi_walk_state         *walk_state);
 
-acpi_status
-acpi_ex_store_object_to_object (
-       acpi_operand_object     *source_desc,
-       acpi_operand_object     *dest_desc,
-       acpi_walk_state         *walk_state);
-
 
 /*
- *
+ * exstoren
  */
 
 acpi_status
 acpi_ex_resolve_object (
        acpi_operand_object     **source_desc_ptr,
-       acpi_object_type8       target_type,
+       acpi_object_type        target_type,
        acpi_walk_state         *walk_state);
 
 acpi_status
-acpi_ex_store_object (
+acpi_ex_store_object_to_object (
        acpi_operand_object     *source_desc,
-       acpi_object_type8       target_type,
-       acpi_operand_object     **target_desc_ptr,
+       acpi_operand_object     *dest_desc,
+       acpi_operand_object     **new_desc,
        acpi_walk_state         *walk_state);
 
 
 /*
- * amcopy - object copy
+ * excopy - object copy
  */
 
 acpi_status
-acpi_ex_copy_buffer_to_buffer (
+acpi_ex_store_buffer_to_buffer (
        acpi_operand_object     *source_desc,
        acpi_operand_object     *target_desc);
 
 acpi_status
-acpi_ex_copy_string_to_string (
+acpi_ex_store_string_to_string (
        acpi_operand_object     *source_desc,
        acpi_operand_object     *target_desc);
 
@@ -589,7 +561,7 @@ acpi_ex_copy_integer_to_buffer_field (
        acpi_operand_object     *target_desc);
 
 /*
- * amutils - interpreter/scanner utilities
+ * exutils - interpreter/scanner utilities
  */
 
 acpi_status
@@ -634,7 +606,7 @@ acpi_ex_unsigned_integer_to_string (
 
 
 /*
- * amregion - default Op_region handlers
+ * exregion - default Op_region handlers
  */
 
 acpi_status
@@ -642,7 +614,7 @@ acpi_ex_system_memory_space_handler (
        u32                     function,
        ACPI_PHYSICAL_ADDRESS   address,
        u32                     bit_width,
-       u32                     *value,
+       acpi_integer            *value,
        void                    *handler_context,
        void                    *region_context);
 
@@ -651,7 +623,7 @@ acpi_ex_system_io_space_handler (
        u32                     function,
        ACPI_PHYSICAL_ADDRESS   address,
        u32                     bit_width,
-       u32                     *value,
+       acpi_integer            *value,
        void                    *handler_context,
        void                    *region_context);
 
@@ -660,7 +632,7 @@ acpi_ex_pci_config_space_handler (
        u32                     function,
        ACPI_PHYSICAL_ADDRESS   address,
        u32                     bit_width,
-       u32                     *value,
+       acpi_integer            *value,
        void                    *handler_context,
        void                    *region_context);
 
@@ -669,7 +641,7 @@ acpi_ex_cmos_space_handler (
        u32                     function,
        ACPI_PHYSICAL_ADDRESS   address,
        u32                     bit_width,
-       u32                     *value,
+       acpi_integer            *value,
        void                    *handler_context,
        void                    *region_context);
 
@@ -678,7 +650,7 @@ acpi_ex_pci_bar_space_handler (
        u32                     function,
        ACPI_PHYSICAL_ADDRESS   address,
        u32                     bit_width,
-       u32                     *value,
+       acpi_integer            *value,
        void                    *handler_context,
        void                    *region_context);
 
@@ -687,7 +659,7 @@ acpi_ex_embedded_controller_space_handler (
        u32                     function,
        ACPI_PHYSICAL_ADDRESS   address,
        u32                     bit_width,
-       u32                     *value,
+       acpi_integer            *value,
        void                    *handler_context,
        void                    *region_context);
 
@@ -696,9 +668,18 @@ acpi_ex_sm_bus_space_handler (
        u32                     function,
        ACPI_PHYSICAL_ADDRESS   address,
        u32                     bit_width,
-       u32                     *value,
+       acpi_integer            *value,
        void                    *handler_context,
        void                    *region_context);
 
 
+acpi_status
+acpi_ex_data_table_space_handler (
+       u32                     function,
+       ACPI_PHYSICAL_ADDRESS   address,
+       u32                     bit_width,
+       acpi_integer            *value,
+       void                    *handler_context,
+       void                    *region_context);
+
 #endif /* __INTERP_H__ */
index 8912e125d8db2e41a746427f3389a41c6ca9763e..d8333e4c02f6dd12152bcbe6deb74a9b6f196da4 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Name: aclocal.h - Internal data types used across the ACPI subsystem
- *       $Revision: 138 $
+ *       $Revision: 159 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -49,6 +49,7 @@ typedef u32                             ACPI_MUTEX_HANDLE;
 #define ACPI_DESC_TYPE_STATE_WSCOPE     0x26
 #define ACPI_DESC_TYPE_STATE_RESULT     0x27
 #define ACPI_DESC_TYPE_STATE_NOTIFY     0x28
+#define ACPI_DESC_TYPE_STATE_THREAD     0x29
 #define ACPI_DESC_TYPE_WALK             0x44
 #define ACPI_DESC_TYPE_PARSER           0x66
 #define ACPI_DESC_TYPE_INTERNAL         0x88
@@ -138,10 +139,10 @@ typedef struct acpi_mutex_info
 
 
 typedef u16                             acpi_owner_id;
-#define OWNER_TYPE_TABLE                0x0
-#define OWNER_TYPE_METHOD               0x1
-#define FIRST_METHOD_ID                 0x0000
-#define FIRST_TABLE_ID                  0x8000
+#define ACPI_OWNER_TYPE_TABLE           0x0
+#define ACPI_OWNER_TYPE_METHOD          0x1
+#define ACPI_FIRST_METHOD_ID            0x0000
+#define ACPI_FIRST_TABLE_ID             0x8000
 
 /* TBD: [Restructure] get rid of the need for this! */
 
@@ -166,11 +167,11 @@ typedef u16                             acpi_owner_id;
 
 typedef enum
 {
-       IMODE_LOAD_PASS1                = 0x01,
-       IMODE_LOAD_PASS2                = 0x02,
-       IMODE_EXECUTE                   = 0x0E
+       ACPI_IMODE_LOAD_PASS1               = 0x01,
+       ACPI_IMODE_LOAD_PASS2               = 0x02,
+       ACPI_IMODE_EXECUTE                  = 0x0E
 
-} operating_mode;
+} acpi_interpreter_mode;
 
 
 /*
@@ -183,7 +184,7 @@ typedef enum
 
 typedef struct acpi_node
 {
-       u8                      data_type;
+       u8                      descriptor;     /* Used to differentiate object descriptor types */
        u8                      type;           /* Type associated with this name */
        u16                     owner_id;
        u32                     name;           /* ACPI Name, always 4 chars per ACPI spec */
@@ -198,12 +199,12 @@ typedef struct acpi_node
 } acpi_namespace_node;
 
 
-#define ENTRY_NOT_FOUND             NULL
+#define ACPI_ENTRY_NOT_FOUND            NULL
 
 
 /* Node flags */
 
-#define ANOBJ_AML_ATTACHMENT            0x01
+#define ANOBJ_RESERVED                  0x01
 #define ANOBJ_END_OF_PEER_LIST          0x02
 #define ANOBJ_DATA_WIDTH_32             0x04     /* Parent table is 64-bits */
 #define ANOBJ_METHOD_ARG                0x08
@@ -243,13 +244,13 @@ typedef struct
        acpi_handle             *list;
        u32                     *count;
 
-} find_context;
+} acpi_find_context;
 
 
 typedef struct
 {
        acpi_namespace_node     *node;
-} ns_search_data;
+} acpi_ns_search_data;
 
 
 /*
@@ -258,10 +259,10 @@ typedef struct
 typedef struct
 {
        NATIVE_CHAR             *name;
-       acpi_object_type8       type;
+       u8                      type;
        NATIVE_CHAR             *val;
 
-} predefined_names;
+} acpi_predefined_names;
 
 
 /* Object types used during package copies */
@@ -297,20 +298,11 @@ typedef struct
        u32                     field_bit_position;
        u32                     field_bit_length;
        u8                      field_flags;
+       u8                      attribute;
        u8                      field_type;
 
 } ACPI_CREATE_FIELD_INFO;
 
-/*
- * Field flags: Bits 00 - 03 : Access_type (Any_acc, Byte_acc, etc.)
- *                   04      : Lock_rule (1 == Lock)
- *                   05 - 06 : Update_rule
- */
-
-#define FIELD_ACCESS_TYPE_MASK      0x0F
-#define FIELD_LOCK_RULE_MASK        0x10
-#define FIELD_UPDATE_RULE_MASK      0x60
-
 
 /*****************************************************************************
  *
@@ -318,38 +310,17 @@ typedef struct
  *
  ****************************************************************************/
 
-
-/* Status bits. */
-
-#define ACPI_STATUS_PMTIMER             0x0001
-#define ACPI_STATUS_BUSMASTER           0x0010
-#define ACPI_STATUS_GLOBAL              0x0020
-#define ACPI_STATUS_POWER_BUTTON        0x0100
-#define ACPI_STATUS_SLEEP_BUTTON        0x0200
-#define ACPI_STATUS_RTC_ALARM           0x0400
-
-/* Enable bits. */
-
-#define ACPI_ENABLE_PMTIMER             0x0001
-#define ACPI_ENABLE_GLOBAL              0x0020
-#define ACPI_ENABLE_POWER_BUTTON        0x0100
-#define ACPI_ENABLE_SLEEP_BUTTON        0x0200
-#define ACPI_ENABLE_RTC_ALARM           0x0400
-
-
-/*
- * Entry in the Address_space (AKA Operation Region) table
- */
+/* Information about each GPE register block */
 
 typedef struct
 {
-       acpi_adr_space_handler  handler;
-       void                    *context;
+       u16                     register_count;
+       u16                     block_address;
+       u8                      block_base_number;
 
-} acpi_adr_space_info;
+} ACPI_GPE_BLOCK_INFO;
 
-
-/* Values and addresses of the GPE registers (both banks) */
+/* Information about a particular GPE register pair */
 
 typedef struct
 {
@@ -358,9 +329,9 @@ typedef struct
        u8                      status;         /* Current value of status reg */
        u8                      enable;         /* Current value of enable reg */
        u8                      wake_enable;    /* Mask of bits to keep enabled when sleeping */
-       u8                      gpe_base;       /* Base GPE number */
+       u8                      base_gpe_number; /* Base GPE number for this register */
 
-} acpi_gpe_registers;
+} ACPI_GPE_REGISTER_INFO;
 
 
 #define ACPI_GPE_LEVEL_TRIGGERED        1
@@ -371,14 +342,21 @@ typedef struct
 
 typedef struct
 {
-       u8                      type;           /* Level or Edge */
-
        acpi_handle             method_handle;  /* Method handle for direct (fast) execution */
        acpi_gpe_handler        handler;        /* Address of handler, if any */
        void                    *context;       /* Context to be passed to handler */
+       u8                      type;           /* Level or Edge */
+       u8                      bit_mask;
+
+
+} ACPI_GPE_NUMBER_INFO;
+
 
-} acpi_gpe_level_info;
+typedef struct
+{
+       u8                      number_index;
 
+} ACPI_GPE_INDEX_INFO;
 
 /* Information about each particular fixed event */
 
@@ -387,8 +365,17 @@ typedef struct
        acpi_event_handler      handler;        /* Address of handler. */
        void                    *context;       /* Context to be passed to handler */
 
-} acpi_fixed_event_info;
+} ACPI_FIXED_EVENT_HANDLER;
+
+
+typedef struct
+{
+       u8                      status_register_id;
+       u8                      enable_register_id;
+       u16                     status_bit_mask;
+       u16                     enable_bit_mask;
 
+} acpi_fixed_event_info;
 
 /* Information used during field processing */
 
@@ -408,16 +395,15 @@ typedef struct
  ****************************************************************************/
 
 
-#define CONTROL_NORMAL                  0xC0
-#define CONTROL_CONDITIONAL_EXECUTING   0xC1
-#define CONTROL_PREDICATE_EXECUTING     0xC2
-#define CONTROL_PREDICATE_FALSE         0xC3
-#define CONTROL_PREDICATE_TRUE          0xC4
+#define ACPI_CONTROL_NORMAL                  0xC0
+#define ACPI_CONTROL_CONDITIONAL_EXECUTING   0xC1
+#define ACPI_CONTROL_PREDICATE_EXECUTING     0xC2
+#define ACPI_CONTROL_PREDICATE_FALSE         0xC3
+#define ACPI_CONTROL_PREDICATE_TRUE          0xC4
 
 
 /* Forward declarations */
 struct acpi_walk_state;
-struct acpi_walk_list;
 struct acpi_parse_obj;
 struct acpi_obj_mutex;
 
@@ -471,7 +457,9 @@ typedef struct acpi_control_state
 {
        ACPI_STATE_COMMON
        struct acpi_parse_obj   *predicate_op;
-       u8                      *aml_predicate_start; /* Start of if/while predicate */
+       u8                      *aml_predicate_start;   /* Start of if/while predicate */
+       u8                      *package_end;           /* End of if/while block */
+       u16                     opcode;
 
 } acpi_control_state;
 
@@ -490,15 +478,30 @@ typedef struct acpi_scope_state
 typedef struct acpi_pscope_state
 {
        ACPI_STATE_COMMON
-       struct acpi_parse_obj   *op;            /* current op being parsed */
-       u8                      *arg_end;       /* current argument end */
-       u8                      *pkg_end;       /* current package end */
-       u32                     arg_list;       /* next argument to parse */
-       u32                     arg_count;      /* Number of fixed arguments */
+       struct acpi_parse_obj   *op;                    /* current op being parsed */
+       u8                      *arg_end;               /* current argument end */
+       u8                      *pkg_end;               /* current package end */
+       u32                     arg_list;               /* next argument to parse */
+       u32                     arg_count;              /* Number of fixed arguments */
 
 } acpi_pscope_state;
 
 
+/*
+ * Thread state - one per thread across multiple walk states.  Multiple walk
+ * states are created when there are nested control methods executing.
+ */
+typedef struct acpi_thread_state
+{
+       ACPI_STATE_COMMON
+       struct acpi_walk_state  *walk_state_list;       /* Head of list of Walk_states for this thread */
+       union acpi_operand_obj  *acquired_mutex_list;   /* List of all currently acquired mutexes */
+       u32                     thread_id;              /* Running thread ID */
+       u16                     current_sync_level;     /* Mutex Sync (nested acquire) level */
+
+} ACPI_THREAD_STATE;
+
+
 /*
  * Result values - used to accumulate the results of nested
  * AML arguments
@@ -546,6 +549,7 @@ typedef union acpi_gen_state
        acpi_scope_state        scope;
        acpi_pscope_state       parse_scope;
        acpi_pkg_state          pkg;
+       ACPI_THREAD_STATE       thread;
        acpi_result_values      results;
        acpi_notify_info        notify;
 
@@ -574,16 +578,16 @@ acpi_status (*ACPI_EXECUTE_OP) (
  */
 typedef struct acpi_opcode_info
 {
+#ifdef _OPCODE_NAMES
+       NATIVE_CHAR             *name;          /* Opcode name (debug only) */
+#endif
        u32                     parse_args;     /* Grammar/Parse time arguments */
        u32                     runtime_args;   /* Interpret time arguments */
-       u16                     flags;          /* Misc flags */
+       u32                     flags;          /* Misc flags */
+       u8                      object_type;    /* Corresponding internal object type */
        u8                      class;          /* Opcode class */
        u8                      type;           /* Opcode type */
 
-#ifdef _OPCODE_NAMES
-       NATIVE_CHAR             *name;          /* op name (debug only) */
-#endif
-
 } acpi_opcode_info;
 
 
@@ -610,7 +614,7 @@ typedef union acpi_parse_val
        u32                     aml_offset;     /* offset of declaration in AML */\
        struct acpi_parse_obj   *parent;        /* parent op */\
        struct acpi_parse_obj   *next;          /* next op */\
-       DEBUG_ONLY_MEMBERS (\
+       ACPI_DEBUG_ONLY_MEMBERS (\
        NATIVE_CHAR             op_name[16])    /* op name (debug only) */\
                          /* NON-DEBUG members below: */\
        acpi_namespace_node     *node;          /* for use by interpreter */\
@@ -652,153 +656,143 @@ typedef struct acpi_parse_state
        u8                      *aml_end;       /* (last + 1) AML byte */
        u8                      *pkg_start;     /* current package begin */
        u8                      *pkg_end;       /* current package end */
-
        struct acpi_parse_obj   *start_op;      /* root of parse tree */
        struct acpi_node        *start_node;
        union acpi_gen_state    *scope;         /* current scope */
+       struct acpi_parse_obj   *start_scope;
 
+} acpi_parse_state;
 
-       struct acpi_parse_obj   *start_scope;
 
+/* Parse object flags */
 
-} acpi_parse_state;
+#define ACPI_PARSEOP_GENERIC                    0x01
+#define ACPI_PARSEOP_NAMED                      0x02
+#define ACPI_PARSEOP_DEFERRED                   0x04
+#define ACPI_PARSEOP_BYTELIST                   0x08
+#define ACPI_PARSEOP_IN_CACHE                   0x80
 
 
 /*****************************************************************************
  *
- * Hardware and PNP
+ * Hardware (ACPI registers) and PNP
  *
  ****************************************************************************/
 
+#define PCI_ROOT_HID_STRING         "PNP0A03"
 
-/* PCI */
-#define PCI_ROOT_HID_STRING             "PNP0A03"
-
-/*
- * The #define's and enum below establish an abstract way of identifying what
- * register block and register is to be accessed.  Do not change any of the
- * values as they are used in switch statements and offset calculations.
- */
-
-#define REGISTER_BLOCK_MASK             0xFF00  /* Register Block Id    */
-#define BIT_IN_REGISTER_MASK            0x00FF  /* Bit Id in the Register Block Id    */
-#define BYTE_IN_REGISTER_MASK           0x00FF  /* Register Offset in the Register Block    */
-
-#define REGISTER_BLOCK_ID(reg_id)       (reg_id & REGISTER_BLOCK_MASK)
-#define REGISTER_BIT_ID(reg_id)         (reg_id & BIT_IN_REGISTER_MASK)
-#define REGISTER_OFFSET(reg_id)         (reg_id & BYTE_IN_REGISTER_MASK)
-
-/*
- * Access Rule
- *  To access a Register Bit:
- *  -> Use Bit Name (= Register Block Id | Bit Id) defined in the enum.
- *
- *  To access a Register:
- *  -> Use Register Id (= Register Block Id | Register Offset)
- */
+typedef struct
+{
+       u8                      parent_register;
+       u8                      bit_position;
+       u16                     access_bit_mask;
 
+} ACPI_BIT_REGISTER_INFO;
 
-/*
- * Register Block Id
- */
-#define PM1_STS                         0x0100
-#define PM1_EN                          0x0200
-#define PM1_CONTROL                     0x0300
-#define PM1A_CONTROL                    0x0400
-#define PM1B_CONTROL                    0x0500
-#define PM2_CONTROL                     0x0600
-#define PM_TIMER                        0x0700
-#define PROCESSOR_BLOCK                 0x0800
-#define GPE0_STS_BLOCK                  0x0900
-#define GPE0_EN_BLOCK                   0x0A00
-#define GPE1_STS_BLOCK                  0x0B00
-#define GPE1_EN_BLOCK                   0x0C00
-#define SMI_CMD_BLOCK                   0x0D00
 
 /*
- * Address space bitmasks for mmio or io spaces
+ * Register IDs
+ * These are the full ACPI registers
  */
+#define ACPI_REGISTER_PM1_STATUS                0x01
+#define ACPI_REGISTER_PM1_ENABLE                0x02
+#define ACPI_REGISTER_PM1_CONTROL               0x03
+#define ACPI_REGISTER_PM1A_CONTROL              0x04
+#define ACPI_REGISTER_PM1B_CONTROL              0x05
+#define ACPI_REGISTER_PM2_CONTROL               0x06
+#define ACPI_REGISTER_PM_TIMER                  0x07
+#define ACPI_REGISTER_PROCESSOR_BLOCK           0x08
+#define ACPI_REGISTER_SMI_COMMAND_BLOCK         0x09
 
-#define SMI_CMD_ADDRESS_SPACE           0x01
-#define PM1_BLK_ADDRESS_SPACE           0x02
-#define PM2_CNT_BLK_ADDRESS_SPACE       0x04
-#define PM_TMR_BLK_ADDRESS_SPACE        0x08
-#define GPE0_BLK_ADDRESS_SPACE          0x10
-#define GPE1_BLK_ADDRESS_SPACE          0x20
 
 /*
- * Control bit definitions
+ * Bit_register IDs
+ * These are bitfields defined within the full ACPI registers
  */
-#define TMR_STS                         (PM1_STS | 0x01)
-#define BM_STS                          (PM1_STS | 0x02)
-#define GBL_STS                         (PM1_STS | 0x03)
-#define PWRBTN_STS                      (PM1_STS | 0x04)
-#define SLPBTN_STS                      (PM1_STS | 0x05)
-#define RTC_STS                         (PM1_STS | 0x06)
-#define WAK_STS                         (PM1_STS | 0x07)
-
-#define TMR_EN                          (PM1_EN | 0x01)
-                        /* no BM_EN */
-#define GBL_EN                          (PM1_EN | 0x03)
-#define PWRBTN_EN                       (PM1_EN | 0x04)
-#define SLPBTN_EN                       (PM1_EN | 0x05)
-#define RTC_EN                          (PM1_EN | 0x06)
-#define WAK_EN                          (PM1_EN | 0x07)
-
-#define SCI_EN                          (PM1_CONTROL | 0x01)
-#define BM_RLD                          (PM1_CONTROL | 0x02)
-#define GBL_RLS                         (PM1_CONTROL | 0x03)
-#define SLP_TYPE_A                      (PM1_CONTROL | 0x04)
-#define SLP_TYPE_B                      (PM1_CONTROL | 0x05)
-#define SLP_EN                          (PM1_CONTROL | 0x06)
-
-#define ARB_DIS                         (PM2_CONTROL | 0x01)
-
-#define TMR_VAL                         (PM_TIMER | 0x01)
-
-#define GPE0_STS                        (GPE0_STS_BLOCK | 0x01)
-#define GPE0_EN                         (GPE0_EN_BLOCK  | 0x01)
-
-#define GPE1_STS                        (GPE1_STS_BLOCK | 0x01)
-#define GPE1_EN                         (GPE1_EN_BLOCK  | 0x01)
-
-
-#define TMR_STS_MASK                    0x0001
-#define BM_STS_MASK                     0x0010
-#define GBL_STS_MASK                    0x0020
-#define PWRBTN_STS_MASK                 0x0100
-#define SLPBTN_STS_MASK                 0x0200
-#define RTC_STS_MASK                    0x0400
-#define WAK_STS_MASK                    0x8000
-
-#define ALL_FIXED_STS_BITS              (TMR_STS_MASK   | BM_STS_MASK  | GBL_STS_MASK \
-                                         | PWRBTN_STS_MASK | SLPBTN_STS_MASK \
-                                         | RTC_STS_MASK | WAK_STS_MASK)
-
-#define TMR_EN_MASK                     0x0001
-#define GBL_EN_MASK                     0x0020
-#define PWRBTN_EN_MASK                  0x0100
-#define SLPBTN_EN_MASK                  0x0200
-#define RTC_EN_MASK                     0x0400
-
-#define SCI_EN_MASK                     0x0001
-#define BM_RLD_MASK                     0x0002
-#define GBL_RLS_MASK                    0x0004
-#define SLP_TYPE_X_MASK                 0x1C00
-#define SLP_EN_MASK                     0x2000
-
-#define ARB_DIS_MASK                    0x0001
-#define TMR_VAL_MASK                    0xFFFFFFFF
-
-#define GPE0_STS_MASK
-#define GPE0_EN_MASK
-
-#define GPE1_STS_MASK
-#define GPE1_EN_MASK
-
-
-#define ACPI_READ                       1
-#define ACPI_WRITE                      2
+#define ACPI_BITREG_TIMER_STATUS                0x00
+#define ACPI_BITREG_BUS_MASTER_STATUS           0x01
+#define ACPI_BITREG_GLOBAL_LOCK_STATUS          0x02
+#define ACPI_BITREG_POWER_BUTTON_STATUS         0x03
+#define ACPI_BITREG_SLEEP_BUTTON_STATUS         0x04
+#define ACPI_BITREG_RT_CLOCK_STATUS             0x05
+#define ACPI_BITREG_WAKE_STATUS                 0x06
+
+#define ACPI_BITREG_TIMER_ENABLE                0x07
+#define ACPI_BITREG_GLOBAL_LOCK_ENABLE          0x08
+#define ACPI_BITREG_POWER_BUTTON_ENABLE         0x09
+#define ACPI_BITREG_SLEEP_BUTTON_ENABLE         0x0A
+#define ACPI_BITREG_RT_CLOCK_ENABLE             0x0B
+#define ACPI_BITREG_WAKE_ENABLE                 0x0C
+
+#define ACPI_BITREG_SCI_ENABLE                  0x0D
+#define ACPI_BITREG_BUS_MASTER_RLD              0x0E
+#define ACPI_BITREG_GLOBAL_LOCK_RELEASE         0x0F
+#define ACPI_BITREG_SLEEP_TYPE_A                0x10
+#define ACPI_BITREG_SLEEP_TYPE_B                0x11
+#define ACPI_BITREG_SLEEP_ENABLE                0x12
+
+#define ACPI_BITREG_ARB_DISABLE                 0x13
+
+#define ACPI_BITREG_MAX                         0x13
+#define ACPI_NUM_BITREG                         ACPI_BITREG_MAX + 1
+
+
+/* Masks used to access the Bit_registers */
+
+#define ACPI_BITMASK_TIMER_STATUS               0x0001
+#define ACPI_BITMASK_BUS_MASTER_STATUS          0x0010
+#define ACPI_BITMASK_GLOBAL_LOCK_STATUS         0x0020
+#define ACPI_BITMASK_POWER_BUTTON_STATUS        0x0100
+#define ACPI_BITMASK_SLEEP_BUTTON_STATUS        0x0200
+#define ACPI_BITMASK_RT_CLOCK_STATUS            0x0400
+#define ACPI_BITMASK_WAKE_STATUS                0x8000
+
+#define ACPI_BITMASK_ALL_FIXED_STATUS           (ACPI_BITMASK_TIMER_STATUS          | \
+                        ACPI_BITMASK_BUS_MASTER_STATUS     | \
+                        ACPI_BITMASK_GLOBAL_LOCK_STATUS    | \
+                        ACPI_BITMASK_POWER_BUTTON_STATUS   | \
+                        ACPI_BITMASK_SLEEP_BUTTON_STATUS   | \
+                        ACPI_BITMASK_RT_CLOCK_STATUS       | \
+                        ACPI_BITMASK_WAKE_STATUS)
+
+#define ACPI_BITMASK_TIMER_ENABLE               0x0001
+#define ACPI_BITMASK_GLOBAL_LOCK_ENABLE         0x0020
+#define ACPI_BITMASK_POWER_BUTTON_ENABLE        0x0100
+#define ACPI_BITMASK_SLEEP_BUTTON_ENABLE        0x0200
+#define ACPI_BITMASK_RT_CLOCK_ENABLE            0x0400
+
+#define ACPI_BITMASK_SCI_ENABLE                 0x0001
+#define ACPI_BITMASK_BUS_MASTER_RLD             0x0002
+#define ACPI_BITMASK_GLOBAL_LOCK_RELEASE        0x0004
+#define ACPI_BITMASK_SLEEP_TYPE_X               0x1C00
+#define ACPI_BITMASK_SLEEP_ENABLE               0x2000
+
+#define ACPI_BITMASK_ARB_DISABLE                0x0001
+
+
+/* Raw bit position of each Bit_register */
+
+#define ACPI_BITPOSITION_TIMER_STATUS           0x00
+#define ACPI_BITPOSITION_BUS_MASTER_STATUS      0x04
+#define ACPI_BITPOSITION_GLOBAL_LOCK_STATUS     0x05
+#define ACPI_BITPOSITION_POWER_BUTTON_STATUS    0x08
+#define ACPI_BITPOSITION_SLEEP_BUTTON_STATUS    0x09
+#define ACPI_BITPOSITION_RT_CLOCK_STATUS        0x0A
+#define ACPI_BITPOSITION_WAKE_STATUS            0x0F
+
+#define ACPI_BITPOSITION_TIMER_ENABLE           0x00
+#define ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE     0x05
+#define ACPI_BITPOSITION_POWER_BUTTON_ENABLE    0x08
+#define ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE    0x09
+#define ACPI_BITPOSITION_RT_CLOCK_ENABLE        0x0A
+
+#define ACPI_BITPOSITION_SCI_ENABLE             0x00
+#define ACPI_BITPOSITION_BUS_MASTER_RLD         0x01
+#define ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE    0x02
+#define ACPI_BITPOSITION_SLEEP_TYPE_X           0x0A
+#define ACPI_BITPOSITION_SLEEP_ENABLE           0x0D
+
+#define ACPI_BITPOSITION_ARB_DISABLE            0x00
 
 
 /*****************************************************************************
@@ -810,45 +804,45 @@ typedef struct acpi_parse_state
 
 /* Resource_type values */
 
-#define RESOURCE_TYPE_MEMORY_RANGE              0
-#define RESOURCE_TYPE_IO_RANGE                  1
-#define RESOURCE_TYPE_BUS_NUMBER_RANGE          2
+#define ACPI_RESOURCE_TYPE_MEMORY_RANGE         0
+#define ACPI_RESOURCE_TYPE_IO_RANGE             1
+#define ACPI_RESOURCE_TYPE_BUS_NUMBER_RANGE     2
 
 /* Resource descriptor types and masks */
 
-#define RESOURCE_DESC_TYPE_LARGE                0x80
-#define RESOURCE_DESC_TYPE_SMALL                0x00
+#define ACPI_RDESC_TYPE_LARGE                   0x80
+#define ACPI_RDESC_TYPE_SMALL                   0x00
 
-#define RESOURCE_DESC_TYPE_MASK                 0x80
-#define RESOURCE_DESC_SMALL_MASK                0x78        /* Only bits 6:3 contain the type */
+#define ACPI_RDESC_TYPE_MASK                    0x80
+#define ACPI_RDESC_SMALL_MASK                   0x78 /* Only bits 6:3 contain the type */
 
 
 /*
  * Small resource descriptor types
  * Note: The 3 length bits (2:0) must be zero
  */
-#define RESOURCE_DESC_IRQ_FORMAT                0x20
-#define RESOURCE_DESC_DMA_FORMAT                0x28
-#define RESOURCE_DESC_START_DEPENDENT           0x30
-#define RESOURCE_DESC_END_DEPENDENT             0x38
-#define RESOURCE_DESC_IO_PORT                   0x40
-#define RESOURCE_DESC_FIXED_IO_PORT             0x48
-#define RESOURCE_DESC_SMALL_VENDOR              0x70
-#define RESOURCE_DESC_END_TAG                   0x78
+#define ACPI_RDESC_TYPE_IRQ_FORMAT              0x20
+#define ACPI_RDESC_TYPE_DMA_FORMAT              0x28
+#define ACPI_RDESC_TYPE_START_DEPENDENT         0x30
+#define ACPI_RDESC_TYPE_END_DEPENDENT           0x38
+#define ACPI_RDESC_TYPE_IO_PORT                 0x40
+#define ACPI_RDESC_TYPE_FIXED_IO_PORT           0x48
+#define ACPI_RDESC_TYPE_SMALL_VENDOR            0x70
+#define ACPI_RDESC_TYPE_END_TAG                 0x78
 
 /*
  * Large resource descriptor types
  */
 
-#define RESOURCE_DESC_MEMORY_24                 0x81
-#define RESOURCE_DESC_GENERAL_REGISTER          0x82
-#define RESOURCE_DESC_LARGE_VENDOR              0x84
-#define RESOURCE_DESC_MEMORY_32                 0x85
-#define RESOURCE_DESC_FIXED_MEMORY_32           0x86
-#define RESOURCE_DESC_DWORD_ADDRESS_SPACE       0x87
-#define RESOURCE_DESC_WORD_ADDRESS_SPACE        0x88
-#define RESOURCE_DESC_EXTENDED_XRUPT            0x89
-#define RESOURCE_DESC_QWORD_ADDRESS_SPACE       0x8A
+#define ACPI_RDESC_TYPE_MEMORY_24               0x81
+#define ACPI_RDESC_TYPE_GENERAL_REGISTER        0x82
+#define ACPI_RDESC_TYPE_LARGE_VENDOR            0x84
+#define ACPI_RDESC_TYPE_MEMORY_32               0x85
+#define ACPI_RDESC_TYPE_FIXED_MEMORY_32         0x86
+#define ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE     0x87
+#define ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE      0x88
+#define ACPI_RDESC_TYPE_EXTENDED_XRUPT          0x89
+#define ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE     0x8A
 
 
 /* String version of device HIDs and UIDs */
@@ -868,7 +862,7 @@ typedef struct
  *
  ****************************************************************************/
 
-#define ASCII_ZERO                      0x30
+#define ACPI_ASCII_ZERO                      0x30
 
 /*****************************************************************************
  *
@@ -885,7 +879,12 @@ typedef struct dbmethodinfo
        u32                     num_loops;
        NATIVE_CHAR             pathname[128];
 
-} db_method_info;
+} acpi_db_method_info;
+
+
+#define ACPI_DB_REDIRECTABLE_OUTPUT  0x01
+#define ACPI_DB_CONSOLE_OUTPUT       0x02
+#define ACPI_DB_DUPLICATE_OUTPUT     0x03
 
 
 /*****************************************************************************
@@ -905,10 +904,9 @@ typedef struct
 
 /* Entry for a memory allocation (debug only) */
 
-
-#define MEM_MALLOC                      0
-#define MEM_CALLOC                      1
-#define MAX_MODULE_NAME                 16
+#define ACPI_MEM_MALLOC                      0
+#define ACPI_MEM_CALLOC                      1
+#define ACPI_MAX_MODULE_NAME                 16
 
 #define ACPI_COMMON_DEBUG_MEM_HEADER \
        struct acpi_debug_mem_block *previous; \
@@ -916,10 +914,9 @@ typedef struct
        u32                         size; \
        u32                         component; \
        u32                         line; \
-       NATIVE_CHAR                 module[MAX_MODULE_NAME]; \
+       NATIVE_CHAR                 module[ACPI_MAX_MODULE_NAME]; \
        u8                          alloc_type;
 
-
 typedef struct
 {
        ACPI_COMMON_DEBUG_MEM_HEADER
index 69fa21372d07aac1cf2954b3098e8a5a05edc9bf..24a9006b03d2b7b0acff4b8fdb282c40f89265f7 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Name: acmacros.h - C macros for the entire subsystem.
- *       $Revision: 97 $
+ *       $Revision: 115 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  * Data manipulation macros
  */
 
-#ifndef LOWORD
-#define LOWORD(l)                       ((u16)(NATIVE_UINT)(l))
-#endif
-
-#ifndef HIWORD
-#define HIWORD(l)                       ((u16)((((NATIVE_UINT)(l)) >> 16) & 0xFFFF))
-#endif
-
-#ifndef LOBYTE
-#define LOBYTE(l)                       ((u8)(u16)(l))
-#endif
-
-#ifndef HIBYTE
-#define HIBYTE(l)                       ((u8)((((u16)(l)) >> 8) & 0xFF))
-#endif
-
-#define BIT0(x)                         ((((x) & 0x01) > 0) ? 1 : 0)
-#define BIT1(x)                         ((((x) & 0x02) > 0) ? 1 : 0)
-#define BIT2(x)                         ((((x) & 0x04) > 0) ? 1 : 0)
-
-#define BIT3(x)                         ((((x) & 0x08) > 0) ? 1 : 0)
-#define BIT4(x)                         ((((x) & 0x10) > 0) ? 1 : 0)
-#define BIT5(x)                         ((((x) & 0x20) > 0) ? 1 : 0)
-#define BIT6(x)                         ((((x) & 0x40) > 0) ? 1 : 0)
-#define BIT7(x)                         ((((x) & 0x80) > 0) ? 1 : 0)
-
-#define LOW_BASE(w)                     ((u16) ((w) & 0x0000FFFF))
-#define MID_BASE(b)                     ((u8) (((b) & 0x00FF0000) >> 16))
-#define HI_BASE(b)                      ((u8) (((b) & 0xFF000000) >> 24))
-#define LOW_LIMIT(w)                    ((u16) ((w) & 0x0000FFFF))
-#define HI_LIMIT(b)                     ((u8) (((b) & 0x00FF0000) >> 16))
+#define ACPI_LOWORD(l)                  ((u16)(NATIVE_UINT)(l))
+#define ACPI_HIWORD(l)                  ((u16)((((NATIVE_UINT)(l)) >> 16) & 0xFFFF))
+#define ACPI_LOBYTE(l)                  ((u8)(u16)(l))
+#define ACPI_HIBYTE(l)                  ((u8)((((u16)(l)) >> 8) & 0xFF))
 
 
 #ifdef _IA16
  * For 16-bit addresses, we have to assume that the upper 32 bits
  * are zero.
  */
-#ifndef LODWORD
-#define LODWORD(l)                      (l)
-#endif
-
-#ifndef HIDWORD
-#define HIDWORD(l)                      (0)
-#endif
+#define ACPI_LODWORD(l)                 (l)
+#define ACPI_HIDWORD(l)                 (0)
 
 #define ACPI_GET_ADDRESS(a)             ((a).lo)
 #define ACPI_STORE_ADDRESS(a,b)         {(a).hi=0;(a).lo=(b);}
 /*
  * acpi_integer is 32-bits, no 64-bit support on this platform
  */
-#ifndef LODWORD
-#define LODWORD(l)                      ((u32)(l))
-#endif
-
-#ifndef HIDWORD
-#define HIDWORD(l)                      (0)
-#endif
+#define ACPI_LODWORD(l)                 ((u32)(l))
+#define ACPI_HIDWORD(l)                 (0)
 
 #define ACPI_GET_ADDRESS(a)             (a)
 #define ACPI_STORE_ADDRESS(a,b)         ((a)=(b))
 /*
  * Full 64-bit address/integer on both 32-bit and 64-bit platforms
  */
-#ifndef LODWORD
-#define LODWORD(l)                      ((u32)(u64)(l))
-#endif
-
-#ifndef HIDWORD
-#define HIDWORD(l)                      ((u32)(((*(uint64_struct *)(&l))).hi))
-#endif
+#define ACPI_LODWORD(l)                 ((u32)(u64)(l))
+#define ACPI_HIDWORD(l)                 ((u32)(((*(uint64_struct *)(&l))).hi))
 
 #define ACPI_GET_ADDRESS(a)             (a)
 #define ACPI_STORE_ADDRESS(a,b)         ((a)=(b))
   * Extract a byte of data using a pointer.  Any more than a byte and we
   * get into potential aligment issues -- see the STORE macros below
   */
-#define GET8(addr)                      (*(u8*)(addr))
+#define ACPI_GET8(addr)                 (*(u8*)(addr))
 
 /* Pointer arithmetic */
 
+#define ACPI_PTR_ADD(t,a,b)             (t *) ((char *)(a) + (b))
+#define ACPI_PTR_DIFF(a,b)              (NATIVE_UINT) ((char *)(a) - (char *)(b))
+
+/* Pointer/Integer type conversions */
 
-#define POINTER_ADD(t,a,b)              (t *) ((NATIVE_UINT)(a) + (NATIVE_UINT)(b))
-#define POINTER_DIFF(a,b)               ((u32) ((NATIVE_UINT)(a) - (NATIVE_UINT)(b)))
+#define ACPI_TO_POINTER(i)              ACPI_PTR_ADD (void,NULL,(NATIVE_UINT)i)
+#define ACPI_TO_INTEGER(p)              ACPI_PTR_DIFF (p,NULL)
+#define ACPI_OFFSET(d,o)                ((ACPI_SIZE) ACPI_TO_INTEGER (&(((d *)0)->o)))
+#define ACPI_FADT_OFFSET(o)             ACPI_OFFSET (FADT_DESCRIPTOR, o)
+
+
+#ifdef _IA16
+#define ACPI_PHYSADDR_TO_PTR(i)         (void *)(i)
+#define ACPI_PTR_TO_PHYSADDR(i)         (char *)(i)
+#else
+#define ACPI_PHYSADDR_TO_PTR(i)         ACPI_TO_POINTER(i)
+#define ACPI_PTR_TO_PHYSADDR(i)         ACPI_TO_INTEGER(i)
+#endif
 
 /*
  * Macros for moving data around to/from buffers that are possibly unaligned.
 
 /* The hardware supports unaligned transfers, just do the move */
 
-#define MOVE_UNALIGNED16_TO_16(d,s)     *(u16*)(d) = *(u16*)(s)
-#define MOVE_UNALIGNED32_TO_32(d,s)     *(u32*)(d) = *(u32*)(s)
-#define MOVE_UNALIGNED16_TO_32(d,s)     *(u32*)(d) = *(u16*)(s)
-#define MOVE_UNALIGNED64_TO_64(d,s)     *(u64*)(d) = *(u64*)(s)
+#define ACPI_MOVE_UNALIGNED16_TO_16(d,s)    *(u16 *)(d) = *(u16 *)(s)
+#define ACPI_MOVE_UNALIGNED32_TO_32(d,s)    *(u32 *)(d) = *(u32 *)(s)
+#define ACPI_MOVE_UNALIGNED16_TO_32(d,s)    *(u32 *)(d) = *(u16 *)(s)
+#define ACPI_MOVE_UNALIGNED64_TO_64(d,s)    *(u64 *)(d) = *(u64 *)(s)
 
 #else
 /*
  * the destination (or both) is/are unaligned.
  */
 
-#define MOVE_UNALIGNED16_TO_16(d,s)     {((u8 *)(d))[0] = ((u8 *)(s))[0];\
-        ((u8 *)(d))[1] = ((u8 *)(s))[1];}
+#define ACPI_MOVE_UNALIGNED16_TO_16(d,s)    {((u8 *)(d))[0] = ((u8 *)(s))[0];\
+         ((u8 *)(d))[1] = ((u8 *)(s))[1];}
 
-#define MOVE_UNALIGNED32_TO_32(d,s)     {((u8 *)(d))[0] = ((u8 *)(s))[0];\
-                         ((u8 *)(d))[1] = ((u8 *)(s))[1];\
-                         ((u8 *)(d))[2] = ((u8 *)(s))[2];\
-                         ((u8 *)(d))[3] = ((u8 *)(s))[3];}
+#define ACPI_MOVE_UNALIGNED32_TO_32(d,s)    {((u8 *)(d))[0] = ((u8 *)(s))[0];\
+                          ((u8 *)(d))[1] = ((u8 *)(s))[1];\
+                          ((u8 *)(d))[2] = ((u8 *)(s))[2];\
+                          ((u8 *)(d))[3] = ((u8 *)(s))[3];}
 
-#define MOVE_UNALIGNED16_TO_32(d,s)     {(*(u32*)(d)) = 0; MOVE_UNALIGNED16_TO_16(d,s);}
+#define ACPI_MOVE_UNALIGNED16_TO_32(d,s)    {(*(u32*)(d)) = 0; ACPI_MOVE_UNALIGNED16_TO_16(d,s);}
 
-#define MOVE_UNALIGNED64_TO_64(d,s)     {((u8 *)(d))[0] = ((u8 *)(s))[0];\
-                                          ((u8 *)(d))[1] = ((u8 *)(s))[1];\
-                                          ((u8 *)(d))[2] = ((u8 *)(s))[2];\
-                                          ((u8 *)(d))[3] = ((u8 *)(s))[3];\
-                                          ((u8 *)(d))[4] = ((u8 *)(s))[4];\
-                                          ((u8 *)(d))[5] = ((u8 *)(s))[5];\
-                                          ((u8 *)(d))[6] = ((u8 *)(s))[6];\
-                                          ((u8 *)(d))[7] = ((u8 *)(s))[7];}
+#define ACPI_MOVE_UNALIGNED64_TO_64(d,s)    {((u8 *)(d))[0] = ((u8 *)(s))[0];\
+                                        ((u8 *)(d))[1] = ((u8 *)(s))[1];\
+                                        ((u8 *)(d))[2] = ((u8 *)(s))[2];\
+                                        ((u8 *)(d))[3] = ((u8 *)(s))[3];\
+                                        ((u8 *)(d))[4] = ((u8 *)(s))[4];\
+                                        ((u8 *)(d))[5] = ((u8 *)(s))[5];\
+                                        ((u8 *)(d))[6] = ((u8 *)(s))[6];\
+                                        ((u8 *)(d))[7] = ((u8 *)(s))[7];}
 
 #endif
 
  * Fast power-of-two math macros for non-optimized compilers
  */
 
-#define _DIV(value,power_of2)           ((u32) ((value) >> (power_of2)))
-#define _MUL(value,power_of2)           ((u32) ((value) << (power_of2)))
-#define _MOD(value,divisor)             ((u32) ((value) & ((divisor) -1)))
+#define _ACPI_DIV(value,power_of2)      ((u32) ((value) >> (power_of2)))
+#define _ACPI_MUL(value,power_of2)      ((u32) ((value) << (power_of2)))
+#define _ACPI_MOD(value,divisor)        ((u32) ((value) & ((divisor) -1)))
 
-#define DIV_2(a)                        _DIV(a,1)
-#define MUL_2(a)                        _MUL(a,1)
-#define MOD_2(a)                        _MOD(a,2)
+#define ACPI_DIV_2(a)                   _ACPI_DIV(a,1)
+#define ACPI_MUL_2(a)                   _ACPI_MUL(a,1)
+#define ACPI_MOD_2(a)                   _ACPI_MOD(a,2)
 
-#define DIV_4(a)                        _DIV(a,2)
-#define MUL_4(a)                        _MUL(a,2)
-#define MOD_4(a)                        _MOD(a,4)
+#define ACPI_DIV_4(a)                   _ACPI_DIV(a,2)
+#define ACPI_MUL_4(a)                   _ACPI_MUL(a,2)
+#define ACPI_MOD_4(a)                   _ACPI_MOD(a,4)
 
-#define DIV_8(a)                        _DIV(a,3)
-#define MUL_8(a)                        _MUL(a,3)
-#define MOD_8(a)                        _MOD(a,8)
+#define ACPI_DIV_8(a)                   _ACPI_DIV(a,3)
+#define ACPI_MUL_8(a)                   _ACPI_MUL(a,3)
+#define ACPI_MOD_8(a)                   _ACPI_MOD(a,8)
 
-#define DIV_16(a)                       _DIV(a,4)
-#define MUL_16(a)                       _MUL(a,4)
-#define MOD_16(a)                       _MOD(a,16)
+#define ACPI_DIV_16(a)                  _ACPI_DIV(a,4)
+#define ACPI_MUL_16(a)                  _ACPI_MUL(a,4)
+#define ACPI_MOD_16(a)                  _ACPI_MOD(a,16)
 
 
 /*
  * Rounding macros (Power of two boundaries only)
  */
-#define ROUND_DOWN(value,boundary)      ((value) & (~((boundary)-1)))
-#define ROUND_UP(value,boundary)        (((value) + ((boundary)-1)) & (~((boundary)-1)))
+#define ACPI_ROUND_DOWN(value,boundary)      (((NATIVE_UINT)(value)) & (~((boundary)-1)))
+#define ACPI_ROUND_UP(value,boundary)        ((((NATIVE_UINT)(value)) + ((boundary)-1)) & (~((boundary)-1)))
 
-#define ROUND_DOWN_TO_32_BITS(a)        ROUND_DOWN(a,4)
-#define ROUND_DOWN_TO_64_BITS(a)        ROUND_DOWN(a,8)
-#define ROUND_DOWN_TO_NATIVE_WORD(a)    ROUND_DOWN(a,ALIGNED_ADDRESS_BOUNDARY)
+#define ACPI_ROUND_DOWN_TO_32_BITS(a)        ACPI_ROUND_DOWN(a,4)
+#define ACPI_ROUND_DOWN_TO_64_BITS(a)        ACPI_ROUND_DOWN(a,8)
+#define ACPI_ROUND_DOWN_TO_NATIVE_WORD(a)    ACPI_ROUND_DOWN(a,ALIGNED_ADDRESS_BOUNDARY)
 
-#define ROUND_UP_TO_32_bITS(a)          ROUND_UP(a,4)
-#define ROUND_UP_TO_64_bITS(a)          ROUND_UP(a,8)
-#define ROUND_UP_TO_NATIVE_WORD(a)      ROUND_UP(a,ALIGNED_ADDRESS_BOUNDARY)
+#define ACPI_ROUND_UP_TO_32_bITS(a)          ACPI_ROUND_UP(a,4)
+#define ACPI_ROUND_UP_TO_64_bITS(a)          ACPI_ROUND_UP(a,8)
+#define ACPI_ROUND_UP_TO_NATIVE_WORD(a)      ACPI_ROUND_UP(a,ALIGNED_ADDRESS_BOUNDARY)
 
-#define ROUND_PTR_UP_TO_4(a,b)          ((b *)(((NATIVE_UINT)(a) + 3) & ~3))
-#define ROUND_PTR_UP_TO_8(a,b)          ((b *)(((NATIVE_UINT)(a) + 7) & ~7))
 
-#define ROUND_BITS_UP_TO_BYTES(a)       DIV_8((a) + 7)
-#define ROUND_BITS_DOWN_TO_BYTES(a)     DIV_8((a))
+#define ACPI_ROUND_BITS_UP_TO_BYTES(a)       ACPI_DIV_8((a) + 7)
+#define ACPI_ROUND_BITS_DOWN_TO_BYTES(a)     ACPI_DIV_8((a))
 
-#define ROUND_UP_TO_1K(a)               (((a) + 1023) >> 10)
+#define ACPI_ROUND_UP_TO_1K(a)               (((a) + 1023) >> 10)
 
 /* Generic (non-power-of-two) rounding */
 
-#define ROUND_UP_TO(value,boundary)     (((value) + ((boundary)-1)) / (boundary))
+#define ACPI_ROUND_UP_TO(value,boundary)     (((value) + ((boundary)-1)) / (boundary))
 
 /*
  * Bitmask creation
  * MASK_BITS_ABOVE creates a mask starting AT the position and above
  * MASK_BITS_BELOW creates a mask starting one bit BELOW the position
  */
-#define MASK_BITS_ABOVE(position)       (~(((u32)(-1)) << ((u32) (position))))
-#define MASK_BITS_BELOW(position)       (((u32)(-1)) << ((u32) (position)))
+#define ACPI_MASK_BITS_ABOVE(position)       (~(((acpi_integer)(-1)) << ((u32) (position))))
+#define ACPI_MASK_BITS_BELOW(position)       (((acpi_integer)(-1)) << ((u32) (position)))
 
+#define ACPI_IS_OCTAL_DIGIT(d)               (((char)(d) >= '0') && ((char)(d) <= '7'))
 
 /* Macros for GAS addressing */
 
 
 #endif
 
+
+/* Bitfields within ACPI registers */
+
+#define ACPI_REGISTER_PREPARE_BITS(val, pos, mask)      ((val << pos) & mask)
+#define ACPI_REGISTER_INSERT_VALUE(reg, pos, mask, val)  reg = (reg & (~(mask))) | ACPI_REGISTER_PREPARE_BITS(val, pos, mask)
+
 /*
- * An acpi_handle (which is actually an acpi_namespace_node *) can appear in some contexts,
- * such as on ap_obj_stack, where a pointer to an acpi_operand_object can also
+ * An acpi_namespace_node * can appear in some contexts,
+ * where a pointer to an acpi_operand_object  can also
  * appear.  This macro is used to distinguish them.
  *
- * The Data_type field is the first field in both structures.
+ * The "Descriptor" field is the first field in both structures.
  */
-#define VALID_DESCRIPTOR_TYPE(d,t)      (((acpi_namespace_node *)d)->data_type == t)
+#define ACPI_GET_DESCRIPTOR_TYPE(d)     (((acpi_namespace_node *)d)->descriptor)
+#define ACPI_SET_DESCRIPTOR_TYPE(d,t)   (((acpi_namespace_node *)d)->descriptor = t)
 
 
 /* Macro to test the object type */
 
-#define IS_THIS_OBJECT_TYPE(d,t)        (((acpi_operand_object  *)d)->common.type == (u8)t)
+#define ACPI_GET_OBJECT_TYPE(d)         (((acpi_operand_object *)d)->common.type)
 
 /* Macro to check the table flags for SINGLE or MULTIPLE tables are allowed */
 
-#define IS_SINGLE_TABLE(x)              (((x) & 0x01) == ACPI_TABLE_SINGLE ? 1 : 0)
+#define ACPI_IS_SINGLE_TABLE(x)         (((x) & 0x01) == ACPI_TABLE_SINGLE ? 1 : 0)
 
 /*
  * Macro to check if a pointer is within an ACPI table.
  * and ((u8 *)b+b->Length) points one byte past the end of the table.
  */
 #ifndef _IA16
-#define IS_IN_ACPI_TABLE(a,b)           (((u8 *)(a) >= (u8 *)(b + 1)) &&\
-                                                          ((u8 *)(a) < ((u8 *)b + b->length)))
+#define ACPI_IS_IN_ACPI_TABLE(a,b)      (((u8 *)(a) >= (u8 *)(b + 1)) &&\
+                                                        ((u8 *)(a) < ((u8 *)b + b->length)))
 
 #else
-#define IS_IN_ACPI_TABLE(a,b)           (_segment)(a) == (_segment)(b) &&\
+#define ACPI_IS_IN_ACPI_TABLE(a,b)      (_segment)(a) == (_segment)(b) &&\
                                                                         (((u8 *)(a) >= (u8 *)(b + 1)) &&\
                                                                         ((u8 *)(a) < ((u8 *)b + b->length)))
 #endif
  * Macros for the master AML opcode table
  */
 #ifdef ACPI_DEBUG
-#define ACPI_OP(name,Pargs,Iargs,class,type,flags)     {Pargs,Iargs,flags,class,type,name}
+#define ACPI_OP(name,Pargs,Iargs,obj_type,class,type,flags)    {name,Pargs,Iargs,flags,obj_type,class,type}
 #else
-#define ACPI_OP(name,Pargs,Iargs,class,type,flags)     {Pargs,Iargs,flags,class,type}
+#define ACPI_OP(name,Pargs,Iargs,obj_type,class,type,flags)    {Pargs,Iargs,flags,obj_type,class,type}
 #endif
 
 #define ARG_TYPE_WIDTH                  5
  * 5) Expand address to 64 bits
  */
 #define ASL_BUILD_GAS_FROM_ENTRY(a,b,c,d)   {a.address_space_id = (u8) d;\
-                                                                                        a.register_bit_width = (u8) MUL_8 (b);\
+                                                                                        a.register_bit_width = (u8) ACPI_MUL_8 (b);\
                                                                                         a.register_bit_offset = 0;\
                                                                                         a.reserved = 0;\
                                                                                         ACPI_STORE_ADDRESS (a.address,c);}
  * Reporting macros that are never compiled out
  */
 
-#define PARAM_LIST(pl)                  pl
+#define ACPI_PARAM_LIST(pl)                  pl
 
 /*
  * Error reporting.  These versions add callers module and line#.  Since
 
 #ifdef ACPI_DEBUG
 
-#define REPORT_INFO(fp)                 {acpi_ut_report_info(_THIS_MODULE,__LINE__,_COMPONENT); \
-                                                                                       acpi_os_printf PARAM_LIST(fp);}
-#define REPORT_ERROR(fp)                {acpi_ut_report_error(_THIS_MODULE,__LINE__,_COMPONENT); \
-                                                                                       acpi_os_printf PARAM_LIST(fp);}
-#define REPORT_WARNING(fp)              {acpi_ut_report_warning(_THIS_MODULE,__LINE__,_COMPONENT); \
-                                                                                       acpi_os_printf PARAM_LIST(fp);}
+#define ACPI_REPORT_INFO(fp)                {acpi_ut_report_info(_THIS_MODULE,__LINE__,_COMPONENT); \
+                                                                                               acpi_os_printf ACPI_PARAM_LIST(fp);}
+#define ACPI_REPORT_ERROR(fp)               {acpi_ut_report_error(_THIS_MODULE,__LINE__,_COMPONENT); \
+                                                                                               acpi_os_printf ACPI_PARAM_LIST(fp);}
+#define ACPI_REPORT_WARNING(fp)             {acpi_ut_report_warning(_THIS_MODULE,__LINE__,_COMPONENT); \
+                                                                                               acpi_os_printf ACPI_PARAM_LIST(fp);}
 
 #else
 
-#define REPORT_INFO(fp)                 {acpi_ut_report_info("ACPI",__LINE__,_COMPONENT); \
-                                                                                       acpi_os_printf PARAM_LIST(fp);}
-#define REPORT_ERROR(fp)                {acpi_ut_report_error("ACPI",__LINE__,_COMPONENT); \
-                                                                                       acpi_os_printf PARAM_LIST(fp);}
-#define REPORT_WARNING(fp)              {acpi_ut_report_warning("ACPI",__LINE__,_COMPONENT); \
-                                                                                       acpi_os_printf PARAM_LIST(fp);}
+#define ACPI_REPORT_INFO(fp)                {acpi_ut_report_info("ACPI",__LINE__,_COMPONENT); \
+                                                                                               acpi_os_printf ACPI_PARAM_LIST(fp);}
+#define ACPI_REPORT_ERROR(fp)               {acpi_ut_report_error("ACPI",__LINE__,_COMPONENT); \
+                                                                                               acpi_os_printf ACPI_PARAM_LIST(fp);}
+#define ACPI_REPORT_WARNING(fp)             {acpi_ut_report_warning("ACPI",__LINE__,_COMPONENT); \
+                                                                                               acpi_os_printf ACPI_PARAM_LIST(fp);}
 
 #endif
 
 /* Error reporting.  These versions pass thru the module and line# */
 
-#define _REPORT_INFO(a,b,c,fp)          {acpi_ut_report_info(a,b,c); \
-                                                                                       acpi_os_printf PARAM_LIST(fp);}
-#define _REPORT_ERROR(a,b,c,fp)         {acpi_ut_report_error(a,b,c); \
-                                                                                       acpi_os_printf PARAM_LIST(fp);}
-#define _REPORT_WARNING(a,b,c,fp)       {acpi_ut_report_warning(a,b,c); \
-                                                                                       acpi_os_printf PARAM_LIST(fp);}
+#define _ACPI_REPORT_INFO(a,b,c,fp)         {acpi_ut_report_info(a,b,c); \
+                                                                                               acpi_os_printf ACPI_PARAM_LIST(fp);}
+#define _ACPI_REPORT_ERROR(a,b,c,fp)        {acpi_ut_report_error(a,b,c); \
+                                                                                               acpi_os_printf ACPI_PARAM_LIST(fp);}
+#define _ACPI_REPORT_WARNING(a,b,c,fp)      {acpi_ut_report_warning(a,b,c); \
+                                                                                               acpi_os_printf ACPI_PARAM_LIST(fp);}
 
 /*
  * Debug macros that are conditionally compiled
 
 #ifdef ACPI_DEBUG
 
-#define MODULE_NAME(name)               static char *_THIS_MODULE = name;
+#define ACPI_MODULE_NAME(name)               static char *_THIS_MODULE = name;
 
 /*
  * Function entry tracing.
  * as a local string ("_Proc_name) so that it can be also used by the function exit macros below.
  */
 
-#define PROC_NAME(a)                    acpi_debug_print_info _dbg;     \
+#define ACPI_FUNCTION_NAME(a)           acpi_debug_print_info _dbg;     \
                                                                                _dbg.component_id = _COMPONENT; \
                                                                                _dbg.proc_name   = a;           \
                                                                                _dbg.module_name = _THIS_MODULE;
 
-#define FUNCTION_TRACE(a)               PROC_NAME(a)\
-                                                                               acpi_ut_trace(__LINE__,&_dbg)
-#define FUNCTION_TRACE_PTR(a,b)         PROC_NAME(a)\
-                                                                               acpi_ut_trace_ptr(__LINE__,&_dbg,(void *)b)
-#define FUNCTION_TRACE_U32(a,b)         PROC_NAME(a)\
-                                                                               acpi_ut_trace_u32(__LINE__,&_dbg,(u32)b)
-#define FUNCTION_TRACE_STR(a,b)         PROC_NAME(a)\
-                                                                               acpi_ut_trace_str(__LINE__,&_dbg,(NATIVE_CHAR *)b)
+#define ACPI_FUNCTION_TRACE(a)          ACPI_FUNCTION_NAME(a)\
+                                                                                       acpi_ut_trace(__LINE__,&_dbg)
+#define ACPI_FUNCTION_TRACE_PTR(a,b)    ACPI_FUNCTION_NAME(a)\
+                                                                                       acpi_ut_trace_ptr(__LINE__,&_dbg,(void *)b)
+#define ACPI_FUNCTION_TRACE_U32(a,b)    ACPI_FUNCTION_NAME(a)\
+                                                                                       acpi_ut_trace_u32(__LINE__,&_dbg,(u32)b)
+#define ACPI_FUNCTION_TRACE_STR(a,b)    ACPI_FUNCTION_NAME(a)\
+                                                                                       acpi_ut_trace_str(__LINE__,&_dbg,(NATIVE_CHAR *)b)
 
-#define FUNCTION_ENTRY()                acpi_ut_track_stack_ptr()
+#define ACPI_FUNCTION_ENTRY()           acpi_ut_track_stack_ptr()
 
 /*
  * Function exit tracing.
 
 /* Conditional execution */
 
-#define DEBUG_EXEC(a)                   a
-#define NORMAL_EXEC(a)
+#define ACPI_DEBUG_EXEC(a)              a
+#define ACPI_NORMAL_EXEC(a)
 
-#define DEBUG_DEFINE(a)                 a;
-#define DEBUG_ONLY_MEMBERS(a)           a;
+#define ACPI_DEBUG_DEFINE(a)            a;
+#define ACPI_DEBUG_ONLY_MEMBERS(a)      a;
 #define _OPCODE_NAMES
 #define _VERBOSE_STRUCTURES
 
 
 /* Stack and buffer dumping */
 
-#define DUMP_STACK_ENTRY(a)             acpi_ex_dump_operand(a)
-#define DUMP_OPERANDS(a,b,c,d,e)        acpi_ex_dump_operands(a,b,c,d,e,_THIS_MODULE,__LINE__)
+#define ACPI_DUMP_STACK_ENTRY(a)        acpi_ex_dump_operand(a)
+#define ACPI_DUMP_OPERANDS(a,b,c,d,e)   acpi_ex_dump_operands(a,b,c,d,e,_THIS_MODULE,__LINE__)
 
 
-#define DUMP_ENTRY(a,b)                 acpi_ns_dump_entry (a,b)
-#define DUMP_TABLES(a,b)                acpi_ns_dump_tables(a,b)
-#define DUMP_PATHNAME(a,b,c,d)          acpi_ns_dump_pathname(a,b,c,d)
-#define DUMP_RESOURCE_LIST(a)           acpi_rs_dump_resource_list(a)
-#define DUMP_BUFFER(a,b)                acpi_ut_dump_buffer((u8 *)a,b,DB_BYTE_DISPLAY,_COMPONENT)
-#define BREAK_MSG(a)                    acpi_os_signal (ACPI_SIGNAL_BREAKPOINT,(a))
+#define ACPI_DUMP_ENTRY(a,b)            acpi_ns_dump_entry (a,b)
+#define ACPI_DUMP_TABLES(a,b)           acpi_ns_dump_tables(a,b)
+#define ACPI_DUMP_PATHNAME(a,b,c,d)     acpi_ns_dump_pathname(a,b,c,d)
+#define ACPI_DUMP_RESOURCE_LIST(a)      acpi_rs_dump_resource_list(a)
+#define ACPI_DUMP_BUFFER(a,b)           acpi_ut_dump_buffer((u8 *)a,b,DB_BYTE_DISPLAY,_COMPONENT)
+#define ACPI_BREAK_MSG(a)               acpi_os_signal (ACPI_SIGNAL_BREAKPOINT,(a))
 
 
 /*
  * Generate INT3 on ACPI_ERROR (Debug only!)
  */
 
-#define ERROR_BREAK
-#ifdef  ERROR_BREAK
-#define BREAK_ON_ERROR(lvl)              if ((lvl)&ACPI_ERROR) acpi_os_signal(ACPI_SIGNAL_BREAKPOINT,"Fatal error encountered\n")
+#define ACPI_ERROR_BREAK
+#ifdef  ACPI_ERROR_BREAK
+#define ACPI_BREAK_ON_ERROR(lvl)        if ((lvl)&ACPI_ERROR) \
+                                                                                       acpi_os_signal(ACPI_SIGNAL_BREAKPOINT,"Fatal error encountered\n")
 #else
-#define BREAK_ON_ERROR(lvl)
+#define ACPI_BREAK_ON_ERROR(lvl)
 #endif
 
 /*
  *    2) Debug error level or trace level for the print statement is enabled
  */
 
-#define ACPI_DEBUG_PRINT(pl)            acpi_ut_debug_print PARAM_LIST(pl)
-#define ACPI_DEBUG_PRINT_RAW(pl)        acpi_ut_debug_print_raw PARAM_LIST(pl)
+#define ACPI_DEBUG_PRINT(pl)            acpi_ut_debug_print ACPI_PARAM_LIST(pl)
+#define ACPI_DEBUG_PRINT_RAW(pl)        acpi_ut_debug_print_raw ACPI_PARAM_LIST(pl)
 
 
 #else
  * leaving no executable debug code!
  */
 
-#define MODULE_NAME(name)
+#define ACPI_MODULE_NAME(name)
 #define _THIS_MODULE ""
 
-#define DEBUG_EXEC(a)
-#define NORMAL_EXEC(a)                  a;
-
-#define DEBUG_DEFINE(a)
-#define DEBUG_ONLY_MEMBERS(a)
-#define PROC_NAME(a)
-#define FUNCTION_TRACE(a)
-#define FUNCTION_TRACE_PTR(a,b)
-#define FUNCTION_TRACE_U32(a,b)
-#define FUNCTION_TRACE_STR(a,b)
-#define FUNCTION_EXIT
-#define FUNCTION_STATUS_EXIT(s)
-#define FUNCTION_VALUE_EXIT(s)
-#define FUNCTION_ENTRY()
-#define DUMP_STACK_ENTRY(a)
-#define DUMP_OPERANDS(a,b,c,d,e)
-#define DUMP_ENTRY(a,b)
-#define DUMP_TABLES(a,b)
-#define DUMP_PATHNAME(a,b,c,d)
-#define DUMP_RESOURCE_LIST(a)
-#define DUMP_BUFFER(a,b)
+#define ACPI_DEBUG_EXEC(a)
+#define ACPI_NORMAL_EXEC(a)             a;
+
+#define ACPI_DEBUG_DEFINE(a)
+#define ACPI_DEBUG_ONLY_MEMBERS(a)
+#define ACPI_FUNCTION_NAME(a)
+#define ACPI_FUNCTION_TRACE(a)
+#define ACPI_FUNCTION_TRACE_PTR(a,b)
+#define ACPI_FUNCTION_TRACE_U32(a,b)
+#define ACPI_FUNCTION_TRACE_STR(a,b)
+#define ACPI_FUNCTION_EXIT
+#define ACPI_FUNCTION_STATUS_EXIT(s)
+#define ACPI_FUNCTION_VALUE_EXIT(s)
+#define ACPI_FUNCTION_ENTRY()
+#define ACPI_DUMP_STACK_ENTRY(a)
+#define ACPI_DUMP_OPERANDS(a,b,c,d,e)
+#define ACPI_DUMP_ENTRY(a,b)
+#define ACPI_DUMP_TABLES(a,b)
+#define ACPI_DUMP_PATHNAME(a,b,c,d)
+#define ACPI_DUMP_RESOURCE_LIST(a)
+#define ACPI_DUMP_BUFFER(a,b)
 #define ACPI_DEBUG_PRINT(pl)
 #define ACPI_DEBUG_PRINT_RAW(pl)
-#define BREAK_MSG(a)
+#define ACPI_BREAK_MSG(a)
 
 #define return_VOID                     return
 #define return_ACPI_STATUS(s)           return(s)
  * DEBUG_PRINT stuff (set by ACPI_DEBUG) is on, or not.
  */
 #ifdef ENABLE_DEBUGGER
-#define DEBUGGER_EXEC(a)                a
+#define ACPI_DEBUGGER_EXEC(a)           a
 #else
-#define DEBUGGER_EXEC(a)
+#define ACPI_DEBUGGER_EXEC(a)
 #endif
 
 
  * we are using ACPI_DEBUG to get the debug output
  */
 #ifdef _IA16
-#undef DEBUG_ONLY_MEMBERS
+#undef ACPI_DEBUG_ONLY_MEMBERS
 #undef _VERBOSE_STRUCTURES
-#define DEBUG_ONLY_MEMBERS(a)
+#define ACPI_DEBUG_ONLY_MEMBERS(a)
 #endif
 
 
  * 1) Set name to blanks
  * 2) Copy the object name
  */
-#define ADD_OBJECT_NAME(a,b)            MEMSET (a->common.name, ' ', sizeof (a->common.name));\
-                                                                               STRNCPY (a->common.name, acpi_gbl_ns_type_names[b], sizeof (a->common.name))
+#define ACPI_ADD_OBJECT_NAME(a,b)       ACPI_MEMSET (a->common.name, ' ', sizeof (a->common.name));\
+                                                                               ACPI_STRNCPY (a->common.name, acpi_gbl_ns_type_names[b], sizeof (a->common.name))
 #else
 
-#define ADD_OBJECT_NAME(a,b)
+#define ACPI_ADD_OBJECT_NAME(a,b)
 #endif
 
 
 
 /* Memory allocation */
 
-#define ACPI_MEM_ALLOCATE(a)            acpi_os_allocate(a)
-#define ACPI_MEM_CALLOCATE(a)           acpi_os_callocate(a)
+#define ACPI_MEM_ALLOCATE(a)            acpi_ut_allocate(a,_COMPONENT,_THIS_MODULE,__LINE__)
+#define ACPI_MEM_CALLOCATE(a)           acpi_ut_callocate(a, _COMPONENT,_THIS_MODULE,__LINE__)
 #define ACPI_MEM_FREE(a)                acpi_os_free(a)
 #define ACPI_MEM_TRACKING(a)
 
 
 /* Memory allocation */
 
-#define ACPI_MEM_ALLOCATE(a)            acpi_ut_allocate(a,_COMPONENT,_THIS_MODULE,__LINE__)
-#define ACPI_MEM_CALLOCATE(a)           acpi_ut_callocate(a, _COMPONENT,_THIS_MODULE,__LINE__)
-#define ACPI_MEM_FREE(a)                acpi_ut_free(a,_COMPONENT,_THIS_MODULE,__LINE__)
+#define ACPI_MEM_ALLOCATE(a)            acpi_ut_allocate_and_track(a,_COMPONENT,_THIS_MODULE,__LINE__)
+#define ACPI_MEM_CALLOCATE(a)           acpi_ut_callocate_and_track(a, _COMPONENT,_THIS_MODULE,__LINE__)
+#define ACPI_MEM_FREE(a)                acpi_ut_free_and_track(a,_COMPONENT,_THIS_MODULE,__LINE__)
 #define ACPI_MEM_TRACKING(a)            a
 
 #endif /* ACPI_DBG_TRACK_ALLOCATIONS */
index 2c59feb733cd90e08dacebf5f227178d0444fdfe..2217e317de373c7b06e570661877643353097d99 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Name: acnamesp.h - Namespace subcomponent prototypes and defines
- *       $Revision: 110 $
+ *       $Revision: 123 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 
 /* To search the entire name space, pass this as Search_base */
 
-#define NS_ALL                  ((acpi_handle)0)
+#define ACPI_NS_ALL                 ((acpi_handle)0)
 
 /*
  * Elements of Acpi_ns_properties are bit significant
  * and should be one-to-one with values of acpi_object_type
  */
-#define NSP_NORMAL              0
-#define NSP_NEWSCOPE            1   /* a definition of this type opens a name scope */
-#define NSP_LOCAL               2   /* suppress search of enclosing scopes */
+#define ACPI_NS_NORMAL              0
+#define ACPI_NS_NEWSCOPE            1   /* a definition of this type opens a name scope */
+#define ACPI_NS_LOCAL               2   /* suppress search of enclosing scopes */
 
 
 /* Definitions of the predefined namespace names  */
 
-#define ACPI_UNKNOWN_NAME       (u32) 0x3F3F3F3F     /* Unknown name is  "????" */
-#define ACPI_ROOT_NAME          (u32) 0x2F202020     /* Root name is     "/   " */
-#define ACPI_SYS_BUS_NAME       (u32) 0x5F53425F     /* Sys bus name is  "_SB_" */
+#define ACPI_UNKNOWN_NAME           (u32) 0x3F3F3F3F     /* Unknown name is  "????" */
+#define ACPI_ROOT_NAME              (u32) 0x2F202020     /* Root name is     "/   " */
+#define ACPI_SYS_BUS_NAME           (u32) 0x5F53425F     /* Sys bus name is  "_SB_" */
 
-#define NS_ROOT_PATH            "/"
-#define NS_SYSTEM_BUS           "_SB_"
+#define ACPI_NS_ROOT_PATH           "\\"
+#define ACPI_NS_SYSTEM_BUS          "_SB_"
 
 
 /* Flags for Acpi_ns_lookup, Acpi_ns_search_and_enter */
 
-#define NS_NO_UPSEARCH          0
-#define NS_SEARCH_PARENT        0x01
-#define NS_DONT_OPEN_SCOPE      0x02
-#define NS_NO_PEER_SEARCH       0x04
-#define NS_ERROR_IF_FOUND       0x08
+#define ACPI_NS_NO_UPSEARCH         0
+#define ACPI_NS_SEARCH_PARENT       0x01
+#define ACPI_NS_DONT_OPEN_SCOPE     0x02
+#define ACPI_NS_NO_PEER_SEARCH      0x04
+#define ACPI_NS_ERROR_IF_FOUND      0x08
 
-#define NS_WALK_UNLOCK          TRUE
-#define NS_WALK_NO_UNLOCK       FALSE
+#define ACPI_NS_WALK_UNLOCK         TRUE
+#define ACPI_NS_WALK_NO_UNLOCK      FALSE
 
 
 acpi_status
@@ -94,7 +94,7 @@ acpi_ns_init_one_object (
 
 acpi_status
 acpi_ns_walk_namespace (
-       acpi_object_type8       type,
+       acpi_object_type        type,
        acpi_handle             start_object,
        u32                     max_depth,
        u8                      unlock_before_callback,
@@ -104,7 +104,7 @@ acpi_ns_walk_namespace (
 
 acpi_namespace_node *
 acpi_ns_get_next_node (
-       acpi_object_type8       type,
+       acpi_object_type        type,
        acpi_namespace_node     *parent,
        acpi_namespace_node     *child);
 
@@ -148,8 +148,8 @@ acpi_status
 acpi_ns_lookup (
        acpi_generic_state      *scope_info,
        NATIVE_CHAR             *name,
-       acpi_object_type8       type,
-       operating_mode          interpreter_mode,
+       acpi_object_type        type,
+       acpi_interpreter_mode   interpreter_mode,
        u32                     flags,
        acpi_walk_state         *walk_state,
        acpi_namespace_node     **ret_node);
@@ -215,13 +215,18 @@ acpi_ns_dump_pathname (
        u32                     level,
        u32                     component);
 
+void
+acpi_ns_print_pathname (
+       u32                     num_segments,
+       char                    *pathname);
+
 void
 acpi_ns_dump_root_devices (
        void);
 
 void
 acpi_ns_dump_objects (
-       acpi_object_type8       type,
+       acpi_object_type        type,
        u8                      display_type,
        u32                     max_depth,
        u32                     ownder_id,
@@ -277,15 +282,15 @@ acpi_ns_exist_downstream_sibling (
 
 
 /*
- * Scope manipulation - nsscope
+ * Name and Scope manipulation - nsnames
  */
 
 u32
 acpi_ns_opens_scope (
-       acpi_object_type8       type);
+       acpi_object_type        type);
 
 NATIVE_CHAR *
-acpi_ns_get_table_pathname (
+acpi_ns_get_external_pathname (
        acpi_namespace_node     *node);
 
 NATIVE_CHAR *
@@ -294,9 +299,8 @@ acpi_ns_name_of_current_scope (
 
 acpi_status
 acpi_ns_handle_to_pathname (
-       acpi_handle             obj_handle,
-       u32                     *buf_size,
-       NATIVE_CHAR             *user_buffer);
+       acpi_handle             target_handle,
+       acpi_buffer             *buffer);
 
 u8
 acpi_ns_pattern_match (
@@ -304,25 +308,51 @@ acpi_ns_pattern_match (
        NATIVE_CHAR             *search_for);
 
 acpi_status
-acpi_ns_get_node (
-       NATIVE_CHAR             *pathname,
+acpi_ns_get_node_by_path (
+       NATIVE_CHAR             *external_pathname,
        acpi_namespace_node     *in_prefix_node,
+       u32                     flags,
        acpi_namespace_node     **out_node);
 
-u32
+ACPI_SIZE
 acpi_ns_get_pathname_length (
        acpi_namespace_node     *node);
 
 
 /*
- * Object management for NTEs - nsobject
+ * Object management for namespace nodes - nsobject
  */
 
 acpi_status
 acpi_ns_attach_object (
        acpi_namespace_node     *node,
        acpi_operand_object     *object,
-       acpi_object_type8       type);
+       acpi_object_type        type);
+
+acpi_operand_object *
+acpi_ns_get_attached_object (
+       acpi_namespace_node     *node);
+
+acpi_operand_object *
+acpi_ns_get_secondary_object (
+       acpi_operand_object     *obj_desc);
+
+acpi_status
+acpi_ns_attach_data (
+       acpi_namespace_node     *node,
+       ACPI_OBJECT_HANDLER     handler,
+       void                    *data);
+
+acpi_status
+acpi_ns_detach_data (
+       acpi_namespace_node     *node,
+       ACPI_OBJECT_HANDLER     handler);
+
+acpi_status
+acpi_ns_get_attached_data (
+       acpi_namespace_node     *node,
+       ACPI_OBJECT_HANDLER     handler,
+       void                    **data);
 
 
 /*
@@ -334,8 +364,8 @@ acpi_ns_search_and_enter (
        u32                     entry_name,
        acpi_walk_state         *walk_state,
        acpi_namespace_node     *node,
-       operating_mode          interpreter_mode,
-       acpi_object_type8       type,
+       acpi_interpreter_mode   interpreter_mode,
+       acpi_object_type        type,
        u32                     flags,
        acpi_namespace_node     **ret_node);
 
@@ -343,7 +373,7 @@ acpi_status
 acpi_ns_search_node (
        u32                     entry_name,
        acpi_namespace_node     *node,
-       acpi_object_type8       type,
+       acpi_object_type        type,
        acpi_namespace_node     **ret_node);
 
 void
@@ -351,7 +381,7 @@ acpi_ns_install_node (
        acpi_walk_state         *walk_state,
        acpi_namespace_node     *parent_node,   /* Parent */
        acpi_namespace_node     *node,      /* New Child*/
-       acpi_object_type8       type);
+       acpi_object_type        type);
 
 
 /*
@@ -366,17 +396,13 @@ u8
 acpi_ns_valid_path_separator (
        NATIVE_CHAR             sep);
 
-acpi_object_type8
+acpi_object_type
 acpi_ns_get_type (
        acpi_namespace_node     *node);
 
-void *
-acpi_ns_get_attached_object (
-       acpi_namespace_node     *node);
-
 u32
 acpi_ns_local (
-       acpi_object_type8       type);
+       acpi_object_type        type);
 
 acpi_status
 acpi_ns_build_internal_name (
@@ -411,7 +437,7 @@ acpi_ns_terminate (
        void);
 
 acpi_namespace_node *
-acpi_ns_get_parent_object (
+acpi_ns_get_parent_node (
        acpi_namespace_node     *node);
 
 
index 155d880e83633707a5d339e0b38bc5933e9018c2..ae2420ea998da0cf4494e3aed82b8b08d4bec0eb 100644 (file)
@@ -2,12 +2,12 @@
 /******************************************************************************
  *
  * Name: acobject.h - Definition of acpi_operand_object  (Internal object only)
- *       $Revision: 93 $
+ *       $Revision: 106 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  */
 
 
-#define ACPI_OBJECT_COMMON_HEADER           /* SIZE/ALIGNMENT: 32-bits plus trailing 8-bit flag */\
-       u8                          data_type;          /* To differentiate various internal objs */\
+#define ACPI_OBJECT_COMMON_HEADER           /* SIZE/ALIGNMENT: 32 bits, one ptr plus trailing 8-bit flag */\
+       u8                          descriptor;         /* To differentiate various internal objs */\
        u8                          type;               /* acpi_object_type */\
        u16                         reference_count;    /* For object deletion management */\
+       union acpi_operand_obj      *next_object;       /* Objects linked to parent NS node */\
        u8                          flags; \
 
 /* Defines for flag byte above */
 
-#define AOPOBJ_STATIC_ALLOCATION    0x1
-#define AOPOBJ_STATIC_POINTER       0x2
-#define AOPOBJ_DATA_VALID           0x4
-#define AOPOBJ_ZERO_CONST           0x4
-#define AOPOBJ_INITIALIZED          0x8
+#define AOPOBJ_RESERVED             0x01
+#define AOPOBJ_STATIC_POINTER       0x02
+#define AOPOBJ_DATA_VALID           0x04
+#define AOPOBJ_OBJECT_INITIALIZED   0x08
+#define AOPOBJ_SETUP_COMPLETE       0x10
+#define AOPOBJ_SINGLE_DATUM         0x20
 
 
 /*
  * Common bitfield for the field objects
- * "Field Datum"    -- a datum from the actual field object
- * "Buffer Datum"   -- a datum from a user buffer, read from or to be written to the field
+ * "Field Datum"  -- a datum from the actual field object
+ * "Buffer Datum" -- a datum from a user buffer, read from or to be written to the field
  */
 #define ACPI_COMMON_FIELD_INFO              /* SIZE/ALIGNMENT: 24 bits + three 32-bit values */\
-       u8                          access_flags;\
-       u16                         bit_length;         /* Length of field in bits */\
-       u32                         base_byte_offset;   /* Byte offset within containing object */\
-       u8                          access_bit_width;   /* Read/Write size in bits (from ASL Access_type)*/\
+       u8                          field_flags;        /* Access, update, and lock bits */\
+       u8                          attribute;          /* From Access_as keyword */\
        u8                          access_byte_width;  /* Read/Write size in bytes */\
-       u8                          update_rule;        /* How neighboring field bits are handled */\
-       u8                          lock_rule;          /* Global Lock: 1 = "Must Lock" */\
+       u32                         bit_length;         /* Length of field in bits */\
+       u32                         base_byte_offset;   /* Byte offset within containing object */\
        u8                          start_field_bit_offset;/* Bit offset within first field datum (0-63) */\
        u8                          datum_valid_bits;   /* Valid bit in first "Field datum" */\
        u8                          end_field_valid_bits; /* Valid bits in the last "field datum" */\
        u8                          end_buffer_valid_bits; /* Valid bits in the last "buffer datum" */\
-       u32                         value;              /* Value to store into the Bank or Index register */
-
-
-/* Access flag bits */
-
-#define AFIELD_SINGLE_DATUM         0x1
+       u32                         value;              /* Value to store into the Bank or Index register */\
+       acpi_namespace_node         *node;              /* Link back to parent node */
 
 
 /*
@@ -150,6 +146,7 @@ typedef struct /* BUFFER - has length and pointer - not null terminated */
        ACPI_OBJECT_COMMON_HEADER
        ACPI_COMMON_BUFFER_INFO
        u8                          *pointer;           /* Buffer value in AML stream or in allocated space */
+       acpi_namespace_node         *node;              /* Link back to parent node */
 
 } ACPI_OBJECT_BUFFER;
 
@@ -210,8 +207,8 @@ typedef struct acpi_obj_mutex /* MUTEX */
        u16                         sync_level;
        u16                         acquisition_depth;
 
+       struct acpi_thread_state    *owner_thread;
        void                        *semaphore;
-       void                        *owner;
        union acpi_operand_obj      *prev;              /* Link for list of acquired mutexes */
        union acpi_operand_obj      *next;              /* Link for list of acquired mutexes */
 
@@ -225,7 +222,6 @@ typedef struct /* REGION */
        u8                          space_id;
        u32                         length;
        ACPI_PHYSICAL_ADDRESS       address;
-       union acpi_operand_obj      *extra;             /* Pointer to executable AML (in region definition) */
 
        union acpi_operand_obj      *addr_handler;      /* Handler for system notifies */
        acpi_namespace_node         *node;              /* containing object */
@@ -301,7 +297,7 @@ typedef struct /* BANK FIELD */
        ACPI_COMMON_FIELD_INFO
 
        union acpi_operand_obj      *region_obj;        /* Containing Op_region object */
-       union acpi_operand_obj      *bank_register_obj; /* Bank_select Register object */
+       union acpi_operand_obj      *bank_obj;          /* Bank_select Register object */
 
 } ACPI_OBJECT_BANK_FIELD;
 
@@ -329,8 +325,6 @@ typedef struct /* BUFFER FIELD */
        ACPI_OBJECT_COMMON_HEADER
        ACPI_COMMON_FIELD_INFO
 
-       union acpi_operand_obj      *extra;             /* Pointer to executable AML (in field definition) */
-       acpi_namespace_node         *node;              /* Parent (containing) object node */
        union acpi_operand_obj      *buffer_obj;        /* Containing Buffer object */
 
 } ACPI_OBJECT_BUFFER_FIELD;
@@ -353,7 +347,7 @@ typedef struct /* NOTIFY HANDLER */
 
 /* Flags for address handler */
 
-#define ADDR_HANDLER_DEFAULT_INSTALLED  0x1
+#define ACPI_ADDR_HANDLER_DEFAULT_INSTALLED  0x1
 
 
 typedef struct /* ADDRESS HANDLER */
@@ -414,6 +408,15 @@ typedef struct /* EXTRA */
 } ACPI_OBJECT_EXTRA;
 
 
+typedef struct /* DATA */
+{
+       ACPI_OBJECT_COMMON_HEADER
+       ACPI_OBJECT_HANDLER         handler;
+       void                        *pointer;
+
+} ACPI_OBJECT_DATA;
+
+
 /******************************************************************************
  *
  * acpi_operand_object  Descriptor - a giant union of all of the above
@@ -445,6 +448,7 @@ typedef union acpi_operand_obj
        ACPI_OBJECT_NOTIFY_HANDLER  notify_handler;
        ACPI_OBJECT_ADDR_HANDLER    addr_handler;
        ACPI_OBJECT_EXTRA           extra;
+       ACPI_OBJECT_DATA            data;
 
 } acpi_operand_object;
 
index c766fc92f0c9f5b614ffe3fe239fbee2cec5988d..95f5b816159bc72874b2bccd2f9d338f1e5d0478 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Name: acoutput.h -- debug output
- *       $Revision: 84 $
+ *       $Revision: 86 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 #define ACPI_DEBUGGER               0x00000200
 #define ACPI_OS_SERVICES            0x00000400
 
-#define ACPI_BUS                    0x00010000
-#define ACPI_SYSTEM                 0x00020000
-#define ACPI_POWER                  0x00040000
-#define ACPI_EC                     0x00080000
-#define ACPI_AC_ADAPTER             0x00100000
-#define ACPI_BATTERY                0x00200000
-#define ACPI_BUTTON                 0x00400000
-#define ACPI_PROCESSOR              0x00800000
-#define ACPI_THERMAL                0x01000000
-#define ACPI_FAN                    0x02000000
-
-#define ACPI_ALL_COMPONENTS         0x0FFFFFFF
+#define ACPI_ALL_COMPONENTS         0x00000FFF
 
 #define ACPI_COMPONENT_DEFAULT      (ACPI_ALL_COMPONENTS)
 
+/* Component IDs for ACPI tools and utilities */
+
+#define ACPI_COMPILER               0x00001000
+#define ACPI_TOOLS                  0x00002000
 
-#define ACPI_COMPILER               0x10000000
-#define ACPI_TOOLS                  0x20000000
+/* Component IDs reserved for ACPI drivers */
 
+#define ACPI_ALL_DRIVERS            0xFFFF0000
 
 /*
  * Raw debug output levels, do not use these in the DEBUG_PRINT macros
index b4861fdaa1afea126f3fa96052d2b11bf97cb6b1..a946415931d6a7af531092aa2c44f58b889f1d1a 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: acparser.h - AML Parser subcomponent prototypes and defines
- *       $Revision: 54 $
+ *       $Revision: 58 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 #define __ACPARSER_H__
 
 
-#define OP_HAS_RETURN_VALUE         1
+#define OP_HAS_RETURN_VALUE             1
 
 /* variable # arguments */
 
-#define ACPI_VAR_ARGS               ACPI_UINT32_MAX
-
-/* maximum virtual address */
-
-#define ACPI_MAX_AML                ((u8 *)(~0UL))
+#define ACPI_VAR_ARGS                   ACPI_UINT32_MAX
 
 
 #define ACPI_PARSE_DELETE_TREE          0x0001
@@ -48,7 +44,8 @@
 #define ACPI_PARSE_EXECUTE              0x0030
 #define ACPI_PARSE_MODE_MASK            0x0030
 
-/* psapi - Parser external interfaces */
+
+/* Parser external interfaces */
 
 acpi_status
 acpi_psx_load_table (
@@ -61,6 +58,7 @@ acpi_psx_execute (
        acpi_operand_object     **params,
        acpi_operand_object     **return_obj_desc);
 
+
 /******************************************************************************
  *
  * Parser interfaces
@@ -85,8 +83,8 @@ acpi_ps_get_next_namestring (
 void
 acpi_ps_get_next_simple_arg (
        acpi_parse_state        *parser_state,
-       u32                     arg_type,       /* type of argument */
-       acpi_parse_object       *arg);           /* (OUT) argument data */
+       u32                     arg_type,
+       acpi_parse_object       *arg);
 
 void
 acpi_ps_get_next_namepath (
@@ -106,6 +104,19 @@ acpi_ps_get_next_arg (
        u32                     *arg_count);
 
 
+/* psfind */
+
+acpi_parse_object *
+acpi_ps_find_name (
+       acpi_parse_object       *scope,
+       u32                     name,
+       u32                     opcode);
+
+acpi_parse_object*
+acpi_ps_get_parent (
+       acpi_parse_object       *op);
+
+
 /* psopcode - AML Opcode information */
 
 const acpi_opcode_info *
@@ -119,6 +130,21 @@ acpi_ps_get_opcode_name (
 
 /* psparse - top level parsing routines */
 
+u32
+acpi_ps_get_opcode_size (
+       u32                     opcode);
+
+u8
+acpi_ps_complete_this_op (
+       acpi_walk_state         *walk_state,
+       acpi_parse_object       *op);
+
+acpi_status
+acpi_ps_next_parse_state (
+       acpi_walk_state         *walk_state,
+       acpi_parse_object       *op,
+       acpi_status             callback_status);
+
 acpi_status
 acpi_ps_find_object (
        acpi_walk_state         *walk_state,
@@ -233,6 +259,10 @@ acpi_ps_get_next_walk_op (
        acpi_parse_object       *op,
        acpi_parse_upwards      ascending_callback);
 
+acpi_status
+acpi_ps_delete_completed_op (
+       acpi_walk_state         *walk_state);
+
 
 /* psutils - parser utilities */
 
index 1544b5302ba410e23d52a0e189e141ece66caca8..dd03d917633dc0ece14ebaa54b8495a7e2391854 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Name: acpi.h - Master include file, Publics and external data.
- *       $Revision: 54 $
+ *       $Revision: 55 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
index 750d306c4764b39d51a711eee90d699dcce4e2cd..181f4809991fc0bc903a5b8c46f903f7d22ee416 100644 (file)
@@ -9,7 +9,7 @@
 
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -62,12 +62,12 @@ typedef struct acpi_fatal_info
  * Types specific to the OS service interfaces
  */
 
-typedef
-u32 (*OSD_HANDLER) (
+typedef u32
+(ACPI_SYSTEM_XFACE *OSD_HANDLER) (
        void                    *context);
 
-typedef
-void (*OSD_EXECUTION_CALLBACK) (
+typedef void
+(ACPI_SYSTEM_XFACE *OSD_EXECUTION_CALLBACK) (
        void                    *context);
 
 
@@ -121,11 +121,7 @@ acpi_os_signal_semaphore (
 
 void *
 acpi_os_allocate (
-       u32                     size);
-
-void *
-acpi_os_callocate (
-       u32                     size);
+       ACPI_SIZE               size);
 
 void
 acpi_os_free (
@@ -134,13 +130,13 @@ acpi_os_free (
 acpi_status
 acpi_os_map_memory (
        ACPI_PHYSICAL_ADDRESS   physical_address,
-       u32                     length,
+       ACPI_SIZE               size,
        void                    **logical_address);
 
 void
 acpi_os_unmap_memory (
        void                    *logical_address,
-       u32                     length);
+       ACPI_SIZE               size);
 
 acpi_status
 acpi_os_get_physical_address (
@@ -202,7 +198,7 @@ acpi_os_read_port (
 acpi_status
 acpi_os_write_port (
        ACPI_IO_ADDRESS         address,
-       NATIVE_UINT             value,
+       acpi_integer            value,
        u32                     width);
 
 
@@ -220,7 +216,7 @@ acpi_os_read_memory (
 acpi_status
 acpi_os_write_memory (
        ACPI_PHYSICAL_ADDRESS   address,
-       NATIVE_UINT             value,
+       acpi_integer            value,
        u32                     width);
 
 
@@ -240,7 +236,7 @@ acpi_status
 acpi_os_write_pci_configuration (
        acpi_pci_id             *pci_id,
        u32                     register,
-       NATIVE_UINT             value,
+       acpi_integer            value,
        u32                     width);
 
 
@@ -272,12 +268,12 @@ acpi_os_signal (
  * Debug print routines
  */
 
-s32
+void ACPI_INTERNAL_VAR_XFACE
 acpi_os_printf (
        const NATIVE_CHAR       *format,
        ...);
 
-s32
+void
 acpi_os_vprintf (
        const NATIVE_CHAR       *format,
        va_list                 args);
index 9950bb21d097d775fb8c30f28679ea88bdb9d61f..c2aee5cd18d7ea10ca4a802d2e22fbc17f61f3a3 100644 (file)
@@ -6,7 +6,7 @@
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -67,6 +67,10 @@ const char *
 acpi_format_exception (
        acpi_status             exception);
 
+acpi_status
+acpi_purge_cached_objects (
+       void);
+
 
 /*
  * ACPI Memory manager
@@ -158,6 +162,23 @@ acpi_get_handle (
        acpi_string             pathname,
        acpi_handle             *ret_handle);
 
+acpi_status
+acpi_attach_data (
+       acpi_handle             obj_handle,
+       ACPI_OBJECT_HANDLER     handler,
+       void                    *data);
+
+acpi_status
+acpi_detach_data (
+       acpi_handle             obj_handle,
+       ACPI_OBJECT_HANDLER     handler);
+
+acpi_status
+acpi_get_data (
+       acpi_handle             obj_handle,
+       ACPI_OBJECT_HANDLER     handler,
+       void                    **data);
+
 
 /*
  * Object manipulation and enumeration
@@ -244,11 +265,12 @@ acpi_install_gpe_handler (
 
 acpi_status
 acpi_acquire_global_lock (
-       void);
+       u32                     timeout,
+       u32                     *handle);
 
 acpi_status
 acpi_release_global_lock (
-       void);
+       u32                     handle);
 
 acpi_status
 acpi_remove_gpe_handler (
@@ -315,6 +337,11 @@ acpi_status
 acpi_get_firmware_waking_vector (
        ACPI_PHYSICAL_ADDRESS   *physical_address);
 
+
+acpi_status
+acpi_enter_sleep_state_prep (
+       u8 sleep_state);
+
 acpi_status
 acpi_enter_sleep_state (
        u8 sleep_state);
index 254b6ee32dd723b02c0d1f765b6d2a0f20179170..dee8f3f7357718d4fe111ede0bf6b9df6232e50c 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Name: acresrc.h - Resource Manager function prototypes
- *       $Revision: 25 $
+ *       $Revision: 30 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -55,24 +55,21 @@ acpi_rs_set_srs_method_data (
 acpi_status
 acpi_rs_create_resource_list (
        acpi_operand_object     *byte_stream_buffer,
-       u8                      *output_buffer,
-       u32                     *output_buffer_length);
+       acpi_buffer             *output_buffer);
 
 acpi_status
 acpi_rs_create_byte_stream (
        acpi_resource           *linked_list_buffer,
-       u8                      *output_buffer,
-       u32                     *output_buffer_length);
+       acpi_buffer             *output_buffer);
 
 acpi_status
 acpi_rs_create_pci_routing_table (
-       acpi_operand_object     *method_return_object,
-       u8                      *output_buffer,
-       u32                     *output_buffer_length);
+       acpi_operand_object     *package_object,
+       acpi_buffer             *output_buffer);
 
 
 /*
- *Function prototypes called from Acpi_rs_create*APIs
+ *Function prototypes called from Acpi_rs_create*
  */
 
 void
@@ -93,225 +90,224 @@ acpi_status
 acpi_rs_calculate_list_length (
        u8                      *byte_stream_buffer,
        u32                     byte_stream_buffer_length,
-       u32                     *size_needed);
+       ACPI_SIZE               *size_needed);
 
 acpi_status
 acpi_rs_calculate_byte_stream_length (
        acpi_resource           *linked_list_buffer,
-       u32                     *size_needed);
+       ACPI_SIZE               *size_needed);
 
 acpi_status
 acpi_rs_calculate_pci_routing_table_length (
        acpi_operand_object     *package_object,
-       u32                     *buffer_size_needed);
+       ACPI_SIZE               *buffer_size_needed);
 
 acpi_status
 acpi_rs_byte_stream_to_list (
        u8                      *byte_stream_buffer,
        u32                     byte_stream_buffer_length,
-       u8                      **output_buffer);
+       u8                      *output_buffer);
 
 acpi_status
 acpi_rs_list_to_byte_stream (
        acpi_resource           *linked_list,
        u32                     byte_stream_size_needed,
-       u8                      **output_buffer);
+       u8                      *output_buffer);
 
 acpi_status
 acpi_rs_io_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size);
+       ACPI_SIZE               *structure_size);
 
 acpi_status
 acpi_rs_fixed_io_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size);
+       ACPI_SIZE               *structure_size);
 
 acpi_status
 acpi_rs_io_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed);
+       ACPI_SIZE               *bytes_consumed);
 
 acpi_status
 acpi_rs_fixed_io_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed);
+       ACPI_SIZE               *bytes_consumed);
 
 acpi_status
 acpi_rs_irq_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size);
+       ACPI_SIZE               *structure_size);
 
 acpi_status
 acpi_rs_irq_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed);
+       ACPI_SIZE               *bytes_consumed);
 
 acpi_status
 acpi_rs_dma_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size);
+       ACPI_SIZE               *structure_size);
 
 acpi_status
 acpi_rs_dma_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed);
+       ACPI_SIZE               *bytes_consumed);
 
 acpi_status
 acpi_rs_address16_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size);
+       ACPI_SIZE               *structure_size);
 
 acpi_status
 acpi_rs_address16_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed);
+       ACPI_SIZE               *bytes_consumed);
 
 acpi_status
 acpi_rs_address32_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size);
+       ACPI_SIZE               *structure_size);
 
 acpi_status
 acpi_rs_address32_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed);
+       ACPI_SIZE               *bytes_consumed);
 
 acpi_status
 acpi_rs_address64_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size);
+       ACPI_SIZE               *structure_size);
 
 acpi_status
 acpi_rs_address64_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed);
+       ACPI_SIZE               *bytes_consumed);
 
 acpi_status
-acpi_rs_start_dependent_functions_resource (
+acpi_rs_start_depend_fns_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size);
+       ACPI_SIZE               *structure_size);
 
 acpi_status
-acpi_rs_end_dependent_functions_resource (
+acpi_rs_end_depend_fns_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size);
+       ACPI_SIZE               *structure_size);
 
 acpi_status
-acpi_rs_start_dependent_functions_stream (
+acpi_rs_start_depend_fns_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed);
+       ACPI_SIZE               *bytes_consumed);
 
 acpi_status
-acpi_rs_end_dependent_functions_stream (
+acpi_rs_end_depend_fns_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed);
+       ACPI_SIZE               *bytes_consumed);
 
 acpi_status
 acpi_rs_memory24_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size);
+       ACPI_SIZE               *structure_size);
 
 acpi_status
 acpi_rs_memory24_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed);
+       ACPI_SIZE               *bytes_consumed);
 
 acpi_status
 acpi_rs_memory32_range_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size
-);
+       ACPI_SIZE               *structure_size);
 
 acpi_status
 acpi_rs_fixed_memory32_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size);
+       ACPI_SIZE               *structure_size);
 
 acpi_status
 acpi_rs_memory32_range_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed);
+       ACPI_SIZE               *bytes_consumed);
 
 acpi_status
 acpi_rs_fixed_memory32_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed);
+       ACPI_SIZE               *bytes_consumed);
 
 acpi_status
 acpi_rs_extended_irq_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size);
+       ACPI_SIZE               *structure_size);
 
 acpi_status
 acpi_rs_extended_irq_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed);
+       ACPI_SIZE               *bytes_consumed);
 
 acpi_status
 acpi_rs_end_tag_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size);
+       ACPI_SIZE               *structure_size);
 
 acpi_status
 acpi_rs_end_tag_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed);
+       ACPI_SIZE               *bytes_consumed);
 
 acpi_status
 acpi_rs_vendor_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size);
+       ACPI_SIZE               *structure_size);
 
 acpi_status
 acpi_rs_vendor_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed);
+       ACPI_SIZE               *bytes_consumed);
 
 u8
 acpi_rs_get_resource_type (
index 92477259b41c0aa64e6bc98b0e57e12919ab3f16..83d7430923357391bca9db7f61e2fadc210a9469 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Name: acstruct.h - Internal structs
- *       $Revision: 10 $
+ *       $Revision: 16 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  * the tree (for whatever reason), and for control method execution.
  */
 
-#define NEXT_OP_DOWNWARD    1
-#define NEXT_OP_UPWARD      2
+#define ACPI_NEXT_OP_DOWNWARD    1
+#define ACPI_NEXT_OP_UPWARD      2
 
-#define WALK_NON_METHOD     0
-#define WALK_METHOD         1
-#define WALK_METHOD_RESTART 2
+#define ACPI_WALK_NON_METHOD     0
+#define ACPI_WALK_METHOD         1
+#define ACPI_WALK_METHOD_RESTART 2
 
 typedef struct acpi_walk_state
 {
@@ -56,12 +56,12 @@ typedef struct acpi_walk_state
        u8                      num_operands;                       /* Stack pointer for Operands[] array */
        u8                      return_used;
        u8                      walk_type;
-       u16                     current_sync_level;                 /* Mutex Sync (nested acquire) level */
        u16                     opcode;                             /* Current AML opcode */
        u32                     arg_count;                          /* push for fixed or var args */
        u32                     aml_offset;
        u32                     arg_types;
        u32                     method_breakpoint;                  /* For single stepping */
+       u32                     user_breakpoint;                    /* User AML breakpoint */
        u32                     parse_flags;
        u32                     prev_arg_types;
 
@@ -86,33 +86,17 @@ typedef struct acpi_walk_state
        union acpi_operand_obj  *return_desc;                       /* Return object, if any */
        acpi_generic_state      *scope_info;                        /* Stack of nested scopes */
 
-/* TBD: Obsolete with removal of WALK procedure ? */
        acpi_parse_object       *prev_op;                           /* Last op that was processed */
        acpi_parse_object       *next_op;                           /* next op to be processed */
-
-
        acpi_parse_downwards    descending_callback;
        acpi_parse_upwards      ascending_callback;
-       struct acpi_walk_list   *walk_list;
+       ACPI_THREAD_STATE       *thread;
        struct acpi_walk_state  *next;                              /* Next Walk_state in list */
 
 
 } acpi_walk_state;
 
 
-/*
- * Walk list - head of a tree of walk states.  Multiple walk states are created when there
- * are nested control methods executing.
- */
-typedef struct acpi_walk_list
-{
-
-       acpi_walk_state         *walk_state;
-       ACPI_OBJECT_MUTEX       acquired_mutex_list;               /* List of all currently acquired mutexes */
-
-} acpi_walk_list;
-
-
 /* Info used by Acpi_ps_init_objects */
 
 typedef struct acpi_init_walk_info
@@ -128,7 +112,7 @@ typedef struct acpi_init_walk_info
 } acpi_init_walk_info;
 
 
-/* Info used by TBD */
+/* Info used by Acpi_ns_initialize_devices */
 
 typedef struct acpi_device_walk_info
 {
index 246236617e8056ba3213baf46c384c1098518026..e07a1f9d61abbfc4680a646bf97a35a7c8ec46de 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Name: actables.h - ACPI table management
- *       $Revision: 32 $
+ *       $Revision: 35 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -118,6 +118,11 @@ acpi_tb_install_table (
        acpi_table_header       *table_ptr,
        acpi_table_desc         *table_info);
 
+acpi_status
+acpi_tb_match_signature (
+       NATIVE_CHAR             *signature,
+       acpi_table_desc         *table_info);
+
 acpi_status
 acpi_tb_recognize_table (
        acpi_table_header       *table_ptr,
@@ -177,6 +182,13 @@ acpi_tb_find_rsdp (
  * tbutils - common table utilities
  */
 
+acpi_status
+acpi_tb_find_table (
+       NATIVE_CHAR             *signature,
+       NATIVE_CHAR             *oem_id,
+       NATIVE_CHAR             *oem_table_id,
+       acpi_table_header       **table_ptr);
+
 acpi_status
 acpi_tb_map_acpi_table (
        ACPI_PHYSICAL_ADDRESS   physical_address,
index 4f277673b1a5c15ece087287aa96e853fbfed443..ce729fcd78c6b66603f02812f978ec632aecabb2 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Name: actbl.h - Table data structures defined in ACPI specification
- *       $Revision: 46 $
+ *       $Revision: 52 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -30,7 +30,6 @@
 /*
  *  Values for description table header signatures
  */
-
 #define RSDP_NAME               "RSDP"
 #define RSDP_SIG                "RSD PTR "  /* RSDT Pointer signature */
 #define APIC_SIG                "APIC"      /* Multiple APIC Description Table */
@@ -42,7 +41,7 @@
 #define XSDT_SIG                "XSDT"      /* Extended  System Description Table */
 #define SSDT_SIG                "SSDT"      /* Secondary System Description Table */
 #define SBST_SIG                "SBST"      /* Smart Battery Specification Table */
-#define SPIC_SIG                "SPIC"      /* iosapic table */
+#define SPIC_SIG                "SPIC"      /* IOSAPIC table */
 #define BOOT_SIG                "BOOT"      /* Boot table */
 
 
  * Architecture-independent tables
  * The architecture dependent tables are in separate files
  */
-
 typedef struct  /* Root System Descriptor Pointer */
 {
-       NATIVE_CHAR             signature [8];          /* contains "RSD PTR " */
-       u8                      checksum;               /* to make sum of struct == 0 */
+       NATIVE_CHAR             signature [8];          /* ACPI signature, contains "RSD PTR " */
+       u8                      checksum;               /* To make sum of struct == 0 */
        NATIVE_CHAR             oem_id [6];             /* OEM identification */
        u8                      revision;               /* Must be 0 for 1.0, 2 for 2.0 */
        u32                     rsdt_physical_address;  /* 32-bit physical address of RSDT */
        u32                     length;                 /* XSDT Length in bytes including hdr */
        u64                     xsdt_physical_address;  /* 64-bit physical address of XSDT */
        u8                      extended_checksum;      /* Checksum of entire table */
-       NATIVE_CHAR             reserved [3];           /* reserved field must be 0 */
+       NATIVE_CHAR             reserved [3];           /* Reserved field must be 0 */
 
 } RSDP_DESCRIPTOR;
 
 
 typedef struct  /* ACPI common table header */
 {
-       NATIVE_CHAR             signature [4];          /* identifies type of table */
-       u32                     length;                 /* length of table, in bytes,
-                         * including header */
-       u8                      revision;               /* specification minor version # */
-       u8                      checksum;               /* to make sum of entire table == 0 */
+       NATIVE_CHAR             signature [4];          /* ACPI signature (4 ASCII characters) */
+       u32                     length;                 /* Length of table, in bytes, including header */
+       u8                      revision;               /* ACPI Specification minor version # */
+       u8                      checksum;               /* To make sum of entire table == 0 */
        NATIVE_CHAR             oem_id [6];             /* OEM identification */
        NATIVE_CHAR             oem_table_id [8];       /* OEM table identification */
        u32                     oem_revision;           /* OEM revision number */
@@ -118,7 +115,7 @@ typedef struct  /* Common FACS for internal use */
 
 typedef struct  /* APIC Table */
 {
-       acpi_table_header       header;                 /* table header */
+       acpi_table_header       header;                 /* ACPI table header */
        u32                     local_apic_address;     /* Physical address for accessing local APICs */
        u32                     PCATcompat      : 1;    /* a one indicates system also has dual 8259s */
        u32                     reserved1       : 31;
@@ -138,7 +135,7 @@ typedef struct  /* Processor APIC */
 {
        APIC_HEADER             header;
        u8                      processor_apic_id;      /* ACPI processor id */
-       u8                      local_apic_id;          /* processor's local APIC id */
+       u8                      local_apic_id;          /* Processor's local APIC id */
        u32                     processor_enabled: 1;   /* Processor is usable if set */
        u32                     reserved1       : 31;
 
@@ -149,21 +146,21 @@ typedef struct  /* IO APIC */
 {
        APIC_HEADER             header;
        u8                      io_apic_id;             /* I/O APIC ID */
-       u8                      reserved;               /* reserved - must be zero */
+       u8                      reserved;               /* Reserved - must be zero */
        u32                     io_apic_address;        /* APIC's physical address */
-       u32                     vector;                 /* interrupt vector index where INTI
+       u32                     vector;                 /* Interrupt vector index where INTI
                          * lines start */
 } IO_APIC;
 
 
 /*
-**  IA64 TODO:  Add SAPIC Tables
-*/
+ *  IA64 TBD:  Add SAPIC Tables
+ */
 
 /*
-**  IA64 TODO:  Modify Smart Battery Description to comply with ACPI IA64
-**              extensions.
-*/
+ *  IA64 TBD:   Modify Smart Battery Description to comply with ACPI IA64
+ *              extensions.
+ */
 typedef struct  /* Smart Battery Description Table */
 {
        acpi_table_header       header;
@@ -182,7 +179,6 @@ typedef struct  /* Smart Battery Description Table */
  * and type of memory allocation (mapped or allocated) for each
  * table for 1) when we exit, and 2) if a new table is installed
  */
-
 #define ACPI_MEM_NOT_ALLOCATED  0
 #define ACPI_MEM_ALLOCATED      1
 #define ACPI_MEM_MAPPED         2
@@ -191,7 +187,7 @@ typedef struct  /* Smart Battery Description Table */
 
 #define ACPI_TABLE_SINGLE       0
 #define ACPI_TABLE_MULTIPLE     1
-
+#define ACPI_TABLE_EXECUTABLE   2
 
 /* Data about each known table type */
 
@@ -199,19 +195,17 @@ typedef struct _acpi_table_support
 {
        NATIVE_CHAR             *name;
        NATIVE_CHAR             *signature;
+       void                    **global_ptr;
        u8                      sig_length;
        u8                      flags;
-       u16                     status;
-       void                    **global_ptr;
 
 } ACPI_TABLE_SUPPORT;
 
+
 /*
  * Get the architecture-specific tables
  */
-
-#include "actbl1.h"   /* Acpi 1.0 table defintions */
-#include "actbl71.h"  /* Acpi 0.71 IA-64 Extension table defintions */
+#include "actbl1.h"   /* Acpi 1.0 table definitions */
 #include "actbl2.h"   /* Acpi 2.0 table definitions */
 
 #endif /* __ACTBL_H__ */
index d8395bd104ee9716a46716cb4cf642d41567e5b4..319b3432ec3ff976482ae5d234883defa0b5d361 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Name: actbl1.h - ACPI 1.0 tables
- *       $Revision: 17 $
+ *       $Revision: 21 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 
 #pragma pack(1)
 
-/*************************************/
-/* ACPI Specification Rev 1.0 for    */
-/* the Root System Description Table */
-/*************************************/
+/*
+ * ACPI 1.0 Root System Description Table (RSDT)
+ */
 typedef struct
 {
-       acpi_table_header       header;                 /* Table header */
+       acpi_table_header       header;                 /* ACPI Table header */
        u32                     table_offset_entry [1]; /* Array of pointers to other */
                         /* ACPI tables */
 } RSDT_DESCRIPTOR_REV1;
 
 
-/***************************************/
-/* ACPI Specification Rev 1.0 for      */
-/* the Firmware ACPI Control Structure */
-/***************************************/
+/*
+ * ACPI 1.0 Firmware ACPI Control Structure (FACS)
+ */
 typedef struct
 {
-       NATIVE_CHAR             signature[4];           /* signature "FACS" */
-       u32                     length;                 /* length of structure, in bytes */
-       u32                     hardware_signature;     /* hardware configuration signature */
+       NATIVE_CHAR             signature[4];           /* ACPI Signature */
+       u32                     length;                 /* Length of structure, in bytes */
+       u32                     hardware_signature;     /* Hardware configuration signature */
        u32                     firmware_waking_vector; /* ACPI OS waking vector */
        u32                     global_lock;            /* Global Lock */
        u32                     S4bios_f        : 1;    /* Indicates if S4BIOS support is present */
-       u32                     reserved1       : 31;   /* must be 0 */
-       u8                      resverved3 [40];        /* reserved - must be zero */
+       u32                     reserved1       : 31;   /* Must be 0 */
+       u8                      resverved3 [40];        /* Reserved - must be zero */
 
 } facs_descriptor_rev1;
 
 
-/************************************/
-/* ACPI Specification Rev 1.0 for   */
-/* the Fixed ACPI Description Table */
-/************************************/
+/*
+ * ACPI 1.0 Fixed ACPI Description Table (FADT)
+ */
 typedef struct
 {
-       acpi_table_header       header;                 /* table header */
+       acpi_table_header       header;                 /* ACPI Table header */
        u32                     firmware_ctrl;          /* Physical address of FACS */
        u32                     dsdt;                   /* Physical address of DSDT */
        u8                      model;                  /* System Interrupt Model */
-       u8                      reserved1;              /* reserved */
+       u8                      reserved1;              /* Reserved */
        u16                     sci_int;                /* System vector of SCI interrupt */
        u32                     smi_cmd;                /* Port address of SMI command port */
-       u8                      acpi_enable;            /* value to write to smi_cmd to enable ACPI */
-       u8                      acpi_disable;           /* value to write to smi_cmd to disable ACPI */
+       u8                      acpi_enable;            /* Value to write to smi_cmd to enable ACPI */
+       u8                      acpi_disable;           /* Value to write to smi_cmd to disable ACPI */
        u8                      S4bios_req;             /* Value to write to SMI CMD to enter S4BIOS state */
-       u8                      reserved2;              /* reserved - must be zero */
+       u8                      reserved2;              /* Reserved - must be zero */
        u32                     pm1a_evt_blk;           /* Port address of Power Mgt 1a Acpi_event Reg Blk */
        u32                     pm1b_evt_blk;           /* Port address of Power Mgt 1b Acpi_event Reg Blk */
        u32                     pm1a_cnt_blk;           /* Port address of Power Mgt 1a Control Reg Blk */
        u32                     pm1b_cnt_blk;           /* Port address of Power Mgt 1b Control Reg Blk */
        u32                     pm2_cnt_blk;            /* Port address of Power Mgt 2 Control Reg Blk */
        u32                     pm_tmr_blk;             /* Port address of Power Mgt Timer Ctrl Reg Blk */
-       u32                     gpe0blk;                /* Port addr of General Purpose Acpi_event 0 Reg Blk */
+       u32                     gpe0_blk;               /* Port addr of General Purpose Acpi_event 0 Reg Blk */
        u32                     gpe1_blk;               /* Port addr of General Purpose Acpi_event 1 Reg Blk */
        u8                      pm1_evt_len;            /* Byte Length of ports at pm1_x_evt_blk */
        u8                      pm1_cnt_len;            /* Byte Length of ports at pm1_x_cnt_blk */
        u8                      pm2_cnt_len;            /* Byte Length of ports at pm2_cnt_blk */
        u8                      pm_tm_len;              /* Byte Length of ports at pm_tm_blk */
-       u8                      gpe0blk_len;            /* Byte Length of ports at gpe0_blk */
+       u8                      gpe0_blk_len;           /* Byte Length of ports at gpe0_blk */
        u8                      gpe1_blk_len;           /* Byte Length of ports at gpe1_blk */
-       u8                      gpe1_base;              /* offset in gpe model where gpe1 events start */
-       u8                      reserved3;              /* reserved */
-       u16                     plvl2_lat;              /* worst case HW latency to enter/exit C2 state */
-       u16                     plvl3_lat;              /* worst case HW latency to enter/exit C3 state */
+       u8                      gpe1_base;              /* Offset in gpe model where gpe1 events start */
+       u8                      reserved3;              /* Reserved */
+       u16                     plvl2_lat;              /* Worst case HW latency to enter/exit C2 state */
+       u16                     plvl3_lat;              /* Worst case HW latency to enter/exit C3 state */
        u16                     flush_size;             /* Size of area read to flush caches */
        u16                     flush_stride;           /* Stride used in flushing caches */
-       u8                      duty_offset;            /* bit location of duty cycle field in p_cnt reg */
-       u8                      duty_width;             /* bit width of duty cycle field in p_cnt reg */
-       u8                      day_alrm;               /* index to day-of-month alarm in RTC CMOS RAM */
-       u8                      mon_alrm;               /* index to month-of-year alarm in RTC CMOS RAM */
-       u8                      century;                /* index to century in RTC CMOS RAM */
-       u8                      reserved4;              /* reserved */
-       u8                      reserved4a;             /* reserved */
-       u8                      reserved4b;             /* reserved */
-       u32                     wb_invd         : 1;    /* wbinvd instruction works properly */
-       u32                     wb_invd_flush   : 1;    /* wbinvd flushes but does not invalidate */
-       u32                     proc_c1         : 1;    /* all processors support C1 state */
+       u8                      duty_offset;            /* Bit location of duty cycle field in p_cnt reg */
+       u8                      duty_width;             /* Bit width of duty cycle field in p_cnt reg */
+       u8                      day_alrm;               /* Index to day-of-month alarm in RTC CMOS RAM */
+       u8                      mon_alrm;               /* Index to month-of-year alarm in RTC CMOS RAM */
+       u8                      century;                /* Index to century in RTC CMOS RAM */
+       u8                      reserved4;              /* Reserved */
+       u8                      reserved4a;             /* Reserved */
+       u8                      reserved4b;             /* Reserved */
+       u32                     wb_invd         : 1;    /* The wbinvd instruction works properly */
+       u32                     wb_invd_flush   : 1;    /* The wbinvd flushes but does not invalidate */
+       u32                     proc_c1         : 1;    /* All processors support C1 state */
        u32                     plvl2_up        : 1;    /* C2 state works on MP system */
        u32                     pwr_button      : 1;    /* Power button is handled as a generic feature */
        u32                     sleep_button    : 1;    /* Sleep button is handled as a generic feature, or not present */
        u32                     fixed_rTC       : 1;    /* RTC wakeup stat not in fixed register space */
        u32                     rtcs4           : 1;    /* RTC wakeup stat not possible from S4 */
-       u32                     tmr_val_ext     : 1;    /* tmr_val is 32 bits */
-       u32                     reserved5       : 23;   /* reserved - must be zero */
+       u32                     tmr_val_ext     : 1;    /* The tmr_val width is 32 bits (0 = 24 bits) */
+       u32                     reserved5       : 23;   /* Reserved - must be zero */
 
 }  fadt_descriptor_rev1;
 
index 469e57220e6e2bd23c317747d98f8fe141b3a1f4..f81c3b4d0e431181e6f2e8a7a92363c299e18733 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Name: actbl2.h - ACPI Specification Revision 2.0 Tables
- *       $Revision: 24 $
+ *       $Revision: 27 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 #pragma pack(1)
 
 /*
- * ACPI Specification Rev 2.0 for the Root System Description Table
+ * ACPI 2.0 Root System Description Table (RSDT)
  */
 typedef struct
 {
-       acpi_table_header       header;                 /* Table header */
+       acpi_table_header       header;                 /* ACPI table header */
        u32                     table_offset_entry [1]; /* Array of pointers to  */
-                        /* other tables' headers */
+                        /* ACPI table headers */
 } RSDT_DESCRIPTOR_REV2;
 
 
 /*
- * ACPI Specification Rev 2.0 for the Extended System Description Table (XSDT)
+ * ACPI 2.0 Extended System Description Table (XSDT)
  */
 typedef struct
 {
-       acpi_table_header       header;                 /* Table header */
+       acpi_table_header       header;                 /* ACPI table header */
        u64                     table_offset_entry [1]; /* Array of pointers to  */
-                        /* other tables' headers */
+                        /* ACPI table headers */
 } XSDT_DESCRIPTOR_REV2;
 
 
 /*
- * ACPI Specification Rev 2.0 for the Firmware ACPI Control Structure
+ * ACPI 2.0 Firmware ACPI Control Structure (FACS)
  */
 typedef struct
 {
-       NATIVE_CHAR             signature[4];           /* signature "FACS" */
-       u32                     length;                 /* length of structure, in bytes */
-       u32                     hardware_signature;     /* hardware configuration signature */
+       NATIVE_CHAR             signature[4];           /* ACPI signature */
+       u32                     length;                 /* Length of structure, in bytes */
+       u32                     hardware_signature;     /* Hardware configuration signature */
        u32                     firmware_waking_vector; /* 32bit physical address of the Firmware Waking Vector. */
        u32                     global_lock;            /* Global Lock used to synchronize access to shared hardware resources */
-       u32                     S4bios_f        : 1;    /* Indicates if S4BIOS support is present */
-       u32                     reserved1       : 31;   /* must be 0 */
+       u32                     S4bios_f        : 1;    /* S4Bios_f - Indicates if S4BIOS support is present */
+       u32                     reserved1       : 31;   /* Must be 0 */
        u64                     Xfirmware_waking_vector; /* 64bit physical address of the Firmware Waking Vector. */
        u8                      version;                /* Version of this table */
-       u8                      reserved3 [31];         /* reserved - must be zero */
+       u8                      reserved3 [31];         /* Reserved - must be zero */
 
 } facs_descriptor_rev2;
 
 
 /*
- * ACPI Specification Rev 2.0 for the Generic Address Structure (GAS)
+ * ACPI 2.0 Generic Address Structure (GAS)
  */
 typedef struct
 {
@@ -104,64 +104,64 @@ typedef struct
 
 
 /*
- * ACPI Specification Rev 2.0 for the Fixed ACPI Description Table
+ * ACPI 2.0 Fixed ACPI Description Table (FADT)
  */
 typedef struct
 {
-       acpi_table_header       header;             /* table header */
+       acpi_table_header       header;             /* ACPI table header */
        u32                     V1_firmware_ctrl;   /* 32-bit physical address of FACS */
        u32                     V1_dsdt;            /* 32-bit physical address of DSDT */
        u8                      reserved1;          /* System Interrupt Model isn't used in ACPI 2.0*/
        u8                      prefer_PM_profile;  /* Conveys preferred power management profile to OSPM. */
        u16                     sci_int;            /* System vector of SCI interrupt */
        u32                     smi_cmd;            /* Port address of SMI command port */
-       u8                      acpi_enable;        /* value to write to smi_cmd to enable ACPI */
-       u8                      acpi_disable;       /* value to write to smi_cmd to disable ACPI */
+       u8                      acpi_enable;        /* Value to write to smi_cmd to enable ACPI */
+       u8                      acpi_disable;       /* Value to write to smi_cmd to disable ACPI */
        u8                      S4bios_req;         /* Value to write to SMI CMD to enter S4BIOS state */
-       u8                      pstate_cnt;         /* processor performance state control*/
+       u8                      pstate_cnt;         /* Processor performance state control*/
        u32                     V1_pm1a_evt_blk;    /* Port address of Power Mgt 1a Acpi_event Reg Blk */
        u32                     V1_pm1b_evt_blk;    /* Port address of Power Mgt 1b Acpi_event Reg Blk */
        u32                     V1_pm1a_cnt_blk;    /* Port address of Power Mgt 1a Control Reg Blk */
        u32                     V1_pm1b_cnt_blk;    /* Port address of Power Mgt 1b Control Reg Blk */
        u32                     V1_pm2_cnt_blk;     /* Port address of Power Mgt 2 Control Reg Blk */
        u32                     V1_pm_tmr_blk;      /* Port address of Power Mgt Timer Ctrl Reg Blk */
-       u32                     V1_gpe0blk;         /* Port addr of General Purpose Acpi_event 0 Reg Blk */
+       u32                     V1_gpe0_blk;        /* Port addr of General Purpose Acpi_event 0 Reg Blk */
        u32                     V1_gpe1_blk;        /* Port addr of General Purpose Acpi_event 1 Reg Blk */
        u8                      pm1_evt_len;        /* Byte Length of ports at pm1_x_evt_blk */
        u8                      pm1_cnt_len;        /* Byte Length of ports at pm1_x_cnt_blk */
        u8                      pm2_cnt_len;        /* Byte Length of ports at pm2_cnt_blk */
        u8                      pm_tm_len;          /* Byte Length of ports at pm_tm_blk */
-       u8                      gpe0blk_len;        /* Byte Length of ports at gpe0_blk */
+       u8                      gpe0_blk_len;       /* Byte Length of ports at gpe0_blk */
        u8                      gpe1_blk_len;       /* Byte Length of ports at gpe1_blk */
-       u8                      gpe1_base;          /* offset in gpe model where gpe1 events start */
+       u8                      gpe1_base;          /* Offset in gpe model where gpe1 events start */
        u8                      cst_cnt;            /* Support for the _CST object and C States change notification.*/
-       u16                     plvl2_lat;          /* worst case HW latency to enter/exit C2 state */
-       u16                     plvl3_lat;          /* worst case HW latency to enter/exit C3 state */
-       u16                     flush_size;         /* number of flush strides that need to be read */
+       u16                     plvl2_lat;          /* Worst case HW latency to enter/exit C2 state */
+       u16                     plvl3_lat;          /* Worst case HW latency to enter/exit C3 state */
+       u16                     flush_size;         /* Number of flush strides that need to be read */
        u16                     flush_stride;       /* Processor's memory cache line width, in bytes */
        u8                      duty_offset;        /* Processor_\92s duty cycle index in processor's P_CNT reg*/
        u8                      duty_width;         /* Processor_\92s duty cycle value bit width in P_CNT register.*/
-       u8                      day_alrm;           /* index to day-of-month alarm in RTC CMOS RAM */
-       u8                      mon_alrm;           /* index to month-of-year alarm in RTC CMOS RAM */
-       u8                      century;            /* index to century in RTC CMOS RAM */
+       u8                      day_alrm;           /* Index to day-of-month alarm in RTC CMOS RAM */
+       u8                      mon_alrm;           /* Index to month-of-year alarm in RTC CMOS RAM */
+       u8                      century;            /* Index to century in RTC CMOS RAM */
        u16                     iapc_boot_arch;     /* IA-PC Boot Architecture Flags. See Table 5-10 for description*/
-       u8                      reserved2;          /* reserved */
-       u32                     wb_invd     : 1;    /* wbinvd instruction works properly */
-       u32                     wb_invd_flush : 1;  /* wbinvd flushes but does not invalidate */
-       u32                     proc_c1     : 1;    /* all processors support C1 state */
+       u8                      reserved2;          /* Reserved */
+       u32                     wb_invd     : 1;    /* The wbinvd instruction works properly */
+       u32                     wb_invd_flush : 1;  /* The wbinvd flushes but does not invalidate */
+       u32                     proc_c1     : 1;    /* All processors support C1 state */
        u32                     plvl2_up    : 1;    /* C2 state works on MP system */
        u32                     pwr_button  : 1;    /* Power button is handled as a generic feature */
        u32                     sleep_button : 1;   /* Sleep button is handled as a generic feature, or not present */
        u32                     fixed_rTC   : 1;    /* RTC wakeup stat not in fixed register space */
        u32                     rtcs4       : 1;    /* RTC wakeup stat not possible from S4 */
-       u32                     tmr_val_ext : 1;    /* tmr_val is 32 bits */
+       u32                     tmr_val_ext : 1;    /* Indicates tmr_val is 32 bits 0=24-bits*/
        u32                     dock_cap    : 1;    /* Supports Docking */
        u32                     reset_reg_sup : 1;  /* Indicates system supports system reset via the FADT RESET_REG*/
        u32                     sealed_case : 1;    /* Indicates system has no internal expansion capabilities and case is sealed. */
        u32                     headless    : 1;    /* Indicates system does not have local video capabilities or local input devices.*/
        u32                     cpu_sw_sleep : 1;   /* Indicates to OSPM that a processor native instruction */
-                          /* must be executed after writing the SLP_TYPx register. */
-       u32                     reserved6   : 18;   /* reserved - must be zero */
+                          /* Must be executed after writing the SLP_TYPx register. */
+       u32                     reserved6   : 18;   /* Reserved - must be zero */
 
        acpi_generic_address    reset_register;     /* Reset register address in GAS format */
        u8                      reset_value;        /* Value to write to the Reset_register port to reset the system. */
@@ -174,7 +174,7 @@ typedef struct
        acpi_generic_address    Xpm1b_cnt_blk;      /* Extended Power Mgt 1b Control Reg Blk address */
        acpi_generic_address    Xpm2_cnt_blk;       /* Extended Power Mgt 2 Control Reg Blk address */
        acpi_generic_address    Xpm_tmr_blk;        /* Extended Power Mgt Timer Ctrl Reg Blk address */
-       acpi_generic_address    Xgpe0blk;           /* Extended General Purpose Acpi_event 0 Reg Blk address */
+       acpi_generic_address    Xgpe0_blk;          /* Extended General Purpose Acpi_event 0 Reg Blk address */
        acpi_generic_address    Xgpe1_blk;          /* Extended General Purpose Acpi_event 1 Reg Blk address */
 
 }  fadt_descriptor_rev2;
index 771856b7e894774eaff4087b9dabac4e72a09a0a..97b098d2b9d0cc3513a6e5860535a699d00ad17b 100644 (file)
@@ -3,12 +3,12 @@
  * Name: actbl71.h - IA-64 Extensions to the ACPI Spec Rev. 0.71
  *                   This file includes tables specific to this
  *                   specification revision.
- *       $Revision: 11 $
+ *       $Revision: 12 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -111,13 +111,13 @@ typedef struct
        u64                 pm1b_cnt_blk;       /* Port address of Power Mgt 1b Control Reg Blk */
        u64                 pm2_cnt_blk;        /* Port address of Power Mgt 2 Control Reg Blk */
        u64                 pm_tmr_blk;         /* Port address of Power Mgt Timer Ctrl Reg Blk */
-       u64                 gpe0blk;            /* Port addr of General Purpose Acpi_event 0 Reg Blk */
+       u64                 gpe0_blk;           /* Port addr of General Purpose Acpi_event 0 Reg Blk */
        u64                 gpe1_blk;           /* Port addr of General Purpose Acpi_event 1 Reg Blk */
        u8                  pm1_evt_len;        /* Byte Length of ports at pm1_x_evt_blk */
        u8                  pm1_cnt_len;        /* Byte Length of ports at pm1_x_cnt_blk */
        u8                  pm2_cnt_len;        /* Byte Length of ports at pm2_cnt_blk */
        u8                  pm_tm_len;          /* Byte Length of ports at pm_tm_blk */
-       u8                  gpe0blk_len;        /* Byte Length of ports at gpe0_blk */
+       u8                  gpe0_blk_len;       /* Byte Length of ports at gpe0_blk */
        u8                  gpe1_blk_len;       /* Byte Length of ports at gpe1_blk */
        u8                  gpe1_base;          /* offset in gpe model where gpe1 events start */
        u8                  reserved3;          /* reserved */
index cf0350ac65ebe875a38edc91fc2aa0a294c1d743..cb7c9cdebf5d966174f7a290f12ddb8a10fef932 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Name: actypes.h - Common data types for the entire ACPI subsystem
- *       $Revision: 193 $
+ *       $Revision: 224 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -45,7 +45,6 @@
  * UINT64       64-bit (8 byte) unsigned value
  * NATIVE_INT   32-bit on IA-32, 64-bit on IA-64 signed value
  * NATIVE_UINT  32-bit on IA-32, 64-bit on IA-64 unsigned value
- * UCHAR        Character. 1 byte unsigned value.
  */
 
 
  */
 typedef unsigned char                   UINT8;
 typedef unsigned char                   BOOLEAN;
-typedef unsigned char                   UCHAR;
 typedef unsigned short                  UINT16;
 typedef int                             INT32;
 typedef unsigned int                    UINT32;
 typedef COMPILER_DEPENDENT_UINT64       UINT64;
 
 typedef UINT64                          NATIVE_UINT;
-typedef INT64                           NATIVE_INT;
+typedef UINT64                          NATIVE_INT;
 
 typedef NATIVE_UINT                     ACPI_TBLPTR;
 typedef UINT64                          ACPI_IO_ADDRESS;
 typedef UINT64                          ACPI_PHYSICAL_ADDRESS;
+typedef UINT64                          ACPI_SIZE;
 
 #define ALIGNED_ADDRESS_BOUNDARY        0x00000008      /* No hardware alignment support in IA64 */
 #define ACPI_USE_NATIVE_DIVIDE                          /* Native 64-bit integer support */
+#define ACPI_MAX_PTR                    0xFFFFFFFFFFFFFFFF
 
 
 #elif _IA16
@@ -78,7 +78,6 @@ typedef UINT64                          ACPI_PHYSICAL_ADDRESS;
  */
 typedef unsigned char                   UINT8;
 typedef unsigned char                   BOOLEAN;
-typedef unsigned char                   UCHAR;
 typedef unsigned int                    UINT16;
 typedef long                            INT32;
 typedef int                             INT16;
@@ -97,10 +96,12 @@ typedef INT16                           NATIVE_INT;
 typedef UINT32                          ACPI_TBLPTR;
 typedef UINT32                          ACPI_IO_ADDRESS;
 typedef char                            *ACPI_PHYSICAL_ADDRESS;
+typedef UINT32                          ACPI_SIZE;
 
 #define ALIGNED_ADDRESS_BOUNDARY        0x00000002
 #define _HW_ALIGNMENT_SUPPORT
 #define ACPI_USE_NATIVE_DIVIDE                          /* No 64-bit integers, ok to use native divide */
+#define ACPI_MAX_PTR                    0xFFFF
 
 /*
  * (16-bit only) internal integers must be 32-bits, so
@@ -115,7 +116,6 @@ typedef char                            *ACPI_PHYSICAL_ADDRESS;
  */
 typedef unsigned char                   UINT8;
 typedef unsigned char                   BOOLEAN;
-typedef unsigned char                   UCHAR;
 typedef unsigned short                  UINT16;
 typedef int                             INT32;
 typedef unsigned int                    UINT32;
@@ -127,9 +127,11 @@ typedef INT32                           NATIVE_INT;
 typedef NATIVE_UINT                     ACPI_TBLPTR;
 typedef UINT32                          ACPI_IO_ADDRESS;
 typedef UINT64                          ACPI_PHYSICAL_ADDRESS;
+typedef UINT32                          ACPI_SIZE;
 
 #define ALIGNED_ADDRESS_BOUNDARY        0x00000004
 #define _HW_ALIGNMENT_SUPPORT
+#define ACPI_MAX_PTR                    0xFFFFFFFF
 #endif
 
 
@@ -151,11 +153,13 @@ typedef char                            NATIVE_CHAR;
 #define ACPI_UINT16_MAX                 (UINT16) 0xFFFF
 #define ACPI_UINT32_MAX                 (UINT32) 0xFFFFFFFF
 #define ACPI_UINT64_MAX                 (UINT64) 0xFFFFFFFFFFFFFFFF
+#define ACPI_ASCII_MAX                  0x7F
 
 
 #ifdef DEFINE_ALTERNATE_TYPES
 /*
- * Types used only in translated source
+ * Types used only in translated source, defined here to enable
+ * cross-platform compilation only.
  */
 typedef INT32                           s32;
 typedef UINT8                           u8;
@@ -251,7 +255,7 @@ typedef u64                             acpi_integer;
  * Constants with special meanings
  */
 
-#define ACPI_ROOT_OBJECT                (acpi_handle)(-1)
+#define ACPI_ROOT_OBJECT                (acpi_handle) ACPI_PTR_ADD (char, NULL, ACPI_UINT32_MAX)
 
 
 /*
@@ -261,9 +265,10 @@ typedef u64                             acpi_integer;
 #define ACPI_NO_ADDRESS_SPACE_INIT      0x01
 #define ACPI_NO_HARDWARE_INIT           0x02
 #define ACPI_NO_EVENT_INIT              0x04
-#define ACPI_NO_ACPI_ENABLE             0x08
-#define ACPI_NO_DEVICE_INIT             0x10
-#define ACPI_NO_OBJECT_INIT             0x20
+#define ACPI_NO_HANDLER_INIT            0x08
+#define ACPI_NO_ACPI_ENABLE             0x10
+#define ACPI_NO_DEVICE_INIT             0x20
+#define ACPI_NO_OBJECT_INIT             0x40
 
 /*
  * Initialization state
@@ -292,6 +297,19 @@ typedef u64                             acpi_integer;
 #define ACPI_D_STATES_MAX               ACPI_STATE_D3
 #define ACPI_D_STATE_COUNT              4
 
+#define ACPI_STATE_C0                   (u8) 0
+#define ACPI_STATE_C1                   (u8) 1
+#define ACPI_STATE_C2                   (u8) 2
+#define ACPI_STATE_C3                   (u8) 3
+#define ACPI_C_STATES_MAX               ACPI_STATE_C3
+#define ACPI_C_STATE_COUNT              4
+
+/*
+ * Sleep type invalid value
+ */
+#define ACPI_SLEEP_TYPE_MAX             0x7
+#define ACPI_SLEEP_TYPE_INVALID         0xFF
+
 /*
  * Standard notify values
  */
@@ -326,35 +344,33 @@ typedef u32                             acpi_table_type;
  * Types associated with names.  The first group of
  * values correspond to the definition of the ACPI
  * Object_type operator (See the ACPI Spec). Therefore,
- * only add to the first group if the spec changes!
+ * only add to the first group if the spec changes.
  *
  * Types must be kept in sync with the Acpi_ns_properties
  * and Acpi_ns_type_names arrays
  */
 
 typedef u32                             acpi_object_type;
-typedef u8                              acpi_object_type8;
-
-
-#define ACPI_TYPE_ANY                   0  /* 0x00  */
-#define ACPI_TYPE_INTEGER               1  /* 0x01  Byte/Word/Dword/Zero/One/Ones */
-#define ACPI_TYPE_STRING                2  /* 0x02  */
-#define ACPI_TYPE_BUFFER                3  /* 0x03  */
-#define ACPI_TYPE_PACKAGE               4  /* 0x04  Byte_const, multiple Data_term/Constant/Super_name */
-#define ACPI_TYPE_FIELD_UNIT            5  /* 0x05  */
-#define ACPI_TYPE_DEVICE                6  /* 0x06  Name, multiple Node */
-#define ACPI_TYPE_EVENT                 7  /* 0x07  */
-#define ACPI_TYPE_METHOD                8  /* 0x08  Name, Byte_const, multiple Code */
-#define ACPI_TYPE_MUTEX                 9  /* 0x09  */
-#define ACPI_TYPE_REGION                10 /* 0x0A  */
-#define ACPI_TYPE_POWER                 11 /* 0x0B  Name,Byte_const,Word_const,multi Node */
-#define ACPI_TYPE_PROCESSOR             12 /* 0x0C  Name,Byte_const,DWord_const,Byte_const,multi Nm_o */
-#define ACPI_TYPE_THERMAL               13 /* 0x0D  Name, multiple Node */
-#define ACPI_TYPE_BUFFER_FIELD          14 /* 0x0E  */
-#define ACPI_TYPE_DDB_HANDLE            15 /* 0x0F  */
-#define ACPI_TYPE_DEBUG_OBJECT          16 /* 0x10  */
-
-#define ACPI_TYPE_MAX                   16
+
+#define ACPI_TYPE_ANY                   0x00
+#define ACPI_TYPE_INTEGER               0x01  /* Byte/Word/Dword/Zero/One/Ones */
+#define ACPI_TYPE_STRING                0x02
+#define ACPI_TYPE_BUFFER                0x03
+#define ACPI_TYPE_PACKAGE               0x04  /* Byte_const, multiple Data_term/Constant/Super_name */
+#define ACPI_TYPE_FIELD_UNIT            0x05
+#define ACPI_TYPE_DEVICE                0x06  /* Name, multiple Node */
+#define ACPI_TYPE_EVENT                 0x07
+#define ACPI_TYPE_METHOD                0x08  /* Name, Byte_const, multiple Code */
+#define ACPI_TYPE_MUTEX                 0x09
+#define ACPI_TYPE_REGION                0x0A
+#define ACPI_TYPE_POWER                 0x0B  /* Name,Byte_const,Word_const,multi Node */
+#define ACPI_TYPE_PROCESSOR             0x0C  /* Name,Byte_const,DWord_const,Byte_const,multi Nm_o */
+#define ACPI_TYPE_THERMAL               0x0D  /* Name, multiple Node */
+#define ACPI_TYPE_BUFFER_FIELD          0x0E
+#define ACPI_TYPE_DDB_HANDLE            0x0F
+#define ACPI_TYPE_DEBUG_OBJECT          0x10
+
+#define ACPI_TYPE_MAX                   0x10
 
 /*
  * This section contains object types that do not relate to the ACPI Object_type operator.
@@ -363,36 +379,37 @@ typedef u8                              acpi_object_type8;
  * Also, values exceeding the largest official ACPI Object_type must not overlap with
  * defined AML opcodes.
  */
-#define INTERNAL_TYPE_BEGIN             17
+#define INTERNAL_TYPE_BEGIN             0x11
 
-#define INTERNAL_TYPE_REGION_FIELD      17 /* 0x11  */
-#define INTERNAL_TYPE_BANK_FIELD        18 /* 0x12  */
-#define INTERNAL_TYPE_INDEX_FIELD       19 /* 0x13  */
-#define INTERNAL_TYPE_REFERENCE         20 /* 0x14  Arg#, Local#, Name, Debug; used only in descriptors */
-#define INTERNAL_TYPE_ALIAS             21 /* 0x15  */
-#define INTERNAL_TYPE_NOTIFY            22 /* 0x16  */
-#define INTERNAL_TYPE_ADDRESS_HANDLER   23 /* 0x17  */
-#define INTERNAL_TYPE_RESOURCE          24 /* 0x18  */
-#define INTERNAL_TYPE_RESOURCE_FIELD    25 /* 0x19  */
+#define INTERNAL_TYPE_REGION_FIELD      0x11
+#define INTERNAL_TYPE_BANK_FIELD        0x12
+#define INTERNAL_TYPE_INDEX_FIELD       0x13
+#define INTERNAL_TYPE_REFERENCE         0x14  /* Arg#, Local#, Name, Debug; used only in descriptors */
+#define INTERNAL_TYPE_ALIAS             0x15
+#define INTERNAL_TYPE_NOTIFY            0x16
+#define INTERNAL_TYPE_ADDRESS_HANDLER   0x17
+#define INTERNAL_TYPE_RESOURCE          0x18
+#define INTERNAL_TYPE_RESOURCE_FIELD    0x19
 
 
-#define INTERNAL_TYPE_NODE_MAX          25
+#define INTERNAL_TYPE_NODE_MAX          0x19
 
 /* These are pseudo-types because there are never any namespace nodes with these types */
 
-#define INTERNAL_TYPE_FIELD_DEFN        26 /* 0x1A  Name, Byte_const, multiple Field_element */
-#define INTERNAL_TYPE_BANK_FIELD_DEFN   27 /* 0x1B  2 Name,DWord_const,Byte_const,multi Field_element */
-#define INTERNAL_TYPE_INDEX_FIELD_DEFN  28 /* 0x1C  2 Name, Byte_const, multiple Field_element */
-#define INTERNAL_TYPE_IF                29 /* 0x1D  */
-#define INTERNAL_TYPE_ELSE              30 /* 0x1E  */
-#define INTERNAL_TYPE_WHILE             31 /* 0x1F  */
-#define INTERNAL_TYPE_SCOPE             32 /* 0x20  Name, multiple Node */
-#define INTERNAL_TYPE_DEF_ANY           33 /* 0x21  type is Any, suppress search of enclosing scopes */
-#define INTERNAL_TYPE_EXTRA             34 /* 0x22  */
+#define INTERNAL_TYPE_FIELD_DEFN        0x1A  /* Name, Byte_const, multiple Field_element */
+#define INTERNAL_TYPE_BANK_FIELD_DEFN   0x1B  /* 2 Name,DWord_const,Byte_const,multi Field_element */
+#define INTERNAL_TYPE_INDEX_FIELD_DEFN  0x1C  /* 2 Name, Byte_const, multiple Field_element */
+#define INTERNAL_TYPE_IF                0x1D
+#define INTERNAL_TYPE_ELSE              0x1E
+#define INTERNAL_TYPE_WHILE             0x1F
+#define INTERNAL_TYPE_SCOPE             0x20  /* Name, multiple Node */
+#define INTERNAL_TYPE_DEF_ANY           0x21  /* type is Any, suppress search of enclosing scopes */
+#define INTERNAL_TYPE_EXTRA             0x22
+#define INTERNAL_TYPE_DATA              0x23
 
-#define INTERNAL_TYPE_MAX               34
+#define INTERNAL_TYPE_MAX               0x23
 
-#define INTERNAL_TYPE_INVALID           35
+#define INTERNAL_TYPE_INVALID           0x24
 #define ACPI_TYPE_NOT_FOUND             0xFF
 
 
@@ -428,51 +445,48 @@ typedef u8                              acpi_object_type8;
 #define ACPI_BTYPE_OBJECTS_AND_REFS     0x0001FFFF  /* ARG or LOCAL */
 #define ACPI_BTYPE_ALL_OBJECTS          0x0000FFFF
 
+/*
+ * All I/O
+ */
+#define ACPI_READ                       0
+#define ACPI_WRITE                      1
+
 
 /*
- * Acpi_event Types:
- * ------------
- * Fixed & general purpose...
+ * Acpi_event Types: Fixed & General Purpose
  */
 
 typedef u32                             acpi_event_type;
 
-#define ACPI_EVENT_FIXED                (acpi_event_type) 0
-#define ACPI_EVENT_GPE                  (acpi_event_type) 1
+#define ACPI_EVENT_FIXED                0
+#define ACPI_EVENT_GPE                  1
 
 /*
  * Fixed events
  */
 
-#define ACPI_EVENT_PMTIMER              (acpi_event_type) 0
-       /*
-        * There's no bus master event so index 1 is used for IRQ's that are not
-        * handled by the SCI handler
-        */
-#define ACPI_EVENT_NOT_USED             (acpi_event_type) 1
-#define ACPI_EVENT_GLOBAL               (acpi_event_type) 2
-#define ACPI_EVENT_POWER_BUTTON         (acpi_event_type) 3
-#define ACPI_EVENT_SLEEP_BUTTON         (acpi_event_type) 4
-#define ACPI_EVENT_RTC                  (acpi_event_type) 5
-#define ACPI_EVENT_GENERAL              (acpi_event_type) 6
-#define ACPI_EVENT_MAX                  6
-#define ACPI_NUM_FIXED_EVENTS           (acpi_event_type) 7
+#define ACPI_EVENT_PMTIMER              0
+#define ACPI_EVENT_GLOBAL               1
+#define ACPI_EVENT_POWER_BUTTON         2
+#define ACPI_EVENT_SLEEP_BUTTON         3
+#define ACPI_EVENT_RTC                  4
+#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      (acpi_event_type) 1
-#define ACPI_EVENT_EDGE_TRIGGERED       (acpi_event_type) 2
+#define ACPI_EVENT_LEVEL_TRIGGERED      1
+#define ACPI_EVENT_EDGE_TRIGGERED       2
 
 /*
  * GPEs
  */
-#define ACPI_EVENT_ENABLE               0x1
-#define ACPI_EVENT_WAKE_ENABLE         0x2
 
-#define ACPI_EVENT_DISABLE              0x1
-#define ACPI_EVENT_WAKE_DISABLE         0x2
+#define ACPI_EVENT_WAKE_ENABLE          0x1
+
+#define ACPI_EVENT_WAKE_DISABLE         0x1
 
 
 /*
@@ -504,7 +518,7 @@ typedef u32                             acpi_event_status;
 #define ACPI_DEVICE_NOTIFY              1
 #define ACPI_MAX_NOTIFY_HANDLER_TYPE    1
 
-#define MAX_SYS_NOTIFY                  0x7f
+#define ACPI_MAX_SYS_NOTIFY                  0x7f
 
 
 /* Address Space (Operation Region) Types */
@@ -518,6 +532,7 @@ typedef u8                              ACPI_ADR_SPACE_TYPE;
 #define ACPI_ADR_SPACE_SMBUS            (ACPI_ADR_SPACE_TYPE) 4
 #define ACPI_ADR_SPACE_CMOS             (ACPI_ADR_SPACE_TYPE) 5
 #define ACPI_ADR_SPACE_PCI_BAR_TARGET   (ACPI_ADR_SPACE_TYPE) 6
+#define ACPI_ADR_SPACE_DATA_TABLE       (ACPI_ADR_SPACE_TYPE) 7
 
 
 /*
@@ -576,7 +591,7 @@ typedef union acpi_obj
                u32                         resource_order;
        } power_resource;
 
-} acpi_object, *PACPI_OBJECT;
+} acpi_object;
 
 
 /*
@@ -588,16 +603,20 @@ typedef struct acpi_obj_list
        u32                         count;
        acpi_object                 *pointer;
 
-} acpi_object_list, *PACPI_OBJECT_LIST;
+} acpi_object_list;
 
 
 /*
  * Miscellaneous common Data Structures used by the interfaces
  */
 
+#define ACPI_NO_BUFFER              0
+#define ACPI_ALLOCATE_BUFFER        (ACPI_SIZE) (-1)
+#define ACPI_ALLOCATE_LOCAL_BUFFER  (ACPI_SIZE) (-2)
+
 typedef struct
 {
-       u32                         length;         /* Length in bytes of the buffer */
+       ACPI_SIZE                   length;         /* Length in bytes of the buffer */
        void                        *pointer;       /* pointer to buffer */
 
 } acpi_buffer;
@@ -616,10 +635,10 @@ typedef struct
  * Structure and flags for Acpi_get_system_info
  */
 
-#define SYS_MODE_UNKNOWN                0x0000
-#define SYS_MODE_ACPI                   0x0001
-#define SYS_MODE_LEGACY                 0x0002
-#define SYS_MODES_MASK                  0x0003
+#define ACPI_SYS_MODE_UNKNOWN           0x0000
+#define ACPI_SYS_MODE_ACPI              0x0001
+#define ACPI_SYS_MODE_LEGACY            0x0002
+#define ACPI_SYS_MODES_MASK             0x0003
 
 
 /*
@@ -669,22 +688,25 @@ void (*acpi_notify_handler) (
        u32                         value,
        void                        *context);
 
+typedef
+void (*ACPI_OBJECT_HANDLER) (
+       acpi_handle                 object,
+       u32                         function,
+       void                        *data);
 
-/* Address Spaces (Operation Regions */
 
-#define ACPI_READ_ADR_SPACE     1
-#define ACPI_WRITE_ADR_SPACE    2
+/* Address Spaces (Operation Regions */
 
 typedef
 acpi_status (*acpi_adr_space_handler) (
        u32                         function,
        ACPI_PHYSICAL_ADDRESS       address,
        u32                         bit_width,
-       u32                         *value,
+       acpi_integer                *value,
        void                        *handler_context,
        void                        *region_context);
 
-#define ACPI_DEFAULT_HANDLER            ((acpi_adr_space_handler) NULL)
+#define ACPI_DEFAULT_HANDLER        ((acpi_adr_space_handler) NULL)
 
 
 typedef
@@ -707,8 +729,8 @@ acpi_status (*acpi_walk_callback) (
 
 /* Interrupt handler return values */
 
-#define INTERRUPT_NOT_HANDLED           0x00
-#define INTERRUPT_HANDLED               0x01
+#define ACPI_INTERRUPT_NOT_HANDLED      0x00
+#define ACPI_INTERRUPT_HANDLED          0x01
 
 
 /* Structure and flags for Acpi_get_device_info */
@@ -755,6 +777,8 @@ typedef struct
 
 typedef struct
 {
+       u32                         length;
+       ACPI_PHYSICAL_ADDRESS       address;
        ACPI_PHYSICAL_ADDRESS       mapped_physical_address;
        u8                          *mapped_logical_address;
        u32                         mapped_length;
@@ -773,78 +797,78 @@ typedef struct
 /*
  *  Memory Attributes
  */
-#define READ_ONLY_MEMORY                (u8) 0x00
-#define READ_WRITE_MEMORY               (u8) 0x01
+#define ACPI_READ_ONLY_MEMORY           (u8) 0x00
+#define ACPI_READ_WRITE_MEMORY          (u8) 0x01
 
-#define NON_CACHEABLE_MEMORY            (u8) 0x00
-#define CACHABLE_MEMORY                 (u8) 0x01
-#define WRITE_COMBINING_MEMORY          (u8) 0x02
-#define PREFETCHABLE_MEMORY             (u8) 0x03
+#define ACPI_NON_CACHEABLE_MEMORY       (u8) 0x00
+#define ACPI_CACHABLE_MEMORY            (u8) 0x01
+#define ACPI_WRITE_COMBINING_MEMORY     (u8) 0x02
+#define ACPI_PREFETCHABLE_MEMORY        (u8) 0x03
 
 /*
  *  IO Attributes
- *  The ISA IO ranges are:     n000-n0FFh,  n400-n4_fFh, n800-n8_fFh, n_c00-n_cFFh.
+ *  The ISA IO ranges are:     n000-n0_fFh, n400-n4_fFh, n800-n8_fFh, n_c00-n_cFFh.
  *  The non-ISA IO ranges are: n100-n3_fFh, n500-n7_fFh, n900-n_bFFh, n_cD0-n_fFFh.
  */
-#define NON_ISA_ONLY_RANGES             (u8) 0x01
-#define ISA_ONLY_RANGES                 (u8) 0x02
-#define ENTIRE_RANGE                    (NON_ISA_ONLY_RANGES | ISA_ONLY_RANGES)
+#define ACPI_NON_ISA_ONLY_RANGES        (u8) 0x01
+#define ACPI_ISA_ONLY_RANGES            (u8) 0x02
+#define ACPI_ENTIRE_RANGE               (ACPI_NON_ISA_ONLY_RANGES | ACPI_ISA_ONLY_RANGES)
 
 /*
  *  IO Port Descriptor Decode
  */
-#define DECODE_10                       (u8) 0x00    /* 10-bit IO address decode */
-#define DECODE_16                       (u8) 0x01    /* 16-bit IO address decode */
+#define ACPI_DECODE_10                  (u8) 0x00    /* 10-bit IO address decode */
+#define ACPI_DECODE_16                  (u8) 0x01    /* 16-bit IO address decode */
 
 /*
  *  IRQ Attributes
  */
-#define EDGE_SENSITIVE                  (u8) 0x00
-#define LEVEL_SENSITIVE                 (u8) 0x01
+#define ACPI_EDGE_SENSITIVE             (u8) 0x00
+#define ACPI_LEVEL_SENSITIVE            (u8) 0x01
 
-#define ACTIVE_HIGH                     (u8) 0x00
-#define ACTIVE_LOW                      (u8) 0x01
+#define ACPI_ACTIVE_HIGH                (u8) 0x00
+#define ACPI_ACTIVE_LOW                 (u8) 0x01
 
-#define EXCLUSIVE                       (u8) 0x00
-#define SHARED                          (u8) 0x01
+#define ACPI_EXCLUSIVE                  (u8) 0x00
+#define ACPI_SHARED                     (u8) 0x01
 
 /*
  *  DMA Attributes
  */
-#define COMPATIBILITY                   (u8) 0x00
-#define TYPE_A                          (u8) 0x01
-#define TYPE_B                          (u8) 0x02
-#define TYPE_F                          (u8) 0x03
+#define ACPI_COMPATIBILITY              (u8) 0x00
+#define ACPI_TYPE_A                     (u8) 0x01
+#define ACPI_TYPE_B                     (u8) 0x02
+#define ACPI_TYPE_F                     (u8) 0x03
 
-#define NOT_BUS_MASTER                  (u8) 0x00
-#define BUS_MASTER                      (u8) 0x01
+#define ACPI_NOT_BUS_MASTER             (u8) 0x00
+#define ACPI_BUS_MASTER                 (u8) 0x01
 
-#define TRANSFER_8                      (u8) 0x00
-#define TRANSFER_8_16                   (u8) 0x01
-#define TRANSFER_16                     (u8) 0x02
+#define ACPI_TRANSFER_8                 (u8) 0x00
+#define ACPI_TRANSFER_8_16              (u8) 0x01
+#define ACPI_TRANSFER_16                (u8) 0x02
 
 /*
  * Start Dependent Functions Priority definitions
  */
-#define GOOD_CONFIGURATION              (u8) 0x00
-#define ACCEPTABLE_CONFIGURATION        (u8) 0x01
-#define SUB_OPTIMAL_CONFIGURATION       (u8) 0x02
+#define ACPI_GOOD_CONFIGURATION         (u8) 0x00
+#define ACPI_ACCEPTABLE_CONFIGURATION   (u8) 0x01
+#define ACPI_SUB_OPTIMAL_CONFIGURATION  (u8) 0x02
 
 /*
  *  16, 32 and 64-bit Address Descriptor resource types
  */
-#define MEMORY_RANGE                    (u8) 0x00
-#define IO_RANGE                        (u8) 0x01
-#define BUS_NUMBER_RANGE                (u8) 0x02
+#define ACPI_MEMORY_RANGE               (u8) 0x00
+#define ACPI_IO_RANGE                   (u8) 0x01
+#define ACPI_BUS_NUMBER_RANGE           (u8) 0x02
 
-#define ADDRESS_NOT_FIXED               (u8) 0x00
-#define ADDRESS_FIXED                   (u8) 0x01
+#define ACPI_ADDRESS_NOT_FIXED          (u8) 0x00
+#define ACPI_ADDRESS_FIXED              (u8) 0x01
 
-#define POS_DECODE                      (u8) 0x00
-#define SUB_DECODE                      (u8) 0x01
+#define ACPI_POS_DECODE                 (u8) 0x00
+#define ACPI_SUB_DECODE                 (u8) 0x01
 
-#define PRODUCER                        (u8) 0x00
-#define CONSUMER                        (u8) 0x01
+#define ACPI_PRODUCER                   (u8) 0x00
+#define ACPI_CONSUMER                   (u8) 0x01
 
 
 /*
@@ -906,6 +930,12 @@ typedef struct
 
 } acpi_resource_vendor;
 
+typedef struct
+{
+       u8                          checksum;
+
+} ACPI_RESOURCE_END_TAG;
+
 typedef struct
 {
        u32                         read_write_attribute;
@@ -1053,7 +1083,7 @@ typedef struct
 #define ACPI_RSTYPE_ADDRESS64           13
 #define ACPI_RSTYPE_EXT_IRQ             14
 
-typedef u32                     acpi_resource_type;
+typedef u32                             acpi_resource_type;
 
 typedef union
 {
@@ -1063,6 +1093,7 @@ typedef union
        acpi_resource_io            io;
        acpi_resource_fixed_io      fixed_io;
        acpi_resource_vendor        vendor_specific;
+       ACPI_RESOURCE_END_TAG       end_tag;
        acpi_resource_mem24         memory24;
        acpi_resource_mem32         memory32;
        acpi_resource_fixed_mem32   fixed_memory32;
@@ -1081,20 +1112,25 @@ typedef struct acpi_resource
 
 } acpi_resource;
 
-#define ACPI_RESOURCE_LENGTH            12
-#define ACPI_RESOURCE_LENGTH_NO_DATA    8       /* Id + Length fields */
+#define ACPI_RESOURCE_LENGTH                12
+#define ACPI_RESOURCE_LENGTH_NO_DATA        8       /* Id + Length fields */
 
-#define SIZEOF_RESOURCE(type)   (ACPI_RESOURCE_LENGTH_NO_DATA + sizeof (type))
+#define ACPI_SIZEOF_RESOURCE(type)          (ACPI_RESOURCE_LENGTH_NO_DATA + sizeof (type))
 
-#define NEXT_RESOURCE(res)      (acpi_resource *)((u8 *) res + res->length)
+#define ACPI_NEXT_RESOURCE(res)             (acpi_resource *)((u8 *) res + res->length)
 
+#ifdef _HW_ALIGNMENT_SUPPORT
+#define ACPI_ALIGN_RESOURCE_SIZE(length)    (length)
+#else
+#define ACPI_ALIGN_RESOURCE_SIZE(length)    ACPI_ROUND_UP_TO_NATIVE_WORD(length)
+#endif
 
 /*
- * END: Definitions for Resource Attributes
+ * END: of definitions for Resource Attributes
  */
 
 
-typedef struct pci_routing_table
+typedef struct acpi_pci_routing_table
 {
        u32                         length;
        u32                         pin;
@@ -1102,11 +1138,11 @@ typedef struct pci_routing_table
        u32                         source_index;
        NATIVE_CHAR                 source[4];      /* pad to 64 bits so sizeof() works in all cases */
 
-} pci_routing_table;
-
+} acpi_pci_routing_table;
 
 /*
- * END: Definitions for PCI Routing tables
+ * END: of definitions for PCI Routing tables
  */
 
+
 #endif /* __ACTYPES_H__ */
index efbcd6bd1c7d25071284428765abd33d284849c0..4f42e8f975aea8a5c48a1a52beb215379eed50d6 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Name: acutils.h -- prototypes for the common (subsystem-wide) procedures
- *       $Revision: 117 $
+ *       $Revision: 130 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -46,7 +46,7 @@ acpi_ut_walk_package_tree (
 typedef struct acpi_pkg_info
 {
        u8                      *free_space;
-       u32                     length;
+       ACPI_SIZE               length;
        u32                     object_space;
        u32                     num_packages;
 } acpi_pkg_info;
@@ -102,14 +102,18 @@ acpi_ut_get_mutex_name (
 
 NATIVE_CHAR *
 acpi_ut_get_type_name (
-       u32                     type);
+       acpi_object_type        type);
+
+#endif
+
 
 NATIVE_CHAR *
 acpi_ut_get_region_name (
        u8                      space_id);
 
-#endif
-
+NATIVE_CHAR *
+acpi_ut_get_event_name (
+       u32                     event_id);
 
 u8
 acpi_ut_hex_to_ascii_char (
@@ -118,7 +122,7 @@ acpi_ut_hex_to_ascii_char (
 
 u8
 acpi_ut_valid_object_type (
-       u32                     type);
+       acpi_object_type        type);
 
 acpi_owner_id
 acpi_ut_allocate_owner_id (
@@ -244,6 +248,17 @@ acpi_ut_copy_ipackage_to_ipackage (
        acpi_operand_object     *dest_obj,
        acpi_walk_state         *walk_state);
 
+acpi_status
+acpi_ut_copy_simple_object (
+       acpi_operand_object     *source_desc,
+       acpi_operand_object     *dest_desc);
+
+acpi_status
+acpi_ut_copy_iobject_to_iobject (
+       acpi_operand_object     *source_desc,
+       acpi_operand_object     **dest_desc,
+       acpi_walk_state         *walk_state);
+
 
 /*
  * Ut_create - Object creation
@@ -338,7 +353,7 @@ acpi_ut_dump_buffer (
        u32                     display,
        u32                     component_id);
 
-void
+void ACPI_INTERNAL_VAR_XFACE
 acpi_ut_debug_print (
        u32                     requested_debug_level,
        u32                     line_number,
@@ -346,7 +361,7 @@ acpi_ut_debug_print (
        char                    *format,
        ...) ACPI_PRINTF_LIKE_FUNC;
 
-void
+void ACPI_INTERNAL_VAR_XFACE
 acpi_ut_debug_print_raw (
        u32                     requested_debug_level,
        u32                     line_number,
@@ -383,6 +398,7 @@ acpi_ut_delete_internal_object_list (
 /* Method name strings */
 
 #define METHOD_NAME__HID        "_HID"
+#define METHOD_NAME__CID        "_CID"
 #define METHOD_NAME__UID        "_UID"
 #define METHOD_NAME__ADR        "_ADR"
 #define METHOD_NAME__STA        "_STA"
@@ -403,6 +419,11 @@ acpi_ut_execute_HID (
        acpi_namespace_node     *device_node,
        acpi_device_id          *hid);
 
+acpi_status
+acpi_ut_execute_CID (
+       acpi_namespace_node     *device_node,
+       acpi_device_id          *cid);
+
 acpi_status
 acpi_ut_execute_STA (
        acpi_namespace_node     *device_node,
@@ -452,7 +473,7 @@ acpi_ut_create_internal_object_dbg (
        NATIVE_CHAR             *module_name,
        u32                     line_number,
        u32                     component_id,
-       acpi_object_type8       type);
+       acpi_object_type        type);
 
 void *
 acpi_ut_allocate_object_desc_dbg (
@@ -491,17 +512,17 @@ acpi_ut_remove_reference (
 acpi_status
 acpi_ut_get_simple_object_size (
        acpi_operand_object     *obj,
-       u32                     *obj_length);
+       ACPI_SIZE               *obj_length);
 
 acpi_status
 acpi_ut_get_package_object_size (
        acpi_operand_object     *obj,
-       u32                     *obj_length);
+       ACPI_SIZE               *obj_length);
 
 acpi_status
 acpi_ut_get_object_size(
        acpi_operand_object     *obj,
-       u32                     *obj_length);
+       ACPI_SIZE               *obj_length);
 
 
 /*
@@ -522,6 +543,10 @@ acpi_generic_state *
 acpi_ut_create_generic_state (
        void);
 
+ACPI_THREAD_STATE *
+acpi_ut_create_thread_state (
+       void);
+
 acpi_generic_state *
 acpi_ut_create_update_state (
        acpi_operand_object     *object,
@@ -596,6 +621,14 @@ acpi_status
 acpi_ut_resolve_package_references (
        acpi_operand_object     *obj_desc);
 
+u8 *
+acpi_ut_get_resource_end_tag (
+       acpi_operand_object     *obj_desc);
+
+u8
+acpi_ut_generate_checksum (
+       u8                      *buffer,
+       u32                     length);
 
 #ifdef ACPI_DEBUG
 void
@@ -623,31 +656,73 @@ void
 acpi_ut_delete_generic_cache (
        u32                     list_id);
 
+acpi_status
+acpi_ut_validate_buffer (
+       acpi_buffer             *buffer);
+
+acpi_status
+acpi_ut_initialize_buffer (
+       acpi_buffer             *buffer,
+       ACPI_SIZE               required_length);
+
 
-/* Debug Memory allocation functions */
+/* Memory allocation functions */
 
 void *
 acpi_ut_allocate (
-       u32                     size,
+       ACPI_SIZE               size,
        u32                     component,
        NATIVE_CHAR             *module,
        u32                     line);
 
 void *
 acpi_ut_callocate (
-       u32                     size,
+       ACPI_SIZE               size,
+       u32                     component,
+       NATIVE_CHAR             *module,
+       u32                     line);
+
+
+#ifdef ACPI_DBG_TRACK_ALLOCATIONS
+
+void *
+acpi_ut_allocate_and_track (
+       ACPI_SIZE               size,
+       u32                     component,
+       NATIVE_CHAR             *module,
+       u32                     line);
+
+void *
+acpi_ut_callocate_and_track (
+       ACPI_SIZE               size,
        u32                     component,
        NATIVE_CHAR             *module,
        u32                     line);
 
 void
-acpi_ut_free (
+acpi_ut_free_and_track (
        void                    *address,
        u32                     component,
        NATIVE_CHAR             *module,
        u32                     line);
+acpi_status
+acpi_ut_track_allocation (
+       u32                     list_id,
+       acpi_debug_mem_block    *address,
+       ACPI_SIZE               size,
+       u8                      alloc_type,
+       u32                     component,
+       NATIVE_CHAR             *module,
+       u32                     line);
+
+acpi_status
+acpi_ut_remove_allocation (
+       u32                     list_id,
+       acpi_debug_mem_block    *address,
+       u32                     component,
+       NATIVE_CHAR             *module,
+       u32                     line);
 
-#ifdef ACPI_DBG_TRACK_ALLOCATIONS
 void
 acpi_ut_dump_allocation_info (
        void);
index 196b236bf045b3a318db3a4a9acc2318f5268be5..7ef785c751a9a70cd3e02b4a21c6af58d7590c13 100644 (file)
@@ -3,12 +3,12 @@
  * Name: amlcode.h - Definitions for AML, as included in "definition blocks"
  *                   Declarations and definitions contained herein are derived
  *                   directly from the ACPI specification.
- *       $Revision: 58 $
+ *       $Revision: 66 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  * Resolved argument types for the AML Interpreter
  * Each field in the Arg_types u32 is 5 bits, allowing for a maximum of 6 arguments.
  * There can be up to 31 unique argument types (0 is end-of-arg-list indicator)
+ *
+ * Note: If and when 5 bits becomes insufficient, it would probably be best
+ * to convert to a 6-byte array of argument types, allowing 8 bits per argument.
  */
 
 /* "Standard" ACPI types are 1-15 (0x0F) */
 #define ARGI_FIXED_TARGET           0x1B     /* Target, no implicit conversion */
 #define ARGI_SIMPLE_TARGET          0x1C     /* Name, Local, Arg -- no implicit conversion */
 #define ARGI_BUFFERSTRING           0x1D
+#define ARGI_REF_OR_STRING          0x1E     /* Reference or String (Used by DEREFOF op only) */
 
 #define ARGI_INVALID_OPCODE         0xFFFFFFFF
 
@@ -369,7 +373,8 @@ typedef enum
        REGION_SMBUS,
        REGION_CMOS,
        REGION_PCI_BAR,
-       REGION_FIXED_HW                 = 0x7F,
+       REGION_DATA_TABLE,              /* Internal use only */
+       REGION_FIXED_HW                 = 0x7F
 
 } AML_REGION_TYPES;
 
@@ -390,52 +395,76 @@ typedef enum
 #define MAX_MATCH_OPERATOR          5
 
 
-/* Field Access Types */
+/*
+ * Field_flags
+ *
+ * This byte is extracted from the AML and includes three separate
+ * pieces of information about the field:
+ * 1) The field access type
+ * 2) The field update rule
+ * 3) The lock rule for the field
+ *
+ * Bits 00 - 03 : Access_type (Any_acc, Byte_acc, etc.)
+ *      04      : Lock_rule (1 == Lock)
+ *      05 - 06 : Update_rule
+ */
+#define AML_FIELD_ACCESS_TYPE_MASK  0x0F
+#define AML_FIELD_LOCK_RULE_MASK    0x10
+#define AML_FIELD_UPDATE_RULE_MASK  0x60
 
-#define ACCESS_TYPE_MASK            0x0f
-#define ACCESS_TYPE_SHIFT           0
+
+/* 1) Field Access Types */
 
 typedef enum
 {
-       ACCESS_ANY_ACC                  = 0,
-       ACCESS_BYTE_ACC                 = 1,
-       ACCESS_WORD_ACC                 = 2,
-       ACCESS_DWORD_ACC                = 3,
-       ACCESS_QWORD_ACC                = 4,    /* ACPI 2.0 */
-       ACCESS_BLOCK_ACC                = 4,
-       ACCESS_SMBSEND_RECV_ACC         = 5,
-       ACCESS_SMBQUICK_ACC             = 6
+       AML_FIELD_ACCESS_ANY            = 0x00,
+       AML_FIELD_ACCESS_BYTE           = 0x01,
+       AML_FIELD_ACCESS_WORD           = 0x02,
+       AML_FIELD_ACCESS_DWORD          = 0x03,
+       AML_FIELD_ACCESS_QWORD          = 0x04,    /* ACPI 2.0 */
+       AML_FIELD_ACCESS_BUFFER         = 0x05     /* ACPI 2.0 */
 
 } AML_ACCESS_TYPE;
 
 
-/* Field Lock Rules */
-
-#define LOCK_RULE_MASK              0x10
-#define LOCK_RULE_SHIFT             4
+/* 2) Field Lock Rules */
 
 typedef enum
 {
-       GLOCK_NEVER_LOCK                = 0,
-       GLOCK_ALWAYS_LOCK               = 1
+       AML_FIELD_LOCK_NEVER            = 0x00,
+       AML_FIELD_LOCK_ALWAYS           = 0x10
 
 } AML_LOCK_RULE;
 
 
-/* Field Update Rules */
-
-#define UPDATE_RULE_MASK            0x060
-#define UPDATE_RULE_SHIFT           5
+/* 3) Field Update Rules */
 
 typedef enum
 {
-       UPDATE_PRESERVE                 = 0,
-       UPDATE_WRITE_AS_ONES            = 1,
-       UPDATE_WRITE_AS_ZEROS           = 2
+       AML_FIELD_UPDATE_PRESERVE       = 0x00,
+       AML_FIELD_UPDATE_WRITE_AS_ONES  = 0x20,
+       AML_FIELD_UPDATE_WRITE_AS_ZEROS = 0x40
 
 } AML_UPDATE_RULE;
 
 
+/*
+ * Field Access Attributes.
+ * This byte is extracted from the AML via the
+ * Access_as keyword
+ */
+typedef enum
+{
+       AML_FIELD_ATTRIB_SMB_QUICK      = 0x02,
+       AML_FIELD_ATTRIB_SMB_SEND_RCV   = 0x04,
+       AML_FIELD_ATTRIB_SMB_BYTE       = 0x06,
+       AML_FIELD_ATTRIB_SMB_WORD       = 0x08,
+       AML_FIELD_ATTRIB_SMB_BLOCK      = 0x0A,
+       AML_FIELD_ATTRIB_SMB_CALL       = 0x0E
+
+} AML_ACCESS_ATTRIBUTE;
+
+
 /* bit fields in Method_flags byte */
 
 #define METHOD_FLAGS_ARG_COUNT      0x07
@@ -445,15 +474,11 @@ typedef enum
 
 /* Array sizes.  Used for range checking also */
 
-#define NUM_REGION_TYPES            7
-#define NUM_ACCESS_TYPES            7
+#define NUM_ACCESS_TYPES            6
 #define NUM_UPDATE_RULES            3
 #define NUM_MATCH_OPS               7
 #define NUM_OPCODES                 256
 #define NUM_FIELD_NAMES             2
 
 
-#define USER_REGION_BEGIN           0x80
-
-
 #endif /* __AMLCODE_H__ */
index ba79092f4811435bbbc7ff9c8ace175df0ac3407..bf3cee324be123488b2fb4e951e3e210a04f7603 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Name: acenv.h - Generation environment specific items
- *       $Revision: 77 $
+ *       $Revision: 85 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 
 /*! [Begin] no source code translation */
 
-#ifdef _LINUX
+#if defined(_LINUX)
 #include "aclinux.h"
 
-#elif _AED_EFI
+#elif defined(_AED_EFI)
 #include "acefi.h"
 
-#elif WIN32
+#elif defined(MSDOS)
+#include "acdos16.h"
+
+#elif defined(WIN32)
 #include "acwin.h"
 
-#elif __FreeBSD__
+#elif defined(WIN64)
+#include "acwin64.h"
+
+#elif defined(__FreeBSD__)
 #include "acfreebsd.h"
 
+#elif defined(MODESTO)
+#include "acmodesto.h"
+
+#elif defined(NETWARE)
+#include "acnetware.h"
+
 #else
 
 /* All other environments */
 
 #endif
 
-
 /*! [End] no source code translation !*/
 
 /******************************************************************************
  * We will be linking to the standard Clib functions
  */
 
-#define STRSTR(s1,s2)   strstr((s1), (s2))
-#define STRUPR(s)       acpi_ut_strupr ((s))
-#define STRLEN(s)       (u32) strlen((s))
-#define STRCPY(d,s)     strcpy((d), (s))
-#define STRNCPY(d,s,n)  strncpy((d), (s), (NATIVE_INT)(n))
-#define STRNCMP(d,s,n)  strncmp((d), (s), (NATIVE_INT)(n))
-#define STRCMP(d,s)     strcmp((d), (s))
-#define STRCAT(d,s)     strcat((d), (s))
-#define STRNCAT(d,s,n)  strncat((d), (s), (NATIVE_INT)(n))
-#define STRTOUL(d,s,n)  strtoul((d), (s), (NATIVE_INT)(n))
-#define MEMCPY(d,s,n)   memcpy((d), (s), (NATIVE_INT)(n))
-#define MEMSET(d,s,n)   memset((d), (s), (NATIVE_INT)(n))
-#define TOUPPER         toupper
-#define TOLOWER         tolower
-#define IS_XDIGIT       isxdigit
+#define ACPI_STRSTR(s1,s2)      strstr((s1), (s2))
+#define ACPI_STRUPR(s)          acpi_ut_strupr ((s))
+#define ACPI_STRLEN(s)          (u32) strlen((s))
+#define ACPI_STRCPY(d,s)        strcpy((d), (s))
+#define ACPI_STRNCPY(d,s,n)     strncpy((d), (s), (NATIVE_INT)(n))
+#define ACPI_STRNCMP(d,s,n)     strncmp((d), (s), (NATIVE_INT)(n))
+#define ACPI_STRCMP(d,s)        strcmp((d), (s))
+#define ACPI_STRCAT(d,s)        strcat((d), (s))
+#define ACPI_STRNCAT(d,s,n)     strncat((d), (s), (NATIVE_INT)(n))
+#define ACPI_STRTOUL(d,s,n)     strtoul((d), (s), (NATIVE_INT)(n))
+#define ACPI_MEMCPY(d,s,n)      (void) memcpy((d), (s), (NATIVE_INT)(n))
+#define ACPI_MEMSET(d,s,n)      (void) memset((d), (s), (NATIVE_INT)(n))
+#define ACPI_TOUPPER            toupper
+#define ACPI_TOLOWER            tolower
+#define ACPI_IS_XDIGIT          isxdigit
 
 /******************************************************************************
  *
@@ -207,35 +218,35 @@ typedef char *va_list;
  * Storage alignment properties
  */
 
-#define  _AUPBND         (sizeof (NATIVE_INT) - 1)
-#define  _ADNBND         (sizeof (NATIVE_INT) - 1)
+#define  _AUPBND                (sizeof (NATIVE_INT) - 1)
+#define  _ADNBND                (sizeof (NATIVE_INT) - 1)
 
 /*
  * Variable argument list macro definitions
  */
 
-#define _bnd(X, bnd)    (((sizeof (X)) + (bnd)) & (~(bnd)))
-#define va_arg(ap, T)   (*(T *)(((ap) += (_bnd (T, _AUPBND))) - (_bnd (T,_ADNBND))))
-#define va_end(ap)      (void) 0
-#define va_start(ap, A) (void) ((ap) = (((char *) &(A)) + (_bnd (A,_AUPBND))))
+#define _bnd(X, bnd)            (((sizeof (X)) + (bnd)) & (~(bnd)))
+#define va_arg(ap, T)           (*(T *)(((ap) += (_bnd (T, _AUPBND))) - (_bnd (T,_ADNBND))))
+#define va_end(ap)              (void) 0
+#define va_start(ap, A)         (void) ((ap) = (((char *) &(A)) + (_bnd (A,_AUPBND))))
 
 #endif /* va_arg */
 
 
-#define STRSTR(s1,s2)    acpi_ut_strstr ((s1), (s2))
-#define STRUPR(s)        acpi_ut_strupr ((s))
-#define STRLEN(s)        acpi_ut_strlen ((s))
-#define STRCPY(d,s)      acpi_ut_strcpy ((d), (s))
-#define STRNCPY(d,s,n)   acpi_ut_strncpy ((d), (s), (n))
-#define STRNCMP(d,s,n)   acpi_ut_strncmp ((d), (s), (n))
-#define STRCMP(d,s)      acpi_ut_strcmp ((d), (s))
-#define STRCAT(d,s)      acpi_ut_strcat ((d), (s))
-#define STRNCAT(d,s,n)   acpi_ut_strncat ((d), (s), (n))
-#define STRTOUL(d,s,n)   acpi_ut_strtoul ((d), (s),(n))
-#define MEMCPY(d,s,n)    acpi_ut_memcpy ((d), (s), (n))
-#define MEMSET(d,v,n)    acpi_ut_memset ((d), (v), (n))
-#define TOUPPER          acpi_ut_to_upper
-#define TOLOWER          acpi_ut_to_lower
+#define ACPI_STRSTR(s1,s2)      acpi_ut_strstr ((s1), (s2))
+#define ACPI_STRUPR(s)          acpi_ut_strupr ((s))
+#define ACPI_STRLEN(s)          acpi_ut_strlen ((s))
+#define ACPI_STRCPY(d,s)        acpi_ut_strcpy ((d), (s))
+#define ACPI_STRNCPY(d,s,n)     acpi_ut_strncpy ((d), (s), (n))
+#define ACPI_STRNCMP(d,s,n)     acpi_ut_strncmp ((d), (s), (n))
+#define ACPI_STRCMP(d,s)        acpi_ut_strcmp ((d), (s))
+#define ACPI_STRCAT(d,s)        acpi_ut_strcat ((d), (s))
+#define ACPI_STRNCAT(d,s,n)     acpi_ut_strncat ((d), (s), (n))
+#define ACPI_STRTOUL(d,s,n)     acpi_ut_strtoul ((d), (s),(n))
+#define ACPI_MEMCPY(d,s,n)      (void) acpi_ut_memcpy ((d), (s), (n))
+#define ACPI_MEMSET(d,v,n)      (void) acpi_ut_memset ((d), (v), (n))
+#define ACPI_TOUPPER            acpi_ut_to_upper
+#define ACPI_TOLOWER            acpi_ut_to_lower
 
 #endif /* ACPI_USE_SYSTEM_CLIBRARY */
 
@@ -256,13 +267,27 @@ typedef char *va_list;
  */
 
 /* Unrecognized compiler, use defaults */
+
 #ifndef ACPI_ASM_MACROS
 
+/*
+ * Calling conventions:
+ *
+ * ACPI_SYSTEM_XFACE        - Interfaces to host OS (handlers, threads)
+ * ACPI_EXTERNAL_XFACE      - External ACPI interfaces
+ * ACPI_INTERNAL_XFACE      - Internal ACPI interfaces
+ * ACPI_INTERNAL_VAR_XFACE  - Internal variable-parameter list interfaces
+ */
+#define ACPI_SYSTEM_XFACE
+#define ACPI_EXTERNAL_XFACE
+#define ACPI_INTERNAL_XFACE
+#define ACPI_INTERNAL_VAR_XFACE
+
 #define ACPI_ASM_MACROS
 #define causeinterrupt(level)
 #define BREAKPOINT3
-#define disable()
-#define enable()
+#define acpi_disable_irqs()
+#define acpi_enable_irqs()
 #define halt()
 #define ACPI_ACQUIRE_GLOBAL_LOCK(Glptr, acq)
 #define ACPI_RELEASE_GLOBAL_LOCK(Glptr, acq)
@@ -283,12 +308,8 @@ typedef char *va_list;
 
 /******************************************************************************
  *
- * Compiler-specific
+ * Compiler-specific information is contained in the compiler-specific
+ * headers.
  *
  *****************************************************************************/
-
-/* this has been moved to compiler-specific headers, which are included from the
-   platform header. */
-
-
 #endif /* __ACENV_H__ */
index bf030dc3e3e8c31b055811c00f28a3dd0837ad47..7065846867b2cdac45ce71f03404c5ba4cd72259 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Name: acgcc.h - GCC specific defines, etc.
- *       $Revision: 14 $
+ *       $Revision: 19 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 #define _IA64
 
 #define COMPILER_DEPENDENT_UINT64   unsigned long
+
+/*
+ * Calling conventions:
+ *
+ * ACPI_SYSTEM_XFACE        - Interfaces to host OS (handlers, threads)
+ * ACPI_EXTERNAL_XFACE      - External ACPI interfaces
+ * ACPI_INTERNAL_XFACE      - Internal ACPI interfaces
+ * ACPI_INTERNAL_VAR_XFACE  - Internal variable-parameter list interfaces
+ */
+#define ACPI_SYSTEM_XFACE
+#define ACPI_EXTERNAL_XFACE
+#define ACPI_INTERNAL_XFACE
+#define ACPI_INTERNAL_VAR_XFACE
+
 /* Single threaded */
+
 #define ACPI_APPLICATION
 
+/* Asm macros */
+
 #define ACPI_ASM_MACROS
 #define causeinterrupt(level)
 #define BREAKPOINT3
-#define disable() __cli()
-#define enable()  __sti()
+#define acpi_disable_irqs() __cli()
+#define acpi_enable_irqs()  __sti()
 
 /*! [Begin] no source code translation */
 
 #else /* DO IA32 */
 
 #define COMPILER_DEPENDENT_UINT64   unsigned long long
+
+/*
+ * Calling conventions:
+ *
+ * ACPI_SYSTEM_XFACE        - Interfaces to host OS (handlers, threads)
+ * ACPI_EXTERNAL_XFACE      - External ACPI interfaces
+ * ACPI_INTERNAL_XFACE      - Internal ACPI interfaces
+ * ACPI_INTERNAL_VAR_XFACE  - Internal variable-parameter list interfaces
+ */
+#define ACPI_SYSTEM_XFACE
+#define ACPI_EXTERNAL_XFACE
+#define ACPI_INTERNAL_XFACE
+#define ACPI_INTERNAL_VAR_XFACE
+
+/* Asm macros */
+
 #define ACPI_ASM_MACROS
 #define causeinterrupt(level)
 #define BREAKPOINT3
-#define disable() __cli()
-#define enable()  __sti()
+#define acpi_disable_irqs() __cli()
+#define acpi_enable_irqs()  __sti()
 #define halt()    __asm__ __volatile__ ("sti; hlt":::"memory")
 
 /*! [Begin] no source code translation
 
 #define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \
        asm("shrl   $1,%2;"             \
-           "rcrl   $1,%3;"             \
-           :"=r"(n_hi), "=r"(n_lo)     \
-           :"0"(n_hi), "1"(n_lo))
+               "rcrl   $1,%3;"             \
+               :"=r"(n_hi), "=r"(n_lo)     \
+               :"0"(n_hi), "1"(n_lo))
 
 /*! [End] no source code translation !*/
 
index 99653bb7924a3d7c7aab18b196379dba6b2d26d8..d92d6bcd1224246ee9aef4fc91c6b34800de814f 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Name: aclinux.h - OS specific defines, etc.
- *       $Revision: 14 $
+ *       $Revision: 15 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
index 0714c087172adf7cb040934c0602ec8c336b3ccd..d0bbc7655a46e95b304e00deeca0e7cf8e60f997 100644 (file)
@@ -1,11 +1,10 @@
 #
 # Makefile for all Linux ACPI interpreter subdirectories
-# EXCEPT for the ospm directory
 #
 
 O_TARGET := $(notdir $(CURDIR)).o
 
-obj-$(CONFIG_ACPI) := $(patsubst %.c,%.o,$(wildcard *.c))
+obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
 
index 73f37a480b0ecf576730ee73434eac25f954f835..2674f02f28db32423fec7411948ee3f70fb58f73 100644 (file)
@@ -1,12 +1,12 @@
 /*******************************************************************************
  *
  * Module Name: nsaccess - Top-level functions for accessing ACPI namespace
- *              $Revision: 135 $
+ *              $Revision: 152 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -32,7 +32,7 @@
 
 
 #define _COMPONENT          ACPI_NAMESPACE
-        MODULE_NAME         ("nsaccess")
+        ACPI_MODULE_NAME    ("nsaccess")
 
 
 /*******************************************************************************
 acpi_status
 acpi_ns_root_initialize (void)
 {
-       acpi_status             status = AE_OK;
-       const predefined_names  *init_val = NULL;
-       acpi_namespace_node     *new_node;
-       acpi_operand_object     *obj_desc;
+       acpi_status                 status;
+       const acpi_predefined_names *init_val = NULL;
+       acpi_namespace_node         *new_node;
+       acpi_operand_object         *obj_desc;
 
 
-       FUNCTION_TRACE ("Ns_root_initialize");
+       ACPI_FUNCTION_TRACE ("Ns_root_initialize");
 
 
-       acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
 
        /*
         * The global root ptr is initially NULL, so a non-NULL value indicates
@@ -72,22 +75,20 @@ acpi_ns_root_initialize (void)
                goto unlock_and_exit;
        }
 
-
        /*
         * Tell the rest of the subsystem that the root is initialized
         * (This is OK because the namespace is locked)
         */
        acpi_gbl_root_node = &acpi_gbl_root_node_struct;
 
-
        /* Enter the pre-defined names in the name table */
 
-       ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Entering predefined entries into namespace\n"));
+       ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+               "Entering predefined entries into namespace\n"));
 
        for (init_val = acpi_gbl_pre_defined_names; init_val->name; init_val++) {
                status = acpi_ns_lookup (NULL, init_val->name, init_val->type,
-                                IMODE_LOAD_PASS2, NS_NO_UPSEARCH,
-                                NULL, &new_node);
+                                 ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, NULL, &new_node);
 
                if (ACPI_FAILURE (status) || (!new_node)) /* Must be on same line for code converter */ {
                        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
@@ -116,13 +117,11 @@ acpi_ns_root_initialize (void)
                         * internal representation. Only types actually
                         * used for initial values are implemented here.
                         */
-
                        switch (init_val->type) {
-
                        case ACPI_TYPE_INTEGER:
 
                                obj_desc->integer.value =
-                                               (acpi_integer) STRTOUL (init_val->val, NULL, 10);
+                                               (acpi_integer) ACPI_STRTOUL (init_val->val, NULL, 10);
                                break;
 
 
@@ -131,7 +130,7 @@ acpi_ns_root_initialize (void)
                                /*
                                 * Build an object around the static string
                                 */
-                               obj_desc->string.length = STRLEN (init_val->val);
+                               obj_desc->string.length = ACPI_STRLEN (init_val->val);
                                obj_desc->string.pointer = init_val->val;
                                obj_desc->common.flags |= AOPOBJ_STATIC_POINTER;
                                break;
@@ -140,16 +139,15 @@ acpi_ns_root_initialize (void)
                        case ACPI_TYPE_MUTEX:
 
                                obj_desc->mutex.sync_level =
-                                                (u16) STRTOUL (init_val->val, NULL, 10);
+                                                (u16) ACPI_STRTOUL (init_val->val, NULL, 10);
 
-                               if (STRCMP (init_val->name, "_GL_") == 0) {
+                               if (ACPI_STRCMP (init_val->name, "_GL_") == 0) {
                                        /*
                                         * Create a counting semaphore for the
                                         * global lock
                                         */
                                        status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT,
                                                         1, &obj_desc->mutex.semaphore);
-
                                        if (ACPI_FAILURE (status)) {
                                                goto unlock_and_exit;
                                        }
@@ -160,13 +158,11 @@ acpi_ns_root_initialize (void)
                                         */
                                        acpi_gbl_global_lock_semaphore = obj_desc->mutex.semaphore;
                                }
-
                                else {
                                        /* Create a mutex */
 
                                        status = acpi_os_create_semaphore (1, 1,
                                                           &obj_desc->mutex.semaphore);
-
                                        if (ACPI_FAILURE (status)) {
                                                goto unlock_and_exit;
                                        }
@@ -175,7 +171,7 @@ acpi_ns_root_initialize (void)
 
 
                        default:
-                               REPORT_ERROR (("Unsupported initial type value %X\n",
+                               ACPI_REPORT_ERROR (("Unsupported initial type value %X\n",
                                        init_val->type));
                                acpi_ut_remove_reference (obj_desc);
                                obj_desc = NULL;
@@ -194,7 +190,7 @@ acpi_ns_root_initialize (void)
 
 
 unlock_and_exit:
-       acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+       (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
        return_ACPI_STATUS (status);
 }
 
@@ -226,8 +222,8 @@ acpi_status
 acpi_ns_lookup (
        acpi_generic_state      *scope_info,
        NATIVE_CHAR             *pathname,
-       acpi_object_type8       type,
-       operating_mode          interpreter_mode,
+       acpi_object_type        type,
+       acpi_interpreter_mode   interpreter_mode,
        u32                     flags,
        acpi_walk_state         *walk_state,
        acpi_namespace_node     **return_node)
@@ -235,33 +231,26 @@ acpi_ns_lookup (
        acpi_status             status;
        acpi_namespace_node     *prefix_node;
        acpi_namespace_node     *current_node = NULL;
-       acpi_namespace_node     *scope_to_push = NULL;
        acpi_namespace_node     *this_node = NULL;
        u32                     num_segments;
        acpi_name               simple_name;
-       u8                      null_name_path = FALSE;
-       acpi_object_type8       type_to_check_for;
-       acpi_object_type8       this_search_type;
-       u32                     local_flags = flags & ~NS_ERROR_IF_FOUND;
+       acpi_object_type        type_to_check_for;
+       acpi_object_type        this_search_type;
+       u32                     local_flags = flags & ~ACPI_NS_ERROR_IF_FOUND;
 
-       DEBUG_EXEC              (u32 i;)
 
-
-       FUNCTION_TRACE ("Ns_lookup");
+       ACPI_FUNCTION_TRACE ("Ns_lookup");
 
 
        if (!return_node) {
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
-
        acpi_gbl_ns_lookup_count++;
-
-       *return_node = ENTRY_NOT_FOUND;
-
+       *return_node = ACPI_ENTRY_NOT_FOUND;
 
        if (!acpi_gbl_root_node) {
-               return (AE_NO_NAMESPACE);
+               return_ACPI_STATUS (AE_NO_NAMESPACE);
        }
 
        /*
@@ -270,7 +259,8 @@ acpi_ns_lookup (
         */
        if ((!scope_info) ||
                (!scope_info->scope.node)) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Null scope prefix, using root node (%p)\n",
+               ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+                       "Null scope prefix, using root node (%p)\n",
                        acpi_gbl_root_node));
 
                prefix_node = acpi_gbl_root_node;
@@ -279,7 +269,6 @@ acpi_ns_lookup (
                prefix_node = scope_info->scope.node;
        }
 
-
        /*
         * This check is explicitly split to relax the Type_to_check_for
         * conditions for Bank_field_defn. Originally, both Bank_field_defn and
@@ -292,210 +281,200 @@ acpi_ns_lookup (
 
                type_to_check_for = ACPI_TYPE_REGION;
        }
-
        else if (INTERNAL_TYPE_BANK_FIELD_DEFN == type) {
                /* Bank_field_defn defines data fields in a Field Object */
 
                type_to_check_for = ACPI_TYPE_ANY;
        }
-
        else {
                type_to_check_for = type;
        }
 
-
-       /* TBD: [Restructure] - Move the pathname stuff into a new procedure */
-
-       /* Examine the name pointer */
-
+       /*
+        * Begin examination of the actual pathname
+        */
        if (!pathname) {
-               /*  8-12-98 ASL Grammar Update supports null Name_path  */
+               /* A Null Name_path is allowed and refers to the root */
 
-               null_name_path = TRUE;
                num_segments = 0;
-               this_node = acpi_gbl_root_node;
+               this_node    = acpi_gbl_root_node;
 
                ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
-                       "Null Pathname (Zero segments),  Flags=%x\n", flags));
+                       "Null Pathname (Zero segments), Flags=%x\n", flags));
        }
-
        else {
                /*
-                * Valid name pointer (Internal name format)
+                * Name pointer is valid (and must be in internal name format)
                 *
-                * Check for prefixes.  As represented in the AML stream, a
-                * Pathname consists of an optional scope prefix followed by
-                * a segment part.
+                * Check for scope prefixes:
                 *
-                * If present, the scope prefix is either a Root_prefix (in
-                * which case the name is fully qualified), or zero or more
-                * Parent_prefixes (in which case the name's scope is relative
-                * to the current scope).
+                * As represented in the AML stream, a namepath consists of an
+                * optional scope prefix followed by a name segment part.
                 *
-                * The segment part consists of either:
-                *  - A single 4-byte name segment, or
-                *  - A Dual_name_prefix followed by two 4-byte name segments, or
-                *  - A Multi_name_prefix_op, followed by a byte indicating the
-                *    number of segments and the segments themselves.
+                * If present, the scope prefix is either a Root Prefix (in
+                * which case the name is fully qualified), or one or more
+                * Parent Prefixes (in which case the name's scope is relative
+                * to the current scope).
                 */
                if (*pathname == AML_ROOT_PREFIX) {
-                       /* Pathname is fully qualified, look in root name table */
+                       /* Pathname is fully qualified, start from the root */
 
-                       current_node = acpi_gbl_root_node;
+                       this_node = acpi_gbl_root_node;
 
-                       /* point to segment part */
+                       /* Point to name segment part */
 
                        pathname++;
 
                        ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Searching from root [%p]\n",
-                               current_node));
-
-                       /* Direct reference to root, "\" */
-
-                       if (!(*pathname)) {
-                               this_node = acpi_gbl_root_node;
-                               goto check_for_new_scope_and_exit;
-                       }
+                               this_node));
                }
-
                else {
                        /* Pathname is relative to current scope, start there */
 
-                       current_node = prefix_node;
-
-                       ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Searching relative to pfx scope [%p]\n",
+                       ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+                               "Searching relative to pfx scope [%p]\n",
                                prefix_node));
 
                        /*
-                        * Handle up-prefix (carat).  More than one prefix
-                        * is supported
+                        * Handle multiple Parent Prefixes (carat) by just getting
+                        * the parent node for each prefix instance.
                         */
+                       this_node = prefix_node;
                        while (*pathname == AML_PARENT_PREFIX) {
-                               /* Point to segment part or next Parent_prefix */
-
+                               /*
+                                * Point past this prefix to the name segment
+                                * part or the next Parent Prefix
+                                */
                                pathname++;
 
-                               /*  Backup to the parent's scope  */
+                               /* Backup to the parent node */
 
-                               this_node = acpi_ns_get_parent_object (current_node);
+                               this_node = acpi_ns_get_parent_node (this_node);
                                if (!this_node) {
                                        /* Current scope has no parent scope */
 
-                                       REPORT_ERROR (
-                                               ("Too many parent prefixes (^) - reached root\n"));
+                                       ACPI_REPORT_ERROR (
+                                               ("ACPI path has too many parent prefixes (^) - reached beyond root node\n"));
                                        return_ACPI_STATUS (AE_NOT_FOUND);
                                }
-
-                               current_node = this_node;
                        }
                }
 
-
                /*
-                * Examine the name prefix opcode, if any,
-                * to determine the number of segments
+                * Determine the number of ACPI name segments in this pathname.
+                *
+                * The segment part consists of either:
+                *  - A Null name segment (0)
+                *  - A Dual_name_prefix followed by two 4-byte name segments
+                *  - A Multi_name_prefix followed by a byte indicating the
+                *      number of segments and the segments themselves.
+                *  - A single 4-byte name segment
+                *
+                * Examine the name prefix opcode, if any, to determine the number of
+                * segments.
                 */
-               if (*pathname == AML_DUAL_NAME_PREFIX) {
-                       num_segments = 2;
+               switch (*pathname) {
+               case 0:
+                       /*
+                        * Null name after a root or parent prefixes. We already
+                        * have the correct target node and there are no name segments.
+                        */
+                       num_segments = 0;
 
-                       /* point to first segment */
+                       ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+                               "Prefix-only Pathname (Zero name segments), Flags=%x\n", flags));
+                       break;
+
+               case AML_DUAL_NAME_PREFIX:
 
+                       /* Two segments, point to first name segment */
+
+                       num_segments = 2;
                        pathname++;
 
                        ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
                                "Dual Pathname (2 segments, Flags=%X)\n", flags));
-               }
+                       break;
 
-               else if (*pathname == AML_MULTI_NAME_PREFIX_OP) {
-                       num_segments = (u32)* (u8 *) ++pathname;
+               case AML_MULTI_NAME_PREFIX_OP:
 
-                       /* point to first segment */
+                       /* Extract segment count, point to first name segment */
 
+                       pathname++;
+                       num_segments = (u32) (u8) *pathname;
                        pathname++;
 
                        ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
                                "Multi Pathname (%d Segments, Flags=%X) \n",
                                num_segments, flags));
-               }
+                       break;
 
-               else {
+               default:
                        /*
-                        * No Dual or Multi prefix, hence there is only one
-                        * segment and Pathname is already pointing to it.
+                        * Not a Null name, no Dual or Multi prefix, hence there is
+                        * only one name segment and Pathname is already pointing to it.
                         */
                        num_segments = 1;
 
                        ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
                                "Simple Pathname (1 segment, Flags=%X)\n", flags));
+                       break;
                }
 
-#ifdef ACPI_DEBUG
-
-               /* TBD: [Restructure] Make this a procedure */
-
-               /* Debug only: print the entire name that we are about to lookup */
-
-               ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "["));
-
-               for (i = 0; i < num_segments; i++) {
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_NAMES, "%4.4s/", (char*)&pathname[i * 4]));
-               }
-               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_NAMES, "]\n"));
-#endif
+               ACPI_DEBUG_EXEC (acpi_ns_print_pathname (num_segments, pathname));
        }
 
-
        /*
-        * Search namespace for each segment of the name.
-        * Loop through and verify/add each name segment.
+        * Search namespace for each segment of the name.  Loop through and
+        * verify/add each name segment.
         */
-       while (num_segments-- && current_node) {
+       current_node = this_node;
+       while (num_segments && current_node) {
                /*
                 * Search for the current name segment under the current
-                * named object.  The Type is significant only at the last (topmost)
-                * level.  (We don't care about the types along the path, only
+                * named object.  The Type is significant only at the last name
+                * segment.  (We don't care about the types along the path, only
                 * the type of the final target object.)
                 */
                this_search_type = ACPI_TYPE_ANY;
+               num_segments--;
                if (!num_segments) {
                        this_search_type = type;
                        local_flags = flags;
                }
 
-               /* Pluck one ACPI name from the front of the pathname */
+               /* Extract one ACPI name from the front of the pathname */
 
-               MOVE_UNALIGNED32_TO_32 (&simple_name, pathname);
+               ACPI_MOVE_UNALIGNED32_TO_32 (&simple_name, pathname);
 
                /* Try to find the ACPI name */
 
-               status = acpi_ns_search_and_enter (simple_name, walk_state,
-                                  current_node, interpreter_mode,
-                                  this_search_type, local_flags,
-                                  &this_node);
-
+               status = acpi_ns_search_and_enter (simple_name, walk_state, current_node,
+                                 interpreter_mode, this_search_type, local_flags, &this_node);
                if (ACPI_FAILURE (status)) {
                        if (status == AE_NOT_FOUND) {
-                               /* Name not found in ACPI namespace  */
+                               /* Name not found in ACPI namespace */
 
                                ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
-                                       "Name [%4.4s] not found in scope %p\n",
-                                       (char*)&simple_name, current_node));
+                                       "Name [%4.4s] not found in scope [%4.4s] %p\n",
+                                       (char *) &simple_name, (char *) &current_node->name, current_node));
                        }
 
                        return_ACPI_STATUS (status);
                }
 
-
                /*
+                * Sanity typecheck of the target object:
+                *
                 * If 1) This is the last segment (Num_segments == 0)
-                *    2) and looking for a specific type
+                *    2) And we are looking for a specific type
                 *       (Not checking for TYPE_ANY)
                 *    3) Which is not an alias
-                *    4) which is not a local type (TYPE_DEF_ANY)
-                *    5) which is not a local type (TYPE_SCOPE)
-                *    6) which is not a local type (TYPE_INDEX_FIELD_DEFN)
-                *    7) and type of object is known (not TYPE_ANY)
-                *    8) and object does not match request
+                *    4) Which is not a local type (TYPE_DEF_ANY)
+                *    5) Which is not a local type (TYPE_SCOPE)
+                *    6) Which is not a local type (TYPE_INDEX_FIELD_DEFN)
+                *    7) And the type of target object is known (not TYPE_ANY)
+                *    8) And target object does not match what we are looking for
                 *
                 * Then we have a type mismatch.  Just warn and ignore it.
                 */
@@ -509,9 +488,9 @@ acpi_ns_lookup (
                        (this_node->type    != type_to_check_for)) {
                        /* Complain about a type mismatch */
 
-                       REPORT_WARNING (
+                       ACPI_REPORT_WARNING (
                                ("Ns_lookup: %4.4s, type %X, checking for type %X\n",
-                               (char*)&simple_name, this_node->type, type_to_check_for));
+                               (char *) &simple_name, this_node->type, type_to_check_for));
                }
 
                /*
@@ -519,57 +498,32 @@ acpi_ns_lookup (
                 * specific type, but the type of found object is known, use that type
                 * to see if it opens a scope.
                 */
-               if ((0 == num_segments) && (ACPI_TYPE_ANY == type)) {
+               if ((num_segments == 0) && (type == ACPI_TYPE_ANY)) {
                        type = this_node->type;
                }
 
-               if ((num_segments || acpi_ns_opens_scope (type)) &&
-                       (this_node->child == NULL)) {
-                       /*
-                        * More segments or the type implies enclosed scope,
-                        * and the next scope has not been allocated.
-                        */
-                       ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Load mode=%X  This_node=%p\n",
-                               interpreter_mode, this_node));
-               }
-
-               current_node = this_node;
-
-               /* point to next name segment */
+               /* Point to next name segment and make this node current */
 
                pathname += ACPI_NAME_SIZE;
+               current_node = this_node;
        }
 
-
        /*
         * Always check if we need to open a new scope
         */
-check_for_new_scope_and_exit:
-
-       if (!(flags & NS_DONT_OPEN_SCOPE) && (walk_state)) {
+       if (!(flags & ACPI_NS_DONT_OPEN_SCOPE) && (walk_state)) {
                /*
-                * If entry is a type which opens a scope,
-                * push the new scope on the scope stack.
+                * If entry is a type which opens a scope, push the new scope on the
+                * scope stack.
                 */
                if (acpi_ns_opens_scope (type_to_check_for)) {
-                       /*  8-12-98 ASL Grammar Update supports null Name_path  */
-
-                       if (null_name_path) {
-                               /* TBD: [Investigate] - is this the correct thing to do? */
-
-                               scope_to_push = NULL;
-                       }
-                       else {
-                               scope_to_push = this_node;
-                       }
-
-                       status = acpi_ds_scope_stack_push (scope_to_push, type,
-                                          walk_state);
+                       status = acpi_ds_scope_stack_push (this_node, type, walk_state);
                        if (ACPI_FAILURE (status)) {
                                return_ACPI_STATUS (status);
                        }
 
-                       ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Set global scope to %p\n", scope_to_push));
+                       ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+                               "Setting global scope to %p\n", this_node));
                }
        }
 
index 1d88d4e057cf670c550515df0f9884980b61ac2c..f719ccc785ed99badd61f616c782e08e0423bcfc 100644 (file)
@@ -1,12 +1,12 @@
 /*******************************************************************************
  *
  * Module Name: nsalloc - Namespace allocation and deletion utilities
- *              $Revision: 60 $
+ *              $Revision: 70 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@
 
 
 #define _COMPONENT          ACPI_NAMESPACE
-        MODULE_NAME         ("nsalloc")
+        ACPI_MODULE_NAME    ("nsalloc")
 
 
 /*******************************************************************************
@@ -52,7 +52,7 @@ acpi_ns_create_node (
        acpi_namespace_node     *node;
 
 
-       FUNCTION_TRACE ("Ns_create_node");
+       ACPI_FUNCTION_TRACE ("Ns_create_node");
 
 
        node = ACPI_MEM_CALLOCATE (sizeof (acpi_namespace_node));
@@ -62,9 +62,9 @@ acpi_ns_create_node (
 
        ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_allocated++);
 
-       node->data_type      = ACPI_DESC_TYPE_NAMED;
        node->name           = name;
        node->reference_count = 1;
+       ACPI_SET_DESCRIPTOR_TYPE (node, ACPI_DESC_TYPE_NAMED);
 
        return_PTR (node);
 }
@@ -91,10 +91,10 @@ acpi_ns_delete_node (
        acpi_namespace_node     *next_node;
 
 
-       FUNCTION_TRACE_PTR ("Ns_delete_node", node);
+       ACPI_FUNCTION_TRACE_PTR ("Ns_delete_node", node);
 
 
-       parent_node = acpi_ns_get_parent_object (node);
+       parent_node = acpi_ns_get_parent_node (node);
 
        prev_node = NULL;
        next_node = parent_node->child;
@@ -118,12 +118,9 @@ acpi_ns_delete_node (
        ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_freed++);
 
        /*
-        * Detach an object if there is one
+        * Detach an object if there is one then delete the node
         */
-       if (node->object) {
-               acpi_ns_detach_object (node);
-       }
-
+       acpi_ns_detach_object (node);
        ACPI_MEM_FREE (node);
        return_VOID;
 }
@@ -140,7 +137,11 @@ acpi_ns_delete_node (
  *
  * RETURN:      None
  *
- * DESCRIPTION: Initialize a new entry within a namespace table.
+ * DESCRIPTION: Initialize a new namespace node and install it amongst
+ *              its peers.
+ *
+ *              Note: Current namespace lookup is linear search, so the nodes
+ *              are not linked in any particular order.
  *
  ******************************************************************************/
 
@@ -149,13 +150,13 @@ acpi_ns_install_node (
        acpi_walk_state         *walk_state,
        acpi_namespace_node     *parent_node,   /* Parent */
        acpi_namespace_node     *node,          /* New Child*/
-       acpi_object_type8       type)
+       acpi_object_type        type)
 {
        u16                     owner_id = TABLE_ID_DSDT;
        acpi_namespace_node     *child_node;
 
 
-       FUNCTION_TRACE ("Ns_install_node");
+       ACPI_FUNCTION_TRACE ("Ns_install_node");
 
 
        /*
@@ -167,16 +168,12 @@ acpi_ns_install_node (
                owner_id = walk_state->owner_id;
        }
 
-
-       /* link the new entry into the parent and existing children */
-
-       /* TBD: Could be first, last, or alphabetic */
+       /* Link the new entry into the parent and existing children */
 
        child_node = parent_node->child;
        if (!child_node) {
                parent_node->child = node;
        }
-
        else {
                while (!(child_node->flags & ANOBJ_END_OF_PEER_LIST)) {
                        child_node = child_node->peer;
@@ -210,7 +207,7 @@ acpi_ns_install_node (
                 * real definition is found later.
                 */
                ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "[%4.4s] is a forward reference\n",
-                       (char*)&node->name));
+                       (char *) &node->name));
        }
 
        /*
@@ -235,13 +232,13 @@ acpi_ns_install_node (
        }
 
        ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%4.4s added to %p at %p\n",
-               (char*)&node->name, parent_node, node));
+               (char *) &node->name, parent_node, node));
 
        /*
         * Increment the reference count(s) of all parents up to
         * the root!
         */
-       while ((node = acpi_ns_get_parent_object (node)) != NULL) {
+       while ((node = acpi_ns_get_parent_node (node)) != NULL) {
                node->reference_count++;
        }
 
@@ -257,8 +254,8 @@ acpi_ns_install_node (
  *
  * RETURN:      None.
  *
- * DESCRIPTION: Delete all children of the parent object. Deletes a
- *              "scope".
+ * DESCRIPTION: Delete all children of the parent object. In other words,
+ *              deletes a "scope".
  *
  ******************************************************************************/
 
@@ -271,7 +268,7 @@ acpi_ns_delete_children (
        u8                      flags;
 
 
-       FUNCTION_TRACE_PTR ("Ns_delete_children", parent_node);
+       ACPI_FUNCTION_TRACE_PTR ("Ns_delete_children", parent_node);
 
 
        if (!parent_node) {
@@ -338,7 +335,7 @@ acpi_ns_delete_children (
  * RETURN:      None.
  *
  * DESCRIPTION: Delete a subtree of the namespace.  This includes all objects
- *              stored within the subtree.  Scope tables are deleted also
+ *              stored within the subtree.
  *
  ******************************************************************************/
 
@@ -350,7 +347,7 @@ acpi_ns_delete_namespace_subtree (
        u32                     level = 1;
 
 
-       FUNCTION_TRACE ("Ns_delete_namespace_subtree");
+       ACPI_FUNCTION_TRACE ("Ns_delete_namespace_subtree");
 
 
        if (!parent_node) {
@@ -383,7 +380,6 @@ acpi_ns_delete_namespace_subtree (
                                child_node    = 0;
                        }
                }
-
                else {
                        /*
                         * No more children of this parent node.
@@ -403,7 +399,7 @@ acpi_ns_delete_namespace_subtree (
 
                        /* Move up the tree to the grandparent */
 
-                       parent_node = acpi_ns_get_parent_object (parent_node);
+                       parent_node = acpi_ns_get_parent_node (parent_node);
                }
        }
 
@@ -430,34 +426,37 @@ static void
 acpi_ns_remove_reference (
        acpi_namespace_node     *node)
 {
-       acpi_namespace_node     *next_node;
+       acpi_namespace_node     *parent_node;
+       acpi_namespace_node     *this_node;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        /*
         * Decrement the reference count(s) of this node and all
         * nodes up to the root,  Delete anything with zero remaining references.
         */
-       next_node = node;
-       while (next_node) {
-               /* Decrement the reference count on this node*/
+       this_node = node;
+       while (this_node) {
+               /* Prepare to move up to parent */
 
-               next_node->reference_count--;
+               parent_node = acpi_ns_get_parent_node (this_node);
+
+               /* Decrement the reference count on this node */
+
+               this_node->reference_count--;
 
                /* Delete the node if no more references */
 
-               if (!next_node->reference_count) {
+               if (!this_node->reference_count) {
                        /* Delete all children and delete the node */
 
-                       acpi_ns_delete_children (next_node);
-                       acpi_ns_delete_node (next_node);
+                       acpi_ns_delete_children (this_node);
+                       acpi_ns_delete_node (this_node);
                }
 
-               /* Move up to parent */
-
-               next_node = acpi_ns_get_parent_object (next_node);
+               this_node = parent_node;
        }
 }
 
@@ -481,60 +480,66 @@ acpi_ns_delete_namespace_by_owner (
        u16                     owner_id)
 {
        acpi_namespace_node     *child_node;
+       acpi_namespace_node     *deletion_node;
        u32                     level;
        acpi_namespace_node     *parent_node;
 
 
-       FUNCTION_TRACE ("Ns_delete_namespace_by_owner");
+       ACPI_FUNCTION_TRACE_U32 ("Ns_delete_namespace_by_owner", owner_id);
 
 
-       parent_node = acpi_gbl_root_node;
-       child_node  = 0;
-       level       = 1;
+       parent_node   = acpi_gbl_root_node;
+       child_node    = NULL;
+       deletion_node = NULL;
+       level         = 1;
 
        /*
         * Traverse the tree of nodes until we bubble back up
         * to where we started.
         */
        while (level > 0) {
-               /* Get the next node in this scope (NULL if none) */
+               /*
+                * Get the next child of this parent node. When Child_node is NULL,
+                * the first child of the parent is returned
+                */
+               child_node = acpi_ns_get_next_node (ACPI_TYPE_ANY, parent_node, child_node);
+
+               if (deletion_node) {
+                       acpi_ns_remove_reference (deletion_node);
+                       deletion_node = NULL;
+               }
 
-               child_node = acpi_ns_get_next_node (ACPI_TYPE_ANY, parent_node,
-                                child_node);
                if (child_node) {
                        if (child_node->owner_id == owner_id) {
-                               /* Found a child node - detach any attached object */
+                               /* Found a matching child node - detach any attached object */
 
                                acpi_ns_detach_object (child_node);
                        }
 
                        /* Check if this node has any children */
 
-                       if (acpi_ns_get_next_node (ACPI_TYPE_ANY, child_node, 0)) {
+                       if (acpi_ns_get_next_node (ACPI_TYPE_ANY, child_node, NULL)) {
                                /*
                                 * There is at least one child of this node,
                                 * visit the node
                                 */
                                level++;
                                parent_node   = child_node;
-                               child_node    = 0;
+                               child_node    = NULL;
                        }
-
                        else if (child_node->owner_id == owner_id) {
-                               acpi_ns_remove_reference (child_node);
+                               deletion_node = child_node;
                        }
                }
-
                else {
                        /*
                         * No more children of this parent node.
                         * Move up to the grandparent.
                         */
                        level--;
-
                        if (level != 0) {
                                if (parent_node->owner_id == owner_id) {
-                                       acpi_ns_remove_reference (parent_node);
+                                       deletion_node = parent_node;
                                }
                        }
 
@@ -544,7 +549,7 @@ acpi_ns_delete_namespace_by_owner (
 
                        /* Move up the tree to the grandparent */
 
-                       parent_node = acpi_ns_get_parent_object (parent_node);
+                       parent_node = acpi_ns_get_parent_node (parent_node);
                }
        }
 
index b356b667c5354ba2cf6f1f567c571343a4762c95..b8f3f0487a42e6ce6e404486d0735fca1607a1a8 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: nsdump - table dumping routines for debug
- *              $Revision: 105 $
+ *              $Revision: 127 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 
 
 #define _COMPONENT          ACPI_NAMESPACE
-        MODULE_NAME         ("nsdump")
-
+        ACPI_MODULE_NAME    ("nsdump")
 
 #if defined(ACPI_DEBUG) || defined(ENABLE_DEBUGGER)
 
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ns_print_pathname
+ *
+ * PARAMETERS:  Num_segment         - Number of ACPI name segments
+ *              Pathname            - The compressed (internal) path
+ *
+ * DESCRIPTION: Print an object's full namespace pathname
+ *
+ ******************************************************************************/
+
+void
+acpi_ns_print_pathname (
+       u32                     num_segments,
+       char                    *pathname)
+{
+       ACPI_FUNCTION_NAME ("Acpi_ns_print_pathname");
+
+
+       if (!(acpi_dbg_level & ACPI_LV_NAMES) || !(acpi_dbg_layer & ACPI_NAMESPACE)) {
+               return;
+       }
+
+               /* Print the entire name */
+
+       ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "["));
+
+       while (num_segments) {
+               acpi_os_printf ("%4.4s", pathname);
+               pathname += ACPI_NAME_SIZE;
+
+               num_segments--;
+               if (num_segments) {
+                       acpi_os_printf (".");
+               }
+       }
+
+       acpi_os_printf ("]\n");
+}
+
+
 /*******************************************************************************
  *
  * FUNCTION:    Acpi_ns_dump_pathname
@@ -58,11 +99,11 @@ acpi_ns_dump_pathname (
        u32                     level,
        u32                     component)
 {
-       NATIVE_CHAR             *buffer;
-       u32                     length;
+       acpi_buffer             buffer;
+       acpi_status             status;
 
 
-       FUNCTION_TRACE ("Ns_dump_pathname");
+       ACPI_FUNCTION_TRACE ("Ns_dump_pathname");
 
 
        /* Do this only if the requested debug level and component are enabled */
@@ -71,21 +112,17 @@ acpi_ns_dump_pathname (
                return_ACPI_STATUS (AE_OK);
        }
 
-       buffer = ACPI_MEM_ALLOCATE (PATHNAME_MAX);
-       if (!buffer) {
-               return_ACPI_STATUS (AE_NO_MEMORY);
-       }
-
        /* Convert handle to a full pathname and print it (with supplied message) */
 
-       length = PATHNAME_MAX;
-       if (ACPI_SUCCESS (acpi_ns_handle_to_pathname (handle, &length, buffer))) {
-               acpi_os_printf ("%s %s (%p)\n", msg, buffer, handle);
-       }
+       buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
 
-       ACPI_MEM_FREE (buffer);
+       status = acpi_ns_handle_to_pathname (handle, &buffer);
+       if (ACPI_SUCCESS (status)) {
+               acpi_os_printf ("%s %s (Node %p)\n", msg, buffer.pointer, handle);
+               ACPI_MEM_FREE (buffer.pointer);
+       }
 
-       return_ACPI_STATUS (AE_OK);
+       return_ACPI_STATUS (status);
 }
 
 
@@ -112,16 +149,17 @@ acpi_ns_dump_one_object (
        acpi_walk_info          *info = (acpi_walk_info *) context;
        acpi_namespace_node     *this_node;
        acpi_operand_object     *obj_desc = NULL;
-       acpi_object_type8       obj_type;
-       acpi_object_type8       type;
+       acpi_object_type        obj_type;
+       acpi_object_type        type;
        u32                     bytes_to_dump;
        u32                     downstream_sibling_mask = 0;
        u32                     level_tmp;
        u32                     which_bit;
        u32                     i;
+       u32                     dbg_level;
 
 
-       PROC_NAME ("Ns_dump_one_object");
+       ACPI_FUNCTION_NAME ("Ns_dump_one_object");
 
 
        this_node = acpi_ns_map_handle_to_node (obj_handle);
@@ -147,68 +185,63 @@ acpi_ns_dump_one_object (
                return (AE_OK);
        }
 
-
        /* Indent the object according to the level */
 
        while (level_tmp--) {
-
                /* Print appropriate characters to form tree structure */
 
                if (level_tmp) {
                        if (downstream_sibling_mask & which_bit) {
-                               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "|"));
+                               acpi_os_printf ("|");
                        }
-
                        else {
-                               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " "));
+                               acpi_os_printf (" ");
                        }
 
                        which_bit <<= 1;
                }
-
                else {
                        if (acpi_ns_exist_downstream_sibling (this_node + 1)) {
                                downstream_sibling_mask |= (1 << (level - 1));
-                               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "+"));
+                               acpi_os_printf ("+");
                        }
-
                        else {
                                downstream_sibling_mask &= ACPI_UINT32_MAX ^ (1 << (level - 1));
-                               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "+"));
+                               acpi_os_printf ("+");
                        }
 
                        if (this_node->child == NULL) {
-                               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "-"));
+                               acpi_os_printf ("-");
                        }
-
                        else if (acpi_ns_exist_downstream_sibling (this_node->child)) {
-                               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "+"));
+                               acpi_os_printf ("+");
                        }
-
                        else {
-                               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "-"));
+                               acpi_os_printf ("-");
                        }
                }
        }
 
-
        /* Check the integrity of our data */
 
        if (type > INTERNAL_TYPE_MAX) {
-               type = INTERNAL_TYPE_DEF_ANY;                                /* prints as *ERROR* */
+               type = INTERNAL_TYPE_DEF_ANY;  /* prints as *ERROR* */
        }
 
        if (!acpi_ut_valid_acpi_name (this_node->name)) {
-               REPORT_WARNING (("Invalid ACPI Name %08X\n", this_node->name));
+               ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n", this_node->name));
        }
 
        /*
         * Now we can print out the pertinent information
         */
-       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " %4.4s %-12s %p",
-                       (char*)&this_node->name, acpi_ut_get_type_name (type), this_node));
+       acpi_os_printf (" %4.4s %-12s %p",
+                       (char *) &this_node->name, acpi_ut_get_type_name (type), this_node);
 
-       obj_desc = this_node->object;
+       dbg_level = acpi_dbg_level;
+       acpi_dbg_level = 0;
+       obj_desc = acpi_ns_get_attached_object (this_node);
+       acpi_dbg_level = dbg_level;
 
        switch (info->display_type) {
        case ACPI_DISPLAY_SUMMARY:
@@ -216,110 +249,109 @@ acpi_ns_dump_one_object (
                if (!obj_desc) {
                        /* No attached object, we are done */
 
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "\n"));
+                       acpi_os_printf ("\n");
                        return (AE_OK);
                }
 
-
                switch (type) {
                case ACPI_TYPE_PROCESSOR:
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " ID %d Addr %.4X Len %.4X\n",
+                       acpi_os_printf (" ID %d Addr %.4X Len %.4X\n",
                                         obj_desc->processor.proc_id,
                                         obj_desc->processor.address,
-                                        obj_desc->processor.length));
+                                        obj_desc->processor.length);
                        break;
 
                case ACPI_TYPE_DEVICE:
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " Notification object: %p", obj_desc));
+                       acpi_os_printf (" Notification object: %p", obj_desc);
                        break;
 
                case ACPI_TYPE_METHOD:
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " Args %d Len %.4X Aml %p \n",
+                       acpi_os_printf (" Args %d Len %.4X Aml %p \n",
                                         obj_desc->method.param_count,
                                         obj_desc->method.aml_length,
-                                        obj_desc->method.aml_start));
+                                        obj_desc->method.aml_start);
                        break;
 
                case ACPI_TYPE_INTEGER:
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " = %8.8X%8.8X\n",
-                                        HIDWORD (obj_desc->integer.value),
-                                        LODWORD (obj_desc->integer.value)));
+                       acpi_os_printf (" = %8.8X%8.8X\n",
+                                        ACPI_HIDWORD (obj_desc->integer.value),
+                                        ACPI_LODWORD (obj_desc->integer.value));
                        break;
 
                case ACPI_TYPE_PACKAGE:
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " Elements %.2X\n",
-                                        obj_desc->package.count));
+                       acpi_os_printf (" Elements %.2X\n",
+                                        obj_desc->package.count);
                        break;
 
                case ACPI_TYPE_BUFFER:
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " Len %.2X",
-                                        obj_desc->buffer.length));
+                       acpi_os_printf (" Len %.2X",
+                                        obj_desc->buffer.length);
 
                        /* Dump some of the buffer */
 
                        if (obj_desc->buffer.length > 0) {
-                               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " ="));
+                               acpi_os_printf (" =");
                                for (i = 0; (i < obj_desc->buffer.length && i < 12); i++) {
-                                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " %.2X",
-                                                       obj_desc->buffer.pointer[i]));
+                                       acpi_os_printf (" %.2X", obj_desc->buffer.pointer[i]);
                                }
                        }
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "\n"));
+                       acpi_os_printf ("\n");
                        break;
 
                case ACPI_TYPE_STRING:
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " Len %.2X",
-                                        obj_desc->string.length));
+                       acpi_os_printf (" Len %.2X", obj_desc->string.length);
 
                        if (obj_desc->string.length > 0) {
-                                ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " = \"%.32s\"...",
-                                                obj_desc->string.pointer));
+                                acpi_os_printf (" = \"%.32s\"...", obj_desc->string.pointer);
                        }
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "\n"));
+                       acpi_os_printf ("\n");
                        break;
 
                case ACPI_TYPE_REGION:
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " [%s]",
-                                        acpi_ut_get_region_name (obj_desc->region.space_id)));
+                       acpi_os_printf (" [%s]", acpi_ut_get_region_name (obj_desc->region.space_id));
                        if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
-                               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " Addr %8.8X%8.8X Len %.4X\n",
-                                                HIDWORD(obj_desc->region.address),
-                                                LODWORD(obj_desc->region.address),
-                                                obj_desc->region.length));
+                               acpi_os_printf (" Addr %8.8X%8.8X Len %.4X\n",
+                                                ACPI_HIDWORD (obj_desc->region.address),
+                                                ACPI_LODWORD (obj_desc->region.address),
+                                                obj_desc->region.length);
                        }
                        else {
-                               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " [Address/Length not evaluated]\n"));
+                               acpi_os_printf (" [Address/Length not evaluated]\n");
                        }
                        break;
 
                case INTERNAL_TYPE_REFERENCE:
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " [%s]\n",
-                                        acpi_ps_get_opcode_name (obj_desc->reference.opcode)));
+                       acpi_os_printf (" [%s]\n",
+                                       acpi_ps_get_opcode_name (obj_desc->reference.opcode));
                        break;
 
                case ACPI_TYPE_BUFFER_FIELD:
-
-                       /* TBD: print Buffer name when we can easily get it */
+                       if (obj_desc->buffer_field.buffer_obj &&
+                               obj_desc->buffer_field.buffer_obj->buffer.node) {
+                               acpi_os_printf (" Buf [%4.4s]",
+                                               (char *) &obj_desc->buffer_field.buffer_obj->buffer.node->name);
+                       }
                        break;
 
                case INTERNAL_TYPE_REGION_FIELD:
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " Rgn [%4.4s]",
-                                        (char *) &obj_desc->common_field.region_obj->region.node->name));
+                       acpi_os_printf (" Rgn [%4.4s]",
+                                       (char *) &obj_desc->common_field.region_obj->region.node->name);
                        break;
 
                case INTERNAL_TYPE_BANK_FIELD:
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " Rgn [%4.4s]",
-                                        (char *) &obj_desc->common_field.region_obj->region.node->name));
+                       acpi_os_printf (" Rgn [%4.4s] Bnk [%4.4s]",
+                                       (char *) &obj_desc->common_field.region_obj->region.node->name,
+                                       (char *) &obj_desc->bank_field.bank_obj->common_field.node->name);
                        break;
 
                case INTERNAL_TYPE_INDEX_FIELD:
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " Rgn [%4.4s]",
-                                        (char *) &obj_desc->index_field.index_obj->common_field.region_obj->region.node->name));
+                       acpi_os_printf (" Idx [%4.4s] Dat [%4.4s]",
+                                       (char *) &obj_desc->index_field.index_obj->common_field.node->name,
+                                       (char *) &obj_desc->index_field.data_obj->common_field.node->name);
                        break;
 
                default:
-
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " Object %p\n", obj_desc));
+                       acpi_os_printf (" Object %p\n", obj_desc);
                        break;
                }
 
@@ -330,10 +362,11 @@ acpi_ns_dump_one_object (
                case INTERNAL_TYPE_REGION_FIELD:
                case INTERNAL_TYPE_BANK_FIELD:
                case INTERNAL_TYPE_INDEX_FIELD:
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " Off %.2X Len %.2X Acc %.2d\n",
-                                        (obj_desc->common_field.base_byte_offset * 8) + obj_desc->common_field.start_field_bit_offset,
-                                        obj_desc->common_field.bit_length,
-                                        obj_desc->common_field.access_bit_width));
+                       acpi_os_printf (" Off %.2X Len %.2X Acc %.2d\n",
+                                       (obj_desc->common_field.base_byte_offset * 8)
+                                               + obj_desc->common_field.start_field_bit_offset,
+                                       obj_desc->common_field.bit_length,
+                                       obj_desc->common_field.access_byte_width);
                        break;
                }
 
@@ -342,62 +375,57 @@ acpi_ns_dump_one_object (
 
        case ACPI_DISPLAY_OBJECTS:
 
-               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "%p O:%p",
-                               this_node, obj_desc));
+               acpi_os_printf ("%p O:%p",
+                               this_node, obj_desc);
 
                if (!obj_desc) {
                        /* No attached object, we are done */
 
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "\n"));
+                       acpi_os_printf ("\n");
                        return (AE_OK);
                }
 
-               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "(R%d)",
-                               obj_desc->common.reference_count));
+               acpi_os_printf ("(R%d)",
+                               obj_desc->common.reference_count);
 
                switch (type) {
-
                case ACPI_TYPE_METHOD:
 
                        /* Name is a Method and its AML offset/length are set */
 
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " M:%p-%X\n",
-                                        obj_desc->method.aml_start,
-                                        obj_desc->method.aml_length));
-
+                       acpi_os_printf (" M:%p-%X\n", obj_desc->method.aml_start,
+                                         obj_desc->method.aml_length);
                        break;
 
-
                case ACPI_TYPE_INTEGER:
 
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " N:%X%X\n",
-                                        HIDWORD(obj_desc->integer.value),
-                                        LODWORD(obj_desc->integer.value)));
+                       acpi_os_printf (" N:%X%X\n", ACPI_HIDWORD(obj_desc->integer.value),
+                                        ACPI_LODWORD(obj_desc->integer.value));
                        break;
 
-
                case ACPI_TYPE_STRING:
 
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " S:%p-%X\n",
-                                        obj_desc->string.pointer,
-                                        obj_desc->string.length));
+                       acpi_os_printf (" S:%p-%X\n", obj_desc->string.pointer,
+                                         obj_desc->string.length);
                        break;
 
-
                case ACPI_TYPE_BUFFER:
 
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " B:%p-%X\n",
-                                        obj_desc->buffer.pointer,
-                                        obj_desc->buffer.length));
+                       acpi_os_printf (" B:%p-%X\n", obj_desc->buffer.pointer,
+                                         obj_desc->buffer.length);
                        break;
 
-
                default:
 
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "\n"));
+                       acpi_os_printf ("\n");
                        break;
                }
                break;
+
+
+       default:
+               acpi_os_printf ("\n");
+               break;
        }
 
        /* If debug turned off, done */
@@ -409,48 +437,55 @@ acpi_ns_dump_one_object (
 
        /* If there is an attached object, display it */
 
-       obj_desc = this_node->object;
+       dbg_level = acpi_dbg_level;
+       acpi_dbg_level = 0;
+       obj_desc = acpi_ns_get_attached_object (this_node);
+       acpi_dbg_level = dbg_level;
 
        /* Dump attached objects */
 
        while (obj_desc) {
                obj_type = INTERNAL_TYPE_INVALID;
+               acpi_os_printf ("      Attached Object %p: ", obj_desc);
 
                /* Decode the type of attached object and dump the contents */
 
-               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "        Attached Object %p: ", obj_desc));
+               switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) {
+               case ACPI_DESC_TYPE_NAMED:
 
-               if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_NAMED)) {
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "(Ptr to Node)\n"));
+                       acpi_os_printf ("(Ptr to Node)\n");
                        bytes_to_dump = sizeof (acpi_namespace_node);
-               }
+                       break;
+
 
+               case ACPI_DESC_TYPE_INTERNAL:
 
-               else if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_INTERNAL)) {
                        obj_type = obj_desc->common.type;
 
                        if (obj_type > INTERNAL_TYPE_MAX) {
-                               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "(Ptr to ACPI Object type %X [UNKNOWN])\n", obj_type));
+                               acpi_os_printf ("(Ptr to ACPI Object type %X [UNKNOWN])\n", obj_type);
                                bytes_to_dump = 32;
                        }
-
                        else {
-                               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "(Ptr to ACPI Object type %2.2X [%s])\n",
-                                                  obj_type, acpi_ut_get_type_name (obj_type)));
+                               acpi_os_printf ("(Ptr to ACPI Object type %2.2X [%s])\n",
+                                                  obj_type, acpi_ut_get_type_name (obj_type));
                                bytes_to_dump = sizeof (acpi_operand_object);
                        }
-               }
+                       break;
 
-               else {
-                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "(String or Buffer - not descriptor)\n"));
+
+               default:
+
+                       acpi_os_printf ("(String or Buffer ptr - not an object descriptor)\n");
                        bytes_to_dump = 16;
+                       break;
                }
 
-               DUMP_BUFFER (obj_desc, bytes_to_dump);
+               ACPI_DUMP_BUFFER (obj_desc, bytes_to_dump);
 
                /* If value is NOT an internal object, we are done */
 
-               if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_NAMED)) {
+               if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_INTERNAL) {
                        goto cleanup;
                }
 
@@ -494,11 +529,11 @@ acpi_ns_dump_one_object (
                        goto cleanup;
                }
 
-               obj_type = INTERNAL_TYPE_INVALID;    /* Terminate loop after next pass */
+               obj_type = INTERNAL_TYPE_INVALID;  /* Terminate loop after next pass */
        }
 
 cleanup:
-       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "\n"));
+       acpi_os_printf ("\n");
        return (AE_OK);
 }
 
@@ -521,7 +556,7 @@ cleanup:
 
 void
 acpi_ns_dump_objects (
-       acpi_object_type8       type,
+       acpi_object_type        type,
        u8                      display_type,
        u32                     max_depth,
        u32                     owner_id,
@@ -530,7 +565,7 @@ acpi_ns_dump_objects (
        acpi_walk_info          info;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        info.debug_level = ACPI_LV_TABLES;
@@ -538,7 +573,7 @@ acpi_ns_dump_objects (
        info.display_type = display_type;
 
 
-       acpi_ns_walk_namespace (type, start_handle, max_depth, NS_WALK_NO_UNLOCK, acpi_ns_dump_one_object,
+       acpi_ns_walk_namespace (type, start_handle, max_depth, ACPI_NS_WALK_NO_UNLOCK, acpi_ns_dump_one_object,
                           (void *) &info, NULL);
 }
 
@@ -569,7 +604,7 @@ acpi_ns_dump_one_device (
        u32                     i;
 
 
-       PROC_NAME ("Ns_dump_one_device");
+       ACPI_FUNCTION_NAME ("Ns_dump_one_device");
 
 
        status = acpi_ns_dump_one_object (obj_handle, level, context, return_value);
@@ -581,7 +616,9 @@ acpi_ns_dump_one_device (
                }
 
                ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "    HID: %s, ADR: %8.8X%8.8X, Status: %x\n",
-                                 info.hardware_id, HIDWORD(info.address), LODWORD(info.address), info.current_status));
+                                 info.hardware_id,
+                                 ACPI_HIDWORD (info.address), ACPI_LODWORD (info.address),
+                                 info.current_status));
        }
 
        return (status);
@@ -604,7 +641,7 @@ acpi_ns_dump_root_devices (void)
        acpi_handle             sys_bus_handle;
 
 
-       PROC_NAME ("Ns_dump_root_devices");
+       ACPI_FUNCTION_NAME ("Ns_dump_root_devices");
 
 
        /* Only dump the table if tracing is enabled */
@@ -613,10 +650,10 @@ acpi_ns_dump_root_devices (void)
                return;
        }
 
-       acpi_get_handle (0, NS_SYSTEM_BUS, &sys_bus_handle);
+       acpi_get_handle (0, ACPI_NS_SYSTEM_BUS, &sys_bus_handle);
 
        ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Display of all devices in the namespace:\n"));
-       acpi_ns_walk_namespace (ACPI_TYPE_DEVICE, sys_bus_handle, ACPI_UINT32_MAX, NS_WALK_NO_UNLOCK,
+       acpi_ns_walk_namespace (ACPI_TYPE_DEVICE, sys_bus_handle, ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK,
                           acpi_ns_dump_one_device, NULL, NULL);
 }
 
@@ -643,7 +680,7 @@ acpi_ns_dump_tables (
        acpi_handle             search_handle = search_base;
 
 
-       FUNCTION_TRACE ("Ns_dump_tables");
+       ACPI_FUNCTION_TRACE ("Ns_dump_tables");
 
 
        if (!acpi_gbl_root_node) {
@@ -655,7 +692,7 @@ acpi_ns_dump_tables (
                return_VOID;
        }
 
-       if (NS_ALL == search_base) {
+       if (ACPI_NS_ALL == search_base) {
                /*  entire namespace    */
 
                search_handle = acpi_gbl_root_node;
@@ -688,11 +725,12 @@ acpi_ns_dump_entry (
        acpi_walk_info          info;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        info.debug_level = debug_level;
        info.owner_id = ACPI_UINT32_MAX;
+       info.display_type = ACPI_DISPLAY_SUMMARY;
 
        acpi_ns_dump_one_object (handle, 1, &info, NULL);
 }
index 9b95ffe43167cef980eef1a8aa9fceb009d0a7d1..39b6ce3a135cbd8701f652a9e3e7d9bbb2b73dc9 100644 (file)
@@ -2,12 +2,12 @@
  *
  * Module Name: nseval - Object evaluation interfaces -- includes control
  *                       method lookup and execution.
- *              $Revision: 102 $
+ *              $Revision: 109 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -33,7 +33,7 @@
 
 
 #define _COMPONENT          ACPI_NAMESPACE
-        MODULE_NAME         ("nseval")
+        ACPI_MODULE_NAME    ("nseval")
 
 
 /*******************************************************************************
@@ -72,7 +72,7 @@ acpi_ns_evaluate_relative (
        acpi_generic_state      scope_info;
 
 
-       FUNCTION_TRACE ("Ns_evaluate_relative");
+       ACPI_FUNCTION_TRACE ("Ns_evaluate_relative");
 
 
        /*
@@ -91,11 +91,14 @@ acpi_ns_evaluate_relative (
 
        /* Get the prefix handle and Node */
 
-       acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
 
        prefix_node = acpi_ns_map_handle_to_node (handle);
        if (!prefix_node) {
-               acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+               (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
                status = AE_BAD_PARAMETER;
                goto cleanup;
        }
@@ -104,10 +107,10 @@ acpi_ns_evaluate_relative (
 
        scope_info.scope.node = prefix_node;
        status = acpi_ns_lookup (&scope_info, internal_path, ACPI_TYPE_ANY,
-                        IMODE_EXECUTE, NS_NO_UPSEARCH, NULL,
+                        ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL,
                         &node);
 
-       acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+       (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 
        if (ACPI_FAILURE (status)) {
                ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Object [%s] not found [%s]\n",
@@ -120,7 +123,7 @@ acpi_ns_evaluate_relative (
         * to evaluate it.
         */
        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s [%p] Value %p\n",
-               pathname, node, node->object));
+               pathname, node, acpi_ns_get_attached_object (node)));
 
        status = acpi_ns_evaluate_by_handle (node, params, return_object);
 
@@ -165,7 +168,7 @@ acpi_ns_evaluate_by_name (
        NATIVE_CHAR             *internal_path = NULL;
 
 
-       FUNCTION_TRACE ("Ns_evaluate_by_name");
+       ACPI_FUNCTION_TRACE ("Ns_evaluate_by_name");
 
 
        /* Build an internal name string for the method */
@@ -175,15 +178,18 @@ acpi_ns_evaluate_by_name (
                return_ACPI_STATUS (status);
        }
 
-       acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
 
        /* Lookup the name in the namespace */
 
        status = acpi_ns_lookup (NULL, internal_path, ACPI_TYPE_ANY,
-                        IMODE_EXECUTE, NS_NO_UPSEARCH, NULL,
+                        ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL,
                         &node);
 
-       acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+       (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 
        if (ACPI_FAILURE (status)) {
                ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Object at [%s] was not found, status=%.4X\n",
@@ -196,7 +202,7 @@ acpi_ns_evaluate_by_name (
         * to evaluate it.
         */
        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s [%p] Value %p\n",
-               pathname, node, node->object));
+               pathname, node, acpi_ns_get_attached_object (node)));
 
        status = acpi_ns_evaluate_by_handle (node, params, return_object);
 
@@ -246,7 +252,7 @@ acpi_ns_evaluate_by_handle (
        acpi_operand_object     *local_return_object;
 
 
-       FUNCTION_TRACE ("Ns_evaluate_by_handle");
+       ACPI_FUNCTION_TRACE ("Ns_evaluate_by_handle");
 
 
        /* Check if namespace has been initialized */
@@ -269,11 +275,14 @@ acpi_ns_evaluate_by_handle (
 
        /* Get the prefix handle and Node */
 
-       acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
 
        node = acpi_ns_map_handle_to_node (handle);
        if (!node) {
-               acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+               (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
@@ -368,7 +377,7 @@ acpi_ns_execute_control_method (
        acpi_operand_object     *obj_desc;
 
 
-       FUNCTION_TRACE ("Ns_execute_control_method");
+       ACPI_FUNCTION_TRACE ("Ns_execute_control_method");
 
 
        /* Verify that there is a method associated with this object */
@@ -377,7 +386,7 @@ acpi_ns_execute_control_method (
        if (!obj_desc) {
                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No attached method object\n"));
 
-               acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+               (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
                return_ACPI_STATUS (AE_NULL_OBJECT);
        }
 
@@ -385,7 +394,7 @@ acpi_ns_execute_control_method (
        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Control method at Offset %p Length %x]\n",
                obj_desc->method.aml_start + 1, obj_desc->method.aml_length - 1));
 
-       DUMP_PATHNAME (method_node, "Ns_execute_control_method: Executing",
+       ACPI_DUMP_PATHNAME (method_node, "Ns_execute_control_method: Executing",
                ACPI_LV_NAMES, _COMPONENT);
 
        ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "At offset %p\n",
@@ -399,7 +408,10 @@ acpi_ns_execute_control_method (
         * interpreter locks to ensure that no thread is using the portion of the
         * namespace that is being deleted.
         */
-       acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+       status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
 
        /*
         * Execute the method via the interpreter.  The interpreter is locked
@@ -427,7 +439,7 @@ acpi_ns_execute_control_method (
  *
  * DESCRIPTION: Return the current value of the object
  *
- * MUTEX:       Assumes namespace is locked
+ * MUTEX:       Assumes namespace is locked, leaves namespace unlocked
  *
  ******************************************************************************/
 
@@ -438,110 +450,59 @@ acpi_ns_get_object_value (
 {
        acpi_status             status = AE_OK;
        acpi_operand_object     *obj_desc;
-       acpi_operand_object     *source_desc;
 
 
-       FUNCTION_TRACE ("Ns_get_object_value");
+       ACPI_FUNCTION_TRACE ("Ns_get_object_value");
 
 
        /*
-        *  We take the value from certain objects directly
+        * Objects require additional resolution steps (e.g., the
+        * Node may be a field that must be read, etc.) -- we can't just grab
+        * the object out of the node.
         */
-       if ((node->type == ACPI_TYPE_PROCESSOR) ||
-               (node->type == ACPI_TYPE_POWER)) {
-               /*
-                *  Create a Reference object to contain the object
-                */
-               obj_desc = acpi_ut_create_internal_object (node->type);
-               if (!obj_desc) {
-                  status = AE_NO_MEMORY;
-                  goto unlock_and_exit;
-               }
-
-               /*
-                *  Get the attached object
-                */
-               source_desc = acpi_ns_get_attached_object (node);
-               if (!source_desc) {
-                       status = AE_NULL_OBJECT;
-                       goto unlock_and_exit;
-               }
-
-               /*
-                * Just copy from the original to the return object
-                *
-                * TBD: [Future] - need a low-level object copy that handles
-                * the reference count automatically.  (Don't want to copy it)
-                */
-               MEMCPY (obj_desc, source_desc, sizeof (acpi_operand_object));
-               obj_desc->common.reference_count = 1;
-               acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
-       }
-
+       obj_desc = (acpi_operand_object *) node;
 
        /*
-        * Other objects require a reference object wrapper which we
-        * then attempt to resolve.
+        * Use Resolve_node_to_value() to get the associated value. This call
+        * always deletes Obj_desc (allocated above).
+        *
+        * NOTE: we can get away with passing in NULL for a walk state
+        * because Obj_desc is guaranteed to not be a reference to either
+        * a method local or a method argument (because this interface can only be
+        * called from the Acpi_evaluate external interface, never called from
+        * a running control method.)
+        *
+        * Even though we do not directly invoke the interpreter
+        * for this, we must enter it because we could access an opregion.
+        * The opregion access code assumes that the interpreter
+        * is locked.
+        *
+        * We must release the namespace lock before entering the
+        * intepreter.
         */
-       else {
-               /* Create an Reference object to contain the object */
-
-               obj_desc = acpi_ut_create_internal_object (INTERNAL_TYPE_REFERENCE);
-               if (!obj_desc) {
-                  status = AE_NO_MEMORY;
-                  goto unlock_and_exit;
-               }
-
-               /* Construct a descriptor pointing to the name */
-
-               obj_desc->reference.opcode = (u8) AML_NAME_OP;
-               obj_desc->reference.object = (void *) node;
+       status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
 
+       status = acpi_ex_enter_interpreter ();
+       if (ACPI_SUCCESS (status)) {
+               status = acpi_ex_resolve_node_to_value ((acpi_namespace_node **) &obj_desc, NULL);
                /*
-                * Use Resolve_to_value() to get the associated value. This call
-                * always deletes Obj_desc (allocated above).
-                *
-                * NOTE: we can get away with passing in NULL for a walk state
-                * because Obj_desc is guaranteed to not be a reference to either
-                * a method local or a method argument
-                *
-                * Even though we do not directly invoke the interpreter
-                * for this, we must enter it because we could access an opregion.
-                * The opregion access code assumes that the interpreter
-                * is locked.
-                *
-                * We must release the namespace lock before entering the
-                * intepreter.
+                * If Acpi_ex_resolve_node_to_value() succeeded, the return value was
+                * placed in Obj_desc.
                 */
-               acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
-               status = acpi_ex_enter_interpreter ();
-               if (ACPI_SUCCESS (status)) {
-                       status = acpi_ex_resolve_to_value (&obj_desc, NULL);
+               acpi_ex_exit_interpreter ();
 
-                       acpi_ex_exit_interpreter ();
+               if (ACPI_SUCCESS (status)) {
+                       status = AE_CTRL_RETURN_VALUE;
+                       *return_obj_desc = obj_desc;
+                       ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Returning obj %p\n", *return_obj_desc));
                }
        }
 
-       /*
-        * If Acpi_ex_resolve_to_value() succeeded, the return value was
-        * placed in Obj_desc.
-        */
-       if (ACPI_SUCCESS (status)) {
-               status = AE_CTRL_RETURN_VALUE;
-
-               *return_obj_desc = obj_desc;
-               ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Returning obj %p\n", *return_obj_desc));
-       }
-
        /* Namespace is unlocked */
 
        return_ACPI_STATUS (status);
-
-
-unlock_and_exit:
-
-       /* Unlock the namespace */
-
-       acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
-       return_ACPI_STATUS (status);
 }
+
index 93d1581d25dfd895ae3e45f789016b722e92ea1b..821126b32978050c524edf2bdead4171aa063454 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: nsinit - namespace initialization
- *              $Revision: 33 $
+ *              $Revision: 41 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@
 #include "acinterp.h"
 
 #define _COMPONENT          ACPI_NAMESPACE
-        MODULE_NAME         ("nsinit")
+        ACPI_MODULE_NAME    ("nsinit")
 
 
 /*******************************************************************************
@@ -54,7 +54,7 @@ acpi_ns_initialize_objects (
        acpi_init_walk_info     info;
 
 
-       FUNCTION_TRACE ("Ns_initialize_objects");
+       ACPI_FUNCTION_TRACE ("Ns_initialize_objects");
 
 
        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
@@ -115,7 +115,7 @@ acpi_ns_initialize_devices (
        acpi_device_walk_info   info;
 
 
-       FUNCTION_TRACE ("Ns_initialize_devices");
+       ACPI_FUNCTION_TRACE ("Ns_initialize_devices");
 
 
        info.device_count = 0;
@@ -168,14 +168,14 @@ acpi_ns_init_one_object (
        void                    *context,
        void                    **return_value)
 {
-       acpi_object_type8       type;
+       acpi_object_type        type;
        acpi_status             status;
        acpi_init_walk_info     *info = (acpi_init_walk_info *) context;
        acpi_namespace_node     *node = (acpi_namespace_node *) obj_handle;
        acpi_operand_object     *obj_desc;
 
 
-       PROC_NAME ("Ns_init_one_object");
+       ACPI_FUNCTION_NAME ("Ns_init_one_object");
 
 
        info->object_count++;
@@ -184,7 +184,7 @@ acpi_ns_init_one_object (
        /* And even then, we are only interested in a few object types */
 
        type = acpi_ns_get_type (obj_handle);
-       obj_desc = node->object;
+       obj_desc = acpi_ns_get_attached_object (node);
        if (!obj_desc) {
                return (AE_OK);
        }
@@ -218,7 +218,7 @@ acpi_ns_init_one_object (
                        ACPI_DEBUG_PRINT_RAW ((ACPI_DB_ERROR, "\n"));
                        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
                                        "%s while getting region arguments [%4.4s]\n",
-                                       acpi_format_exception (status), (char*)&node->name));
+                                       acpi_format_exception (status), (char *) &node->name));
                }
 
                if (!(acpi_dbg_level & ACPI_LV_INIT)) {
@@ -241,7 +241,7 @@ acpi_ns_init_one_object (
                        ACPI_DEBUG_PRINT_RAW ((ACPI_DB_ERROR, "\n"));
                        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
                                        "%s while getting buffer field arguments [%4.4s]\n",
-                                       acpi_format_exception (status), (char*)&node->name));
+                                       acpi_format_exception (status), (char *) &node->name));
                }
                if (!(acpi_dbg_level & ACPI_LV_INIT)) {
                        ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, "."));
@@ -291,7 +291,7 @@ acpi_ns_init_one_device (
        acpi_device_walk_info  *info = (acpi_device_walk_info *) context;
 
 
-       FUNCTION_TRACE ("Ns_init_one_device");
+       ACPI_FUNCTION_TRACE ("Ns_init_one_device");
 
 
        if (!(acpi_dbg_level & ACPI_LV_INIT)) {
@@ -300,20 +300,26 @@ acpi_ns_init_one_device (
 
        info->device_count++;
 
-       acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
 
        node = acpi_ns_map_handle_to_node (obj_handle);
        if (!node) {
-               acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
-               return (AE_BAD_PARAMETER);
+               (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+               return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
-       acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+       status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
 
        /*
         * Run _STA to determine if we can run _INI on the device.
         */
-       DEBUG_EXEC (acpi_ut_display_init_pathname (node, "_STA [Method]"));
+       ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname (node, "_STA [Method]"));
        status = acpi_ut_execute_STA (node, &flags);
        if (ACPI_FAILURE (status)) {
                /* Ignore error and move on to next device */
@@ -333,7 +339,7 @@ acpi_ns_init_one_device (
        /*
         * The device is present. Run _INI.
         */
-       DEBUG_EXEC (acpi_ut_display_init_pathname (obj_handle, "_INI [Method]"));
+       ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname (obj_handle, "_INI [Method]"));
        status = acpi_ns_evaluate_relative (obj_handle, "_INI", NULL, NULL);
        if (AE_NOT_FOUND == status) {
                /* No _INI means device requires no initialization */
@@ -345,7 +351,7 @@ acpi_ns_init_one_device (
                /* Ignore error and move on to next device */
 
 #ifdef ACPI_DEBUG
-               NATIVE_CHAR *scope_name = acpi_ns_get_table_pathname (obj_handle);
+               NATIVE_CHAR *scope_name = acpi_ns_get_external_pathname (obj_handle);
 
                ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "%s._INI failed: %s\n",
                                scope_name, acpi_format_exception (status)));
index 98e084f41e2cd296777f70752bc4e40d859f9cbc..d1047985ce98d00cc9a785564643a9f7a7ab849e 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: nsload - namespace loading/expanding/contracting procedures
- *              $Revision: 47 $
+ *              $Revision: 53 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 
 
 #define _COMPONENT          ACPI_NAMESPACE
-        MODULE_NAME         ("nsload")
+        ACPI_MODULE_NAME    ("nsload")
 
 
 /*******************************************************************************
  *
  * FUNCTION:    Acpi_load_namespace
  *
- * PARAMETERS:  Display_aml_during_load
+ * PARAMETERS:  None
  *
  * RETURN:      Status
  *
@@ -57,7 +57,7 @@ acpi_ns_load_namespace (
        acpi_status             status;
 
 
-       FUNCTION_TRACE ("Acpi_load_name_space");
+       ACPI_FUNCTION_TRACE ("Acpi_load_name_space");
 
 
        /* There must be at least a DSDT installed */
@@ -67,7 +67,6 @@ acpi_ns_load_namespace (
                return_ACPI_STATUS (AE_NO_ACPI_TABLES);
        }
 
-
        /*
         * Load the namespace.  The DSDT is required,
         * but the SSDT and PSDT tables are optional.
@@ -82,12 +81,10 @@ acpi_ns_load_namespace (
        acpi_ns_load_table_by_type (ACPI_TABLE_SSDT);
        acpi_ns_load_table_by_type (ACPI_TABLE_PSDT);
 
-
        ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
                "ACPI Namespace successfully loaded at root %p\n",
                acpi_gbl_root_node));
 
-
        return_ACPI_STATUS (status);
 }
 
@@ -96,11 +93,12 @@ acpi_ns_load_namespace (
  *
  * FUNCTION:    Acpi_ns_one_parse_pass
  *
- * PARAMETERS:
+ * PARAMETERS:  Pass_number             - 1 or 2
+ *              Table_desc              - The table to be parsed.
  *
  * RETURN:      Status
  *
- * DESCRIPTION:
+ * DESCRIPTION: Perform one complete parse of an ACPI/AML table.
  *
  ******************************************************************************/
 
@@ -114,7 +112,7 @@ acpi_ns_one_complete_parse (
        acpi_walk_state         *walk_state;
 
 
-       FUNCTION_TRACE ("Ns_one_complete_parse");
+       ACPI_FUNCTION_TRACE ("Ns_one_complete_parse");
 
 
        /* Create and init a Root Node */
@@ -126,7 +124,6 @@ acpi_ns_one_complete_parse (
 
        ((acpi_parse2_object *) parse_root)->name = ACPI_ROOT_NAME;
 
-
        /* Create and initialize a new walk state */
 
        walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT,
@@ -174,7 +171,7 @@ acpi_ns_parse_table (
        acpi_status             status;
 
 
-       FUNCTION_TRACE ("Ns_parse_table");
+       ACPI_FUNCTION_TRACE ("Ns_parse_table");
 
 
        /*
@@ -192,7 +189,6 @@ acpi_ns_parse_table (
                return_ACPI_STATUS (status);
        }
 
-
        /*
         * AML Parse, pass 2
         *
@@ -232,8 +228,18 @@ acpi_ns_load_table (
        acpi_status             status;
 
 
-       FUNCTION_TRACE ("Ns_load_table");
+       ACPI_FUNCTION_TRACE ("Ns_load_table");
+
+
+       /* Check if table contains valid AML (must be DSDT, PSDT, SSDT, etc.) */
 
+       if (!(acpi_gbl_acpi_table_data[table_desc->type].flags & ACPI_TABLE_EXECUTABLE)) {
+               /* Just ignore this table */
+
+               return_ACPI_STATUS (AE_OK);
+       }
+
+       /* Check validity of the AML start and length */
 
        if (!table_desc->aml_start) {
                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null AML pointer\n"));
@@ -242,13 +248,11 @@ acpi_ns_load_table (
 
        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AML block at %p\n", table_desc->aml_start));
 
-
        if (!table_desc->aml_length) {
                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Zero-length AML block\n"));
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
-
        /*
         * Parse the table and load the namespace with all named
         * objects found within.  Control methods are NOT parsed
@@ -260,9 +264,13 @@ acpi_ns_load_table (
         */
        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Loading table into namespace ****\n"));
 
-       acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
+
        status = acpi_ns_parse_table (table_desc, node->child);
-       acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+       (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 
        if (ACPI_FAILURE (status)) {
                return_ACPI_STATUS (status);
@@ -305,22 +313,23 @@ acpi_ns_load_table_by_type (
        acpi_table_type         table_type)
 {
        u32                     i;
-       acpi_status             status = AE_OK;
+       acpi_status             status;
        acpi_table_desc         *table_desc;
 
 
-       FUNCTION_TRACE ("Ns_load_table_by_type");
-
+       ACPI_FUNCTION_TRACE ("Ns_load_table_by_type");
 
-       acpi_ut_acquire_mutex (ACPI_MTX_TABLES);
 
+       status = acpi_ut_acquire_mutex (ACPI_MTX_TABLES);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
 
        /*
         * Table types supported are:
         * DSDT (one), SSDT/PSDT (multiple)
         */
        switch (table_type) {
-
        case ACPI_TABLE_DSDT:
 
                ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Loading DSDT\n"));
@@ -408,11 +417,8 @@ acpi_ns_load_table_by_type (
 
 
 unlock_and_exit:
-
-       acpi_ut_release_mutex (ACPI_MTX_TABLES);
-
+       (void) acpi_ut_release_mutex (ACPI_MTX_TABLES);
        return_ACPI_STATUS (status);
-
 }
 
 
@@ -427,8 +433,8 @@ unlock_and_exit:
  * DESCRIPTION: Walks the namespace starting at the given handle and deletes
  *              all objects, entries, and scopes in the entire subtree.
  *
- *              TBD: [Investigate] What if any part of this subtree is in use?
- *              (i.e. on one of the object stacks?)
+ *              Namespace/Interpreter should be locked or the subsystem should
+ *              be in shutdown before this routine is called.
  *
  ******************************************************************************/
 
@@ -444,7 +450,7 @@ acpi_ns_delete_subtree (
        u32                     level;
 
 
-       FUNCTION_TRACE ("Ns_delete_subtree");
+       ACPI_FUNCTION_TRACE ("Ns_delete_subtree");
 
 
        parent_handle = start_handle;
@@ -463,7 +469,6 @@ acpi_ns_delete_subtree (
 
                child_handle = next_child_handle;
 
-
                /* Did we get a new object? */
 
                if (ACPI_SUCCESS (status)) {
@@ -480,7 +485,6 @@ acpi_ns_delete_subtree (
                                child_handle = 0;
                        }
                }
-
                else {
                        /*
                         * No more children in this object, go back up to
@@ -526,7 +530,7 @@ acpi_ns_unload_namespace (
        acpi_status             status;
 
 
-       FUNCTION_TRACE ("Ns_unload_name_space");
+       ACPI_FUNCTION_TRACE ("Ns_unload_name_space");
 
 
        /* Parameter validation */
@@ -539,7 +543,6 @@ acpi_ns_unload_namespace (
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
-
        /* This function does the real work */
 
        status = acpi_ns_delete_subtree (handle);
index 5b05525d49d963e8e1cada892e86d5e22b825bb7..6d1571a2ed32e3753f68f06b616ef84e44928f56 100644 (file)
@@ -1,12 +1,12 @@
 /*******************************************************************************
  *
  * Module Name: nsnames - Name manipulation and search
- *              $Revision: 64 $
+ *              $Revision: 74 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 
 
 #define _COMPONENT          ACPI_NAMESPACE
-        MODULE_NAME         ("nsnames")
+        ACPI_MODULE_NAME    ("nsnames")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_get_table_pathname
+ * FUNCTION:    Acpi_ns_build_external_path
  *
- * PARAMETERS:  Node        - Scope whose name is needed
+ * PARAMETERS:  Node            - NS node whose pathname is needed
+ *              Size            - Size of the pathname
+ *              *Name_buffer    - Where to return the pathname
  *
- * RETURN:      Pointer to storage containing the fully qualified name of
- *              the scope, in Label format (all segments strung together
- *              with no separators)
+ * RETURN:      Places the pathname into the Name_buffer, in external format
+ *              (name segments separated by path separators)
  *
- * DESCRIPTION: Used for debug printing in Acpi_ns_search_table().
+ * DESCRIPTION: Generate a full pathaname
  *
  ******************************************************************************/
 
-NATIVE_CHAR *
-acpi_ns_get_table_pathname (
-       acpi_namespace_node     *node)
+void
+acpi_ns_build_external_path (
+       acpi_namespace_node     *node,
+       ACPI_SIZE               size,
+       NATIVE_CHAR             *name_buffer)
 {
-       NATIVE_CHAR             *name_buffer;
-       u32                     size;
-       acpi_name               name;
-       acpi_namespace_node     *child_node;
+       u32                     index;
        acpi_namespace_node     *parent_node;
 
 
-       FUNCTION_TRACE_PTR ("Ns_get_table_pathname", node);
+       ACPI_FUNCTION_NAME ("Ns_build_external_path");
 
 
-       if (!acpi_gbl_root_node || !node) {
-               /*
-                * If the name space has not been initialized,
-                * this function should not have been called.
-                */
-               return_PTR (NULL);
+       /* Special case for root */
+
+       index = size - 1;
+       if (index < ACPI_NAME_SIZE) {
+               name_buffer[0] = AML_ROOT_PREFIX;
+               name_buffer[1] = 0;
+               return;
        }
 
-       child_node = node->child;
+       /* Store terminator byte, then build name backwards */
+
+       parent_node = node;
+       name_buffer[index] = 0;
 
+       while ((index > ACPI_NAME_SIZE) && (parent_node != acpi_gbl_root_node)) {
+               index -= ACPI_NAME_SIZE;
 
-       /* Calculate required buffer size based on depth below root */
+               /* Put the name into the buffer */
+
+               ACPI_MOVE_UNALIGNED32_TO_32 ((name_buffer + index), &parent_node->name);
+               parent_node = acpi_ns_get_parent_node (parent_node);
 
-       size = 1;
-       parent_node = child_node;
-       while (parent_node) {
-               parent_node = acpi_ns_get_parent_object (parent_node);
-               if (parent_node) {
-                       size += ACPI_NAME_SIZE;
-               }
+               /* Prefix name with the path separator */
+
+               index--;
+               name_buffer[index] = PATH_SEPARATOR;
        }
 
+       /* Overwrite final separator with the root prefix character */
 
-       /* Allocate a buffer to be returned to caller */
+       name_buffer[index] = AML_ROOT_PREFIX;
 
-       name_buffer = ACPI_MEM_CALLOCATE (size + 1);
-       if (!name_buffer) {
-               REPORT_ERROR (("Ns_get_table_pathname: allocation failure\n"));
-               return_PTR (NULL);
+       if (index != 0) {
+               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+                       "Could not construct pathname; index=%X, size=%X, Path=%s\n",
+                       index, size, &name_buffer[size]));
        }
 
+       return;
+}
 
-       /* Store terminator byte, then build name backwards */
 
-       name_buffer[size] = '\0';
-       while ((size > ACPI_NAME_SIZE) &&
-               acpi_ns_get_parent_object (child_node)) {
-               size -= ACPI_NAME_SIZE;
-               name = acpi_ns_find_parent_name (child_node);
+#ifdef ACPI_DEBUG
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ns_get_external_pathname
+ *
+ * PARAMETERS:  Node            - NS node whose pathname is needed
+ *
+ * RETURN:      Pointer to storage containing the fully qualified name of
+ *              the node, In external format (name segments separated by path
+ *              separators.)
+ *
+ * DESCRIPTION: Used for debug printing in Acpi_ns_search_table().
+ *
+ ******************************************************************************/
 
-               /* Put the name into the buffer */
+NATIVE_CHAR *
+acpi_ns_get_external_pathname (
+       acpi_namespace_node     *node)
+{
+       NATIVE_CHAR             *name_buffer;
+       ACPI_SIZE               size;
+
+
+       ACPI_FUNCTION_TRACE_PTR ("Ns_get_external_pathname", node);
 
-               MOVE_UNALIGNED32_TO_32 ((name_buffer + size), &name);
-               child_node = acpi_ns_get_parent_object (child_node);
-       }
 
-       name_buffer[--size] = AML_ROOT_PREFIX;
+       /* Calculate required buffer size based on depth below root */
+
+       size = acpi_ns_get_pathname_length (node);
+
+       /* Allocate a buffer to be returned to caller */
 
-       if (size != 0) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Bad pointer returned; size=%X\n", size));
+       name_buffer = ACPI_MEM_CALLOCATE (size);
+       if (!name_buffer) {
+               ACPI_REPORT_ERROR (("Ns_get_table_pathname: allocation failure\n"));
+               return_PTR (NULL);
        }
 
+       /* Build the path in the allocated buffer */
+
+       acpi_ns_build_external_path (node, size, name_buffer);
        return_PTR (name_buffer);
 }
+#endif
 
 
 /*******************************************************************************
@@ -130,31 +162,27 @@ acpi_ns_get_table_pathname (
  *
  ******************************************************************************/
 
-u32
+ACPI_SIZE
 acpi_ns_get_pathname_length (
        acpi_namespace_node     *node)
 {
-       u32                     size;
+       ACPI_SIZE               size;
        acpi_namespace_node     *next_node;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        /*
         * Compute length of pathname as 5 * number of name segments.
         * Go back up the parent tree to the root
         */
-       for (size = 0, next_node = node;
-                 acpi_ns_get_parent_object (next_node);
-                 next_node = acpi_ns_get_parent_object (next_node)) {
-               size += PATH_SEGMENT_LENGTH;
-       }
-
-       /* Special case for size still 0 - no parent for "special" nodes */
+       size = 0;
+       next_node = node;
 
-       if (!size) {
-               size = PATH_SEGMENT_LENGTH;
+       while (next_node != acpi_gbl_root_node) {
+               size += PATH_SEGMENT_LENGTH;
+               next_node = acpi_ns_get_parent_node (next_node);
        }
 
        return (size + 1);
@@ -167,96 +195,49 @@ acpi_ns_get_pathname_length (
  *
  * PARAMETERS:  Target_handle           - Handle of named object whose name is
  *                                        to be found
- *              Buf_size                - Size of the buffer provided
- *              User_buffer             - Where the pathname is returned
+ *              Buffer                  - Where the pathname is returned
  *
  * RETURN:      Status, Buffer is filled with pathname if status is AE_OK
  *
  * DESCRIPTION: Build and return a full namespace pathname
  *
- * MUTEX:       Locks Namespace
- *
  ******************************************************************************/
 
 acpi_status
 acpi_ns_handle_to_pathname (
        acpi_handle             target_handle,
-       u32                     *buf_size,
-       NATIVE_CHAR             *user_buffer)
+       acpi_buffer             *buffer)
 {
-       acpi_status             status = AE_OK;
+       acpi_status             status;
        acpi_namespace_node     *node;
-       u32                     path_length;
-       u32                     user_buf_size;
-       acpi_name               name;
-       u32                     size;
+       ACPI_SIZE               required_size;
 
 
-       FUNCTION_TRACE_PTR ("Ns_handle_to_pathname", target_handle);
+       ACPI_FUNCTION_TRACE_PTR ("Ns_handle_to_pathname", target_handle);
 
 
-       if (!acpi_gbl_root_node) {
-               /*
-                * If the name space has not been initialized,
-                * this function should not have been called.
-                */
-               return_ACPI_STATUS (AE_NO_NAMESPACE);
-       }
-
        node = acpi_ns_map_handle_to_node (target_handle);
        if (!node) {
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
+       /* Determine size required for the caller buffer */
 
-       /* Set return length to the required path length */
-
-       path_length = acpi_ns_get_pathname_length (node);
-       size = path_length - 1;
-
-       user_buf_size = *buf_size;
-       *buf_size = path_length;
+       required_size = acpi_ns_get_pathname_length (node);
 
-       /* Check if the user buffer is sufficiently large */
+       /* Validate/Allocate/Clear caller buffer */
 
-       if (path_length > user_buf_size) {
-               status = AE_BUFFER_OVERFLOW;
-               goto exit;
+       status = acpi_ut_initialize_buffer (buffer, required_size);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
        }
 
-       /* Store null terminator */
-
-       user_buffer[size] = 0;
-       size -= ACPI_NAME_SIZE;
-
-       /* Put the original ACPI name at the end of the path */
-
-       MOVE_UNALIGNED32_TO_32 ((user_buffer + size),
-                        &node->name);
-
-       user_buffer[--size] = PATH_SEPARATOR;
-
-       /* Build name backwards, putting "." between segments */
-
-       while ((size > ACPI_NAME_SIZE) && node) {
-               size -= ACPI_NAME_SIZE;
-               name = acpi_ns_find_parent_name (node);
-               MOVE_UNALIGNED32_TO_32 ((user_buffer + size), &name);
-
-               user_buffer[--size] = PATH_SEPARATOR;
-               node = acpi_ns_get_parent_object (node);
-       }
-
-       /*
-        * Overlay the "." preceding the first segment with
-        * the root name "\"
-        */
-       user_buffer[size] = '\\';
+       /* Build the path in the caller buffer */
 
-       ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Len=%X, %s \n", path_length, user_buffer));
+       acpi_ns_build_external_path (node, required_size, buffer->pointer);
 
-exit:
-       return_ACPI_STATUS (status);
+       ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s [%X] \n", (char *) buffer->pointer, required_size));
+       return_ACPI_STATUS (AE_OK);
 }
 
 
index fcc3896c56460aafb4f129c46070f70476038f40..4bf7e1788e19457c14d05f1775192956c23ae0b6 100644 (file)
@@ -2,12 +2,12 @@
  *
  * Module Name: nsobject - Utilities for objects attached to namespace
  *                         table entries
- *              $Revision: 67 $
+ *              $Revision: 78 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -33,7 +33,7 @@
 
 
 #define _COMPONENT          ACPI_NAMESPACE
-        MODULE_NAME         ("nsobject")
+        ACPI_MODULE_NAME    ("nsobject")
 
 
 /*******************************************************************************
@@ -48,6 +48,8 @@
  * DESCRIPTION: Record the given object as the value associated with the
  *              name whose acpi_handle is passed.  If Object is NULL
  *              and Type is ACPI_TYPE_ANY, set the name as having no value.
+ *              Note: Future may require that the Node->Flags field be passed
+ *              as a parameter.
  *
  * MUTEX:       Assumes namespace is locked
  *
@@ -57,45 +59,37 @@ acpi_status
 acpi_ns_attach_object (
        acpi_namespace_node     *node,
        acpi_operand_object     *object,
-       acpi_object_type8       type)
+       acpi_object_type        type)
 {
        acpi_operand_object     *obj_desc;
-       acpi_operand_object     *previous_obj_desc;
-       acpi_object_type8       obj_type = ACPI_TYPE_ANY;
-       u8                      flags;
+       acpi_operand_object     *last_obj_desc;
+       acpi_object_type        object_type = ACPI_TYPE_ANY;
 
 
-       FUNCTION_TRACE ("Ns_attach_object");
+       ACPI_FUNCTION_TRACE ("Ns_attach_object");
 
 
        /*
         * Parameter validation
         */
-       if (!acpi_gbl_root_node) {
-               /* Name space not initialized  */
-
-               REPORT_ERROR (("Ns_attach_object: Namespace not initialized\n"));
-               return_ACPI_STATUS (AE_NO_NAMESPACE);
-       }
-
        if (!node) {
                /* Invalid handle */
 
-               REPORT_ERROR (("Ns_attach_object: Null Named_obj handle\n"));
+               ACPI_REPORT_ERROR (("Ns_attach_object: Null Named_obj handle\n"));
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
        if (!object && (ACPI_TYPE_ANY != type)) {
                /* Null object */
 
-               REPORT_ERROR (("Ns_attach_object: Null object, but type not ACPI_TYPE_ANY\n"));
+               ACPI_REPORT_ERROR (("Ns_attach_object: Null object, but type not ACPI_TYPE_ANY\n"));
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
-       if (!VALID_DESCRIPTOR_TYPE (node, ACPI_DESC_TYPE_NAMED)) {
+       if (ACPI_GET_DESCRIPTOR_TYPE (node) != ACPI_DESC_TYPE_NAMED) {
                /* Not a name handle */
 
-               REPORT_ERROR (("Ns_attach_object: Invalid handle\n"));
+               ACPI_REPORT_ERROR (("Ns_attach_object: Invalid handle\n"));
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
@@ -108,42 +102,27 @@ acpi_ns_attach_object (
                return_ACPI_STATUS (AE_OK);
        }
 
-
-       /* Get the current flags field of the Node */
-
-       flags = node->flags;
-       flags &= ~ANOBJ_AML_ATTACHMENT;
-
-
        /* If null object, we will just install it */
 
        if (!object) {
-               obj_desc = NULL;
-               obj_type = ACPI_TYPE_ANY;
+               obj_desc   = NULL;
+               object_type = ACPI_TYPE_ANY;
        }
 
        /*
         * If the source object is a namespace Node with an attached object,
         * we will use that (attached) object
         */
-       else if (VALID_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_NAMED) &&
+       else if ((ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED) &&
                        ((acpi_namespace_node *) object)->object) {
                /*
                 * Value passed is a name handle and that name has a
                 * non-null value.  Use that name's value and type.
                 */
-               obj_desc = ((acpi_namespace_node *) object)->object;
-               obj_type = ((acpi_namespace_node *) object)->type;
-
-               /*
-                * Copy appropriate flags
-                */
-               if (((acpi_namespace_node *) object)->flags & ANOBJ_AML_ATTACHMENT) {
-                       flags |= ANOBJ_AML_ATTACHMENT;
-               }
+               obj_desc   = ((acpi_namespace_node *) object)->object;
+               object_type = ((acpi_namespace_node *) object)->type;
        }
 
-
        /*
         * Otherwise, we will use the parameter object, but we must type
         * it first
@@ -154,37 +133,15 @@ acpi_ns_attach_object (
                /* If a valid type (non-ANY) was given, just use it */
 
                if (ACPI_TYPE_ANY != type) {
-                       obj_type = type;
+                       object_type = type;
                }
-
                else {
-                       /*
-                        * Cannot figure out the type -- set to Def_any which
-                        * will print as an error in the name table dump
-                        */
-                       if (acpi_dbg_level > 0) {
-                               DUMP_PATHNAME (node,
-                                       "Ns_attach_object confused: setting bogus type for ",
-                                       ACPI_LV_INFO, _COMPONENT);
-
-                               if (VALID_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_NAMED)) {
-                                       DUMP_PATHNAME (object, "name ", ACPI_LV_INFO, _COMPONENT);
-                               }
-
-                               else {
-                                       DUMP_PATHNAME (object, "object ", ACPI_LV_INFO, _COMPONENT);
-                                       DUMP_STACK_ENTRY (object);
-                               }
-                       }
-
-                       obj_type = INTERNAL_TYPE_DEF_ANY;
+                       object_type = INTERNAL_TYPE_DEF_ANY;
                }
        }
 
-
        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Installing %p into Node %p [%4.4s]\n",
-               obj_desc, node, (char*)&node->name));
-
+               obj_desc, node, (char *) &node->name));
 
        /*
         * Must increment the new value's reference count
@@ -192,29 +149,28 @@ acpi_ns_attach_object (
         */
        acpi_ut_add_reference (obj_desc);
 
-       /* Save the existing object (if any) for deletion later */
+       /* Detach an existing attached object if present */
 
-       previous_obj_desc = node->object;
-
-       /* Install the object and set the type, flags */
-
-       node->object   = obj_desc;
-       node->type     = (u8) obj_type;
-       node->flags    |= flags;
+       if (node->object) {
+               acpi_ns_detach_object (node);
+       }
 
 
        /*
-        * Delete an existing attached object.
+        * Handle objects with multiple descriptors - walk
+        * to the end of the descriptor list
         */
-       if (previous_obj_desc) {
-               /* One for the attach to the Node */
+       last_obj_desc = obj_desc;
+       while (last_obj_desc->common.next_object) {
+               last_obj_desc = last_obj_desc->common.next_object;
+       }
 
-               acpi_ut_remove_reference (previous_obj_desc);
+       /* Install the object at the front of the object list */
 
-               /* Now delete */
+       last_obj_desc->common.next_object = node->object;
 
-               acpi_ut_remove_reference (previous_obj_desc);
-       }
+       node->type     = (u8) object_type;
+       node->object   = obj_desc;
 
        return_ACPI_STATUS (AE_OK);
 }
@@ -241,20 +197,32 @@ acpi_ns_detach_object (
        acpi_operand_object     *obj_desc;
 
 
-       FUNCTION_TRACE ("Ns_detach_object");
+       ACPI_FUNCTION_TRACE ("Ns_detach_object");
 
 
        obj_desc = node->object;
-       if (!obj_desc) {
+       if (!obj_desc   ||
+               (obj_desc->common.type == INTERNAL_TYPE_DATA)) {
                return_VOID;
        }
 
        /* Clear the entry in all cases */
 
        node->object = NULL;
+       if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_INTERNAL) {
+               node->object = obj_desc->common.next_object;
+               if (node->object &&
+                  (node->object->common.type != INTERNAL_TYPE_DATA)) {
+                       node->object = node->object->common.next_object;
+               }
+       }
+
+       /* Reset the node type to untyped */
 
-       ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Object=%p Value=%p Name %4.4s\n",
-               node, obj_desc, (char*)&node->name));
+       node->type = ACPI_TYPE_ANY;
+
+       ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Node %p [%4.4s] Object %p\n",
+               node, (char *) &node->name, obj_desc));
 
        /* Remove one reference on the object (and all subobjects) */
 
@@ -274,21 +242,197 @@ acpi_ns_detach_object (
  *
  ******************************************************************************/
 
-void *
+acpi_operand_object *
 acpi_ns_get_attached_object (
        acpi_namespace_node     *node)
 {
-       FUNCTION_TRACE_PTR ("Ns_get_attached_object", node);
+       ACPI_FUNCTION_TRACE_PTR ("Ns_get_attached_object", node);
 
 
        if (!node) {
-               /* handle invalid */
-
                ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Null Node ptr\n"));
                return_PTR (NULL);
        }
 
+       if (!node->object ||
+                       ((ACPI_GET_DESCRIPTOR_TYPE (node->object) != ACPI_DESC_TYPE_INTERNAL)  &&
+                        (ACPI_GET_DESCRIPTOR_TYPE (node->object) != ACPI_DESC_TYPE_NAMED))    ||
+               (node->object->common.type == INTERNAL_TYPE_DATA)) {
+               return_PTR (NULL);
+       }
+
        return_PTR (node->object);
 }
 
 
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ns_get_secondary_object
+ *
+ * PARAMETERS:  Node             - Parent Node to be examined
+ *
+ * RETURN:      Current value of the object field from the Node whose
+ *              handle is passed
+ *
+ ******************************************************************************/
+
+acpi_operand_object *
+acpi_ns_get_secondary_object (
+       acpi_operand_object     *obj_desc)
+{
+       ACPI_FUNCTION_TRACE_PTR ("Acpi_ns_get_secondary_object", obj_desc);
+
+
+       if ((!obj_desc)                                  ||
+               (obj_desc->common.type == INTERNAL_TYPE_DATA) ||
+               (!obj_desc->common.next_object)              ||
+               (obj_desc->common.next_object->common.type == INTERNAL_TYPE_DATA)) {
+               return_PTR (NULL);
+       }
+
+       return_PTR (obj_desc->common.next_object);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ns_attach_data
+ *
+ * PARAMETERS:
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION:
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ns_attach_data (
+       acpi_namespace_node     *node,
+       ACPI_OBJECT_HANDLER     handler,
+       void                    *data)
+{
+       acpi_operand_object     *prev_obj_desc;
+       acpi_operand_object     *obj_desc;
+       acpi_operand_object     *data_desc;
+
+
+       /* */
+       prev_obj_desc = NULL;
+       obj_desc = node->object;
+       while (obj_desc) {
+               if ((obj_desc->common.type == INTERNAL_TYPE_DATA) &&
+                       (obj_desc->data.handler == handler)) {
+                       return (AE_ALREADY_EXISTS);
+               }
+
+               prev_obj_desc = obj_desc;
+               obj_desc = obj_desc->common.next_object;
+       }
+
+
+       /* Create an internal object for the data */
+
+       data_desc = acpi_ut_create_internal_object (INTERNAL_TYPE_DATA);
+       if (!data_desc) {
+               return (AE_NO_MEMORY);
+       }
+
+       data_desc->data.handler = handler;
+       data_desc->data.pointer = data;
+
+
+       /* Install the data object */
+
+       if (prev_obj_desc) {
+               prev_obj_desc->common.next_object = data_desc;
+       }
+       else {
+               node->object = data_desc;
+       }
+
+       return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ns_detach_data
+ *
+ * PARAMETERS:
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION:
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ns_detach_data (
+       acpi_namespace_node     *node,
+       ACPI_OBJECT_HANDLER     handler)
+{
+       acpi_operand_object     *obj_desc;
+       acpi_operand_object     *prev_obj_desc;
+
+
+       prev_obj_desc = NULL;
+       obj_desc = node->object;
+       while (obj_desc) {
+               if ((obj_desc->common.type == INTERNAL_TYPE_DATA) &&
+                       (obj_desc->data.handler == handler)) {
+                       if (prev_obj_desc) {
+                               prev_obj_desc->common.next_object = obj_desc->common.next_object;
+                       }
+                       else {
+                               node->object = obj_desc->common.next_object;
+                       }
+
+                       acpi_ut_remove_reference (obj_desc);
+                       return (AE_OK);
+               }
+
+               prev_obj_desc = obj_desc;
+               obj_desc = obj_desc->common.next_object;
+       }
+
+       return (AE_NOT_FOUND);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ns_get_attached_data
+ *
+ * PARAMETERS:
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION:
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ns_get_attached_data (
+       acpi_namespace_node     *node,
+       ACPI_OBJECT_HANDLER     handler,
+       void                    **data)
+{
+       acpi_operand_object     *obj_desc;
+
+
+       obj_desc = node->object;
+       while (obj_desc) {
+               if ((obj_desc->common.type == INTERNAL_TYPE_DATA) &&
+                       (obj_desc->data.handler == handler)) {
+                       *data = obj_desc->data.pointer;
+                       return (AE_OK);
+               }
+
+               obj_desc = obj_desc->common.next_object;
+       }
+
+       return (AE_NOT_FOUND);
+}
+
+
index 5bcd431fab2e8ee203e04734a67ed39e0c104ded..47217f059fb8ae3706120e0af821517ed275b2c2 100644 (file)
@@ -1,12 +1,12 @@
 /*******************************************************************************
  *
  * Module Name: nssearch - Namespace search
- *              $Revision: 75 $
+ *              $Revision: 83 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -31,7 +31,7 @@
 
 
 #define _COMPONENT          ACPI_NAMESPACE
-        MODULE_NAME         ("nssearch")
+        ACPI_MODULE_NAME    ("nssearch")
 
 
 /*******************************************************************************
@@ -64,30 +64,29 @@ acpi_status
 acpi_ns_search_node (
        u32                     target_name,
        acpi_namespace_node     *node,
-       acpi_object_type8       type,
+       acpi_object_type        type,
        acpi_namespace_node     **return_node)
 {
        acpi_namespace_node     *next_node;
 
 
-       FUNCTION_TRACE ("Ns_search_node");
+       ACPI_FUNCTION_TRACE ("Ns_search_node");
 
 
 #ifdef ACPI_DEBUG
        if (ACPI_LV_NAMES & acpi_dbg_level) {
                NATIVE_CHAR         *scope_name;
 
-               scope_name = acpi_ns_get_table_pathname (node);
+               scope_name = acpi_ns_get_external_pathname (node);
                if (scope_name) {
-                       ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Searching %s [%p] For %4.4s (type %X)\n",
-                               scope_name, node, (char*)&target_name, type));
+                       ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Searching %s [%p] For %4.4s (type %s)\n",
+                               scope_name, node, (char *) &target_name, acpi_ut_get_type_name (type)));
 
                        ACPI_MEM_FREE (scope_name);
                }
        }
 #endif
 
-
        /*
         * Search for name in this table, which is to say that we must search
         * for the name among the children of this object
@@ -123,14 +122,13 @@ acpi_ns_search_node (
                        }
 
                        ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
-                               "Name %4.4s (actual type %X) found at %p\n",
-                               (char*)&target_name, next_node->type, next_node));
+                               "Name %4.4s Type [%s] found at %p\n",
+                               (char *) &target_name, acpi_ut_get_type_name (next_node->type), next_node));
 
                        *return_node = next_node;
                        return_ACPI_STATUS (AE_OK);
                }
 
-
                /*
                 * The last entry in the list points back to the parent,
                 * so a flag is used to indicate the end-of-list
@@ -146,11 +144,10 @@ acpi_ns_search_node (
                next_node = next_node->peer;
        }
 
-
        /* Searched entire table, not found */
 
        ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Name %4.4s (type %X) not found at %p\n",
-               (char*)&target_name, type, next_node));
+               (char *) &target_name, type, next_node));
 
        return_ACPI_STATUS (AE_NOT_FOUND);
 }
@@ -185,17 +182,17 @@ static acpi_status
 acpi_ns_search_parent_tree (
        u32                     target_name,
        acpi_namespace_node     *node,
-       acpi_object_type8       type,
+       acpi_object_type        type,
        acpi_namespace_node     **return_node)
 {
        acpi_status             status;
        acpi_namespace_node     *parent_node;
 
 
-       FUNCTION_TRACE ("Ns_search_parent_tree");
+       ACPI_FUNCTION_TRACE ("Ns_search_parent_tree");
 
 
-       parent_node = acpi_ns_get_parent_object (node);
+       parent_node = acpi_ns_get_parent_node (node);
 
        /*
         * If there is no parent (at the root) or type is "local", we won't be
@@ -205,33 +202,33 @@ acpi_ns_search_parent_tree (
                (!parent_node)) {
                if (!parent_node) {
                        ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[%4.4s] has no parent\n",
-                               (char*)&target_name));
+                               (char *) &target_name));
                }
 
                if (acpi_ns_local (type)) {
                        ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[%4.4s] type %X is local(no search)\n",
-                               (char*)&target_name, type));
+                               (char *) &target_name, type));
                }
 
                return_ACPI_STATUS (AE_NOT_FOUND);
        }
 
-
        /* Search the parent tree */
 
-       ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Searching parent for %4.4s\n", (char*)&target_name));
+       ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Searching parent for %4.4s\n", (char *) &target_name));
 
        /*
         * Search parents until found the target or we have backed up to
         * the root
         */
        while (parent_node) {
-               /* Search parent scope */
-               /* TBD: [Investigate] Why ACPI_TYPE_ANY? */
-
+               /*
+                * Search parent scope.  Use TYPE_ANY because we don't care about the
+                * object type at this point, we only care about the existence of
+                * the actual name we are searching for.  Typechecking comes later.
+                */
                status = acpi_ns_search_node (target_name, parent_node,
                                   ACPI_TYPE_ANY, return_node);
-
                if (ACPI_SUCCESS (status)) {
                        return_ACPI_STATUS (status);
                }
@@ -240,10 +237,9 @@ acpi_ns_search_parent_tree (
                 * Not found here, go up another level
                 * (until we reach the root)
                 */
-               parent_node = acpi_ns_get_parent_object (parent_node);
+               parent_node = acpi_ns_get_parent_node (parent_node);
        }
 
-
        /* Not found in parent tree */
 
        return_ACPI_STATUS (AE_NOT_FOUND);
@@ -280,8 +276,8 @@ acpi_ns_search_and_enter (
        u32                     target_name,
        acpi_walk_state         *walk_state,
        acpi_namespace_node     *node,
-       operating_mode          interpreter_mode,
-       acpi_object_type8       type,
+       acpi_interpreter_mode   interpreter_mode,
+       acpi_object_type        type,
        u32                     flags,
        acpi_namespace_node     **return_node)
 {
@@ -289,7 +285,7 @@ acpi_ns_search_and_enter (
        acpi_namespace_node     *new_node;
 
 
-       FUNCTION_TRACE ("Ns_search_and_enter");
+       ACPI_FUNCTION_TRACE ("Ns_search_and_enter");
 
 
        /* Parameter validation */
@@ -298,25 +294,23 @@ acpi_ns_search_and_enter (
                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null param-  Table %p Name %X Return %p\n",
                        node, target_name, return_node));
 
-               REPORT_ERROR (("Ns_search_and_enter: bad (null) parameter\n"));
+               ACPI_REPORT_ERROR (("Ns_search_and_enter: bad (null) parameter\n"));
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
-
        /* Name must consist of printable characters */
 
        if (!acpi_ut_valid_acpi_name (target_name)) {
                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "*** Bad character in name: %08x *** \n",
                        target_name));
 
-               REPORT_ERROR (("Ns_search_and_enter: Bad character in ACPI Name\n"));
+               ACPI_REPORT_ERROR (("Ns_search_and_enter: Bad character in ACPI Name\n"));
                return_ACPI_STATUS (AE_BAD_CHARACTER);
        }
 
-
        /* Try to find the name in the table specified by the caller */
 
-       *return_node = ENTRY_NOT_FOUND;
+       *return_node = ACPI_ENTRY_NOT_FOUND;
        status = acpi_ns_search_node (target_name, node, type, return_node);
        if (status != AE_NOT_FOUND) {
                /*
@@ -324,8 +318,8 @@ acpi_ns_search_and_enter (
                 * return the error
                 */
                if ((status == AE_OK) &&
-                       (flags & NS_ERROR_IF_FOUND)) {
-                       status = AE_EXIST;
+                       (flags & ACPI_NS_ERROR_IF_FOUND)) {
+                       status = AE_ALREADY_EXISTS;
                }
 
                /*
@@ -335,9 +329,8 @@ acpi_ns_search_and_enter (
                return_ACPI_STATUS (status);
        }
 
-
        /*
-        * Not found in the table.  If we are NOT performing the
+        * The name was not found.  If we are NOT performing the
         * first pass (name entry) of loading the namespace, search
         * the parent tree (all the way to the root if necessary.)
         * We don't want to perform the parent search when the
@@ -345,8 +338,8 @@ acpi_ns_search_and_enter (
         * the search when namespace references are being resolved
         * (load pass 2) and during the execution phase.
         */
-       if ((interpreter_mode != IMODE_LOAD_PASS1) &&
-               (flags & NS_SEARCH_PARENT)) {
+       if ((interpreter_mode != ACPI_IMODE_LOAD_PASS1) &&
+               (flags & ACPI_NS_SEARCH_PARENT)) {
                /*
                 * Not found in table - search parent tree according
                 * to ACPI specification
@@ -358,18 +351,16 @@ acpi_ns_search_and_enter (
                }
        }
 
-
        /*
         * In execute mode, just search, never add names.  Exit now.
         */
-       if (interpreter_mode == IMODE_EXECUTE) {
+       if (interpreter_mode == ACPI_IMODE_EXECUTE) {
                ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%4.4s Not found in %p [Not adding]\n",
-                       (char*)&target_name, node));
+                       (char *) &target_name, node));
 
                return_ACPI_STATUS (AE_NOT_FOUND);
        }
 
-
        /* Create the new named object */
 
        new_node = acpi_ns_create_node (target_name);
index 448dba65af3276fd9d9216c8fcaedcc75ed388ba..d9b23690f2618111ebdea2426b54ed1d9dcff34a 100644 (file)
@@ -2,12 +2,12 @@
  *
  * Module Name: nsutils - Utilities for accessing ACPI namespace, accessing
  *                        parents and siblings and Scope manipulation
- *              $Revision: 92 $
+ *              $Revision: 104 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -32,7 +32,7 @@
 #include "actables.h"
 
 #define _COMPONENT          ACPI_NAMESPACE
-        MODULE_NAME         ("nsutils")
+        ACPI_MODULE_NAME    ("nsutils")
 
 
 /*******************************************************************************
@@ -87,19 +87,19 @@ acpi_ns_valid_path_separator (
  *
  ******************************************************************************/
 
-acpi_object_type8
+acpi_object_type
 acpi_ns_get_type (
        acpi_namespace_node     *node)
 {
-       FUNCTION_TRACE ("Ns_get_type");
+       ACPI_FUNCTION_TRACE ("Ns_get_type");
 
 
        if (!node) {
-               REPORT_WARNING (("Ns_get_type: Null Node ptr"));
+               ACPI_REPORT_WARNING (("Ns_get_type: Null Node ptr"));
                return_VALUE (ACPI_TYPE_ANY);
        }
 
-       return_VALUE (node->type);
+       return_VALUE ((acpi_object_type) node->type);
 }
 
 
@@ -116,19 +116,19 @@ acpi_ns_get_type (
 
 u32
 acpi_ns_local (
-       acpi_object_type8       type)
+       acpi_object_type        type)
 {
-       FUNCTION_TRACE ("Ns_local");
+       ACPI_FUNCTION_TRACE ("Ns_local");
 
 
        if (!acpi_ut_valid_object_type (type)) {
                /* Type code out of range  */
 
-               REPORT_WARNING (("Ns_local: Invalid Object Type\n"));
-               return_VALUE (NSP_NORMAL);
+               ACPI_REPORT_WARNING (("Ns_local: Invalid Object Type\n"));
+               return_VALUE (ACPI_NS_NORMAL);
        }
 
-       return_VALUE ((u32) acpi_gbl_ns_properties[type] & NSP_LOCAL);
+       return_VALUE ((u32) acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL);
 }
 
 
@@ -154,7 +154,7 @@ acpi_ns_get_internal_name_length (
        u32                     i;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        next_external_char = info->external_name;
@@ -175,7 +175,6 @@ acpi_ns_get_internal_name_length (
                info->fully_qualified = TRUE;
                next_external_char++;
        }
-
        else {
                /*
                 * Handle Carat prefixes
@@ -234,7 +233,7 @@ acpi_ns_build_internal_name (
        u32                     i;
 
 
-       FUNCTION_TRACE ("Ns_build_internal_name");
+       ACPI_FUNCTION_TRACE ("Ns_build_internal_name");
 
 
        /* Setup the correct prefixes, counts, and pointers */
@@ -268,15 +267,13 @@ acpi_ns_build_internal_name (
                        }
                }
 
-               if (num_segments == 1) {
+               if (num_segments <= 1) {
                        result = &internal_name[i];
                }
-
                else if (num_segments == 2) {
                        internal_name[i] = AML_DUAL_NAME_PREFIX;
                        result = &internal_name[i+1];
                }
-
                else {
                        internal_name[i] = AML_MULTI_NAME_PREFIX_OP;
                        internal_name[i+1] = (char) num_segments;
@@ -295,11 +292,10 @@ acpi_ns_build_internal_name (
 
                                result[i] = '_';
                        }
-
                        else {
                                /* Convert the character to uppercase and save it */
 
-                               result[i] = (char) TOUPPER (*external_name);
+                               result[i] = (char) ACPI_TOUPPER (*external_name);
                                external_name++;
                        }
                }
@@ -317,7 +313,6 @@ acpi_ns_build_internal_name (
                result += ACPI_NAME_SIZE;
        }
 
-
        /* Terminate the string */
 
        *result = 0;
@@ -360,7 +355,7 @@ acpi_ns_internalize_name (
        acpi_status             status;
 
 
-       FUNCTION_TRACE ("Ns_internalize_name");
+       ACPI_FUNCTION_TRACE ("Ns_internalize_name");
 
 
        if ((!external_name)     ||
@@ -369,7 +364,6 @@ acpi_ns_internalize_name (
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
-
        /* Get the length of the new internal name */
 
        info.external_name = external_name;
@@ -420,22 +414,21 @@ acpi_ns_externalize_name (
 {
        u32                     prefix_length = 0;
        u32                     names_index = 0;
-       u32                     names_count = 0;
+       u32                     num_segments = 0;
        u32                     i = 0;
        u32                     j = 0;
+       u32                     required_length;
 
 
-       FUNCTION_TRACE ("Ns_externalize_name");
+       ACPI_FUNCTION_TRACE ("Ns_externalize_name");
 
 
        if (!internal_name_length   ||
                !internal_name          ||
-               !converted_name_length  ||
                !converted_name) {
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
-
        /*
         * Check for a prefix (one '\' | one or more '^').
         */
@@ -464,36 +457,36 @@ acpi_ns_externalize_name (
         */
        if (prefix_length < internal_name_length) {
                switch (internal_name[prefix_length]) {
+               case AML_MULTI_NAME_PREFIX_OP:
 
-               /* <count> 4-byte names */
+                       /* <count> 4-byte names */
 
-               case AML_MULTI_NAME_PREFIX_OP:
                        names_index = prefix_length + 2;
-                       names_count = (u32) internal_name[prefix_length + 1];
+                       num_segments = (u32) (u8) internal_name[prefix_length + 1];
                        break;
 
+               case AML_DUAL_NAME_PREFIX:
 
-               /* two 4-byte names */
+                       /* Two 4-byte names */
 
-               case AML_DUAL_NAME_PREFIX:
                        names_index = prefix_length + 1;
-                       names_count = 2;
+                       num_segments = 2;
                        break;
 
+               case 0:
 
-               /* Null_name */
+                       /* Null_name */
 
-               case 0:
                        names_index = 0;
-                       names_count = 0;
+                       num_segments = 0;
                        break;
 
+               default:
 
-               /* one 4-byte name */
+                       /* one 4-byte name */
 
-               default:
                        names_index = prefix_length;
-                       names_count = 1;
+                       num_segments = 1;
                        break;
                }
        }
@@ -503,23 +496,22 @@ acpi_ns_externalize_name (
         * of the prefix, length of all object names, length of any required
         * punctuation ('.') between object names, plus the NULL terminator.
         */
-       *converted_name_length = prefix_length + (4 * names_count) +
-                          ((names_count > 0) ? (names_count - 1) : 0) + 1;
+       required_length = prefix_length + (4 * num_segments) +
+                          ((num_segments > 0) ? (num_segments - 1) : 0) + 1;
 
        /*
         * Check to see if we're still in bounds.  If not, there's a problem
         * with Internal_name (invalid format).
         */
-       if (*converted_name_length > internal_name_length) {
-               REPORT_ERROR (("Ns_externalize_name: Invalid internal name\n"));
+       if (required_length > internal_name_length) {
+               ACPI_REPORT_ERROR (("Ns_externalize_name: Invalid internal name\n"));
                return_ACPI_STATUS (AE_BAD_PATHNAME);
        }
 
        /*
         * Build Converted_name...
         */
-
-       (*converted_name) = ACPI_MEM_CALLOCATE (*converted_name_length);
+       *converted_name = ACPI_MEM_CALLOCATE (required_length);
        if (!(*converted_name)) {
                return_ACPI_STATUS (AE_NO_MEMORY);
        }
@@ -530,8 +522,8 @@ acpi_ns_externalize_name (
                (*converted_name)[j++] = internal_name[i];
        }
 
-       if (names_count > 0) {
-               for (i = 0; i < names_count; i++) {
+       if (num_segments > 0) {
+               for (i = 0; i < num_segments; i++) {
                        if (i > 0) {
                                (*converted_name)[j++] = '.';
                        }
@@ -543,6 +535,10 @@ acpi_ns_externalize_name (
                }
        }
 
+       if (converted_name_length) {
+               *converted_name_length = required_length;
+       }
+
        return_ACPI_STATUS (AE_OK);
 }
 
@@ -557,6 +553,9 @@ acpi_ns_externalize_name (
  *
  * DESCRIPTION: Convert a namespace handle to a real Node
  *
+ * Note: Real integer handles allow for more verification
+ *       and keep all pointers within this subsystem.
+ *
  ******************************************************************************/
 
 acpi_namespace_node *
@@ -564,13 +563,11 @@ acpi_ns_map_handle_to_node (
        acpi_handle             handle)
 {
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        /*
-        * Simple implementation for now;
-        * TBD: [Future] Real integer handles allow for more verification
-        * and keep all pointers within this subsystem!
+        * Simple implementation.
         */
        if (!handle) {
                return (NULL);
@@ -580,10 +577,9 @@ acpi_ns_map_handle_to_node (
                return (acpi_gbl_root_node);
        }
 
-
        /* We can at least attempt to verify the handle */
 
-       if (!VALID_DESCRIPTOR_TYPE (handle, ACPI_DESC_TYPE_NAMED)) {
+       if (ACPI_GET_DESCRIPTOR_TYPE (handle) != ACPI_DESC_TYPE_NAMED) {
                return (NULL);
        }
 
@@ -611,8 +607,6 @@ acpi_ns_convert_entry_to_handle (
 
        /*
         * Simple implementation for now;
-        * TBD: [Future] Real integer handles allow for more verification
-        * and keep all pointers within this subsystem!
         */
        return ((acpi_handle) node);
 
@@ -654,7 +648,7 @@ acpi_ns_terminate (void)
        acpi_namespace_node     *this_node;
 
 
-       FUNCTION_TRACE ("Ns_terminate");
+       ACPI_FUNCTION_TRACE ("Ns_terminate");
 
 
        this_node = acpi_gbl_root_node;
@@ -702,25 +696,25 @@ acpi_ns_terminate (void)
 
 u32
 acpi_ns_opens_scope (
-       acpi_object_type8       type)
+       acpi_object_type        type)
 {
-       FUNCTION_TRACE_U32 ("Ns_opens_scope", type);
+       ACPI_FUNCTION_TRACE_U32 ("Ns_opens_scope", type);
 
 
        if (!acpi_ut_valid_object_type (type)) {
                /* type code out of range  */
 
-               REPORT_WARNING (("Ns_opens_scope: Invalid Object Type\n"));
-               return_VALUE (NSP_NORMAL);
+               ACPI_REPORT_WARNING (("Ns_opens_scope: Invalid Object Type %X\n", type));
+               return_VALUE (ACPI_NS_NORMAL);
        }
 
-       return_VALUE (((u32) acpi_gbl_ns_properties[type]) & NSP_NEWSCOPE);
+       return_VALUE (((u32) acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_get_node
+ * FUNCTION:    Acpi_ns_get_node_by_path
  *
  * PARAMETERS:  *Pathname   - Name to be found, in external (ASL) format. The
  *                            \ (backslash) and ^ (carat) prefixes, and the
@@ -729,6 +723,8 @@ acpi_ns_opens_scope (
  *                            root of the name space.  If Name is fully
  *                            qualified (first s8 is '\'), the passed value
  *                            of Scope will not be accessed.
+ *              Flags       - Used to indicate whether to perform upsearch or
+ *                            not.
  *              Return_node - Where the Node is returned
  *
  * DESCRIPTION: Look up a name relative to a given scope and return the
@@ -739,9 +735,10 @@ acpi_ns_opens_scope (
  ******************************************************************************/
 
 acpi_status
-acpi_ns_get_node (
+acpi_ns_get_node_by_path (
        NATIVE_CHAR             *pathname,
        acpi_namespace_node     *start_node,
+       u32                     flags,
        acpi_namespace_node     **return_node)
 {
        acpi_generic_state      scope_info;
@@ -749,20 +746,13 @@ acpi_ns_get_node (
        NATIVE_CHAR             *internal_path = NULL;
 
 
-       FUNCTION_TRACE_PTR ("Ns_get_node", pathname);
+       ACPI_FUNCTION_TRACE_PTR ("Ns_get_node_by_path", pathname);
 
 
-       /* Ensure that the namespace has been initialized */
-
-       if (!acpi_gbl_root_node) {
-               return_ACPI_STATUS (AE_NO_NAMESPACE);
-       }
-
        if (!pathname) {
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
-
        /* Convert path to internal representation */
 
        status = acpi_ns_internalize_name (pathname, &internal_path);
@@ -770,8 +760,12 @@ acpi_ns_get_node (
                return_ACPI_STATUS (status);
        }
 
+       /* Must lock namespace during lookup */
 
-       acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
 
        /* Setup lookup scope (search starting point) */
 
@@ -780,20 +774,17 @@ acpi_ns_get_node (
        /* Lookup the name in the namespace */
 
        status = acpi_ns_lookup (&scope_info, internal_path,
-                        ACPI_TYPE_ANY, IMODE_EXECUTE,
-                        NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE,
+                        ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
+                        (flags | ACPI_NS_DONT_OPEN_SCOPE),
                         NULL, return_node);
-
        if (ACPI_FAILURE (status)) {
                ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s, %s\n",
                                internal_path, acpi_format_exception (status)));
        }
 
-
-       acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
-
        /* Cleanup */
 
+       (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
        ACPI_MEM_FREE (internal_path);
        return_ACPI_STATUS (status);
 }
@@ -820,16 +811,17 @@ acpi_ns_find_parent_name (
        acpi_namespace_node     *parent_node;
 
 
-       FUNCTION_TRACE ("Ns_find_parent_name");
+       ACPI_FUNCTION_TRACE ("Ns_find_parent_name");
 
 
        if (child_node) {
                /* Valid entry.  Get the parent Node */
 
-               parent_node = acpi_ns_get_parent_object (child_node);
+               parent_node = acpi_ns_get_parent_node (child_node);
                if (parent_node) {
                        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Parent of %p [%4.4s] is %p [%4.4s]\n",
-                               child_node, (char*)&child_node->name, parent_node, (char*)&parent_node->name));
+                               child_node, (char *) &child_node->name,
+                               parent_node, (char *) &parent_node->name));
 
                        if (parent_node->name) {
                                return_VALUE (parent_node->name);
@@ -837,7 +829,7 @@ acpi_ns_find_parent_name (
                }
 
                ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "unable to find parent of %p (%4.4s)\n",
-                       child_node, (char*)&child_node->name));
+                       child_node, (char *) &child_node->name));
        }
 
        return_VALUE (ACPI_UNKNOWN_NAME);
@@ -883,7 +875,7 @@ acpi_ns_exist_downstream_sibling (
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ns_get_parent_object
+ * FUNCTION:    Acpi_ns_get_parent_node
  *
  * PARAMETERS:  Node       - Current table entry
  *
@@ -895,12 +887,10 @@ acpi_ns_exist_downstream_sibling (
 
 
 acpi_namespace_node *
-acpi_ns_get_parent_object (
+acpi_ns_get_parent_node (
        acpi_namespace_node     *node)
 {
-
-
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        if (!node) {
index c006ec2d7150e661f7d6f57ee3e7d6f3152eef79..4cfcef7e0ef962d2377951539418a90b20d79945 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: nswalk - Functions for walking the ACPI namespace
- *              $Revision: 26 $
+ *              $Revision: 32 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@
 
 
 #define _COMPONENT          ACPI_NAMESPACE
-        MODULE_NAME         ("nswalk")
+        ACPI_MODULE_NAME    ("nswalk")
 
 
 /*******************************************************************************
 
 acpi_namespace_node *
 acpi_ns_get_next_node (
-       acpi_object_type8       type,
+       acpi_object_type        type,
        acpi_namespace_node     *parent_node,
        acpi_namespace_node     *child_node)
 {
        acpi_namespace_node     *next_node = NULL;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        if (!child_node) {
@@ -138,7 +138,7 @@ acpi_ns_get_next_node (
 
 acpi_status
 acpi_ns_walk_namespace (
-       acpi_object_type8       type,
+       acpi_object_type        type,
        acpi_handle             start_node,
        u32                     max_depth,
        u8                      unlock_before_callback,
@@ -149,11 +149,11 @@ acpi_ns_walk_namespace (
        acpi_status             status;
        acpi_namespace_node     *child_node;
        acpi_namespace_node     *parent_node;
-       acpi_object_type8        child_type;
+       acpi_object_type        child_type;
        u32                     level;
 
 
-       FUNCTION_TRACE ("Ns_walk_namespace");
+       ACPI_FUNCTION_TRACE ("Ns_walk_namespace");
 
 
        /* Special case for the namespace Root Node */
@@ -194,14 +194,20 @@ acpi_ns_walk_namespace (
                                 * callback function
                                 */
                                if (unlock_before_callback) {
-                                       acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+                                       status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+                                       if (ACPI_FAILURE (status)) {
+                                               return_ACPI_STATUS (status);
+                                       }
                                }
 
                                status = user_function (child_node, level,
                                                 context, return_value);
 
                                if (unlock_before_callback) {
-                                       acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+                                       status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+                                       if (ACPI_FAILURE (status)) {
+                                               return_ACPI_STATUS (status);
+                                       }
                                }
 
                                switch (status) {
@@ -216,14 +222,12 @@ acpi_ns_walk_namespace (
                                        /* Exit now, with OK status */
 
                                        return_ACPI_STATUS (AE_OK);
-                                       break;
 
                                default:
 
                                        /* All others are valid exceptions */
 
                                        return_ACPI_STATUS (status);
-                                       break;
                                }
                        }
 
@@ -247,7 +251,6 @@ acpi_ns_walk_namespace (
                                }
                        }
                }
-
                else {
                        /*
                         * No more children of this node (Acpi_ns_get_next_node
@@ -256,7 +259,7 @@ acpi_ns_walk_namespace (
                         */
                        level--;
                        child_node = parent_node;
-                       parent_node = acpi_ns_get_parent_object (parent_node);
+                       parent_node = acpi_ns_get_parent_node (parent_node);
                }
        }
 
index 17bd2b2ebc7879271fdba186de4e811e8b7d1e26..194c6c7fdfa167f2426acfd75857273dd5cd76cf 100644 (file)
@@ -2,12 +2,12 @@
  *
  * Module Name: nsxfname - Public interfaces to the ACPI subsystem
  *                         ACPI Namespace oriented interfaces
- *              $Revision: 82 $
+ *              $Revision: 89 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -35,7 +35,7 @@
 
 
 #define _COMPONENT          ACPI_NAMESPACE
-        MODULE_NAME         ("nsxfname")
+        ACPI_MODULE_NAME    ("nsxfname")
 
 
 /****************************************************************************
@@ -67,7 +67,7 @@ acpi_get_handle (
        acpi_namespace_node     *prefix_node = NULL;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        /* Parameter Validation */
@@ -79,20 +79,26 @@ acpi_get_handle (
        /* Convert a parent handle to a prefix node */
 
        if (parent) {
-               acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+               status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+               if (ACPI_FAILURE (status)) {
+                       return (status);
+               }
 
                prefix_node = acpi_ns_map_handle_to_node (parent);
                if (!prefix_node) {
-                       acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+                       (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
                        return (AE_BAD_PARAMETER);
                }
 
-               acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+               status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+               if (ACPI_FAILURE (status)) {
+                       return (status);
+               }
        }
 
        /* Special case for root, since we can't search for it */
 
-       if (STRCMP (pathname, NS_ROOT_PATH) == 0) {
+       if (ACPI_STRCMP (pathname, ACPI_NS_ROOT_PATH) == 0) {
                *ret_handle = acpi_ns_convert_entry_to_handle (acpi_gbl_root_node);
                return (AE_OK);
        }
@@ -100,7 +106,7 @@ acpi_get_handle (
        /*
         *  Find the Node and convert to a handle
         */
-       status = acpi_ns_get_node (pathname, prefix_node, &node);
+       status = acpi_ns_get_node_by_path (pathname, prefix_node, ACPI_NS_NO_UPSEARCH, &node);
 
        *ret_handle = NULL;
        if (ACPI_SUCCESS (status)) {
@@ -117,7 +123,7 @@ acpi_get_handle (
  *
  * PARAMETERS:  Handle          - Handle to be converted to a pathname
  *              Name_type       - Full pathname or single segment
- *              Ret_path_ptr    - Buffer for returned path
+ *              Buffer          - Buffer for returned path
  *
  * RETURN:      Pointer to a string containing the fully qualified Name.
  *
@@ -131,63 +137,63 @@ acpi_status
 acpi_get_name (
        acpi_handle             handle,
        u32                     name_type,
-       acpi_buffer             *ret_path_ptr)
+       acpi_buffer             *buffer)
 {
        acpi_status             status;
        acpi_namespace_node     *node;
 
 
-       /* Buffer pointer must be valid always */
+       /* Parameter validation */
 
-       if (!ret_path_ptr || (name_type > ACPI_NAME_TYPE_MAX)) {
+       if (name_type > ACPI_NAME_TYPE_MAX) {
                return (AE_BAD_PARAMETER);
        }
 
-       /* Allow length to be zero and ignore the pointer */
-
-       if ((ret_path_ptr->length) &&
-          (!ret_path_ptr->pointer)) {
-               return (AE_BAD_PARAMETER);
+       status = acpi_ut_validate_buffer (buffer);
+       if (ACPI_FAILURE (status)) {
+               return (status);
        }
 
        if (name_type == ACPI_FULL_PATHNAME) {
                /* Get the full pathname (From the namespace root) */
 
-               status = acpi_ns_handle_to_pathname (handle, &ret_path_ptr->length,
-                                  ret_path_ptr->pointer);
+               status = acpi_ns_handle_to_pathname (handle, buffer);
                return (status);
        }
 
        /*
         * Wants the single segment ACPI name.
-        * Validate handle and convert to an Node
+        * Validate handle and convert to a namespace Node
         */
-       acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE (status)) {
+               return (status);
+       }
+
        node = acpi_ns_map_handle_to_node (handle);
        if (!node) {
                status = AE_BAD_PARAMETER;
                goto unlock_and_exit;
        }
 
-       /* Check if name will fit in buffer */
+       /* Validate/Allocate/Clear caller buffer */
 
-       if (ret_path_ptr->length < PATH_SEGMENT_LENGTH) {
-               ret_path_ptr->length = PATH_SEGMENT_LENGTH;
-               status = AE_BUFFER_OVERFLOW;
+       status = acpi_ut_initialize_buffer (buffer, PATH_SEGMENT_LENGTH);
+       if (ACPI_FAILURE (status)) {
                goto unlock_and_exit;
        }
 
        /* Just copy the ACPI name from the Node and zero terminate it */
 
-       STRNCPY (ret_path_ptr->pointer, (NATIVE_CHAR *) &node->name,
+       ACPI_STRNCPY (buffer->pointer, (NATIVE_CHAR *) &node->name,
                         ACPI_NAME_SIZE);
-       ((NATIVE_CHAR *) ret_path_ptr->pointer) [ACPI_NAME_SIZE] = 0;
+       ((NATIVE_CHAR *) buffer->pointer) [ACPI_NAME_SIZE] = 0;
        status = AE_OK;
 
 
 unlock_and_exit:
 
-       acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+       (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
        return (status);
 }
 
@@ -226,18 +232,24 @@ acpi_get_object_info (
                return (AE_BAD_PARAMETER);
        }
 
-       acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE (status)) {
+               return (status);
+       }
 
        node = acpi_ns_map_handle_to_node (handle);
        if (!node) {
-               acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+               (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
                return (AE_BAD_PARAMETER);
        }
 
        info->type      = node->type;
        info->name      = node->name;
 
-       acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+       status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE (status)) {
+               return (status);
+       }
 
        /*
         * If not a device, we are all done.
@@ -260,8 +272,7 @@ acpi_get_object_info (
 
        status = acpi_ut_execute_HID (node, &hid);
        if (ACPI_SUCCESS (status)) {
-               STRNCPY (info->hardware_id, hid.buffer, sizeof(info->hardware_id));
-
+               ACPI_STRNCPY (info->hardware_id, hid.buffer, sizeof(info->hardware_id));
                info->valid |= ACPI_VALID_HID;
        }
 
@@ -269,8 +280,7 @@ acpi_get_object_info (
 
        status = acpi_ut_execute_UID (node, &uid);
        if (ACPI_SUCCESS (status)) {
-               STRCPY (info->unique_id, uid.buffer);
-
+               ACPI_STRCPY (info->unique_id, uid.buffer);
                info->valid |= ACPI_VALID_UID;
        }
 
index e3299c5488fb168f9729e65535ec103b83dc88d4..3f88c8edd79c3b10297e069540a4c9a52b4e7446 100644 (file)
@@ -2,12 +2,12 @@
  *
  * Module Name: nsxfobj - Public interfaces to the ACPI subsystem
  *                         ACPI Object oriented interfaces
- *              $Revision: 95 $
+ *              $Revision: 108 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -32,7 +32,7 @@
 
 
 #define _COMPONENT          ACPI_NAMESPACE
-        MODULE_NAME         ("nsxfobj")
+        ACPI_MODULE_NAME    ("nsxfobj")
 
 
 /*******************************************************************************
@@ -65,12 +65,11 @@ acpi_evaluate_object (
        acpi_status             status;
        acpi_operand_object     **internal_params = NULL;
        acpi_operand_object     *internal_return_obj = NULL;
-       u32                     buffer_space_needed;
-       u32                     user_buffer_length;
+       ACPI_SIZE               buffer_space_needed;
        u32                     i;
 
 
-       FUNCTION_TRACE ("Acpi_evaluate_object");
+       ACPI_FUNCTION_TRACE ("Acpi_evaluate_object");
 
 
        /*
@@ -83,12 +82,12 @@ acpi_evaluate_object (
                 * Allocate a new parameter block for the internal objects
                 * Add 1 to count to allow for null terminated internal list
                 */
-               internal_params = ACPI_MEM_CALLOCATE ((external_params->count + 1) * sizeof (void *));
+               internal_params = ACPI_MEM_CALLOCATE ((external_params->count + 1) *
+                                 sizeof (void *));
                if (!internal_params) {
                        return_ACPI_STATUS (AE_NO_MEMORY);
                }
 
-
                /*
                 * Convert each external object in the list to an
                 * internal object
@@ -96,7 +95,6 @@ acpi_evaluate_object (
                for (i = 0; i < external_params->count; i++) {
                        status = acpi_ut_copy_eobject_to_iobject (&external_params->pointer[i],
                                         &internal_params[i]);
-
                        if (ACPI_FAILURE (status)) {
                                acpi_ut_delete_internal_object_list (internal_params);
                                return_ACPI_STATUS (status);
@@ -105,7 +103,6 @@ acpi_evaluate_object (
                internal_params[external_params->count] = NULL;
        }
 
-
        /*
         * Three major cases:
         * 1) Fully qualified pathname
@@ -117,9 +114,9 @@ acpi_evaluate_object (
                /*
                 *  The path is fully qualified, just evaluate by name
                 */
-               status = acpi_ns_evaluate_by_name (pathname, internal_params, &internal_return_obj);
+               status = acpi_ns_evaluate_by_name (pathname, internal_params,
+                                &internal_return_obj);
        }
-
        else if (!handle) {
                /*
                 * A handle is optional iff a fully qualified pathname
@@ -127,16 +124,16 @@ acpi_evaluate_object (
                 * qualified names above, this is an error
                 */
                if (!pathname) {
-                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Both Handle and Pathname are NULL\n"));
+                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+                               "Both Handle and Pathname are NULL\n"));
                }
-
                else {
-                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Handle is NULL and Pathname is relative\n"));
+                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+                               "Handle is NULL and Pathname is relative\n"));
                }
 
                status = AE_BAD_PARAMETER;
        }
-
        else {
                /*
                 * We get here if we have a handle -- and if we have a
@@ -148,15 +145,15 @@ acpi_evaluate_object (
                         * The null pathname case means the handle is for
                         * the actual object to be evaluated
                         */
-                       status = acpi_ns_evaluate_by_handle (handle, internal_params, &internal_return_obj);
+                       status = acpi_ns_evaluate_by_handle (handle, internal_params,
+                                         &internal_return_obj);
                }
-
                else {
                   /*
                        * Both a Handle and a relative Pathname
                        */
                        status = acpi_ns_evaluate_relative (handle, pathname, internal_params,
-                                        &internal_return_obj);
+                                         &internal_return_obj);
                }
        }
 
@@ -165,26 +162,23 @@ acpi_evaluate_object (
         * If we are expecting a return value, and all went well above,
         * copy the return value to an external object.
         */
-
        if (return_buffer) {
-               user_buffer_length = return_buffer->length;
-               return_buffer->length = 0;
-
-               if (internal_return_obj) {
-                       if (VALID_DESCRIPTOR_TYPE (internal_return_obj, ACPI_DESC_TYPE_NAMED)) {
+               if (!internal_return_obj) {
+                       return_buffer->length = 0;
+               }
+               else {
+                       if (ACPI_GET_DESCRIPTOR_TYPE (internal_return_obj) == ACPI_DESC_TYPE_NAMED) {
                                /*
-                                * If we got an Node as a return object,
-                                * this means the object we are evaluating
-                                * has nothing interesting to return (such
-                                * as a mutex, etc.)  We return an error
-                                * because these types are essentially
-                                * unsupported by this interface.  We
-                                * don't check up front because this makes
-                                * it easier to add support for various
-                                * types at a later date if necessary.
+                                * If we received a NS Node as a return object, this means that
+                                * the object we are evaluating has nothing interesting to
+                                * return (such as a mutex, etc.)  We return an error because
+                                * these types are essentially unsupported by this interface.
+                                * We don't check up front because this makes it easier to add
+                                * support for various types at a later date if necessary.
                                 */
                                status = AE_TYPE;
-                               internal_return_obj = NULL; /* No need to delete an Node */
+                               internal_return_obj = NULL; /* No need to delete a NS Node */
+                               return_buffer->length = 0;
                        }
 
                        if (ACPI_SUCCESS (status)) {
@@ -195,38 +189,29 @@ acpi_evaluate_object (
                                status = acpi_ut_get_object_size (internal_return_obj,
                                                   &buffer_space_needed);
                                if (ACPI_SUCCESS (status)) {
-                                       /*
-                                        * Check if there is enough room in the
-                                        * caller's buffer
-                                        */
-                                       if (user_buffer_length < buffer_space_needed) {
+                                       /* Validate/Allocate/Clear caller buffer */
+
+                                       status = acpi_ut_initialize_buffer (return_buffer, buffer_space_needed);
+                                       if (ACPI_FAILURE (status)) {
                                                /*
-                                                * Caller's buffer is too small, can't
-                                                * give him partial results fail the call
-                                                * but return the buffer size needed
+                                                * Caller's buffer is too small or a new one can't be allocated
                                                 */
                                                ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-                                                       "Needed buffer size %X, received %X\n",
-                                                       buffer_space_needed, user_buffer_length));
-
-                                               return_buffer->length = buffer_space_needed;
-                                               status = AE_BUFFER_OVERFLOW;
+                                                       "Needed buffer size %X, %s\n",
+                                                       buffer_space_needed, acpi_format_exception (status)));
                                        }
-
                                        else {
                                                /*
                                                 *  We have enough space for the object, build it
                                                 */
                                                status = acpi_ut_copy_iobject_to_eobject (internal_return_obj,
                                                                  return_buffer);
-                                               return_buffer->length = buffer_space_needed;
                                        }
                                }
                        }
                }
        }
 
-
        /* Delete the return and parameter objects */
 
        if (internal_return_obj) {
@@ -275,7 +260,7 @@ acpi_get_next_object (
        acpi_handle             child,
        acpi_handle             *ret_handle)
 {
-       acpi_status             status = AE_OK;
+       acpi_status             status;
        acpi_namespace_node     *node;
        acpi_namespace_node     *parent_node = NULL;
        acpi_namespace_node     *child_node = NULL;
@@ -287,7 +272,10 @@ acpi_get_next_object (
                return (AE_BAD_PARAMETER);
        }
 
-       acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE (status)) {
+               return (status);
+       }
 
        /* If null handle, use the parent */
 
@@ -300,10 +288,8 @@ acpi_get_next_object (
                        goto unlock_and_exit;
                }
        }
-
-       /* Non-null handle, ignore the parent */
-
        else {
+               /* Non-null handle, ignore the parent */
                /* Convert and validate the handle */
 
                child_node = acpi_ns_map_handle_to_node (child);
@@ -313,11 +299,9 @@ acpi_get_next_object (
                }
        }
 
-
        /* Internal function does the real work */
 
-       node = acpi_ns_get_next_node ((acpi_object_type8) type,
-                          parent_node, child_node);
+       node = acpi_ns_get_next_node (type, parent_node, child_node);
        if (!node) {
                status = AE_NOT_FOUND;
                goto unlock_and_exit;
@@ -330,7 +314,7 @@ acpi_get_next_object (
 
 unlock_and_exit:
 
-       acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+       (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
        return (status);
 }
 
@@ -354,6 +338,7 @@ acpi_get_type (
        acpi_object_type        *ret_type)
 {
        acpi_namespace_node     *node;
+       acpi_status             status;
 
 
        /* Parameter Validation */
@@ -371,21 +356,24 @@ acpi_get_type (
                return (AE_OK);
        }
 
-       acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE (status)) {
+               return (status);
+       }
 
        /* Convert and validate the handle */
 
        node = acpi_ns_map_handle_to_node (handle);
        if (!node) {
-               acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+               (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
                return (AE_BAD_PARAMETER);
        }
 
        *ret_type = node->type;
 
 
-       acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
-       return (AE_OK);
+       status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+       return (status);
 }
 
 
@@ -409,7 +397,7 @@ acpi_get_parent (
        acpi_handle             *ret_handle)
 {
        acpi_namespace_node     *node;
-       acpi_status             status = AE_OK;
+       acpi_status             status;
 
 
        if (!ret_handle) {
@@ -422,8 +410,10 @@ acpi_get_parent (
                return (AE_NULL_ENTRY);
        }
 
-
-       acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE (status)) {
+               return (status);
+       }
 
        /* Convert and validate the handle */
 
@@ -433,22 +423,21 @@ acpi_get_parent (
                goto unlock_and_exit;
        }
 
-
        /* Get the parent entry */
 
        *ret_handle =
-               acpi_ns_convert_entry_to_handle (acpi_ns_get_parent_object (node));
+               acpi_ns_convert_entry_to_handle (acpi_ns_get_parent_node (node));
 
        /* Return exeption if parent is null */
 
-       if (!acpi_ns_get_parent_object (node)) {
+       if (!acpi_ns_get_parent_node (node)) {
                status = AE_NULL_ENTRY;
        }
 
 
 unlock_and_exit:
 
-       acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+       (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
        return (status);
 }
 
@@ -495,7 +484,7 @@ acpi_walk_namespace (
        acpi_status             status;
 
 
-       FUNCTION_TRACE ("Acpi_walk_namespace");
+       ACPI_FUNCTION_TRACE ("Acpi_walk_namespace");
 
 
        /* Parameter validation */
@@ -512,13 +501,15 @@ acpi_walk_namespace (
         * to the user function - since this function
         * must be allowed to make Acpi calls itself.
         */
-       acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
-       status = acpi_ns_walk_namespace ((acpi_object_type8) type, start_object,
-                         max_depth, NS_WALK_UNLOCK, user_function, context,
-                         return_value);
+       status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
 
-       acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+       status = acpi_ns_walk_namespace (type, start_object, max_depth, ACPI_NS_WALK_UNLOCK,
+                         user_function, context, return_value);
 
+       (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
        return_ACPI_STATUS (status);
 }
 
@@ -547,15 +538,23 @@ acpi_ns_get_device_callback (
        acpi_status             status;
        acpi_namespace_node     *node;
        u32                     flags;
-       acpi_device_id          device_id;
+       acpi_device_id          hid;
+       acpi_device_id          cid;
        acpi_get_devices_info   *info;
 
 
        info = context;
 
-       acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE (status)) {
+               return (status);
+       }
+
        node = acpi_ns_map_handle_to_node (obj_handle);
-       acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+       status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE (status)) {
+               return (status);
+       }
 
        if (!node) {
                return (AE_BAD_PARAMETER);
@@ -570,25 +569,36 @@ acpi_ns_get_device_callback (
        }
 
        if (!(flags & 0x01)) {
-               /* don't return at the device or children of the device if not there */
+               /* Don't return at the device or children of the device if not there */
                return (AE_CTRL_DEPTH);
        }
 
        /*
-        * Filter based on device HID
+        * Filter based on device HID & CID
         */
        if (info->hid != NULL) {
-               status = acpi_ut_execute_HID (node, &device_id);
+               status = acpi_ut_execute_HID (node, &hid);
                if (status == AE_NOT_FOUND) {
                        return (AE_OK);
                }
-
                else if (ACPI_FAILURE (status)) {
                        return (AE_CTRL_DEPTH);
                }
 
-               if (STRNCMP (device_id.buffer, info->hid, sizeof (device_id.buffer)) != 0) {
-                       return (AE_OK);
+               if (ACPI_STRNCMP (hid.buffer, info->hid, sizeof (hid.buffer)) != 0) {
+                       status = acpi_ut_execute_CID (node, &cid);
+                       if (status == AE_NOT_FOUND) {
+                               return (AE_OK);
+                       }
+                       else if (ACPI_FAILURE (status)) {
+                               return (AE_CTRL_DEPTH);
+                       }
+
+                       /* TBD: Handle CID packages */
+
+                       if (ACPI_STRNCMP (cid.buffer, info->hid, sizeof (cid.buffer)) != 0) {
+                               return (AE_OK);
+                       }
                }
        }
 
@@ -633,7 +643,7 @@ acpi_get_devices (
        acpi_get_devices_info   info;
 
 
-       FUNCTION_TRACE ("Acpi_get_devices");
+       ACPI_FUNCTION_TRACE ("Acpi_get_devices");
 
 
        /* Parameter validation */
@@ -656,14 +666,170 @@ acpi_get_devices (
         * to the user function - since this function
         * must be allowed to make Acpi calls itself.
         */
-       acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
+
        status = acpi_ns_walk_namespace (ACPI_TYPE_DEVICE,
                           ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
-                          NS_WALK_UNLOCK,
+                          ACPI_NS_WALK_UNLOCK,
                           acpi_ns_get_device_callback, &info,
                           return_value);
 
-       acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
-
+       (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
        return_ACPI_STATUS (status);
 }
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_attach_data
+ *
+ * PARAMETERS:
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION:
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_attach_data (
+       acpi_handle             obj_handle,
+       ACPI_OBJECT_HANDLER     handler,
+       void                    *data)
+{
+       acpi_namespace_node     *node;
+       acpi_status             status;
+
+
+       /* Parameter validation */
+
+       if (!obj_handle ||
+               !handler    ||
+               !data) {
+               return (AE_BAD_PARAMETER);
+       }
+
+       status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE (status)) {
+               return (status);
+       }
+
+       /* Convert and validate the handle */
+
+       node = acpi_ns_map_handle_to_node (obj_handle);
+       if (!node) {
+               status = AE_BAD_PARAMETER;
+               goto unlock_and_exit;
+       }
+
+       status = acpi_ns_attach_data (node, handler, data);
+
+unlock_and_exit:
+       (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+       return (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_detach_data
+ *
+ * PARAMETERS:
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION:
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_detach_data (
+       acpi_handle             obj_handle,
+       ACPI_OBJECT_HANDLER     handler)
+{
+       acpi_namespace_node     *node;
+       acpi_status             status;
+
+
+       /* Parameter validation */
+
+       if (!obj_handle ||
+               !handler) {
+               return (AE_BAD_PARAMETER);
+       }
+
+       status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE (status)) {
+               return (status);
+       }
+
+       /* Convert and validate the handle */
+
+       node = acpi_ns_map_handle_to_node (obj_handle);
+       if (!node) {
+               status = AE_BAD_PARAMETER;
+               goto unlock_and_exit;
+       }
+
+       status = acpi_ns_detach_data (node, handler);
+
+unlock_and_exit:
+       (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+       return (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_get_data
+ *
+ * PARAMETERS:
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION:
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_get_data (
+       acpi_handle             obj_handle,
+       ACPI_OBJECT_HANDLER     handler,
+       void                    **data)
+{
+       acpi_namespace_node     *node;
+       acpi_status             status;
+
+
+       /* Parameter validation */
+
+       if (!obj_handle ||
+               !handler    ||
+               !data) {
+               return (AE_BAD_PARAMETER);
+       }
+
+       status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE (status)) {
+               return (status);
+       }
+
+       /* Convert and validate the handle */
+
+       node = acpi_ns_map_handle_to_node (obj_handle);
+       if (!node) {
+               status = AE_BAD_PARAMETER;
+               goto unlock_and_exit;
+       }
+
+       status = acpi_ns_get_attached_data (node, handler, data);
+
+unlock_and_exit:
+       (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+       return (status);
+}
+
+
index 0714c087172adf7cb040934c0602ec8c336b3ccd..d0bbc7655a46e95b304e00deeca0e7cf8e60f997 100644 (file)
@@ -1,11 +1,10 @@
 #
 # Makefile for all Linux ACPI interpreter subdirectories
-# EXCEPT for the ospm directory
 #
 
 O_TARGET := $(notdir $(CURDIR)).o
 
-obj-$(CONFIG_ACPI) := $(patsubst %.c,%.o,$(wildcard *.c))
+obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
 
index b7274d5559fb073c35540c5bdd9a2c2203f7c4b9..9415c5dbc864d2ddcd483fdea5b6397b3ba880e7 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: psargs - Parse AML opcode arguments
- *              $Revision: 52 $
+ *              $Revision: 58 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@
 #include "acnamesp.h"
 
 #define _COMPONENT          ACPI_PARSER
-        MODULE_NAME         ("psargs")
+        ACPI_MODULE_NAME    ("psargs")
 
 
 /*******************************************************************************
@@ -54,10 +54,10 @@ acpi_ps_get_next_package_length (
        u32                     length = 0;
 
 
-       FUNCTION_TRACE ("Ps_get_next_package_length");
+       ACPI_FUNCTION_TRACE ("Ps_get_next_package_length");
 
 
-       encoded_length = (u32) GET8 (parser_state->aml);
+       encoded_length = (u32) ACPI_GET8 (parser_state->aml);
        parser_state->aml++;
 
 
@@ -70,7 +70,7 @@ acpi_ps_get_next_package_length (
 
        case 1: /* 2-byte encoding (next byte + bits 0-3) */
 
-               length = ((GET8 (parser_state->aml) << 04) |
+               length = ((ACPI_GET8 (parser_state->aml) << 04) |
                                 (encoded_length & 0x0F));
                parser_state->aml++;
                break;
@@ -78,8 +78,8 @@ acpi_ps_get_next_package_length (
 
        case 2: /* 3-byte encoding (next 2 bytes + bits 0-3) */
 
-               length = ((GET8 (parser_state->aml + 1) << 12) |
-                                 (GET8 (parser_state->aml)    << 04) |
+               length = ((ACPI_GET8 (parser_state->aml + 1) << 12) |
+                                 (ACPI_GET8 (parser_state->aml)    << 04) |
                                  (encoded_length & 0x0F));
                parser_state->aml += 2;
                break;
@@ -87,9 +87,9 @@ acpi_ps_get_next_package_length (
 
        case 3: /* 4-byte encoding (next 3 bytes + bits 0-3) */
 
-               length = ((GET8 (parser_state->aml + 2) << 20) |
-                                 (GET8 (parser_state->aml + 1) << 12) |
-                                 (GET8 (parser_state->aml)    << 04) |
+               length = ((ACPI_GET8 (parser_state->aml + 2) << 20) |
+                                 (ACPI_GET8 (parser_state->aml + 1) << 12) |
+                                 (ACPI_GET8 (parser_state->aml)    << 04) |
                                  (encoded_length & 0x0F));
                parser_state->aml += 3;
                break;
@@ -120,7 +120,7 @@ acpi_ps_get_next_package_end (
        NATIVE_UINT             length;
 
 
-       FUNCTION_TRACE ("Ps_get_next_package_end");
+       ACPI_FUNCTION_TRACE ("Ps_get_next_package_end");
 
 
        length = (NATIVE_UINT) acpi_ps_get_next_package_length (parser_state);
@@ -153,12 +153,12 @@ acpi_ps_get_next_namestring (
        u32                     length;
 
 
-       FUNCTION_TRACE ("Ps_get_next_namestring");
+       ACPI_FUNCTION_TRACE ("Ps_get_next_namestring");
 
 
        /* Handle multiple prefix characters */
 
-       while (acpi_ps_is_prefix_char (GET8 (end))) {
+       while (acpi_ps_is_prefix_char (ACPI_GET8 (end))) {
                /* include prefix '\\' or '^' */
 
                end++;
@@ -166,7 +166,7 @@ acpi_ps_get_next_namestring (
 
        /* Decode the path */
 
-       switch (GET8 (end)) {
+       switch (ACPI_GET8 (end)) {
        case 0:
 
                /* Null_name */
@@ -190,7 +190,7 @@ acpi_ps_get_next_namestring (
 
                /* multiple name segments */
 
-               length = (u32) GET8 (end + 1) * 4;
+               length = (u32) ACPI_GET8 (end + 1) * 4;
                end += 2 + length;
                break;
 
@@ -247,7 +247,7 @@ acpi_ps_get_next_namepath (
        acpi_parse_object       *count;
 
 
-       FUNCTION_TRACE ("Ps_get_next_namepath");
+       ACPI_FUNCTION_TRACE ("Ps_get_next_namepath");
 
 
        path = acpi_ps_get_next_namestring (parser_state);
@@ -340,7 +340,7 @@ acpi_ps_get_next_namepath (
        acpi_generic_state      scope_info;
 
 
-       FUNCTION_TRACE ("Ps_get_next_namepath");
+       ACPI_FUNCTION_TRACE ("Ps_get_next_namepath");
 
 
        path = acpi_ps_get_next_namestring (parser_state);
@@ -369,8 +369,8 @@ acpi_ps_get_next_namepath (
                 * parent tree, but don't open a new scope -- we just want to lookup the
                 * object  (MUST BE mode EXECUTE to perform upsearch)
                 */
-               status = acpi_ns_lookup (&scope_info, path, ACPI_TYPE_ANY, IMODE_EXECUTE,
-                                NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE, NULL,
+               status = acpi_ns_lookup (&scope_info, path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
+                                ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL,
                                 &node);
                if (ACPI_SUCCESS (status)) {
                        if (node->type == ACPI_TYPE_METHOD) {
@@ -391,11 +391,11 @@ acpi_ps_get_next_namepath (
                                        name_op->node = method_node;
                                        acpi_ps_append_arg (arg, name_op);
 
-                                       if (!method_node->object) {
+                                       if (!acpi_ns_get_attached_object (method_node)) {
                                                return_VOID;
                                        }
 
-                                       *arg_count = (method_node->object)->method.param_count;
+                                       *arg_count = (acpi_ns_get_attached_object (method_node))->method.param_count;
                                }
 
                                return_VOID;
@@ -444,7 +444,7 @@ acpi_ps_get_next_simple_arg (
        acpi_parse_object       *arg)
 {
 
-       FUNCTION_TRACE_U32 ("Ps_get_next_simple_arg", arg_type);
+       ACPI_FUNCTION_TRACE_U32 ("Ps_get_next_simple_arg", arg_type);
 
 
        switch (arg_type) {
@@ -452,7 +452,7 @@ acpi_ps_get_next_simple_arg (
        case ARGP_BYTEDATA:
 
                acpi_ps_init_op (arg, AML_BYTE_OP);
-               arg->value.integer = (u32) GET8 (parser_state->aml);
+               arg->value.integer = (u32) ACPI_GET8 (parser_state->aml);
                parser_state->aml++;
                break;
 
@@ -463,7 +463,7 @@ acpi_ps_get_next_simple_arg (
 
                /* Get 2 bytes from the AML stream */
 
-               MOVE_UNALIGNED16_TO_32 (&arg->value.integer, parser_state->aml);
+               ACPI_MOVE_UNALIGNED16_TO_32 (&arg->value.integer, parser_state->aml);
                parser_state->aml += 2;
                break;
 
@@ -474,7 +474,7 @@ acpi_ps_get_next_simple_arg (
 
                /* Get 4 bytes from the AML stream */
 
-               MOVE_UNALIGNED32_TO_32 (&arg->value.integer, parser_state->aml);
+               ACPI_MOVE_UNALIGNED32_TO_32 (&arg->value.integer, parser_state->aml);
                parser_state->aml += 4;
                break;
 
@@ -485,7 +485,7 @@ acpi_ps_get_next_simple_arg (
 
                /* Get 8 bytes from the AML stream */
 
-               MOVE_UNALIGNED64_TO_64 (&arg->value.integer, parser_state->aml);
+               ACPI_MOVE_UNALIGNED64_TO_64 (&arg->value.integer, parser_state->aml);
                parser_state->aml += 8;
                break;
 
@@ -493,9 +493,9 @@ acpi_ps_get_next_simple_arg (
        case ARGP_CHARLIST:
 
                acpi_ps_init_op (arg, AML_STRING_OP);
-               arg->value.string = (char*) parser_state->aml;
+               arg->value.string = (char *) parser_state->aml;
 
-               while (GET8 (parser_state->aml) != '\0') {
+               while (ACPI_GET8 (parser_state->aml) != '\0') {
                        parser_state->aml++;
                }
                parser_state->aml++;
@@ -537,12 +537,12 @@ acpi_ps_get_next_field (
        u32                     name;
 
 
-       FUNCTION_TRACE ("Ps_get_next_field");
+       ACPI_FUNCTION_TRACE ("Ps_get_next_field");
 
 
        /* determine field type */
 
-       switch (GET8 (parser_state->aml)) {
+       switch (ACPI_GET8 (parser_state->aml)) {
 
        default:
 
@@ -578,7 +578,7 @@ acpi_ps_get_next_field (
 
                        /* Get the 4-character name */
 
-                       MOVE_UNALIGNED32_TO_32 (&name, parser_state->aml);
+                       ACPI_MOVE_UNALIGNED32_TO_32 (&name, parser_state->aml);
                        acpi_ps_set_name (field, name);
                        parser_state->aml += 4;
 
@@ -598,11 +598,14 @@ acpi_ps_get_next_field (
 
                case AML_INT_ACCESSFIELD_OP:
 
-                       /* Get Access_type and Access_atrib and merge into the field Op */
-
-                       field->value.integer = ((GET8 (parser_state->aml) << 8) |
-                                         GET8 (parser_state->aml));
-                       parser_state->aml += 2;
+                       /*
+                        * Get Access_type and Access_attrib and merge into the field Op
+                        * Access_type is first operand, Access_attribute is second
+                        */
+                       field->value.integer32 = (ACPI_GET8 (parser_state->aml) << 8);
+                       parser_state->aml++;
+                       field->value.integer32 |= ACPI_GET8 (parser_state->aml);
+                       parser_state->aml++;
                        break;
                }
        }
@@ -639,7 +642,7 @@ acpi_ps_get_next_arg (
        u32                     subop;
 
 
-       FUNCTION_TRACE_PTR ("Ps_get_next_arg", parser_state);
+       ACPI_FUNCTION_TRACE_PTR ("Ps_get_next_arg", parser_state);
 
 
        switch (arg_type) {
@@ -717,7 +720,8 @@ acpi_ps_get_next_arg (
 
 
        case ARGP_TARGET:
-       case ARGP_SUPERNAME: {
+       case ARGP_SUPERNAME:
+       case ARGP_SIMPLENAME: {
                        subop = acpi_ps_peek_opcode (parser_state);
                        if (subop == 0              ||
                                acpi_ps_is_leading_char (subop) ||
index 7f7b08ad2895da7e9c981d5a9beacf58b1fa0ea6..79b318efb771323939b5c631773b1f4d6e191940 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: psopcode - Parser/Interpreter opcode information table
- *              $Revision: 49 $
+ *              $Revision: 64 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@
 
 
 #define _COMPONENT          ACPI_PARSER
-        MODULE_NAME         ("psopcode")
+        ACPI_MODULE_NAME    ("psopcode")
 
 
 #define _UNK                        0x6B
 #define ARGP_TO_STRING_OP               ARGP_LIST3 (ARGP_TERMARG,    ARGP_TERMARG,       ARGP_TARGET)
 #define ARGP_TYPE_OP                    ARGP_LIST1 (ARGP_SUPERNAME)
 #define ARGP_UNLOAD_OP                  ARGP_LIST1 (ARGP_SUPERNAME)
-#define ARGP_VAR_PACKAGE_OP             ARGP_LIST3 (ARGP_PKGLENGTH,  ARGP_BYTEDATA,      ARGP_DATAOBJLIST)
+#define ARGP_VAR_PACKAGE_OP             ARGP_LIST3 (ARGP_PKGLENGTH,  ARGP_TERMARG,       ARGP_DATAOBJLIST)
 #define ARGP_WAIT_OP                    ARGP_LIST2 (ARGP_SUPERNAME,  ARGP_TERMARG)
 #define ARGP_WHILE_OP                   ARGP_LIST3 (ARGP_PKGLENGTH,  ARGP_TERMARG,       ARGP_TERMLIST)
 #define ARGP_WORD_OP                    ARGP_LIST1 (ARGP_WORDDATA)
 #define ARGI_DATA_REGION_OP             ARGI_LIST3 (ARGI_STRING,     ARGI_STRING,       ARGI_STRING)
 #define ARGI_DEBUG_OP                   ARG_NONE
 #define ARGI_DECREMENT_OP               ARGI_LIST1 (ARGI_INTEGER_REF)
-#define ARGI_DEREF_OF_OP                ARGI_LIST1 (ARGI_REFERENCE)
+#define ARGI_DEREF_OF_OP                ARGI_LIST1 (ARGI_REF_OR_STRING)
 #define ARGI_DEVICE_OP                  ARGI_INVALID_OPCODE
 #define ARGI_DIVIDE_OP                  ARGI_LIST4 (ARGI_INTEGER,    ARGI_INTEGER,       ARGI_TARGETREF,    ARGI_TARGETREF)
 #define ARGI_DWORD_OP                   ARGI_INVALID_OPCODE
 #define ARGI_LNOT_OP                    ARGI_LIST1 (ARGI_INTEGER)
 #define ARGI_LNOTEQUAL_OP               ARGI_INVALID_OPCODE
 #define ARGI_LOAD_OP                    ARGI_LIST2 (ARGI_REGION,     ARGI_TARGETREF)
-#define ARGI_LOAD_TABLE_OP              ARGI_LIST6 (ARGI_STRING,     ARGI_STRING,        ARGI_STRING,       ARGI_STRING,    ARGI_STRING, ARGI_TARGETREF)
+#define ARGI_LOAD_TABLE_OP              ARGI_LIST6 (ARGI_STRING,     ARGI_STRING,        ARGI_STRING,       ARGI_STRING,    ARGI_STRING, ARGI_ANYTYPE)
 #define ARGI_LOCAL0                     ARG_NONE
 #define ARGI_LOCAL1                     ARG_NONE
 #define ARGI_LOCAL2                     ARG_NONE
 
 /******************************************************************************
 
- Opcodes that have associated namespace objects
+ Opcodes that have associated namespace objects (AML_NSOBJECT flag)
 
        AML_SCOPE_OP
        AML_DEVICE_OP
        AML_INT_METHODCALL_OP
        AML_INT_NAMEPATH_OP
 
-  Opcodes that are "namespace" opcodes
+  Opcodes that are "namespace" opcodes (AML_NSOPCODE flag)
 
        AML_SCOPE_OP
        AML_DEVICE_OP
        AML_REGION_OP
        AML_INT_NAMEDFIELD_OP
 
-  Opcodes that have an associated namespace node
+  Opcodes that have an associated namespace node (AML_NSNODE flag)
 
        AML_SCOPE_OP
        AML_DEVICE_OP
        AML_INT_METHODCALL_OP
        AML_INT_NAMEPATH_OP
 
-  Opcodes that define named ACPI objects
+  Opcodes that define named ACPI objects (AML_NAMED flag)
 
        AML_SCOPE_OP
        AML_DEVICE_OP
        AML_REGION_OP
        AML_INT_NAMEDFIELD_OP
 
-       Opcodes that contain executable AML as part of the definition that
-       must be deferred until needed
+  Opcodes that contain executable AML as part of the definition that
+  must be deferred until needed
 
        AML_METHOD_OP
        AML_VAR_PACKAGE_OP
  */
 
 
-static const acpi_opcode_info    aml_op_info[] =
+static const acpi_opcode_info    acpi_gbl_aml_op_info[] =
 {
-/* Index           Name                 Parser Args               Interpreter Args                 Class                      Type                  Flags */
-
-/* 00 */ ACPI_OP ("Zero",               ARGP_ZERO_OP,              ARGI_ZERO_OP,               AML_CLASS_ARGUMENT,        AML_TYPE_CONSTANT,        0),
-/* 01 */ ACPI_OP ("One",                ARGP_ONE_OP,               ARGI_ONE_OP,                AML_CLASS_ARGUMENT,        AML_TYPE_CONSTANT,        0),
-/* 02 */ ACPI_OP ("Alias",              ARGP_ALIAS_OP,             ARGI_ALIAS_OP,              AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_SIMPLE,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
-/* 03 */ ACPI_OP ("Name",               ARGP_NAME_OP,              ARGI_NAME_OP,               AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_COMPLEX,   AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
-/* 04 */ ACPI_OP ("Byte_const",         ARGP_BYTE_OP,              ARGI_BYTE_OP,               AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         0),
-/* 05 */ ACPI_OP ("Word_const",         ARGP_WORD_OP,              ARGI_WORD_OP,               AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         0),
-/* 06 */ ACPI_OP ("Dword_const",        ARGP_DWORD_OP,             ARGI_DWORD_OP,              AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         0),
-/* 07 */ ACPI_OP ("String",             ARGP_STRING_OP,            ARGI_STRING_OP,             AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         0),
-/* 08 */ ACPI_OP ("Scope",              ARGP_SCOPE_OP,             ARGI_SCOPE_OP,              AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_NO_OBJ,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
-/* 09 */ ACPI_OP ("Buffer",             ARGP_BUFFER_OP,            ARGI_BUFFER_OP,             AML_CLASS_ARGUMENT,        AML_TYPE_DATA_TERM,       AML_HAS_ARGS),
-/* 0A */ ACPI_OP ("Package",            ARGP_PACKAGE_OP,           ARGI_PACKAGE_OP,            AML_CLASS_ARGUMENT,        AML_TYPE_DATA_TERM,       AML_HAS_ARGS),
-/* 0B */ ACPI_OP ("Method",             ARGP_METHOD_OP,            ARGI_METHOD_OP,             AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_COMPLEX,   AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER),
-/* 0C */ ACPI_OP ("Local0",             ARGP_LOCAL0,               ARGI_LOCAL0,                AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
-/* 0D */ ACPI_OP ("Local1",             ARGP_LOCAL1,               ARGI_LOCAL1,                AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
-/* 0E */ ACPI_OP ("Local2",             ARGP_LOCAL2,               ARGI_LOCAL2,                AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
-/* 0F */ ACPI_OP ("Local3",             ARGP_LOCAL3,               ARGI_LOCAL3,                AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
-/* 10 */ ACPI_OP ("Local4",             ARGP_LOCAL4,               ARGI_LOCAL4,                AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
-/* 11 */ ACPI_OP ("Local5",             ARGP_LOCAL5,               ARGI_LOCAL5,                AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
-/* 12 */ ACPI_OP ("Local6",             ARGP_LOCAL6,               ARGI_LOCAL6,                AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
-/* 13 */ ACPI_OP ("Local7",             ARGP_LOCAL7,               ARGI_LOCAL7,                AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
-/* 14 */ ACPI_OP ("Arg0",               ARGP_ARG0,                 ARGI_ARG0,                  AML_CLASS_ARGUMENT,        AML_TYPE_METHOD_ARGUMENT, 0),
-/* 15 */ ACPI_OP ("Arg1",               ARGP_ARG1,                 ARGI_ARG1,                  AML_CLASS_ARGUMENT,        AML_TYPE_METHOD_ARGUMENT, 0),
-/* 16 */ ACPI_OP ("Arg2",               ARGP_ARG2,                 ARGI_ARG2,                  AML_CLASS_ARGUMENT,        AML_TYPE_METHOD_ARGUMENT, 0),
-/* 17 */ ACPI_OP ("Arg3",               ARGP_ARG3,                 ARGI_ARG3,                  AML_CLASS_ARGUMENT,        AML_TYPE_METHOD_ARGUMENT, 0),
-/* 18 */ ACPI_OP ("Arg4",               ARGP_ARG4,                 ARGI_ARG4,                  AML_CLASS_ARGUMENT,        AML_TYPE_METHOD_ARGUMENT, 0),
-/* 19 */ ACPI_OP ("Arg5",               ARGP_ARG5,                 ARGI_ARG5,                  AML_CLASS_ARGUMENT,        AML_TYPE_METHOD_ARGUMENT, 0),
-/* 1_a */ ACPI_OP ("Arg6",              ARGP_ARG6,                 ARGI_ARG6,                  AML_CLASS_ARGUMENT,        AML_TYPE_METHOD_ARGUMENT, 0),
-/* 1_b */ ACPI_OP ("Store",             ARGP_STORE_OP,             ARGI_STORE_OP,              AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
-/* 1_c */ ACPI_OP ("Ref_of",            ARGP_REF_OF_OP,            ARGI_REF_OF_OP,             AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R),
-/* 1_d */ ACPI_OP ("Add",               ARGP_ADD_OP,               ARGI_ADD_OP,                AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
-/* 1_e */ ACPI_OP ("Concatenate",       ARGP_CONCAT_OP,            ARGI_CONCAT_OP,             AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R),
-/* 1_f */ ACPI_OP ("Subtract",          ARGP_SUBTRACT_OP,          ARGI_SUBTRACT_OP,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
-/* 20 */ ACPI_OP ("Increment",          ARGP_INCREMENT_OP,         ARGI_INCREMENT_OP,          AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R),
-/* 21 */ ACPI_OP ("Decrement",          ARGP_DECREMENT_OP,         ARGI_DECREMENT_OP,          AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R),
-/* 22 */ ACPI_OP ("Multiply",           ARGP_MULTIPLY_OP,          ARGI_MULTIPLY_OP,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
-/* 23 */ ACPI_OP ("Divide",             ARGP_DIVIDE_OP,            ARGI_DIVIDE_OP,             AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_2T_1R,   AML_FLAGS_EXEC_2A_2T_1R),
-/* 24 */ ACPI_OP ("Shift_left",         ARGP_SHIFT_LEFT_OP,        ARGI_SHIFT_LEFT_OP,         AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
-/* 25 */ ACPI_OP ("Shift_right",        ARGP_SHIFT_RIGHT_OP,       ARGI_SHIFT_RIGHT_OP,        AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
-/* 26 */ ACPI_OP ("And",                ARGP_BIT_AND_OP,           ARGI_BIT_AND_OP,            AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
-/* 27 */ ACPI_OP ("NAnd",               ARGP_BIT_NAND_OP,          ARGI_BIT_NAND_OP,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
-/* 28 */ ACPI_OP ("Or",                 ARGP_BIT_OR_OP,            ARGI_BIT_OR_OP,             AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
-/* 29 */ ACPI_OP ("NOr",                ARGP_BIT_NOR_OP,           ARGI_BIT_NOR_OP,            AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
-/* 2_a */ ACPI_OP ("XOr",               ARGP_BIT_XOR_OP,           ARGI_BIT_XOR_OP,            AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
-/* 2_b */ ACPI_OP ("Not",               ARGP_BIT_NOT_OP,           ARGI_BIT_NOT_OP,            AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
-/* 2_c */ ACPI_OP ("Find_set_left_bit", ARGP_FIND_SET_LEFT_BIT_OP, ARGI_FIND_SET_LEFT_BIT_OP,  AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
-/* 2_d */ ACPI_OP ("Find_set_right_bit", ARGP_FIND_SET_RIGHT_BIT_OP,ARGI_FIND_SET_RIGHT_BIT_OP, AML_CLASS_EXECUTE,        AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
-/* 2_e */ ACPI_OP ("Deref_of",          ARGP_DEREF_OF_OP,          ARGI_DEREF_OF_OP,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R),
-/* 2_f */ ACPI_OP ("Notify",            ARGP_NOTIFY_OP,            ARGI_NOTIFY_OP,             AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_0R,   AML_FLAGS_EXEC_2A_0T_0R),
-/* 30 */ ACPI_OP ("Size_of",            ARGP_SIZE_OF_OP,           ARGI_SIZE_OF_OP,            AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R),
-/* 31 */ ACPI_OP ("Index",              ARGP_INDEX_OP,             ARGI_INDEX_OP,              AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R),
-/* 32 */ ACPI_OP ("Match",              ARGP_MATCH_OP,             ARGI_MATCH_OP,              AML_CLASS_EXECUTE,         AML_TYPE_EXEC_6A_0T_1R,   AML_FLAGS_EXEC_6A_0T_1R),
-/* 33 */ ACPI_OP ("Create_dWord_field", ARGP_CREATE_DWORD_FIELD_OP,ARGI_CREATE_DWORD_FIELD_OP, AML_CLASS_CREATE,          AML_TYPE_CREATE_FIELD,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
-/* 34 */ ACPI_OP ("Create_word_field",  ARGP_CREATE_WORD_FIELD_OP, ARGI_CREATE_WORD_FIELD_OP,  AML_CLASS_CREATE,          AML_TYPE_CREATE_FIELD,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
-/* 35 */ ACPI_OP ("Create_byte_field",  ARGP_CREATE_BYTE_FIELD_OP, ARGI_CREATE_BYTE_FIELD_OP,  AML_CLASS_CREATE,          AML_TYPE_CREATE_FIELD,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
-/* 36 */ ACPI_OP ("Create_bit_field",   ARGP_CREATE_BIT_FIELD_OP,  ARGI_CREATE_BIT_FIELD_OP,   AML_CLASS_CREATE,          AML_TYPE_CREATE_FIELD,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
-/* 37 */ ACPI_OP ("Object_type",        ARGP_TYPE_OP,              ARGI_TYPE_OP,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R),
-/* 38 */ ACPI_OP ("LAnd",               ARGP_LAND_OP,              ARGI_LAND_OP,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL),
-/* 39 */ ACPI_OP ("LOr",                ARGP_LOR_OP,               ARGI_LOR_OP,                AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL),
-/* 3_a */ ACPI_OP ("LNot",              ARGP_LNOT_OP,              ARGI_LNOT_OP,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R),
-/* 3_b */ ACPI_OP ("LEqual",            ARGP_LEQUAL_OP,            ARGI_LEQUAL_OP,             AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL),
-/* 3_c */ ACPI_OP ("LGreater",          ARGP_LGREATER_OP,          ARGI_LGREATER_OP,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL),
-/* 3_d */ ACPI_OP ("LLess",             ARGP_LLESS_OP,             ARGI_LLESS_OP,              AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL),
-/* 3_e */ ACPI_OP ("If",                ARGP_IF_OP,                ARGI_IF_OP,                 AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         AML_HAS_ARGS),
-/* 3_f */ ACPI_OP ("Else",              ARGP_ELSE_OP,              ARGI_ELSE_OP,               AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         AML_HAS_ARGS),
-/* 40 */ ACPI_OP ("While",              ARGP_WHILE_OP,             ARGI_WHILE_OP,              AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         AML_HAS_ARGS),
-/* 41 */ ACPI_OP ("Noop",               ARGP_NOOP_OP,              ARGI_NOOP_OP,               AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         0),
-/* 42 */ ACPI_OP ("Return",             ARGP_RETURN_OP,            ARGI_RETURN_OP,             AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         AML_HAS_ARGS),
-/* 43 */ ACPI_OP ("Break",              ARGP_BREAK_OP,             ARGI_BREAK_OP,              AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         0),
-/* 44 */ ACPI_OP ("Break_point",        ARGP_BREAK_POINT_OP,       ARGI_BREAK_POINT_OP,        AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         0),
-/* 45 */ ACPI_OP ("Ones",               ARGP_ONES_OP,              ARGI_ONES_OP,               AML_CLASS_ARGUMENT,        AML_TYPE_CONSTANT,        0),
+/*! [Begin] no source code translation */
+/* Index           Name                 Parser Args               Interpreter Args                ObjectType                Class                      Type                  Flags */
+
+/* 00 */ ACPI_OP ("Zero",               ARGP_ZERO_OP,              ARGI_ZERO_OP,               INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT,        AML_TYPE_CONSTANT,        0),
+/* 01 */ ACPI_OP ("One",                ARGP_ONE_OP,               ARGI_ONE_OP,                INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT,        AML_TYPE_CONSTANT,        0),
+/* 02 */ ACPI_OP ("Alias",              ARGP_ALIAS_OP,             ARGI_ALIAS_OP,              INTERNAL_TYPE_ALIAS,     AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_SIMPLE,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
+/* 03 */ ACPI_OP ("Name",               ARGP_NAME_OP,              ARGI_NAME_OP,               ACPI_TYPE_ANY,           AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_COMPLEX,   AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
+/* 04 */ ACPI_OP ("ByteConst",          ARGP_BYTE_OP,              ARGI_BYTE_OP,               ACPI_TYPE_INTEGER,       AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         0),
+/* 05 */ ACPI_OP ("WordConst",          ARGP_WORD_OP,              ARGI_WORD_OP,               ACPI_TYPE_INTEGER,       AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         0),
+/* 06 */ ACPI_OP ("DwordConst",         ARGP_DWORD_OP,             ARGI_DWORD_OP,              ACPI_TYPE_INTEGER,       AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         0),
+/* 07 */ ACPI_OP ("String",             ARGP_STRING_OP,            ARGI_STRING_OP,             ACPI_TYPE_STRING,        AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         0),
+/* 08 */ ACPI_OP ("Scope",              ARGP_SCOPE_OP,             ARGI_SCOPE_OP,              INTERNAL_TYPE_SCOPE,     AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_NO_OBJ,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
+/* 09 */ ACPI_OP ("Buffer",             ARGP_BUFFER_OP,            ARGI_BUFFER_OP,             ACPI_TYPE_BUFFER,        AML_CLASS_ARGUMENT,        AML_TYPE_DATA_TERM,       AML_HAS_ARGS),
+/* 0A */ ACPI_OP ("Package",            ARGP_PACKAGE_OP,           ARGI_PACKAGE_OP,            ACPI_TYPE_PACKAGE,       AML_CLASS_ARGUMENT,        AML_TYPE_DATA_TERM,       AML_HAS_ARGS),
+/* 0B */ ACPI_OP ("Method",             ARGP_METHOD_OP,            ARGI_METHOD_OP,             ACPI_TYPE_METHOD,        AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_COMPLEX,   AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER),
+/* 0C */ ACPI_OP ("Local0",             ARGP_LOCAL0,               ARGI_LOCAL0,                INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
+/* 0D */ ACPI_OP ("Local1",             ARGP_LOCAL1,               ARGI_LOCAL1,                INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
+/* 0E */ ACPI_OP ("Local2",             ARGP_LOCAL2,               ARGI_LOCAL2,                INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
+/* 0F */ ACPI_OP ("Local3",             ARGP_LOCAL3,               ARGI_LOCAL3,                INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
+/* 10 */ ACPI_OP ("Local4",             ARGP_LOCAL4,               ARGI_LOCAL4,                INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
+/* 11 */ ACPI_OP ("Local5",             ARGP_LOCAL5,               ARGI_LOCAL5,                INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
+/* 12 */ ACPI_OP ("Local6",             ARGP_LOCAL6,               ARGI_LOCAL6,                INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
+/* 13 */ ACPI_OP ("Local7",             ARGP_LOCAL7,               ARGI_LOCAL7,                INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT,        AML_TYPE_LOCAL_VARIABLE,  0),
+/* 14 */ ACPI_OP ("Arg0",               ARGP_ARG0,                 ARGI_ARG0,                  INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT,        AML_TYPE_METHOD_ARGUMENT, 0),
+/* 15 */ ACPI_OP ("Arg1",               ARGP_ARG1,                 ARGI_ARG1,                  INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT,        AML_TYPE_METHOD_ARGUMENT, 0),
+/* 16 */ ACPI_OP ("Arg2",               ARGP_ARG2,                 ARGI_ARG2,                  INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT,        AML_TYPE_METHOD_ARGUMENT, 0),
+/* 17 */ ACPI_OP ("Arg3",               ARGP_ARG3,                 ARGI_ARG3,                  INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT,        AML_TYPE_METHOD_ARGUMENT, 0),
+/* 18 */ ACPI_OP ("Arg4",               ARGP_ARG4,                 ARGI_ARG4,                  INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT,        AML_TYPE_METHOD_ARGUMENT, 0),
+/* 19 */ ACPI_OP ("Arg5",               ARGP_ARG5,                 ARGI_ARG5,                  INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT,        AML_TYPE_METHOD_ARGUMENT, 0),
+/* 1A */ ACPI_OP ("Arg6",               ARGP_ARG6,                 ARGI_ARG6,                  INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT,        AML_TYPE_METHOD_ARGUMENT, 0),
+/* 1B */ ACPI_OP ("Store",              ARGP_STORE_OP,             ARGI_STORE_OP,              ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
+/* 1C */ ACPI_OP ("RefOf",              ARGP_REF_OF_OP,            ARGI_REF_OF_OP,             ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R),
+/* 1D */ ACPI_OP ("Add",                ARGP_ADD_OP,               ARGI_ADD_OP,                ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
+/* 1E */ ACPI_OP ("Concatenate",        ARGP_CONCAT_OP,            ARGI_CONCAT_OP,             ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R),
+/* 1F */ ACPI_OP ("Subtract",           ARGP_SUBTRACT_OP,          ARGI_SUBTRACT_OP,           ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
+/* 20 */ ACPI_OP ("Increment",          ARGP_INCREMENT_OP,         ARGI_INCREMENT_OP,          ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R),
+/* 21 */ ACPI_OP ("Decrement",          ARGP_DECREMENT_OP,         ARGI_DECREMENT_OP,          ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R),
+/* 22 */ ACPI_OP ("Multiply",           ARGP_MULTIPLY_OP,          ARGI_MULTIPLY_OP,           ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
+/* 23 */ ACPI_OP ("Divide",             ARGP_DIVIDE_OP,            ARGI_DIVIDE_OP,             ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_2T_1R,   AML_FLAGS_EXEC_2A_2T_1R),
+/* 24 */ ACPI_OP ("ShiftLeft",          ARGP_SHIFT_LEFT_OP,        ARGI_SHIFT_LEFT_OP,         ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
+/* 25 */ ACPI_OP ("ShiftRight",         ARGP_SHIFT_RIGHT_OP,       ARGI_SHIFT_RIGHT_OP,        ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
+/* 26 */ ACPI_OP ("And",                ARGP_BIT_AND_OP,           ARGI_BIT_AND_OP,            ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
+/* 27 */ ACPI_OP ("NAnd",               ARGP_BIT_NAND_OP,          ARGI_BIT_NAND_OP,           ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
+/* 28 */ ACPI_OP ("Or",                 ARGP_BIT_OR_OP,            ARGI_BIT_OR_OP,             ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
+/* 29 */ ACPI_OP ("NOr",                ARGP_BIT_NOR_OP,           ARGI_BIT_NOR_OP,            ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
+/* 2A */ ACPI_OP ("XOr",                ARGP_BIT_XOR_OP,           ARGI_BIT_XOR_OP,            ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R | AML_MATH),
+/* 2B */ ACPI_OP ("Not",                ARGP_BIT_NOT_OP,           ARGI_BIT_NOT_OP,            ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
+/* 2C */ ACPI_OP ("FindSetLeftBit",     ARGP_FIND_SET_LEFT_BIT_OP, ARGI_FIND_SET_LEFT_BIT_OP,  ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
+/* 2D */ ACPI_OP ("FindSetRightBit",    ARGP_FIND_SET_RIGHT_BIT_OP,ARGI_FIND_SET_RIGHT_BIT_OP, ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
+/* 2E */ ACPI_OP ("DerefOf",            ARGP_DEREF_OF_OP,          ARGI_DEREF_OF_OP,           ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R),
+/* 2F */ ACPI_OP ("Notify",             ARGP_NOTIFY_OP,            ARGI_NOTIFY_OP,             ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_0R,   AML_FLAGS_EXEC_2A_0T_0R),
+/* 30 */ ACPI_OP ("SizeOf",             ARGP_SIZE_OF_OP,           ARGI_SIZE_OF_OP,            ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R),
+/* 31 */ ACPI_OP ("Index",              ARGP_INDEX_OP,             ARGI_INDEX_OP,              ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R),
+/* 32 */ ACPI_OP ("Match",              ARGP_MATCH_OP,             ARGI_MATCH_OP,              ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_6A_0T_1R,   AML_FLAGS_EXEC_6A_0T_1R),
+/* 33 */ ACPI_OP ("CreateDWordField",   ARGP_CREATE_DWORD_FIELD_OP,ARGI_CREATE_DWORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD,  AML_CLASS_CREATE,          AML_TYPE_CREATE_FIELD,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
+/* 34 */ ACPI_OP ("CreateWordField",    ARGP_CREATE_WORD_FIELD_OP, ARGI_CREATE_WORD_FIELD_OP,  ACPI_TYPE_BUFFER_FIELD,  AML_CLASS_CREATE,          AML_TYPE_CREATE_FIELD,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
+/* 35 */ ACPI_OP ("CreateByteField",    ARGP_CREATE_BYTE_FIELD_OP, ARGI_CREATE_BYTE_FIELD_OP,  ACPI_TYPE_BUFFER_FIELD,  AML_CLASS_CREATE,          AML_TYPE_CREATE_FIELD,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
+/* 36 */ ACPI_OP ("CreateBitField",     ARGP_CREATE_BIT_FIELD_OP,  ARGI_CREATE_BIT_FIELD_OP,   ACPI_TYPE_BUFFER_FIELD,  AML_CLASS_CREATE,          AML_TYPE_CREATE_FIELD,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
+/* 37 */ ACPI_OP ("ObjectType",         ARGP_TYPE_OP,              ARGI_TYPE_OP,               ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R),
+/* 38 */ ACPI_OP ("LAnd",               ARGP_LAND_OP,              ARGI_LAND_OP,               ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL),
+/* 39 */ ACPI_OP ("LOr",                ARGP_LOR_OP,               ARGI_LOR_OP,                ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL),
+/* 3A */ ACPI_OP ("LNot",               ARGP_LNOT_OP,              ARGI_LNOT_OP,               ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R),
+/* 3B */ ACPI_OP ("LEqual",             ARGP_LEQUAL_OP,            ARGI_LEQUAL_OP,             ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL),
+/* 3C */ ACPI_OP ("LGreater",           ARGP_LGREATER_OP,          ARGI_LGREATER_OP,           ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL),
+/* 3D */ ACPI_OP ("LLess",              ARGP_LLESS_OP,             ARGI_LLESS_OP,              ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL),
+/* 3E */ ACPI_OP ("If",                 ARGP_IF_OP,                ARGI_IF_OP,                 ACPI_TYPE_ANY,           AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         AML_HAS_ARGS),
+/* 3F */ ACPI_OP ("Else",               ARGP_ELSE_OP,              ARGI_ELSE_OP,               ACPI_TYPE_ANY,           AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         AML_HAS_ARGS),
+/* 40 */ ACPI_OP ("While",              ARGP_WHILE_OP,             ARGI_WHILE_OP,              ACPI_TYPE_ANY,           AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         AML_HAS_ARGS),
+/* 41 */ ACPI_OP ("Noop",               ARGP_NOOP_OP,              ARGI_NOOP_OP,               ACPI_TYPE_ANY,           AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         0),
+/* 42 */ ACPI_OP ("Return",             ARGP_RETURN_OP,            ARGI_RETURN_OP,             ACPI_TYPE_ANY,           AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         AML_HAS_ARGS),
+/* 43 */ ACPI_OP ("Break",              ARGP_BREAK_OP,             ARGI_BREAK_OP,              ACPI_TYPE_ANY,           AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         0),
+/* 44 */ ACPI_OP ("BreakPoint",         ARGP_BREAK_POINT_OP,       ARGI_BREAK_POINT_OP,        ACPI_TYPE_ANY,           AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         0),
+/* 45 */ ACPI_OP ("Ones",               ARGP_ONES_OP,              ARGI_ONES_OP,               INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT,        AML_TYPE_CONSTANT,        0),
 
 /* Prefixed opcodes (Two-byte opcodes with a prefix op) */
 
-/* 46 */ ACPI_OP ("Mutex",              ARGP_MUTEX_OP,             ARGI_MUTEX_OP,              AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_SIMPLE,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
-/* 47 */ ACPI_OP ("Event",              ARGP_EVENT_OP,             ARGI_EVENT_OP,              AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_SIMPLE,    AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ),
-/* 48 */ ACPI_OP ("Cond_ref_of",        ARGP_COND_REF_OF_OP,       ARGI_COND_REF_OF_OP,        AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
-/* 49 */ ACPI_OP ("Create_field",       ARGP_CREATE_FIELD_OP,      ARGI_CREATE_FIELD_OP,       AML_CLASS_CREATE,          AML_TYPE_CREATE_FIELD,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_FIELD | AML_CREATE),
-/* 4_a */ ACPI_OP ("Load",              ARGP_LOAD_OP,              ARGI_LOAD_OP,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_0R,   AML_FLAGS_EXEC_1A_1T_0R),
-/* 4_b */ ACPI_OP ("Stall",             ARGP_STALL_OP,             ARGI_STALL_OP,              AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_0R,   AML_FLAGS_EXEC_1A_0T_0R),
-/* 4_c */ ACPI_OP ("Sleep",             ARGP_SLEEP_OP,             ARGI_SLEEP_OP,              AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_0R,   AML_FLAGS_EXEC_1A_0T_0R),
-/* 4_d */ ACPI_OP ("Acquire",           ARGP_ACQUIRE_OP,           ARGI_ACQUIRE_OP,            AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R),
-/* 4_e */ ACPI_OP ("Signal",            ARGP_SIGNAL_OP,            ARGI_SIGNAL_OP,             AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_0R,   AML_FLAGS_EXEC_1A_0T_0R),
-/* 4_f */ ACPI_OP ("Wait",              ARGP_WAIT_OP,              ARGI_WAIT_OP,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R),
-/* 50 */ ACPI_OP ("Reset",              ARGP_RESET_OP,             ARGI_RESET_OP,              AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_0R,   AML_FLAGS_EXEC_1A_0T_0R),
-/* 51 */ ACPI_OP ("Release",            ARGP_RELEASE_OP,           ARGI_RELEASE_OP,            AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_0R,   AML_FLAGS_EXEC_1A_0T_0R),
-/* 52 */ ACPI_OP ("From_bCD",           ARGP_FROM_BCD_OP,          ARGI_FROM_BCD_OP,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
-/* 53 */ ACPI_OP ("To_bCD",             ARGP_TO_BCD_OP,            ARGI_TO_BCD_OP,             AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
-/* 54 */ ACPI_OP ("Unload",             ARGP_UNLOAD_OP,            ARGI_UNLOAD_OP,             AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_0R,   AML_FLAGS_EXEC_1A_0T_0R),
-/* 55 */ ACPI_OP ("Revision",           ARGP_REVISION_OP,          ARGI_REVISION_OP,           AML_CLASS_ARGUMENT,        AML_TYPE_CONSTANT,        0),
-/* 56 */ ACPI_OP ("Debug",              ARGP_DEBUG_OP,             ARGI_DEBUG_OP,              AML_CLASS_ARGUMENT,        AML_TYPE_CONSTANT,        0),
-/* 57 */ ACPI_OP ("Fatal",              ARGP_FATAL_OP,             ARGI_FATAL_OP,              AML_CLASS_EXECUTE,         AML_TYPE_EXEC_3A_0T_0R,   AML_FLAGS_EXEC_3A_0T_0R),
-/* 58 */ ACPI_OP ("Op_region",          ARGP_REGION_OP,            ARGI_REGION_OP,             AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_COMPLEX,   AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER),
-/* 59 */ ACPI_OP ("Field",              ARGP_FIELD_OP,             ARGI_FIELD_OP,              AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_FIELD,     AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD),
-/* 5_a */ ACPI_OP ("Device",            ARGP_DEVICE_OP,            ARGI_DEVICE_OP,             AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_NO_OBJ,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
-/* 5_b */ ACPI_OP ("Processor",         ARGP_PROCESSOR_OP,         ARGI_PROCESSOR_OP,          AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_SIMPLE,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
-/* 5_c */ ACPI_OP ("Power_resource",    ARGP_POWER_RES_OP,         ARGI_POWER_RES_OP,          AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_SIMPLE,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
-/* 5_d */ ACPI_OP ("Thermal_zone",      ARGP_THERMAL_ZONE_OP,      ARGI_THERMAL_ZONE_OP,       AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_NO_OBJ,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
-/* 5_e */ ACPI_OP ("Index_field",       ARGP_INDEX_FIELD_OP,       ARGI_INDEX_FIELD_OP,        AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_FIELD,     AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD),
-/* 5_f */ ACPI_OP ("Bank_field",        ARGP_BANK_FIELD_OP,        ARGI_BANK_FIELD_OP,         AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_FIELD,     AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD),
+/* 46 */ ACPI_OP ("Mutex",              ARGP_MUTEX_OP,             ARGI_MUTEX_OP,              ACPI_TYPE_MUTEX,         AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_SIMPLE,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
+/* 47 */ ACPI_OP ("Event",              ARGP_EVENT_OP,             ARGI_EVENT_OP,              ACPI_TYPE_EVENT,         AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_SIMPLE,    AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ),
+/* 48 */ ACPI_OP ("CondRefOf",          ARGP_COND_REF_OF_OP,       ARGI_COND_REF_OF_OP,        ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
+/* 49 */ ACPI_OP ("CreateField",        ARGP_CREATE_FIELD_OP,      ARGI_CREATE_FIELD_OP,       ACPI_TYPE_BUFFER_FIELD,  AML_CLASS_CREATE,          AML_TYPE_CREATE_FIELD,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_FIELD | AML_CREATE),
+/* 4A */ ACPI_OP ("Load",               ARGP_LOAD_OP,              ARGI_LOAD_OP,               ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_0R,   AML_FLAGS_EXEC_1A_1T_0R),
+/* 4B */ ACPI_OP ("Stall",              ARGP_STALL_OP,             ARGI_STALL_OP,              ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_0R,   AML_FLAGS_EXEC_1A_0T_0R),
+/* 4C */ ACPI_OP ("Sleep",              ARGP_SLEEP_OP,             ARGI_SLEEP_OP,              ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_0R,   AML_FLAGS_EXEC_1A_0T_0R),
+/* 4D */ ACPI_OP ("Acquire",            ARGP_ACQUIRE_OP,           ARGI_ACQUIRE_OP,            ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R),
+/* 4E */ ACPI_OP ("Signal",             ARGP_SIGNAL_OP,            ARGI_SIGNAL_OP,             ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_0R,   AML_FLAGS_EXEC_1A_0T_0R),
+/* 4F */ ACPI_OP ("Wait",               ARGP_WAIT_OP,              ARGI_WAIT_OP,               ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R),
+/* 50 */ ACPI_OP ("Reset",              ARGP_RESET_OP,             ARGI_RESET_OP,              ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_0R,   AML_FLAGS_EXEC_1A_0T_0R),
+/* 51 */ ACPI_OP ("Release",            ARGP_RELEASE_OP,           ARGI_RELEASE_OP,            ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_0R,   AML_FLAGS_EXEC_1A_0T_0R),
+/* 52 */ ACPI_OP ("FromBCD",            ARGP_FROM_BCD_OP,          ARGI_FROM_BCD_OP,           ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
+/* 53 */ ACPI_OP ("ToBCD",              ARGP_TO_BCD_OP,            ARGI_TO_BCD_OP,             ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
+/* 54 */ ACPI_OP ("Unload",             ARGP_UNLOAD_OP,            ARGI_UNLOAD_OP,             ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_0R,   AML_FLAGS_EXEC_1A_0T_0R),
+/* 55 */ ACPI_OP ("Revision",           ARGP_REVISION_OP,          ARGI_REVISION_OP,           INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT,        AML_TYPE_CONSTANT,        0),
+/* 56 */ ACPI_OP ("Debug",              ARGP_DEBUG_OP,             ARGI_DEBUG_OP,              INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT,        AML_TYPE_CONSTANT,        0),
+/* 57 */ ACPI_OP ("Fatal",              ARGP_FATAL_OP,             ARGI_FATAL_OP,              ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_3A_0T_0R,   AML_FLAGS_EXEC_3A_0T_0R),
+/* 58 */ ACPI_OP ("OperationRegion",    ARGP_REGION_OP,            ARGI_REGION_OP,             ACPI_TYPE_REGION,        AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_COMPLEX,   AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER),
+/* 59 */ ACPI_OP ("Field",              ARGP_FIELD_OP,             ARGI_FIELD_OP,              INTERNAL_TYPE_FIELD_DEFN,AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_FIELD,     AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD),
+/* 5A */ ACPI_OP ("Device",             ARGP_DEVICE_OP,            ARGI_DEVICE_OP,             ACPI_TYPE_DEVICE,        AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_NO_OBJ,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
+/* 5B */ ACPI_OP ("Processor",          ARGP_PROCESSOR_OP,         ARGI_PROCESSOR_OP,          ACPI_TYPE_PROCESSOR,     AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_SIMPLE,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
+/* 5C */ ACPI_OP ("PowerResource",      ARGP_POWER_RES_OP,         ARGI_POWER_RES_OP,          ACPI_TYPE_POWER,         AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_SIMPLE,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
+/* 5D */ ACPI_OP ("ThermalZone",        ARGP_THERMAL_ZONE_OP,      ARGI_THERMAL_ZONE_OP,       ACPI_TYPE_THERMAL,       AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_NO_OBJ,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
+/* 5E */ ACPI_OP ("IndexField",         ARGP_INDEX_FIELD_OP,       ARGI_INDEX_FIELD_OP,        INTERNAL_TYPE_INDEX_FIELD_DEFN,AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD,  AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD),
+/* 5F */ ACPI_OP ("BankField",          ARGP_BANK_FIELD_OP,        ARGI_BANK_FIELD_OP,         INTERNAL_TYPE_BANK_FIELD_DEFN,AML_CLASS_NAMED_OBJECT,  AML_TYPE_NAMED_FIELD,  AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD),
 
 /* Internal opcodes that map to invalid AML opcodes */
 
-/* 60 */ ACPI_OP ("LNot_equal",         ARGP_LNOTEQUAL_OP,         ARGI_LNOTEQUAL_OP,          AML_CLASS_INTERNAL,        AML_TYPE_BOGUS,           AML_HAS_ARGS),
-/* 61 */ ACPI_OP ("LLess_equal",        ARGP_LLESSEQUAL_OP,        ARGI_LLESSEQUAL_OP,         AML_CLASS_INTERNAL,        AML_TYPE_BOGUS,           AML_HAS_ARGS),
-/* 62 */ ACPI_OP ("LGreater_equal",     ARGP_LGREATEREQUAL_OP,     ARGI_LGREATEREQUAL_OP,      AML_CLASS_INTERNAL,        AML_TYPE_BOGUS,           AML_HAS_ARGS),
-/* 63 */ ACPI_OP ("[Name_path]",        ARGP_NAMEPATH_OP,          ARGI_NAMEPATH_OP,           AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         AML_NSOBJECT | AML_NSNODE ),
-/* 64 */ ACPI_OP ("[Method_call]",      ARGP_METHODCALL_OP,        ARGI_METHODCALL_OP,         AML_CLASS_METHOD_CALL,     AML_TYPE_METHOD_CALL,     AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE),
-/* 65 */ ACPI_OP ("[Byte_list]",        ARGP_BYTELIST_OP,          ARGI_BYTELIST_OP,           AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         0),
-/* 66 */ ACPI_OP ("[Reserved_field]",   ARGP_RESERVEDFIELD_OP,     ARGI_RESERVEDFIELD_OP,      AML_CLASS_INTERNAL,        AML_TYPE_BOGUS,           0),
-/* 67 */ ACPI_OP ("[Named_field]",      ARGP_NAMEDFIELD_OP,        ARGI_NAMEDFIELD_OP,         AML_CLASS_INTERNAL,        AML_TYPE_BOGUS,           AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ),
-/* 68 */ ACPI_OP ("[Access_field]",     ARGP_ACCESSFIELD_OP,       ARGI_ACCESSFIELD_OP,        AML_CLASS_INTERNAL,        AML_TYPE_BOGUS,           0),
-/* 69 */ ACPI_OP ("[Static_string",     ARGP_STATICSTRING_OP,      ARGI_STATICSTRING_OP,       AML_CLASS_INTERNAL,        AML_TYPE_BOGUS,           0),
-/* 6_a */ ACPI_OP ("[Return Value]",    ARG_NONE,                  ARG_NONE,                   AML_CLASS_RETURN_VALUE,    AML_TYPE_RETURN,          AML_HAS_ARGS | AML_HAS_RETVAL),
-/* 6_b */ ACPI_OP ("UNKNOWN_OP!",       ARG_NONE,                  ARG_NONE,                   AML_CLASS_UNKNOWN,         AML_TYPE_BOGUS,           AML_HAS_ARGS),
-/* 6_c */ ACPI_OP ("ASCII_ONLY!",       ARG_NONE,                  ARG_NONE,                   AML_CLASS_ASCII,           AML_TYPE_BOGUS,           AML_HAS_ARGS),
-/* 6_d */ ACPI_OP ("PREFIX_ONLY!",      ARG_NONE,                  ARG_NONE,                   AML_CLASS_PREFIX,          AML_TYPE_BOGUS,           AML_HAS_ARGS),
+/* 60 */ ACPI_OP ("LNotEqual",          ARGP_LNOTEQUAL_OP,         ARGI_LNOTEQUAL_OP,          ACPI_TYPE_ANY,           AML_CLASS_INTERNAL,        AML_TYPE_BOGUS,           AML_HAS_ARGS),
+/* 61 */ ACPI_OP ("LLessEqual",         ARGP_LLESSEQUAL_OP,        ARGI_LLESSEQUAL_OP,         ACPI_TYPE_ANY,           AML_CLASS_INTERNAL,        AML_TYPE_BOGUS,           AML_HAS_ARGS),
+/* 62 */ ACPI_OP ("LGreaterEqual",      ARGP_LGREATEREQUAL_OP,     ARGI_LGREATEREQUAL_OP,      ACPI_TYPE_ANY,           AML_CLASS_INTERNAL,        AML_TYPE_BOGUS,           AML_HAS_ARGS),
+/* 63 */ ACPI_OP ("[NamePath]",         ARGP_NAMEPATH_OP,          ARGI_NAMEPATH_OP,           INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         AML_NSOBJECT | AML_NSNODE ),
+/* 64 */ ACPI_OP ("[MethodCall]",       ARGP_METHODCALL_OP,        ARGI_METHODCALL_OP,         ACPI_TYPE_METHOD,        AML_CLASS_METHOD_CALL,     AML_TYPE_METHOD_CALL,     AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE),
+/* 65 */ ACPI_OP ("[ByteList]",         ARGP_BYTELIST_OP,          ARGI_BYTELIST_OP,           ACPI_TYPE_ANY,           AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         0),
+/* 66 */ ACPI_OP ("[ReservedField]",    ARGP_RESERVEDFIELD_OP,     ARGI_RESERVEDFIELD_OP,      ACPI_TYPE_ANY,           AML_CLASS_INTERNAL,        AML_TYPE_BOGUS,           0),
+/* 67 */ ACPI_OP ("[NamedField]",       ARGP_NAMEDFIELD_OP,        ARGI_NAMEDFIELD_OP,         ACPI_TYPE_ANY,           AML_CLASS_INTERNAL,        AML_TYPE_BOGUS,           AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ),
+/* 68 */ ACPI_OP ("[AccessField]",      ARGP_ACCESSFIELD_OP,       ARGI_ACCESSFIELD_OP,        ACPI_TYPE_ANY,           AML_CLASS_INTERNAL,        AML_TYPE_BOGUS,           0),
+/* 69 */ ACPI_OP ("[StaticString",      ARGP_STATICSTRING_OP,      ARGI_STATICSTRING_OP,       ACPI_TYPE_ANY,           AML_CLASS_INTERNAL,        AML_TYPE_BOGUS,           0),
+/* 6A */ ACPI_OP ("[Return Value]",     ARG_NONE,                  ARG_NONE,                   ACPI_TYPE_ANY,           AML_CLASS_RETURN_VALUE,    AML_TYPE_RETURN,          AML_HAS_ARGS | AML_HAS_RETVAL),
+/* 6B */ ACPI_OP ("UNKNOWN_OP!",        ARG_NONE,                  ARG_NONE,                   INTERNAL_TYPE_INVALID,   AML_CLASS_UNKNOWN,         AML_TYPE_BOGUS,           AML_HAS_ARGS),
+/* 6C */ ACPI_OP ("ASCII_ONLY!",        ARG_NONE,                  ARG_NONE,                   ACPI_TYPE_ANY,           AML_CLASS_ASCII,           AML_TYPE_BOGUS,           AML_HAS_ARGS),
+/* 6D */ ACPI_OP ("PREFIX_ONLY!",       ARG_NONE,                  ARG_NONE,                   ACPI_TYPE_ANY,           AML_CLASS_PREFIX,          AML_TYPE_BOGUS,           AML_HAS_ARGS),
 
 
 /* ACPI 2.0 opcodes */
 
-/* 6_e */ ACPI_OP ("Qword_const",       ARGP_QWORD_OP,             ARGI_QWORD_OP,              AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         0),
-/* 6_f */ ACPI_OP ("Var_package",       ARGP_VAR_PACKAGE_OP,       ARGI_VAR_PACKAGE_OP,        AML_CLASS_ARGUMENT,        AML_TYPE_DATA_TERM,       AML_HAS_ARGS | AML_DEFER),
-/* 70 */ ACPI_OP ("Concat_res",         ARGP_CONCAT_RES_OP,        ARGI_CONCAT_RES_OP,         AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R),
-/* 71 */ ACPI_OP ("Mod",                ARGP_MOD_OP,               ARGI_MOD_OP,                AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R),
-/* 72 */ ACPI_OP ("Create_qWord_field", ARGP_CREATE_QWORD_FIELD_OP,ARGI_CREATE_QWORD_FIELD_OP, AML_CLASS_CREATE,          AML_TYPE_CREATE_FIELD,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
-/* 73 */ ACPI_OP ("To_buffer",          ARGP_TO_BUFFER_OP,         ARGI_TO_BUFFER_OP,          AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
-/* 74 */ ACPI_OP ("To_decimal_string",  ARGP_TO_DEC_STR_OP,        ARGI_TO_DEC_STR_OP,         AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
-/* 75 */ ACPI_OP ("To_hex_string",      ARGP_TO_HEX_STR_OP,        ARGI_TO_HEX_STR_OP,         AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
-/* 76 */ ACPI_OP ("To_integer",         ARGP_TO_INTEGER_OP,        ARGI_TO_INTEGER_OP,         AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
-/* 77 */ ACPI_OP ("To_string",          ARGP_TO_STRING_OP,         ARGI_TO_STRING_OP,          AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R),
-/* 78 */ ACPI_OP ("Copy_object",        ARGP_COPY_OP,              ARGI_COPY_OP,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
-/* 79 */ ACPI_OP ("Mid",                ARGP_MID_OP,               ARGI_MID_OP,                AML_CLASS_EXECUTE,         AML_TYPE_EXEC_3A_1T_1R,   AML_FLAGS_EXEC_3A_1T_1R),
-/* 7_a */ ACPI_OP ("Continue",          ARGP_CONTINUE_OP,          ARGI_CONTINUE_OP,           AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         0),
-/* 7_b */ ACPI_OP ("Load_table",        ARGP_LOAD_TABLE_OP,        ARGI_LOAD_TABLE_OP,         AML_CLASS_EXECUTE,         AML_TYPE_EXEC_6A_0T_1R,   AML_FLAGS_EXEC_6A_0T_1R),
-/* 7_c */ ACPI_OP ("Data_op_region",    ARGP_DATA_REGION_OP,       ARGI_DATA_REGION_OP,        AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
-
+/* 6E */ ACPI_OP ("QwordConst",         ARGP_QWORD_OP,             ARGI_QWORD_OP,              ACPI_TYPE_INTEGER,       AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         0),
+/* 6F */ ACPI_OP ("Package /*Var*/",    ARGP_VAR_PACKAGE_OP,       ARGI_VAR_PACKAGE_OP,        ACPI_TYPE_PACKAGE,       AML_CLASS_ARGUMENT,        AML_TYPE_DATA_TERM,       AML_HAS_ARGS | AML_DEFER),
+/* 70 */ ACPI_OP ("ConcatenateResTemplate", ARGP_CONCAT_RES_OP,    ARGI_CONCAT_RES_OP,         ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R),
+/* 71 */ ACPI_OP ("Mod",                ARGP_MOD_OP,               ARGI_MOD_OP,                ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R),
+/* 72 */ ACPI_OP ("CreateQWordField",   ARGP_CREATE_QWORD_FIELD_OP,ARGI_CREATE_QWORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD,  AML_CLASS_CREATE,          AML_TYPE_CREATE_FIELD,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
+/* 73 */ ACPI_OP ("ToBuffer",           ARGP_TO_BUFFER_OP,         ARGI_TO_BUFFER_OP,          ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
+/* 74 */ ACPI_OP ("ToDecimalString",    ARGP_TO_DEC_STR_OP,        ARGI_TO_DEC_STR_OP,         ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
+/* 75 */ ACPI_OP ("ToHexString",        ARGP_TO_HEX_STR_OP,        ARGI_TO_HEX_STR_OP,         ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
+/* 76 */ ACPI_OP ("ToInteger",          ARGP_TO_INTEGER_OP,        ARGI_TO_INTEGER_OP,         ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
+/* 77 */ ACPI_OP ("ToString",           ARGP_TO_STRING_OP,         ARGI_TO_STRING_OP,          ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_1T_1R,   AML_FLAGS_EXEC_2A_1T_1R),
+/* 78 */ ACPI_OP ("CopyObject",         ARGP_COPY_OP,              ARGI_COPY_OP,               ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_1T_1R,   AML_FLAGS_EXEC_1A_1T_1R),
+/* 79 */ ACPI_OP ("Mid",                ARGP_MID_OP,               ARGI_MID_OP,                ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_3A_1T_1R,   AML_FLAGS_EXEC_3A_1T_1R),
+/* 7A */ ACPI_OP ("Continue",           ARGP_CONTINUE_OP,          ARGI_CONTINUE_OP,           ACPI_TYPE_ANY,           AML_CLASS_CONTROL,         AML_TYPE_CONTROL,         0),
+/* 7B */ ACPI_OP ("LoadTable",          ARGP_LOAD_TABLE_OP,        ARGI_LOAD_TABLE_OP,         ACPI_TYPE_ANY,           AML_CLASS_EXECUTE,         AML_TYPE_EXEC_6A_0T_1R,   AML_FLAGS_EXEC_6A_0T_1R),
+/* 7C */ ACPI_OP ("DataTableRegion",    ARGP_DATA_REGION_OP,       ARGI_DATA_REGION_OP,        ACPI_TYPE_REGION,        AML_CLASS_NAMED_OBJECT,    AML_TYPE_NAMED_SIMPLE,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
+
+/*! [End] no source code translation !*/
 };
 
 /*
@@ -594,7 +596,7 @@ static const acpi_opcode_info    aml_op_info[] =
  * index into the table above
  */
 
-static const u8 aml_short_op_info_index[256] =
+static const u8 acpi_gbl_short_op_index[256] =
 {
 /*              0     1     2     3     4     5     6     7  */
 /*              8     9     A     B     C     D     E     F  */
@@ -633,7 +635,7 @@ static const u8 aml_short_op_info_index[256] =
 };
 
 
-static const u8 aml_long_op_info_index[NUM_EXTENDED_OPCODE] =
+static const u8 acpi_gbl_long_op_index[NUM_EXTENDED_OPCODE] =
 {
 /*              0     1     2     3     4     5     6     7  */
 /*              8     9     A     B     C     D     E     F  */
@@ -676,57 +678,39 @@ const acpi_opcode_info *
 acpi_ps_get_opcode_info (
        u16                     opcode)
 {
-       const acpi_opcode_info  *op_info;
-       u8                      upper_opcode;
-       u8                      lower_opcode;
-
-
-       PROC_NAME ("Ps_get_opcode_info");
-
-
-       /* Split the 16-bit opcode into separate bytes */
-
-       upper_opcode = (u8) (opcode >> 8);
-       lower_opcode = (u8) opcode;
-
-       /* Default is "unknown opcode" */
-
-       op_info = &aml_op_info [_UNK];
+       ACPI_FUNCTION_NAME ("Ps_get_opcode_info");
 
 
        /*
         * Detect normal 8-bit opcode or extended 16-bit opcode
         */
-
-       switch (upper_opcode) {
+       switch ((u8) (opcode >> 8)) {
        case 0:
 
                /* Simple (8-bit) opcode: 0-255, can't index beyond table  */
 
-               op_info = &aml_op_info [aml_short_op_info_index [lower_opcode]];
-               break;
-
+               return (&acpi_gbl_aml_op_info [acpi_gbl_short_op_index [(u8) opcode]]);
 
        case AML_EXTOP:
 
                /* Extended (16-bit, prefix+opcode) opcode */
 
-               if (lower_opcode <= MAX_EXTENDED_OPCODE) {
-                       op_info = &aml_op_info [aml_long_op_info_index [lower_opcode]];
+               if (((u8) opcode) <= MAX_EXTENDED_OPCODE) {
+                       return (&acpi_gbl_aml_op_info [acpi_gbl_long_op_index [(u8) opcode]]);
                }
-               break;
 
+               /* Else fall through to error case below */
 
        default:
 
-               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown extended opcode=%X\n", opcode));
+               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown extended opcode [%X]\n", opcode));
                break;
        }
 
 
-       /* Get the Op info pointer for this opcode */
+       /* Default is "unknown opcode" */
 
-       return (op_info);
+       return (&acpi_gbl_aml_op_info [_UNK]);
 }
 
 
@@ -747,6 +731,8 @@ NATIVE_CHAR *
 acpi_ps_get_opcode_name (
        u16                     opcode)
 {
+#ifdef ACPI_DEBUG
+
        const acpi_opcode_info  *op;
 
 
@@ -754,10 +740,11 @@ acpi_ps_get_opcode_name (
 
        /* Always guaranteed to return a valid pointer */
 
-#ifdef ACPI_DEBUG
        return (op->name);
+
 #else
        return ("AE_NOT_CONFIGURED");
+
 #endif
 }
 
index fe5847e41930f876867ae44d678932b5b99e657d..16e01da2bad45f64e1591db38109bcb4f84feeab 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: psparse - Parser top level AML parse routines
- *              $Revision: 104 $
+ *              $Revision: 119 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -42,7 +42,7 @@
 #include "acinterp.h"
 
 #define _COMPONENT          ACPI_PARSER
-        MODULE_NAME         ("psparse")
+        ACPI_MODULE_NAME    ("psparse")
 
 
 u32                         acpi_gbl_depth = 0;
@@ -61,7 +61,7 @@ extern u32                  acpi_gbl_scope_depth;
  *
  ******************************************************************************/
 
-static u32
+u32
 acpi_ps_get_opcode_size (
        u32                     opcode)
 {
@@ -99,32 +99,16 @@ acpi_ps_peek_opcode (
 
 
        aml = parser_state->aml;
-       opcode = (u16) GET8 (aml);
+       opcode = (u16) ACPI_GET8 (aml);
 
-       aml++;
 
-
-       /*
-        * Original code special cased LNOTEQUAL, LLESSEQUAL, LGREATEREQUAL.
-        * These opcodes are no longer recognized. Instead, they are broken into
-        * two opcodes.
-        *
-        *
-        *    if (Opcode == AML_EXTOP
-        *       || (Opcode == AML_LNOT
-        *          && (GET8 (Aml) == AML_LEQUAL
-        *               || GET8 (Aml) == AML_LGREATER
-        *               || GET8 (Aml) == AML_LLESS)))
-        *
-        *     extended Opcode, !=, <=, or >=
-        */
        if (opcode == AML_EXTOP) {
                /* Extended opcode */
 
-               opcode = (u16) ((opcode << 8) | GET8 (aml));
+               aml++;
+               opcode = (u16) ((opcode << 8) | ACPI_GET8 (aml));
        }
 
-
        return (opcode);
 }
 
@@ -194,7 +178,7 @@ acpi_ps_find_object (
  *
  ******************************************************************************/
 
-static u8
+u8
 acpi_ps_complete_this_op (
        acpi_walk_state         *walk_state,
        acpi_parse_object       *op)
@@ -206,8 +190,14 @@ acpi_ps_complete_this_op (
        acpi_parse_object       *replacement_op = NULL;
 
 
-       FUNCTION_TRACE_PTR ("Ps_complete_this_op", op);
+       ACPI_FUNCTION_TRACE_PTR ("Ps_complete_this_op", op);
+
 
+       /* Check for null Op, can happen if AML code is corrupt */
+
+       if (!op) {
+               return_VALUE (TRUE);
+       }
 
        /* Delete this op and the subtree below it if asked to */
 
@@ -223,29 +213,34 @@ acpi_ps_complete_this_op (
                        parent_info = acpi_ps_get_opcode_info (op->parent->opcode);
 
                        switch (parent_info->class) {
-                       case AML_CLASS_CONTROL:        /* IF, ELSE, WHILE only */
+                       case AML_CLASS_CONTROL:
                                break;
 
-                       case AML_CLASS_NAMED_OBJECT:   /* Scope, method, etc. */
                        case AML_CLASS_CREATE:
 
+                               /*
+                                * These opcodes contain Term_arg operands. The current
+                                * op must be replace by a placeholder return op
+                                */
+                               replacement_op = acpi_ps_alloc_op (AML_INT_RETURN_VALUE_OP);
+                               if (!replacement_op) {
+                                       return_VALUE (FALSE);
+                               }
+                               break;
+
+                       case AML_CLASS_NAMED_OBJECT:
+
                                /*
                                 * These opcodes contain Term_arg operands. The current
                                 * op must be replace by a placeholder return op
                                 */
                                if ((op->parent->opcode == AML_REGION_OP)               ||
-                                       (op->parent->opcode == AML_CREATE_FIELD_OP)         ||
-                                       (op->parent->opcode == AML_CREATE_BIT_FIELD_OP)     ||
-                                       (op->parent->opcode == AML_CREATE_BYTE_FIELD_OP)    ||
-                                       (op->parent->opcode == AML_CREATE_WORD_FIELD_OP)    ||
-                                       (op->parent->opcode == AML_CREATE_DWORD_FIELD_OP)   ||
-                                       (op->parent->opcode == AML_CREATE_QWORD_FIELD_OP)) {
+                                       (op->parent->opcode == AML_DATA_REGION_OP)) {
                                        replacement_op = acpi_ps_alloc_op (AML_INT_RETURN_VALUE_OP);
                                        if (!replacement_op) {
                                                return_VALUE (FALSE);
                                        }
                                }
-
                                break;
 
                        default:
@@ -294,7 +289,6 @@ acpi_ps_complete_this_op (
 
                                prev = next;
                        }
-
                }
 
                /* Now we can actually delete the subtree rooted at op */
@@ -324,7 +318,7 @@ acpi_ps_complete_this_op (
  *
  ******************************************************************************/
 
-static acpi_status
+acpi_status
 acpi_ps_next_parse_state (
        acpi_walk_state         *walk_state,
        acpi_parse_object       *op,
@@ -332,11 +326,9 @@ acpi_ps_next_parse_state (
 {
        acpi_parse_state        *parser_state = &walk_state->parser_state;
        acpi_status             status = AE_CTRL_PENDING;
-       u8                      *start;
-       u32                     package_length;
 
 
-       FUNCTION_TRACE_PTR ("Ps_next_parse_state", op);
+       ACPI_FUNCTION_TRACE_PTR ("Ps_next_parse_state", op);
 
 
        switch (callback_status) {
@@ -351,32 +343,33 @@ acpi_ps_next_parse_state (
                break;
 
 
-       case AE_CTRL_PENDING:
+       case AE_CTRL_BREAK:
 
-               /*
-                * Predicate of a WHILE was true and the loop just completed an
-                * execution.  Go back to the start of the loop and reevaluate the
-                * predicate.
-                */
+               parser_state->aml = walk_state->aml_last_while;
+               walk_state->control_state->common.value = FALSE;
+               status = AE_CTRL_BREAK;
+               break;
+
+       case AE_CTRL_CONTINUE:
 
-               /* TBD: How to handle a break within a while. */
-               /* This code attempts it */
+
+               parser_state->aml = walk_state->aml_last_while;
+               status = AE_CTRL_CONTINUE;
+               break;
+
+       case AE_CTRL_PENDING:
 
                parser_state->aml = walk_state->aml_last_while;
                break;
 
 
        case AE_CTRL_TRUE:
+
                /*
                 * Predicate of an IF was true, and we are at the matching ELSE.
                 * Just close out this package
-                *
-                * Note: Parser_state->Aml is modified by the package length procedure
-                * TBD: [Investigate] perhaps it shouldn't, too much trouble
                 */
-               start = parser_state->aml;
-               package_length = acpi_ps_get_next_package_length (parser_state);
-               parser_state->aml = start + package_length;
+               parser_state->aml = acpi_ps_get_next_package_end (parser_state);
                break;
 
 
@@ -451,14 +444,14 @@ acpi_ps_parse_loop (
        u8                      *aml_op_start;
 
 
-       FUNCTION_TRACE_PTR ("Ps_parse_loop", walk_state);
+       ACPI_FUNCTION_TRACE_PTR ("Ps_parse_loop", walk_state);
 
 
        parser_state = &walk_state->parser_state;
        walk_state->arg_types = 0;
 
 #ifndef PARSER_ONLY
-       if (walk_state->walk_type & WALK_METHOD_RESTART) {
+       if (walk_state->walk_type & ACPI_WALK_METHOD_RESTART) {
                /* We are restarting a preempted control method */
 
                if (acpi_ps_has_completed_scope (parser_state)) {
@@ -471,14 +464,14 @@ acpi_ps_parse_loop (
                                (parser_state->scope->parse_scope.op->opcode == AML_WHILE_OP)) &&
                                (walk_state->control_state) &&
                                (walk_state->control_state->common.state ==
-                                       CONTROL_PREDICATE_EXECUTING)) {
+                                       ACPI_CONTROL_PREDICATE_EXECUTING)) {
 
                                /*
                                 * A predicate was just completed, get the value of the
                                 * predicate and branch based on that value
                                 */
                                walk_state->op = NULL;
-                               status = acpi_ds_get_predicate_value (walk_state, TRUE);
+                               status = acpi_ds_get_predicate_value (walk_state, ACPI_TO_POINTER (TRUE));
                                if (ACPI_FAILURE (status) &&
                                        ((status & AE_CODE_MASK) != AE_CODE_CONTROL)) {
                                        if (status == AE_AML_NO_RETURN_VALUE) {
@@ -545,7 +538,7 @@ acpi_ps_parse_loop (
                                        "Found unknown opcode %X at AML offset %X, ignoring\n",
                                        walk_state->opcode, walk_state->aml_offset));
 
-                               DUMP_BUFFER (parser_state->aml, 128);
+                               ACPI_DUMP_BUFFER (parser_state->aml, 128);
 
                                /* Assume one-byte bad opcode */
 
@@ -590,9 +583,6 @@ acpi_ps_parse_loop (
                                        walk_state->op = NULL;
 
                                        status = walk_state->descending_callback (walk_state, &op);
-
-                                       /* TBD: check status here? */
-
                                        if (ACPI_FAILURE (status)) {
                                                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "During name lookup/catalog, %s\n",
                                                                acpi_format_exception (status)));
@@ -602,6 +592,7 @@ acpi_ps_parse_loop (
                                        if (op == NULL) {
                                                continue;
                                        }
+
                                        status = acpi_ps_next_parse_state (walk_state, op, status);
                                        if (status == AE_CTRL_PENDING) {
                                                status = AE_OK;
@@ -616,7 +607,6 @@ acpi_ps_parse_loop (
                                acpi_ps_append_arg (op, pre_op.value.arg);
                                acpi_gbl_depth++;
 
-
                                if (op->opcode == AML_REGION_OP) {
                                        /*
                                         * Defer final parsing of an Operation_region body,
@@ -635,7 +625,6 @@ acpi_ps_parse_loop (
                                }
                        }
 
-
                        else {
                                /* Not a named opcode, just allocate Op and append to parent */
 
@@ -645,7 +634,6 @@ acpi_ps_parse_loop (
                                        return_ACPI_STATUS (AE_NO_MEMORY);
                                }
 
-
                                if (walk_state->op_info->flags & AML_CREATE) {
                                        /*
                                         * Backup to beginning of Create_xXXfield declaration
@@ -662,7 +650,7 @@ acpi_ps_parse_loop (
                                         * Find the object.  This will either insert the object into
                                         * the namespace or simply look it up
                                         */
-                                       walk_state->op    = op;
+                                       walk_state->op = op;
 
                                        status = walk_state->descending_callback (walk_state, &op);
                                        status = acpi_ps_next_parse_state (walk_state, op, status);
@@ -681,8 +669,8 @@ acpi_ps_parse_loop (
 
                        if (walk_state->op_info) {
                                ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
-                                       "Op=%p Opcode=%4.4X Aml %p Oft=%5.5X\n",
-                                        op, op->opcode, parser_state->aml, op->aml_offset));
+                                       "Opcode %4.4X [%s] Op %p Aml %p Aml_offset %5.5X\n",
+                                        op->opcode, walk_state->op_info->name, op, parser_state->aml, op->aml_offset));
                        }
                }
 
@@ -691,7 +679,6 @@ acpi_ps_parse_loop (
 
                walk_state->arg_count = 0;
 
-
                if (walk_state->arg_types) /* Are there any arguments that must be processed? */ {
                        /* get arguments */
 
@@ -732,7 +719,6 @@ acpi_ps_parse_loop (
                                        INCREMENT_ARG_LIST (walk_state->arg_types);
                                }
 
-
                                /* For a method, save the length and address of the body */
 
                                if (op->opcode == AML_METHOD_OP) {
@@ -741,9 +727,9 @@ acpi_ps_parse_loop (
                                         * because we don't have enough info in the first pass
                                         * to parse them correctly.
                                         */
-                                       ((acpi_parse2_object * ) op)->data    = parser_state->aml;
-                                       ((acpi_parse2_object * ) op)->length  = (u32) (parser_state->pkg_end -
-                                                          parser_state->aml);
+                                       ((acpi_parse2_object * ) op)->data   = parser_state->aml;
+                                       ((acpi_parse2_object * ) op)->length = (u32) (parser_state->pkg_end -
+                                                         parser_state->aml);
 
                                        /*
                                         * Skip body of method.  For Op_regions, we must continue
@@ -751,166 +737,193 @@ acpi_ps_parse_loop (
                                         * package (We don't know where the end is).
                                         */
                                        parser_state->aml   = parser_state->pkg_end;
-                                       walk_state->arg_count          = 0;
+                                       walk_state->arg_count = 0;
+                               }
+                               else if (op->opcode == AML_WHILE_OP) {
+                                       if (walk_state->control_state) {
+                                               walk_state->control_state->control.package_end = parser_state->pkg_end;
+                                       }
                                }
-
                                break;
                        }
                }
 
 
-               /*
-                * Zero Arg_count means that all arguments for this op have been processed
-                */
-               if (!walk_state->arg_count) {
-                       /* completed Op, prepare for next */
+               /* Check for arguments that need to be processed */
 
-                       walk_state->op_info = acpi_ps_get_opcode_info (op->opcode);
-                       if (walk_state->op_info->flags & AML_NAMED) {
-                               if (acpi_gbl_depth) {
-                                       acpi_gbl_depth--;
-                               }
+               if (walk_state->arg_count) {
+                       /* There are arguments (complex ones), push Op and prepare for argument */
 
-                               if (op->opcode == AML_REGION_OP) {
-                                       /*
-                                        * Skip parsing of control method or opregion body,
-                                        * because we don't have enough info in the first pass
-                                        * to parse them correctly.
-                                        *
-                                        * Completed parsing an Op_region declaration, we now
-                                        * know the length.
-                                        */
-                                       ((acpi_parse2_object * ) op)->length = (u32) (parser_state->aml -
-                                                          ((acpi_parse2_object * ) op)->data);
-                               }
+                       acpi_ps_push_scope (parser_state, op, walk_state->arg_types, walk_state->arg_count);
+                       op = NULL;
+                       continue;
+               }
+
+
+               /* All arguments have been processed -- Op is complete, prepare for next */
+
+               walk_state->op_info = acpi_ps_get_opcode_info (op->opcode);
+               if (walk_state->op_info->flags & AML_NAMED) {
+                       if (acpi_gbl_depth) {
+                               acpi_gbl_depth--;
                        }
 
-                       if (walk_state->op_info->flags & AML_CREATE) {
+                       if (op->opcode == AML_REGION_OP) {
                                /*
-                                * Backup to beginning of Create_xXXfield declaration (1 for
-                                * Opcode)
+                                * Skip parsing of control method or opregion body,
+                                * because we don't have enough info in the first pass
+                                * to parse them correctly.
                                 *
-                                * Body_length is unknown until we parse the body
+                                * Completed parsing an Op_region declaration, we now
+                                * know the length.
                                 */
                                ((acpi_parse2_object * ) op)->length = (u32) (parser_state->aml -
                                                   ((acpi_parse2_object * ) op)->data);
                        }
+               }
 
-                       /* This op complete, notify the dispatcher */
+               if (walk_state->op_info->flags & AML_CREATE) {
+                       /*
+                        * Backup to beginning of Create_xXXfield declaration (1 for
+                        * Opcode)
+                        *
+                        * Body_length is unknown until we parse the body
+                        */
+                       ((acpi_parse2_object * ) op)->length = (u32) (parser_state->aml -
+                                          ((acpi_parse2_object * ) op)->data);
+               }
 
-                       if (walk_state->ascending_callback != NULL) {
-                               walk_state->op    = op;
-                               walk_state->opcode = op->opcode;
+               /* This op complete, notify the dispatcher */
 
-                               status = walk_state->ascending_callback (walk_state);
-                               status = acpi_ps_next_parse_state (walk_state, op, status);
-                               if (status == AE_CTRL_PENDING) {
-                                       status = AE_OK;
-                                       goto close_this_op;
-                               }
+               if (walk_state->ascending_callback != NULL) {
+                       walk_state->op    = op;
+                       walk_state->opcode = op->opcode;
+
+                       status = walk_state->ascending_callback (walk_state);
+                       status = acpi_ps_next_parse_state (walk_state, op, status);
+                       if (status == AE_CTRL_PENDING) {
+                               status = AE_OK;
+                               goto close_this_op;
                        }
+               }
 
 
 close_this_op:
+               /*
+                * Finished one argument of the containing scope
+                */
+               parser_state->scope->parse_scope.arg_count--;
+
+               /* Close this Op (may result in parse subtree deletion) */
+
+               if (acpi_ps_complete_this_op (walk_state, op)) {
+                       op = NULL;
+               }
+
+               switch (status) {
+               case AE_OK:
+                       break;
+
+
+               case AE_CTRL_TRANSFER:
 
                        /*
-                        * Finished one argument of the containing scope
+                        * We are about to transfer to a called method.
                         */
-                       parser_state->scope->parse_scope.arg_count--;
+                       walk_state->prev_op = op;
+                       walk_state->prev_arg_types = walk_state->arg_types;
+                       return_ACPI_STATUS (status);
 
-                       /* Close this Op (may result in parse subtree deletion) */
 
-                       if (acpi_ps_complete_this_op (walk_state, op)) {
-                               op = NULL;
-                       }
+               case AE_CTRL_END:
 
+                       acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types, &walk_state->arg_count);
 
-                       switch (status) {
-                       case AE_OK:
-                               break;
+                       walk_state->op    = op;
+                       walk_state->op_info = acpi_ps_get_opcode_info (op->opcode);
+                       walk_state->opcode = op->opcode;
 
+                       status = walk_state->ascending_callback (walk_state);
+                       status = acpi_ps_next_parse_state (walk_state, op, status);
 
-                       case AE_CTRL_TRANSFER:
+                       acpi_ps_complete_this_op (walk_state, op);
+                       op = NULL;
+                       status = AE_OK;
+                       break;
 
-                               /*
-                                * We are about to transfer to a called method.
-                                */
-                               walk_state->prev_op = op;
-                               walk_state->prev_arg_types = walk_state->arg_types;
-                               return_ACPI_STATUS (status);
-                               break;
 
+               case AE_CTRL_BREAK:
+               case AE_CTRL_CONTINUE:
 
-                       case AE_CTRL_END:
+                       /* Pop off scopes until we find the While */
 
+                       while (!op || (op->opcode != AML_WHILE_OP)) {
                                acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types, &walk_state->arg_count);
+                       }
 
-                               walk_state->op    = op;
-                               walk_state->op_info = acpi_ps_get_opcode_info (op->opcode);
-                               walk_state->opcode = op->opcode;
+                       /* Close this iteration of the While loop */
 
-                               status = walk_state->ascending_callback (walk_state);
-                               status = acpi_ps_next_parse_state (walk_state, op, status);
+                       walk_state->op    = op;
+                       walk_state->op_info = acpi_ps_get_opcode_info (op->opcode);
+                       walk_state->opcode = op->opcode;
 
-                               acpi_ps_complete_this_op (walk_state, op);
-                               op = NULL;
-                               status = AE_OK;
-                               break;
+                       status = walk_state->ascending_callback (walk_state);
+                       status = acpi_ps_next_parse_state (walk_state, op, status);
 
+                       acpi_ps_complete_this_op (walk_state, op);
+                       op = NULL;
 
-                       case AE_CTRL_TERMINATE:
+                       status = AE_OK;
+                       break;
 
-                               status = AE_OK;
 
-                               /* Clean up */
-                               do {
-                                       if (op) {
-                                               acpi_ps_complete_this_op (walk_state, op);
-                                       }
+               case AE_CTRL_TERMINATE:
 
-                                       acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types, &walk_state->arg_count);
-                               } while (op);
+                       status = AE_OK;
 
-                               return_ACPI_STATUS (status);
-                               break;
+                       /* Clean up */
+                       do {
+                               if (op) {
+                                       acpi_ps_complete_this_op (walk_state, op);
+                               }
+                               acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types, &walk_state->arg_count);
 
+                       } while (op);
 
-                       default:  /* All other non-AE_OK status */
+                       return_ACPI_STATUS (status);
 
-                               if (op == NULL) {
-                                       acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types, &walk_state->arg_count);
-                               }
-                               walk_state->prev_op = op;
-                               walk_state->prev_arg_types = walk_state->arg_types;
 
-                               /*
-                                * TEMP:
-                                */
+               default:  /* All other non-AE_OK status */
 
-                               return_ACPI_STATUS (status);
-                               break;
-                       }
+                       do {
+                               if (op) {
+                                       acpi_ps_complete_this_op (walk_state, op);
+                               }
+                               acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types, &walk_state->arg_count);
 
-                       /* This scope complete? */
+                       } while (op);
 
-                       if (acpi_ps_has_completed_scope (parser_state)) {
-                               acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types, &walk_state->arg_count);
-                               ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", op));
-                       }
 
-                       else {
-                               op = NULL;
+                       /*
+                        * TBD: Cleanup parse ops on error
+                        */
+#if 0
+                       if (op == NULL) {
+                               acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types, &walk_state->arg_count);
                        }
-
+#endif
+                       walk_state->prev_op = op;
+                       walk_state->prev_arg_types = walk_state->arg_types;
+                       return_ACPI_STATUS (status);
                }
 
+               /* This scope complete? */
 
-               /* Arg_count is non-zero */
-
+               if (acpi_ps_has_completed_scope (parser_state)) {
+                       acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types, &walk_state->arg_count);
+                       ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", op));
+               }
                else {
-                       /* complex argument, push Op and prepare for argument */
-
-                       acpi_ps_push_scope (parser_state, op, walk_state->arg_types, walk_state->arg_count);
                        op = NULL;
                }
 
@@ -992,30 +1005,32 @@ acpi_ps_parse_aml (
        acpi_walk_state         *walk_state)
 {
        acpi_status             status;
-       acpi_walk_list          walk_list;
-       acpi_walk_list          *prev_walk_list = acpi_gbl_current_walk_list;
+       ACPI_THREAD_STATE       *thread;
+       ACPI_THREAD_STATE       *prev_walk_list = acpi_gbl_current_walk_list;
        acpi_walk_state         *previous_walk_state;
 
 
-       FUNCTION_TRACE ("Ps_parse_aml");
+       ACPI_FUNCTION_TRACE ("Ps_parse_aml");
 
        ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Entered with Walk_state=%p Aml=%p size=%X\n",
                walk_state, walk_state->parser_state.aml, walk_state->parser_state.aml_size));
 
 
-       /* Create and initialize a new walk list */
+       /* Create and initialize a new thread state */
 
-       walk_list.walk_state            = NULL;
-       walk_list.acquired_mutex_list.prev = NULL;
-       walk_list.acquired_mutex_list.next = NULL;
-
-       walk_state->walk_list = &walk_list;
-       acpi_ds_push_walk_state (walk_state, &walk_list);
+       thread = acpi_ut_create_thread_state ();
+       if (!thread) {
+               return_ACPI_STATUS (AE_NO_MEMORY);
+       }
 
+       walk_state->thread = thread;
+       acpi_ds_push_walk_state (walk_state, thread);
 
-       /* TBD: [Restructure] TEMP until we pass Walk_state to the interpreter
+       /*
+        * This global allows the AML debugger to get a handle to the currently
+        * executing control method.
         */
-       acpi_gbl_current_walk_list = &walk_list;
+       acpi_gbl_current_walk_list = thread;
 
        /*
         * Execute the walk loop as long as there is a valid Walk State.  This
@@ -1041,13 +1056,13 @@ acpi_ps_parse_aml (
                         * A method call was detected.
                         * Transfer control to the called control method
                         */
-                       status = acpi_ds_call_control_method (&walk_list, walk_state, NULL);
+                       status = acpi_ds_call_control_method (thread, walk_state, NULL);
 
                        /*
                         * If the transfer to the new method method call worked, a new walk
                         * state was created -- get it
                         */
-                       walk_state = acpi_ds_get_current_walk_state (&walk_list);
+                       walk_state = acpi_ds_get_current_walk_state (thread);
                        continue;
                }
 
@@ -1057,7 +1072,7 @@ acpi_ps_parse_aml (
 
                /* We are done with this walk, move on to the parent if any */
 
-               walk_state = acpi_ds_pop_walk_state (&walk_list);
+               walk_state = acpi_ds_pop_walk_state (thread);
 
                /* Reset the current scope to the beginning of scope stack */
 
@@ -1082,17 +1097,25 @@ acpi_ps_parse_aml (
 
                /* Check if we have restarted a preempted walk */
 
-               walk_state = acpi_ds_get_current_walk_state (&walk_list);
+               walk_state = acpi_ds_get_current_walk_state (thread);
                if (walk_state) {
                        if (ACPI_SUCCESS (status)) {
-                               /* There is another walk state, restart it */
-
                                /*
-                                * If the method returned value is not used by the parent,
+                                * There is another walk state, restart it.
+                                * If the method return value is not used by the parent,
                                 * The object is deleted
                                 */
                                acpi_ds_restart_control_method (walk_state, previous_walk_state->return_desc);
-                               walk_state->walk_type |= WALK_METHOD_RESTART;
+                               walk_state->walk_type |= ACPI_WALK_METHOD_RESTART;
+                       }
+                       else {
+                               /* On error, delete any return object */
+
+                               acpi_ut_remove_reference (previous_walk_state->return_desc);
+
+                               ACPI_REPORT_ERROR (("Method execution failed, %s\n", acpi_format_exception (status)));
+                               ACPI_DUMP_PATHNAME (walk_state->method_node, "Method pathname: ",
+                                       ACPI_LV_ERROR, _COMPONENT);
                        }
                }
 
@@ -1113,10 +1136,10 @@ acpi_ps_parse_aml (
                acpi_ds_delete_walk_state (previous_walk_state);
        }
 
-
        /* Normal exit */
 
-       acpi_ex_release_all_mutexes ((acpi_operand_object *) &walk_list.acquired_mutex_list);
+       acpi_ex_release_all_mutexes (thread);
+       acpi_ut_delete_generic_state ((acpi_generic_state *) thread);
        acpi_gbl_current_walk_list = prev_walk_list;
        return_ACPI_STATUS (status);
 }
index a76a6b174c608893ae83fb65945b248f01401601..900651c41813ab2180da2b704716124e438d94b8 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: psscope - Parser scope stack management routines
- *              $Revision: 30 $
+ *              $Revision: 35 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -28,7 +28,7 @@
 #include "acparser.h"
 
 #define _COMPONENT          ACPI_PARSER
-        MODULE_NAME         ("psscope")
+        ACPI_MODULE_NAME    ("psscope")
 
 
 /*******************************************************************************
@@ -95,7 +95,7 @@ acpi_ps_init_scope (
        acpi_generic_state      *scope;
 
 
-       FUNCTION_TRACE_PTR ("Ps_init_scope", root_op);
+       ACPI_FUNCTION_TRACE_PTR ("Ps_init_scope", root_op);
 
 
        scope = acpi_ut_create_generic_state ();
@@ -141,12 +141,12 @@ acpi_ps_push_scope (
        acpi_generic_state      *scope;
 
 
-       FUNCTION_TRACE_PTR ("Ps_push_scope", op);
+       ACPI_FUNCTION_TRACE_PTR ("Ps_push_scope", op);
 
 
        scope = acpi_ut_create_generic_state ();
        if (!scope) {
-               return (AE_NO_MEMORY);
+               return_ACPI_STATUS (AE_NO_MEMORY);
        }
 
 
@@ -170,7 +170,7 @@ acpi_ps_push_scope (
        else {
                /* single argument */
 
-               scope->parse_scope.arg_end = ACPI_MAX_AML;
+               scope->parse_scope.arg_end = ACPI_TO_POINTER (ACPI_MAX_PTR);
        }
 
        return_ACPI_STATUS (AE_OK);
@@ -203,7 +203,7 @@ acpi_ps_pop_scope (
        acpi_generic_state      *scope = parser_state->scope;
 
 
-       FUNCTION_TRACE ("Ps_pop_scope");
+       ACPI_FUNCTION_TRACE ("Ps_pop_scope");
 
 
        /*
@@ -257,7 +257,7 @@ acpi_ps_cleanup_scope (
 {
        acpi_generic_state      *scope;
 
-       FUNCTION_TRACE_PTR ("Ps_cleanup_scope", parser_state);
+       ACPI_FUNCTION_TRACE_PTR ("Ps_cleanup_scope", parser_state);
 
 
        if (!parser_state) {
index 57c623d0c8d7a364e09675fa351b68d7ac353dd9..7e7a345e9f5a95a329531fc2fe0d18d8b2658b60 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: pstree - Parser op tree manipulation/traversal/search
- *              $Revision: 35 $
+ *              $Revision: 37 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -29,7 +29,7 @@
 #include "amlcode.h"
 
 #define _COMPONENT          ACPI_PARSER
-        MODULE_NAME         ("pstree")
+        ACPI_MODULE_NAME    ("pstree")
 
 
 /*******************************************************************************
@@ -54,7 +54,7 @@ acpi_ps_get_arg (
        const acpi_opcode_info  *op_info;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        /* Get the info structure for this opcode */
@@ -108,7 +108,7 @@ acpi_ps_append_arg (
        const acpi_opcode_info  *op_info;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        if (!op) {
@@ -121,7 +121,7 @@ acpi_ps_append_arg (
        if (op_info->class == AML_CLASS_UNKNOWN) {
                /* Invalid opcode */
 
-               REPORT_ERROR (("Ps_append_arg: Invalid AML Opcode: 0x%2.2X\n", op->opcode));
+               ACPI_REPORT_ERROR (("Ps_append_arg: Invalid AML Opcode: 0x%2.2X\n", op->opcode));
                return;
        }
 
@@ -181,7 +181,7 @@ acpi_ps_get_child (
        acpi_parse_object       *child = NULL;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        switch (op->opcode) {
@@ -249,7 +249,7 @@ acpi_ps_get_depth_next (
        acpi_parse_object       *arg;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        if (!op) {
index 7f137319e18f13f580a1b0b379e7bbf0a68c926c..2322fd222e1f5cbaade43f85b975845d9c1f1664 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: psutils - Parser miscellaneous utilities (Parser only)
- *              $Revision: 44 $
+ *              $Revision: 49 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 #include "amlcode.h"
 
 #define _COMPONENT          ACPI_PARSER
-        MODULE_NAME         ("psutils")
-
-
-#define PARSEOP_GENERIC     0x01
-#define PARSEOP_NAMED       0x02
-#define PARSEOP_DEFERRED    0x04
-#define PARSEOP_BYTELIST    0x08
-#define PARSEOP_IN_CACHE    0x80
+        ACPI_MODULE_NAME    ("psutils")
 
 
 /*******************************************************************************
@@ -58,19 +51,14 @@ acpi_ps_init_op (
        acpi_parse_object       *op,
        u16                     opcode)
 {
-       const acpi_opcode_info  *aml_op;
-
-
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        op->data_type = ACPI_DESC_TYPE_PARSER;
        op->opcode = opcode;
 
-       aml_op = acpi_ps_get_opcode_info (opcode);
-
-       DEBUG_ONLY_MEMBERS (STRNCPY (op->op_name, aml_op->name,
-                          sizeof (op->op_name)));
+       ACPI_DEBUG_ONLY_MEMBERS (ACPI_STRNCPY (op->op_name,
+                       (acpi_ps_get_opcode_info (opcode))->name, sizeof (op->op_name)));
 }
 
 
@@ -98,7 +86,7 @@ acpi_ps_alloc_op (
        const acpi_opcode_info  *op_info;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        op_info = acpi_ps_get_opcode_info (opcode);
@@ -107,22 +95,22 @@ acpi_ps_alloc_op (
 
        if (op_info->flags & AML_DEFER) {
                size = sizeof (acpi_parse2_object);
-               flags = PARSEOP_DEFERRED;
+               flags = ACPI_PARSEOP_DEFERRED;
        }
 
        else if (op_info->flags & AML_NAMED) {
                size = sizeof (acpi_parse2_object);
-               flags = PARSEOP_NAMED;
+               flags = ACPI_PARSEOP_NAMED;
        }
 
        else if (opcode == AML_INT_BYTELIST_OP) {
                size = sizeof (acpi_parse2_object);
-               flags = PARSEOP_BYTELIST;
+               flags = ACPI_PARSEOP_BYTELIST;
        }
 
        else {
                size = sizeof (acpi_parse_object);
-               flags = PARSEOP_GENERIC;
+               flags = ACPI_PARSEOP_GENERIC;
        }
 
 
@@ -165,14 +153,14 @@ void
 acpi_ps_free_op (
        acpi_parse_object       *op)
 {
-       PROC_NAME ("Ps_free_op");
+       ACPI_FUNCTION_NAME ("Ps_free_op");
 
 
        if (op->opcode == AML_INT_RETURN_VALUE_OP) {
                ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Free retval op: %p\n", op));
        }
 
-       if (op->flags == PARSEOP_GENERIC) {
+       if (op->flags == ACPI_PARSEOP_GENERIC) {
                acpi_ut_release_to_cache (ACPI_MEM_LIST_PSNODE, op);
        }
 
@@ -198,7 +186,7 @@ void
 acpi_ps_delete_parse_cache (
        void)
 {
-       FUNCTION_TRACE ("Ps_delete_parse_cache");
+       ACPI_FUNCTION_TRACE ("Ps_delete_parse_cache");
 
 
        acpi_ut_delete_generic_cache (ACPI_MEM_LIST_PSNODE);
@@ -249,7 +237,7 @@ acpi_ps_get_name (
 
        /* The "generic" object has no name associated with it */
 
-       if (op->flags & PARSEOP_GENERIC) {
+       if (op->flags & ACPI_PARSEOP_GENERIC) {
                return (0);
        }
 
@@ -270,7 +258,7 @@ acpi_ps_set_name (
 
        /* The "generic" object has no name associated with it */
 
-       if (op->flags & PARSEOP_GENERIC) {
+       if (op->flags & ACPI_PARSEOP_GENERIC) {
                return;
        }
 
index 7aff0d6825fa4dfa6548f5f8d0834ebffb816648..a94a7d7d38dc8b9151080a077aa6188d714d0b9a 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: pswalk - Parser routines to walk parsed op tree(s)
- *              $Revision: 58 $
+ *              $Revision: 63 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -32,7 +32,7 @@
 #include "acinterp.h"
 
 #define _COMPONENT          ACPI_PARSER
-        MODULE_NAME         ("pswalk")
+        ACPI_MODULE_NAME    ("pswalk")
 
 
 /*******************************************************************************
@@ -61,12 +61,12 @@ acpi_ps_get_next_walk_op (
        acpi_status             status;
 
 
-       FUNCTION_TRACE_PTR ("Ps_get_next_walk_op", op);
+       ACPI_FUNCTION_TRACE_PTR ("Ps_get_next_walk_op", op);
 
 
        /* Check for a argument only if we are descending in the tree */
 
-       if (walk_state->next_op_info != NEXT_OP_UPWARD) {
+       if (walk_state->next_op_info != ACPI_NEXT_OP_UPWARD) {
                /* Look for an argument or child of the current op */
 
                next = acpi_ps_get_arg (op, 0);
@@ -75,12 +75,11 @@ acpi_ps_get_next_walk_op (
 
                        walk_state->prev_op     = op;
                        walk_state->next_op     = next;
-                       walk_state->next_op_info = NEXT_OP_DOWNWARD;
+                       walk_state->next_op_info = ACPI_NEXT_OP_DOWNWARD;
 
                        return_ACPI_STATUS (AE_OK);
                }
 
-
                /*
                 * No more children, this Op is complete.  Save Next and Parent
                 * in case the Op object gets deleted by the callback routine
@@ -115,7 +114,7 @@ acpi_ps_get_next_walk_op (
 
                        walk_state->prev_op     = op;
                        walk_state->next_op     = next;
-                       walk_state->next_op_info = NEXT_OP_DOWNWARD;
+                       walk_state->next_op_info = ACPI_NEXT_OP_DOWNWARD;
 
                        /* Continue downward */
 
@@ -127,7 +126,6 @@ acpi_ps_get_next_walk_op (
                 * the tree
                 */
        }
-
        else {
                /*
                 * We are resuming a walk, and we were (are) going upward in the tree.
@@ -136,7 +134,6 @@ acpi_ps_get_next_walk_op (
                parent = op;
        }
 
-
        /*
         * Look for a sibling of the current Op's parent
         * Continue moving up the tree until we find a node that has not been
@@ -175,7 +172,7 @@ acpi_ps_get_next_walk_op (
 
                        walk_state->prev_op     = parent;
                        walk_state->next_op     = next;
-                       walk_state->next_op_info = NEXT_OP_DOWNWARD;
+                       walk_state->next_op_info = ACPI_NEXT_OP_DOWNWARD;
 
                        return_ACPI_STATUS (status);
                }
@@ -188,9 +185,10 @@ acpi_ps_get_next_walk_op (
        }
 
 
-       /* Got all the way to the top of the tree, we must be done! */
-       /* However, the code should have terminated in the loop above */
-
+       /*
+        * Got all the way to the top of the tree, we must be done!
+        * However, the code should have terminated in the loop above
+        */
        walk_state->next_op     = NULL;
 
        return_ACPI_STATUS (AE_OK);
@@ -212,7 +210,7 @@ acpi_ps_get_next_walk_op (
  *
  ******************************************************************************/
 
-static acpi_status
+acpi_status
 acpi_ps_delete_completed_op (
        acpi_walk_state         *walk_state)
 {
@@ -239,10 +237,10 @@ acpi_ps_delete_parse_tree (
        acpi_parse_object       *subtree_root)
 {
        acpi_walk_state         *walk_state;
-       acpi_walk_list          walk_list;
+       ACPI_THREAD_STATE       *thread;
 
 
-       FUNCTION_TRACE_PTR ("Ps_delete_parse_tree", subtree_root);
+       ACPI_FUNCTION_TRACE_PTR ("Ps_delete_parse_tree", subtree_root);
 
 
        if (!subtree_root) {
@@ -251,11 +249,13 @@ acpi_ps_delete_parse_tree (
 
        /* Create and initialize a new walk list */
 
-       walk_list.walk_state = NULL;
-       walk_list.acquired_mutex_list.prev = NULL;
-       walk_list.acquired_mutex_list.next = NULL;
+       thread = acpi_ut_create_thread_state ();
+       if (!thread) {
+               return_VOID;
+       }
+
 
-       walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT, NULL, NULL, &walk_list);
+       walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT, NULL, NULL, thread);
        if (!walk_state) {
                return_VOID;
        }
@@ -264,14 +264,12 @@ acpi_ps_delete_parse_tree (
        walk_state->descending_callback = NULL;
        walk_state->ascending_callback  = NULL;
 
-
        walk_state->origin = subtree_root;
        walk_state->next_op = subtree_root;
 
-
        /* Head downward in the tree */
 
-       walk_state->next_op_info = NEXT_OP_DOWNWARD;
+       walk_state->next_op_info = ACPI_NEXT_OP_DOWNWARD;
 
        /* Visit all nodes in the subtree */
 
@@ -282,7 +280,7 @@ acpi_ps_delete_parse_tree (
 
        /* We are done with this walk */
 
-       acpi_ex_release_all_mutexes ((acpi_operand_object *) &walk_list.acquired_mutex_list);
+       acpi_ut_delete_generic_state ((acpi_generic_state *) thread);
        acpi_ds_delete_walk_state (walk_state);
 
        return_VOID;
index 172d9860b6f2444169e32ec1ee1b45446fc532e5..fb7f37d5dc68804155a07273a0d6cfa117e32e2a 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: psxface - Parser external interfaces
- *              $Revision: 52 $
+ *              $Revision: 59 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -33,7 +33,7 @@
 
 
 #define _COMPONENT          ACPI_PARSER
-        MODULE_NAME         ("psxface")
+        ACPI_MODULE_NAME    ("psxface")
 
 
 /*******************************************************************************
@@ -67,7 +67,7 @@ acpi_psx_execute (
        acpi_walk_state         *walk_state;
 
 
-       FUNCTION_TRACE ("Psx_execute");
+       ACPI_FUNCTION_TRACE ("Psx_execute");
 
 
        /* Validate the Node and get the attached object */
@@ -113,9 +113,16 @@ acpi_psx_execute (
                return_ACPI_STATUS (AE_NO_MEMORY);
        }
 
+       /*
+        * Get a new Owner_id for objects created by this method. Namespace
+        * objects (such as Operation Regions) can be created during the
+        * first pass parse.
+        */
+       obj_desc->method.owning_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_METHOD);
+
        /* Create and initialize a new walk state */
 
-       walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT,
+       walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id,
                           NULL, NULL, NULL);
        if (!walk_state) {
                return_ACPI_STATUS (AE_NO_MEMORY);
@@ -124,7 +131,7 @@ acpi_psx_execute (
        status = acpi_ds_init_aml_walk (walk_state, op, method_node, obj_desc->method.aml_start,
                          obj_desc->method.aml_length, NULL, NULL, 1);
        if (ACPI_FAILURE (status)) {
-               /* TBD: delete walk state */
+               acpi_ds_delete_walk_state (walk_state);
                return_ACPI_STATUS (status);
        }
 
@@ -164,7 +171,7 @@ acpi_psx_execute (
        status = acpi_ds_init_aml_walk (walk_state, op, method_node, obj_desc->method.aml_start,
                          obj_desc->method.aml_length, params, return_obj_desc, 3);
        if (ACPI_FAILURE (status)) {
-               /* TBD: delete walk state */
+               acpi_ds_delete_walk_state (walk_state);
                return_ACPI_STATUS (status);
        }
 
@@ -182,13 +189,6 @@ acpi_psx_execute (
                }
        }
 
-
-       if (ACPI_FAILURE (status)) {
-               DUMP_PATHNAME (method_node, "Ps_execute: method failed -",
-                       ACPI_LV_ERROR, _COMPONENT);
-       }
-
-
        /*
         * If the method has returned an object, signal this to the caller with
         * a control exception code
@@ -196,12 +196,11 @@ acpi_psx_execute (
        if (*return_obj_desc) {
                ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Method returned Obj_desc=%p\n",
                        *return_obj_desc));
-               DUMP_STACK_ENTRY (*return_obj_desc);
+               ACPI_DUMP_STACK_ENTRY (*return_obj_desc);
 
                status = AE_CTRL_RETURN_VALUE;
        }
 
-
        return_ACPI_STATUS (status);
 }
 
index 0714c087172adf7cb040934c0602ec8c336b3ccd..d0bbc7655a46e95b304e00deeca0e7cf8e60f997 100644 (file)
@@ -1,11 +1,10 @@
 #
 # Makefile for all Linux ACPI interpreter subdirectories
-# EXCEPT for the ospm directory
 #
 
 O_TARGET := $(notdir $(CURDIR)).o
 
-obj-$(CONFIG_ACPI) := $(patsubst %.c,%.o,$(wildcard *.c))
+obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
 
index f57b3c13ac9e17fd75d2b2c33f5369e5cd21b830..a509fdec7c365dac43f1308e2da4124e6f58e96a 100644 (file)
@@ -1,12 +1,12 @@
 /*******************************************************************************
  *
  * Module Name: rsaddr - Address resource descriptors (16/32/64)
- *              $Revision: 19 $
+ *              $Revision: 24 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -28,7 +28,7 @@
 #include "acresrc.h"
 
 #define _COMPONENT          ACPI_RESOURCES
-        MODULE_NAME         ("rsaddr")
+        ACPI_MODULE_NAME    ("rsaddr")
 
 
 /*******************************************************************************
  *
  * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              Bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the Byte_stream_buffer is
+ *                                        returned
+ *              Output_buffer           - Pointer to the return data buffer
+ *              Structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
 acpi_status
 acpi_rs_address16_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size)
+       ACPI_SIZE               *structure_size)
 {
        u8                      *buffer = byte_stream_buffer;
        acpi_resource           *output_struct = (acpi_resource *) *output_buffer;
        NATIVE_CHAR             *temp_ptr;
-       u32                     struct_size = SIZEOF_RESOURCE (acpi_resource_address16);
+       ACPI_SIZE               struct_size = ACPI_SIZEOF_RESOURCE (acpi_resource_address16);
        u32                     index;
        u16                     temp16;
        u8                      temp8;
 
 
-       FUNCTION_TRACE ("Rs_address16_resource");
+       ACPI_FUNCTION_TRACE ("Rs_address16_resource");
 
        /*
         * Point past the Descriptor to get the number of bytes consumed
         */
        buffer += 1;
-       MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+       ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
 
        *bytes_consumed = temp16 + 3;
        output_struct->id = ACPI_RSTYPE_ADDRESS16;
@@ -87,6 +86,7 @@ acpi_rs_address16_resource (
        temp8 = *buffer;
 
        /* Values 0-2 are valid */
+
        if (temp8 > 2) {
                return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
        }
@@ -99,24 +99,20 @@ acpi_rs_address16_resource (
        buffer += 1;
        temp8 = *buffer;
 
-       /*
-        * Producer / Consumer
-        */
+       /* Producer / Consumer */
+
        output_struct->data.address16.producer_consumer = temp8 & 0x01;
 
-       /*
-        * Decode
-        */
+       /* Decode */
+
        output_struct->data.address16.decode = (temp8 >> 1) & 0x01;
 
-       /*
-        * Min Address Fixed
-        */
+       /* Min Address Fixed */
+
        output_struct->data.address16.min_address_fixed = (temp8 >> 2) & 0x01;
 
-       /*
-        * Max Address Fixed
-        */
+       /* Max Address Fixed */
+
        output_struct->data.address16.max_address_fixed = (temp8 >> 3) & 0x01;
 
        /*
@@ -125,19 +121,17 @@ acpi_rs_address16_resource (
        buffer += 1;
        temp8 = *buffer;
 
-       if (MEMORY_RANGE == output_struct->data.address16.resource_type) {
+       if (ACPI_MEMORY_RANGE == output_struct->data.address16.resource_type) {
                output_struct->data.address16.attribute.memory.read_write_attribute =
                                (u16) (temp8 & 0x01);
                output_struct->data.address16.attribute.memory.cache_attribute =
                                (u16) ((temp8 >> 1) & 0x0F);
        }
-
        else {
-               if (IO_RANGE == output_struct->data.address16.resource_type) {
+               if (ACPI_IO_RANGE == output_struct->data.address16.resource_type) {
                        output_struct->data.address16.attribute.io.range_attribute =
                                (u16) (temp8 & 0x03);
                }
-
                else {
                        /* BUS_NUMBER_RANGE == Address16.Data->Resource_type */
                        /* Nothing needs to be filled in */
@@ -148,35 +142,35 @@ acpi_rs_address16_resource (
         * Get Granularity (Bytes 6-7)
         */
        buffer += 1;
-       MOVE_UNALIGNED16_TO_16 (&output_struct->data.address16.granularity,
+       ACPI_MOVE_UNALIGNED16_TO_16 (&output_struct->data.address16.granularity,
                         buffer);
 
        /*
         * Get Min_address_range (Bytes 8-9)
         */
        buffer += 2;
-       MOVE_UNALIGNED16_TO_16 (&output_struct->data.address16.min_address_range,
+       ACPI_MOVE_UNALIGNED16_TO_16 (&output_struct->data.address16.min_address_range,
                         buffer);
 
        /*
         * Get Max_address_range (Bytes 10-11)
         */
        buffer += 2;
-       MOVE_UNALIGNED16_TO_16 (&output_struct->data.address16.max_address_range,
+       ACPI_MOVE_UNALIGNED16_TO_16 (&output_struct->data.address16.max_address_range,
                         buffer);
 
        /*
         * Get Address_translation_offset (Bytes 12-13)
         */
        buffer += 2;
-       MOVE_UNALIGNED16_TO_16 (&output_struct->data.address16.address_translation_offset,
+       ACPI_MOVE_UNALIGNED16_TO_16 (&output_struct->data.address16.address_translation_offset,
                         buffer);
 
        /*
         * Get Address_length (Bytes 14-15)
         */
        buffer += 2;
-       MOVE_UNALIGNED16_TO_16 (&output_struct->data.address16.address_length,
+       ACPI_MOVE_UNALIGNED16_TO_16 (&output_struct->data.address16.address_length,
                         buffer);
 
        /*
@@ -233,9 +227,8 @@ acpi_rs_address16_resource (
                 * Struct_size to the next 32-bit boundary.
                 */
                temp8 = (u8) (index + 1);
-               struct_size += ROUND_UP_TO_32_bITS (temp8);
+               struct_size += ACPI_ROUND_UP_TO_32_bITS (temp8);
        }
-
        else {
                output_struct->data.address16.resource_source.index = 0x00;
                output_struct->data.address16.resource_source.string_length = 0;
@@ -261,9 +254,8 @@ acpi_rs_address16_resource (
  *
  * PARAMETERS:  Linked_list             - Pointer to the resource linked list
  *              Output_buffer           - Pointer to the user's return buffer
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes of the
- *                                        Output_buffer used
+ *              Bytes_consumed          - Pointer to where the number of bytes
+ *                                        used in the Output_buffer is returned
  *
  * RETURN:      Status
  *
@@ -276,16 +268,16 @@ acpi_status
 acpi_rs_address16_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed)
+       ACPI_SIZE               *bytes_consumed)
 {
        u8                      *buffer = *output_buffer;
        u8                      *length_field;
        u8                      temp8;
        NATIVE_CHAR             *temp_pointer = NULL;
-       u32                     actual_bytes;
+       ACPI_SIZE               actual_bytes;
 
 
-       FUNCTION_TRACE ("Rs_address16_stream");
+       ACPI_FUNCTION_TRACE ("Rs_address16_stream");
 
 
        /*
@@ -324,7 +316,7 @@ acpi_rs_address16_stream (
         */
        temp8 = 0;
 
-       if (MEMORY_RANGE == linked_list->data.address16.resource_type) {
+       if (ACPI_MEMORY_RANGE == linked_list->data.address16.resource_type) {
                temp8 = (u8)
                        (linked_list->data.address16.attribute.memory.read_write_attribute &
                         0x01);
@@ -333,8 +325,7 @@ acpi_rs_address16_stream (
                        (linked_list->data.address16.attribute.memory.cache_attribute &
                         0x0F) << 1;
        }
-
-       else if (IO_RANGE == linked_list->data.address16.resource_type) {
+       else if (ACPI_IO_RANGE == linked_list->data.address16.resource_type) {
                temp8 = (u8)
                        (linked_list->data.address16.attribute.io.range_attribute &
                         0x03);
@@ -346,35 +337,35 @@ acpi_rs_address16_stream (
        /*
         * Set the address space granularity
         */
-       MOVE_UNALIGNED16_TO_16 (buffer,
+       ACPI_MOVE_UNALIGNED16_TO_16 (buffer,
                           &linked_list->data.address16.granularity);
        buffer += 2;
 
        /*
         * Set the address range minimum
         */
-       MOVE_UNALIGNED16_TO_16 (buffer,
+       ACPI_MOVE_UNALIGNED16_TO_16 (buffer,
                           &linked_list->data.address16.min_address_range);
        buffer += 2;
 
        /*
         * Set the address range maximum
         */
-       MOVE_UNALIGNED16_TO_16 (buffer,
+       ACPI_MOVE_UNALIGNED16_TO_16 (buffer,
                           &linked_list->data.address16.max_address_range);
        buffer += 2;
 
        /*
         * Set the address translation offset
         */
-       MOVE_UNALIGNED16_TO_16 (buffer,
+       ACPI_MOVE_UNALIGNED16_TO_16 (buffer,
                           &linked_list->data.address16.address_translation_offset);
        buffer += 2;
 
        /*
         * Set the address length
         */
-       MOVE_UNALIGNED16_TO_16 (buffer,
+       ACPI_MOVE_UNALIGNED16_TO_16 (buffer,
                           &linked_list->data.address16.address_length);
        buffer += 2;
 
@@ -392,21 +383,21 @@ acpi_rs_address16_stream (
                /*
                 * Copy the string
                 */
-               STRCPY (temp_pointer,
+               ACPI_STRCPY (temp_pointer,
                                linked_list->data.address16.resource_source.string_ptr);
 
                /*
                 * Buffer needs to be set to the length of the sting + one for the
                 *  terminating null
                 */
-               buffer += (STRLEN (linked_list->data.address16.resource_source.string_ptr)
+               buffer += (ACPI_STRLEN (linked_list->data.address16.resource_source.string_ptr)
                                 + 1);
        }
 
        /*
         * Return the number of bytes consumed in this operation
         */
-       actual_bytes = POINTER_DIFF (buffer, *output_buffer);
+       actual_bytes = ACPI_PTR_DIFF (buffer, *output_buffer);
        *bytes_consumed = actual_bytes;
 
        /*
@@ -414,7 +405,7 @@ acpi_rs_address16_stream (
         * minus the header size (3 bytes)
         */
        actual_bytes -= 3;
-       MOVE_UNALIGNED16_TO_16 (length_field, &actual_bytes);
+       ACPI_MOVE_UNALIGNED16_TO_16 (length_field, &actual_bytes);
        return_ACPI_STATUS (AE_OK);
 }
 
@@ -425,13 +416,12 @@ acpi_rs_address16_stream (
  *
  * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              Bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the Byte_stream_buffer is
+ *                                        returned
+ *              Output_buffer           - Pointer to the return data buffer
+ *              Structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
@@ -444,33 +434,32 @@ acpi_rs_address16_stream (
 acpi_status
 acpi_rs_address32_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size)
+       ACPI_SIZE               *structure_size)
 {
        u8                      *buffer;
        acpi_resource           *output_struct;
        u16                     temp16;
        u8                      temp8;
        NATIVE_CHAR             *temp_ptr;
-       u32                     struct_size;
+       ACPI_SIZE               struct_size;
        u32                     index;
 
 
-       FUNCTION_TRACE ("Rs_address32_resource");
+       ACPI_FUNCTION_TRACE ("Rs_address32_resource");
 
 
        buffer = byte_stream_buffer;
        output_struct = (acpi_resource *) *output_buffer;
 
-       struct_size = SIZEOF_RESOURCE (acpi_resource_address32);
+       struct_size = ACPI_SIZEOF_RESOURCE (acpi_resource_address32);
 
        /*
         * Point past the Descriptor to get the number of bytes consumed
         */
        buffer += 1;
-       MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
-
+       ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
        *bytes_consumed = temp16 + 3;
 
        output_struct->id = ACPI_RSTYPE_ADDRESS32;
@@ -520,20 +509,18 @@ acpi_rs_address32_resource (
        buffer += 1;
        temp8 = *buffer;
 
-       if (MEMORY_RANGE == output_struct->data.address32.resource_type) {
+       if (ACPI_MEMORY_RANGE == output_struct->data.address32.resource_type) {
                output_struct->data.address32.attribute.memory.read_write_attribute =
                                (u16) (temp8 & 0x01);
 
                output_struct->data.address32.attribute.memory.cache_attribute =
                                (u16) ((temp8 >> 1) & 0x0F);
        }
-
        else {
-               if (IO_RANGE == output_struct->data.address32.resource_type) {
+               if (ACPI_IO_RANGE == output_struct->data.address32.resource_type) {
                        output_struct->data.address32.attribute.io.range_attribute =
                                (u16) (temp8 & 0x03);
                }
-
                else {
                        /* BUS_NUMBER_RANGE == Output_struct->Data.Address32.Resource_type */
                        /* Nothing needs to be filled in */
@@ -544,35 +531,35 @@ acpi_rs_address32_resource (
         * Get Granularity (Bytes 6-9)
         */
        buffer += 1;
-       MOVE_UNALIGNED32_TO_32 (&output_struct->data.address32.granularity,
+       ACPI_MOVE_UNALIGNED32_TO_32 (&output_struct->data.address32.granularity,
                         buffer);
 
        /*
         * Get Min_address_range (Bytes 10-13)
         */
        buffer += 4;
-       MOVE_UNALIGNED32_TO_32 (&output_struct->data.address32.min_address_range,
+       ACPI_MOVE_UNALIGNED32_TO_32 (&output_struct->data.address32.min_address_range,
                         buffer);
 
        /*
         * Get Max_address_range (Bytes 14-17)
         */
        buffer += 4;
-       MOVE_UNALIGNED32_TO_32 (&output_struct->data.address32.max_address_range,
+       ACPI_MOVE_UNALIGNED32_TO_32 (&output_struct->data.address32.max_address_range,
                         buffer);
 
        /*
         * Get Address_translation_offset (Bytes 18-21)
         */
        buffer += 4;
-       MOVE_UNALIGNED32_TO_32 (&output_struct->data.address32.address_translation_offset,
+       ACPI_MOVE_UNALIGNED32_TO_32 (&output_struct->data.address32.address_translation_offset,
                         buffer);
 
        /*
         * Get Address_length (Bytes 22-25)
         */
        buffer += 4;
-       MOVE_UNALIGNED32_TO_32 (&output_struct->data.address32.address_length,
+       ACPI_MOVE_UNALIGNED32_TO_32 (&output_struct->data.address32.address_length,
                         buffer);
 
        /*
@@ -606,7 +593,6 @@ acpi_rs_address32_resource (
                /* Copy the string into the buffer */
 
                index = 0;
-
                while (0x00 != *buffer) {
                        *temp_ptr = *buffer;
 
@@ -627,9 +613,8 @@ acpi_rs_address32_resource (
                 *  Struct_size to the next 32-bit boundary.
                 */
                temp8 = (u8) (index + 1);
-               struct_size += ROUND_UP_TO_32_bITS (temp8);
+               struct_size += ACPI_ROUND_UP_TO_32_bITS (temp8);
        }
-
        else {
                output_struct->data.address32.resource_source.index = 0x00;
                output_struct->data.address32.resource_source.string_length = 0;
@@ -655,9 +640,8 @@ acpi_rs_address32_resource (
  *
  * PARAMETERS:  Linked_list             - Pointer to the resource linked list
  *              Output_buffer           - Pointer to the user's return buffer
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes of the
- *                                        Output_buffer used
+ *              Bytes_consumed          - Pointer to where the number of bytes
+ *                                        used in the Output_buffer is returned
  *
  * RETURN:      Status
  *
@@ -670,7 +654,7 @@ acpi_status
 acpi_rs_address32_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed)
+       ACPI_SIZE               *bytes_consumed)
 {
        u8                      *buffer;
        u16                     *length_field;
@@ -678,7 +662,7 @@ acpi_rs_address32_stream (
        NATIVE_CHAR             *temp_pointer;
 
 
-       FUNCTION_TRACE ("Rs_address32_stream");
+       ACPI_FUNCTION_TRACE ("Rs_address32_stream");
 
 
        buffer = *output_buffer;
@@ -692,7 +676,6 @@ acpi_rs_address32_stream (
        /*
         * Set a pointer to the Length field - to be filled in later
         */
-
        length_field = (u16 *) buffer;
        buffer += 2;
 
@@ -720,7 +703,7 @@ acpi_rs_address32_stream (
         */
        temp8 = 0;
 
-       if(MEMORY_RANGE == linked_list->data.address32.resource_type) {
+       if (ACPI_MEMORY_RANGE == linked_list->data.address32.resource_type) {
                temp8 = (u8)
                        (linked_list->data.address32.attribute.memory.read_write_attribute &
                        0x01);
@@ -729,8 +712,7 @@ acpi_rs_address32_stream (
                        (linked_list->data.address32.attribute.memory.cache_attribute &
                         0x0F) << 1;
        }
-
-       else if (IO_RANGE == linked_list->data.address32.resource_type) {
+       else if (ACPI_IO_RANGE == linked_list->data.address32.resource_type) {
                temp8 = (u8)
                        (linked_list->data.address32.attribute.io.range_attribute &
                         0x03);
@@ -742,35 +724,35 @@ acpi_rs_address32_stream (
        /*
         * Set the address space granularity
         */
-       MOVE_UNALIGNED32_TO_32 (buffer,
+       ACPI_MOVE_UNALIGNED32_TO_32 (buffer,
                          &linked_list->data.address32.granularity);
        buffer += 4;
 
        /*
         * Set the address range minimum
         */
-       MOVE_UNALIGNED32_TO_32 (buffer,
+       ACPI_MOVE_UNALIGNED32_TO_32 (buffer,
                          &linked_list->data.address32.min_address_range);
        buffer += 4;
 
        /*
         * Set the address range maximum
         */
-       MOVE_UNALIGNED32_TO_32 (buffer,
+       ACPI_MOVE_UNALIGNED32_TO_32 (buffer,
                          &linked_list->data.address32.max_address_range);
        buffer += 4;
 
        /*
         * Set the address translation offset
         */
-       MOVE_UNALIGNED32_TO_32 (buffer,
+       ACPI_MOVE_UNALIGNED32_TO_32 (buffer,
                          &linked_list->data.address32.address_translation_offset);
        buffer += 4;
 
        /*
         * Set the address length
         */
-       MOVE_UNALIGNED32_TO_32 (buffer,
+       ACPI_MOVE_UNALIGNED32_TO_32 (buffer,
                          &linked_list->data.address32.address_length);
        buffer += 4;
 
@@ -788,20 +770,20 @@ acpi_rs_address32_stream (
                /*
                 * Copy the string
                 */
-               STRCPY (temp_pointer,
+               ACPI_STRCPY (temp_pointer,
                        linked_list->data.address32.resource_source.string_ptr);
 
                /*
                 * Buffer needs to be set to the length of the sting + one for the
                 *  terminating null
                 */
-               buffer += (STRLEN (linked_list->data.address32.resource_source.string_ptr) + 1);
+               buffer += (ACPI_STRLEN (linked_list->data.address32.resource_source.string_ptr) + 1);
        }
 
        /*
         * Return the number of bytes consumed in this operation
         */
-       *bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+       *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
 
        /*
         * Set the length field to the number of bytes consumed
@@ -818,13 +800,12 @@ acpi_rs_address32_stream (
  *
  * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              Bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the Byte_stream_buffer is
+ *                                        returned
+ *              Output_buffer           - Pointer to the return data buffer
+ *              Structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
@@ -837,32 +818,32 @@ acpi_rs_address32_stream (
 acpi_status
 acpi_rs_address64_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size)
+       ACPI_SIZE               *structure_size)
 {
        u8                      *buffer;
        acpi_resource           *output_struct;
        u16                     temp16;
        u8                      temp8;
        NATIVE_CHAR             *temp_ptr;
-       u32                     struct_size;
+       ACPI_SIZE               struct_size;
        u32                     index;
 
 
-       FUNCTION_TRACE ("Rs_address64_resource");
+       ACPI_FUNCTION_TRACE ("Rs_address64_resource");
 
 
        buffer = byte_stream_buffer;
        output_struct = (acpi_resource *) *output_buffer;
 
-       struct_size = SIZEOF_RESOURCE (acpi_resource_address64);
+       struct_size = ACPI_SIZEOF_RESOURCE (acpi_resource_address64);
 
        /*
         * Point past the Descriptor to get the number of bytes consumed
         */
        buffer += 1;
-       MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+       ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
 
        *bytes_consumed = temp16 + 3;
        output_struct->id = ACPI_RSTYPE_ADDRESS64;
@@ -874,6 +855,7 @@ acpi_rs_address64_resource (
        temp8 = *buffer;
 
        /* Values 0-2 are valid */
+
        if(temp8 > 2) {
                return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
        }
@@ -912,20 +894,18 @@ acpi_rs_address64_resource (
        buffer += 1;
        temp8 = *buffer;
 
-       if (MEMORY_RANGE == output_struct->data.address64.resource_type) {
+       if (ACPI_MEMORY_RANGE == output_struct->data.address64.resource_type) {
                output_struct->data.address64.attribute.memory.read_write_attribute =
                                (u16) (temp8 & 0x01);
 
                output_struct->data.address64.attribute.memory.cache_attribute =
                                (u16) ((temp8 >> 1) & 0x0F);
        }
-
        else {
-               if (IO_RANGE == output_struct->data.address64.resource_type) {
+               if (ACPI_IO_RANGE == output_struct->data.address64.resource_type) {
                        output_struct->data.address64.attribute.io.range_attribute =
                                (u16) (temp8 & 0x03);
                }
-
                else {
                        /* BUS_NUMBER_RANGE == Output_struct->Data.Address64.Resource_type */
                        /* Nothing needs to be filled in */
@@ -936,35 +916,35 @@ acpi_rs_address64_resource (
         * Get Granularity (Bytes 6-13)
         */
        buffer += 1;
-       MOVE_UNALIGNED64_TO_64 (&output_struct->data.address64.granularity,
+       ACPI_MOVE_UNALIGNED64_TO_64 (&output_struct->data.address64.granularity,
                         buffer);
 
        /*
         * Get Min_address_range (Bytes 14-21)
         */
        buffer += 8;
-       MOVE_UNALIGNED64_TO_64 (&output_struct->data.address64.min_address_range,
+       ACPI_MOVE_UNALIGNED64_TO_64 (&output_struct->data.address64.min_address_range,
                         buffer);
 
        /*
         * Get Max_address_range (Bytes 22-29)
         */
        buffer += 8;
-       MOVE_UNALIGNED64_TO_64 (&output_struct->data.address64.max_address_range,
+       ACPI_MOVE_UNALIGNED64_TO_64 (&output_struct->data.address64.max_address_range,
                         buffer);
 
        /*
         * Get Address_translation_offset (Bytes 30-37)
         */
        buffer += 8;
-       MOVE_UNALIGNED64_TO_64 (&output_struct->data.address64.address_translation_offset,
+       ACPI_MOVE_UNALIGNED64_TO_64 (&output_struct->data.address64.address_translation_offset,
                         buffer);
 
        /*
         * Get Address_length (Bytes 38-45)
         */
        buffer += 8;
-       MOVE_UNALIGNED64_TO_64 (&output_struct->data.address64.address_length,
+       ACPI_MOVE_UNALIGNED64_TO_64 (&output_struct->data.address64.address_length,
                         buffer);
 
        /*
@@ -1000,7 +980,6 @@ acpi_rs_address64_resource (
                /* Copy the string into the buffer */
 
                index = 0;
-
                while (0x00 != *buffer) {
                        *temp_ptr = *buffer;
 
@@ -1022,9 +1001,8 @@ acpi_rs_address64_resource (
                 * Struct_size to the next 32-bit boundary.
                 */
                temp8 = (u8) (index + 1);
-               struct_size += ROUND_UP_TO_32_bITS (temp8);
+               struct_size += ACPI_ROUND_UP_TO_32_bITS (temp8);
        }
-
        else {
                output_struct->data.address64.resource_source.index = 0x00;
                output_struct->data.address64.resource_source.string_length = 0;
@@ -1050,9 +1028,8 @@ acpi_rs_address64_resource (
  *
  * PARAMETERS:  Linked_list             - Pointer to the resource linked list
  *              Output_buffer           - Pointer to the user's return buffer
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes of the
- *                                        Output_buffer used
+ *              Bytes_consumed          - Pointer to where the number of bytes
+ *                                        used in the Output_buffer is returned
  *
  * RETURN:      Status
  *
@@ -1065,7 +1042,7 @@ acpi_status
 acpi_rs_address64_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed)
+       ACPI_SIZE               *bytes_consumed)
 {
        u8                      *buffer;
        u16                     *length_field;
@@ -1073,7 +1050,7 @@ acpi_rs_address64_stream (
        NATIVE_CHAR             *temp_pointer;
 
 
-       FUNCTION_TRACE ("Rs_address64_stream");
+       ACPI_FUNCTION_TRACE ("Rs_address64_stream");
 
 
        buffer = *output_buffer;
@@ -1115,7 +1092,7 @@ acpi_rs_address64_stream (
         */
        temp8 = 0;
 
-       if(MEMORY_RANGE == linked_list->data.address64.resource_type) {
+       if (ACPI_MEMORY_RANGE == linked_list->data.address64.resource_type) {
                temp8 = (u8)
                        (linked_list->data.address64.attribute.memory.read_write_attribute &
                        0x01);
@@ -1124,8 +1101,7 @@ acpi_rs_address64_stream (
                        (linked_list->data.address64.attribute.memory.cache_attribute &
                         0x0F) << 1;
        }
-
-       else if (IO_RANGE == linked_list->data.address64.resource_type) {
+       else if (ACPI_IO_RANGE == linked_list->data.address64.resource_type) {
                temp8 = (u8)
                        (linked_list->data.address64.attribute.io.range_attribute &
                         0x03);
@@ -1137,35 +1113,35 @@ acpi_rs_address64_stream (
        /*
         * Set the address space granularity
         */
-       MOVE_UNALIGNED64_TO_64 (buffer,
+       ACPI_MOVE_UNALIGNED64_TO_64 (buffer,
                           &linked_list->data.address64.granularity);
        buffer += 8;
 
        /*
         * Set the address range minimum
         */
-       MOVE_UNALIGNED64_TO_64 (buffer,
+       ACPI_MOVE_UNALIGNED64_TO_64 (buffer,
                           &linked_list->data.address64.min_address_range);
        buffer += 8;
 
        /*
         * Set the address range maximum
         */
-       MOVE_UNALIGNED64_TO_64 (buffer,
+       ACPI_MOVE_UNALIGNED64_TO_64 (buffer,
                           &linked_list->data.address64.max_address_range);
        buffer += 8;
 
        /*
         * Set the address translation offset
         */
-       MOVE_UNALIGNED64_TO_64 (buffer,
+       ACPI_MOVE_UNALIGNED64_TO_64 (buffer,
                           &linked_list->data.address64.address_translation_offset);
        buffer += 8;
 
        /*
         * Set the address length
         */
-       MOVE_UNALIGNED64_TO_64 (buffer,
+       ACPI_MOVE_UNALIGNED64_TO_64 (buffer,
                           &linked_list->data.address64.address_length);
        buffer += 8;
 
@@ -1183,19 +1159,19 @@ acpi_rs_address64_stream (
                /*
                 * Copy the string
                 */
-               STRCPY (temp_pointer, linked_list->data.address64.resource_source.string_ptr);
+               ACPI_STRCPY (temp_pointer, linked_list->data.address64.resource_source.string_ptr);
 
                /*
                 * Buffer needs to be set to the length of the sting + one for the
                 *  terminating null
                 */
-               buffer += (STRLEN (linked_list->data.address64.resource_source.string_ptr) + 1);
+               buffer += (ACPI_STRLEN (linked_list->data.address64.resource_source.string_ptr) + 1);
        }
 
        /*
         * Return the number of bytes consumed in this operation
         */
-       *bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+       *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
 
        /*
         * Set the length field to the number of bytes consumed
index 6d26a512035f13cb68e59757f966eba59467e058..55a99e714fc995c207c4eb55b147a363b82a23c1 100644 (file)
@@ -1,12 +1,12 @@
 /*******************************************************************************
  *
  * Module Name: rscalc - Calculate stream and list lengths
- *              $Revision: 32 $
+ *              $Revision: 39 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@
 #include "acnamesp.h"
 
 #define _COMPONENT          ACPI_RESOURCES
-        MODULE_NAME         ("rscalc")
+        ACPI_MODULE_NAME    ("rscalc")
 
 
 /*******************************************************************************
 acpi_status
 acpi_rs_calculate_byte_stream_length (
        acpi_resource           *linked_list,
-       u32                     *size_needed)
+       ACPI_SIZE               *size_needed)
 {
-       u32                     byte_stream_size_needed = 0;
-       u32                     segment_size;
+       ACPI_SIZE               byte_stream_size_needed = 0;
+       ACPI_SIZE               segment_size;
        acpi_resource_ext_irq   *ex_irq = NULL;
        u8                      done = FALSE;
 
 
-       FUNCTION_TRACE ("Rs_calculate_byte_stream_length");
+       ACPI_FUNCTION_TRACE ("Rs_calculate_byte_stream_length");
 
 
        while (!done) {
@@ -243,7 +243,6 @@ acpi_rs_calculate_byte_stream_length (
                         * so exit with an error
                         */
                        return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
-                       break;
 
                } /* switch (Linked_list->Id) */
 
@@ -255,7 +254,7 @@ acpi_rs_calculate_byte_stream_length (
                /*
                 * Point to the next object
                 */
-               linked_list = POINTER_ADD (acpi_resource,
+               linked_list = ACPI_PTR_ADD (acpi_resource,
                                  linked_list, linked_list->length);
        }
 
@@ -289,7 +288,7 @@ acpi_status
 acpi_rs_calculate_list_length (
        u8                      *byte_stream_buffer,
        u32                     byte_stream_buffer_length,
-       u32                     *size_needed)
+       ACPI_SIZE               *size_needed)
 {
        u32                     buffer_size = 0;
        u32                     bytes_parsed = 0;
@@ -305,7 +304,7 @@ acpi_rs_calculate_list_length (
        u8                      additional_bytes;
 
 
-       FUNCTION_TRACE ("Rs_calculate_list_length");
+       ACPI_FUNCTION_TRACE ("Rs_calculate_list_length");
 
 
        while (bytes_parsed < byte_stream_buffer_length) {
@@ -315,65 +314,65 @@ acpi_rs_calculate_list_length (
                resource_type = acpi_rs_get_resource_type (*byte_stream_buffer);
 
                switch (resource_type) {
-               case RESOURCE_DESC_MEMORY_24:
+               case ACPI_RDESC_TYPE_MEMORY_24:
                        /*
                         * 24-Bit Memory Resource
                         */
                        bytes_consumed = 12;
 
-                       structure_size = SIZEOF_RESOURCE (acpi_resource_mem24);
+                       structure_size = ACPI_SIZEOF_RESOURCE (acpi_resource_mem24);
                        break;
 
 
-               case RESOURCE_DESC_LARGE_VENDOR:
+               case ACPI_RDESC_TYPE_LARGE_VENDOR:
                        /*
                         * Vendor Defined Resource
                         */
                        buffer = byte_stream_buffer;
                        ++buffer;
 
-                       MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+                       ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
                        bytes_consumed = temp16 + 3;
 
                        /*
                         * Ensure a 32-bit boundary for the structure
                         */
-                       temp16 = (u16) ROUND_UP_TO_32_bITS (temp16);
+                       temp16 = (u16) ACPI_ROUND_UP_TO_32_bITS (temp16);
 
-                       structure_size = SIZEOF_RESOURCE (acpi_resource_vendor) +
+                       structure_size = ACPI_SIZEOF_RESOURCE (acpi_resource_vendor) +
                                           (temp16 * sizeof (u8));
                        break;
 
 
-               case RESOURCE_DESC_MEMORY_32:
+               case ACPI_RDESC_TYPE_MEMORY_32:
                        /*
                         * 32-Bit Memory Range Resource
                         */
 
                        bytes_consumed = 20;
 
-                       structure_size = SIZEOF_RESOURCE (acpi_resource_mem32);
+                       structure_size = ACPI_SIZEOF_RESOURCE (acpi_resource_mem32);
                        break;
 
 
-               case RESOURCE_DESC_FIXED_MEMORY_32:
+               case ACPI_RDESC_TYPE_FIXED_MEMORY_32:
                        /*
                         * 32-Bit Fixed Memory Resource
                         */
                        bytes_consumed = 12;
 
-                       structure_size = SIZEOF_RESOURCE (acpi_resource_fixed_mem32);
+                       structure_size = ACPI_SIZEOF_RESOURCE (acpi_resource_fixed_mem32);
                        break;
 
 
-               case RESOURCE_DESC_QWORD_ADDRESS_SPACE:
+               case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE:
                        /*
                         * 64-Bit Address Resource
                         */
                        buffer = byte_stream_buffer;
 
                        ++buffer;
-                       MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+                       ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
 
                        bytes_consumed = temp16 + 3;
 
@@ -397,21 +396,21 @@ acpi_rs_calculate_list_length (
                        /*
                         * Ensure a 64-bit boundary for the structure
                         */
-                       temp8 = (u8) ROUND_UP_TO_64_bITS (temp8);
+                       temp8 = (u8) ACPI_ROUND_UP_TO_64_bITS (temp8);
 
-                       structure_size = SIZEOF_RESOURCE (acpi_resource_address64) +
+                       structure_size = ACPI_SIZEOF_RESOURCE (acpi_resource_address64) +
                                           (temp8 * sizeof (u8));
                        break;
 
 
-               case RESOURCE_DESC_DWORD_ADDRESS_SPACE:
+               case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE:
                        /*
                         * 32-Bit Address Resource
                         */
                        buffer = byte_stream_buffer;
 
                        ++buffer;
-                       MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+                       ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
 
                        bytes_consumed = temp16 + 3;
 
@@ -435,21 +434,21 @@ acpi_rs_calculate_list_length (
                        /*
                         * Ensure a 32-bit boundary for the structure
                         */
-                       temp8 = (u8) ROUND_UP_TO_32_bITS (temp8);
+                       temp8 = (u8) ACPI_ROUND_UP_TO_32_bITS (temp8);
 
-                       structure_size = SIZEOF_RESOURCE (acpi_resource_address32) +
+                       structure_size = ACPI_SIZEOF_RESOURCE (acpi_resource_address32) +
                                           (temp8 * sizeof (u8));
                        break;
 
 
-               case RESOURCE_DESC_WORD_ADDRESS_SPACE:
+               case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE:
                        /*
                         * 16-Bit Address Resource
                         */
                        buffer = byte_stream_buffer;
 
                        ++buffer;
-                       MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+                       ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
 
                        bytes_consumed = temp16 + 3;
 
@@ -473,21 +472,21 @@ acpi_rs_calculate_list_length (
                        /*
                         * Ensure a 32-bit boundary for the structure
                         */
-                       temp8 = (u8) ROUND_UP_TO_32_bITS (temp8);
+                       temp8 = (u8) ACPI_ROUND_UP_TO_32_bITS (temp8);
 
-                       structure_size = SIZEOF_RESOURCE (acpi_resource_address16) +
+                       structure_size = ACPI_SIZEOF_RESOURCE (acpi_resource_address16) +
                                           (temp8 * sizeof (u8));
                        break;
 
 
-               case RESOURCE_DESC_EXTENDED_XRUPT:
+               case ACPI_RDESC_TYPE_EXTENDED_XRUPT:
                        /*
                         * Extended IRQ
                         */
                        buffer = byte_stream_buffer;
 
                        ++buffer;
-                       MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+                       ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
 
                        bytes_consumed = temp16 + 3;
 
@@ -518,7 +517,6 @@ acpi_rs_calculate_list_length (
                        if (9 + additional_bytes < temp16) {
                                temp8 = (u8) (temp16 - (9 + additional_bytes));
                        }
-
                        else {
                                temp8 = 0;
                        }
@@ -526,15 +524,15 @@ acpi_rs_calculate_list_length (
                        /*
                         * Ensure a 32-bit boundary for the structure
                         */
-                       temp8 = (u8) ROUND_UP_TO_32_bITS (temp8);
+                       temp8 = (u8) ACPI_ROUND_UP_TO_32_bITS (temp8);
 
-                       structure_size = SIZEOF_RESOURCE (acpi_resource_ext_irq) +
+                       structure_size = ACPI_SIZEOF_RESOURCE (acpi_resource_ext_irq) +
                                           (additional_bytes * sizeof (u8)) +
                                           (temp8 * sizeof (u8));
                        break;
 
 
-               case RESOURCE_DESC_IRQ_FORMAT:
+               case ACPI_RDESC_TYPE_IRQ_FORMAT:
                        /*
                         * IRQ Resource.
                         * Determine if it there are two or three trailing bytes
@@ -545,7 +543,6 @@ acpi_rs_calculate_list_length (
                        if(temp8 & 0x01) {
                                bytes_consumed = 4;
                        }
-
                        else {
                                bytes_consumed = 3;
                        }
@@ -558,7 +555,7 @@ acpi_rs_calculate_list_length (
                        /*
                         * Look at the number of bits set
                         */
-                       MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+                       ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
 
                        for (index = 0; index < 16; index++) {
                                if (temp16 & 0x1) {
@@ -568,12 +565,12 @@ acpi_rs_calculate_list_length (
                                temp16 >>= 1;
                        }
 
-                       structure_size = SIZEOF_RESOURCE (acpi_resource_io) +
+                       structure_size = ACPI_SIZEOF_RESOURCE (acpi_resource_io) +
                                           (number_of_interrupts * sizeof (u32));
                        break;
 
 
-               case RESOURCE_DESC_DMA_FORMAT:
+               case ACPI_RDESC_TYPE_DMA_FORMAT:
                        /*
                         * DMA Resource
                         */
@@ -598,12 +595,12 @@ acpi_rs_calculate_list_length (
                                temp8 >>= 1;
                        }
 
-                       structure_size = SIZEOF_RESOURCE (acpi_resource_dma) +
+                       structure_size = ACPI_SIZEOF_RESOURCE (acpi_resource_dma) +
                                           (number_of_channels * sizeof (u32));
                        break;
 
 
-               case RESOURCE_DESC_START_DEPENDENT:
+               case ACPI_RDESC_TYPE_START_DEPENDENT:
                        /*
                         * Start Dependent Functions Resource
                         * Determine if it there are two or three trailing bytes
@@ -618,11 +615,11 @@ acpi_rs_calculate_list_length (
                                bytes_consumed = 1;
                        }
 
-                       structure_size = SIZEOF_RESOURCE (acpi_resource_start_dpf);
+                       structure_size = ACPI_SIZEOF_RESOURCE (acpi_resource_start_dpf);
                        break;
 
 
-               case RESOURCE_DESC_END_DEPENDENT:
+               case ACPI_RDESC_TYPE_END_DEPENDENT:
                        /*
                         * End Dependent Functions Resource
                         */
@@ -631,25 +628,25 @@ acpi_rs_calculate_list_length (
                        break;
 
 
-               case RESOURCE_DESC_IO_PORT:
+               case ACPI_RDESC_TYPE_IO_PORT:
                        /*
                         * IO Port Resource
                         */
                        bytes_consumed = 8;
-                       structure_size = SIZEOF_RESOURCE (acpi_resource_io);
+                       structure_size = ACPI_SIZEOF_RESOURCE (acpi_resource_io);
                        break;
 
 
-               case RESOURCE_DESC_FIXED_IO_PORT:
+               case ACPI_RDESC_TYPE_FIXED_IO_PORT:
                        /*
                         * Fixed IO Port Resource
                         */
                        bytes_consumed = 4;
-                       structure_size = SIZEOF_RESOURCE (acpi_resource_fixed_io);
+                       structure_size = ACPI_SIZEOF_RESOURCE (acpi_resource_fixed_io);
                        break;
 
 
-               case RESOURCE_DESC_SMALL_VENDOR:
+               case ACPI_RDESC_TYPE_SMALL_VENDOR:
                        /*
                         * Vendor Specific Resource
                         */
@@ -662,13 +659,13 @@ acpi_rs_calculate_list_length (
                        /*
                         * Ensure a 32-bit boundary for the structure
                         */
-                       temp8 = (u8) ROUND_UP_TO_32_bITS (temp8);
-                       structure_size = SIZEOF_RESOURCE (acpi_resource_vendor) +
+                       temp8 = (u8) ACPI_ROUND_UP_TO_32_bITS (temp8);
+                       structure_size = ACPI_SIZEOF_RESOURCE (acpi_resource_vendor) +
                                           (temp8 * sizeof (u8));
                        break;
 
 
-               case RESOURCE_DESC_END_TAG:
+               case ACPI_RDESC_TYPE_END_TAG:
                        /*
                         * End Tag
                         */
@@ -684,14 +681,12 @@ acpi_rs_calculate_list_length (
                         *  so exit with an error
                         */
                        return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
-                       break;
                }
 
-
                /*
                 * Update the return value and counter
                 */
-               buffer_size += structure_size;
+               buffer_size += ACPI_ALIGN_RESOURCE_SIZE(structure_size);
                bytes_parsed += bytes_consumed;
 
                /*
@@ -700,7 +695,6 @@ acpi_rs_calculate_list_length (
                byte_stream_buffer += bytes_consumed;
        }
 
-
        /*
         * This is the data the caller needs
         */
@@ -729,7 +723,7 @@ acpi_rs_calculate_list_length (
 acpi_status
 acpi_rs_calculate_pci_routing_table_length (
        acpi_operand_object     *package_object,
-       u32                     *buffer_size_needed)
+       ACPI_SIZE               *buffer_size_needed)
 {
        u32                     number_of_elements;
        u32                     temp_size_needed = 0;
@@ -741,7 +735,7 @@ acpi_rs_calculate_pci_routing_table_length (
        u32                     table_index;
 
 
-       FUNCTION_TRACE ("Rs_calculate_pci_routing_table_length");
+       ACPI_FUNCTION_TRACE ("Rs_calculate_pci_routing_table_length");
 
 
        number_of_elements = package_object->package.count;
@@ -781,7 +775,6 @@ acpi_rs_calculate_pci_routing_table_length (
                                        ((*sub_object_list)->reference.opcode == AML_INT_NAMEPATH_OP))) {
                                name_found = TRUE;
                        }
-
                        else {
                                /*
                                 * Look at the next element
@@ -790,7 +783,7 @@ acpi_rs_calculate_pci_routing_table_length (
                        }
                }
 
-               temp_size_needed += (sizeof (pci_routing_table) - 4);
+               temp_size_needed += (sizeof (acpi_pci_routing_table) - 4);
 
                /*
                 * Was a String type found?
@@ -803,13 +796,11 @@ acpi_rs_calculate_pci_routing_table_length (
                                 */
                                temp_size_needed += (*sub_object_list)->string.length;
                        }
-
                        else {
                                temp_size_needed += acpi_ns_get_pathname_length (
                                                   (*sub_object_list)->reference.node);
                        }
                }
-
                else {
                        /*
                         * If no name was found, then this is a NULL, which is
@@ -820,7 +811,7 @@ acpi_rs_calculate_pci_routing_table_length (
 
                /* Round up the size since each element must be aligned */
 
-               temp_size_needed = ROUND_UP_TO_64_bITS (temp_size_needed);
+               temp_size_needed = ACPI_ROUND_UP_TO_64_bITS (temp_size_needed);
 
                /*
                 * Point to the next acpi_operand_object
@@ -828,10 +819,9 @@ acpi_rs_calculate_pci_routing_table_length (
                top_object_list++;
        }
 
-
        /*
         * Adding an extra element to the end of the list, essentially a NULL terminator
         */
-       *buffer_size_needed = temp_size_needed + sizeof (pci_routing_table);
+       *buffer_size_needed = temp_size_needed + sizeof (acpi_pci_routing_table);
        return_ACPI_STATUS (AE_OK);
 }
index 3d2465a5a2ba36f313553dfe93b4cae4f88ba0db..2a750c3eda32a32df15e710f40bcbacb927a0db0 100644 (file)
@@ -1,12 +1,12 @@
 /*******************************************************************************
  *
  * Module Name: rscreate - Create resource lists/tables
- *              $Revision: 36 $
+ *              $Revision: 53 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@
 #include "acnamesp.h"
 
 #define _COMPONENT          ACPI_RESOURCES
-        MODULE_NAME         ("rscreate")
+        ACPI_MODULE_NAME    ("rscreate")
 
 
 /*******************************************************************************
 acpi_status
 acpi_rs_create_resource_list (
        acpi_operand_object     *byte_stream_buffer,
-       u8                      *output_buffer,
-       u32                     *output_buffer_length)
+       acpi_buffer             *output_buffer)
 {
 
        acpi_status             status;
        u8                      *byte_stream_start;
-       u32                     list_size_needed = 0;
+       ACPI_SIZE               list_size_needed = 0;
        u32                     byte_stream_buffer_length;
 
 
-       FUNCTION_TRACE ("Rs_create_resource_list");
+       ACPI_FUNCTION_TRACE ("Rs_create_resource_list");
 
 
        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Byte_stream_buffer = %p\n", byte_stream_buffer));
@@ -85,43 +84,27 @@ acpi_rs_create_resource_list (
 
        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status=%X List_size_needed=%X\n",
                status, list_size_needed));
-
-       /*
-        * Exit with the error passed back
-        */
        if (ACPI_FAILURE (status)) {
                return_ACPI_STATUS (status);
        }
 
-       /*
-        * If the linked list will fit into the available buffer
-        * call to fill in the list
-        */
-       if (list_size_needed <= *output_buffer_length) {
-               /*
-                * Zero out the return buffer before proceeding
-                */
-               MEMSET (output_buffer, 0x00, *output_buffer_length);
-
-               status = acpi_rs_byte_stream_to_list (byte_stream_start, byte_stream_buffer_length,
-                                &output_buffer);
+       /* Validate/Allocate/Clear caller buffer */
 
-               /*
-                * Exit with the error passed back
-                */
-               if (ACPI_FAILURE (status)) {
-                       return_ACPI_STATUS (status);
-               }
-
-               ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Output_buffer = %p\n", output_buffer));
+       status = acpi_ut_initialize_buffer (output_buffer, list_size_needed);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
        }
 
-       else {
-               *output_buffer_length = list_size_needed;
-               return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
+       /* Do the conversion */
+
+       status = acpi_rs_byte_stream_to_list (byte_stream_start, byte_stream_buffer_length,
+                         output_buffer->pointer);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
        }
 
-       *output_buffer_length = list_size_needed;
+       ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Output_buffer %p Length %X\n",
+                       output_buffer->pointer, output_buffer->length));
        return_ACPI_STATUS (AE_OK);
 }
 
@@ -137,225 +120,203 @@ acpi_rs_create_resource_list (
  *
  * RETURN:      Status  AE_OK if okay, else a valid acpi_status code.
  *              If the Output_buffer is too small, the error will be
- *              AE_BUFFER_OVERFLOW and Output_buffer_length will point
+ *              AE_BUFFER_OVERFLOW and Output_buffer->Length will point
  *              to the size buffer needed.
  *
  * DESCRIPTION: Takes the acpi_operand_object  package and creates a
  *              linked list of PCI interrupt descriptions
  *
+ * NOTE: It is the caller's responsibility to ensure that the start of the
+ * output buffer is aligned properly (if necessary).
+ *
  ******************************************************************************/
 
 acpi_status
 acpi_rs_create_pci_routing_table (
        acpi_operand_object     *package_object,
-       u8                      *output_buffer,
-       u32                     *output_buffer_length)
+       acpi_buffer             *output_buffer)
 {
-       u8                      *buffer = output_buffer;
+       u8                      *buffer;
        acpi_operand_object     **top_object_list = NULL;
        acpi_operand_object     **sub_object_list = NULL;
        acpi_operand_object     *package_element = NULL;
-       u32                     buffer_size_needed = 0;
+       ACPI_SIZE               buffer_size_needed = 0;
        u32                     number_of_elements = 0;
        u32                     index = 0;
-       pci_routing_table       *user_prt = NULL;
+       acpi_pci_routing_table  *user_prt = NULL;
        acpi_namespace_node     *node;
        acpi_status             status;
+       acpi_buffer             path_buffer;
 
 
-       FUNCTION_TRACE ("Rs_create_pci_routing_table");
+       ACPI_FUNCTION_TRACE ("Rs_create_pci_routing_table");
 
 
+       /* Params already validated, so we don't re-validate here */
+
        /*
-        * Params already validated, so we don't re-validate here
+        * Get the required buffer length
         */
        status = acpi_rs_calculate_pci_routing_table_length (package_object,
                         &buffer_size_needed);
-
-       if (!ACPI_SUCCESS(status)) {
+       if (ACPI_FAILURE (status)) {
                return_ACPI_STATUS (status);
        }
 
        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Buffer_size_needed = %X\n", buffer_size_needed));
 
+       /* Validate/Allocate/Clear caller buffer */
+
+       status = acpi_ut_initialize_buffer (output_buffer, buffer_size_needed);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
+
        /*
-        * If the data will fit into the available buffer
-        * call to fill in the list
+        * Loop through the ACPI_INTERNAL_OBJECTS - Each object should contain an
+        * acpi_integer Address, a u8 Pin, a Name and a u8 Source_index.
         */
-       if (buffer_size_needed <= *output_buffer_length) {
+       top_object_list  = package_object->package.elements;
+       number_of_elements = package_object->package.count;
+       buffer           = output_buffer->pointer;
+       user_prt         = (acpi_pci_routing_table *) buffer;
+
+       for (index = 0; index < number_of_elements; index++) {
                /*
-                * Zero out the return buffer before proceeding
+                * Point User_prt past this current structure
+                *
+                * NOTE: On the first iteration, User_prt->Length will
+                * be zero because we cleared the return buffer earlier
                 */
-               MEMSET (output_buffer, 0x00, *output_buffer_length);
+               buffer += user_prt->length;
+               user_prt = (acpi_pci_routing_table *) buffer;
 
                /*
-                * Loop through the ACPI_INTERNAL_OBJECTS - Each object should
-                * contain a u32 Address, a u8 Pin, a Name and a u8
-                * Source_index.
+                * Fill in the Length field with the information we have at this point.
+                * The minus four is to subtract the size of the u8 Source[4] member
+                * because it is added below.
                 */
-               top_object_list     = package_object->package.elements;
-               number_of_elements  = package_object->package.count;
-               user_prt            = (pci_routing_table *) buffer;
-
-
-               buffer = ROUND_PTR_UP_TO_8 (buffer, u8);
-
-               for (index = 0; index < number_of_elements; index++) {
-                       /*
-                        * Point User_prt past this current structure
-                        *
-                        * NOTE: On the first iteration, User_prt->Length will
-                        * be zero because we cleared the return buffer earlier
-                        */
-                       buffer += user_prt->length;
-                       user_prt = (pci_routing_table *) buffer;
+               user_prt->length = (sizeof (acpi_pci_routing_table) -4);
 
+               /*
+                * Dereference the sub-package
+                */
+               package_element = *top_object_list;
 
-                       /*
-                        * Fill in the Length field with the information we
-                        * have at this point.
-                        * The minus four is to subtract the size of the
-                        * u8 Source[4] member because it is added below.
-                        */
-                       user_prt->length = (sizeof (pci_routing_table) -4);
-
-                       /*
-                        * Dereference the sub-package
-                        */
-                       package_element = *top_object_list;
+               /*
+                * The Sub_object_list will now point to an array of the four IRQ
+                * elements: Address, Pin, Source and Source_index
+                */
+               sub_object_list = package_element->package.elements;
 
-                       /*
-                        * The Sub_object_list will now point to an array of
-                        * the four IRQ elements: Address, Pin, Source and
-                        * Source_index
-                        */
-                       sub_object_list = package_element->package.elements;
+               /*
+                * 1) First subobject:  Dereference the Address
+                */
+               if (ACPI_TYPE_INTEGER == (*sub_object_list)->common.type) {
+                       user_prt->address = (*sub_object_list)->integer.value;
+               }
+               else {
+                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Need Integer, found %s\n",
+                               acpi_ut_get_type_name ((*sub_object_list)->common.type)));
+                       return_ACPI_STATUS (AE_BAD_DATA);
+               }
 
-                       /*
-                        * 1) First subobject:  Dereference the Address
-                        */
-                       if (ACPI_TYPE_INTEGER == (*sub_object_list)->common.type) {
-                               user_prt->address = (*sub_object_list)->integer.value;
-                       }
+               /*
+                * 2) Second subobject: Dereference the Pin
+                */
+               sub_object_list++;
 
-                       else {
-                               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Need Integer, found %s\n",
-                                       acpi_ut_get_type_name ((*sub_object_list)->common.type)));
-                               return_ACPI_STATUS (AE_BAD_DATA);
-                       }
+               if (ACPI_TYPE_INTEGER == (*sub_object_list)->common.type) {
+                       user_prt->pin = (u32) (*sub_object_list)->integer.value;
+               }
+               else {
+                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Need Integer, found %s\n",
+                               acpi_ut_get_type_name ((*sub_object_list)->common.type)));
+                       return_ACPI_STATUS (AE_BAD_DATA);
+               }
 
-                       /*
-                        * 2) Second subobject: Dereference the Pin
-                        */
-                       sub_object_list++;
+               /*
+                * 3) Third subobject: Dereference the Source Name
+                */
+               sub_object_list++;
 
-                       if (ACPI_TYPE_INTEGER == (*sub_object_list)->common.type) {
-                               user_prt->pin = (u32) (*sub_object_list)->integer.value;
-                       }
+               switch ((*sub_object_list)->common.type) {
+               case INTERNAL_TYPE_REFERENCE:
 
-                       else {
-                               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Need Integer, found %s\n",
-                                       acpi_ut_get_type_name ((*sub_object_list)->common.type)));
+                       if ((*sub_object_list)->reference.opcode != AML_INT_NAMEPATH_OP) {
+                          ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Need name, found reference op %X\n",
+                                       (*sub_object_list)->reference.opcode));
                                return_ACPI_STATUS (AE_BAD_DATA);
                        }
 
-                       /*
-                        * 3) Third subobject: Dereference the Source Name
-                        */
-                       sub_object_list++;
-
-                       switch ((*sub_object_list)->common.type) {
-                       case INTERNAL_TYPE_REFERENCE:
+                       node = (*sub_object_list)->reference.node;
 
-                               if ((*sub_object_list)->reference.opcode != AML_INT_NAMEPATH_OP) {
-                                  ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Need name, found reference op %X\n",
-                                               (*sub_object_list)->reference.opcode));
-                                       return_ACPI_STATUS (AE_BAD_DATA);
-                               }
+                       /* Use *remaining* length of the buffer as max for pathname */
 
-                               node = (*sub_object_list)->reference.node;
+                       path_buffer.length = output_buffer->length -
+                                          (u32) ((u8 *) user_prt->source - (u8 *) output_buffer->pointer);
+                       path_buffer.pointer = user_prt->source;
 
-                               /* TBD: use *remaining* length of the buffer! */
+                       status = acpi_ns_handle_to_pathname ((acpi_handle *) node, &path_buffer);
 
-                               status = acpi_ns_handle_to_pathname ((acpi_handle *) node,
-                                                output_buffer_length, user_prt->source);
+                       user_prt->length += ACPI_STRLEN (user_prt->source) + 1; /* include null terminator */
+                       break;
 
-                               user_prt->length += STRLEN (user_prt->source) + 1; /* include null terminator */
-                               break;
 
+               case ACPI_TYPE_STRING:
 
-                       case ACPI_TYPE_STRING:
+                       ACPI_STRCPY (user_prt->source,
+                                 (*sub_object_list)->string.pointer);
 
-                               STRCPY (user_prt->source,
-                                         (*sub_object_list)->string.pointer);
+                       /* Add to the Length field the length of the string */
 
-                               /*
-                                * Add to the Length field the length of the string
-                                */
-                               user_prt->length += (*sub_object_list)->string.length;
-                               break;
+                       user_prt->length += (*sub_object_list)->string.length;
+                       break;
 
 
-                       case ACPI_TYPE_INTEGER:
-                               /*
-                                * If this is a number, then the Source Name
-                                * is NULL, since the entire buffer was zeroed
-                                * out, we can leave this alone.
-                                */
-                               /*
-                                * Add to the Length field the length of
-                                * the u32 NULL
-                                */
-                               user_prt->length += sizeof (u32);
-                               break;
+               case ACPI_TYPE_INTEGER:
+                       /*
+                        * If this is a number, then the Source Name is NULL, since the
+                        * entire buffer was zeroed out, we can leave this alone.
+                        *
+                        * Add to the Length field the length of the u32 NULL
+                        */
+                       user_prt->length += sizeof (u32);
+                       break;
 
 
-                       default:
+               default:
 
-                          ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Need Integer, found %s\n",
-                                       acpi_ut_get_type_name ((*sub_object_list)->common.type)));
-                          return_ACPI_STATUS (AE_BAD_DATA);
-                          break;
-                       }
+                  ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Need Integer, found %s\n",
+                               acpi_ut_get_type_name ((*sub_object_list)->common.type)));
+                  return_ACPI_STATUS (AE_BAD_DATA);
+               }
 
-                       /* Now align the current length */
+               /* Now align the current length */
 
-                       user_prt->length = ROUND_UP_TO_64_bITS (user_prt->length);
+               user_prt->length = ACPI_ROUND_UP_TO_64_bITS (user_prt->length);
 
-                       /*
-                        * 4) Fourth subobject: Dereference the Source Index
-                        */
-                       sub_object_list++;
-
-                       if (ACPI_TYPE_INTEGER == (*sub_object_list)->common.type) {
-                               user_prt->source_index = (u32) (*sub_object_list)->integer.value;
-                       }
-
-                       else {
-                               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Need Integer, found %s\n",
-                                       acpi_ut_get_type_name ((*sub_object_list)->common.type)));
-                               return_ACPI_STATUS (AE_BAD_DATA);
-                       }
+               /*
+                * 4) Fourth subobject: Dereference the Source Index
+                */
+               sub_object_list++;
 
-                       /*
-                        * Point to the next acpi_operand_object
-                        */
-                       top_object_list++;
+               if (ACPI_TYPE_INTEGER == (*sub_object_list)->common.type) {
+                       user_prt->source_index = (u32) (*sub_object_list)->integer.value;
+               }
+               else {
+                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Need Integer, found %s\n",
+                               acpi_ut_get_type_name ((*sub_object_list)->common.type)));
+                       return_ACPI_STATUS (AE_BAD_DATA);
                }
 
-               ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Output_buffer = %p\n", output_buffer));
-       }
-
-       else {
-               *output_buffer_length = buffer_size_needed;
+               /* Point to the next acpi_operand_object */
 
-               return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
+               top_object_list++;
        }
 
-       /*
-        * Report the amount of buffer used
-        */
-       *output_buffer_length = buffer_size_needed;
+       ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Output_buffer %p Length %X\n",
+                       output_buffer->pointer, output_buffer->length));
        return_ACPI_STATUS (AE_OK);
 }
 
@@ -366,11 +327,10 @@ acpi_rs_create_pci_routing_table (
  *
  * PARAMETERS:  Linked_list_buffer      - Pointer to the resource linked list
  *              Output_buffer           - Pointer to the user's buffer
- *              Output_buffer_length    - Size of Output_buffer
  *
  * RETURN:      Status  AE_OK if okay, else a valid acpi_status code.
  *              If the Output_buffer is too small, the error will be
- *              AE_BUFFER_OVERFLOW and Output_buffer_length will point
+ *              AE_BUFFER_OVERFLOW and Output_buffer->Length will point
  *              to the size buffer needed.
  *
  * DESCRIPTION: Takes the linked list of device resources and
@@ -382,14 +342,13 @@ acpi_rs_create_pci_routing_table (
 acpi_status
 acpi_rs_create_byte_stream (
        acpi_resource           *linked_list_buffer,
-       u8                      *output_buffer,
-       u32                     *output_buffer_length)
+       acpi_buffer             *output_buffer)
 {
        acpi_status             status;
-       u32                     byte_stream_size_needed = 0;
+       ACPI_SIZE               byte_stream_size_needed = 0;
 
 
-       FUNCTION_TRACE ("Rs_create_byte_stream");
+       ACPI_FUNCTION_TRACE ("Rs_create_byte_stream");
 
 
        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Linked_list_buffer = %p\n", linked_list_buffer));
@@ -397,7 +356,7 @@ acpi_rs_create_byte_stream (
        /*
         * Params already validated, so we don't re-validate here
         *
-        * Pass the Linked_list_buffer into a module that can calculate
+        * Pass the Linked_list_buffer into a module that calculates
         * the buffer size needed for the byte stream.
         */
        status = acpi_rs_calculate_byte_stream_length (linked_list_buffer,
@@ -405,42 +364,27 @@ acpi_rs_create_byte_stream (
 
        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Byte_stream_size_needed=%X, %s\n",
                byte_stream_size_needed, acpi_format_exception (status)));
-
-       /*
-        * Exit with the error passed back
-        */
        if (ACPI_FAILURE (status)) {
                return_ACPI_STATUS (status);
        }
 
-       /*
-        * If the linked list will fit into the available buffer
-        * call to fill in the list
-        */
-       if (byte_stream_size_needed <= *output_buffer_length) {
-               /*
-                * Zero out the return buffer before proceeding
-                */
-               MEMSET (output_buffer, 0x00, *output_buffer_length);
-
-               status = acpi_rs_list_to_byte_stream (linked_list_buffer, byte_stream_size_needed,
-                                &output_buffer);
+       /* Validate/Allocate/Clear caller buffer */
 
-               /*
-                * Exit with the error passed back
-                */
-               if (ACPI_FAILURE (status)) {
-                       return_ACPI_STATUS (status);
-               }
-
-               ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Output_buffer = %p\n", output_buffer));
+       status = acpi_ut_initialize_buffer (output_buffer, byte_stream_size_needed);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
        }
 
-       else {
-               *output_buffer_length = byte_stream_size_needed;
-               return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
+       /* Do the conversion */
+
+       status = acpi_rs_list_to_byte_stream (linked_list_buffer, byte_stream_size_needed,
+                         output_buffer->pointer);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
        }
 
+       ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Output_buffer %p Length %X\n",
+                       output_buffer->pointer, output_buffer->length));
        return_ACPI_STATUS (AE_OK);
 }
 
index 5a90b55f0c6bd543621c9dc8dbe11e3b461d428f..c28cddcdd3e03c79c3a406f90508882c48bd78b3 100644 (file)
@@ -1,12 +1,12 @@
 /*******************************************************************************
  *
  * Module Name: rsdump - Functions to display the resource structures.
- *              $Revision: 23 $
+ *              $Revision: 29 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -28,7 +28,7 @@
 #include "acresrc.h"
 
 #define _COMPONENT          ACPI_RESOURCES
-        MODULE_NAME         ("rsdump")
+        ACPI_MODULE_NAME    ("rsdump")
 
 
 #ifdef ACPI_DEBUG
@@ -53,19 +53,19 @@ acpi_rs_dump_irq (
        u8                      index = 0;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        acpi_os_printf ("IRQ Resource\n");
 
        acpi_os_printf ("  %s Triggered\n",
-                        LEVEL_SENSITIVE == irq_data->edge_level ? "Level" : "Edge");
+                        ACPI_LEVEL_SENSITIVE == irq_data->edge_level ? "Level" : "Edge");
 
        acpi_os_printf ("  Active %s\n",
-                        ACTIVE_LOW == irq_data->active_high_low ? "Low" : "High");
+                        ACPI_ACTIVE_LOW == irq_data->active_high_low ? "Low" : "High");
 
        acpi_os_printf ("  %s\n",
-                        SHARED == irq_data->shared_exclusive ? "Shared" : "Exclusive");
+                        ACPI_SHARED == irq_data->shared_exclusive ? "Shared" : "Exclusive");
 
        acpi_os_printf ("  %X Interrupts ( ", irq_data->number_of_interrupts);
 
@@ -98,25 +98,25 @@ acpi_rs_dump_dma (
        u8                      index = 0;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        acpi_os_printf ("DMA Resource\n");
 
        switch (dma_data->type) {
-       case COMPATIBILITY:
+       case ACPI_COMPATIBILITY:
                acpi_os_printf ("  Compatibility mode\n");
                break;
 
-       case TYPE_A:
+       case ACPI_TYPE_A:
                acpi_os_printf ("  Type A\n");
                break;
 
-       case TYPE_B:
+       case ACPI_TYPE_B:
                acpi_os_printf ("  Type B\n");
                break;
 
-       case TYPE_F:
+       case ACPI_TYPE_F:
                acpi_os_printf ("  Type F\n");
                break;
 
@@ -126,19 +126,19 @@ acpi_rs_dump_dma (
        }
 
        acpi_os_printf ("  %sBus Master\n",
-                        BUS_MASTER == dma_data->bus_master ? "" : "Not a ");
+                        ACPI_BUS_MASTER == dma_data->bus_master ? "" : "Not a ");
 
 
        switch (dma_data->transfer) {
-       case TRANSFER_8:
+       case ACPI_TRANSFER_8:
                acpi_os_printf ("  8-bit only transfer\n");
                break;
 
-       case TRANSFER_8_16:
+       case ACPI_TRANSFER_8_16:
                acpi_os_printf ("  8 and 16-bit transfer\n");
                break;
 
-       case TRANSFER_16:
+       case ACPI_TRANSFER_16:
                acpi_os_printf ("  16 bit only transfer\n");
                break;
 
@@ -160,7 +160,7 @@ acpi_rs_dump_dma (
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_dump_start_dependent_functions
+ * FUNCTION:    Acpi_rs_dump_start_depend_fns
  *
  * PARAMETERS:  Data            - pointer to the resource structure to dump.
  *
@@ -171,27 +171,27 @@ acpi_rs_dump_dma (
  ******************************************************************************/
 
 void
-acpi_rs_dump_start_dependent_functions (
+acpi_rs_dump_start_depend_fns (
        acpi_resource_data          *data)
 {
        acpi_resource_start_dpf     *sdf_data = (acpi_resource_start_dpf *) data;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        acpi_os_printf ("Start Dependent Functions Resource\n");
 
        switch (sdf_data->compatibility_priority) {
-       case GOOD_CONFIGURATION:
+       case ACPI_GOOD_CONFIGURATION:
                acpi_os_printf ("  Good configuration\n");
                break;
 
-       case ACCEPTABLE_CONFIGURATION:
+       case ACPI_ACCEPTABLE_CONFIGURATION:
                acpi_os_printf ("  Acceptable configuration\n");
                break;
 
-       case SUB_OPTIMAL_CONFIGURATION:
+       case ACPI_SUB_OPTIMAL_CONFIGURATION:
                acpi_os_printf ("  Sub-optimal configuration\n");
                break;
 
@@ -201,15 +201,15 @@ acpi_rs_dump_start_dependent_functions (
        }
 
        switch(sdf_data->performance_robustness) {
-       case GOOD_CONFIGURATION:
+       case ACPI_GOOD_CONFIGURATION:
                acpi_os_printf ("  Good configuration\n");
                break;
 
-       case ACCEPTABLE_CONFIGURATION:
+       case ACPI_ACCEPTABLE_CONFIGURATION:
                acpi_os_printf ("  Acceptable configuration\n");
                break;
 
-       case SUB_OPTIMAL_CONFIGURATION:
+       case ACPI_SUB_OPTIMAL_CONFIGURATION:
                acpi_os_printf ("  Sub-optimal configuration\n");
                break;
 
@@ -242,13 +242,13 @@ acpi_rs_dump_io (
        acpi_resource_io        *io_data = (acpi_resource_io *) data;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        acpi_os_printf ("Io Resource\n");
 
        acpi_os_printf ("  %d bit decode\n",
-                        DECODE_16 == io_data->io_decode ? 16 : 10);
+                        ACPI_DECODE_16 == io_data->io_decode ? 16 : 10);
 
        acpi_os_printf ("  Range minimum base: %08X\n",
                         io_data->min_base_address);
@@ -285,7 +285,7 @@ acpi_rs_dump_fixed_io (
        acpi_resource_fixed_io  *fixed_io_data = (acpi_resource_fixed_io *) data;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        acpi_os_printf ("Fixed Io Resource\n");
@@ -319,7 +319,7 @@ acpi_rs_dump_vendor_specific (
        u16                     index = 0;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        acpi_os_printf ("Vendor Specific Resource\n");
@@ -354,13 +354,13 @@ acpi_rs_dump_memory24 (
        acpi_resource_mem24     *memory24_data = (acpi_resource_mem24 *) data;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        acpi_os_printf ("24-Bit Memory Range Resource\n");
 
        acpi_os_printf ("  Read%s\n",
-                        READ_WRITE_MEMORY ==
+                        ACPI_READ_WRITE_MEMORY ==
                         memory24_data->read_write_attribute ?
                         "/Write" : " only");
 
@@ -399,13 +399,13 @@ acpi_rs_dump_memory32 (
        acpi_resource_mem32     *memory32_data = (acpi_resource_mem32 *) data;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        acpi_os_printf ("32-Bit Memory Range Resource\n");
 
        acpi_os_printf ("  Read%s\n",
-                        READ_WRITE_MEMORY ==
+                        ACPI_READ_WRITE_MEMORY ==
                         memory32_data->read_write_attribute ?
                         "/Write" : " only");
 
@@ -444,13 +444,13 @@ acpi_rs_dump_fixed_memory32 (
        acpi_resource_fixed_mem32   *fixed_memory32_data = (acpi_resource_fixed_mem32 *) data;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        acpi_os_printf ("32-Bit Fixed Location Memory Range Resource\n");
 
        acpi_os_printf ("  Read%s\n",
-                        READ_WRITE_MEMORY ==
+                        ACPI_READ_WRITE_MEMORY ==
                         fixed_memory32_data->read_write_attribute ?
                         "/Write" : " Only");
 
@@ -483,34 +483,34 @@ acpi_rs_dump_address16 (
        acpi_resource_address16 *address16_data = (acpi_resource_address16 *) data;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        acpi_os_printf ("16-Bit Address Space Resource\n");
        acpi_os_printf ("  Resource Type: ");
 
        switch (address16_data->resource_type) {
-       case MEMORY_RANGE:
+       case ACPI_MEMORY_RANGE:
 
                acpi_os_printf ("Memory Range\n");
 
                switch (address16_data->attribute.memory.cache_attribute) {
-               case NON_CACHEABLE_MEMORY:
+               case ACPI_NON_CACHEABLE_MEMORY:
                        acpi_os_printf ("  Type Specific: "
                                          "Noncacheable memory\n");
                        break;
 
-               case CACHABLE_MEMORY:
+               case ACPI_CACHABLE_MEMORY:
                        acpi_os_printf ("  Type Specific: "
                                          "Cacheable memory\n");
                        break;
 
-               case WRITE_COMBINING_MEMORY:
+               case ACPI_WRITE_COMBINING_MEMORY:
                        acpi_os_printf ("  Type Specific: "
                                          "Write-combining memory\n");
                        break;
 
-               case PREFETCHABLE_MEMORY:
+               case ACPI_PREFETCHABLE_MEMORY:
                        acpi_os_printf ("  Type Specific: "
                                          "Prefetchable memory\n");
                        break;
@@ -522,27 +522,27 @@ acpi_rs_dump_address16 (
                }
 
                acpi_os_printf ("  Type Specific: Read%s\n",
-                       READ_WRITE_MEMORY ==
+                       ACPI_READ_WRITE_MEMORY ==
                        address16_data->attribute.memory.read_write_attribute ?
                        "/Write" : " Only");
                break;
 
-       case IO_RANGE:
+       case ACPI_IO_RANGE:
 
                acpi_os_printf ("I/O Range\n");
 
                switch (address16_data->attribute.io.range_attribute) {
-               case NON_ISA_ONLY_RANGES:
+               case ACPI_NON_ISA_ONLY_RANGES:
                        acpi_os_printf ("  Type Specific: "
                                          "Non-ISA Io Addresses\n");
                        break;
 
-               case ISA_ONLY_RANGES:
+               case ACPI_ISA_ONLY_RANGES:
                        acpi_os_printf ("  Type Specific: "
                                          "ISA Io Addresses\n");
                        break;
 
-               case ENTIRE_RANGE:
+               case ACPI_ENTIRE_RANGE:
                        acpi_os_printf ("  Type Specific: "
                                          "ISA and non-ISA Io Addresses\n");
                        break;
@@ -554,7 +554,7 @@ acpi_rs_dump_address16 (
                }
                break;
 
-       case BUS_NUMBER_RANGE:
+       case ACPI_BUS_NUMBER_RANGE:
 
                acpi_os_printf ("Bus Number Range\n");
                break;
@@ -566,19 +566,19 @@ acpi_rs_dump_address16 (
        }
 
        acpi_os_printf ("  Resource %s\n",
-                       CONSUMER == address16_data->producer_consumer ?
+                       ACPI_CONSUMER == address16_data->producer_consumer ?
                        "Consumer" : "Producer");
 
        acpi_os_printf ("  %s decode\n",
-                        SUB_DECODE == address16_data->decode ?
+                        ACPI_SUB_DECODE == address16_data->decode ?
                         "Subtractive" : "Positive");
 
        acpi_os_printf ("  Min address is %s fixed\n",
-                        ADDRESS_FIXED == address16_data->min_address_fixed ?
+                        ACPI_ADDRESS_FIXED == address16_data->min_address_fixed ?
                         "" : "not");
 
        acpi_os_printf ("  Max address is %s fixed\n",
-                        ADDRESS_FIXED == address16_data->max_address_fixed ?
+                        ACPI_ADDRESS_FIXED == address16_data->max_address_fixed ?
                         "" : "not");
 
        acpi_os_printf ("  Granularity: %08X\n",
@@ -626,33 +626,33 @@ acpi_rs_dump_address32 (
        acpi_resource_address32 *address32_data = (acpi_resource_address32 *) data;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        acpi_os_printf ("32-Bit Address Space Resource\n");
 
        switch (address32_data->resource_type) {
-       case MEMORY_RANGE:
+       case ACPI_MEMORY_RANGE:
 
                acpi_os_printf ("  Resource Type: Memory Range\n");
 
                switch (address32_data->attribute.memory.cache_attribute) {
-               case NON_CACHEABLE_MEMORY:
+               case ACPI_NON_CACHEABLE_MEMORY:
                        acpi_os_printf ("  Type Specific: "
                                          "Noncacheable memory\n");
                        break;
 
-               case CACHABLE_MEMORY:
+               case ACPI_CACHABLE_MEMORY:
                        acpi_os_printf ("  Type Specific: "
                                          "Cacheable memory\n");
                        break;
 
-               case WRITE_COMBINING_MEMORY:
+               case ACPI_WRITE_COMBINING_MEMORY:
                        acpi_os_printf ("  Type Specific: "
                                          "Write-combining memory\n");
                        break;
 
-               case PREFETCHABLE_MEMORY:
+               case ACPI_PREFETCHABLE_MEMORY:
                        acpi_os_printf ("  Type Specific: "
                                          "Prefetchable memory\n");
                        break;
@@ -664,27 +664,27 @@ acpi_rs_dump_address32 (
                }
 
                acpi_os_printf ("  Type Specific: Read%s\n",
-                       READ_WRITE_MEMORY ==
+                       ACPI_READ_WRITE_MEMORY ==
                        address32_data->attribute.memory.read_write_attribute ?
                        "/Write" : " Only");
                break;
 
-       case IO_RANGE:
+       case ACPI_IO_RANGE:
 
                acpi_os_printf ("  Resource Type: Io Range\n");
 
                switch (address32_data->attribute.io.range_attribute) {
-                       case NON_ISA_ONLY_RANGES:
+                       case ACPI_NON_ISA_ONLY_RANGES:
                                acpi_os_printf ("  Type Specific: "
                                                  "Non-ISA Io Addresses\n");
                                break;
 
-                       case ISA_ONLY_RANGES:
+                       case ACPI_ISA_ONLY_RANGES:
                                acpi_os_printf ("  Type Specific: "
                                                  "ISA Io Addresses\n");
                                break;
 
-                       case ENTIRE_RANGE:
+                       case ACPI_ENTIRE_RANGE:
                                acpi_os_printf ("  Type Specific: "
                                                  "ISA and non-ISA Io Addresses\n");
                                break;
@@ -696,7 +696,7 @@ acpi_rs_dump_address32 (
                        }
                break;
 
-       case BUS_NUMBER_RANGE:
+       case ACPI_BUS_NUMBER_RANGE:
 
                acpi_os_printf ("  Resource Type: Bus Number Range\n");
                break;
@@ -708,19 +708,19 @@ acpi_rs_dump_address32 (
        }
 
        acpi_os_printf ("  Resource %s\n",
-                        CONSUMER == address32_data->producer_consumer ?
+                        ACPI_CONSUMER == address32_data->producer_consumer ?
                         "Consumer" : "Producer");
 
        acpi_os_printf ("  %s decode\n",
-                        SUB_DECODE == address32_data->decode ?
+                        ACPI_SUB_DECODE == address32_data->decode ?
                         "Subtractive" : "Positive");
 
        acpi_os_printf ("  Min address is %s fixed\n",
-                        ADDRESS_FIXED == address32_data->min_address_fixed ?
+                        ACPI_ADDRESS_FIXED == address32_data->min_address_fixed ?
                         "" : "not ");
 
        acpi_os_printf ("  Max address is %s fixed\n",
-                        ADDRESS_FIXED == address32_data->max_address_fixed ?
+                        ACPI_ADDRESS_FIXED == address32_data->max_address_fixed ?
                         "" : "not ");
 
        acpi_os_printf ("  Granularity: %08X\n",
@@ -768,33 +768,33 @@ acpi_rs_dump_address64 (
        acpi_resource_address64 *address64_data = (acpi_resource_address64 *) data;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        acpi_os_printf ("64-Bit Address Space Resource\n");
 
        switch (address64_data->resource_type) {
-       case MEMORY_RANGE:
+       case ACPI_MEMORY_RANGE:
 
                acpi_os_printf ("  Resource Type: Memory Range\n");
 
                switch (address64_data->attribute.memory.cache_attribute) {
-               case NON_CACHEABLE_MEMORY:
+               case ACPI_NON_CACHEABLE_MEMORY:
                        acpi_os_printf ("  Type Specific: "
                                          "Noncacheable memory\n");
                        break;
 
-               case CACHABLE_MEMORY:
+               case ACPI_CACHABLE_MEMORY:
                        acpi_os_printf ("  Type Specific: "
                                          "Cacheable memory\n");
                        break;
 
-               case WRITE_COMBINING_MEMORY:
+               case ACPI_WRITE_COMBINING_MEMORY:
                        acpi_os_printf ("  Type Specific: "
                                          "Write-combining memory\n");
                        break;
 
-               case PREFETCHABLE_MEMORY:
+               case ACPI_PREFETCHABLE_MEMORY:
                        acpi_os_printf ("  Type Specific: "
                                          "Prefetchable memory\n");
                        break;
@@ -806,27 +806,27 @@ acpi_rs_dump_address64 (
                }
 
                acpi_os_printf ("  Type Specific: Read%s\n",
-                       READ_WRITE_MEMORY ==
+                       ACPI_READ_WRITE_MEMORY ==
                        address64_data->attribute.memory.read_write_attribute ?
                        "/Write" : " Only");
                break;
 
-       case IO_RANGE:
+       case ACPI_IO_RANGE:
 
                acpi_os_printf ("  Resource Type: Io Range\n");
 
                switch (address64_data->attribute.io.range_attribute) {
-                       case NON_ISA_ONLY_RANGES:
+                       case ACPI_NON_ISA_ONLY_RANGES:
                                acpi_os_printf ("  Type Specific: "
                                                  "Non-ISA Io Addresses\n");
                                break;
 
-                       case ISA_ONLY_RANGES:
+                       case ACPI_ISA_ONLY_RANGES:
                                acpi_os_printf ("  Type Specific: "
                                                  "ISA Io Addresses\n");
                                break;
 
-                       case ENTIRE_RANGE:
+                       case ACPI_ENTIRE_RANGE:
                                acpi_os_printf ("  Type Specific: "
                                                  "ISA and non-ISA Io Addresses\n");
                                break;
@@ -838,7 +838,7 @@ acpi_rs_dump_address64 (
                        }
                break;
 
-       case BUS_NUMBER_RANGE:
+       case ACPI_BUS_NUMBER_RANGE:
 
                acpi_os_printf ("  Resource Type: Bus Number Range\n");
                break;
@@ -850,19 +850,19 @@ acpi_rs_dump_address64 (
        }
 
        acpi_os_printf ("  Resource %s\n",
-                        CONSUMER == address64_data->producer_consumer ?
+                        ACPI_CONSUMER == address64_data->producer_consumer ?
                         "Consumer" : "Producer");
 
        acpi_os_printf ("  %s decode\n",
-                        SUB_DECODE == address64_data->decode ?
+                        ACPI_SUB_DECODE == address64_data->decode ?
                         "Subtractive" : "Positive");
 
        acpi_os_printf ("  Min address is %s fixed\n",
-                        ADDRESS_FIXED == address64_data->min_address_fixed ?
+                        ACPI_ADDRESS_FIXED == address64_data->min_address_fixed ?
                         "" : "not ");
 
        acpi_os_printf ("  Max address is %s fixed\n",
-                        ADDRESS_FIXED == address64_data->max_address_fixed ?
+                        ACPI_ADDRESS_FIXED == address64_data->max_address_fixed ?
                         "" : "not ");
 
        acpi_os_printf ("  Granularity: %16X\n",
@@ -911,25 +911,25 @@ acpi_rs_dump_extended_irq (
        u8                      index = 0;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        acpi_os_printf ("Extended IRQ Resource\n");
 
        acpi_os_printf ("  Resource %s\n",
-                        CONSUMER == ext_irq_data->producer_consumer ?
+                        ACPI_CONSUMER == ext_irq_data->producer_consumer ?
                         "Consumer" : "Producer");
 
        acpi_os_printf ("  %s\n",
-                        LEVEL_SENSITIVE == ext_irq_data->edge_level ?
+                        ACPI_LEVEL_SENSITIVE == ext_irq_data->edge_level ?
                         "Level" : "Edge");
 
        acpi_os_printf ("  Active %s\n",
-                        ACTIVE_LOW == ext_irq_data->active_high_low ?
+                        ACPI_ACTIVE_LOW == ext_irq_data->active_high_low ?
                         "low" : "high");
 
        acpi_os_printf ("  %s\n",
-                        SHARED == ext_irq_data->shared_exclusive ?
+                        ACPI_SHARED == ext_irq_data->shared_exclusive ?
                         "Shared" : "Exclusive");
 
        acpi_os_printf ("  Interrupts : %X ( ",
@@ -972,7 +972,7 @@ acpi_rs_dump_resource_list (
        u8                  done = FALSE;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        if (acpi_dbg_level & ACPI_LV_RESOURCES && _COMPONENT & acpi_dbg_layer) {
@@ -989,7 +989,7 @@ acpi_rs_dump_resource_list (
                                break;
 
                        case ACPI_RSTYPE_START_DPF:
-                               acpi_rs_dump_start_dependent_functions (&resource->data);
+                               acpi_rs_dump_start_depend_fns (&resource->data);
                                break;
 
                        case ACPI_RSTYPE_END_DPF:
@@ -1049,7 +1049,7 @@ acpi_rs_dump_resource_list (
 
                        }
 
-                       resource = POINTER_ADD (acpi_resource, resource, resource->length);
+                       resource = ACPI_PTR_ADD (acpi_resource, resource, resource->length);
                }
        }
 
@@ -1070,25 +1070,26 @@ acpi_rs_dump_resource_list (
 
 void
 acpi_rs_dump_irq_list (
-       u8                  *route_table)
+       u8                      *route_table)
 {
-       u8                  *buffer = route_table;
-       u8                  count = 0;
-       u8                  done = FALSE;
-       pci_routing_table   *prt_element;
+       u8                      *buffer = route_table;
+       u8                      count = 0;
+       u8                      done = FALSE;
+       acpi_pci_routing_table  *prt_element;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        if (acpi_dbg_level & ACPI_LV_RESOURCES && _COMPONENT & acpi_dbg_layer) {
-               prt_element = (pci_routing_table *) buffer;
+               prt_element = (acpi_pci_routing_table *) buffer;
 
                while (!done) {
                        acpi_os_printf ("PCI IRQ Routing Table structure %X.\n", count++);
 
-                       acpi_os_printf ("  Address: %X\n",
-                                        prt_element->address);
+                       acpi_os_printf ("  Address: %8.8X%8.8X\n",
+                                        ACPI_HIDWORD (prt_element->address),
+                                        ACPI_LODWORD (prt_element->address));
 
                        acpi_os_printf ("  Pin: %X\n", prt_element->pin);
 
@@ -1099,7 +1100,7 @@ acpi_rs_dump_irq_list (
 
                        buffer += prt_element->length;
 
-                       prt_element = (pci_routing_table *) buffer;
+                       prt_element = (acpi_pci_routing_table *) buffer;
 
                        if(0 == prt_element->length) {
                                done = TRUE;
index aaa10629268ba84ec0328a524cab78523f5873c6..ab09fa5ec7284b4f4804c90ba8fda1af3da5c946 100644 (file)
@@ -1,12 +1,12 @@
 /*******************************************************************************
  *
  * Module Name: rsio - IO and DMA resource descriptors
- *              $Revision: 14 $
+ *              $Revision: 17 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -28,7 +28,7 @@
 #include "acresrc.h"
 
 #define _COMPONENT          ACPI_RESOURCES
-        MODULE_NAME         ("rsio")
+        ACPI_MODULE_NAME    ("rsio")
 
 
 /*******************************************************************************
  *
  * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              Bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the Byte_stream_buffer is
+ *                                        returned
+ *              Output_buffer           - Pointer to the return data buffer
+ *              Structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
 acpi_status
 acpi_rs_io_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size)
+       ACPI_SIZE               *structure_size)
 {
        u8                      *buffer = byte_stream_buffer;
        acpi_resource           *output_struct = (acpi_resource *) *output_buffer;
        u16                     temp16 = 0;
        u8                      temp8 = 0;
-       u32                     struct_size = SIZEOF_RESOURCE (acpi_resource_io);
+       ACPI_SIZE               struct_size = ACPI_SIZEOF_RESOURCE (acpi_resource_io);
 
 
-       FUNCTION_TRACE ("Rs_io_resource");
+       ACPI_FUNCTION_TRACE ("Rs_io_resource");
 
 
        /*
@@ -89,7 +88,7 @@ acpi_rs_io_resource (
         * Check Min_base Address
         */
        buffer += 1;
-       MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+       ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
 
        output_struct->data.io.min_base_address = temp16;
 
@@ -97,7 +96,7 @@ acpi_rs_io_resource (
         * Check Max_base Address
         */
        buffer += 2;
-       MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+       ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
 
        output_struct->data.io.max_base_address = temp16;
 
@@ -136,13 +135,12 @@ acpi_rs_io_resource (
  *
  * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              Bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the Byte_stream_buffer is
+ *                                        returned
+ *              Output_buffer           - Pointer to the return data buffer
+ *              Structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
@@ -155,18 +153,18 @@ acpi_rs_io_resource (
 acpi_status
 acpi_rs_fixed_io_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size)
+       ACPI_SIZE               *structure_size)
 {
        u8                      *buffer = byte_stream_buffer;
        acpi_resource           *output_struct = (acpi_resource *) *output_buffer;
        u16                     temp16 = 0;
        u8                      temp8 = 0;
-       u32                     struct_size = SIZEOF_RESOURCE (acpi_resource_fixed_io);
+       ACPI_SIZE               struct_size = ACPI_SIZEOF_RESOURCE (acpi_resource_fixed_io);
 
 
-       FUNCTION_TRACE ("Rs_fixed_io_resource");
+       ACPI_FUNCTION_TRACE ("Rs_fixed_io_resource");
 
 
        /*
@@ -180,7 +178,7 @@ acpi_rs_fixed_io_resource (
         * Check Range Base Address
         */
        buffer += 1;
-       MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+       ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
 
        output_struct->data.fixed_io.base_address = temp16;
 
@@ -211,9 +209,8 @@ acpi_rs_fixed_io_resource (
  *
  * PARAMETERS:  Linked_list             - Pointer to the resource linked list
  *              Output_buffer           - Pointer to the user's return buffer
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes of the
- *                                        Output_buffer used
+ *              Bytes_consumed          - Pointer to where the number of bytes
+ *                                        used in the Output_buffer is returned
  *
  * RETURN:      Status
  *
@@ -226,14 +223,14 @@ acpi_status
 acpi_rs_io_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed)
+       ACPI_SIZE               *bytes_consumed)
 {
        u8                      *buffer = *output_buffer;
        u16                     temp16 = 0;
        u8                      temp8 = 0;
 
 
-       FUNCTION_TRACE ("Rs_io_stream");
+       ACPI_FUNCTION_TRACE ("Rs_io_stream");
 
 
        /*
@@ -255,7 +252,7 @@ acpi_rs_io_stream (
         */
        temp16 = (u16) linked_list->data.io.min_base_address;
 
-       MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
+       ACPI_MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
        buffer += 2;
 
        /*
@@ -263,7 +260,7 @@ acpi_rs_io_stream (
         */
        temp16 = (u16) linked_list->data.io.max_base_address;
 
-       MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
+       ACPI_MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
        buffer += 2;
 
        /*
@@ -285,7 +282,7 @@ acpi_rs_io_stream (
        /*
         * Return the number of bytes consumed in this operation
         */
-       *bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+       *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
        return_ACPI_STATUS (AE_OK);
 }
 
@@ -296,9 +293,8 @@ acpi_rs_io_stream (
  *
  * PARAMETERS:  Linked_list             - Pointer to the resource linked list
  *              Output_buffer           - Pointer to the user's return buffer
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes of the
- *                                        Output_buffer used
+ *              Bytes_consumed          - Pointer to where the number of bytes
+ *                                        used in the Output_buffer is returned
  *
  * RETURN:      Status
  *
@@ -311,14 +307,14 @@ acpi_status
 acpi_rs_fixed_io_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed)
+       ACPI_SIZE               *bytes_consumed)
 {
        u8                      *buffer = *output_buffer;
        u16                     temp16 = 0;
        u8                      temp8 = 0;
 
 
-       FUNCTION_TRACE ("Rs_fixed_io_stream");
+       ACPI_FUNCTION_TRACE ("Rs_fixed_io_stream");
 
 
        /*
@@ -333,7 +329,7 @@ acpi_rs_fixed_io_stream (
         */
        temp16 = (u16) linked_list->data.fixed_io.base_address;
 
-       MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
+       ACPI_MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
        buffer += 2;
 
        /*
@@ -347,7 +343,7 @@ acpi_rs_fixed_io_stream (
        /*
         * Return the number of bytes consumed in this operation
         */
-       *bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+       *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
        return_ACPI_STATUS (AE_OK);
 }
 
@@ -358,13 +354,12 @@ acpi_rs_fixed_io_stream (
  *
  * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              Bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the Byte_stream_buffer is
+ *                                        returned
+ *              Output_buffer           - Pointer to the return data buffer
+ *              Structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
@@ -377,19 +372,19 @@ acpi_rs_fixed_io_stream (
 acpi_status
 acpi_rs_dma_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size)
+       ACPI_SIZE               *structure_size)
 {
        u8                      *buffer = byte_stream_buffer;
        acpi_resource           *output_struct = (acpi_resource *) *output_buffer;
        u8                      temp8 = 0;
        u8                      index;
        u8                      i;
-       u32                     struct_size = SIZEOF_RESOURCE (acpi_resource_dma);
+       ACPI_SIZE               struct_size = ACPI_SIZEOF_RESOURCE (acpi_resource_dma);
 
 
-       FUNCTION_TRACE ("Rs_dma_resource");
+       ACPI_FUNCTION_TRACE ("Rs_dma_resource");
 
 
        /*
@@ -464,9 +459,8 @@ acpi_rs_dma_resource (
  *
  * PARAMETERS:  Linked_list             - Pointer to the resource linked list
  *              Output_buffer           - Pointer to the user's return buffer
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes of the
- *                                        Output_buffer used
+ *              Bytes_consumed          - Pointer to where the number of bytes
+ *                                        used in the Output_buffer is returned
  *
  * RETURN:      Status
  *
@@ -479,7 +473,7 @@ acpi_status
 acpi_rs_dma_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed)
+       ACPI_SIZE               *bytes_consumed)
 {
        u8                      *buffer = *output_buffer;
        u16                     temp16 = 0;
@@ -487,7 +481,7 @@ acpi_rs_dma_stream (
        u8                      index;
 
 
-       FUNCTION_TRACE ("Rs_dma_stream");
+       ACPI_FUNCTION_TRACE ("Rs_dma_stream");
 
 
        /*
@@ -523,7 +517,7 @@ acpi_rs_dma_stream (
        /*
         * Return the number of bytes consumed in this operation
         */
-       *bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+       *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
        return_ACPI_STATUS (AE_OK);
 }
 
index a6d1ab107a9c394cba8121888809734c07ad2764..fc9ea44cc328614357b872afde930008a21ab927 100644 (file)
@@ -1,12 +1,12 @@
 /*******************************************************************************
  *
  * Module Name: rsirq - IRQ resource descriptors
- *              $Revision: 18 $
+ *              $Revision: 24 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -28,7 +28,7 @@
 #include "acresrc.h"
 
 #define _COMPONENT          ACPI_RESOURCES
-        MODULE_NAME         ("rsirq")
+        ACPI_MODULE_NAME    ("rsirq")
 
 
 /*******************************************************************************
  *
  * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              Bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the Byte_stream_buffer is
+ *                                        returned
+ *              Output_buffer           - Pointer to the return data buffer
+ *              Structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
@@ -56,9 +55,9 @@
 acpi_status
 acpi_rs_irq_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size)
+       ACPI_SIZE               *structure_size)
 {
        u8                      *buffer = byte_stream_buffer;
        acpi_resource           *output_struct = (acpi_resource *) *output_buffer;
@@ -66,10 +65,10 @@ acpi_rs_irq_resource (
        u8                      temp8 = 0;
        u8                      index;
        u8                      i;
-       u32                     struct_size = SIZEOF_RESOURCE (acpi_resource_irq);
+       ACPI_SIZE               struct_size = ACPI_SIZEOF_RESOURCE (acpi_resource_irq);
 
 
-       FUNCTION_TRACE ("Rs_irq_resource");
+       ACPI_FUNCTION_TRACE ("Rs_irq_resource");
 
 
        /*
@@ -84,7 +83,7 @@ acpi_rs_irq_resource (
         * Point to the 16-bits of Bytes 1 and 2
         */
        buffer += 1;
-       MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+       ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
 
        output_struct->data.irq.number_of_interrupts = 0;
 
@@ -114,16 +113,14 @@ acpi_rs_irq_resource (
                 * Check for HE, LL or HL
                 */
                if (temp8 & 0x01) {
-                       output_struct->data.irq.edge_level = EDGE_SENSITIVE;
-                       output_struct->data.irq.active_high_low = ACTIVE_HIGH;
+                       output_struct->data.irq.edge_level = ACPI_EDGE_SENSITIVE;
+                       output_struct->data.irq.active_high_low = ACPI_ACTIVE_HIGH;
                }
-
                else {
                        if (temp8 & 0x8) {
-                               output_struct->data.irq.edge_level = LEVEL_SENSITIVE;
-                               output_struct->data.irq.active_high_low = ACTIVE_LOW;
+                               output_struct->data.irq.edge_level = ACPI_LEVEL_SENSITIVE;
+                               output_struct->data.irq.active_high_low = ACPI_ACTIVE_LOW;
                        }
-
                        else {
                                /*
                                 * Only _LL and _HE polarity/trigger interrupts
@@ -139,15 +136,14 @@ acpi_rs_irq_resource (
                 */
                output_struct->data.irq.shared_exclusive = (temp8 >> 3) & 0x01;
        }
-
        else {
                /*
                 * Assume Edge Sensitive, Active High, Non-Sharable
                 * per ACPI Specification
                 */
-               output_struct->data.irq.edge_level = EDGE_SENSITIVE;
-               output_struct->data.irq.active_high_low = ACTIVE_HIGH;
-               output_struct->data.irq.shared_exclusive = EXCLUSIVE;
+               output_struct->data.irq.edge_level = ACPI_EDGE_SENSITIVE;
+               output_struct->data.irq.active_high_low = ACPI_ACTIVE_HIGH;
+               output_struct->data.irq.shared_exclusive = ACPI_EXCLUSIVE;
        }
 
        /*
@@ -169,9 +165,8 @@ acpi_rs_irq_resource (
  *
  * PARAMETERS:  Linked_list             - Pointer to the resource linked list
  *              Output_buffer           - Pointer to the user's return buffer
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes of the
- *                                        Output_buffer used
+ *              Bytes_consumed          - Pointer to where the number of bytes
+ *                                        used in the Output_buffer is returned
  *
  * RETURN:      Status
  *
@@ -184,7 +179,7 @@ acpi_status
 acpi_rs_irq_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed)
+       ACPI_SIZE               *bytes_consumed)
 {
        u8                      *buffer = *output_buffer;
        u16                     temp16 = 0;
@@ -193,20 +188,19 @@ acpi_rs_irq_stream (
        u8                      IRQinfo_byte_needed;
 
 
-       FUNCTION_TRACE ("Rs_irq_stream");
+       ACPI_FUNCTION_TRACE ("Rs_irq_stream");
 
 
        /*
         * The descriptor field is set based upon whether a third byte is
         * needed to contain the IRQ Information.
         */
-       if (EDGE_SENSITIVE == linked_list->data.irq.edge_level &&
-               ACTIVE_HIGH == linked_list->data.irq.active_high_low &&
-               EXCLUSIVE == linked_list->data.irq.shared_exclusive) {
+       if (ACPI_EDGE_SENSITIVE == linked_list->data.irq.edge_level &&
+               ACPI_ACTIVE_HIGH == linked_list->data.irq.active_high_low &&
+               ACPI_EXCLUSIVE == linked_list->data.irq.shared_exclusive) {
                *buffer = 0x22;
                IRQinfo_byte_needed = FALSE;
        }
-
        else {
                *buffer = 0x23;
                IRQinfo_byte_needed = TRUE;
@@ -225,7 +219,7 @@ acpi_rs_irq_stream (
                temp16 |= 0x1 << temp8;
        }
 
-       MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
+       ACPI_MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
        buffer += 2;
 
        /*
@@ -236,11 +230,10 @@ acpi_rs_irq_stream (
                temp8 = (u8) ((linked_list->data.irq.shared_exclusive &
                                 0x01) << 4);
 
-               if (LEVEL_SENSITIVE == linked_list->data.irq.edge_level &&
-                       ACTIVE_LOW == linked_list->data.irq.active_high_low) {
+               if (ACPI_LEVEL_SENSITIVE == linked_list->data.irq.edge_level &&
+                       ACPI_ACTIVE_LOW == linked_list->data.irq.active_high_low) {
                        temp8 |= 0x08;
                }
-
                else {
                        temp8 |= 0x01;
                }
@@ -252,7 +245,7 @@ acpi_rs_irq_stream (
        /*
         * Return the number of bytes consumed in this operation
         */
-       *bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+       *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
        return_ACPI_STATUS (AE_OK);
 }
 
@@ -263,13 +256,12 @@ acpi_rs_irq_stream (
  *
  * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              Bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the Byte_stream_buffer is
+ *                                        returned
+ *              Output_buffer           - Pointer to the return data buffer
+ *              Structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
@@ -282,9 +274,9 @@ acpi_rs_irq_stream (
 acpi_status
 acpi_rs_extended_irq_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size)
+       ACPI_SIZE               *structure_size)
 {
        u8                      *buffer = byte_stream_buffer;
        acpi_resource           *output_struct = (acpi_resource *) *output_buffer;
@@ -292,17 +284,17 @@ acpi_rs_extended_irq_resource (
        u8                      temp8 = 0;
        NATIVE_CHAR             *temp_ptr;
        u8                      index;
-       u32                     struct_size = SIZEOF_RESOURCE (acpi_resource_ext_irq);
+       ACPI_SIZE               struct_size = ACPI_SIZEOF_RESOURCE (acpi_resource_ext_irq);
 
 
-       FUNCTION_TRACE ("Rs_extended_irq_resource");
+       ACPI_FUNCTION_TRACE ("Rs_extended_irq_resource");
 
 
        /*
         * Point past the Descriptor to get the number of bytes consumed
         */
        buffer += 1;
-       MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+       ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
 
        *bytes_consumed = temp16 + 3;
        output_struct->id = ACPI_RSTYPE_EXT_IRQ;
@@ -316,28 +308,20 @@ acpi_rs_extended_irq_resource (
        output_struct->data.extended_irq.producer_consumer = temp8 & 0x01;
 
        /*
-        * Check for HE, LL or HL
+        * Check for Interrupt Mode
+        *
+        * The definition of an Extended IRQ changed between ACPI spec v1.0b
+        * and ACPI spec 2.0 (section 6.4.3.6 in both).
+        *
+        * - Edge/Level are defined opposite in the table vs the headers
         */
-       if(temp8 & 0x02) {
-               output_struct->data.extended_irq.edge_level = EDGE_SENSITIVE;
-               output_struct->data.extended_irq.active_high_low = ACTIVE_HIGH;
-       }
-
-       else {
-               if(temp8 & 0x4) {
-                       output_struct->data.extended_irq.edge_level = LEVEL_SENSITIVE;
-                       output_struct->data.extended_irq.active_high_low = ACTIVE_LOW;
-               }
+       output_struct->data.extended_irq.edge_level =
+                          (temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE;
 
-               else {
-                       /*
-                        * Only _LL and _HE polarity/trigger interrupts
-                        * are allowed (ACPI spec v1.0b ection 6.4.2.1),
-                        * so an error will occur if we reach this point
-                        */
-                       return_ACPI_STATUS (AE_BAD_DATA);
-               }
-       }
+       /*
+        * Check Interrupt Polarity
+        */
+       output_struct->data.extended_irq.active_high_low = (temp8 >> 2) & 0x1;
 
        /*
         * Check for sharable
@@ -404,7 +388,6 @@ acpi_rs_extended_irq_resource (
                /* Copy the string into the buffer */
 
                index = 0;
-
                while (0x00 != *buffer) {
                        *temp_ptr = *buffer;
 
@@ -425,9 +408,8 @@ acpi_rs_extended_irq_resource (
                 * Struct_size to the next 32-bit boundary.
                 */
                temp8 = (u8) (index + 1);
-               struct_size += ROUND_UP_TO_32_bITS (temp8);
+               struct_size += ACPI_ROUND_UP_TO_32_bITS (temp8);
        }
-
        else {
                output_struct->data.extended_irq.resource_source.index = 0x00;
                output_struct->data.extended_irq.resource_source.string_length = 0;
@@ -453,9 +435,8 @@ acpi_rs_extended_irq_resource (
  *
  * PARAMETERS:  Linked_list             - Pointer to the resource linked list
  *              Output_buffer           - Pointer to the user's return buffer
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes of the
- *                                        Output_buffer used
+ *              Bytes_consumed          - Pointer to where the number of bytes
+ *                                        used in the Output_buffer is returned
  *
  * RETURN:      Status
  *
@@ -468,7 +449,7 @@ acpi_status
 acpi_rs_extended_irq_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed)
+       ACPI_SIZE               *bytes_consumed)
 {
        u8                      *buffer = *output_buffer;
        u16                     *length_field;
@@ -477,7 +458,7 @@ acpi_rs_extended_irq_stream (
        NATIVE_CHAR             *temp_pointer = NULL;
 
 
-       FUNCTION_TRACE ("Rs_extended_irq_stream");
+       ACPI_FUNCTION_TRACE ("Rs_extended_irq_stream");
 
 
        /*
@@ -498,14 +479,24 @@ acpi_rs_extended_irq_stream (
        temp8 = (u8)(linked_list->data.extended_irq.producer_consumer & 0x01);
        temp8 |= ((linked_list->data.extended_irq.shared_exclusive & 0x01) << 3);
 
-       if (LEVEL_SENSITIVE == linked_list->data.extended_irq.edge_level &&
-          ACTIVE_LOW == linked_list->data.extended_irq.active_high_low) {
-               temp8 |= 0x04;
-       }
-       else {
-               temp8 |= 0x02;
+       /*
+        * Set the Interrupt Mode
+        *
+        * The definition of an Extended IRQ changed between ACPI spec v1.0b
+        * and ACPI spec 2.0 (section 6.4.3.6 in both).  This code does not
+        * implement the more restrictive definition of 1.0b
+        *
+        * - Edge/Level are defined opposite in the table vs the headers
+        */
+       if (ACPI_EDGE_SENSITIVE == linked_list->data.extended_irq.edge_level) {
+               temp8 |= 0x2;
        }
 
+       /*
+        * Set the Interrupt Polarity
+        */
+       temp8 |= ((linked_list->data.extended_irq.active_high_low & 0x1) << 2);
+
        *buffer = temp8;
        buffer += 1;
 
@@ -519,7 +510,7 @@ acpi_rs_extended_irq_stream (
 
        for (index = 0; index < linked_list->data.extended_irq.number_of_interrupts;
                 index++) {
-               MOVE_UNALIGNED32_TO_32 (buffer,
+               ACPI_MOVE_UNALIGNED32_TO_32 (buffer,
                                  &linked_list->data.extended_irq.interrupts[index]);
                buffer += 4;
        }
@@ -536,20 +527,20 @@ acpi_rs_extended_irq_stream (
                /*
                 * Copy the string
                 */
-               STRCPY (temp_pointer,
+               ACPI_STRCPY (temp_pointer,
                        linked_list->data.extended_irq.resource_source.string_ptr);
 
                /*
                 * Buffer needs to be set to the length of the sting + one for the
                 * terminating null
                 */
-               buffer += (STRLEN (linked_list->data.extended_irq.resource_source.string_ptr) + 1);
+               buffer += (ACPI_STRLEN (linked_list->data.extended_irq.resource_source.string_ptr) + 1);
        }
 
        /*
         * Return the number of bytes consumed in this operation
         */
-       *bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+       *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
 
        /*
         * Set the length field to the number of bytes consumed
index a6ad460fd38e0e2413ef1240a37272e0277dcd23..2ffd506f53aa0ca3435c4d4a03fc796ba42d42f8 100644 (file)
@@ -1,12 +1,12 @@
 /*******************************************************************************
  *
  * Module Name: rslist - Linked list utilities
- *              $Revision: 19 $
+ *              $Revision: 26 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -28,7 +28,7 @@
 #include "acresrc.h"
 
 #define _COMPONENT          ACPI_RESOURCES
-        MODULE_NAME         ("rslist")
+        ACPI_MODULE_NAME    ("rslist")
 
 
 /*******************************************************************************
@@ -49,29 +49,27 @@ acpi_rs_get_resource_type (
        u8                      resource_start_byte)
 {
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        /*
         * Determine if this is a small or large resource
         */
-       switch (resource_start_byte & RESOURCE_DESC_TYPE_MASK) {
-       case RESOURCE_DESC_TYPE_SMALL:
+       switch (resource_start_byte & ACPI_RDESC_TYPE_MASK) {
+       case ACPI_RDESC_TYPE_SMALL:
 
                /*
                 * Small Resource Type -- Only bits 6:3 are valid
                 */
-               return ((u8) (resource_start_byte & RESOURCE_DESC_SMALL_MASK));
-               break;
+               return ((u8) (resource_start_byte & ACPI_RDESC_SMALL_MASK));
 
 
-       case RESOURCE_DESC_TYPE_LARGE:
+       case ACPI_RDESC_TYPE_LARGE:
 
                /*
                 * Large Resource Type -- All bits are valid
                 */
                return (resource_start_byte);
-               break;
        }
 
        return (0xFF);
@@ -98,18 +96,18 @@ acpi_status
 acpi_rs_byte_stream_to_list (
        u8                      *byte_stream_buffer,
        u32                     byte_stream_buffer_length,
-       u8                      **output_buffer)
+       u8                      *output_buffer)
 {
        acpi_status             status;
        u32                     bytes_parsed = 0;
        u8                      resource_type = 0;
-       u32                     bytes_consumed = 0;
-       u8                      **buffer = output_buffer;
-       u32                     structure_size = 0;
+       ACPI_SIZE               bytes_consumed = 0;
+       u8                      *buffer = output_buffer;
+       ACPI_SIZE               structure_size = 0;
        u8                      end_tag_processed = FALSE;
+       acpi_resource           *resource;
 
-
-       FUNCTION_TRACE ("Rs_byte_stream_to_list");
+       ACPI_FUNCTION_TRACE ("Rs_byte_stream_to_list");
 
 
        while (bytes_parsed < byte_stream_buffer_length &&
@@ -120,148 +118,148 @@ acpi_rs_byte_stream_to_list (
                resource_type = acpi_rs_get_resource_type (*byte_stream_buffer);
 
                switch (resource_type) {
-               case RESOURCE_DESC_MEMORY_24:
+               case ACPI_RDESC_TYPE_MEMORY_24:
                        /*
                         * 24-Bit Memory Resource
                         */
                        status = acpi_rs_memory24_resource (byte_stream_buffer,
-                                        &bytes_consumed, buffer, &structure_size);
+                                        &bytes_consumed, &buffer, &structure_size);
                        break;
 
 
-               case RESOURCE_DESC_LARGE_VENDOR:
+               case ACPI_RDESC_TYPE_LARGE_VENDOR:
                        /*
                         * Vendor Defined Resource
                         */
                        status = acpi_rs_vendor_resource (byte_stream_buffer,
-                                        &bytes_consumed, buffer, &structure_size);
+                                        &bytes_consumed, &buffer, &structure_size);
                        break;
 
 
-               case RESOURCE_DESC_MEMORY_32:
+               case ACPI_RDESC_TYPE_MEMORY_32:
                        /*
                         * 32-Bit Memory Range Resource
                         */
                        status = acpi_rs_memory32_range_resource (byte_stream_buffer,
-                                        &bytes_consumed, buffer, &structure_size);
+                                        &bytes_consumed, &buffer, &structure_size);
                        break;
 
 
-               case RESOURCE_DESC_FIXED_MEMORY_32:
+               case ACPI_RDESC_TYPE_FIXED_MEMORY_32:
                        /*
                         * 32-Bit Fixed Memory Resource
                         */
                        status = acpi_rs_fixed_memory32_resource (byte_stream_buffer,
-                                        &bytes_consumed, buffer, &structure_size);
+                                        &bytes_consumed, &buffer, &structure_size);
                        break;
 
 
-               case RESOURCE_DESC_QWORD_ADDRESS_SPACE:
+               case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE:
                        /*
                         * 64-Bit Address Resource
                         */
                        status = acpi_rs_address64_resource (byte_stream_buffer,
-                                        &bytes_consumed, buffer, &structure_size);
+                                        &bytes_consumed, &buffer, &structure_size);
                        break;
 
 
-               case RESOURCE_DESC_DWORD_ADDRESS_SPACE:
+               case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE:
                        /*
                         * 32-Bit Address Resource
                         */
                        status = acpi_rs_address32_resource (byte_stream_buffer,
-                                        &bytes_consumed, buffer, &structure_size);
+                                        &bytes_consumed, &buffer, &structure_size);
                        break;
 
 
-               case RESOURCE_DESC_WORD_ADDRESS_SPACE:
+               case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE:
                        /*
                         * 16-Bit Address Resource
                         */
                        status = acpi_rs_address16_resource (byte_stream_buffer,
-                                        &bytes_consumed, buffer, &structure_size);
+                                        &bytes_consumed, &buffer, &structure_size);
                        break;
 
 
-               case RESOURCE_DESC_EXTENDED_XRUPT:
+               case ACPI_RDESC_TYPE_EXTENDED_XRUPT:
                        /*
                         * Extended IRQ
                         */
                        status = acpi_rs_extended_irq_resource (byte_stream_buffer,
-                                        &bytes_consumed, buffer, &structure_size);
+                                        &bytes_consumed, &buffer, &structure_size);
                        break;
 
 
-               case RESOURCE_DESC_IRQ_FORMAT:
+               case ACPI_RDESC_TYPE_IRQ_FORMAT:
                        /*
                         * IRQ Resource
                         */
                        status = acpi_rs_irq_resource (byte_stream_buffer,
-                                        &bytes_consumed, buffer, &structure_size);
+                                        &bytes_consumed, &buffer, &structure_size);
                        break;
 
 
-               case RESOURCE_DESC_DMA_FORMAT:
+               case ACPI_RDESC_TYPE_DMA_FORMAT:
                        /*
                         * DMA Resource
                         */
                        status = acpi_rs_dma_resource (byte_stream_buffer,
-                                        &bytes_consumed, buffer, &structure_size);
+                                        &bytes_consumed, &buffer, &structure_size);
                        break;
 
 
-               case RESOURCE_DESC_START_DEPENDENT:
+               case ACPI_RDESC_TYPE_START_DEPENDENT:
                        /*
                         * Start Dependent Functions Resource
                         */
-                       status = acpi_rs_start_dependent_functions_resource (byte_stream_buffer,
-                                        &bytes_consumed, buffer, &structure_size);
+                       status = acpi_rs_start_depend_fns_resource (byte_stream_buffer,
+                                        &bytes_consumed, &buffer, &structure_size);
                        break;
 
 
-               case RESOURCE_DESC_END_DEPENDENT:
+               case ACPI_RDESC_TYPE_END_DEPENDENT:
                        /*
                         * End Dependent Functions Resource
                         */
-                       status = acpi_rs_end_dependent_functions_resource (byte_stream_buffer,
-                                        &bytes_consumed, buffer, &structure_size);
+                       status = acpi_rs_end_depend_fns_resource (byte_stream_buffer,
+                                        &bytes_consumed, &buffer, &structure_size);
                        break;
 
 
-               case RESOURCE_DESC_IO_PORT:
+               case ACPI_RDESC_TYPE_IO_PORT:
                        /*
                         * IO Port Resource
                         */
                        status = acpi_rs_io_resource (byte_stream_buffer,
-                                        &bytes_consumed, buffer, &structure_size);
+                                        &bytes_consumed, &buffer, &structure_size);
                        break;
 
 
-               case RESOURCE_DESC_FIXED_IO_PORT:
+               case ACPI_RDESC_TYPE_FIXED_IO_PORT:
                        /*
                         * Fixed IO Port Resource
                         */
                        status = acpi_rs_fixed_io_resource (byte_stream_buffer,
-                                        &bytes_consumed, buffer, &structure_size);
+                                        &bytes_consumed, &buffer, &structure_size);
                        break;
 
 
-               case RESOURCE_DESC_SMALL_VENDOR:
+               case ACPI_RDESC_TYPE_SMALL_VENDOR:
                        /*
                         * Vendor Specific Resource
                         */
                        status = acpi_rs_vendor_resource (byte_stream_buffer,
-                                        &bytes_consumed, buffer, &structure_size);
+                                        &bytes_consumed, &buffer, &structure_size);
                        break;
 
 
-               case RESOURCE_DESC_END_TAG:
+               case ACPI_RDESC_TYPE_END_TAG:
                        /*
                         * End Tag
                         */
                        end_tag_processed = TRUE;
                        status = acpi_rs_end_tag_resource (byte_stream_buffer,
-                                        &bytes_consumed, buffer, &structure_size);
+                                        &bytes_consumed, &buffer, &structure_size);
                        break;
 
 
@@ -273,8 +271,7 @@ acpi_rs_byte_stream_to_list (
                        break;
                }
 
-
-               if (!ACPI_SUCCESS(status)) {
+               if (ACPI_FAILURE (status)) {
                        return_ACPI_STATUS (status);
                }
 
@@ -291,7 +288,9 @@ acpi_rs_byte_stream_to_list (
                /*
                 * Set the Buffer to the next structure
                 */
-               *buffer += structure_size;
+               resource = (acpi_resource *)buffer;
+               resource->length = ACPI_ALIGN_RESOURCE_SIZE(resource->length);
+               buffer += ACPI_ALIGN_RESOURCE_SIZE(structure_size);
 
        } /*  end while */
 
@@ -331,15 +330,15 @@ acpi_status
 acpi_rs_list_to_byte_stream (
        acpi_resource           *linked_list,
        u32                     byte_stream_size_needed,
-       u8                      **output_buffer)
+       u8                      *output_buffer)
 {
        acpi_status             status;
-       u8                      *buffer = *output_buffer;
-       u32                     bytes_consumed = 0;
+       u8                      *buffer = output_buffer;
+       ACPI_SIZE               bytes_consumed = 0;
        u8                      done = FALSE;
 
 
-       FUNCTION_TRACE ("Rs_list_to_byte_stream");
+       ACPI_FUNCTION_TRACE ("Rs_list_to_byte_stream");
 
 
        while (!done) {
@@ -362,7 +361,7 @@ acpi_rs_list_to_byte_stream (
                        /*
                         * Start Dependent Functions Resource
                         */
-                       status = acpi_rs_start_dependent_functions_stream (linked_list,
+                       status = acpi_rs_start_depend_fns_stream (linked_list,
                                          &buffer, &bytes_consumed);
                        break;
 
@@ -370,7 +369,7 @@ acpi_rs_list_to_byte_stream (
                        /*
                         * End Dependent Functions Resource
                         */
-                       status = acpi_rs_end_dependent_functions_stream (linked_list,
+                       status = acpi_rs_end_depend_fns_stream (linked_list,
                                          &buffer, &bytes_consumed);
                        break;
 
@@ -472,8 +471,7 @@ acpi_rs_list_to_byte_stream (
 
                } /* switch (Linked_list->Id) */
 
-
-               if (!ACPI_SUCCESS(status)) {
+               if (ACPI_FAILURE (status)) {
                        return_ACPI_STATUS (status);
                }
 
@@ -485,7 +483,7 @@ acpi_rs_list_to_byte_stream (
                /*
                 * Point to the next object
                 */
-               linked_list = POINTER_ADD (acpi_resource,
+               linked_list = ACPI_PTR_ADD (acpi_resource,
                                  linked_list, linked_list->length);
        }
 
index af181a52727d617b4966d104c03d335647af96c5..ef00af5183834bdcad180b8fa43f4f1051a8fd34 100644 (file)
@@ -1,12 +1,12 @@
 /*******************************************************************************
  *
  * Module Name: rsmem24 - Memory resource descriptors
- *              $Revision: 14 $
+ *              $Revision: 17 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -28,7 +28,7 @@
 #include "acresrc.h"
 
 #define _COMPONENT          ACPI_RESOURCES
-        MODULE_NAME         ("rsmemory")
+        ACPI_MODULE_NAME    ("rsmemory")
 
 
 /*******************************************************************************
  *
  * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              Bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the Byte_stream_buffer is
+ *                                        returned
+ *              Output_buffer           - Pointer to the return data buffer
+ *              Structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
 acpi_status
 acpi_rs_memory24_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size)
+       ACPI_SIZE               *structure_size)
 {
        u8                      *buffer = byte_stream_buffer;
        acpi_resource           *output_struct = (acpi_resource *) *output_buffer;
        u16                     temp16 = 0;
        u8                      temp8 = 0;
-       u32                     struct_size = SIZEOF_RESOURCE (acpi_resource_mem24);
+       ACPI_SIZE               struct_size = ACPI_SIZEOF_RESOURCE (acpi_resource_mem24);
 
 
-       FUNCTION_TRACE ("Rs_memory24_resource");
+       ACPI_FUNCTION_TRACE ("Rs_memory24_resource");
 
 
        /*
@@ -75,7 +74,7 @@ acpi_rs_memory24_resource (
         */
        buffer += 1;
 
-       MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+       ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
        buffer += 2;
        *bytes_consumed = temp16 + 3;
        output_struct->id = ACPI_RSTYPE_MEM24;
@@ -90,28 +89,28 @@ acpi_rs_memory24_resource (
        /*
         * Get Min_base_address (Bytes 4-5)
         */
-       MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+       ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
        buffer += 2;
        output_struct->data.memory24.min_base_address = temp16;
 
        /*
         * Get Max_base_address (Bytes 6-7)
         */
-       MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+       ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
        buffer += 2;
        output_struct->data.memory24.max_base_address = temp16;
 
        /*
         * Get Alignment (Bytes 8-9)
         */
-       MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+       ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
        buffer += 2;
        output_struct->data.memory24.alignment = temp16;
 
        /*
         * Get Range_length (Bytes 10-11)
         */
-       MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+       ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
        output_struct->data.memory24.range_length = temp16;
 
        /*
@@ -133,9 +132,8 @@ acpi_rs_memory24_resource (
  *
  * PARAMETERS:  Linked_list             - Pointer to the resource linked list
  *              Output_buffer           - Pointer to the user's return buffer
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes of the
- *                                        Output_buffer used
+ *              Bytes_consumed          - Pointer to where the number of bytes
+ *                                        used in the Output_buffer is returned
  *
  * RETURN:      Status
  *
@@ -148,14 +146,14 @@ acpi_status
 acpi_rs_memory24_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed)
+       ACPI_SIZE               *bytes_consumed)
 {
        u8                      *buffer = *output_buffer;
        u16                     temp16 = 0;
        u8                      temp8 = 0;
 
 
-       FUNCTION_TRACE ("Rs_memory24_stream");
+       ACPI_FUNCTION_TRACE ("Rs_memory24_stream");
 
 
        /*
@@ -168,7 +166,7 @@ acpi_rs_memory24_stream (
         * The length field is static
         */
        temp16 = 0x09;
-       MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
+       ACPI_MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
        buffer += 2;
 
        /*
@@ -181,31 +179,31 @@ acpi_rs_memory24_stream (
        /*
         * Set the Range minimum base address
         */
-       MOVE_UNALIGNED16_TO_16 (buffer, &linked_list->data.memory24.min_base_address);
+       ACPI_MOVE_UNALIGNED16_TO_16 (buffer, &linked_list->data.memory24.min_base_address);
        buffer += 2;
 
        /*
         * Set the Range maximum base address
         */
-       MOVE_UNALIGNED16_TO_16 (buffer, &linked_list->data.memory24.max_base_address);
+       ACPI_MOVE_UNALIGNED16_TO_16 (buffer, &linked_list->data.memory24.max_base_address);
        buffer += 2;
 
        /*
         * Set the base alignment
         */
-       MOVE_UNALIGNED16_TO_16 (buffer, &linked_list->data.memory24.alignment);
+       ACPI_MOVE_UNALIGNED16_TO_16 (buffer, &linked_list->data.memory24.alignment);
        buffer += 2;
 
        /*
         * Set the range length
         */
-       MOVE_UNALIGNED16_TO_16 (buffer, &linked_list->data.memory24.range_length);
+       ACPI_MOVE_UNALIGNED16_TO_16 (buffer, &linked_list->data.memory24.range_length);
        buffer += 2;
 
        /*
         * Return the number of bytes consumed in this operation
         */
-       *bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+       *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
        return_ACPI_STATUS (AE_OK);
 }
 
@@ -216,13 +214,12 @@ acpi_rs_memory24_stream (
  *
  * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              Bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the Byte_stream_buffer is
+ *                                        returned
+ *              Output_buffer           - Pointer to the return data buffer
+ *              Structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
@@ -235,18 +232,18 @@ acpi_rs_memory24_stream (
 acpi_status
 acpi_rs_memory32_range_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size)
+       ACPI_SIZE               *structure_size)
 {
        u8                      *buffer = byte_stream_buffer;
        acpi_resource           *output_struct = (acpi_resource *) *output_buffer;
        u16                     temp16 = 0;
        u8                      temp8 = 0;
-       u32                     struct_size = SIZEOF_RESOURCE (acpi_resource_mem32);
+       ACPI_SIZE               struct_size = ACPI_SIZEOF_RESOURCE (acpi_resource_mem32);
 
 
-       FUNCTION_TRACE ("Rs_memory32_range_resource");
+       ACPI_FUNCTION_TRACE ("Rs_memory32_range_resource");
 
 
        /*
@@ -254,7 +251,7 @@ acpi_rs_memory32_range_resource (
         */
        buffer += 1;
 
-       MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+       ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
        buffer += 2;
        *bytes_consumed = temp16 + 3;
 
@@ -281,27 +278,27 @@ acpi_rs_memory32_range_resource (
        /*
         * Get Min_base_address (Bytes 4-7)
         */
-       MOVE_UNALIGNED32_TO_32 (&output_struct->data.memory32.min_base_address,
+       ACPI_MOVE_UNALIGNED32_TO_32 (&output_struct->data.memory32.min_base_address,
                         buffer);
        buffer += 4;
 
        /*
         * Get Max_base_address (Bytes 8-11)
         */
-       MOVE_UNALIGNED32_TO_32 (&output_struct->data.memory32.max_base_address,
+       ACPI_MOVE_UNALIGNED32_TO_32 (&output_struct->data.memory32.max_base_address,
                         buffer);
        buffer += 4;
 
        /*
         * Get Alignment (Bytes 12-15)
         */
-       MOVE_UNALIGNED32_TO_32 (&output_struct->data.memory32.alignment, buffer);
+       ACPI_MOVE_UNALIGNED32_TO_32 (&output_struct->data.memory32.alignment, buffer);
        buffer += 4;
 
        /*
         * Get Range_length (Bytes 16-19)
         */
-       MOVE_UNALIGNED32_TO_32 (&output_struct->data.memory32.range_length, buffer);
+       ACPI_MOVE_UNALIGNED32_TO_32 (&output_struct->data.memory32.range_length, buffer);
 
        /*
         * Set the Length parameter
@@ -322,13 +319,12 @@ acpi_rs_memory32_range_resource (
  *
  * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              Bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the Byte_stream_buffer is
+ *                                        returned
+ *              Output_buffer           - Pointer to the return data buffer
+ *              Structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
@@ -341,25 +337,25 @@ acpi_rs_memory32_range_resource (
 acpi_status
 acpi_rs_fixed_memory32_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size)
+       ACPI_SIZE               *structure_size)
 {
        u8                      *buffer = byte_stream_buffer;
        acpi_resource           *output_struct = (acpi_resource *) *output_buffer;
        u16                     temp16 = 0;
        u8                      temp8 = 0;
-       u32                     struct_size = SIZEOF_RESOURCE (acpi_resource_fixed_mem32);
+       ACPI_SIZE               struct_size = ACPI_SIZEOF_RESOURCE (acpi_resource_fixed_mem32);
 
 
-       FUNCTION_TRACE ("Rs_fixed_memory32_resource");
+       ACPI_FUNCTION_TRACE ("Rs_fixed_memory32_resource");
 
 
        /*
         * Point past the Descriptor to get the number of bytes consumed
         */
        buffer += 1;
-       MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+       ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
 
        buffer += 2;
        *bytes_consumed = temp16 + 3;
@@ -376,14 +372,14 @@ acpi_rs_fixed_memory32_resource (
        /*
         * Get Range_base_address (Bytes 4-7)
         */
-       MOVE_UNALIGNED32_TO_32 (&output_struct->data.fixed_memory32.range_base_address,
+       ACPI_MOVE_UNALIGNED32_TO_32 (&output_struct->data.fixed_memory32.range_base_address,
                         buffer);
        buffer += 4;
 
        /*
         * Get Range_length (Bytes 8-11)
         */
-       MOVE_UNALIGNED32_TO_32 (&output_struct->data.fixed_memory32.range_length,
+       ACPI_MOVE_UNALIGNED32_TO_32 (&output_struct->data.fixed_memory32.range_length,
                         buffer);
 
        /*
@@ -405,9 +401,8 @@ acpi_rs_fixed_memory32_resource (
  *
  * PARAMETERS:  Linked_list             - Pointer to the resource linked list
  *              Output_buffer           - Pointer to the user's return buffer
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes of the
- *                                        Output_buffer used
+ *              Bytes_consumed          - Pointer to where the number of bytes
+ *                                        used in the Output_buffer is returned
  *
  * RETURN:      Status
  *
@@ -420,14 +415,14 @@ acpi_status
 acpi_rs_memory32_range_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed)
+       ACPI_SIZE               *bytes_consumed)
 {
        u8                      *buffer = *output_buffer;
        u16                     temp16 = 0;
        u8                      temp8 = 0;
 
 
-       FUNCTION_TRACE ("Rs_memory32_range_stream");
+       ACPI_FUNCTION_TRACE ("Rs_memory32_range_stream");
 
 
        /*
@@ -441,7 +436,7 @@ acpi_rs_memory32_range_stream (
         */
        temp16 = 0x11;
 
-       MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
+       ACPI_MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
        buffer += 2;
 
        /*
@@ -454,31 +449,31 @@ acpi_rs_memory32_range_stream (
        /*
         * Set the Range minimum base address
         */
-       MOVE_UNALIGNED32_TO_32 (buffer, &linked_list->data.memory32.min_base_address);
+       ACPI_MOVE_UNALIGNED32_TO_32 (buffer, &linked_list->data.memory32.min_base_address);
        buffer += 4;
 
        /*
         * Set the Range maximum base address
         */
-       MOVE_UNALIGNED32_TO_32 (buffer, &linked_list->data.memory32.max_base_address);
+       ACPI_MOVE_UNALIGNED32_TO_32 (buffer, &linked_list->data.memory32.max_base_address);
        buffer += 4;
 
        /*
         * Set the base alignment
         */
-       MOVE_UNALIGNED32_TO_32 (buffer, &linked_list->data.memory32.alignment);
+       ACPI_MOVE_UNALIGNED32_TO_32 (buffer, &linked_list->data.memory32.alignment);
        buffer += 4;
 
        /*
         * Set the range length
         */
-       MOVE_UNALIGNED32_TO_32 (buffer, &linked_list->data.memory32.range_length);
+       ACPI_MOVE_UNALIGNED32_TO_32 (buffer, &linked_list->data.memory32.range_length);
        buffer += 4;
 
        /*
         * Return the number of bytes consumed in this operation
         */
-       *bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+       *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
        return_ACPI_STATUS (AE_OK);
 }
 
@@ -489,9 +484,8 @@ acpi_rs_memory32_range_stream (
  *
  * PARAMETERS:  Linked_list             - Pointer to the resource linked list
  *              Output_buffer           - Pointer to the user's return buffer
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes of the
- *                                        Output_buffer used
+ *              Bytes_consumed          - Pointer to where the number of bytes
+ *                                        used in the Output_buffer is returned
  *
  * RETURN:      Status
  *
@@ -504,14 +498,14 @@ acpi_status
 acpi_rs_fixed_memory32_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed)
+       ACPI_SIZE               *bytes_consumed)
 {
        u8                      *buffer = *output_buffer;
        u16                     temp16 = 0;
        u8                      temp8 = 0;
 
 
-       FUNCTION_TRACE ("Rs_fixed_memory32_stream");
+       ACPI_FUNCTION_TRACE ("Rs_fixed_memory32_stream");
 
 
        /*
@@ -525,7 +519,7 @@ acpi_rs_fixed_memory32_stream (
         */
        temp16 = 0x09;
 
-       MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
+       ACPI_MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
        buffer += 2;
 
        /*
@@ -538,21 +532,21 @@ acpi_rs_fixed_memory32_stream (
        /*
         * Set the Range base address
         */
-       MOVE_UNALIGNED32_TO_32 (buffer,
+       ACPI_MOVE_UNALIGNED32_TO_32 (buffer,
                         &linked_list->data.fixed_memory32.range_base_address);
        buffer += 4;
 
        /*
         * Set the range length
         */
-       MOVE_UNALIGNED32_TO_32 (buffer,
+       ACPI_MOVE_UNALIGNED32_TO_32 (buffer,
                         &linked_list->data.fixed_memory32.range_length);
        buffer += 4;
 
        /*
         * Return the number of bytes consumed in this operation
         */
-       *bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+       *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
        return_ACPI_STATUS (AE_OK);
 }
 
index d15457604f89313b12b071b14a866effeafe19ae..c253d41a322b66609d1d1b843d5b2d0953b173b4 100644 (file)
@@ -1,12 +1,12 @@
 /*******************************************************************************
  *
  * Module Name: rsmisc - Miscellaneous resource descriptors
- *              $Revision: 16 $
+ *              $Revision: 20 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -28,7 +28,7 @@
 #include "acresrc.h"
 
 #define _COMPONENT          ACPI_RESOURCES
-        MODULE_NAME         ("rsmisc")
+        ACPI_MODULE_NAME    ("rsmisc")
 
 
 /*******************************************************************************
  *
  * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              Bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the Byte_stream_buffer is
+ *                                        returned
+ *              Output_buffer           - Pointer to the return data buffer
+ *              Structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
 acpi_status
 acpi_rs_end_tag_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size)
+       ACPI_SIZE               *structure_size)
 {
        acpi_resource           *output_struct = (acpi_resource *) *output_buffer;
-       u32                     struct_size = ACPI_RESOURCE_LENGTH;
+       ACPI_SIZE               struct_size = ACPI_RESOURCE_LENGTH;
 
 
-       FUNCTION_TRACE ("Rs_end_tag_resource");
+       ACPI_FUNCTION_TRACE ("Rs_end_tag_resource");
 
 
        /*
@@ -96,9 +95,8 @@ acpi_rs_end_tag_resource (
  *
  * PARAMETERS:  Linked_list             - Pointer to the resource linked list
  *              Output_buffer           - Pointer to the user's return buffer
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes of the
- *                                        Output_buffer used
+ *              Bytes_consumed          - Pointer to where the number of bytes
+ *                                        used in the Output_buffer is returned
  *
  * RETURN:      Status
  *
@@ -111,13 +109,13 @@ acpi_status
 acpi_rs_end_tag_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed)
+       ACPI_SIZE               *bytes_consumed)
 {
        u8                      *buffer = *output_buffer;
        u8                      temp8 = 0;
 
 
-       FUNCTION_TRACE ("Rs_end_tag_stream");
+       ACPI_FUNCTION_TRACE ("Rs_end_tag_stream");
 
 
        /*
@@ -138,7 +136,7 @@ acpi_rs_end_tag_stream (
        /*
         * Return the number of bytes consumed in this operation
         */
-       *bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+       *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
        return_ACPI_STATUS (AE_OK);
 }
 
@@ -149,13 +147,12 @@ acpi_rs_end_tag_stream (
  *
  * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              Bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the Byte_stream_buffer is
+ *                                        returned
+ *              Output_buffer           - Pointer to the return data buffer
+ *              Structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
@@ -168,19 +165,19 @@ acpi_rs_end_tag_stream (
 acpi_status
 acpi_rs_vendor_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size)
+       ACPI_SIZE               *structure_size)
 {
        u8                      *buffer = byte_stream_buffer;
        acpi_resource           *output_struct = (acpi_resource *) *output_buffer;
        u16                     temp16 = 0;
        u8                      temp8 = 0;
        u8                      index;
-       u32                     struct_size = SIZEOF_RESOURCE (acpi_resource_vendor);
+       ACPI_SIZE               struct_size = ACPI_SIZEOF_RESOURCE (acpi_resource_vendor);
 
 
-       FUNCTION_TRACE ("Rs_vendor_resource");
+       ACPI_FUNCTION_TRACE ("Rs_vendor_resource");
 
 
        /*
@@ -190,14 +187,13 @@ acpi_rs_vendor_resource (
 
        if (temp8 & 0x80) {
                /*
-                * Large Item
-                * Point to the length field
+                * Large Item, point to the length field
                 */
                buffer += 1;
 
                /* Dereference */
 
-               MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
+               ACPI_MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
 
                /* Calculate bytes consumed */
 
@@ -207,11 +203,9 @@ acpi_rs_vendor_resource (
 
                buffer += 2;
        }
-
        else {
                /*
-                * Small Item
-                * Dereference the size
+                * Small Item, dereference the size
                 */
                temp16 = (u8)(*buffer & 0x07);
 
@@ -237,7 +231,7 @@ acpi_rs_vendor_resource (
         * calculate the length of the vendor string and expand the
         * Struct_size to the next 32-bit boundary.
         */
-       struct_size += ROUND_UP_TO_32_bITS (temp16);
+       struct_size += ACPI_ROUND_UP_TO_32_bITS (temp16);
 
        /*
         * Set the Length parameter
@@ -258,9 +252,8 @@ acpi_rs_vendor_resource (
  *
  * PARAMETERS:  Linked_list             - Pointer to the resource linked list
  *              Output_buffer           - Pointer to the user's return buffer
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes of the
- *                                        Output_buffer used
+ *              Bytes_consumed          - Pointer to where the number of bytes
+ *                                        used in the Output_buffer is returned
  *
  * RETURN:      Status
  *
@@ -273,7 +266,7 @@ acpi_status
 acpi_rs_vendor_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed)
+       ACPI_SIZE               *bytes_consumed)
 {
        u8                      *buffer = *output_buffer;
        u16                     temp16 = 0;
@@ -281,7 +274,7 @@ acpi_rs_vendor_stream (
        u8                      index;
 
 
-       FUNCTION_TRACE ("Rs_vendor_stream");
+       ACPI_FUNCTION_TRACE ("Rs_vendor_stream");
 
 
        /*
@@ -289,22 +282,19 @@ acpi_rs_vendor_stream (
         */
        if(linked_list->data.vendor_specific.length > 7) {
                /*
-                * Large Item
-                * Set the descriptor field and length bytes
+                * Large Item, Set the descriptor field and length bytes
                 */
                *buffer = 0x84;
                buffer += 1;
 
                temp16 = (u16) linked_list->data.vendor_specific.length;
 
-               MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
+               ACPI_MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
                buffer += 2;
        }
-
        else {
                /*
-                * Small Item
-                * Set the descriptor field
+                * Small Item, Set the descriptor field
                 */
                temp8 = 0x70;
                temp8 |= linked_list->data.vendor_specific.length;
@@ -326,24 +316,23 @@ acpi_rs_vendor_stream (
        /*
         * Return the number of bytes consumed in this operation
         */
-       *bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+       *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
        return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_start_dependent_functions_resource
+ * FUNCTION:    Acpi_rs_start_depend_fns_resource
  *
  * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              Bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the Byte_stream_buffer is
+ *                                        returned
+ *              Output_buffer           - Pointer to the return data buffer
+ *              Structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
@@ -354,19 +343,19 @@ acpi_rs_vendor_stream (
  ******************************************************************************/
 
 acpi_status
-acpi_rs_start_dependent_functions_resource (
+acpi_rs_start_depend_fns_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size)
+       ACPI_SIZE               *structure_size)
 {
        u8                      *buffer = byte_stream_buffer;
-       acpi_resource          *output_struct = (acpi_resource *) *output_buffer;
+       acpi_resource           *output_struct = (acpi_resource *) *output_buffer;
        u8                      temp8 = 0;
-       u32                     struct_size = SIZEOF_RESOURCE (acpi_resource_start_dpf);
+       ACPI_SIZE               struct_size = ACPI_SIZEOF_RESOURCE (acpi_resource_start_dpf);
 
 
-       FUNCTION_TRACE ("Rs_start_dependent_functions_resource");
+       ACPI_FUNCTION_TRACE ("Rs_start_depend_fns_resource");
 
 
        /*
@@ -403,13 +392,12 @@ acpi_rs_start_dependent_functions_resource (
                        return_ACPI_STATUS (AE_AML_ERROR);
                }
        }
-
        else {
                output_struct->data.start_dpf.compatibility_priority =
-                               ACCEPTABLE_CONFIGURATION;
+                               ACPI_ACCEPTABLE_CONFIGURATION;
 
                output_struct->data.start_dpf.performance_robustness =
-                               ACCEPTABLE_CONFIGURATION;
+                               ACPI_ACCEPTABLE_CONFIGURATION;
        }
 
        /*
@@ -427,17 +415,16 @@ acpi_rs_start_dependent_functions_resource (
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_end_dependent_functions_resource
+ * FUNCTION:    Acpi_rs_end_depend_fns_resource
  *
  * PARAMETERS:  Byte_stream_buffer      - Pointer to the resource input byte
  *                                        stream
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes consumed from
- *                                        the Byte_stream_buffer
- *              Output_buffer           - Pointer to the user's return buffer
- *              Structure_size          - u32 pointer that is filled with
- *                                        the number of bytes in the filled
- *                                        in structure
+ *              Bytes_consumed          - Pointer to where the number of bytes
+ *                                        consumed the Byte_stream_buffer is
+ *                                        returned
+ *              Output_buffer           - Pointer to the return data buffer
+ *              Structure_size          - Pointer to where the number of bytes
+ *                                        in the return data struct is returned
  *
  * RETURN:      Status
  *
@@ -448,17 +435,17 @@ acpi_rs_start_dependent_functions_resource (
  ******************************************************************************/
 
 acpi_status
-acpi_rs_end_dependent_functions_resource (
+acpi_rs_end_depend_fns_resource (
        u8                      *byte_stream_buffer,
-       u32                     *bytes_consumed,
+       ACPI_SIZE               *bytes_consumed,
        u8                      **output_buffer,
-       u32                     *structure_size)
+       ACPI_SIZE               *structure_size)
 {
        acpi_resource           *output_struct = (acpi_resource *) *output_buffer;
-       u32                     struct_size = ACPI_RESOURCE_LENGTH;
+       ACPI_SIZE               struct_size = ACPI_RESOURCE_LENGTH;
 
 
-       FUNCTION_TRACE ("Rs_end_dependent_functions_resource");
+       ACPI_FUNCTION_TRACE ("Rs_end_depend_fns_resource");
 
 
        /*
@@ -486,7 +473,7 @@ acpi_rs_end_dependent_functions_resource (
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_start_dependent_functions_stream
+ * FUNCTION:    Acpi_rs_start_depend_fns_stream
  *
  * PARAMETERS:  Linked_list             - Pointer to the resource linked list
  *              Output_buffer           - Pointer to the user's return buffer
@@ -502,25 +489,25 @@ acpi_rs_end_dependent_functions_resource (
  ******************************************************************************/
 
 acpi_status
-acpi_rs_start_dependent_functions_stream (
+acpi_rs_start_depend_fns_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed)
+       ACPI_SIZE               *bytes_consumed)
 {
        u8                      *buffer = *output_buffer;
        u8                      temp8 = 0;
 
 
-       FUNCTION_TRACE ("Rs_start_dependent_functions_stream");
+       ACPI_FUNCTION_TRACE ("Rs_start_depend_fns_stream");
 
 
        /*
         * The descriptor field is set based upon whether a byte is needed
         * to contain Priority data.
         */
-       if (ACCEPTABLE_CONFIGURATION ==
+       if (ACPI_ACCEPTABLE_CONFIGURATION ==
                        linked_list->data.start_dpf.compatibility_priority &&
-               ACCEPTABLE_CONFIGURATION ==
+               ACPI_ACCEPTABLE_CONFIGURATION ==
                        linked_list->data.start_dpf.performance_robustness) {
                *buffer = 0x30;
        }
@@ -544,20 +531,19 @@ acpi_rs_start_dependent_functions_stream (
        /*
         * Return the number of bytes consumed in this operation
         */
-       *bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+       *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
        return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_rs_end_dependent_functions_stream
+ * FUNCTION:    Acpi_rs_end_depend_fns_stream
  *
  * PARAMETERS:  Linked_list             - Pointer to the resource linked list
  *              Output_buffer           - Pointer to the user's return buffer
- *              Bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes of the
- *                                        Output_buffer used
+ *              Bytes_consumed          - Pointer to where the number of bytes
+ *                                        used in the Output_buffer is returned
  *
  * RETURN:      Status
  *
@@ -567,16 +553,15 @@ acpi_rs_start_dependent_functions_stream (
  ******************************************************************************/
 
 acpi_status
-acpi_rs_end_dependent_functions_stream (
+acpi_rs_end_depend_fns_stream (
        acpi_resource           *linked_list,
        u8                      **output_buffer,
-       u32                     *bytes_consumed
-       )
+       ACPI_SIZE               *bytes_consumed)
 {
        u8                      *buffer = *output_buffer;
 
 
-       FUNCTION_TRACE ("Rs_end_dependent_functions_stream");
+       ACPI_FUNCTION_TRACE ("Rs_end_depend_fns_stream");
 
 
        /*
@@ -588,7 +573,7 @@ acpi_rs_end_dependent_functions_stream (
        /*
         * Return the number of bytes consumed in this operation
         */
-       *bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
+       *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
        return_ACPI_STATUS (AE_OK);
 }
 
index 777ac38281f0afa53ea5794c7f59f6a3b5ff099a..c02750ae4c8553d0223cc107d537feb78e847e65 100644 (file)
@@ -1,12 +1,12 @@
 /*******************************************************************************
  *
  * Module Name: rsutils - Utilities for the resource manager
- *              $Revision: 23 $
+ *              $Revision: 29 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@
 
 
 #define _COMPONENT          ACPI_RESOURCES
-        MODULE_NAME         ("rsutils")
+        ACPI_MODULE_NAME    ("rsutils")
 
 
 /*******************************************************************************
@@ -58,15 +58,12 @@ acpi_rs_get_prt_method_data (
 {
        acpi_operand_object     *ret_obj;
        acpi_status             status;
-       u32                     buffer_space_needed;
 
 
-       FUNCTION_TRACE ("Rs_get_prt_method_data");
+       ACPI_FUNCTION_TRACE ("Rs_get_prt_method_data");
 
 
-       /* already validated params, so we won't repeat here */
-
-       buffer_space_needed = ret_buffer->length;
+       /* Parameters guaranteed valid by caller */
 
        /*
         *  Execute the method, no parameters
@@ -83,34 +80,25 @@ acpi_rs_get_prt_method_data (
                return_ACPI_STATUS (AE_TYPE);
        }
 
-
        /*
-        * The return object will be a package, so check the
-        *  parameters.  If the return object is not a package,
-        *  then the underlying AML code is corrupt or improperly
-        *  written.
+        * The return object will be a package, so check the parameters.  If the
+        * return object is not a package, then the underlying AML code is corrupt
+        * or improperly written.
         */
        if (ACPI_TYPE_PACKAGE != ret_obj->common.type) {
+               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "_PRT did not return a Package, returned %s\n",
+                               acpi_ut_get_type_name (ret_obj->common.type)));
                status = AE_AML_OPERAND_TYPE;
                goto cleanup;
        }
 
        /*
-        * Make the call to create a resource linked list from the
-        *  byte stream buffer that comes back from the _CRS method
-        *  execution.
-        */
-       status = acpi_rs_create_pci_routing_table (ret_obj, ret_buffer->pointer,
-                         &buffer_space_needed);
-
-       /*
-        * Tell the user how much of the buffer we have used or is needed
-        *  and return the final status.
+        * Create a resource linked list from the byte stream buffer that comes
+        * back from the _CRS method execution.
         */
-       ret_buffer->length = buffer_space_needed;
+       status = acpi_rs_create_pci_routing_table (ret_obj, ret_buffer);
 
-
-       /* On exit, we must delete the object returned by evaluate_object */
+       /* On exit, we must delete the object returned by Evaluate_object */
 
 cleanup:
 
@@ -144,16 +132,15 @@ acpi_rs_get_crs_method_data (
 {
        acpi_operand_object     *ret_obj;
        acpi_status             status;
-       u32                     buffer_space_needed = ret_buffer->length;
 
 
-       FUNCTION_TRACE ("Rs_get_crs_method_data");
+       ACPI_FUNCTION_TRACE ("Rs_get_crs_method_data");
 
 
-       /* already validated params, so we won't repeat here */
+       /* Parameters guaranteed valid by caller */
 
        /*
-        *  Execute the method, no parameters
+        * Execute the method, no parameters
         */
        status = acpi_ns_evaluate_relative (handle, "_CRS", NULL, &ret_obj);
        if (ACPI_FAILURE (status)) {
@@ -169,30 +156,23 @@ acpi_rs_get_crs_method_data (
 
        /*
         * The return object will be a buffer, but check the
-        *  parameters.  If the return object is not a buffer,
-        *  then the underlying AML code is corrupt or improperly
-        *  written.
+        * parameters.  If the return object is not a buffer,
+        * then the underlying AML code is corrupt or improperly
+        * written.
         */
        if (ACPI_TYPE_BUFFER != ret_obj->common.type) {
+               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "_CRS did not return a Buffer, returned %s\n",
+                               acpi_ut_get_type_name (ret_obj->common.type)));
                status = AE_AML_OPERAND_TYPE;
                goto cleanup;
        }
 
        /*
         * Make the call to create a resource linked list from the
-        *  byte stream buffer that comes back from the _CRS method
-        *  execution.
+        * byte stream buffer that comes back from the _CRS method
+        * execution.
         */
-       status = acpi_rs_create_resource_list (ret_obj, ret_buffer->pointer,
-                        &buffer_space_needed);
-
-
-       /*
-        * Tell the user how much of the buffer we have used or is needed
-        *  and return the final status.
-        */
-       ret_buffer->length = buffer_space_needed;
-
+       status = acpi_rs_create_resource_list (ret_obj, ret_buffer);
 
        /* On exit, we must delete the object returned by evaluate_object */
 
@@ -228,16 +208,15 @@ acpi_rs_get_prs_method_data (
 {
        acpi_operand_object     *ret_obj;
        acpi_status             status;
-       u32                     buffer_space_needed = ret_buffer->length;
 
 
-       FUNCTION_TRACE ("Rs_get_prs_method_data");
+       ACPI_FUNCTION_TRACE ("Rs_get_prs_method_data");
 
 
-       /* already validated params, so we won't repeat here */
+       /* Parameters guaranteed valid by caller */
 
        /*
-        *  Execute the method, no parameters
+        * Execute the method, no parameters
         */
        status = acpi_ns_evaluate_relative (handle, "_PRS", NULL, &ret_obj);
        if (ACPI_FAILURE (status)) {
@@ -253,29 +232,23 @@ acpi_rs_get_prs_method_data (
 
        /*
         * The return object will be a buffer, but check the
-        *  parameters.  If the return object is not a buffer,
-        *  then the underlying AML code is corrupt or improperly
-        *  written..
+        * parameters.  If the return object is not a buffer,
+        * then the underlying AML code is corrupt or improperly
+        * written..
         */
        if (ACPI_TYPE_BUFFER != ret_obj->common.type) {
+               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "_PRS did not return a Buffer, returned %s\n",
+                               acpi_ut_get_type_name (ret_obj->common.type)));
                status = AE_AML_OPERAND_TYPE;
                goto cleanup;
        }
 
        /*
         * Make the call to create a resource linked list from the
-        *  byte stream buffer that comes back from the _CRS method
-        *  execution.
-        */
-       status = acpi_rs_create_resource_list (ret_obj, ret_buffer->pointer,
-                        &buffer_space_needed);
-
-       /*
-        * Tell the user how much of the buffer we have used or is needed
-        *  and return the final status.
+        * byte stream buffer that comes back from the _CRS method
+        * execution.
         */
-       ret_buffer->length = buffer_space_needed;
-
+       status = acpi_rs_create_resource_list (ret_obj, ret_buffer);
 
        /* On exit, we must delete the object returned by evaluate_object */
 
@@ -311,50 +284,25 @@ acpi_rs_set_srs_method_data (
 {
        acpi_operand_object     *params[2];
        acpi_status             status;
-       u8                      *byte_stream = NULL;
-       u32                     buffer_size_needed = 0;
+       acpi_buffer             buffer;
 
 
-       FUNCTION_TRACE ("Rs_set_srs_method_data");
+       ACPI_FUNCTION_TRACE ("Rs_set_srs_method_data");
 
 
-       /* already validated params, so we won't repeat here */
+       /* Parameters guaranteed valid by caller */
 
        /*
         * The In_buffer parameter will point to a linked list of
         * resource parameters.  It needs to be formatted into a
-        * byte stream to be sent in as an input parameter.
-        */
-       buffer_size_needed = 0;
-
-       /*
-        * First call is to get the buffer size needed
-        */
-       status = acpi_rs_create_byte_stream (in_buffer->pointer, byte_stream,
-                        &buffer_size_needed);
-       /*
-        * We expect a return of AE_BUFFER_OVERFLOW
-        * if not, exit with the error
+        * byte stream to be sent in as an input parameter to _SRS
+        *
+        * Convert the linked list into a byte stream
         */
-       if (AE_BUFFER_OVERFLOW != status) {
-               return_ACPI_STATUS (status);
-       }
-
-       /*
-        * Allocate the buffer needed
-        */
-       byte_stream = ACPI_MEM_CALLOCATE (buffer_size_needed);
-       if (NULL == byte_stream) {
-               return_ACPI_STATUS (AE_NO_MEMORY);
-       }
-
-       /*
-        * Now call to convert the linked list into a byte stream
-        */
-       status = acpi_rs_create_byte_stream (in_buffer->pointer, byte_stream,
-                        &buffer_size_needed);
+       buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
+       status = acpi_rs_create_byte_stream (in_buffer->pointer, &buffer);
        if (ACPI_FAILURE (status)) {
-               goto cleanup;
+               return_ACPI_STATUS (status);
        }
 
        /*
@@ -362,28 +310,26 @@ acpi_rs_set_srs_method_data (
         */
        params[0] = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER);
        if (!params[0]) {
-               status = AE_NO_MEMORY;
-               goto cleanup;
+               acpi_os_free (buffer.pointer);
+               return_ACPI_STATUS (AE_NO_MEMORY);
        }
-       params [1] = NULL;
 
        /*
-        *  Set up the parameter object
+        * Set up the parameter object
         */
-       params[0]->buffer.length  = buffer_size_needed;
-       params[0]->buffer.pointer = byte_stream;
+       params[0]->buffer.length  = buffer.length;
+       params[0]->buffer.pointer = buffer.pointer;
+       params[1] = NULL;
 
        /*
         * Execute the method, no return value
         */
        status = acpi_ns_evaluate_relative (handle, "_SRS", params, NULL);
-       acpi_ut_remove_reference (params[0]);
 
        /*
         * Clean up and return the status from Acpi_ns_evaluate_relative
         */
-cleanup:
-
+       acpi_ut_remove_reference (params[0]);
        return_ACPI_STATUS (status);
 }
 
index 7235a95373246b1533f6d9d9cc33c11ae93deb3c..16fe573ec00606fb15c0c527657913be64110eb9 100644 (file)
@@ -1,12 +1,12 @@
 /*******************************************************************************
  *
  * Module Name: rsxface - Public interfaces to the resource manager
- *              $Revision: 15 $
+ *              $Revision: 18 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@
 #include "acresrc.h"
 
 #define _COMPONENT          ACPI_RESOURCES
-        MODULE_NAME         ("rsxface")
+        ACPI_MODULE_NAME    ("rsxface")
 
 
 /*******************************************************************************
@@ -64,7 +64,7 @@ acpi_get_irq_routing_table (
        acpi_status             status;
 
 
-       FUNCTION_TRACE ("Acpi_get_irq_routing_table ");
+       ACPI_FUNCTION_TRACE ("Acpi_get_irq_routing_table ");
 
 
        /*
@@ -73,12 +73,15 @@ acpi_get_irq_routing_table (
         * we also need a valid pointer in the buffer. If it's a zero buffer length,
         * we'll be returning the needed buffer size, so keep going.
         */
-       if ((!device_handle)        ||
-               (!ret_buffer)           ||
-               ((!ret_buffer->pointer) && (ret_buffer->length))) {
+       if (!device_handle) {
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
+       status = acpi_ut_validate_buffer (ret_buffer);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
+
        status = acpi_rs_get_prt_method_data (device_handle, ret_buffer);
        return_ACPI_STATUS (status);
 }
@@ -116,7 +119,7 @@ acpi_get_current_resources (
        acpi_status             status;
 
 
-       FUNCTION_TRACE ("Acpi_get_current_resources");
+       ACPI_FUNCTION_TRACE ("Acpi_get_current_resources");
 
 
        /*
@@ -125,12 +128,15 @@ acpi_get_current_resources (
         * we also need a valid pointer in the buffer. If it's a zero buffer length,
         * we'll be returning the needed buffer size, so keep going.
         */
-       if ((!device_handle)        ||
-               (!ret_buffer)           ||
-               ((ret_buffer->length) && (!ret_buffer->pointer))) {
+       if (!device_handle) {
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
+       status = acpi_ut_validate_buffer (ret_buffer);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
+
        status = acpi_rs_get_crs_method_data (device_handle, ret_buffer);
        return_ACPI_STATUS (status);
 }
@@ -165,7 +171,7 @@ acpi_get_possible_resources (
        acpi_status             status;
 
 
-       FUNCTION_TRACE ("Acpi_get_possible_resources");
+       ACPI_FUNCTION_TRACE ("Acpi_get_possible_resources");
 
 
        /*
@@ -174,12 +180,15 @@ acpi_get_possible_resources (
         * we also need a valid pointer in the buffer. If it's a zero buffer length,
         * we'll be returning the needed buffer size, so keep going.
         */
-       if ((!device_handle)        ||
-               (!ret_buffer)           ||
-               ((ret_buffer->length) && (!ret_buffer->pointer))) {
+       if (!device_handle) {
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
+       status = acpi_ut_validate_buffer (ret_buffer);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
+
        status = acpi_rs_get_prs_method_data (device_handle, ret_buffer);
        return_ACPI_STATUS (status);
 }
@@ -211,7 +220,7 @@ acpi_set_current_resources (
        acpi_status             status;
 
 
-       FUNCTION_TRACE ("Acpi_set_current_resources");
+       ACPI_FUNCTION_TRACE ("Acpi_set_current_resources");
 
 
        /*
index 0714c087172adf7cb040934c0602ec8c336b3ccd..d0bbc7655a46e95b304e00deeca0e7cf8e60f997 100644 (file)
@@ -1,11 +1,10 @@
 #
 # Makefile for all Linux ACPI interpreter subdirectories
-# EXCEPT for the ospm directory
 #
 
 O_TARGET := $(notdir $(CURDIR)).o
 
-obj-$(CONFIG_ACPI) := $(patsubst %.c,%.o,$(wildcard *.c))
+obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
 
index 5176436e19aeb72cbcde98837e7c4adc9bcd29c7..e2b284d6487200793b138f2fea9f33bd647a1b12 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: tbconvrt - ACPI Table conversion utilities
- *              $Revision: 28 $
+ *              $Revision: 36 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 
 
 #include "acpi.h"
-#include "achware.h"
 #include "actables.h"
-#include "actbl.h"
 
 
 #define _COMPONENT          ACPI_TABLES
-        MODULE_NAME         ("tbconvrt")
+        ACPI_MODULE_NAME    ("tbconvrt")
 
 
 /*******************************************************************************
@@ -54,7 +52,7 @@ acpi_tb_get_table_count (
        u32                     pointer_size;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
 #ifndef _IA64
@@ -62,7 +60,6 @@ acpi_tb_get_table_count (
        if (RSDP->revision < 2) {
                pointer_size = sizeof (u32);
        }
-
        else
 #endif
        {
@@ -101,17 +98,17 @@ acpi_tb_convert_to_xsdt (
        xsdt_descriptor         *new_table;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
-       *number_of_tables = acpi_tb_get_table_count (acpi_gbl_RSDP, table_info->pointer);
+       /* Get the number of tables defined in the RSDT or XSDT */
 
+       *number_of_tables = acpi_tb_get_table_count (acpi_gbl_RSDP, table_info->pointer);
 
        /* Compute size of the converted XSDT */
 
        table_size = (*number_of_tables * sizeof (u64)) + sizeof (acpi_table_header);
 
-
        /* Allocate an XSDT */
 
        new_table = ACPI_MEM_CALLOCATE (table_size);
@@ -121,20 +118,15 @@ acpi_tb_convert_to_xsdt (
 
        /* Copy the header and set the length */
 
-       MEMCPY (new_table, table_info->pointer, sizeof (acpi_table_header));
+       ACPI_MEMCPY (new_table, table_info->pointer, sizeof (acpi_table_header));
        new_table->header.length = table_size;
 
        /* Copy the table pointers */
 
        for (i = 0; i < *number_of_tables; i++) {
                if (acpi_gbl_RSDP->revision < 2) {
-#ifdef _IA64
-                       new_table->table_offset_entry[i] =
-                               ((RSDT_DESCRIPTOR_REV071 *) table_info->pointer)->table_offset_entry[i];
-#else
                        ACPI_STORE_ADDRESS (new_table->table_offset_entry[i],
                                ((RSDT_DESCRIPTOR_REV1 *) table_info->pointer)->table_offset_entry[i]);
-#endif
                }
                else {
                        new_table->table_offset_entry[i] =
@@ -142,12 +134,10 @@ acpi_tb_convert_to_xsdt (
                }
        }
 
-
        /* Delete the original table (either mapped or in a buffer) */
 
        acpi_tb_delete_single_table (table_info);
 
-
        /* Point the table descriptor to the new table */
 
        table_info->pointer     = (acpi_table_header *) new_table;
@@ -163,12 +153,12 @@ acpi_tb_convert_to_xsdt (
  *
  * FUNCTION:    Acpi_tb_convert_table_fadt
  *
- * PARAMETERS:
+ * PARAMETERS:  None
  *
- * RETURN:
+ * RETURN:      Status
  *
  * DESCRIPTION:
- *    Converts BIOS supplied 1.0 and 0.71 ACPI FADT to an intermediate
+ *    Converts a BIOS supplied ACPI 1.0 FADT to an intermediate
  *    ACPI 2.0 FADT. If the BIOS supplied a 2.0 FADT then it is simply
  *    copied to the intermediate FADT.  The ACPI CA software uses this
  *    intermediate FADT. Thus a significant amount of special #ifdef
@@ -180,254 +170,84 @@ acpi_tb_convert_to_xsdt (
 acpi_status
 acpi_tb_convert_table_fadt (void)
 {
-
-#ifdef _IA64
-       fadt_descriptor_rev071 *FADT71;
-       u8                      pm1_address_space;
-       u8                      pm2_address_space;
-       u8                      pm_timer_address_space;
-       u8                      gpe0address_space;
-       u8                      gpe1_address_space;
-#else
        fadt_descriptor_rev1   *FADT1;
-#endif
-
        fadt_descriptor_rev2   *FADT2;
        acpi_table_desc        *table_desc;
 
 
-       FUNCTION_TRACE ("Tb_convert_table_fadt");
-
+       ACPI_FUNCTION_TRACE ("Tb_convert_table_fadt");
 
-       /* Acpi_gbl_FADT is valid */
-       /* Allocate and zero the 2.0 buffer */
 
+       /*
+        * Acpi_gbl_FADT is valid
+        * Allocate and zero the 2.0 FADT buffer
+        */
        FADT2 = ACPI_MEM_CALLOCATE (sizeof (fadt_descriptor_rev2));
        if (FADT2 == NULL) {
                return_ACPI_STATUS (AE_NO_MEMORY);
        }
 
-
-       /* The ACPI FADT revision number is FADT2_REVISION_ID=3 */
-       /* So, if the current table revision is less than 3 it is type 1.0 or 0.71 */
-
+       /*
+        * The ACPI FADT revision number is FADT2_REVISION_ID=3
+        * So, if the current table revision is less than 3 it is type 1.0
+        */
        if (acpi_gbl_FADT->header.revision >= FADT2_REVISION_ID) {
                /* We have an ACPI 2.0 FADT but we must copy it to our local buffer */
 
                *FADT2 = *((fadt_descriptor_rev2*) acpi_gbl_FADT);
-
        }
-
        else {
-
-#ifdef _IA64
-               /*
-                * For the 64-bit case only, a revision ID less than V2.0 means the
-                * tables are the 0.71 extensions
-                */
-
-               /* The BIOS stored FADT should agree with Revision 0.71 */
-
-               FADT71 = (fadt_descriptor_rev071 *) acpi_gbl_FADT;
-
-               /* Copy the table header*/
-
-               FADT2->header       = FADT71->header;
-
-               /* Copy the common fields */
-
-               FADT2->sci_int      = FADT71->sci_int;
-               FADT2->acpi_enable  = FADT71->acpi_enable;
-               FADT2->acpi_disable = FADT71->acpi_disable;
-               FADT2->S4bios_req   = FADT71->S4bios_req;
-               FADT2->plvl2_lat    = FADT71->plvl2_lat;
-               FADT2->plvl3_lat    = FADT71->plvl3_lat;
-               FADT2->day_alrm     = FADT71->day_alrm;
-               FADT2->mon_alrm     = FADT71->mon_alrm;
-               FADT2->century      = FADT71->century;
-               FADT2->gpe1_base    = FADT71->gpe1_base;
-
-               /*
-                * We still use the block length registers even though
-                * the GAS structure should obsolete them.  This is because
-                * these registers are byte lengths versus the GAS which
-                * contains a bit width
-                */
-               FADT2->pm1_evt_len  = FADT71->pm1_evt_len;
-               FADT2->pm1_cnt_len  = FADT71->pm1_cnt_len;
-               FADT2->pm2_cnt_len  = FADT71->pm2_cnt_len;
-               FADT2->pm_tm_len    = FADT71->pm_tm_len;
-               FADT2->gpe0blk_len  = FADT71->gpe0blk_len;
-               FADT2->gpe1_blk_len = FADT71->gpe1_blk_len;
-               FADT2->gpe1_base    = FADT71->gpe1_base;
-
-               /* Copy the existing 0.71 flags to 2.0. The other bits are zero.*/
-
-               FADT2->wb_invd      = FADT71->flush_cash;
-               FADT2->proc_c1      = FADT71->proc_c1;
-               FADT2->plvl2_up     = FADT71->plvl2_up;
-               FADT2->pwr_button   = FADT71->pwr_button;
-               FADT2->sleep_button = FADT71->sleep_button;
-               FADT2->fixed_rTC    = FADT71->fixed_rTC;
-               FADT2->rtcs4        = FADT71->rtcs4;
-               FADT2->tmr_val_ext  = FADT71->tmr_val_ext;
-               FADT2->dock_cap     = FADT71->dock_cap;
-
-
-               /* We should not use these next two addresses */
-               /* Since our buffer is pre-zeroed nothing to do for */
-               /* the next three data items in the structure */
-               /* FADT2->Firmware_ctrl = 0; */
-               /* FADT2->Dsdt = 0; */
-
-               /* System Interrupt Model isn't used in ACPI 2.0*/
-               /* FADT2->Reserved1 = 0; */
-
-               /* This field is set by the OEM to convey the preferred */
-               /* power management profile to OSPM. It doesn't have any*/
-               /* 0.71 equivalence.  Since we don't know what kind of  */
-               /* 64-bit system this is, we will pick unspecified.     */
-
-               FADT2->prefer_PM_profile = PM_UNSPECIFIED;
-
-
-               /* Port address of SMI command port */
-               /* We shouldn't use this port because IA64 doesn't */
-               /* have or use SMI.  It has PMI. */
-
-               FADT2->smi_cmd      = (u32)(FADT71->smi_cmd & 0xFFFFFFFF);
-
-
-               /* processor performance state control*/
-               /* The value OSPM writes to the SMI_CMD register to assume */
-               /* processor performance state control responsibility. */
-               /* There isn't any equivalence in 0.71 */
-               /* Again this should be meaningless for IA64 */
-               /* FADT2->Pstate_cnt = 0; */
-
-               /* The 32-bit Power management and GPE registers are */
-               /* not valid in IA-64 and we are not going to use them */
-               /* so leaving them pre-zeroed. */
-
-               /* Support for the _CST object and C States change notification.*/
-               /* This data item hasn't any 0.71 equivalence so leaving it zero.*/
-               /* FADT2->Cst_cnt = 0; */
-
-               /* number of flush strides that need to be read */
-               /* No 0.71 equivalence. Leave pre-zeroed. */
-               /* FADT2->Flush_size = 0; */
-
-               /* Processor's memory cache line width, in bytes */
-               /* No 0.71 equivalence. Leave pre-zeroed. */
-               /* FADT2->Flush_stride = 0; */
-
-               /* Processor's duty cycle index in processor's P_CNT reg*/
-               /* No 0.71 equivalence. Leave pre-zeroed. */
-               /* FADT2->Duty_offset = 0; */
-
-               /* Processor's duty cycle value bit width in P_CNT register.*/
-               /* No 0.71 equivalence. Leave pre-zeroed. */
-               /* FADT2->Duty_width = 0; */
-
-
-               /* Since there isn't any equivalence in 0.71 */
-               /* and since Big_sur had to support legacy */
-
-               FADT2->iapc_boot_arch = BAF_LEGACY_DEVICES;
-
-               /* Copy to ACPI 2.0 64-BIT Extended Addresses */
-
-               FADT2->Xfirmware_ctrl = FADT71->firmware_ctrl;
-               FADT2->Xdsdt         = FADT71->dsdt;
-
-
-               /* Extract the address space IDs */
-
-               pm1_address_space   = (u8)((FADT71->address_space & PM1_BLK_ADDRESS_SPACE)    >> 1);
-               pm2_address_space   = (u8)((FADT71->address_space & PM2_CNT_BLK_ADDRESS_SPACE) >> 2);
-               pm_timer_address_space = (u8)((FADT71->address_space & PM_TMR_BLK_ADDRESS_SPACE) >> 3);
-               gpe0address_space   = (u8)((FADT71->address_space & GPE0_BLK_ADDRESS_SPACE)   >> 4);
-               gpe1_address_space  = (u8)((FADT71->address_space & GPE1_BLK_ADDRESS_SPACE)   >> 5);
-
-               /*
-                * Convert the 0.71 (non-GAS style) Block addresses to V2.0 GAS structures,
-                * in this order:
-                *
-                * PM 1_a Events
-                * PM 1_b Events
-                * PM 1_a Control
-                * PM 1_b Control
-                * PM 2 Control
-                * PM Timer Control
-                * GPE Block 0
-                * GPE Block 1
-                */
-
-               ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm1a_evt_blk, FADT71->pm1_evt_len, FADT71->pm1a_evt_blk, pm1_address_space);
-               ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm1b_evt_blk, FADT71->pm1_evt_len, FADT71->pm1b_evt_blk, pm1_address_space);
-               ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm1a_cnt_blk, FADT71->pm1_cnt_len, FADT71->pm1a_cnt_blk, pm1_address_space);
-               ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm1b_cnt_blk, FADT71->pm1_cnt_len, FADT71->pm1b_cnt_blk, pm1_address_space);
-               ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm2_cnt_blk, FADT71->pm2_cnt_len, FADT71->pm2_cnt_blk, pm2_address_space);
-               ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm_tmr_blk, FADT71->pm_tm_len,  FADT71->pm_tmr_blk, pm_timer_address_space);
-               ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xgpe0blk,    FADT71->gpe0blk_len, FADT71->gpe0blk,   gpe0address_space);
-               ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xgpe1_blk,   FADT71->gpe1_blk_len, FADT71->gpe1_blk, gpe1_address_space);
-
-#else
-
                /* ACPI 1.0 FACS */
 
-
                /* The BIOS stored FADT should agree with Revision 1.0 */
 
                FADT1 = (fadt_descriptor_rev1*) acpi_gbl_FADT;
 
                /*
-                * Copy the table header and the common part of the tables
-                * The 2.0 table is an extension of the 1.0 table, so the
-                * entire 1.0 table can be copied first, then expand some
-                * fields to 64 bits.
+                * Copy the table header and the common part of the tables.
+                *
+                * The 2.0 table is an extension of the 1.0 table, so the entire 1.0
+                * table can be copied first, then expand some fields to 64 bits.
                 */
-               MEMCPY (FADT2, FADT1, sizeof (fadt_descriptor_rev1));
-
+               ACPI_MEMCPY (FADT2, FADT1, sizeof (fadt_descriptor_rev1));
 
                /* Convert table pointers to 64-bit fields */
 
                ACPI_STORE_ADDRESS (FADT2->Xfirmware_ctrl, FADT1->firmware_ctrl);
                ACPI_STORE_ADDRESS (FADT2->Xdsdt, FADT1->dsdt);
 
-               /* System Interrupt Model isn't used in ACPI 2.0*/
-               /* FADT2->Reserved1 = 0; */
-
-               /* This field is set by the OEM to convey the preferred */
-               /* power management profile to OSPM. It doesn't have any*/
-               /* 1.0 equivalence.  Since we don't know what kind of   */
-               /* 32-bit system this is, we will pick unspecified.     */
+               /*
+                * System Interrupt Model isn't used in ACPI 2.0 (FADT2->Reserved1 = 0;)
+                */
 
+               /*
+                * This field is set by the OEM to convey the preferred power management
+                * profile to OSPM. It doesn't have any 1.0 equivalence.  Since we don't
+                * know what kind of 32-bit system this is, we will use "unspecified".
+                */
                FADT2->prefer_PM_profile = PM_UNSPECIFIED;
 
-
-               /* Processor Performance State Control. This is the value  */
-               /* OSPM writes to the SMI_CMD register to assume processor */
-               /* performance state control responsibility. There isn't   */
-               /* any equivalence in 1.0.  So leave it zeroed.            */
-
+               /*
+                * Processor Performance State Control. This is the value OSPM writes to
+                * the SMI_CMD register to assume processor performance state control
+                * responsibility. There isn't any equivalence in 1.0, leave it zeroed.
+                */
                FADT2->pstate_cnt = 0;
 
-
-               /* Support for the _CST object and C States change notification.*/
-               /* This data item hasn't any 1.0 equivalence so leaving it zero.*/
-
+               /*
+                * Support for the _CST object and C States change notification.
+                * This data item hasn't any 1.0 equivalence so leave it zero.
+                */
                FADT2->cst_cnt = 0;
 
-
-               /* Since there isn't any equivalence in 1.0 and since it   */
-               /* is highly likely that a 1.0 system has legacy  support. */
-
+               /*
+                * Since there isn't any equivalence in 1.0 and since it highly likely
+                * that a 1.0 system has legacy support.
+                */
                FADT2->iapc_boot_arch = BAF_LEGACY_DEVICES;
 
-
                /*
-                * Convert the V1.0 Block addresses to V2.0 GAS structures
+                * Convert the V1.0 block addresses to V2.0 GAS structures
                 * in this order:
                 *
                 * PM 1_a Events
@@ -439,32 +259,27 @@ acpi_tb_convert_table_fadt (void)
                 * GPE Block 0
                 * GPE Block 1
                 */
-
                ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm1a_evt_blk, FADT1->pm1_evt_len, FADT1->pm1a_evt_blk);
                ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm1b_evt_blk, FADT1->pm1_evt_len, FADT1->pm1b_evt_blk);
                ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm1a_cnt_blk, FADT1->pm1_cnt_len, FADT1->pm1a_cnt_blk);
                ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm1b_cnt_blk, FADT1->pm1_cnt_len, FADT1->pm1b_cnt_blk);
                ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm2_cnt_blk, FADT1->pm2_cnt_len, FADT1->pm2_cnt_blk);
                ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm_tmr_blk, FADT1->pm_tm_len,  FADT1->pm_tmr_blk);
-               ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xgpe0blk,    FADT1->gpe0blk_len, FADT1->gpe0blk);
+               ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xgpe0_blk,   FADT1->gpe0_blk_len, FADT1->gpe0_blk);
                ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xgpe1_blk,   FADT1->gpe1_blk_len, FADT1->gpe1_blk);
-#endif
        }
 
-
        /*
         * Global FADT pointer will point to the common V2.0 FADT
         */
        acpi_gbl_FADT = FADT2;
        acpi_gbl_FADT->header.length = sizeof (FADT_DESCRIPTOR);
 
-
        /* Free the original table */
 
        table_desc = &acpi_gbl_acpi_tables[ACPI_TABLE_FADT];
        acpi_tb_delete_single_table (table_desc);
 
-
        /* Install the new table */
 
        table_desc->pointer = (acpi_table_header *) acpi_gbl_FADT;
@@ -472,14 +287,12 @@ acpi_tb_convert_table_fadt (void)
        table_desc->allocation = ACPI_MEM_ALLOCATED;
        table_desc->length = sizeof (fadt_descriptor_rev2);
 
-
        /* Dump the entire FADT */
 
        ACPI_DEBUG_PRINT ((ACPI_DB_TABLES,
                "Hex dump of common internal FADT, size %d (%X)\n",
                acpi_gbl_FADT->header.length, acpi_gbl_FADT->header.length));
-       DUMP_BUFFER ((u8 *) (acpi_gbl_FADT), acpi_gbl_FADT->header.length);
-
+       ACPI_DUMP_BUFFER ((u8 *) (acpi_gbl_FADT), acpi_gbl_FADT->header.length);
 
        return_ACPI_STATUS (AE_OK);
 }
@@ -489,11 +302,12 @@ acpi_tb_convert_table_fadt (void)
  *
  * FUNCTION:    Acpi_tb_convert_table_facs
  *
- * PARAMETERS:
+ * PARAMETERS:  Table_info      - Info for currently installad FACS
  *
- * RETURN:
+ * RETURN:      Status
  *
- * DESCRIPTION:
+ * DESCRIPTION: Convert ACPI 1.0 and ACPI 2.0 FACS to a common internal
+ *              table format.
  *
  ******************************************************************************/
 
@@ -501,67 +315,34 @@ acpi_status
 acpi_tb_build_common_facs (
        acpi_table_desc         *table_info)
 {
-       acpi_common_facs        *common_facs;
-
-#ifdef _IA64
-       facs_descriptor_rev071  *FACS71;
-#else
        facs_descriptor_rev1    *FACS1;
-#endif
-
        facs_descriptor_rev2    *FACS2;
 
 
-       FUNCTION_TRACE ("Tb_build_common_facs");
-
-
-       /* Allocate a common FACS */
-
-       common_facs = ACPI_MEM_CALLOCATE (sizeof (acpi_common_facs));
-       if (!common_facs) {
-               return_ACPI_STATUS (AE_NO_MEMORY);
-       }
+       ACPI_FUNCTION_TRACE ("Tb_build_common_facs");
 
 
        /* Copy fields to the new FACS */
 
        if (acpi_gbl_RSDP->revision < 2) {
-#ifdef _IA64
-               /* 0.71 FACS */
-
-               FACS71 = (facs_descriptor_rev071 *) acpi_gbl_FACS;
-
-               common_facs->global_lock = (u32 *) &(FACS71->global_lock);
-               common_facs->firmware_waking_vector = &FACS71->firmware_waking_vector;
-               common_facs->vector_width = 64;
-#else
                /* ACPI 1.0 FACS */
 
                FACS1 = (facs_descriptor_rev1 *) acpi_gbl_FACS;
 
-               common_facs->global_lock = &(FACS1->global_lock);
-               common_facs->firmware_waking_vector = (u64 *) &FACS1->firmware_waking_vector;
-               common_facs->vector_width = 32;
-
-#endif
+               acpi_gbl_common_fACS.global_lock = &(FACS1->global_lock);
+               acpi_gbl_common_fACS.firmware_waking_vector = (u64 *) &FACS1->firmware_waking_vector;
+               acpi_gbl_common_fACS.vector_width = 32;
        }
-
        else {
                /* ACPI 2.0 FACS */
 
                FACS2 = (facs_descriptor_rev2 *) acpi_gbl_FACS;
 
-               common_facs->global_lock = &(FACS2->global_lock);
-               common_facs->firmware_waking_vector = &FACS2->Xfirmware_waking_vector;
-               common_facs->vector_width = 64;
+               acpi_gbl_common_fACS.global_lock = &(FACS2->global_lock);
+               acpi_gbl_common_fACS.firmware_waking_vector = &FACS2->Xfirmware_waking_vector;
+               acpi_gbl_common_fACS.vector_width = 64;
        }
 
-
-       /* Set the global FACS pointer to point to the common FACS */
-
-
-       acpi_gbl_FACS = common_facs;
-
        return_ACPI_STATUS  (AE_OK);
 }
 
index 02608cad32219d5e037973901d801e1908ca0701..6f03a3b0b587be9bc69af6612bd415bdd830ad73 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: tbget - ACPI Table get* routines
- *              $Revision: 56 $
+ *              $Revision: 63 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 
 
 #include "acpi.h"
-#include "achware.h"
 #include "actables.h"
 
 
 #define _COMPONENT          ACPI_TABLES
-        MODULE_NAME         ("tbget")
-
-#define RSDP_CHECKSUM_LENGTH 20
+        ACPI_MODULE_NAME    ("tbget")
 
 
 /*******************************************************************************
@@ -60,7 +57,7 @@ acpi_tb_get_table_ptr (
        u32                     i;
 
 
-       FUNCTION_TRACE ("Tb_get_table_ptr");
+       ACPI_FUNCTION_TRACE ("Tb_get_table_ptr");
 
 
        if (!acpi_gbl_DSDT) {
@@ -71,7 +68,6 @@ acpi_tb_get_table_ptr (
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
-
        /*
         * For all table types (Single/Multiple), the first
         * instance is always in the list head.
@@ -85,7 +81,6 @@ acpi_tb_get_table_ptr (
                return_ACPI_STATUS (AE_OK);
        }
 
-
        /*
         * Check for instance out of range
         */
@@ -141,14 +136,13 @@ acpi_tb_get_table (
        acpi_status             status = AE_OK;
 
 
-       FUNCTION_TRACE ("Tb_get_table");
+       ACPI_FUNCTION_TRACE ("Tb_get_table");
 
 
        if (!table_info) {
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
-
        if (buffer_ptr) {
                /*
                 * Getting data from a buffer, not BIOS tables
@@ -171,14 +165,13 @@ acpi_tb_get_table (
                /* Copy the entire table (including header) to the local buffer */
 
                size = table_header->length;
-               MEMCPY (full_table, buffer_ptr, size);
+               ACPI_MEMCPY (full_table, buffer_ptr, size);
 
                /* Save allocation type */
 
                allocation = ACPI_MEM_ALLOCATED;
        }
 
-
        /*
         * Not reading from a buffer, just map the table's physical memory
         * into our address space.
@@ -196,7 +189,6 @@ acpi_tb_get_table (
                allocation = ACPI_MEM_MAPPED;
        }
 
-
        /* Return values */
 
        table_info->pointer     = full_table;
@@ -232,7 +224,7 @@ acpi_tb_get_all_tables (
        acpi_table_desc         table_info;
 
 
-       FUNCTION_TRACE ("Tb_get_all_tables");
+       ACPI_FUNCTION_TRACE ("Tb_get_all_tables");
 
        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Number of tables: %d\n", number_of_tables));
 
@@ -245,7 +237,7 @@ acpi_tb_get_all_tables (
        for (index = 0; index < number_of_tables; index++) {
                /* Clear the Table_info each time */
 
-               MEMSET (&table_info, 0, sizeof (acpi_table_desc));
+               ACPI_MEMSET (&table_info, 0, sizeof (acpi_table_desc));
 
                /* Get the table via the XSDT */
 
@@ -278,7 +270,6 @@ acpi_tb_get_all_tables (
                }
        }
 
-
        /*
         * Convert the FADT to a common format.  This allows earlier revisions of the
         * table to coexist with newer versions, using common access code.
@@ -288,7 +279,6 @@ acpi_tb_get_all_tables (
                return_ACPI_STATUS (status);
        }
 
-
        /*
         * Get the minimum set of ACPI tables, namely:
         *
@@ -323,7 +313,6 @@ acpi_tb_get_all_tables (
                return_ACPI_STATUS (status);
        }
 
-
        /*
         * Get the DSDT (We know that the FADT is valid now)
         */
@@ -343,26 +332,18 @@ acpi_tb_get_all_tables (
        /* Dump the DSDT Header */
 
        ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Hex dump of DSDT Header:\n"));
-       DUMP_BUFFER ((u8 *) acpi_gbl_DSDT, sizeof (acpi_table_header));
+       ACPI_DUMP_BUFFER ((u8 *) acpi_gbl_DSDT, sizeof (acpi_table_header));
 
        /* Dump the entire DSDT */
 
        ACPI_DEBUG_PRINT ((ACPI_DB_TABLES,
                "Hex dump of DSDT (After header), size %d (%x)\n",
                acpi_gbl_DSDT->length, acpi_gbl_DSDT->length));
-       DUMP_BUFFER ((u8 *) (acpi_gbl_DSDT + 1), acpi_gbl_DSDT->length);
-
-       /*
-        * Initialize the capabilities flags.
-        * Assumes that platform supports ACPI_MODE since we have tables!
-        */
-       acpi_gbl_system_flags |= acpi_hw_get_mode_capabilities ();
-
+       ACPI_DUMP_BUFFER ((u8 *) (acpi_gbl_DSDT + 1), acpi_gbl_DSDT->length);
 
        /* Always delete the RSDP mapping, we are done with it */
 
        acpi_tb_delete_acpi_table (ACPI_TABLE_RSDP);
-
        return_ACPI_STATUS (status);
 }
 
@@ -385,17 +366,17 @@ acpi_tb_verify_rsdp (
 {
        acpi_table_desc         table_info;
        acpi_status             status;
-       u8                      *table_ptr;
+       RSDP_DESCRIPTOR         *rsdp;
 
 
-       FUNCTION_TRACE ("Tb_verify_rsdp");
+       ACPI_FUNCTION_TRACE ("Tb_verify_rsdp");
 
 
        /*
         * Obtain access to the RSDP structure
         */
        status = acpi_os_map_memory (rsdp_physical_address, sizeof (RSDP_DESCRIPTOR),
-                         (void **) &table_ptr);
+                         (void **) &rsdp);
        if (ACPI_FAILURE (status)) {
                return_ACPI_STATUS (status);
        }
@@ -403,28 +384,36 @@ acpi_tb_verify_rsdp (
        /*
         *  The signature and checksum must both be correct
         */
-       if (STRNCMP ((NATIVE_CHAR *) table_ptr, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) {
+       if (ACPI_STRNCMP ((NATIVE_CHAR *) rsdp, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) {
                /* Nope, BAD Signature */
 
                status = AE_BAD_SIGNATURE;
                goto cleanup;
        }
 
-       if (acpi_tb_checksum (table_ptr, RSDP_CHECKSUM_LENGTH) != 0) {
-               /* Nope, BAD Checksum */
+       /* Check the standard checksum */
 
+       if (acpi_tb_checksum (rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) {
                status = AE_BAD_CHECKSUM;
                goto cleanup;
        }
 
-       /* TBD: Check extended checksum if table version >= 2 */
+       /* Check extended checksum if table version >= 2 */
+
+       if (rsdp->revision >= 2) {
+               if (acpi_tb_checksum (rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0) {
+                       status = AE_BAD_CHECKSUM;
+                       goto cleanup;
+               }
+       }
+
 
        /* The RSDP supplied is OK */
 
-       table_info.pointer     = (acpi_table_header *) table_ptr;
+       table_info.pointer     = (acpi_table_header *) rsdp;
        table_info.length      = sizeof (RSDP_DESCRIPTOR);
        table_info.allocation  = ACPI_MEM_MAPPED;
-       table_info.base_pointer = table_ptr;
+       table_info.base_pointer = rsdp;
 
        /* Save the table pointers and allocation info */
 
@@ -433,7 +422,6 @@ acpi_tb_verify_rsdp (
                goto cleanup;
        }
 
-
        /* Save the RSDP in a global for easy access */
 
        acpi_gbl_RSDP = (RSDP_DESCRIPTOR *) table_info.pointer;
@@ -443,7 +431,7 @@ acpi_tb_verify_rsdp (
        /* Error exit */
 cleanup:
 
-       acpi_os_unmap_memory (table_ptr, sizeof (RSDP_DESCRIPTOR));
+       acpi_os_unmap_memory (rsdp, sizeof (RSDP_DESCRIPTOR));
        return_ACPI_STATUS (status);
 }
 
@@ -467,7 +455,7 @@ acpi_tb_get_rsdt_address (void)
        ACPI_PHYSICAL_ADDRESS   physical_address;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        /*
@@ -475,14 +463,8 @@ acpi_tb_get_rsdt_address (void)
         * For RSDP revision 2 (and above), we use the XSDT
         */
        if (acpi_gbl_RSDP->revision < 2) {
-#ifdef _IA64
-               /* 0.71 RSDP has 64bit Rsdt address field */
-               physical_address = ((RSDP_DESCRIPTOR_REV071 *)acpi_gbl_RSDP)->rsdt_physical_address;
-#else
                physical_address = (ACPI_PHYSICAL_ADDRESS) acpi_gbl_RSDP->rsdt_physical_address;
-#endif
        }
-
        else {
                physical_address = (ACPI_PHYSICAL_ADDRESS)
                                   ACPI_GET_ADDRESS (acpi_gbl_RSDP->xsdt_physical_address);
@@ -511,29 +493,28 @@ acpi_tb_validate_rsdt (
        u32                     no_match;
 
 
-       PROC_NAME ("Tb_validate_rsdt");
+       ACPI_FUNCTION_NAME ("Tb_validate_rsdt");
 
 
        /*
         * For RSDP revision 0 or 1, we use the RSDT.
-        * For RSDP revision 2 (and above), we use the XSDT
+        * For RSDP revision 2 and above, we use the XSDT
         */
        if (acpi_gbl_RSDP->revision < 2) {
-               no_match = STRNCMP ((char *) table_ptr, RSDT_SIG,
+               no_match = ACPI_STRNCMP ((char *) table_ptr, RSDT_SIG,
                                  sizeof (RSDT_SIG) -1);
        }
        else {
-               no_match = STRNCMP ((char *) table_ptr, XSDT_SIG,
+               no_match = ACPI_STRNCMP ((char *) table_ptr, XSDT_SIG,
                                  sizeof (XSDT_SIG) -1);
        }
 
-
        if (no_match) {
                /* Invalid RSDT or XSDT signature */
 
-               REPORT_ERROR (("Invalid signature where RSDP indicates RSDT/XSDT should be located\n"));
+               ACPI_REPORT_ERROR (("Invalid signature where RSDP indicates RSDT/XSDT should be located\n"));
 
-               DUMP_BUFFER (acpi_gbl_RSDP, 20);
+               ACPI_DUMP_BUFFER (acpi_gbl_RSDP, 20);
 
                ACPI_DEBUG_PRINT_RAW ((ACPI_DB_ERROR,
                        "RSDT/XSDT signature at %X is invalid\n",
@@ -570,18 +551,16 @@ acpi_tb_get_table_pointer (
        acpi_status             status;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) {
                *size = SIZE_IN_HEADER;
                status = acpi_tb_map_acpi_table (physical_address, size, table_ptr);
        }
-
        else {
                *size = 0;
-               *table_ptr = (acpi_table_header *) (ACPI_TBLPTR) physical_address;
-
+               *table_ptr = ACPI_PHYSADDR_TO_PTR (physical_address);
                status = AE_OK;
        }
 
@@ -610,7 +589,7 @@ acpi_tb_get_table_rsdt (
        ACPI_PHYSICAL_ADDRESS   physical_address;
 
 
-       FUNCTION_TRACE ("Tb_get_table_rsdt");
+       ACPI_FUNCTION_TRACE ("Tb_get_table_rsdt");
 
 
        /*
@@ -618,13 +597,12 @@ acpi_tb_get_table_rsdt (
         */
        ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
                "RSDP located at %p, RSDT physical=%8.8X%8.8X \n",
-               acpi_gbl_RSDP, HIDWORD(acpi_gbl_RSDP->rsdt_physical_address),
-               LODWORD(acpi_gbl_RSDP->rsdt_physical_address)));
-
+               acpi_gbl_RSDP,
+               ACPI_HIDWORD (acpi_gbl_RSDP->rsdt_physical_address),
+               ACPI_LODWORD (acpi_gbl_RSDP->rsdt_physical_address)));
 
        physical_address = acpi_tb_get_rsdt_address ();
 
-
        /* Get the RSDT/XSDT */
 
        status = acpi_tb_get_table (physical_address, NULL, &table_info);
@@ -634,7 +612,6 @@ acpi_tb_get_table_rsdt (
                return_ACPI_STATUS (status);
        }
 
-
        /* Check the RSDT or XSDT signature */
 
        status = acpi_tb_validate_rsdt (table_info.pointer);
@@ -642,14 +619,12 @@ acpi_tb_get_table_rsdt (
                return_ACPI_STATUS (status);
        }
 
-
        /*
         * Valid RSDT signature, verify the checksum.  If it fails, just
         * print a warning and ignore it.
         */
        status = acpi_tb_verify_table_checksum (table_info.pointer);
 
-
        /* Convert and/or copy to an XSDT structure */
 
        status = acpi_tb_convert_to_xsdt (&table_info, number_of_tables);
@@ -667,7 +642,6 @@ acpi_tb_get_table_rsdt (
        acpi_gbl_XSDT = (xsdt_descriptor *) table_info.pointer;
 
        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "XSDT located at %p\n", acpi_gbl_XSDT));
-
        return_ACPI_STATUS (status);
 }
 
@@ -700,7 +674,7 @@ acpi_tb_get_table_facs (
        acpi_status             status = AE_OK;
 
 
-       FUNCTION_TRACE ("Tb_get_table_facs");
+       ACPI_FUNCTION_TRACE ("Tb_get_table_facs");
 
 
        /* Must have a valid FADT pointer */
@@ -720,13 +694,12 @@ acpi_tb_get_table_facs (
                        return_ACPI_STATUS (AE_NO_MEMORY);
                }
 
-               MEMCPY (table_ptr, buffer_ptr, size);
+               ACPI_MEMCPY (table_ptr, buffer_ptr, size);
 
                /* Save allocation type */
 
                allocation = ACPI_MEM_ALLOCATED;
        }
-
        else {
                /* Just map the physical memory to our address space */
 
@@ -741,7 +714,6 @@ acpi_tb_get_table_facs (
                allocation = ACPI_MEM_MAPPED;
        }
 
-
        /* Return values */
 
        table_info->pointer     = table_ptr;
index 7b063916da400bcd5dead73e8054657fa31813f7..81b643d3a01f8a4f68e6341f3b0c590fec5df12f 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: tbinstal - ACPI table installation and removal
- *              $Revision: 45 $
+ *              $Revision: 55 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 
 
 #include "acpi.h"
-#include "achware.h"
 #include "actables.h"
 
 
 #define _COMPONENT          ACPI_TABLES
-        MODULE_NAME         ("tbinstal")
+        ACPI_MODULE_NAME    ("tbinstal")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_tb_match_signature
+ *
+ * PARAMETERS:  Signature           - Table signature to match
+ *              Table_info          - Return data
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Compare signature against the list of "ACPI-subsystem-owned"
+ *              tables (DSDT/FADT/SSDT, etc.) Returns the Table_type_iD on match.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_tb_match_signature (
+       NATIVE_CHAR             *signature,
+       acpi_table_desc         *table_info)
+{
+       NATIVE_UINT             i;
+
+
+       ACPI_FUNCTION_TRACE ("Tb_match_signature");
+
+
+       /*
+        * Search for a signature match among the known table types
+        */
+       for (i = 0; i < NUM_ACPI_TABLES; i++) {
+               if (!ACPI_STRNCMP (signature, acpi_gbl_acpi_table_data[i].signature,
+                                  acpi_gbl_acpi_table_data[i].sig_length)) {
+                       /* Found a signature match, return index if requested */
+
+                       if (table_info) {
+                               table_info->type = (u8) i;
+                       }
+
+                       ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Signature match %4.4s\n",
+                               (char *) acpi_gbl_acpi_table_data[i].signature));
+
+                       return_ACPI_STATUS (AE_OK);
+               }
+       }
+
+       return_ACPI_STATUS (AE_TABLE_NOT_SUPPORTED);
+}
 
 
 /*******************************************************************************
@@ -55,7 +102,7 @@ acpi_tb_install_table (
 {
        acpi_status             status;
 
-       FUNCTION_TRACE ("Tb_install_table");
+       ACPI_FUNCTION_TRACE ("Tb_install_table");
 
 
        /*
@@ -69,7 +116,10 @@ acpi_tb_install_table (
 
        /* Lock tables while installing */
 
-       acpi_ut_acquire_mutex (ACPI_MTX_TABLES);
+       status = acpi_ut_acquire_mutex (ACPI_MTX_TABLES);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
 
        /* Install the table into the global data structure */
 
@@ -78,7 +128,7 @@ acpi_tb_install_table (
        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s located at %p\n",
                acpi_gbl_acpi_table_data[table_info->type].name, table_info->pointer));
 
-       acpi_ut_release_mutex (ACPI_MTX_TABLES);
+       (void) acpi_ut_release_mutex (ACPI_MTX_TABLES);
        return_ACPI_STATUS (status);
 }
 
@@ -111,11 +161,9 @@ acpi_tb_recognize_table (
 {
        acpi_table_header       *table_header;
        acpi_status             status;
-       acpi_table_type         table_type = 0;
-       u32                     i;
 
 
-       FUNCTION_TRACE ("Tb_recognize_table");
+       ACPI_FUNCTION_TRACE ("Tb_recognize_table");
 
 
        /* Ensure that we have a valid table pointer */
@@ -126,52 +174,32 @@ acpi_tb_recognize_table (
        }
 
        /*
-        * Search for a signature match among the known table types
-        * Start at index one -> Skip the RSDP
+        * We only "recognize" a limited number of ACPI tables -- namely, the
+        * ones that are used by the subsystem (DSDT, FADT, etc.)
+        *
+        * An AE_NOT_FOUND means that the table was not recognized.
+        * This can be any one of many valid ACPI tables, it just isn't one of
+        * the tables that is consumed by the core subsystem
         */
-       status = AE_SUPPORT;
-       for (i = 1; i < NUM_ACPI_TABLES; i++) {
-               if (!STRNCMP (table_header->signature,
-                                 acpi_gbl_acpi_table_data[i].signature,
-                                 acpi_gbl_acpi_table_data[i].sig_length)) {
-                       /*
-                        * Found a signature match, get the pertinent info from the
-                        * Table_data structure
-                        */
-                       table_type      = i;
-                       status          = acpi_gbl_acpi_table_data[i].status;
-
-                       ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Found %4.4s\n",
-                               (char*)acpi_gbl_acpi_table_data[i].signature));
-                       break;
-               }
-       }
-
-       /* Return the table type and length via the info struct */
-
-       table_info->type    = (u8) table_type;
-       table_info->length  = table_header->length;
+       status = acpi_tb_match_signature (table_header->signature, table_info);
+       if (ACPI_SUCCESS (status)) {
+               /* Return the table type and length via the info struct */
 
+               table_info->length  = table_header->length;
 
-       /*
-        * Validate checksum for _most_ tables,
-        * even the ones whose signature we don't recognize
-        */
-       if (table_type != ACPI_TABLE_FACS) {
-               /* But don't abort if the checksum is wrong */
-               /* TBD: [Future] make this a configuration option? */
-
-               acpi_tb_verify_table_checksum (table_header);
-       }
+               /*
+                * Validate checksum for _most_ tables,
+                * even the ones whose signature we don't recognize
+                */
+               if (table_info->type != ACPI_TABLE_FACS) {
+                       status = acpi_tb_verify_table_checksum (table_header);
+                       if (ACPI_FAILURE (status) &&
+                               (!ACPI_CHECKSUM_ABORT)) {
+                               /* Ignore the error if configuration says so */
 
-       /*
-        * An AE_SUPPORT means that the table was not recognized.
-        * We basically ignore this;  just print a debug message
-        */
-       if (status == AE_SUPPORT) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-                       "Unsupported table %s (Type %X) was found and discarded\n",
-                       acpi_gbl_acpi_table_data[table_type].name, table_type));
+                               status = AE_OK;
+                       }
+               }
        }
 
        return_ACPI_STATUS (status);
@@ -200,7 +228,7 @@ acpi_tb_init_table_descriptor (
        acpi_table_desc         *table_desc;
 
 
-       FUNCTION_TRACE_U32 ("Tb_init_table_descriptor", table_type);
+       ACPI_FUNCTION_TRACE_U32 ("Tb_init_table_descriptor", table_type);
 
        /*
         * Install the table into the global data structure
@@ -208,25 +236,24 @@ acpi_tb_init_table_descriptor (
        list_head   = &acpi_gbl_acpi_tables[table_type];
        table_desc  = list_head;
 
-
        /*
         * Two major types of tables:  1) Only one instance is allowed.  This
         * includes most ACPI tables such as the DSDT.  2) Multiple instances of
         * the table are allowed.  This includes SSDT and PSDTs.
         */
-       if (IS_SINGLE_TABLE (acpi_gbl_acpi_table_data[table_type].flags)) {
+       if (ACPI_IS_SINGLE_TABLE (acpi_gbl_acpi_table_data[table_type].flags)) {
                /*
                 * Only one table allowed, and a table has alread been installed
                 *  at this location, so return an error.
                 */
                if (list_head->pointer) {
-                       return_ACPI_STATUS (AE_EXIST);
+                       return_ACPI_STATUS (AE_ALREADY_EXISTS);
                }
 
                table_desc->count = 1;
+               table_desc->prev = NULL;
+               table_desc->next = NULL;
        }
-
-
        else {
                /*
                 * Multiple tables allowed for this table type, we must link
@@ -253,15 +280,14 @@ acpi_tb_init_table_descriptor (
 
                        list_head->prev = table_desc;
                }
-
                else {
                        table_desc->count = 1;
                }
        }
 
-
        /* Common initialization of the table descriptor */
 
+       table_desc->type                = table_info->type;
        table_desc->pointer             = table_info->pointer;
        table_desc->base_pointer        = table_info->base_pointer;
        table_desc->length              = table_info->length;
@@ -269,7 +295,7 @@ acpi_tb_init_table_descriptor (
        table_desc->aml_start           = (u8 *) (table_desc->pointer + 1),
        table_desc->aml_length          = (u32) (table_desc->length -
                         (u32) sizeof (acpi_table_header));
-       table_desc->table_id            = acpi_ut_allocate_owner_id (OWNER_TYPE_TABLE);
+       table_desc->table_id            = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_TABLE);
        table_desc->loaded_into_namespace = FALSE;
 
        /*
@@ -280,7 +306,6 @@ acpi_tb_init_table_descriptor (
                *(acpi_gbl_acpi_table_data[table_type].global_ptr) = table_info->pointer;
        }
 
-
        /* Return Data */
 
        table_info->table_id        = table_desc->table_id;
@@ -315,7 +340,6 @@ acpi_tb_delete_acpi_tables (void)
        for (type = 0; type < NUM_ACPI_TABLES; type++) {
                acpi_tb_delete_acpi_table (type);
        }
-
 }
 
 
@@ -336,21 +360,22 @@ void
 acpi_tb_delete_acpi_table (
        acpi_table_type             type)
 {
-       FUNCTION_TRACE_U32 ("Tb_delete_acpi_table", type);
+
+       ACPI_FUNCTION_TRACE_U32 ("Tb_delete_acpi_table", type);
 
 
        if (type > ACPI_TABLE_MAX) {
                return_VOID;
        }
 
-
-       acpi_ut_acquire_mutex (ACPI_MTX_TABLES);
+       if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_TABLES))) {
+               return;
+       }
 
        /* Free the table */
 
        acpi_tb_free_acpi_tables_of_type (&acpi_gbl_acpi_tables[type]);
 
-
        /* Clear the appropriate "typed" global table pointer */
 
        switch (type) {
@@ -380,8 +405,7 @@ acpi_tb_delete_acpi_table (
                break;
        }
 
-       acpi_ut_release_mutex (ACPI_MTX_TABLES);
-
+       (void) acpi_ut_release_mutex (ACPI_MTX_TABLES);
        return_VOID;
 }
 
@@ -408,7 +432,7 @@ acpi_tb_free_acpi_tables_of_type (
        u32                     i;
 
 
-       FUNCTION_TRACE_PTR ("Tb_free_acpi_tables_of_type", list_head);
+       ACPI_FUNCTION_TRACE_PTR ("Tb_free_acpi_tables_of_type", list_head);
 
 
        /* Get the head of the list */
@@ -454,17 +478,14 @@ acpi_tb_delete_single_table (
                /* Valid table, determine type of memory allocation */
 
                switch (table_desc->allocation) {
-
                case ACPI_MEM_NOT_ALLOCATED:
                        break;
 
-
                case ACPI_MEM_ALLOCATED:
 
                        ACPI_MEM_FREE (table_desc->base_pointer);
                        break;
 
-
                case ACPI_MEM_MAPPED:
 
                        acpi_os_unmap_memory (table_desc->base_pointer, table_desc->length);
@@ -495,14 +516,13 @@ acpi_tb_uninstall_table (
        acpi_table_desc         *next_desc;
 
 
-       FUNCTION_TRACE_PTR ("Tb_delete_single_table", table_desc);
+       ACPI_FUNCTION_TRACE_PTR ("Tb_delete_single_table", table_desc);
 
 
        if (!table_desc) {
                return_PTR (NULL);
        }
 
-
        /* Unlink the descriptor */
 
        if (table_desc->prev) {
@@ -513,16 +533,13 @@ acpi_tb_uninstall_table (
                table_desc->next->prev = table_desc->prev;
        }
 
-
        /* Free the memory allocated for the table itself */
 
        acpi_tb_delete_single_table (table_desc);
 
-
        /* Free the table descriptor (Don't delete the list head, tho) */
 
        if ((table_desc->prev) == (table_desc->next)) {
-
                next_desc = NULL;
 
                /* Clear the list head */
@@ -530,9 +547,7 @@ acpi_tb_uninstall_table (
                table_desc->pointer  = NULL;
                table_desc->length   = 0;
                table_desc->count    = 0;
-
        }
-
        else {
                /* Free the table descriptor */
 
@@ -540,7 +555,6 @@ acpi_tb_uninstall_table (
                ACPI_MEM_FREE (table_desc);
        }
 
-
        return_PTR (next_desc);
 }
 
index 2b0bd50e7929b7164f1886b42d74a84b51b13a3f..31c69e835f9eeb63ace1b253ca3462c35484a453 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: tbutils - Table manipulation utilities
- *              $Revision: 42 $
+ *              $Revision: 49 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@
 
 
 #define _COMPONENT          ACPI_TABLES
-        MODULE_NAME         ("tbutils")
+        ACPI_MODULE_NAME    ("tbutils")
 
 
 /*******************************************************************************
@@ -55,7 +55,7 @@ acpi_tb_handle_to_object (
        acpi_table_desc         *list_head;
 
 
-       PROC_NAME ("Tb_handle_to_object");
+       ACPI_FUNCTION_NAME ("Tb_handle_to_object");
 
 
        for (i = 0; i < ACPI_TABLE_MAX; i++) {
@@ -77,81 +77,6 @@ acpi_tb_handle_to_object (
 }
 
 
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_tb_system_table_pointer
- *
- * PARAMETERS:  *Where              - Pointer to be examined
- *
- * RETURN:      TRUE if Where is within the AML stream (in one of the ACPI
- *              system tables such as the DSDT or an SSDT.)
- *              FALSE otherwise
- *
- ******************************************************************************/
-
-u8
-acpi_tb_system_table_pointer (
-       void                    *where)
-{
-       u32                     i;
-       acpi_table_desc         *table_desc;
-       acpi_table_header       *table;
-
-
-       /* No function trace, called too often! */
-
-
-       /* Ignore null pointer */
-
-       if (!where) {
-               return (FALSE);
-       }
-
-
-       /* Check for a pointer within the DSDT */
-
-       if ((acpi_gbl_DSDT) &&
-               (IS_IN_ACPI_TABLE (where, acpi_gbl_DSDT))) {
-               return (TRUE);
-       }
-
-
-       /* Check each of the loaded SSDTs (if any)*/
-
-       table_desc = &acpi_gbl_acpi_tables[ACPI_TABLE_SSDT];
-
-       for (i = 0; i < acpi_gbl_acpi_tables[ACPI_TABLE_SSDT].count; i++) {
-               table = table_desc->pointer;
-
-               if (IS_IN_ACPI_TABLE (where, table)) {
-                       return (TRUE);
-               }
-
-               table_desc = table_desc->next;
-       }
-
-
-       /* Check each of the loaded PSDTs (if any)*/
-
-       table_desc = &acpi_gbl_acpi_tables[ACPI_TABLE_PSDT];
-
-       for (i = 0; i < acpi_gbl_acpi_tables[ACPI_TABLE_PSDT].count; i++) {
-               table = table_desc->pointer;
-
-               if (IS_IN_ACPI_TABLE (where, table)) {
-                       return (TRUE);
-               }
-
-               table_desc = table_desc->next;
-       }
-
-
-       /* Pointer does not point into any system table */
-
-       return (FALSE);
-}
-
-
 /*******************************************************************************
  *
  * FUNCTION:    Acpi_tb_validate_table_header
@@ -179,7 +104,7 @@ acpi_tb_validate_table_header (
        acpi_name               signature;
 
 
-       PROC_NAME ("Tb_validate_table_header");
+       ACPI_FUNCTION_NAME ("Tb_validate_table_header");
 
 
        /* Verify that this is a valid address */
@@ -193,14 +118,14 @@ acpi_tb_validate_table_header (
 
        /* Ensure that the signature is 4 ASCII characters */
 
-       MOVE_UNALIGNED32_TO_32 (&signature, &table_header->signature);
+       ACPI_MOVE_UNALIGNED32_TO_32 (&signature, &table_header->signature);
        if (!acpi_ut_valid_acpi_name (signature)) {
                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
                        "Table signature at %p [%p] has invalid characters\n",
                        table_header, &signature));
 
-               REPORT_WARNING (("Invalid table signature %4.4s found\n", (char*)&signature));
-               DUMP_BUFFER (table_header, sizeof (acpi_table_header));
+               ACPI_REPORT_WARNING (("Invalid table signature %4.4s found\n", (char *) &signature));
+               ACPI_DUMP_BUFFER (table_header, sizeof (acpi_table_header));
                return (AE_BAD_SIGNATURE);
        }
 
@@ -210,10 +135,10 @@ acpi_tb_validate_table_header (
        if (table_header->length < sizeof (acpi_table_header)) {
                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
                        "Invalid length in table header %p name %4.4s\n",
-                       table_header, (char*)&signature));
+                       table_header, (char *) &signature));
 
-               REPORT_WARNING (("Invalid table header length found\n"));
-               DUMP_BUFFER (table_header, sizeof (acpi_table_header));
+               ACPI_REPORT_WARNING (("Invalid table header length (0x%X) found\n", table_header->length));
+               ACPI_DUMP_BUFFER (table_header, sizeof (acpi_table_header));
                return (AE_BAD_HEADER);
        }
 
@@ -248,7 +173,7 @@ acpi_tb_map_acpi_table (
        acpi_status             status = AE_OK;
 
 
-       PROC_NAME ("Tb_map_acpi_table");
+       ACPI_FUNCTION_NAME ("Tb_map_acpi_table");
 
 
        /* If size is zero, look at the table header to get the actual size */
@@ -323,7 +248,7 @@ acpi_tb_verify_table_checksum (
        acpi_status             status = AE_OK;
 
 
-       FUNCTION_TRACE ("Tb_verify_table_checksum");
+       ACPI_FUNCTION_TRACE ("Tb_verify_table_checksum");
 
 
        /* Compute the checksum on the table */
@@ -333,8 +258,8 @@ acpi_tb_verify_table_checksum (
        /* Return the appropriate exception */
 
        if (checksum) {
-               REPORT_WARNING (("Invalid checksum (%X) in table %4.4s\n",
-                       checksum, (char*)&table_header->signature));
+               ACPI_REPORT_WARNING (("Invalid checksum (%X) in table %4.4s\n",
+                       checksum, (char *) &table_header->signature));
 
                status = AE_BAD_CHECKSUM;
        }
@@ -362,8 +287,8 @@ acpi_tb_checksum (
        void                    *buffer,
        u32                     length)
 {
-       u8                      *limit;
-       u8                      *rover;
+       const u8                *limit;
+       const u8                *rover;
        u8                      sum = 0;
 
 
index 57b14708447052694eae5a8f2666884e84f98388..01a2c9e068feff3f2615457eda8f6b25bf246b6e 100644 (file)
@@ -2,12 +2,12 @@
  *
  * Module Name: tbxface - Public interfaces to the ACPI subsystem
  *                         ACPI table oriented interfaces
- *              $Revision: 45 $
+ *              $Revision: 51 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -32,7 +32,7 @@
 
 
 #define _COMPONENT          ACPI_TABLES
-        MODULE_NAME         ("tbxface")
+        ACPI_MODULE_NAME    ("tbxface")
 
 
 /*******************************************************************************
@@ -56,7 +56,7 @@ acpi_load_tables (void)
        u32                     number_of_tables = 0;
 
 
-       FUNCTION_TRACE ("Acpi_load_tables");
+       ACPI_FUNCTION_TRACE ("Acpi_load_tables");
 
 
        /* Get the RSDP */
@@ -64,7 +64,7 @@ acpi_load_tables (void)
        status = acpi_os_get_root_pointer (ACPI_LOGICAL_ADDRESSING,
                          &rsdp_physical_address);
        if (ACPI_FAILURE (status)) {
-               REPORT_ERROR (("Acpi_load_tables: Could not get RSDP, %s\n",
+               ACPI_REPORT_ERROR (("Acpi_load_tables: Could not get RSDP, %s\n",
                                  acpi_format_exception (status)));
                goto error_exit;
        }
@@ -73,7 +73,7 @@ acpi_load_tables (void)
 
        status = acpi_tb_verify_rsdp (rsdp_physical_address);
        if (ACPI_FAILURE (status)) {
-               REPORT_ERROR (("Acpi_load_tables: RSDP Failed validation: %s\n",
+               ACPI_REPORT_ERROR (("Acpi_load_tables: RSDP Failed validation: %s\n",
                                  acpi_format_exception (status)));
                goto error_exit;
        }
@@ -82,7 +82,7 @@ acpi_load_tables (void)
 
        status = acpi_tb_get_table_rsdt (&number_of_tables);
        if (ACPI_FAILURE (status)) {
-               REPORT_ERROR (("Acpi_load_tables: Could not load RSDT: %s\n",
+               ACPI_REPORT_ERROR (("Acpi_load_tables: Could not load RSDT: %s\n",
                                  acpi_format_exception (status)));
                goto error_exit;
        }
@@ -91,7 +91,7 @@ acpi_load_tables (void)
 
        status = acpi_tb_get_all_tables (number_of_tables, NULL);
        if (ACPI_FAILURE (status)) {
-               REPORT_ERROR (("Acpi_load_tables: Error getting required tables (DSDT/FADT/FACS): %s\n",
+               ACPI_REPORT_ERROR (("Acpi_load_tables: Error getting required tables (DSDT/FADT/FACS): %s\n",
                                  acpi_format_exception (status)));
                goto error_exit;
        }
@@ -103,7 +103,7 @@ acpi_load_tables (void)
 
        status = acpi_ns_load_namespace ();
        if (ACPI_FAILURE (status)) {
-               REPORT_ERROR (("Acpi_load_tables: Could not load namespace: %s\n",
+               ACPI_REPORT_ERROR (("Acpi_load_tables: Could not load namespace: %s\n",
                                  acpi_format_exception (status)));
                goto error_exit;
        }
@@ -112,7 +112,7 @@ acpi_load_tables (void)
 
 
 error_exit:
-       REPORT_ERROR (("Acpi_load_tables: Could not load tables: %s\n",
+       ACPI_REPORT_ERROR (("Acpi_load_tables: Could not load tables: %s\n",
                          acpi_format_exception (status)));
 
        return_ACPI_STATUS (status);
@@ -143,7 +143,7 @@ acpi_load_table (
        acpi_table_desc         table_info;
 
 
-       FUNCTION_TRACE ("Acpi_load_table");
+       ACPI_FUNCTION_TRACE ("Acpi_load_table");
 
 
        if (!table_ptr) {
@@ -167,16 +167,32 @@ acpi_load_table (
                return_ACPI_STATUS (status);
        }
 
+       /* Convert the table to common format if necessary */
+
+       switch (table_info.type) {
+       case ACPI_TABLE_FADT:
+
+               status = acpi_tb_convert_table_fadt ();
+               break;
+
+       case ACPI_TABLE_FACS:
+
+               status = acpi_tb_build_common_facs (&table_info);
+               break;
+
+       default:
+               /* Load table into namespace if it contains executable AML */
+
+               status = acpi_ns_load_table (table_info.installed_desc, acpi_gbl_root_node);
+               break;
+       }
 
-       status = acpi_ns_load_table (table_info.installed_desc, acpi_gbl_root_node);
        if (ACPI_FAILURE (status)) {
                /* Uninstall table and free the buffer */
 
                acpi_tb_uninstall_table (table_info.installed_desc);
-               return_ACPI_STATUS (status);
        }
 
-
        return_ACPI_STATUS (status);
 }
 
@@ -200,7 +216,7 @@ acpi_unload_table (
        acpi_table_desc         *list_head;
 
 
-       FUNCTION_TRACE ("Acpi_unload_table");
+       ACPI_FUNCTION_TRACE ("Acpi_unload_table");
 
 
        /* Parameter validation */
@@ -263,7 +279,7 @@ acpi_get_table_header (
        acpi_status             status;
 
 
-       FUNCTION_TRACE ("Acpi_get_table_header");
+       ACPI_FUNCTION_TRACE ("Acpi_get_table_header");
 
 
        if ((instance == 0)                 ||
@@ -275,7 +291,7 @@ acpi_get_table_header (
        /* Check the table type and instance */
 
        if ((table_type > ACPI_TABLE_MAX)   ||
-               (IS_SINGLE_TABLE (acpi_gbl_acpi_table_data[table_type].flags) &&
+               (ACPI_IS_SINGLE_TABLE (acpi_gbl_acpi_table_data[table_type].flags) &&
                 instance > 1)) {
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
@@ -298,7 +314,7 @@ acpi_get_table_header (
        /*
         * Copy the header to the caller's buffer
         */
-       MEMCPY ((void *) out_table_header, (void *) tbl_ptr,
+       ACPI_MEMCPY ((void *) out_table_header, (void *) tbl_ptr,
                         sizeof (acpi_table_header));
 
        return_ACPI_STATUS (status);
@@ -336,25 +352,27 @@ acpi_get_table (
 {
        acpi_table_header       *tbl_ptr;
        acpi_status             status;
-       u32                     ret_buf_len;
+       u32                     table_length;
 
 
-       FUNCTION_TRACE ("Acpi_get_table");
+       ACPI_FUNCTION_TRACE ("Acpi_get_table");
 
 
-       /*
-        *  If we have a buffer, we must have a length too
-        */
-       if ((instance == 0)                 ||
-               (!ret_buffer)                   ||
-               ((!ret_buffer->pointer) && (ret_buffer->length))) {
+       /* Parameter validation */
+
+       if (instance == 0) {
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
 
+       status = acpi_ut_validate_buffer (ret_buffer);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
+
        /* Check the table type and instance */
 
        if ((table_type > ACPI_TABLE_MAX)   ||
-               (IS_SINGLE_TABLE (acpi_gbl_acpi_table_data[table_type].flags) &&
+               (ACPI_IS_SINGLE_TABLE (acpi_gbl_acpi_table_data[table_type].flags) &&
                 instance > 1)) {
                return_ACPI_STATUS (AE_BAD_PARAMETER);
        }
@@ -375,31 +393,28 @@ acpi_get_table (
                return_ACPI_STATUS (AE_NOT_EXIST);
        }
 
-       /*
-        * Got a table ptr, assume it's ok and copy it to the user's buffer
-        */
+       /* Get the table length */
+
        if (table_type == ACPI_TABLE_RSDP) {
                /*
                 *  RSD PTR is the only "table" without a header
                 */
-               ret_buf_len = sizeof (RSDP_DESCRIPTOR);
+               table_length = sizeof (RSDP_DESCRIPTOR);
        }
        else {
-               ret_buf_len = tbl_ptr->length;
+               table_length = tbl_ptr->length;
        }
 
-       /*
-        * Verify we have space in the caller's buffer for the table
-        */
-       if (ret_buffer->length < ret_buf_len) {
-               ret_buffer->length = ret_buf_len;
-               return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
-       }
+       /* Validate/Allocate/Clear caller buffer */
 
-       ret_buffer->length = ret_buf_len;
+       status = acpi_ut_initialize_buffer (ret_buffer, table_length);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
 
-       MEMCPY ((void *) ret_buffer->pointer, (void *) tbl_ptr, ret_buf_len);
+       /* Copy the table to the buffer */
 
+       ACPI_MEMCPY ((void *) ret_buffer->pointer, (void *) tbl_ptr, table_length);
        return_ACPI_STATUS (AE_OK);
 }
 
index 7e88adf1a76ba35201f445163308df225bc31ace..71c9d9d964ae87ae6ede259d68e581560a6f18df 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: tbxfroot - Find the root ACPI table (RSDT)
- *              $Revision: 52 $
+ *              $Revision: 58 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 
 
 #include "acpi.h"
-#include "achware.h"
 #include "actables.h"
 
 
 #define _COMPONENT          ACPI_TABLES
-        MODULE_NAME         ("tbxfroot")
-
-#define RSDP_CHECKSUM_LENGTH 20
+        ACPI_MODULE_NAME    ("tbxfroot")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_find_root_pointer
+ * FUNCTION:    Acpi_tb_find_table
  *
- * PARAMETERS:  **Rsdp_physical_address     - Where to place the RSDP address
- *              Flags                       - Logical/Physical addressing
+ * PARAMETERS:  Signature           - String with ACPI table signature
+ *              Oem_id              - String with the table OEM ID
+ *              Oem_table_id        - String with the OEM Table ID.
  *
- * RETURN:      Status, Physical address of the RSDP
+ * RETURN:      Status
  *
- * DESCRIPTION: Find the RSDP
+ * DESCRIPTION: Find an ACPI table (in the RSDT/XSDT) that matches the
+ *              Signature, OEM ID and OEM Table ID.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_find_root_pointer (
-       u32                     flags,
-       ACPI_PHYSICAL_ADDRESS   *rsdp_physical_address)
+acpi_tb_find_table (
+       NATIVE_CHAR             *signature,
+       NATIVE_CHAR             *oem_id,
+       NATIVE_CHAR             *oem_table_id,
+       acpi_table_header       **table_ptr)
 {
-       acpi_table_desc         table_info;
        acpi_status             status;
+       acpi_table_header       *table;
 
 
-       FUNCTION_TRACE ("Acpi_find_root_pointer");
+       ACPI_FUNCTION_TRACE ("Tb_find_table");
 
 
-       /* Get the RSDP */
+       /* Validate string lengths */
 
-       status = acpi_tb_find_rsdp (&table_info, flags);
-       if (ACPI_FAILURE (status)) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "RSDP structure not found\n"));
-               return_ACPI_STATUS (AE_NO_ACPI_TABLES);
+       if ((ACPI_STRLEN (signature)  > 4) ||
+               (ACPI_STRLEN (oem_id)     > 6) ||
+               (ACPI_STRLEN (oem_table_id) > 8)) {
+               return_ACPI_STATUS (AE_AML_STRING_LIMIT);
        }
 
-       *rsdp_physical_address = table_info.physical_address;
-
-       return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_tb_scan_memory_for_rsdp
- *
- * PARAMETERS:  Start_address       - Starting pointer for search
- *              Length              - Maximum length to search
- *
- * RETURN:      Pointer to the RSDP if found, otherwise NULL.
- *
- * DESCRIPTION: Search a block of memory for the RSDP signature
- *
- ******************************************************************************/
-
-u8 *
-acpi_tb_scan_memory_for_rsdp (
-       u8                      *start_address,
-       u32                     length)
-{
-       u32                     offset;
-       u8                      *mem_rover;
-
-
-       FUNCTION_TRACE ("Tb_scan_memory_for_rsdp");
-
-
-       /* Search from given start addr for the requested length  */
-
-       for (offset = 0, mem_rover = start_address;
-                offset < length;
-                offset += RSDP_SCAN_STEP, mem_rover += RSDP_SCAN_STEP) {
-
-               /* The signature and checksum must both be correct */
-
-               if (STRNCMP ((NATIVE_CHAR *) mem_rover,
-                               RSDP_SIG, sizeof (RSDP_SIG)-1) == 0 &&
-                       acpi_tb_checksum (mem_rover, RSDP_CHECKSUM_LENGTH) == 0) {
-                       /* If so, we have found the RSDP */
-
-                       ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-                               "RSDP located at physical address %p\n",mem_rover));
-                       return_PTR (mem_rover);
-               }
-       }
-
-       /* Searched entire block, no RSDP was found */
-
-       ACPI_DEBUG_PRINT ((ACPI_DB_INFO,"Searched entire block, no RSDP was found.\n"));
-
-       return_PTR (NULL);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_tb_find_rsdp
- *
- * PARAMETERS:  *Table_info             - Where the table info is returned
- *              Flags                   - Current memory mode (logical vs.
- *                                        physical addressing)
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Search lower 1_mbyte 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 1_k of the Extended
- *              BIOS Data Area or between E0000 and FFFFF (ACPI 1.0 section
- *              5.2.2; assertion #421).
- *
- ******************************************************************************/
-
-acpi_status
-acpi_tb_find_rsdp (
-       acpi_table_desc         *table_info,
-       u32                     flags)
-{
-       u8                      *table_ptr;
-       u8                      *mem_rover;
-       u64                     phys_addr;
-       acpi_status             status = AE_OK;
-
-
-       FUNCTION_TRACE ("Tb_find_rsdp");
-
-
-       /*
-        * Scan supports either 1) Logical addressing or 2) Physical addressing
-        */
-       if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) {
-               /*
-                * 1) Search EBDA (low memory) paragraphs
-                */
-               status = acpi_os_map_memory (LO_RSDP_WINDOW_BASE, LO_RSDP_WINDOW_SIZE,
-                                 (void **) &table_ptr);
-               if (ACPI_FAILURE (status)) {
-                       return_ACPI_STATUS (status);
-               }
-
-               mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr, LO_RSDP_WINDOW_SIZE);
-               acpi_os_unmap_memory (table_ptr, LO_RSDP_WINDOW_SIZE);
-
-               if (mem_rover) {
-                       /* Found it, return the physical address */
-
-                       phys_addr = LO_RSDP_WINDOW_BASE;
-                       phys_addr += (mem_rover - table_ptr);
-
-                       table_info->physical_address = phys_addr;
-
-                       return_ACPI_STATUS (AE_OK);
-               }
-
-               /*
-                * 2) Search upper memory: 16-byte boundaries in E0000h-F0000h
-                */
-               status = acpi_os_map_memory (HI_RSDP_WINDOW_BASE, HI_RSDP_WINDOW_SIZE,
-                                 (void **) &table_ptr);
-               if (ACPI_FAILURE (status)) {
-                       return_ACPI_STATUS (status);
-               }
-
-               mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr, HI_RSDP_WINDOW_SIZE);
-               acpi_os_unmap_memory (table_ptr, HI_RSDP_WINDOW_SIZE);
-
-               if (mem_rover) {
-                       /* Found it, return the physical address */
+       /* Find the table */
 
-                       phys_addr = HI_RSDP_WINDOW_BASE;
-                       phys_addr += (mem_rover - table_ptr);
-
-                       table_info->physical_address = phys_addr;
-
-                       return_ACPI_STATUS (AE_OK);
-               }
+       status = acpi_get_firmware_table (signature, 1,
+                          ACPI_LOGICAL_ADDRESSING, &table);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
        }
 
+       /* Check Oem_id and Oem_table_id */
 
-       /*
-        * Physical addressing
-        */
-       else {
-               /*
-                * 1) Search EBDA (low memory) paragraphs
-                */
-               mem_rover = acpi_tb_scan_memory_for_rsdp ((u8 *) LO_RSDP_WINDOW_BASE,
-                                 LO_RSDP_WINDOW_SIZE);
-               if (mem_rover) {
-                       /* Found it, return the physical address */
-
-                       table_info->physical_address = (ACPI_TBLPTR) mem_rover;
-                       return_ACPI_STATUS (AE_OK);
-               }
-
-               /*
-                * 2) Search upper memory: 16-byte boundaries in E0000h-F0000h
-                */
-               mem_rover = acpi_tb_scan_memory_for_rsdp ((u8 *) HI_RSDP_WINDOW_BASE,
-                                 HI_RSDP_WINDOW_SIZE);
-               if (mem_rover) {
-                       /* Found it, return the physical address */
-
-                       table_info->physical_address = (ACPI_TBLPTR) mem_rover;
-                       return_ACPI_STATUS (AE_OK);
-               }
+       if ((oem_id[0]     && ACPI_STRCMP (oem_id, table->oem_id)) ||
+               (oem_table_id[0] && ACPI_STRCMP (oem_table_id, table->oem_table_id))) {
+               return_ACPI_STATUS (AE_AML_NAME_NOT_FOUND);
        }
 
-
-       /* RSDP signature was not found */
-
-       return_ACPI_STATUS (AE_NOT_FOUND);
+       *table_ptr = table;
+       return_ACPI_STATUS (AE_OK);
 }
 
 
@@ -287,7 +129,7 @@ acpi_get_firmware_table (
        u32                     j;
 
 
-       FUNCTION_TRACE ("Acpi_get_firmware_table");
+       ACPI_FUNCTION_TRACE ("Acpi_get_firmware_table");
 
 
        /*
@@ -323,20 +165,20 @@ acpi_get_firmware_table (
                        }
                }
                else {
-                       acpi_gbl_RSDP = (void *) (NATIVE_UINT) physical_address;
+                       acpi_gbl_RSDP = ACPI_PHYSADDR_TO_PTR (physical_address);
                }
 
                /*
                 *  The signature and checksum must both be correct
                 */
-               if (STRNCMP ((NATIVE_CHAR *) acpi_gbl_RSDP, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) {
+               if (ACPI_STRNCMP ((NATIVE_CHAR *) acpi_gbl_RSDP, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) {
                        /* Nope, BAD Signature */
 
                        status = AE_BAD_SIGNATURE;
                        goto cleanup;
                }
 
-               if (acpi_tb_checksum (acpi_gbl_RSDP, RSDP_CHECKSUM_LENGTH) != 0) {
+               if (acpi_tb_checksum (acpi_gbl_RSDP, ACPI_RSDP_CHECKSUM_LENGTH) != 0) {
                        /* Nope, BAD Checksum */
 
                        status = AE_BAD_CHECKSUM;
@@ -344,12 +186,11 @@ acpi_get_firmware_table (
                }
        }
 
-
        ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
                "RSDP located at %p, RSDT physical=%8.8X%8.8X \n",
-               acpi_gbl_RSDP, HIDWORD(acpi_gbl_RSDP->rsdt_physical_address),
-               LODWORD(acpi_gbl_RSDP->rsdt_physical_address)));
-
+               acpi_gbl_RSDP,
+               ACPI_HIDWORD (acpi_gbl_RSDP->rsdt_physical_address),
+               ACPI_LODWORD (acpi_gbl_RSDP->rsdt_physical_address)));
 
        /* Get the RSDT and validate it */
 
@@ -364,7 +205,6 @@ acpi_get_firmware_table (
                goto cleanup;
        }
 
-
        /* Get the number of table pointers within the RSDT */
 
        table_count = acpi_tb_get_table_count (acpi_gbl_RSDP, rsdt_ptr);
@@ -378,7 +218,8 @@ acpi_get_firmware_table (
                /* Get the next table pointer */
 
                if (acpi_gbl_RSDP->revision < 2) {
-                       physical_address = ((RSDT_DESCRIPTOR *) rsdt_ptr)->table_offset_entry[i];
+                       physical_address = (ACPI_PHYSICAL_ADDRESS)
+                               ((RSDT_DESCRIPTOR *) rsdt_ptr)->table_offset_entry[i];
                }
                else {
                        physical_address = (ACPI_PHYSICAL_ADDRESS)
@@ -394,7 +235,7 @@ acpi_get_firmware_table (
 
                /* Compare table signatures and table instance */
 
-               if (!STRNCMP ((char *) table_ptr, signature, STRLEN (signature))) {
+               if (!ACPI_STRNCMP ((char *) table_ptr, signature, ACPI_STRLEN (signature))) {
                        /* An instance of the table was found */
 
                        j++;
@@ -427,3 +268,214 @@ cleanup:
 }
 
 
+/* TBD: Move to a new file */
+
+#ifndef _IA16
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_find_root_pointer
+ *
+ * PARAMETERS:  **Rsdp_physical_address     - Where to place the RSDP address
+ *              Flags                       - Logical/Physical addressing
+ *
+ * RETURN:      Status, Physical address of the RSDP
+ *
+ * DESCRIPTION: Find the RSDP
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_find_root_pointer (
+       u32                     flags,
+       ACPI_PHYSICAL_ADDRESS   *rsdp_physical_address)
+{
+       acpi_table_desc         table_info;
+       acpi_status             status;
+
+
+       ACPI_FUNCTION_TRACE ("Acpi_find_root_pointer");
+
+
+       /* Get the RSDP */
+
+       status = acpi_tb_find_rsdp (&table_info, flags);
+       if (ACPI_FAILURE (status)) {
+               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "RSDP structure not found\n"));
+               return_ACPI_STATUS (AE_NO_ACPI_TABLES);
+       }
+
+       *rsdp_physical_address = table_info.physical_address;
+       return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_tb_scan_memory_for_rsdp
+ *
+ * PARAMETERS:  Start_address       - Starting pointer for search
+ *              Length              - Maximum length to search
+ *
+ * RETURN:      Pointer to the RSDP if found, otherwise NULL.
+ *
+ * DESCRIPTION: Search a block of memory for the RSDP signature
+ *
+ ******************************************************************************/
+
+u8 *
+acpi_tb_scan_memory_for_rsdp (
+       u8                      *start_address,
+       u32                     length)
+{
+       u32                     offset;
+       u8                      *mem_rover;
+
+
+       ACPI_FUNCTION_TRACE ("Tb_scan_memory_for_rsdp");
+
+
+       /* Search from given start addr for the requested length  */
+
+       for (offset = 0, mem_rover = start_address;
+                offset < length;
+                offset += RSDP_SCAN_STEP, mem_rover += RSDP_SCAN_STEP) {
+
+               /* The signature and checksum must both be correct */
+
+               if (ACPI_STRNCMP ((NATIVE_CHAR *) mem_rover,
+                               RSDP_SIG, sizeof (RSDP_SIG)-1) == 0 &&
+                       acpi_tb_checksum (mem_rover, ACPI_RSDP_CHECKSUM_LENGTH) == 0) {
+                       /* If so, we have found the RSDP */
+
+                       ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+                               "RSDP located at physical address %p\n",mem_rover));
+                       return_PTR (mem_rover);
+               }
+       }
+
+       /* Searched entire block, no RSDP was found */
+
+       ACPI_DEBUG_PRINT ((ACPI_DB_INFO,"Searched entire block, no RSDP was found.\n"));
+       return_PTR (NULL);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_tb_find_rsdp
+ *
+ * PARAMETERS:  *Table_info             - Where the table info is returned
+ *              Flags                   - Current memory mode (logical vs.
+ *                                        physical addressing)
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Search lower 1_mbyte 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 1_k of the Extended
+ *              BIOS Data Area or between E0000 and FFFFF (ACPI 1.0 section
+ *              5.2.2; assertion #421).
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_tb_find_rsdp (
+       acpi_table_desc         *table_info,
+       u32                     flags)
+{
+       u8                      *table_ptr;
+       u8                      *mem_rover;
+       u64                     phys_addr;
+       acpi_status             status = AE_OK;
+
+
+       ACPI_FUNCTION_TRACE ("Tb_find_rsdp");
+
+
+       /*
+        * Scan supports either 1) Logical addressing or 2) Physical addressing
+        */
+       if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) {
+               /*
+                * 1) Search EBDA (low memory) paragraphs
+                */
+               status = acpi_os_map_memory ((u64) LO_RSDP_WINDOW_BASE, LO_RSDP_WINDOW_SIZE,
+                                 (void **) &table_ptr);
+               if (ACPI_FAILURE (status)) {
+                       return_ACPI_STATUS (status);
+               }
+
+               mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr, LO_RSDP_WINDOW_SIZE);
+               acpi_os_unmap_memory (table_ptr, LO_RSDP_WINDOW_SIZE);
+
+               if (mem_rover) {
+                       /* Found it, return the physical address */
+
+                       phys_addr = LO_RSDP_WINDOW_BASE;
+                       phys_addr += (mem_rover - table_ptr);
+
+                       table_info->physical_address = phys_addr;
+                       return_ACPI_STATUS (AE_OK);
+               }
+
+               /*
+                * 2) Search upper memory: 16-byte boundaries in E0000h-F0000h
+                */
+               status = acpi_os_map_memory ((u64) HI_RSDP_WINDOW_BASE, HI_RSDP_WINDOW_SIZE,
+                                 (void **) &table_ptr);
+               if (ACPI_FAILURE (status)) {
+                       return_ACPI_STATUS (status);
+               }
+
+               mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr, HI_RSDP_WINDOW_SIZE);
+               acpi_os_unmap_memory (table_ptr, HI_RSDP_WINDOW_SIZE);
+
+               if (mem_rover) {
+                       /* Found it, return the physical address */
+
+                       phys_addr = HI_RSDP_WINDOW_BASE;
+                       phys_addr += (mem_rover - table_ptr);
+
+                       table_info->physical_address = phys_addr;
+                       return_ACPI_STATUS (AE_OK);
+               }
+       }
+
+       /*
+        * Physical addressing
+        */
+       else {
+               /*
+                * 1) Search EBDA (low memory) paragraphs
+                */
+               mem_rover = acpi_tb_scan_memory_for_rsdp (ACPI_PHYSADDR_TO_PTR (LO_RSDP_WINDOW_BASE),
+                                 LO_RSDP_WINDOW_SIZE);
+               if (mem_rover) {
+                       /* Found it, return the physical address */
+
+                       table_info->physical_address = ACPI_TO_INTEGER (mem_rover);
+                       return_ACPI_STATUS (AE_OK);
+               }
+
+               /*
+                * 2) Search upper memory: 16-byte boundaries in E0000h-F0000h
+                */
+               mem_rover = acpi_tb_scan_memory_for_rsdp (ACPI_PHYSADDR_TO_PTR (HI_RSDP_WINDOW_BASE),
+                                 HI_RSDP_WINDOW_SIZE);
+               if (mem_rover) {
+                       /* Found it, return the physical address */
+
+                       table_info->physical_address = ACPI_TO_INTEGER (mem_rover);
+                       return_ACPI_STATUS (AE_OK);
+               }
+       }
+
+       /* RSDP signature was not found */
+
+       return_ACPI_STATUS (AE_NOT_FOUND);
+}
+
+#endif
+
index 0714c087172adf7cb040934c0602ec8c336b3ccd..d0bbc7655a46e95b304e00deeca0e7cf8e60f997 100644 (file)
@@ -1,11 +1,10 @@
 #
 # Makefile for all Linux ACPI interpreter subdirectories
-# EXCEPT for the ospm directory
 #
 
 O_TARGET := $(notdir $(CURDIR)).o
 
-obj-$(CONFIG_ACPI) := $(patsubst %.c,%.o,$(wildcard *.c))
+obj-$(CONFIG_ACPI_INTERPRETER) := $(patsubst %.c,%.o,$(wildcard *.c))
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
 
index 40c871508b9ef7501676e5a346e7e87d9e3d57b5..6c36604eafec2cd573e777ddbfbc59050b789dea 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: utalloc - local cache and memory allocation routines
- *              $Revision: 106 $
+ *              $Revision: 121 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -31,7 +31,7 @@
 #include "acglobal.h"
 
 #define _COMPONENT          ACPI_UTILITIES
-        MODULE_NAME         ("utalloc")
+        ACPI_MODULE_NAME    ("utalloc")
 
 
 /******************************************************************************
@@ -56,7 +56,7 @@ acpi_ut_release_to_cache (
        ACPI_MEMORY_LIST        *cache_info;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        /* If walk cache is full, just free this wallkstate object */
@@ -70,12 +70,14 @@ acpi_ut_release_to_cache (
        /* Otherwise put this object back into the cache */
 
        else {
-               acpi_ut_acquire_mutex (ACPI_MTX_CACHES);
+               if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_CACHES))) {
+                       return;
+               }
 
                /* Mark the object as cached */
 
-               MEMSET (object, 0xCA, cache_info->object_size);
-               ((acpi_operand_object *) object)->common.data_type = ACPI_CACHED_OBJECT;
+               ACPI_MEMSET (object, 0xCA, cache_info->object_size);
+               ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_CACHED_OBJECT);
 
                /* Put the object at the head of the cache list */
 
@@ -83,7 +85,7 @@ acpi_ut_release_to_cache (
                cache_info->list_head = object;
                cache_info->cache_depth++;
 
-               acpi_ut_release_mutex (ACPI_MTX_CACHES);
+               (void) acpi_ut_release_mutex (ACPI_MTX_CACHES);
        }
 }
 
@@ -110,11 +112,14 @@ acpi_ut_acquire_from_cache (
        void                    *object;
 
 
-       PROC_NAME ("Ut_acquire_from_cache");
+       ACPI_FUNCTION_NAME ("Ut_acquire_from_cache");
 
 
        cache_info = &acpi_gbl_memory_lists[list_id];
-       acpi_ut_acquire_mutex (ACPI_MTX_CACHES);
+       if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_CACHES))) {
+               return (NULL);
+       }
+
        ACPI_MEM_TRACKING (cache_info->cache_requests++);
 
        /* Check the cache first */
@@ -133,11 +138,13 @@ acpi_ut_acquire_from_cache (
                        object, acpi_gbl_memory_lists[list_id].list_name));
 #endif
 
-               acpi_ut_release_mutex (ACPI_MTX_CACHES);
+               if (ACPI_FAILURE (acpi_ut_release_mutex (ACPI_MTX_CACHES))) {
+                       return (NULL);
+               }
 
                /* Clear (zero) the previously used Object */
 
-               MEMSET (object, 0, cache_info->object_size);
+               ACPI_MEMSET (object, 0, cache_info->object_size);
        }
 
        else {
@@ -145,7 +152,9 @@ acpi_ut_acquire_from_cache (
 
                /* Avoid deadlock with ACPI_MEM_CALLOCATE */
 
-               acpi_ut_release_mutex (ACPI_MTX_CACHES);
+               if (ACPI_FAILURE (acpi_ut_release_mutex (ACPI_MTX_CACHES))) {
+                       return (NULL);
+               }
 
                object = ACPI_MEM_CALLOCATE (cache_info->object_size);
                ACPI_MEM_TRACKING (cache_info->total_allocated++);
@@ -175,7 +184,7 @@ acpi_ut_delete_generic_cache (
        char                    *next;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        cache_info = &acpi_gbl_memory_lists[list_id];
@@ -191,9 +200,230 @@ acpi_ut_delete_generic_cache (
 }
 
 
-#ifdef ACPI_DBG_TRACK_ALLOCATIONS
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ut_validate_buffer
+ *
+ * PARAMETERS:  Buffer              - Buffer descriptor to be validated
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Perform parameter validation checks on an acpi_buffer
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ut_validate_buffer (
+       acpi_buffer             *buffer)
+{
+
+       /* Obviously, the structure pointer must be valid */
+
+       if (!buffer) {
+               return (AE_BAD_PARAMETER);
+       }
+
+       /* Special semantics for the length */
+
+       if ((buffer->length == ACPI_NO_BUFFER)              ||
+               (buffer->length == ACPI_ALLOCATE_BUFFER)        ||
+               (buffer->length == ACPI_ALLOCATE_LOCAL_BUFFER)) {
+               return (AE_OK);
+       }
+
+       /* Length is valid, the buffer pointer must be also */
+
+       if (!buffer->pointer) {
+               return (AE_BAD_PARAMETER);
+       }
+
+       return (AE_OK);
+}
 
 
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ut_initialize_buffer
+ *
+ * PARAMETERS:  Required_length     - Length needed
+ *              Buffer              - Buffer to be validated
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Validate that the buffer is of the required length or
+ *              allocate a new buffer.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ut_initialize_buffer (
+       acpi_buffer             *buffer,
+       ACPI_SIZE               required_length)
+{
+       acpi_status             status = AE_OK;
+
+
+       switch (buffer->length) {
+       case ACPI_NO_BUFFER:
+
+               /* Set the exception and returned the required length */
+
+               status = AE_BUFFER_OVERFLOW;
+               break;
+
+
+       case ACPI_ALLOCATE_BUFFER:
+
+               /* Allocate a new buffer */
+
+               buffer->pointer = acpi_os_allocate (required_length);
+               if (!buffer->pointer) {
+                       return (AE_NO_MEMORY);
+               }
+
+               /* Clear the buffer */
+
+               ACPI_MEMSET (buffer->pointer, 0, required_length);
+               break;
+
+
+       case ACPI_ALLOCATE_LOCAL_BUFFER:
+
+               /* Allocate a new buffer with local interface to allow tracking */
+
+               buffer->pointer = ACPI_MEM_ALLOCATE (required_length);
+               if (!buffer->pointer) {
+                       return (AE_NO_MEMORY);
+               }
+
+               /* Clear the buffer */
+
+               ACPI_MEMSET (buffer->pointer, 0, required_length);
+               break;
+
+
+       default:
+
+               /* Validate the size of the buffer */
+
+               if (buffer->length < required_length) {
+                       status = AE_BUFFER_OVERFLOW;
+               }
+
+               /* Clear the buffer */
+
+               ACPI_MEMSET (buffer->pointer, 0, required_length);
+               break;
+       }
+
+       buffer->length = required_length;
+       return (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ut_allocate
+ *
+ * PARAMETERS:  Size                - Size of the allocation
+ *              Component           - Component type of caller
+ *              Module              - Source file name of caller
+ *              Line                - Line number of caller
+ *
+ * RETURN:      Address of the allocated memory on success, NULL on failure.
+ *
+ * DESCRIPTION: The subsystem's equivalent of malloc.
+ *
+ ******************************************************************************/
+
+void *
+acpi_ut_allocate (
+       ACPI_SIZE               size,
+       u32                     component,
+       NATIVE_CHAR             *module,
+       u32                     line)
+{
+       void                    *allocation;
+
+
+       ACPI_FUNCTION_TRACE_U32 ("Ut_allocate", size);
+
+
+       /* Check for an inadvertent size of zero bytes */
+
+       if (!size) {
+               _ACPI_REPORT_ERROR (module, line, component,
+                               ("Ut_allocate: Attempt to allocate zero bytes\n"));
+               size = 1;
+       }
+
+       allocation = acpi_os_allocate (size);
+       if (!allocation) {
+               /* Report allocation error */
+
+               _ACPI_REPORT_ERROR (module, line, component,
+                               ("Ut_allocate: Could not allocate size %X\n", size));
+
+               return_PTR (NULL);
+       }
+
+       return_PTR (allocation);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ut_callocate
+ *
+ * PARAMETERS:  Size                - Size of the allocation
+ *              Component           - Component type of caller
+ *              Module              - Source file name of caller
+ *              Line                - Line number of caller
+ *
+ * RETURN:      Address of the allocated memory on success, NULL on failure.
+ *
+ * DESCRIPTION: Subsystem equivalent of calloc.
+ *
+ ******************************************************************************/
+
+void *
+acpi_ut_callocate (
+       ACPI_SIZE               size,
+       u32                     component,
+       NATIVE_CHAR             *module,
+       u32                     line)
+{
+       void                    *allocation;
+
+
+       ACPI_FUNCTION_TRACE_U32 ("Ut_callocate", size);
+
+
+       /* Check for an inadvertent size of zero bytes */
+
+       if (!size) {
+               _ACPI_REPORT_ERROR (module, line, component,
+                               ("Ut_callocate: Attempt to allocate zero bytes\n"));
+               return_PTR (NULL);
+       }
+
+       allocation = acpi_os_allocate (size);
+       if (!allocation) {
+               /* Report allocation error */
+
+               _ACPI_REPORT_ERROR (module, line, component,
+                               ("Ut_callocate: Could not allocate size %X\n", size));
+               return_PTR (NULL);
+       }
+
+       /* Clear the memory block */
+
+       ACPI_MEMSET (allocation, 0, size);
+       return_PTR (allocation);
+}
+
+
+#ifdef ACPI_DBG_TRACK_ALLOCATIONS
 /*
  * These procedures are used for tracking memory leaks in the subsystem, and
  * they get compiled out when the ACPI_DBG_TRACK_ALLOCATIONS is not set.
@@ -206,11 +436,158 @@ acpi_ut_delete_generic_cache (
  */
 
 
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ut_allocate_and_track
+ *
+ * PARAMETERS:  Size                - Size of the allocation
+ *              Component           - Component type of caller
+ *              Module              - Source file name of caller
+ *              Line                - Line number of caller
+ *
+ * RETURN:      Address of the allocated memory on success, NULL on failure.
+ *
+ * DESCRIPTION: The subsystem's equivalent of malloc.
+ *
+ ******************************************************************************/
+
+void *
+acpi_ut_allocate_and_track (
+       ACPI_SIZE               size,
+       u32                     component,
+       NATIVE_CHAR             *module,
+       u32                     line)
+{
+       acpi_debug_mem_block    *allocation;
+       acpi_status             status;
+
+
+       allocation = acpi_ut_allocate (size + sizeof (acpi_debug_mem_block), component,
+                         module, line);
+       if (!allocation) {
+               return (NULL);
+       }
+
+       status = acpi_ut_track_allocation (ACPI_MEM_LIST_GLOBAL, allocation, size,
+                         ACPI_MEM_MALLOC, component, module, line);
+       if (ACPI_FAILURE (status)) {
+               acpi_os_free (allocation);
+               return (NULL);
+       }
+
+       acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_allocated++;
+       acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size += (u32) size;
+
+       return ((void *) &allocation->user_space);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ut_callocate_and_track
+ *
+ * PARAMETERS:  Size                - Size of the allocation
+ *              Component           - Component type of caller
+ *              Module              - Source file name of caller
+ *              Line                - Line number of caller
+ *
+ * RETURN:      Address of the allocated memory on success, NULL on failure.
+ *
+ * DESCRIPTION: Subsystem equivalent of calloc.
+ *
+ ******************************************************************************/
+
+void *
+acpi_ut_callocate_and_track (
+       ACPI_SIZE               size,
+       u32                     component,
+       NATIVE_CHAR             *module,
+       u32                     line)
+{
+       acpi_debug_mem_block    *allocation;
+       acpi_status             status;
+
+
+       allocation = acpi_ut_callocate (size + sizeof (acpi_debug_mem_block), component,
+                         module, line);
+       if (!allocation) {
+               /* Report allocation error */
+
+               _ACPI_REPORT_ERROR (module, line, component,
+                               ("Ut_callocate: Could not allocate size %X\n", size));
+               return (NULL);
+       }
+
+       status = acpi_ut_track_allocation (ACPI_MEM_LIST_GLOBAL, allocation, size,
+                          ACPI_MEM_CALLOC, component, module, line);
+       if (ACPI_FAILURE (status)) {
+               acpi_os_free (allocation);
+               return (NULL);
+       }
+
+       acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_allocated++;
+       acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size += (u32) size;
+
+       return ((void *) &allocation->user_space);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ut_free_and_track
+ *
+ * PARAMETERS:  Allocation          - Address of the memory to deallocate
+ *              Component           - Component type of caller
+ *              Module              - Source file name of caller
+ *              Line                - Line number of caller
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Frees the memory at Allocation
+ *
+ ******************************************************************************/
+
+void
+acpi_ut_free_and_track (
+       void                    *allocation,
+       u32                     component,
+       NATIVE_CHAR             *module,
+       u32                     line)
+{
+       acpi_debug_mem_block    *debug_block;
+
+
+       ACPI_FUNCTION_TRACE_PTR ("Ut_free", allocation);
+
+
+       if (NULL == allocation) {
+               _ACPI_REPORT_ERROR (module, line, component,
+                       ("Acpi_ut_free: Attempt to delete a NULL address\n"));
+
+               return_VOID;
+       }
+
+       debug_block = (acpi_debug_mem_block *)
+                         (((char *) allocation) - sizeof (acpi_debug_mem_header));
+
+       acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_freed++;
+       acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size -= debug_block->size;
+
+       acpi_ut_remove_allocation (ACPI_MEM_LIST_GLOBAL, debug_block,
+                       component, module, line);
+       acpi_os_free (debug_block);
+
+       ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", allocation));
+
+       return_VOID;
+}
+
+
 /*******************************************************************************
  *
  * FUNCTION:    Acpi_ut_find_allocation
  *
- * PARAMETERS:  Address             - Address of allocated memory
+ * PARAMETERS:  Allocation             - Address of allocated memory
  *
  * RETURN:      A list element if found; NULL otherwise.
  *
@@ -221,12 +598,12 @@ acpi_ut_delete_generic_cache (
 acpi_debug_mem_block *
 acpi_ut_find_allocation (
        u32                     list_id,
-       void                    *address)
+       void                    *allocation)
 {
        acpi_debug_mem_block    *element;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        if (list_id > ACPI_MEM_LIST_MAX) {
@@ -238,7 +615,7 @@ acpi_ut_find_allocation (
        /* Search for the address. */
 
        while (element) {
-               if (element == address) {
+               if (element == allocation) {
                        return (element);
                }
 
@@ -253,7 +630,7 @@ acpi_ut_find_allocation (
  *
  * FUNCTION:    Acpi_ut_track_allocation
  *
- * PARAMETERS:  Address             - Address of allocated memory
+ * PARAMETERS:  Allocation          - Address of allocated memory
  *              Size                - Size of the allocation
  *              Alloc_type          - MEM_MALLOC or MEM_CALLOC
  *              Component           - Component type of caller
@@ -269,8 +646,8 @@ acpi_ut_find_allocation (
 acpi_status
 acpi_ut_track_allocation (
        u32                     list_id,
-       acpi_debug_mem_block    *address,
-       u32                     size,
+       acpi_debug_mem_block    *allocation,
+       ACPI_SIZE               size,
        u8                      alloc_type,
        u32                     component,
        NATIVE_CHAR             *module,
@@ -281,7 +658,7 @@ acpi_ut_track_allocation (
        acpi_status             status = AE_OK;
 
 
-       FUNCTION_TRACE_PTR ("Ut_track_allocation", address);
+       ACPI_FUNCTION_TRACE_PTR ("Ut_track_allocation", allocation);
 
 
        if (list_id > ACPI_MEM_LIST_MAX) {
@@ -289,46 +666,49 @@ acpi_ut_track_allocation (
        }
 
        mem_list = &acpi_gbl_memory_lists[list_id];
-       acpi_ut_acquire_mutex (ACPI_MTX_MEMORY);
+       status = acpi_ut_acquire_mutex (ACPI_MTX_MEMORY);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
 
        /*
         * Search list for this address to make sure it is not already on the list.
         * This will catch several kinds of problems.
         */
 
-       element = acpi_ut_find_allocation (list_id, address);
+       element = acpi_ut_find_allocation (list_id, allocation);
        if (element) {
-               REPORT_ERROR (("Ut_track_allocation: Address already present in list! (%p)\n",
-                       address));
+               ACPI_REPORT_ERROR (("Ut_track_allocation: Allocation already present in list! (%p)\n",
+                       allocation));
 
-               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Element %p Address %p\n", element, address));
+               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Element %p Address %p\n", element, allocation));
 
                goto unlock_and_exit;
        }
 
        /* Fill in the instance data. */
 
-       address->size      = size;
-       address->alloc_type = alloc_type;
-       address->component = component;
-       address->line      = line;
+       allocation->size      = (u32) size;
+       allocation->alloc_type = alloc_type;
+       allocation->component = component;
+       allocation->line      = line;
 
-       STRNCPY (address->module, module, MAX_MODULE_NAME);
+       ACPI_STRNCPY (allocation->module, module, ACPI_MAX_MODULE_NAME);
 
        /* Insert at list head */
 
        if (mem_list->list_head) {
-               ((acpi_debug_mem_block *)(mem_list->list_head))->previous = address;
+               ((acpi_debug_mem_block *)(mem_list->list_head))->previous = allocation;
        }
 
-       address->next = mem_list->list_head;
-       address->previous = NULL;
+       allocation->next = mem_list->list_head;
+       allocation->previous = NULL;
 
-       mem_list->list_head = address;
+       mem_list->list_head = allocation;
 
 
 unlock_and_exit:
-       acpi_ut_release_mutex (ACPI_MTX_MEMORY);
+       status = acpi_ut_release_mutex (ACPI_MTX_MEMORY);
        return_ACPI_STATUS (status);
 }
 
@@ -337,7 +717,7 @@ unlock_and_exit:
  *
  * FUNCTION:    Acpi_ut_remove_allocation
  *
- * PARAMETERS:  Address             - Address of allocated memory
+ * PARAMETERS:  Allocation          - Address of allocated memory
  *              Component           - Component type of caller
  *              Module              - Source file name of caller
  *              Line                - Line number of caller
@@ -351,15 +731,16 @@ unlock_and_exit:
 acpi_status
 acpi_ut_remove_allocation (
        u32                     list_id,
-       acpi_debug_mem_block    *address,
+       acpi_debug_mem_block    *allocation,
        u32                     component,
        NATIVE_CHAR             *module,
        u32                     line)
 {
        ACPI_MEMORY_LIST        *mem_list;
+       acpi_status             status;
 
 
-       FUNCTION_TRACE ("Ut_remove_allocation");
+       ACPI_FUNCTION_TRACE ("Ut_remove_allocation");
 
 
        if (list_id > ACPI_MEM_LIST_MAX) {
@@ -370,37 +751,38 @@ acpi_ut_remove_allocation (
        if (NULL == mem_list->list_head) {
                /* No allocations! */
 
-               _REPORT_ERROR (module, line, component,
+               _ACPI_REPORT_ERROR (module, line, component,
                                ("Ut_remove_allocation: Empty allocation list, nothing to free!\n"));
 
                return_ACPI_STATUS (AE_OK);
        }
 
-
-       acpi_ut_acquire_mutex (ACPI_MTX_MEMORY);
+       status = acpi_ut_acquire_mutex (ACPI_MTX_MEMORY);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
 
        /* Unlink */
 
-       if (address->previous) {
-               (address->previous)->next = address->next;
+       if (allocation->previous) {
+               (allocation->previous)->next = allocation->next;
        }
        else {
-               mem_list->list_head = address->next;
+               mem_list->list_head = allocation->next;
        }
 
-       if (address->next) {
-               (address->next)->previous = address->previous;
+       if (allocation->next) {
+               (allocation->next)->previous = allocation->previous;
        }
 
-
        /* Mark the segment as deleted */
 
-       MEMSET (&address->user_space, 0xEA, address->size);
+       ACPI_MEMSET (&allocation->user_space, 0xEA, allocation->size);
 
-       ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size %X\n", address->size));
+       ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size %X\n", allocation->size));
 
-       acpi_ut_release_mutex (ACPI_MTX_MEMORY);
-       return_ACPI_STATUS (AE_OK);
+       status = acpi_ut_release_mutex (ACPI_MTX_MEMORY);
+       return_ACPI_STATUS (status);
 }
 
 
@@ -424,7 +806,7 @@ acpi_ut_dump_allocation_info (
        ACPI_MEMORY_LIST        *Mem_list;
 */
 
-       FUNCTION_TRACE ("Ut_dump_allocation_info");
+       ACPI_FUNCTION_TRACE ("Ut_dump_allocation_info");
 
 /*
        ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
@@ -482,302 +864,114 @@ acpi_ut_dump_allocations (
        NATIVE_CHAR             *module)
 {
        acpi_debug_mem_block    *element;
-       u32                     i;
-
-
-       FUNCTION_TRACE ("Ut_dump_allocations");
+       u32                     num_outstanding = 0;
 
 
-       element = acpi_gbl_memory_lists[0].list_head;
-       if (element == NULL) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_OK,
-                               "No outstanding allocations.\n"));
-               return_VOID;
-       }
+       ACPI_FUNCTION_TRACE ("Ut_dump_allocations");
 
 
        /*
         * Walk the allocation list.
         */
-       acpi_ut_acquire_mutex (ACPI_MTX_MEMORY);
-
-       ACPI_DEBUG_PRINT ((ACPI_DB_OK,
-               "Outstanding allocations:\n"));
+       if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_MEMORY))) {
+               return;
+       }
 
-       for (i = 1; ; i++)  /* Just a counter */ {
+       element = acpi_gbl_memory_lists[0].list_head;
+       while (element) {
                if ((element->component & component) &&
-                       ((module == NULL) || (0 == STRCMP (module, element->module)))) {
+                       ((module == NULL) || (0 == ACPI_STRCMP (module, element->module)))) {
+                       /* Ignore allocated objects that are in a cache */
+
                        if (((acpi_operand_object  *)(&element->user_space))->common.type != ACPI_CACHED_OBJECT) {
-                               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-                                                "%p Len %04X %9.9s-%d",
+                               acpi_os_printf ("%p Len %04X %9.9s-%d ",
                                                 &element->user_space, element->size, element->module,
-                                                element->line));
+                                                element->line);
 
                                /* Most of the elements will be internal objects. */
 
-                               switch (((acpi_operand_object  *)
-                                       (&element->user_space))->common.data_type) {
+                               switch (ACPI_GET_DESCRIPTOR_TYPE (&element->user_space)) {
                                case ACPI_DESC_TYPE_INTERNAL:
-                                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-                                                       " Obj_type %12.12s R%d",
+                                       acpi_os_printf ("Obj_type %12.12s R%d",
                                                        acpi_ut_get_type_name (((acpi_operand_object *)(&element->user_space))->common.type),
-                                                       ((acpi_operand_object *)(&element->user_space))->common.reference_count));
+                                                       ((acpi_operand_object *)(&element->user_space))->common.reference_count);
                                        break;
 
                                case ACPI_DESC_TYPE_PARSER:
-                                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-                                                       " Parse_obj Opcode %04X",
-                                                       ((acpi_parse_object *)(&element->user_space))->opcode));
+                                       acpi_os_printf ("Parse_obj Opcode %04X",
+                                                       ((acpi_parse_object *)(&element->user_space))->opcode);
                                        break;
 
                                case ACPI_DESC_TYPE_NAMED:
-                                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-                                                       " Node %4.4s",
-                                                       (char*)&((acpi_namespace_node *)(&element->user_space))->name));
+                                       acpi_os_printf ("Node %4.4s",
+                                                       (char *) &((acpi_namespace_node *)(&element->user_space))->name);
                                        break;
 
                                case ACPI_DESC_TYPE_STATE:
-                                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-                                                       " Untyped State_obj"));
+                                       acpi_os_printf ("Untyped State_obj");
                                        break;
 
                                case ACPI_DESC_TYPE_STATE_UPDATE:
-                                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-                                                       " UPDATE State_obj"));
+                                       acpi_os_printf ("UPDATE State_obj");
                                        break;
 
                                case ACPI_DESC_TYPE_STATE_PACKAGE:
-                                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-                                                       " PACKAGE State_obj"));
+                                       acpi_os_printf ("PACKAGE State_obj");
                                        break;
 
                                case ACPI_DESC_TYPE_STATE_CONTROL:
-                                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-                                                       " CONTROL State_obj"));
+                                       acpi_os_printf ("CONTROL State_obj");
                                        break;
 
                                case ACPI_DESC_TYPE_STATE_RPSCOPE:
-                                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-                                                       " ROOT-PARSE-SCOPE State_obj"));
+                                       acpi_os_printf ("ROOT-PARSE-SCOPE State_obj");
                                        break;
 
                                case ACPI_DESC_TYPE_STATE_PSCOPE:
-                                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-                                                       " PARSE-SCOPE State_obj"));
+                                       acpi_os_printf ("PARSE-SCOPE State_obj");
                                        break;
 
                                case ACPI_DESC_TYPE_STATE_WSCOPE:
-                                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-                                                       " WALK-SCOPE State_obj"));
+                                       acpi_os_printf ("WALK-SCOPE State_obj");
                                        break;
 
                                case ACPI_DESC_TYPE_STATE_RESULT:
-                                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-                                                       " RESULT State_obj"));
+                                       acpi_os_printf ("RESULT State_obj");
                                        break;
 
                                case ACPI_DESC_TYPE_STATE_NOTIFY:
-                                       ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
-                                                       " NOTIFY State_obj"));
+                                       acpi_os_printf ("NOTIFY State_obj");
+                                       break;
+
+                               case ACPI_DESC_TYPE_STATE_THREAD:
+                                       acpi_os_printf ("THREAD State_obj");
                                        break;
                                }
 
-                               ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, "\n"));
+                               acpi_os_printf ( "\n");
+                               num_outstanding++;
                        }
                }
-
-               if (element->next == NULL) {
-                       break;
-               }
-
                element = element->next;
        }
 
-       acpi_ut_release_mutex (ACPI_MTX_MEMORY);
-
-       ACPI_DEBUG_PRINT ((ACPI_DB_OK,
-               "Total number of unfreed allocations = %d(%X)\n", i,i));
-
-
-       return_VOID;
-
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ut_allocate
- *
- * PARAMETERS:  Size                - Size of the allocation
- *              Component           - Component type of caller
- *              Module              - Source file name of caller
- *              Line                - Line number of caller
- *
- * RETURN:      Address of the allocated memory on success, NULL on failure.
- *
- * DESCRIPTION: The subsystem's equivalent of malloc.
- *
- ******************************************************************************/
-
-void *
-acpi_ut_allocate (
-       u32                     size,
-       u32                     component,
-       NATIVE_CHAR             *module,
-       u32                     line)
-{
-       acpi_debug_mem_block    *address;
-       acpi_status             status;
-
-
-       FUNCTION_TRACE_U32 ("Ut_allocate", size);
-
-
-       /* Check for an inadvertent size of zero bytes */
-
-       if (!size) {
-               _REPORT_ERROR (module, line, component,
-                               ("Ut_allocate: Attempt to allocate zero bytes\n"));
-               size = 1;
-       }
-
-       address = acpi_os_allocate (size + sizeof (acpi_debug_mem_block));
-       if (!address) {
-               /* Report allocation error */
-
-               _REPORT_ERROR (module, line, component,
-                               ("Ut_allocate: Could not allocate size %X\n", size));
-
-               return_PTR (NULL);
-       }
-
-       status = acpi_ut_track_allocation (ACPI_MEM_LIST_GLOBAL, address, size,
-                         MEM_MALLOC, component, module, line);
-       if (ACPI_FAILURE (status)) {
-               acpi_os_free (address);
-               return_PTR (NULL);
-       }
-
-       acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_allocated++;
-       acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size += size;
-
-       ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n", address, size));
-
-       return_PTR ((void *) &address->user_space);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ut_callocate
- *
- * PARAMETERS:  Size                - Size of the allocation
- *              Component           - Component type of caller
- *              Module              - Source file name of caller
- *              Line                - Line number of caller
- *
- * RETURN:      Address of the allocated memory on success, NULL on failure.
- *
- * DESCRIPTION: Subsystem equivalent of calloc.
- *
- ******************************************************************************/
-
-void *
-acpi_ut_callocate (
-       u32                     size,
-       u32                     component,
-       NATIVE_CHAR             *module,
-       u32                     line)
-{
-       acpi_debug_mem_block    *address;
-       acpi_status             status;
-
-
-       FUNCTION_TRACE_U32 ("Ut_callocate", size);
-
-
-       /* Check for an inadvertent size of zero bytes */
-
-       if (!size) {
-               _REPORT_ERROR (module, line, component,
-                               ("Ut_callocate: Attempt to allocate zero bytes\n"));
-               return_PTR (NULL);
-       }
-
-
-       address = acpi_os_callocate (size + sizeof (acpi_debug_mem_block));
-       if (!address) {
-               /* Report allocation error */
+       (void) acpi_ut_release_mutex (ACPI_MTX_MEMORY);
 
-               _REPORT_ERROR (module, line, component,
-                               ("Ut_callocate: Could not allocate size %X\n", size));
-               return_PTR (NULL);
-       }
+       /* Print summary */
 
-       status = acpi_ut_track_allocation (ACPI_MEM_LIST_GLOBAL, address, size,
-                          MEM_CALLOC, component, module, line);
-       if (ACPI_FAILURE (status)) {
-               acpi_os_free (address);
-               return_PTR (NULL);
+       if (!num_outstanding) {
+               ACPI_DEBUG_PRINT ((ACPI_DB_OK,
+                               "No outstanding allocations.\n"));
        }
-
-       acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_allocated++;
-       acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size += size;
-
-       ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n", address, size));
-       return_PTR ((void *) &address->user_space);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    Acpi_ut_free
- *
- * PARAMETERS:  Address             - Address of the memory to deallocate
- *              Component           - Component type of caller
- *              Module              - Source file name of caller
- *              Line                - Line number of caller
- *
- * RETURN:      None
- *
- * DESCRIPTION: Frees the memory at Address
- *
- ******************************************************************************/
-
-void
-acpi_ut_free (
-       void                    *address,
-       u32                     component,
-       NATIVE_CHAR             *module,
-       u32                     line)
-{
-       acpi_debug_mem_block    *debug_block;
-
-
-       FUNCTION_TRACE_PTR ("Ut_free", address);
-
-
-       if (NULL == address) {
-               _REPORT_ERROR (module, line, component,
-                       ("Acpi_ut_free: Trying to delete a NULL address\n"));
-
-               return_VOID;
+       else {
+               ACPI_DEBUG_PRINT ((ACPI_DB_OK,
+                       "%d(%X) Outstanding allocations\n",
+                       num_outstanding, num_outstanding));
        }
 
-       debug_block = (acpi_debug_mem_block *)
-                         (((char *) address) - sizeof (acpi_debug_mem_header));
-
-       acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_freed++;
-       acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size -= debug_block->size;
-
-       acpi_ut_remove_allocation (ACPI_MEM_LIST_GLOBAL, debug_block,
-                       component, module, line);
-       acpi_os_free (debug_block);
-
-       ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", address));
-
        return_VOID;
 }
 
+
 #endif  /* #ifdef ACPI_DBG_TRACK_ALLOCATIONS */
 
index e729c36002209efc3d2c0067cc011b605b725425..99f3057c80d673036cac16e4b9fe77f05636fa4f 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: utcopy - Internal to external object translation utilities
- *              $Revision: 83 $
+ *              $Revision: 94 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -31,7 +31,7 @@
 
 
 #define _COMPONENT          ACPI_UTILITIES
-        MODULE_NAME         ("utcopy")
+        ACPI_MODULE_NAME    ("utcopy")
 
 
 /*******************************************************************************
@@ -56,27 +56,28 @@ acpi_ut_copy_isimple_to_esimple (
        acpi_operand_object     *internal_object,
        acpi_object             *external_object,
        u8                      *data_space,
-       u32                     *buffer_space_used)
+       ACPI_SIZE               *buffer_space_used)
 {
-       u32                     length = 0;
+       acpi_buffer             buffer;
        acpi_status             status = AE_OK;
 
 
-       FUNCTION_TRACE ("Ut_copy_isimple_to_esimple");
+       ACPI_FUNCTION_TRACE ("Ut_copy_isimple_to_esimple");
+
 
+       *buffer_space_used = 0;
 
        /*
         * Check for NULL object case (could be an uninitialized
         * package element
         */
        if (!internal_object) {
-               *buffer_space_used = 0;
                return_ACPI_STATUS (AE_OK);
        }
 
        /* Always clear the external object */
 
-       MEMSET (external_object, 0, sizeof (acpi_object));
+       ACPI_MEMSET (external_object, 0, sizeof (acpi_object));
 
        /*
         * In general, the external object will be the same type as
@@ -87,28 +88,31 @@ acpi_ut_copy_isimple_to_esimple (
        /* However, only a limited number of external types are supported */
 
        switch (internal_object->common.type) {
-
        case ACPI_TYPE_STRING:
 
-               length = internal_object->string.length + 1;
-               external_object->string.length = internal_object->string.length;
                external_object->string.pointer = (NATIVE_CHAR *) data_space;
-               MEMCPY ((void *) data_space, (void *) internal_object->string.pointer, length);
+               external_object->string.length = internal_object->string.length;
+               *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD (internal_object->string.length + 1);
+
+               ACPI_MEMCPY ((void *) data_space, (void *) internal_object->string.pointer,
+                                internal_object->string.length + 1);
                break;
 
 
        case ACPI_TYPE_BUFFER:
 
-               length = internal_object->buffer.length;
-               external_object->buffer.length = internal_object->buffer.length;
                external_object->buffer.pointer = data_space;
-               MEMCPY ((void *) data_space, (void *) internal_object->buffer.pointer, length);
+               external_object->buffer.length = internal_object->buffer.length;
+               *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD (internal_object->string.length);
+
+               ACPI_MEMCPY ((void *) data_space, (void *) internal_object->buffer.pointer,
+                                internal_object->buffer.length);
                break;
 
 
        case ACPI_TYPE_INTEGER:
 
-               external_object->integer.value= internal_object->integer.value;
+               external_object->integer.value = internal_object->integer.value;
                break;
 
 
@@ -143,15 +147,19 @@ acpi_ut_copy_isimple_to_esimple (
                         * This is a named reference, get the string.  We already know that
                         * we have room for it, use max length
                         */
-                       length = MAX_STRING_LENGTH;
                        external_object->type = ACPI_TYPE_STRING;
                        external_object->string.pointer = (NATIVE_CHAR *) data_space;
+
+                       buffer.length = MAX_STRING_LENGTH;
+                       buffer.pointer = data_space;
+
                        status = acpi_ns_handle_to_pathname ((acpi_handle *) internal_object->reference.node,
-                                        &length, (char *) data_space);
+                                        &buffer);
 
                        /* Converted (external) string length is returned from above */
 
-                       external_object->string.length = length;
+                       external_object->string.length = buffer.length;
+                       *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD (buffer.length);
                        break;
 
                default:
@@ -189,12 +197,8 @@ acpi_ut_copy_isimple_to_esimple (
                 * There is no corresponding external object type
                 */
                return_ACPI_STATUS (AE_SUPPORT);
-               break;
        }
 
-
-       *buffer_space_used = (u32) ROUND_UP_TO_NATIVE_WORD (length);
-
        return_ACPI_STATUS (status);
 }
 
@@ -220,12 +224,12 @@ acpi_ut_copy_ielement_to_eelement (
 {
        acpi_status             status = AE_OK;
        acpi_pkg_info           *info = (acpi_pkg_info *) context;
-       u32                     object_space;
+       ACPI_SIZE               object_space;
        u32                     this_index;
        acpi_object             *target_object;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        this_index   = state->pkg.index;
@@ -236,16 +240,16 @@ acpi_ut_copy_ielement_to_eelement (
        case ACPI_COPY_TYPE_SIMPLE:
 
                /*
-                * This is a simple or null object -- get the size
+                * This is a simple or null object
                 */
                status = acpi_ut_copy_isimple_to_esimple (source_object,
                                  target_object, info->free_space, &object_space);
                if (ACPI_FAILURE (status)) {
                        return (status);
                }
-
                break;
 
+
        case ACPI_COPY_TYPE_PACKAGE:
 
                /*
@@ -264,18 +268,17 @@ acpi_ut_copy_ielement_to_eelement (
                 * Save space for the array of objects (Package elements)
                 * update the buffer length counter
                 */
-               object_space = (u32) ROUND_UP_TO_NATIVE_WORD (
+               object_space = ACPI_ROUND_UP_TO_NATIVE_WORD (
                                   target_object->package.count * sizeof (acpi_object));
                break;
 
+
        default:
                return (AE_BAD_PARAMETER);
        }
 
-
        info->free_space  += object_space;
        info->length      += object_space;
-
        return (status);
 }
 
@@ -303,14 +306,14 @@ static acpi_status
 acpi_ut_copy_ipackage_to_epackage (
        acpi_operand_object     *internal_object,
        u8                      *buffer,
-       u32                     *space_used)
+       ACPI_SIZE               *space_used)
 {
        acpi_object             *external_object;
        acpi_status             status;
        acpi_pkg_info           info;
 
 
-       FUNCTION_TRACE ("Ut_copy_ipackage_to_epackage");
+       ACPI_FUNCTION_TRACE ("Ut_copy_ipackage_to_epackage");
 
 
        /*
@@ -324,31 +327,27 @@ acpi_ut_copy_ipackage_to_epackage (
        info.length      = 0;
        info.object_space = 0;
        info.num_packages = 1;
-       info.free_space  = buffer + ROUND_UP_TO_NATIVE_WORD (sizeof (acpi_object));
-
+       info.free_space  = buffer + ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (acpi_object));
 
        external_object->type              = internal_object->common.type;
        external_object->package.count     = internal_object->package.count;
        external_object->package.elements  = (acpi_object *) info.free_space;
 
-
        /*
         * Build an array of ACPI_OBJECTS in the buffer
         * and move the free space past it
         */
        info.free_space += external_object->package.count *
-                         ROUND_UP_TO_NATIVE_WORD (sizeof (acpi_object));
-
+                         ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (acpi_object));
 
        status = acpi_ut_walk_package_tree (internal_object, external_object,
                         acpi_ut_copy_ielement_to_eelement, &info);
 
        *space_used = info.length;
-
        return_ACPI_STATUS (status);
-
 }
 
+
 /*******************************************************************************
  *
  * FUNCTION:    Acpi_ut_copy_iobject_to_eobject
@@ -371,10 +370,10 @@ acpi_ut_copy_iobject_to_eobject (
        acpi_status             status;
 
 
-       FUNCTION_TRACE ("Ut_copy_iobject_to_eobject");
+       ACPI_FUNCTION_TRACE ("Ut_copy_iobject_to_eobject");
 
 
-       if (IS_THIS_OBJECT_TYPE (internal_object, ACPI_TYPE_PACKAGE)) {
+       if (internal_object->common.type == ACPI_TYPE_PACKAGE) {
                /*
                 * Package object:  Copy all subobjects (including
                 * nested packages)
@@ -382,7 +381,6 @@ acpi_ut_copy_iobject_to_eobject (
                status = acpi_ut_copy_ipackage_to_epackage (internal_object,
                                  ret_buffer->pointer, &ret_buffer->length);
        }
-
        else {
                /*
                 * Build a simple object (no nested objects)
@@ -390,7 +388,7 @@ acpi_ut_copy_iobject_to_eobject (
                status = acpi_ut_copy_isimple_to_esimple (internal_object,
                                  (acpi_object *) ret_buffer->pointer,
                                  ((u8 *) ret_buffer->pointer +
-                                 ROUND_UP_TO_NATIVE_WORD (sizeof (acpi_object))),
+                                 ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (acpi_object))),
                                  &ret_buffer->length);
                /*
                 * build simple does not include the object size in the length
@@ -427,7 +425,7 @@ acpi_ut_copy_esimple_to_isimple (
        acpi_operand_object     *internal_object;
 
 
-       FUNCTION_TRACE ("Ut_copy_esimple_to_isimple");
+       ACPI_FUNCTION_TRACE ("Ut_copy_esimple_to_isimple");
 
 
        /*
@@ -449,7 +447,6 @@ acpi_ut_copy_esimple_to_isimple (
                 * Whatever other type -- it is not supported
                 */
                return_ACPI_STATUS (AE_SUPPORT);
-               break;
        }
 
 
@@ -464,9 +461,9 @@ acpi_ut_copy_esimple_to_isimple (
                        return_ACPI_STATUS (AE_NO_MEMORY);
                }
 
-               MEMCPY (internal_object->string.pointer,
-                               external_object->string.pointer,
-                               external_object->string.length);
+               ACPI_MEMCPY (internal_object->string.pointer,
+                                 external_object->string.pointer,
+                                 external_object->string.length);
 
                internal_object->string.length = external_object->string.length;
                break;
@@ -479,9 +476,9 @@ acpi_ut_copy_esimple_to_isimple (
                        return_ACPI_STATUS (AE_NO_MEMORY);
                }
 
-               MEMCPY (internal_object->buffer.pointer,
-                               external_object->buffer.pointer,
-                               external_object->buffer.length);
+               ACPI_MEMCPY (internal_object->buffer.pointer,
+                                 external_object->buffer.pointer,
+                                 external_object->buffer.length);
 
                internal_object->buffer.length = external_object->buffer.length;
                break;
@@ -493,7 +490,6 @@ acpi_ut_copy_esimple_to_isimple (
                break;
        }
 
-
        *ret_internal_object = internal_object;
        return_ACPI_STATUS (AE_OK);
 }
@@ -537,7 +533,7 @@ acpi_ut_copy_epackage_to_ipackage (
        acpi_object             *this_external_obj;
 
 
-       FUNCTION_TRACE ("Ut_copy_epackage_to_ipackage");
+       ACPI_FUNCTION_TRACE ("Ut_copy_epackage_to_ipackage");
 
 
        /*
@@ -591,23 +587,13 @@ acpi_ut_copy_eobject_to_iobject (
        acpi_status             status;
 
 
-       FUNCTION_TRACE ("Ut_copy_eobject_to_iobject");
+       ACPI_FUNCTION_TRACE ("Ut_copy_eobject_to_iobject");
 
 
        if (external_object->type == ACPI_TYPE_PACKAGE) {
                /*
-                * Package objects contain other objects (which can be objects)
-                * buildpackage does it all
-                *
-                * TBD: Package conversion must be completed and tested
-                * NOTE: this code converts packages as input parameters to
-                * control methods only.  This is a very, very rare case.
+                * Packages as external input to control methods are not supported,
                 */
-/*
-               Status = Acpi_ut_copy_epackage_to_ipackage(Internal_object,
-                                Ret_buffer->Pointer,
-                                &Ret_buffer->Length);
-*/
                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
                        "Packages as parameters not implemented!\n"));
 
@@ -625,13 +611,82 @@ acpi_ut_copy_eobject_to_iobject (
 }
 
 
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ut_copy_simple_object
+ *
+ * PARAMETERS:  Source_desc         - The internal object to be copied
+ *              Dest_desc           - New target object
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Simple copy of one internal object to another.  Reference count
+ *              of the destination object is preserved.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ut_copy_simple_object (
+       acpi_operand_object     *source_desc,
+       acpi_operand_object     *dest_desc)
+{
+       u16                     reference_count;
+       acpi_operand_object     *next_object;
+
+
+       /* Save fields from destination that we don't want to overwrite */
+
+       reference_count = dest_desc->common.reference_count;
+       next_object = dest_desc->common.next_object;
+
+       /* Copy the entire source object over the destination object*/
+
+       ACPI_MEMCPY ((char *) dest_desc, (char *) source_desc, sizeof (acpi_operand_object));
+
+       /* Restore the saved fields */
+
+       dest_desc->common.reference_count = reference_count;
+       dest_desc->common.next_object = next_object;
+
+       /* Handle the objects with extra data */
+
+       switch (dest_desc->common.type) {
+       case ACPI_TYPE_BUFFER:
+
+               dest_desc->buffer.node = NULL;
+
+       case ACPI_TYPE_STRING:
+
+               /*
+                * Allocate and copy the actual string if and only if:
+                * 1) There is a valid string (length > 0)
+                * 2) The string is not static (not in an ACPI table) (in this case,
+                *    the actual pointer was already copied above)
+                */
+               if ((source_desc->string.length) &&
+                       (!(source_desc->common.flags & AOPOBJ_STATIC_POINTER))) {
+                       dest_desc->string.pointer = ACPI_MEM_ALLOCATE (source_desc->string.length);
+                       if (!dest_desc->string.pointer) {
+                               return (AE_NO_MEMORY);
+                       }
+
+                       ACPI_MEMCPY (dest_desc->string.pointer, source_desc->string.pointer,
+                                         source_desc->string.length);
+               }
+               break;
+       }
+
+       return (AE_OK);
+}
+
+
 /*******************************************************************************
  *
  * FUNCTION:    Acpi_ut_copy_ielement_to_ielement
  *
  * PARAMETERS:  ACPI_PKG_CALLBACK
  *
- * RETURN:      Status          - the status of the call
+ * RETURN:      Status
  *
  * DESCRIPTION: Copy one package element to another package element
  *
@@ -650,7 +705,7 @@ acpi_ut_copy_ielement_to_ielement (
        acpi_operand_object     *target_object;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        this_index    = state->pkg.index;
@@ -668,8 +723,7 @@ acpi_ut_copy_ielement_to_ielement (
                        return (AE_NO_MEMORY);
                }
 
-               status = acpi_ex_store_object_to_object (source_object, target_object,
-                                 (acpi_walk_state *) context);
+               status = acpi_ut_copy_simple_object (source_object, target_object);
                if (ACPI_FAILURE (status)) {
                        return (status);
                }
@@ -679,14 +733,13 @@ acpi_ut_copy_ielement_to_ielement (
 
 
        case 1:
+
                /*
                 * This object is a package - go down another nesting level
                 * Create and build the package object
                 */
                target_object = acpi_ut_create_internal_object (ACPI_TYPE_PACKAGE);
                if (!target_object) {
-                       /* TBD: must delete package created up to this point */
-
                        return (AE_NO_MEMORY);
                }
 
@@ -703,11 +756,11 @@ acpi_ut_copy_ielement_to_ielement (
                *this_target_ptr = target_object;
                break;
 
+
        default:
                return (AE_BAD_PARAMETER);
        }
 
-
        return (status);
 }
 
@@ -735,7 +788,7 @@ acpi_ut_copy_ipackage_to_ipackage (
        acpi_status             status = AE_OK;
 
 
-       FUNCTION_TRACE ("Ut_copy_ipackage_to_ipackage");
+       ACPI_FUNCTION_TRACE ("Ut_copy_ipackage_to_ipackage");
 
 
        dest_obj->common.type   = source_obj->common.type;
@@ -747,18 +800,76 @@ acpi_ut_copy_ipackage_to_ipackage (
         */
        dest_obj->package.elements = ACPI_MEM_CALLOCATE ((source_obj->package.count + 1) *
                         sizeof (void *));
-       dest_obj->package.next_element = dest_obj->package.elements;
-
        if (!dest_obj->package.elements) {
-               REPORT_ERROR (
+               ACPI_REPORT_ERROR (
                        ("Aml_build_copy_internal_package_object: Package allocation failure\n"));
                return_ACPI_STATUS (AE_NO_MEMORY);
        }
 
+       /* Init */
 
+       dest_obj->package.next_element = dest_obj->package.elements;
+
+       /*
+        * Copy the package element-by-element by walking the package "tree".
+        * This handles nested packages of arbitrary depth.
+        */
        status = acpi_ut_walk_package_tree (source_obj, dest_obj,
                         acpi_ut_copy_ielement_to_ielement, walk_state);
+       if (ACPI_FAILURE (status)) {
+               /* On failure, delete the destination package object */
+
+               acpi_ut_remove_reference (dest_obj);
+       }
+
+       return_ACPI_STATUS (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ut_copy_iobject_to_iobject
+ *
+ * PARAMETERS:  Walk_state          - Current walk state
+ *              Source_desc         - The internal object to be copied
+ *              Dest_desc           - Where the copied object is returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Copy an internal object to a new internal object
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ut_copy_iobject_to_iobject (
+       acpi_operand_object     *source_desc,
+       acpi_operand_object     **dest_desc,
+       acpi_walk_state         *walk_state)
+{
+       acpi_status             status = AE_OK;
+
+
+       ACPI_FUNCTION_TRACE ("Ut_copy_iobject_to_iobject");
+
+
+       /* Create the top level object */
+
+       *dest_desc = acpi_ut_create_internal_object (source_desc->common.type);
+       if (!*dest_desc) {
+               return_ACPI_STATUS (AE_NO_MEMORY);
+       }
+
+       /* Copy the object and possible subobjects */
+
+       if (source_desc->common.type == ACPI_TYPE_PACKAGE) {
+               status = acpi_ut_copy_ipackage_to_ipackage (source_desc, *dest_desc,
+                                 walk_state);
+       }
+       else {
+               status = acpi_ut_copy_simple_object (source_desc, *dest_desc);
+       }
 
        return_ACPI_STATUS (status);
 }
 
+
index 5c88a04d48ab0ea2385e4b668649abf182ae2190..4a40ec51fc5d9f6773c6d2eec5aebb1148a5b119 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: utdebug - Debug print routines
- *              $Revision: 90 $
+ *              $Revision: 96 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -27,7 +27,7 @@
 #include "acpi.h"
 
 #define _COMPONENT          ACPI_UTILITIES
-        MODULE_NAME         ("utdebug")
+        ACPI_MODULE_NAME    ("utdebug")
 
 
 u32             acpi_gbl_prev_thread_id = 0xFFFFFFFF;
@@ -57,7 +57,7 @@ acpi_ut_init_stack_ptr_trace (
        u32                 current_sp;
 
 
-       acpi_gbl_entry_stack_pointer = (u32) &current_sp;
+       acpi_gbl_entry_stack_pointer = ACPI_PTR_DIFF (&current_sp, NULL);
 }
 
 
@@ -77,9 +77,10 @@ void
 acpi_ut_track_stack_ptr (
        void)
 {
-       u32                 current_sp;
+       ACPI_SIZE           current_sp;
+
 
-       current_sp = (u32) &current_sp;
+       current_sp = ACPI_PTR_DIFF (&current_sp, NULL);
 
        if (current_sp < acpi_gbl_lowest_stack_pointer) {
                acpi_gbl_lowest_stack_pointer = current_sp;
@@ -111,7 +112,7 @@ acpi_ut_track_stack_ptr (
  *
  ****************************************************************************/
 
-void
+void  ACPI_INTERNAL_VAR_XFACE
 acpi_ut_debug_print (
        u32                     requested_debug_level,
        u32                     line_number,
@@ -184,7 +185,7 @@ acpi_ut_debug_print (
  *
  ****************************************************************************/
 
-void
+void  ACPI_INTERNAL_VAR_XFACE
 acpi_ut_debug_print_raw (
        u32                     requested_debug_level,
        u32                     line_number,
@@ -431,7 +432,8 @@ acpi_ut_value_exit (
 {
 
        acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info,
-                       "%s %8.8X%8.8X\n", acpi_gbl_fn_exit_str, HIDWORD(value), LODWORD(value));
+                       "%s %8.8X%8.8X\n", acpi_gbl_fn_exit_str,
+                       ACPI_HIDWORD (value), ACPI_LODWORD (value));
 
        acpi_gbl_nesting_level--;
 }
@@ -539,8 +541,8 @@ acpi_ut_dump_buffer (
 
                        case DB_WORD_DISPLAY:
 
-                               MOVE_UNALIGNED16_TO_32 (&temp32,
-                                                &buffer[i + j]);
+                               ACPI_MOVE_UNALIGNED16_TO_32 (&temp32,
+                                                  &buffer[i + j]);
                                acpi_os_printf ("%04X ", temp32);
                                j += 2;
                                break;
@@ -548,8 +550,8 @@ acpi_ut_dump_buffer (
 
                        case DB_DWORD_DISPLAY:
 
-                               MOVE_UNALIGNED32_TO_32 (&temp32,
-                                                &buffer[i + j]);
+                               ACPI_MOVE_UNALIGNED32_TO_32 (&temp32,
+                                                  &buffer[i + j]);
                                acpi_os_printf ("%08X ", temp32);
                                j += 4;
                                break;
@@ -557,12 +559,12 @@ acpi_ut_dump_buffer (
 
                        case DB_QWORD_DISPLAY:
 
-                               MOVE_UNALIGNED32_TO_32 (&temp32,
-                                                &buffer[i + j]);
+                               ACPI_MOVE_UNALIGNED32_TO_32 (&temp32,
+                                                  &buffer[i + j]);
                                acpi_os_printf ("%08X", temp32);
 
-                               MOVE_UNALIGNED32_TO_32 (&temp32,
-                                                &buffer[i + j + 4]);
+                               ACPI_MOVE_UNALIGNED32_TO_32 (&temp32,
+                                                  &buffer[i + j + 4]);
                                acpi_os_printf ("%08X ", temp32);
                                j += 8;
                                break;
index 6b00c5243ca79cc216675accbdb05c47142f13b1..fa89145d5b83a5244bd1b6c3e54fcf7ab7d6036d 100644 (file)
@@ -1,12 +1,12 @@
 /*******************************************************************************
  *
  * Module Name: utdelete - object deletion and reference count utilities
- *              $Revision: 81 $
+ *              $Revision: 87 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -31,7 +31,7 @@
 #include "acparser.h"
 
 #define _COMPONENT          ACPI_UTILITIES
-        MODULE_NAME         ("utdelete")
+        ACPI_MODULE_NAME    ("utdelete")
 
 
 /*******************************************************************************
@@ -53,9 +53,10 @@ acpi_ut_delete_internal_obj (
 {
        void                    *obj_pointer = NULL;
        acpi_operand_object     *handler_desc;
+       acpi_operand_object     *second_desc;
 
 
-       FUNCTION_TRACE_PTR ("Ut_delete_internal_obj", object);
+       ACPI_FUNCTION_TRACE_PTR ("Ut_delete_internal_obj", object);
 
 
        if (!object) {
@@ -138,7 +139,6 @@ acpi_ut_delete_internal_obj (
                        acpi_os_delete_semaphore (object->method.semaphore);
                        object->method.semaphore = NULL;
                }
-
                break;
 
 
@@ -146,7 +146,8 @@ acpi_ut_delete_internal_obj (
 
                ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "***** Region %p\n", object));
 
-               if (object->region.extra) {
+               second_desc = acpi_ns_get_secondary_object (object);
+               if (second_desc) {
                        /*
                         * Free the Region_context if and only if the handler is one of the
                         * default handlers -- and therefore, we created the context object
@@ -154,13 +155,13 @@ acpi_ut_delete_internal_obj (
                         */
                        handler_desc = object->region.addr_handler;
                        if ((handler_desc) &&
-                               (handler_desc->addr_handler.hflags == ADDR_HANDLER_DEFAULT_INSTALLED)) {
-                               obj_pointer = object->region.extra->extra.region_context;
+                               (handler_desc->addr_handler.hflags == ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) {
+                               obj_pointer = second_desc->extra.region_context;
                        }
 
                        /* Now we can free the Extra object */
 
-                       acpi_ut_delete_object_desc (object->region.extra);
+                       acpi_ut_delete_object_desc (second_desc);
                }
                break;
 
@@ -169,38 +170,32 @@ acpi_ut_delete_internal_obj (
 
                ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "***** Buffer Field %p\n", object));
 
-               if (object->buffer_field.extra) {
-                       acpi_ut_delete_object_desc (object->buffer_field.extra);
+               second_desc = acpi_ns_get_secondary_object (object);
+               if (second_desc) {
+                       acpi_ut_delete_object_desc (second_desc);
                }
                break;
 
+
        default:
                break;
        }
 
 
-       /*
-        * Delete any allocated memory found above
-        */
+       /* Free any allocated memory (pointer within the object) found above */
+
        if (obj_pointer) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Deleting Obj Ptr %p \n", obj_pointer));
+               ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Deleting Object Subptr %p\n",
+                               obj_pointer));
                ACPI_MEM_FREE (obj_pointer);
        }
 
-       /* Only delete the object if it was dynamically allocated */
-
-       if (object->common.flags & AOPOBJ_STATIC_ALLOCATION) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Object %p [%s] static allocation, no delete\n",
-                       object, acpi_ut_get_type_name (object->common.type)));
-       }
+       /* Now the object can be safely deleted */
 
-       if (!(object->common.flags & AOPOBJ_STATIC_ALLOCATION)) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Deleting object %p [%s]\n",
+       ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Deleting Object %p [%s]\n",
                        object, acpi_ut_get_type_name (object->common.type)));
 
-               acpi_ut_delete_object_desc (object);
-       }
-
+       acpi_ut_delete_object_desc (object);
        return_VOID;
 }
 
@@ -225,7 +220,7 @@ acpi_ut_delete_internal_object_list (
        acpi_operand_object     **internal_obj;
 
 
-       FUNCTION_TRACE ("Ut_delete_internal_object_list");
+       ACPI_FUNCTION_TRACE ("Ut_delete_internal_object_list");
 
 
        /* Walk the null-terminated internal list */
@@ -264,7 +259,7 @@ acpi_ut_update_ref_count (
        u16                     new_count;
 
 
-       PROC_NAME ("Ut_update_ref_count");
+       ACPI_FUNCTION_NAME ("Ut_update_ref_count");
 
        if (!object) {
                return;
@@ -386,7 +381,7 @@ acpi_ut_update_object_reference (
        acpi_generic_state       *state;
 
 
-       FUNCTION_TRACE_PTR ("Ut_update_object_reference", object);
+       ACPI_FUNCTION_TRACE_PTR ("Ut_update_object_reference", object);
 
 
        /* Ignore a null object ptr */
@@ -395,16 +390,14 @@ acpi_ut_update_object_reference (
                return_ACPI_STATUS (AE_OK);
        }
 
-
        /*
-        * Make sure that this isn't a namespace handle or an AML pointer
+        * Make sure that this isn't a namespace handle
         */
-       if (VALID_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_NAMED)) {
+       if (ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED) {
                ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Object %p is NS handle\n", object));
                return_ACPI_STATUS (AE_OK);
        }
 
-
        state = acpi_ut_create_update_state (object, action);
 
        while (state) {
@@ -417,7 +410,6 @@ acpi_ut_update_object_reference (
                 * Different object types have different subobjects.
                 */
                switch (object->common.type) {
-
                case ACPI_TYPE_DEVICE:
 
                        status = acpi_ut_create_update_state_and_push (object->device.addr_handler,
@@ -490,7 +482,7 @@ acpi_ut_update_object_reference (
                case INTERNAL_TYPE_BANK_FIELD:
 
                        status = acpi_ut_create_update_state_and_push (
-                                        object->bank_field.bank_register_obj, action, &state_list);
+                                        object->bank_field.bank_obj, action, &state_list);
                        if (ACPI_FAILURE (status)) {
                                return_ACPI_STATUS (status);
                        }
@@ -526,7 +518,6 @@ acpi_ut_update_object_reference (
                        break;
                }
 
-
                /*
                 * Now we can update the count in the main object.  This can only
                 * happen after we update the sub-objects in case this causes the
@@ -534,13 +525,11 @@ acpi_ut_update_object_reference (
                 */
                acpi_ut_update_ref_count (object, action);
 
-
                /* Move on to the next object to be updated */
 
                state = acpi_ut_pop_generic_state (&state_list);
        }
 
-
        return_ACPI_STATUS (AE_OK);
 }
 
@@ -563,7 +552,7 @@ acpi_ut_add_reference (
        acpi_operand_object     *object)
 {
 
-       FUNCTION_TRACE_PTR ("Ut_add_reference", object);
+       ACPI_FUNCTION_TRACE_PTR ("Ut_add_reference", object);
 
 
        /*
@@ -599,7 +588,7 @@ acpi_ut_remove_reference (
        acpi_operand_object     *object)
 {
 
-       FUNCTION_TRACE_PTR ("Ut_remove_reference", object);
+       ACPI_FUNCTION_TRACE_PTR ("Ut_remove_reference", object);
 
        /*
         * Allow a NULL pointer to be passed in, just ignore it.  This saves
@@ -607,7 +596,7 @@ acpi_ut_remove_reference (
         *
         */
        if (!object ||
-               (VALID_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_NAMED))) {
+               (ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED)) {
                return_VOID;
        }
 
index b3bd999d88e8b3834bca46ee7a95e36b6d447fcc..26767fb208ead0f1d1e1dcccf5ec5344f07803c1 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: uteval - Object evaluation
- *              $Revision: 31 $
+ *              $Revision: 37 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@
 
 
 #define _COMPONENT          ACPI_UTILITIES
-        MODULE_NAME         ("uteval")
+        ACPI_MODULE_NAME    ("uteval")
 
 
 /*******************************************************************************
@@ -60,7 +60,7 @@ acpi_ut_evaluate_numeric_object (
        acpi_status             status;
 
 
-       FUNCTION_TRACE ("Ut_evaluate_numeric_object");
+       ACPI_FUNCTION_TRACE ("Ut_evaluate_numeric_object");
 
 
        /* Execute the method */
@@ -69,11 +69,11 @@ acpi_ut_evaluate_numeric_object (
        if (ACPI_FAILURE (status)) {
                if (status == AE_NOT_FOUND) {
                        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s on %4.4s was not found\n",
-                               object_name, (char*)&device_node->name));
+                               object_name, (char *) &device_node->name));
                }
                else {
                        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s on %4.4s failed with status %s\n",
-                               object_name, (char*)&device_node->name,
+                               object_name, (char *) &device_node->name,
                                acpi_format_exception (status)));
                }
 
@@ -138,7 +138,7 @@ acpi_ut_execute_HID (
        acpi_status             status;
 
 
-       FUNCTION_TRACE ("Ut_execute_HID");
+       ACPI_FUNCTION_TRACE ("Ut_execute_HID");
 
 
        /* Execute the method */
@@ -148,12 +148,11 @@ acpi_ut_execute_HID (
        if (ACPI_FAILURE (status)) {
                if (status == AE_NOT_FOUND) {
                        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "_HID on %4.4s was not found\n",
-                               (char*)&device_node->name));
+                               (char *) &device_node->name));
                }
-
                else {
                        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "_HID on %4.4s failed %s\n",
-                               (char*)&device_node->name, acpi_format_exception (status)));
+                               (char *) &device_node->name, acpi_format_exception (status)));
                }
 
                return_ACPI_STATUS (status);
@@ -177,21 +176,111 @@ acpi_ut_execute_HID (
                        "Type returned from _HID not a number or string: %s(%X) \n",
                        acpi_ut_get_type_name (obj_desc->common.type), obj_desc->common.type));
        }
-
        else {
                if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
                        /* Convert the Numeric HID to string */
 
                        acpi_ex_eisa_id_to_string ((u32) obj_desc->integer.value, hid->buffer);
                }
-
                else {
                        /* Copy the String HID from the returned object */
 
-                       STRNCPY(hid->buffer, obj_desc->string.pointer, sizeof(hid->buffer));
+                       ACPI_STRNCPY (hid->buffer, obj_desc->string.pointer, sizeof(hid->buffer));
+               }
+       }
+
+       /* On exit, we must delete the return object */
+
+       acpi_ut_remove_reference (obj_desc);
+
+       return_ACPI_STATUS (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ut_execute_CID
+ *
+ * PARAMETERS:  Device_node         - Node for the device
+ *              *Cid                - Where the CID is returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Executes the _CID control method that returns one or more
+ *              compatible hardware IDs for the device.
+ *
+ *              NOTE: Internal function, no parameter validation
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ut_execute_CID (
+       acpi_namespace_node     *device_node,
+       acpi_device_id          *cid)
+{
+       acpi_operand_object     *obj_desc;
+       acpi_status             status;
+
+
+       ACPI_FUNCTION_TRACE ("Ut_execute_CID");
+
+       /* Execute the method */
+
+       status = acpi_ns_evaluate_relative (device_node,
+                        METHOD_NAME__CID, NULL, &obj_desc);
+       if (ACPI_FAILURE (status)) {
+               if (status == AE_NOT_FOUND) {
+                       ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "_CID on %4.4s was not found\n",
+                               (char *)&device_node->name));
                }
+               else {
+                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "_CID on %4.4s failed %s\n",
+                               (char *)&device_node->name, acpi_format_exception (status)));
+               }
+
+               return_ACPI_STATUS (status);
        }
 
+       /* Did we get a return object? */
+
+       if (!obj_desc) {
+               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No object was returned from _CID\n"));
+               return_ACPI_STATUS (AE_TYPE);
+       }
+
+       /*
+        *  A _CID can return either a single compatible ID or a package of compatible
+        *  IDs.  Each compatible ID can be a Number (32 bit compressed EISA ID) or
+        *  string (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss").
+        */
+       switch (obj_desc->common.type) {
+       case ACPI_TYPE_INTEGER:
+
+               /* Convert the Numeric CID to string */
+
+               acpi_ex_eisa_id_to_string ((u32) obj_desc->integer.value, cid->buffer);
+               break;
+
+       case ACPI_TYPE_STRING:
+
+               /* Copy the String CID from the returned object */
+
+               ACPI_STRNCPY (cid->buffer, obj_desc->string.pointer, sizeof(cid->buffer));
+               break;
+
+       case ACPI_TYPE_PACKAGE:
+
+               /* TBD: Parse package elements; need different return struct, etc. */
+               break;
+
+       default:
+
+               status = AE_TYPE;
+               ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+                       "Type returned from _CID not a number, string, or package: %s(%X) \n",
+                       acpi_ut_get_type_name (obj_desc->common.type), obj_desc->common.type));
+               break;
+       }
 
        /* On exit, we must delete the return object */
 
@@ -226,7 +315,7 @@ acpi_ut_execute_UID (
        acpi_status             status;
 
 
-       PROC_NAME ("Ut_execute_UID");
+       ACPI_FUNCTION_NAME ("Ut_execute_UID");
 
 
        /* Execute the method */
@@ -236,13 +325,12 @@ acpi_ut_execute_UID (
        if (ACPI_FAILURE (status)) {
                if (status == AE_NOT_FOUND) {
                        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "_UID on %4.4s was not found\n",
-                               (char*)&device_node->name));
+                               (char *) &device_node->name));
                }
-
                else {
                        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
                                "_UID on %4.4s failed %s\n",
-                               (char*)&device_node->name, acpi_format_exception (status)));
+                               (char *) &device_node->name, acpi_format_exception (status)));
                }
 
                return (status);
@@ -266,18 +354,16 @@ acpi_ut_execute_UID (
                        "Type returned from _UID was not a number or string: %X \n",
                        obj_desc->common.type));
        }
-
        else {
                if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
                        /* Convert the Numeric UID to string */
 
                        acpi_ex_unsigned_integer_to_string (obj_desc->integer.value, uid->buffer);
                }
-
                else {
                        /* Copy the String UID from the returned object */
 
-                       STRNCPY(uid->buffer, obj_desc->string.pointer, sizeof(uid->buffer));
+                       ACPI_STRNCPY (uid->buffer, obj_desc->string.pointer, sizeof(uid->buffer));
                }
        }
 
@@ -315,7 +401,7 @@ acpi_ut_execute_STA (
        acpi_status             status;
 
 
-       FUNCTION_TRACE ("Ut_execute_STA");
+       ACPI_FUNCTION_TRACE ("Ut_execute_STA");
 
 
        /* Execute the method */
@@ -325,7 +411,7 @@ acpi_ut_execute_STA (
        if (AE_NOT_FOUND == status) {
                ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
                        "_STA on %4.4s was not found, assuming present.\n",
-                       (char*)&device_node->name));
+                       (char *) &device_node->name));
 
                *flags = 0x0F;
                status = AE_OK;
@@ -333,7 +419,7 @@ acpi_ut_execute_STA (
 
        else if (ACPI_FAILURE (status)) {
                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "_STA on %4.4s failed %s\n",
-                       (char*)&device_node->name,
+                       (char *) &device_node->name,
                        acpi_format_exception (status)));
        }
 
@@ -353,7 +439,6 @@ acpi_ut_execute_STA (
                                "Type returned from _STA was not a number: %X \n",
                                obj_desc->common.type));
                }
-
                else {
                        /* Extract the status flags */
 
index 4a4ff5cf3dd49e62323cc3f26c6aa9b8087aef02..d22c2ebe9e837c5e76f7c74d212b28ae8d6df154 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: utglobal - Global variables for the ACPI subsystem
- *              $Revision: 133 $
+ *              $Revision: 153 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -33,7 +33,7 @@
 
 
 #define _COMPONENT          ACPI_UTILITIES
-        MODULE_NAME         ("utglobal")
+        ACPI_MODULE_NAME    ("utglobal")
 
 
 /******************************************************************************
@@ -136,10 +136,9 @@ u8                          acpi_gbl_method_executing = FALSE;
 
 /* System flags */
 
-u32                         acpi_gbl_system_flags = 0;
 u32                         acpi_gbl_startup_flags = 0;
 
-/* System starts unitialized! */
+/* System starts uninitialized */
 
 u8                          acpi_gbl_shutdown = TRUE;
 
@@ -168,7 +167,7 @@ const NATIVE_CHAR           *acpi_gbl_db_sleep_states[ACPI_NUM_SLEEP_STATES] = {
  *    during the initialization sequence.
  */
 
-const predefined_names      acpi_gbl_pre_defined_names[] =
+const acpi_predefined_names     acpi_gbl_pre_defined_names[] =
 { {"_GPE",    INTERNAL_TYPE_DEF_ANY},
        {"_PR_",    INTERNAL_TYPE_DEF_ANY},
        {"_SB_",    ACPI_TYPE_DEVICE},
@@ -188,44 +187,45 @@ const predefined_names      acpi_gbl_pre_defined_names[] =
  * and the table is indexed by values of acpi_object_type
  */
 
-const u8                    acpi_gbl_ns_properties[] =
+const u8                        acpi_gbl_ns_properties[] =
 {
-       NSP_NORMAL,                 /* 00 Any              */
-       NSP_NORMAL,                 /* 01 Number           */
-       NSP_NORMAL,                 /* 02 String           */
-       NSP_NORMAL,                 /* 03 Buffer           */
-       NSP_LOCAL,                  /* 04 Package          */
-       NSP_NORMAL,                 /* 05 Field_unit       */
-       NSP_NEWSCOPE | NSP_LOCAL,   /* 06 Device           */
-       NSP_LOCAL,                  /* 07 Acpi_event       */
-       NSP_NEWSCOPE | NSP_LOCAL,   /* 08 Method           */
-       NSP_LOCAL,                  /* 09 Mutex            */
-       NSP_LOCAL,                  /* 10 Region           */
-       NSP_NEWSCOPE | NSP_LOCAL,   /* 11 Power            */
-       NSP_NEWSCOPE | NSP_LOCAL,   /* 12 Processor        */
-       NSP_NEWSCOPE | NSP_LOCAL,   /* 13 Thermal          */
-       NSP_NORMAL,                 /* 14 Buffer_field     */
-       NSP_NORMAL,                 /* 15 Ddb_handle       */
-       NSP_NORMAL,                 /* 16 Debug Object     */
-       NSP_NORMAL,                 /* 17 Def_field        */
-       NSP_NORMAL,                 /* 18 Bank_field       */
-       NSP_NORMAL,                 /* 19 Index_field      */
-       NSP_NORMAL,                 /* 20 Reference        */
-       NSP_NORMAL,                 /* 21 Alias            */
-       NSP_NORMAL,                 /* 22 Notify           */
-       NSP_NORMAL,                 /* 23 Address Handler  */
-       NSP_NEWSCOPE | NSP_LOCAL,   /* 24 Resource Desc    */
-       NSP_NEWSCOPE | NSP_LOCAL,   /* 25 Resource Field   */
-       NSP_NORMAL,                 /* 26 Def_field_defn   */
-       NSP_NORMAL,                 /* 27 Bank_field_defn  */
-       NSP_NORMAL,                 /* 28 Index_field_defn */
-       NSP_NORMAL,                 /* 29 If               */
-       NSP_NORMAL,                 /* 30 Else             */
-       NSP_NORMAL,                 /* 31 While            */
-       NSP_NEWSCOPE,               /* 32 Scope            */
-       NSP_LOCAL,                  /* 33 Def_any          */
-       NSP_NORMAL,                 /* 34 Extra            */
-       NSP_NORMAL                  /* 35 Invalid          */
+       ACPI_NS_NORMAL,                     /* 00 Any              */
+       ACPI_NS_NORMAL,                     /* 01 Number           */
+       ACPI_NS_NORMAL,                     /* 02 String           */
+       ACPI_NS_NORMAL,                     /* 03 Buffer           */
+       ACPI_NS_LOCAL,                      /* 04 Package          */
+       ACPI_NS_NORMAL,                     /* 05 Field_unit       */
+       ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL,   /* 06 Device           */
+       ACPI_NS_LOCAL,                      /* 07 Acpi_event       */
+       ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL,   /* 08 Method           */
+       ACPI_NS_LOCAL,                      /* 09 Mutex            */
+       ACPI_NS_LOCAL,                      /* 10 Region           */
+       ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL,   /* 11 Power            */
+       ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL,   /* 12 Processor        */
+       ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL,   /* 13 Thermal          */
+       ACPI_NS_NORMAL,                     /* 14 Buffer_field     */
+       ACPI_NS_NORMAL,                     /* 15 Ddb_handle       */
+       ACPI_NS_NORMAL,                     /* 16 Debug Object     */
+       ACPI_NS_NORMAL,                     /* 17 Def_field        */
+       ACPI_NS_NORMAL,                     /* 18 Bank_field       */
+       ACPI_NS_NORMAL,                     /* 19 Index_field      */
+       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_NORMAL,                     /* 26 Def_field_defn   */
+       ACPI_NS_NORMAL,                     /* 27 Bank_field_defn  */
+       ACPI_NS_NORMAL,                     /* 28 Index_field_defn */
+       ACPI_NS_NORMAL,                     /* 29 If               */
+       ACPI_NS_NORMAL,                     /* 30 Else             */
+       ACPI_NS_NORMAL,                     /* 31 While            */
+       ACPI_NS_NEWSCOPE,                   /* 32 Scope            */
+       ACPI_NS_LOCAL,                      /* 33 Def_any          */
+       ACPI_NS_NORMAL,                     /* 34 Extra            */
+       ACPI_NS_NORMAL,                     /* 35 Data             */
+       ACPI_NS_NORMAL                      /* 36 Invalid          */
 };
 
 
@@ -261,12 +261,15 @@ acpi_ut_hex_to_ascii_char (
 
 /******************************************************************************
  *
- * Table globals
+ * Table name globals
  *
  * NOTE: This table includes ONLY the ACPI tables that the subsystem consumes.
  * it is NOT an exhaustive list of all possible ACPI tables.  All ACPI tables
  * that are not used by the subsystem are simply ignored.
  *
+ * Do NOT add any table to this list that is not consumed directly by this
+ * subsystem.
+ *
  ******************************************************************************/
 
 
@@ -275,18 +278,147 @@ acpi_table_desc             acpi_gbl_acpi_tables[NUM_ACPI_TABLES];
 
 ACPI_TABLE_SUPPORT          acpi_gbl_acpi_table_data[NUM_ACPI_TABLES] =
 {
-       /***********    Name,    Signature,  Signature size,    How many allowed?,   Supported?  Global typed pointer */
-
-       /* RSDP 0 */ {RSDP_NAME, RSDP_SIG, sizeof (RSDP_SIG)-1, ACPI_TABLE_SINGLE,   AE_OK,      NULL},
-       /* DSDT 1 */ {DSDT_SIG,  DSDT_SIG, sizeof (DSDT_SIG)-1, ACPI_TABLE_SINGLE,   AE_OK,      (void **) &acpi_gbl_DSDT},
-       /* FADT 2 */ {FADT_SIG,  FADT_SIG, sizeof (FADT_SIG)-1, ACPI_TABLE_SINGLE,   AE_OK,      (void **) &acpi_gbl_FADT},
-       /* FACS 3 */ {FACS_SIG,  FACS_SIG, sizeof (FACS_SIG)-1, ACPI_TABLE_SINGLE,   AE_OK,      (void **) &acpi_gbl_FACS},
-       /* PSDT 4 */ {PSDT_SIG,  PSDT_SIG, sizeof (PSDT_SIG)-1, ACPI_TABLE_MULTIPLE, AE_OK,      NULL},
-       /* SSDT 5 */ {SSDT_SIG,  SSDT_SIG, sizeof (SSDT_SIG)-1, ACPI_TABLE_MULTIPLE, AE_OK,      NULL},
-       /* XSDT 6 */ {XSDT_SIG,  XSDT_SIG, sizeof (RSDT_SIG)-1, ACPI_TABLE_SINGLE,   AE_OK,      NULL},
+       /***********    Name,   Signature, Global typed pointer     Signature size,      How many allowed?,    Contains valid AML? */
+
+       /* RSDP 0 */ {RSDP_NAME, RSDP_SIG, NULL,                    sizeof (RSDP_SIG)-1, ACPI_TABLE_SINGLE},
+       /* DSDT 1 */ {DSDT_SIG,  DSDT_SIG, (void **) &acpi_gbl_DSDT, sizeof (DSDT_SIG)-1, ACPI_TABLE_SINGLE  | ACPI_TABLE_EXECUTABLE},
+       /* FADT 2 */ {FADT_SIG,  FADT_SIG, (void **) &acpi_gbl_FADT, sizeof (FADT_SIG)-1, ACPI_TABLE_SINGLE},
+       /* FACS 3 */ {FACS_SIG,  FACS_SIG, (void **) &acpi_gbl_FACS, sizeof (FACS_SIG)-1, ACPI_TABLE_SINGLE},
+       /* PSDT 4 */ {PSDT_SIG,  PSDT_SIG, NULL,                    sizeof (PSDT_SIG)-1, ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE},
+       /* SSDT 5 */ {SSDT_SIG,  SSDT_SIG, NULL,                    sizeof (SSDT_SIG)-1, ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE},
+       /* XSDT 6 */ {XSDT_SIG,  XSDT_SIG, NULL,                    sizeof (RSDT_SIG)-1, ACPI_TABLE_SINGLE},
+};
+
+
+/******************************************************************************
+ *
+ * Event and Hardware globals
+ *
+ ******************************************************************************/
+
+ACPI_BIT_REGISTER_INFO      acpi_gbl_bit_register_info[ACPI_NUM_BITREG] =
+{
+       /* Name                                     Parent Register             Register Bit Position                   Register Bit Mask       */
+
+       /* ACPI_BITREG_TIMER_STATUS         */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_TIMER_STATUS,          ACPI_BITMASK_TIMER_STATUS},
+       /* ACPI_BITREG_BUS_MASTER_STATUS    */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_BUS_MASTER_STATUS,     ACPI_BITMASK_BUS_MASTER_STATUS},
+       /* ACPI_BITREG_GLOBAL_LOCK_STATUS   */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_GLOBAL_LOCK_STATUS,    ACPI_BITMASK_GLOBAL_LOCK_STATUS},
+       /* ACPI_BITREG_POWER_BUTTON_STATUS  */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_POWER_BUTTON_STATUS,   ACPI_BITMASK_POWER_BUTTON_STATUS},
+       /* ACPI_BITREG_SLEEP_BUTTON_STATUS  */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_SLEEP_BUTTON_STATUS,   ACPI_BITMASK_SLEEP_BUTTON_STATUS},
+       /* ACPI_BITREG_RT_CLOCK_STATUS      */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_RT_CLOCK_STATUS,       ACPI_BITMASK_RT_CLOCK_STATUS},
+       /* ACPI_BITREG_WAKE_STATUS          */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_WAKE_STATUS,           ACPI_BITMASK_WAKE_STATUS},
+
+       /* ACPI_BITREG_TIMER_ENABLE         */   {ACPI_REGISTER_PM1_ENABLE,   ACPI_BITPOSITION_TIMER_ENABLE,          ACPI_BITMASK_TIMER_ENABLE},
+       /* ACPI_BITREG_GLOBAL_LOCK_ENABLE   */   {ACPI_REGISTER_PM1_ENABLE,   ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE,    ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
+       /* ACPI_BITREG_POWER_BUTTON_ENABLE  */   {ACPI_REGISTER_PM1_ENABLE,   ACPI_BITPOSITION_POWER_BUTTON_ENABLE,   ACPI_BITMASK_POWER_BUTTON_ENABLE},
+       /* ACPI_BITREG_SLEEP_BUTTON_ENABLE  */   {ACPI_REGISTER_PM1_ENABLE,   ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE,   ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
+       /* ACPI_BITREG_RT_CLOCK_ENABLE      */   {ACPI_REGISTER_PM1_ENABLE,   ACPI_BITPOSITION_RT_CLOCK_ENABLE,       ACPI_BITMASK_RT_CLOCK_ENABLE},
+       /* ACPI_BITREG_WAKE_ENABLE          */   {ACPI_REGISTER_PM1_ENABLE,   0,                                      0},
+
+       /* ACPI_BITREG_SCI_ENABLE           */   {ACPI_REGISTER_PM1_CONTROL,  ACPI_BITPOSITION_SCI_ENABLE,            ACPI_BITMASK_SCI_ENABLE},
+       /* ACPI_BITREG_BUS_MASTER_RLD       */   {ACPI_REGISTER_PM1_CONTROL,  ACPI_BITPOSITION_BUS_MASTER_RLD,        ACPI_BITMASK_BUS_MASTER_RLD},
+       /* ACPI_BITREG_GLOBAL_LOCK_RELEASE  */   {ACPI_REGISTER_PM1_CONTROL,  ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE,   ACPI_BITMASK_GLOBAL_LOCK_RELEASE},
+       /* ACPI_BITREG_SLEEP_TYPE_A         */   {ACPI_REGISTER_PM1_CONTROL,  ACPI_BITPOSITION_SLEEP_TYPE_X,          ACPI_BITMASK_SLEEP_TYPE_X},
+       /* ACPI_BITREG_SLEEP_TYPE_B         */   {ACPI_REGISTER_PM1_CONTROL,  ACPI_BITPOSITION_SLEEP_TYPE_X,          ACPI_BITMASK_SLEEP_TYPE_X},
+       /* ACPI_BITREG_SLEEP_ENABLE         */   {ACPI_REGISTER_PM1_CONTROL,  ACPI_BITPOSITION_SLEEP_ENABLE,          ACPI_BITMASK_SLEEP_ENABLE},
+
+       /* ACPI_BITREG_ARB_DIS              */   {ACPI_REGISTER_PM2_CONTROL,  ACPI_BITPOSITION_ARB_DISABLE,           ACPI_BITMASK_ARB_DISABLE}
 };
 
 
+acpi_fixed_event_info       acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] =
+{
+       /* ACPI_EVENT_PMTIMER       */  {ACPI_BITREG_TIMER_STATUS,          ACPI_BITREG_TIMER_ENABLE,        ACPI_BITMASK_TIMER_STATUS,          ACPI_BITMASK_TIMER_ENABLE},
+       /* ACPI_EVENT_GLOBAL        */  {ACPI_BITREG_GLOBAL_LOCK_STATUS,    ACPI_BITREG_GLOBAL_LOCK_ENABLE,  ACPI_BITMASK_GLOBAL_LOCK_STATUS,    ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
+       /* ACPI_EVENT_POWER_BUTTON  */  {ACPI_BITREG_POWER_BUTTON_STATUS,   ACPI_BITREG_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_STATUS,   ACPI_BITMASK_POWER_BUTTON_ENABLE},
+       /* ACPI_EVENT_SLEEP_BUTTON  */  {ACPI_BITREG_SLEEP_BUTTON_STATUS,   ACPI_BITREG_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_STATUS,   ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
+       /* ACPI_EVENT_RTC           */  {ACPI_BITREG_RT_CLOCK_STATUS,       ACPI_BITREG_RT_CLOCK_ENABLE,     0,                                  0},
+};
+
+/*****************************************************************************
+ *
+ * FUNCTION:    Acpi_ut_get_region_name
+ *
+ * PARAMETERS:  None.
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Translate a Space ID into a name string (Debug only)
+ *
+ ****************************************************************************/
+
+/* Region type decoding */
+
+const NATIVE_CHAR *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] =
+{
+       "System_memory",
+       "System_iO",
+       "PCIConfig",
+       "Embedded_control",
+       "SMBus",
+       "CMOS",
+       "PCIBar_target",
+       "Data_table",
+};
+
+
+NATIVE_CHAR *
+acpi_ut_get_region_name (
+       u8                      space_id)
+{
+
+       if (space_id >= ACPI_USER_REGION_BEGIN)
+       {
+               return ("User_defined_region");
+       }
+
+       else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS)
+       {
+               return ("Invalid_space_iD");
+       }
+
+       return ((NATIVE_CHAR *) acpi_gbl_region_types[space_id]);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION:    Acpi_ut_get_event_name
+ *
+ * PARAMETERS:  None.
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Translate a Event ID into a name string (Debug only)
+ *
+ ****************************************************************************/
+
+/* Event type decoding */
+
+const NATIVE_CHAR *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] =
+{
+       "PM_Timer",
+       "Global_lock",
+       "Power_button",
+       "Sleep_button",
+       "Real_time_clock",
+};
+
+
+NATIVE_CHAR *
+acpi_ut_get_event_name (
+       u32                     event_id)
+{
+
+       if (event_id > ACPI_EVENT_MAX)
+       {
+               return ("Invalid_event_iD");
+       }
+
+       return ((NATIVE_CHAR *) acpi_gbl_event_types[event_id]);
+}
+
+
 #ifdef ACPI_DEBUG
 
 /*
@@ -321,6 +453,18 @@ acpi_ut_get_mutex_name (
 }
 
 
+/*****************************************************************************
+ *
+ * FUNCTION:    Acpi_ut_get_type_name
+ *
+ * PARAMETERS:  None.
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Translate a Type ID into a name string (Debug only)
+ *
+ ****************************************************************************/
+
 /*
  * Elements of Acpi_gbl_Ns_type_names below must match
  * one-to-one with values of acpi_object_type
@@ -370,25 +514,14 @@ static const NATIVE_CHAR    *acpi_gbl_ns_type_names[] = /* printable names of AC
        /* 32 */ "Scope",
        /* 33 */ "Def_any",
        /* 34 */ "Extra",
-       /* 35 */ "Invalid"
+       /* 35 */ "Data",
+       /* 36 */ "Invalid"
 };
 
 
-/*****************************************************************************
- *
- * FUNCTION:    Acpi_ut_get_type_name
- *
- * PARAMETERS:  None.
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Translate a Type ID into a name string (Debug only)
- *
- ****************************************************************************/
-
 NATIVE_CHAR *
 acpi_ut_get_type_name (
-       u32                     type)
+       acpi_object_type        type)
 {
 
        if (type > INTERNAL_TYPE_INVALID)
@@ -400,51 +533,6 @@ acpi_ut_get_type_name (
 }
 
 
-/* Region type decoding */
-
-const NATIVE_CHAR *acpi_gbl_region_types[NUM_REGION_TYPES] =
-{
-       "System_memory",
-       "System_iO",
-       "PCIConfig",
-       "Embedded_control",
-       "SMBus",
-       "CMOS",
-       "PCIBar_target",
-};
-
-
-/*****************************************************************************
- *
- * FUNCTION:    Acpi_ut_get_region_name
- *
- * PARAMETERS:  None.
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Translate a Space ID into a name string (Debug only)
- *
- ****************************************************************************/
-
-NATIVE_CHAR *
-acpi_ut_get_region_name (
-       u8                      space_id)
-{
-
-       if (space_id >= USER_REGION_BEGIN)
-       {
-               return ("User_defined_region");
-       }
-
-       else if (space_id >= NUM_REGION_TYPES)
-       {
-               return ("Invalid_space_iD");
-       }
-
-       return ((NATIVE_CHAR *) acpi_gbl_region_types[space_id]);
-}
-
-
 /* Data used in keeping track of fields */
 
 const NATIVE_CHAR *acpi_gbl_FEnames[NUM_FIELD_NAMES] =
@@ -474,9 +562,8 @@ const NATIVE_CHAR *acpi_gbl_access_types[NUM_ACCESS_TYPES] =
        "Byte_acc",
        "Word_acc",
        "DWord_acc",
-       "Block_acc",
-       "SMBSend_recv_acc",
-       "SMBQuick_acc"
+       "QWord_acc",
+       "Buffer_acc",
 };
 
 
@@ -506,7 +593,7 @@ const NATIVE_CHAR *acpi_gbl_update_rules[NUM_UPDATE_RULES] =
 
 u8
 acpi_ut_valid_object_type (
-       u32                     type)
+       acpi_object_type        type)
 {
 
        if (type > ACPI_TYPE_MAX)
@@ -539,40 +626,41 @@ acpi_ut_allocate_owner_id (
        acpi_owner_id           owner_id = 0xFFFF;
 
 
-       FUNCTION_TRACE ("Ut_allocate_owner_id");
+       ACPI_FUNCTION_TRACE ("Ut_allocate_owner_id");
 
 
-       acpi_ut_acquire_mutex (ACPI_MTX_CACHES);
+       if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_CACHES)))
+       {
+               return (0);
+       }
 
        switch (id_type)
        {
-       case OWNER_TYPE_TABLE:
+       case ACPI_OWNER_TYPE_TABLE:
 
                owner_id = acpi_gbl_next_table_owner_id;
                acpi_gbl_next_table_owner_id++;
 
-               if (acpi_gbl_next_table_owner_id == FIRST_METHOD_ID)
+               if (acpi_gbl_next_table_owner_id == ACPI_FIRST_METHOD_ID)
                {
-                       acpi_gbl_next_table_owner_id = FIRST_TABLE_ID;
+                       acpi_gbl_next_table_owner_id = ACPI_FIRST_TABLE_ID;
                }
                break;
 
 
-       case OWNER_TYPE_METHOD:
+       case ACPI_OWNER_TYPE_METHOD:
 
                owner_id = acpi_gbl_next_method_owner_id;
                acpi_gbl_next_method_owner_id++;
 
-               if (acpi_gbl_next_method_owner_id == FIRST_TABLE_ID)
+               if (acpi_gbl_next_method_owner_id == ACPI_FIRST_TABLE_ID)
                {
-                       acpi_gbl_next_method_owner_id = FIRST_METHOD_ID;
+                       acpi_gbl_next_method_owner_id = ACPI_FIRST_METHOD_ID;
                }
                break;
        }
 
-
-       acpi_ut_release_mutex (ACPI_MTX_CACHES);
-
+       (void) acpi_ut_release_mutex (ACPI_MTX_CACHES);
        return_VALUE (owner_id);
 }
 
@@ -595,17 +683,17 @@ acpi_ut_init_globals (
        u32                     i;
 
 
-       FUNCTION_TRACE ("Ut_init_globals");
+       ACPI_FUNCTION_TRACE ("Ut_init_globals");
 
        /* Memory allocation and cache lists */
 
-       MEMSET (acpi_gbl_memory_lists, 0, sizeof (ACPI_MEMORY_LIST) * ACPI_NUM_MEM_LISTS);
+       ACPI_MEMSET (acpi_gbl_memory_lists, 0, sizeof (ACPI_MEMORY_LIST) * ACPI_NUM_MEM_LISTS);
 
-       acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].link_offset      = (u16) (NATIVE_UINT) &(((acpi_generic_state *) NULL)->common.next);
-       acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].link_offset     = (u16) (NATIVE_UINT) &(((acpi_parse_object *) NULL)->next);
-       acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].link_offset = (u16) (NATIVE_UINT) &(((acpi_parse2_object *) NULL)->next);
-       acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].link_offset    = (u16) (NATIVE_UINT) &(((acpi_operand_object *) NULL)->cache.next);
-       acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].link_offset       = (u16) (NATIVE_UINT) &(((acpi_walk_state *) NULL)->next);
+       acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].link_offset      = (u16) ACPI_PTR_DIFF (&(((acpi_generic_state *) NULL)->common.next), NULL);
+       acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].link_offset     = (u16) ACPI_PTR_DIFF (&(((acpi_parse_object *) NULL)->next), NULL);
+       acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].link_offset = (u16) ACPI_PTR_DIFF (&(((acpi_parse2_object *) NULL)->next), NULL);
+       acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].link_offset    = (u16) ACPI_PTR_DIFF (&(((acpi_operand_object *) NULL)->cache.next), NULL);
+       acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].link_offset       = (u16) ACPI_PTR_DIFF (&(((acpi_walk_state *) NULL)->next), NULL);
 
        acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].object_size     = sizeof (acpi_namespace_node);
        acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].object_size      = sizeof (acpi_generic_state);
@@ -640,15 +728,6 @@ acpi_ut_init_globals (
                acpi_gbl_acpi_tables[i].count       = 0;
        }
 
-
-       /* Address Space handler array */
-
-       for (i = 0; i < ACPI_NUM_ADDRESS_SPACES; i++)
-       {
-               acpi_gbl_address_spaces[i].handler  = NULL;
-               acpi_gbl_address_spaces[i].context  = NULL;
-       }
-
        /* Mutex locked flags */
 
        for (i = 0; i < NUM_MTX; i++)
@@ -675,11 +754,10 @@ acpi_ut_init_globals (
 
        acpi_gbl_global_lock_acquired       = FALSE;
        acpi_gbl_global_lock_thread_count   = 0;
+       acpi_gbl_global_lock_handle         = 0;
 
        /* Miscellaneous variables */
 
-       acpi_gbl_system_flags               = 0;
-       acpi_gbl_startup_flags              = 0;
        acpi_gbl_rsdp_original_location     = 0;
        acpi_gbl_cm_single_step             = FALSE;
        acpi_gbl_db_terminate_threads       = FALSE;
@@ -687,24 +765,22 @@ acpi_ut_init_globals (
        acpi_gbl_ns_lookup_count            = 0;
        acpi_gbl_ps_find_count              = 0;
        acpi_gbl_acpi_hardware_present      = TRUE;
-       acpi_gbl_next_table_owner_id        = FIRST_TABLE_ID;
-       acpi_gbl_next_method_owner_id       = FIRST_METHOD_ID;
+       acpi_gbl_next_table_owner_id        = ACPI_FIRST_TABLE_ID;
+       acpi_gbl_next_method_owner_id       = ACPI_FIRST_METHOD_ID;
        acpi_gbl_debugger_configuration     = DEBUGGER_THREADING;
+       acpi_gbl_db_output_flags            = ACPI_DB_CONSOLE_OUTPUT;
 
        /* Hardware oriented */
 
-       acpi_gbl_gpe0enable_register_save   = NULL;
-       acpi_gbl_gpe1_enable_register_save  = NULL;
-       acpi_gbl_original_mode              = SYS_MODE_UNKNOWN;   /*  original ACPI/legacy mode   */
-       acpi_gbl_gpe_registers              = NULL;
-       acpi_gbl_gpe_info                   = NULL;
+       acpi_gbl_gpe_register_info          = NULL;
+       acpi_gbl_gpe_number_info            = NULL;
 
        /* Namespace */
 
        acpi_gbl_root_node                  = NULL;
 
        acpi_gbl_root_node_struct.name      = ACPI_ROOT_NAME;
-       acpi_gbl_root_node_struct.data_type = ACPI_DESC_TYPE_NAMED;
+       acpi_gbl_root_node_struct.descriptor = ACPI_DESC_TYPE_NAMED;
        acpi_gbl_root_node_struct.type      = ACPI_TYPE_ANY;
        acpi_gbl_root_node_struct.child     = NULL;
        acpi_gbl_root_node_struct.peer      = NULL;
index 5e3ef7f9d439fb368d0ed83e42d548f3220999b2..108b922126142ecc0032e098c2255982f1d8e97a 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: utinit - Common ACPI subsystem initialization
- *              $Revision: 102 $
+ *              $Revision: 109 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 #include "achware.h"
 #include "acnamesp.h"
 #include "acevents.h"
-#include "acparser.h"
-#include "acdispat.h"
 
 #define _COMPONENT          ACPI_UTILITIES
-        MODULE_NAME         ("utinit")
-
-
-#define ACPI_OFFSET(d,o)    ((u32) &(((d *)0)->o))
-#define ACPI_FADT_OFFSET(o) ACPI_OFFSET (FADT_DESCRIPTOR, o)
+        ACPI_MODULE_NAME    ("utinit")
 
 
 /*******************************************************************************
  *
  ******************************************************************************/
 
-static acpi_status
+static void
 acpi_ut_fadt_register_error (
        NATIVE_CHAR             *register_name,
        u32                     value,
-       u32                     offset)
+       ACPI_SIZE               offset)
 {
 
-       REPORT_ERROR (
+       ACPI_REPORT_WARNING (
                ("Invalid FADT value %s=%lX at offset %lX FADT=%p\n",
                register_name, value, offset, acpi_gbl_FADT));
-
-
-       return (AE_BAD_VALUE);
 }
 
 
@@ -86,69 +77,67 @@ acpi_status
 acpi_ut_validate_fadt (
        void)
 {
-       acpi_status                 status = AE_OK;
-
 
        /*
         * Verify Fixed ACPI Description Table fields,
         * but don't abort on any problems, just display error
         */
        if (acpi_gbl_FADT->pm1_evt_len < 4) {
-               status = acpi_ut_fadt_register_error ("PM1_EVT_LEN",
+               acpi_ut_fadt_register_error ("PM1_EVT_LEN",
                                  (u32) acpi_gbl_FADT->pm1_evt_len,
                                  ACPI_FADT_OFFSET (pm1_evt_len));
        }
 
        if (!acpi_gbl_FADT->pm1_cnt_len) {
-               status = acpi_ut_fadt_register_error ("PM1_CNT_LEN", 0,
+               acpi_ut_fadt_register_error ("PM1_CNT_LEN", 0,
                                  ACPI_FADT_OFFSET (pm1_cnt_len));
        }
 
        if (!ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xpm1a_evt_blk.address)) {
-               status = acpi_ut_fadt_register_error ("X_PM1a_EVT_BLK", 0,
+               acpi_ut_fadt_register_error ("X_PM1a_EVT_BLK", 0,
                                  ACPI_FADT_OFFSET (Xpm1a_evt_blk.address));
        }
 
        if (!ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xpm1a_cnt_blk.address)) {
-               status = acpi_ut_fadt_register_error ("X_PM1a_CNT_BLK", 0,
+               acpi_ut_fadt_register_error ("X_PM1a_CNT_BLK", 0,
                                  ACPI_FADT_OFFSET (Xpm1a_cnt_blk.address));
        }
 
        if (!ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xpm_tmr_blk.address)) {
-               status = acpi_ut_fadt_register_error ("X_PM_TMR_BLK", 0,
+               acpi_ut_fadt_register_error ("X_PM_TMR_BLK", 0,
                                  ACPI_FADT_OFFSET (Xpm_tmr_blk.address));
        }
 
        if ((ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xpm2_cnt_blk.address) &&
                !acpi_gbl_FADT->pm2_cnt_len)) {
-               status = acpi_ut_fadt_register_error ("PM2_CNT_LEN",
+               acpi_ut_fadt_register_error ("PM2_CNT_LEN",
                                  (u32) acpi_gbl_FADT->pm2_cnt_len,
                                  ACPI_FADT_OFFSET (pm2_cnt_len));
        }
 
        if (acpi_gbl_FADT->pm_tm_len < 4) {
-               status = acpi_ut_fadt_register_error ("PM_TM_LEN",
+               acpi_ut_fadt_register_error ("PM_TM_LEN",
                                  (u32) acpi_gbl_FADT->pm_tm_len,
                                  ACPI_FADT_OFFSET (pm_tm_len));
        }
 
-       /* length of GPE blocks must be a multiple of 2 */
+       /* Length of GPE blocks must be a multiple of 2 */
 
-       if (ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xgpe0blk.address) &&
-               (acpi_gbl_FADT->gpe0blk_len & 1)) {
-               status = acpi_ut_fadt_register_error ("(x)GPE0_BLK_LEN",
-                                 (u32) acpi_gbl_FADT->gpe0blk_len,
-                                 ACPI_FADT_OFFSET (gpe0blk_len));
+       if (ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xgpe0_blk.address) &&
+               (acpi_gbl_FADT->gpe0_blk_len & 1)) {
+               acpi_ut_fadt_register_error ("(x)GPE0_BLK_LEN",
+                                 (u32) acpi_gbl_FADT->gpe0_blk_len,
+                                 ACPI_FADT_OFFSET (gpe0_blk_len));
        }
 
        if (ACPI_VALID_ADDRESS (acpi_gbl_FADT->Xgpe1_blk.address) &&
                (acpi_gbl_FADT->gpe1_blk_len & 1)) {
-               status = acpi_ut_fadt_register_error ("(x)GPE1_BLK_LEN",
+               acpi_ut_fadt_register_error ("(x)GPE1_BLK_LEN",
                                  (u32) acpi_gbl_FADT->gpe1_blk_len,
                                  ACPI_FADT_OFFSET (gpe1_blk_len));
        }
 
-       return (status);
+       return (AE_OK);
 }
 
 
@@ -168,19 +157,12 @@ void
 acpi_ut_terminate (void)
 {
 
-       FUNCTION_TRACE ("Ut_terminate");
+       ACPI_FUNCTION_TRACE ("Ut_terminate");
 
 
        /* Free global tables, etc. */
 
-       if (acpi_gbl_gpe0enable_register_save) {
-               ACPI_MEM_FREE (acpi_gbl_gpe0enable_register_save);
-       }
-
-       if (acpi_gbl_gpe1_enable_register_save) {
-               ACPI_MEM_FREE (acpi_gbl_gpe1_enable_register_save);
-       }
-
+       /* Nothing to do at this time */
 
        return_VOID;
 }
@@ -203,7 +185,7 @@ acpi_status
 acpi_ut_subsystem_shutdown (void)
 {
 
-       FUNCTION_TRACE ("Ut_subsystem_shutdown");
+       ACPI_FUNCTION_TRACE ("Ut_subsystem_shutdown");
 
        /* Just exit if subsystem is already shutdown */
 
@@ -217,7 +199,6 @@ acpi_ut_subsystem_shutdown (void)
        acpi_gbl_shutdown = TRUE;
        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Shutting down ACPI Subsystem...\n"));
 
-
        /* Close the Namespace */
 
        acpi_ns_terminate ();
@@ -230,17 +211,9 @@ acpi_ut_subsystem_shutdown (void)
 
        acpi_ut_terminate ();
 
-       /* Flush the local cache(s) */
-
-       acpi_ut_delete_generic_state_cache ();
-       acpi_ut_delete_object_cache ();
-       acpi_ds_delete_walk_state_cache ();
-
-       /* Close the Parser */
-
-       /* TBD: [Restructure] Acpi_ps_terminate () */
+       /* Purge the local caches */
 
-       acpi_ps_delete_parse_cache ();
+       acpi_purge_cached_objects ();
 
        /* Debug only - display leftover memory allocation, if any */
 
index aefb202e29a683257bdbc6604dd9f0209e9bec51..85caf3e3999a4211e0f6bc00cbe69e4a7e0eca1c 100644 (file)
@@ -1,12 +1,12 @@
 /*******************************************************************************
  *
  * Module Name: utmath - Integer math support routines
- *              $Revision: 7 $
+ *              $Revision: 10 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -28,7 +28,7 @@
 
 
 #define _COMPONENT          ACPI_UTILITIES
-        MODULE_NAME         ("utmath")
+        ACPI_MODULE_NAME    ("utmath")
 
 /*
  * Support for double-precision integer divide.  This code is included here
@@ -66,14 +66,14 @@ acpi_ut_short_divide (
        u32                     remainder32;
 
 
-       FUNCTION_TRACE ("Ut_short_divide");
+       ACPI_FUNCTION_TRACE ("Ut_short_divide");
 
        dividend.full = *in_dividend;
 
        /* Always check for a zero divisor */
 
        if (divisor == 0) {
-               REPORT_ERROR (("Acpi_ut_short_divide: Divide by zero\n"));
+               ACPI_REPORT_ERROR (("Acpi_ut_short_divide: Divide by zero\n"));
                return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
        }
 
@@ -132,13 +132,13 @@ acpi_ut_divide (
        uint64_overlay          partial3;
 
 
-       FUNCTION_TRACE ("Ut_divide");
+       ACPI_FUNCTION_TRACE ("Ut_divide");
 
 
        /* Always check for a zero divisor */
 
        if (*in_divisor == 0) {
-               REPORT_ERROR (("Acpi_ut_divide: Divide by zero\n"));
+               ACPI_REPORT_ERROR (("Acpi_ut_divide: Divide by zero\n"));
                return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
        }
 
@@ -257,13 +257,13 @@ acpi_ut_short_divide (
        u32                     *out_remainder)
 {
 
-       FUNCTION_TRACE ("Ut_short_divide");
+       ACPI_FUNCTION_TRACE ("Ut_short_divide");
 
 
        /* Always check for a zero divisor */
 
        if (divisor == 0) {
-               REPORT_ERROR (("Acpi_ut_short_divide: Divide by zero\n"));
+               ACPI_REPORT_ERROR (("Acpi_ut_short_divide: Divide by zero\n"));
                return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
        }
 
@@ -286,13 +286,13 @@ acpi_ut_divide (
        acpi_integer            *out_quotient,
        acpi_integer            *out_remainder)
 {
-       FUNCTION_TRACE ("Ut_divide");
+       ACPI_FUNCTION_TRACE ("Ut_divide");
 
 
        /* Always check for a zero divisor */
 
        if (*in_divisor == 0) {
-               REPORT_ERROR (("Acpi_ut_divide: Divide by zero\n"));
+               ACPI_REPORT_ERROR (("Acpi_ut_divide: Divide by zero\n"));
                return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
        }
 
index e821b72218221f724481b3680f916113671bd69f..72d24b04bc4146907952b5930c5d5b5d994a296f 100644 (file)
@@ -1,12 +1,12 @@
 /*******************************************************************************
  *
  * Module Name: utmisc - common utility procedures
- *              $Revision: 52 $
+ *              $Revision: 67 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 
 
 #define _COMPONENT          ACPI_UTILITIES
-        MODULE_NAME         ("utmisc")
+        ACPI_MODULE_NAME    ("utmisc")
+
+
+#ifdef ACPI_DEBUG
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ut_display_init_pathname
+ *
+ * PARAMETERS:  Obj_handle          - Handle whose pathname will be displayed
+ *              Path                - Additional path string to be appended
+ *
+ * RETURN:      acpi_status
+ *
+ * DESCRIPTION: Display full pathnbame of an object, DEBUG ONLY
+ *
+ ******************************************************************************/
+
+void
+acpi_ut_display_init_pathname (
+       acpi_handle             obj_handle,
+       char                    *path)
+{
+       acpi_status             status;
+       acpi_buffer             buffer;
+
+
+       ACPI_FUNCTION_NAME ("Ut_display_init_pathname");
+
+
+       buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
+
+       status = acpi_ns_handle_to_pathname (obj_handle, &buffer);
+       if (ACPI_SUCCESS (status)) {
+               if (path) {
+                       ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "%s.%s\n", (char *) buffer.pointer, path));
+               }
+               else {
+                       ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "%s\n", (char *) buffer.pointer));
+               }
+
+               ACPI_MEM_FREE (buffer.pointer);
+       }
+}
+#endif
 
 
 /*******************************************************************************
@@ -60,7 +103,7 @@ acpi_ut_valid_acpi_name (
        u32                     i;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        for (i = 0; i < ACPI_NAME_SIZE; i++) {
@@ -92,7 +135,7 @@ acpi_ut_valid_acpi_character (
        NATIVE_CHAR             character)
 {
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
        return ((u8)   ((character == '_') ||
                           (character >= 'A' && character <= 'Z') ||
@@ -119,13 +162,13 @@ acpi_ut_strupr (
        NATIVE_CHAR             *string;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        /* Walk entire string, uppercasing the letters */
 
        for (string = src_string; *string; ) {
-               *string = (char) TOUPPER (*string);
+               *string = (char) ACPI_TOUPPER (*string);
                string++;
        }
 
@@ -153,7 +196,7 @@ acpi_ut_mutex_initialize (
        acpi_status             status;
 
 
-       FUNCTION_TRACE ("Ut_mutex_initialize");
+       ACPI_FUNCTION_TRACE ("Ut_mutex_initialize");
 
 
        /*
@@ -189,7 +232,7 @@ acpi_ut_mutex_terminate (
        u32                     i;
 
 
-       FUNCTION_TRACE ("Ut_mutex_terminate");
+       ACPI_FUNCTION_TRACE ("Ut_mutex_terminate");
 
 
        /*
@@ -222,7 +265,7 @@ acpi_ut_create_mutex (
        acpi_status             status = AE_OK;
 
 
-       FUNCTION_TRACE_U32 ("Ut_create_mutex", mutex_id);
+       ACPI_FUNCTION_TRACE_U32 ("Ut_create_mutex", mutex_id);
 
 
        if (mutex_id > MAX_MTX) {
@@ -260,7 +303,7 @@ acpi_ut_delete_mutex (
        acpi_status             status;
 
 
-       FUNCTION_TRACE_U32 ("Ut_delete_mutex", mutex_id);
+       ACPI_FUNCTION_TRACE_U32 ("Ut_delete_mutex", mutex_id);
 
 
        if (mutex_id > MAX_MTX) {
@@ -298,7 +341,7 @@ acpi_ut_acquire_mutex (
        u32                     this_thread_id;
 
 
-       PROC_NAME ("Ut_acquire_mutex");
+       ACPI_FUNCTION_NAME ("Ut_acquire_mutex");
 
 
        if (mutex_id > MAX_MTX) {
@@ -340,7 +383,6 @@ acpi_ut_acquire_mutex (
 
        status = acpi_os_wait_semaphore (acpi_gbl_acpi_mutex_info[mutex_id].mutex,
                           1, WAIT_FOREVER);
-
        if (ACPI_SUCCESS (status)) {
                ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n",
                                 this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
@@ -380,7 +422,7 @@ acpi_ut_release_mutex (
        u32                     this_thread_id;
 
 
-       PROC_NAME ("Ut_release_mutex");
+       ACPI_FUNCTION_NAME ("Ut_release_mutex");
 
 
        this_thread_id = acpi_os_get_thread_id ();
@@ -469,7 +511,7 @@ acpi_ut_create_update_state_and_push (
        acpi_generic_state       *state;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        /* Ignore null objects; these are expected */
@@ -513,7 +555,7 @@ acpi_ut_create_pkg_state_and_push (
        acpi_generic_state       *state;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        state = acpi_ut_create_pkg_state (internal_object, external_object, index);
@@ -545,7 +587,7 @@ acpi_ut_push_generic_state (
        acpi_generic_state      **list_head,
        acpi_generic_state      *state)
 {
-       FUNCTION_TRACE ("Ut_push_generic_state");
+       ACPI_FUNCTION_TRACE ("Ut_push_generic_state");
 
 
        /* Push the state object onto the front of the list (stack) */
@@ -576,7 +618,7 @@ acpi_ut_pop_generic_state (
        acpi_generic_state      *state;
 
 
-       FUNCTION_TRACE ("Ut_pop_generic_state");
+       ACPI_FUNCTION_TRACE ("Ut_pop_generic_state");
 
 
        /* Remove the state object at the head of the list (stack) */
@@ -611,7 +653,7 @@ acpi_ut_create_generic_state (void)
        acpi_generic_state      *state;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
        state = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_STATE);
@@ -626,6 +668,45 @@ acpi_ut_create_generic_state (void)
 }
 
 
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ut_create_thread_state
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Thread State
+ *
+ * DESCRIPTION: Create a "Thread State" - a flavor of the generic state used
+ *              to track per-thread info during method execution
+ *
+ ******************************************************************************/
+
+ACPI_THREAD_STATE *
+acpi_ut_create_thread_state (
+       void)
+{
+       acpi_generic_state      *state;
+
+
+       ACPI_FUNCTION_TRACE ("Ut_create_thread_state");
+
+
+       /* Create the generic state object */
+
+       state = acpi_ut_create_generic_state ();
+       if (!state) {
+               return_PTR (NULL);
+       }
+
+       /* Init fields specific to the update struct */
+
+       state->common.data_type = ACPI_DESC_TYPE_STATE_THREAD;
+       state->thread.thread_id = acpi_os_get_thread_id ();
+
+       return_PTR ((ACPI_THREAD_STATE *) state);
+}
+
+
 /*******************************************************************************
  *
  * FUNCTION:    Acpi_ut_create_update_state
@@ -650,14 +731,14 @@ acpi_ut_create_update_state (
        acpi_generic_state      *state;
 
 
-       FUNCTION_TRACE_PTR ("Ut_create_update_state", object);
+       ACPI_FUNCTION_TRACE_PTR ("Ut_create_update_state", object);
 
 
        /* Create the generic state object */
 
        state = acpi_ut_create_generic_state ();
        if (!state) {
-               return (NULL);
+               return_PTR (NULL);
        }
 
        /* Init fields specific to the update struct */
@@ -693,14 +774,14 @@ acpi_ut_create_pkg_state (
        acpi_generic_state      *state;
 
 
-       FUNCTION_TRACE_PTR ("Ut_create_pkg_state", internal_object);
+       ACPI_FUNCTION_TRACE_PTR ("Ut_create_pkg_state", internal_object);
 
 
        /* Create the generic state object */
 
        state = acpi_ut_create_generic_state ();
        if (!state) {
-               return (NULL);
+               return_PTR (NULL);
        }
 
        /* Init fields specific to the update struct */
@@ -735,21 +816,21 @@ acpi_ut_create_control_state (
        acpi_generic_state      *state;
 
 
-       FUNCTION_TRACE ("Ut_create_control_state");
+       ACPI_FUNCTION_TRACE ("Ut_create_control_state");
 
 
        /* Create the generic state object */
 
        state = acpi_ut_create_generic_state ();
        if (!state) {
-               return (NULL);
+               return_PTR (NULL);
        }
 
 
        /* Init fields specific to the control struct */
 
        state->common.data_type = ACPI_DESC_TYPE_STATE_CONTROL;
-       state->common.state     = CONTROL_CONDITIONAL_EXECUTING;
+       state->common.state     = ACPI_CONTROL_CONDITIONAL_EXECUTING;
 
        return_PTR (state);
 }
@@ -772,7 +853,7 @@ void
 acpi_ut_delete_generic_state (
        acpi_generic_state      *state)
 {
-       FUNCTION_TRACE ("Ut_delete_generic_state");
+       ACPI_FUNCTION_TRACE ("Ut_delete_generic_state");
 
 
        acpi_ut_release_to_cache (ACPI_MEM_LIST_STATE, state);
@@ -797,7 +878,7 @@ void
 acpi_ut_delete_generic_state_cache (
        void)
 {
-       FUNCTION_TRACE ("Ut_delete_generic_state_cache");
+       ACPI_FUNCTION_TRACE ("Ut_delete_generic_state_cache");
 
 
        acpi_ut_delete_generic_cache (ACPI_MEM_LIST_STATE);
@@ -807,100 +888,109 @@ acpi_ut_delete_generic_state_cache (
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_resolve_package_references
+ * FUNCTION:    Acpi_ut_resolve_reference
  *
- * PARAMETERS:  Obj_desc        - The Package object on which to resolve refs
+ * PARAMETERS:  ACPI_PKG_CALLBACK
  *
- * RETURN:      Status
+ * RETURN:      Status          - the status of the call
  *
- * DESCRIPTION: Walk through a package and turn internal references into values
+ * DESCRIPTION: Resolve a reference object to an actual value
  *
  ******************************************************************************/
 
 acpi_status
-acpi_ut_resolve_package_references (
-       acpi_operand_object     *obj_desc)
+acpi_ut_resolve_reference (
+       u8                      object_type,
+       acpi_operand_object     *source_object,
+       acpi_generic_state      *state,
+       void                    *context)
 {
-       u32                     count;
-       acpi_operand_object     *sub_object;
+       acpi_pkg_info           *info = (acpi_pkg_info *) context;
 
 
-       FUNCTION_TRACE ("Ut_resolve_package_references");
+       switch (object_type) {
+       case ACPI_COPY_TYPE_SIMPLE:
 
+               /*
+                * Simple object - check for a reference
+                */
+               if (source_object->common.type == INTERNAL_TYPE_REFERENCE) {
+                       switch (source_object->reference.opcode) {
+                       case AML_ZERO_OP:
 
-       if (obj_desc->common.type != ACPI_TYPE_PACKAGE) {
-               /* The object must be a package */
+                               source_object->common.type = ACPI_TYPE_INTEGER;
+                               source_object->integer.value = 0;
+                               break;
 
-               REPORT_ERROR (("Must resolve Package Refs on a Package\n"));
-               return_ACPI_STATUS(AE_ERROR);
-       }
+                       case AML_ONE_OP:
 
-       /*
-        * TBD: what about nested packages? */
+                               source_object->common.type = ACPI_TYPE_INTEGER;
+                               source_object->integer.value = 1;
+                               break;
 
-       for (count = 0; count < obj_desc->package.count; count++) {
-               sub_object = obj_desc->package.elements[count];
+                       case AML_ONES_OP:
 
-               if (sub_object->common.type == INTERNAL_TYPE_REFERENCE) {
-                       if (sub_object->reference.opcode == AML_ZERO_OP) {
-                               sub_object->common.type = ACPI_TYPE_INTEGER;
-                               sub_object->integer.value = 0;
+                               source_object->common.type = ACPI_TYPE_INTEGER;
+                               source_object->integer.value = ACPI_INTEGER_MAX;
+                               break;
                        }
+               }
+               break;
 
-                       else if (sub_object->reference.opcode == AML_ONE_OP) {
-                               sub_object->common.type = ACPI_TYPE_INTEGER;
-                               sub_object->integer.value = 1;
-                       }
 
-                       else if (sub_object->reference.opcode == AML_ONES_OP) {
-                               sub_object->common.type = ACPI_TYPE_INTEGER;
-                               sub_object->integer.value = ACPI_INTEGER_MAX;
-                       }
-               }
+       case ACPI_COPY_TYPE_PACKAGE:
+
+               /* Package object - nothing much to do here, let the walk handle it */
+
+               info->num_packages++;
+               state->pkg.this_target_obj = NULL;
+               break;
        }
 
-       return_ACPI_STATUS(AE_OK);
+       return (AE_OK);
 }
 
-#ifdef ACPI_DEBUG
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ut_display_init_pathname
+ * FUNCTION:    Acpi_ut_resolve_package_references
  *
- * PARAMETERS:  Obj_handle          - Handle whose pathname will be displayed
- *              Path                - Additional path string to be appended
+ * PARAMETERS:  Obj_desc        - The Package object on which to resolve refs
  *
- * RETURN:      acpi_status
+ * RETURN:      Status
  *
- * DESCRIPTION: Display full pathnbame of an object, DEBUG ONLY
+ * DESCRIPTION: Walk through a package and turn internal references into values
  *
  ******************************************************************************/
 
-void
-acpi_ut_display_init_pathname (
-       acpi_handle             obj_handle,
-       char                    *path)
+acpi_status
+acpi_ut_resolve_package_references (
+       acpi_operand_object     *obj_desc)
 {
+       acpi_pkg_info           info;
        acpi_status             status;
-       u32                     length = 128;
-       char                    buffer[128];
 
 
-       PROC_NAME ("Ut_display_init_pathname");
+       ACPI_FUNCTION_TRACE ("Ut_resolve_package_references");
 
 
-       status = acpi_ns_handle_to_pathname (obj_handle, &length, buffer);
-       if (ACPI_SUCCESS (status)) {
-               if (path) {
-                       ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "%s.%s\n", buffer, path));
-               }
-               else {
-                       ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "%s\n", buffer));
-               }
+       if (obj_desc->common.type != ACPI_TYPE_PACKAGE) {
+               /* The object must be a package */
+
+               ACPI_REPORT_ERROR (("Expecting a Package object\n"));
+               return_ACPI_STATUS (AE_TYPE);
        }
+
+       info.length      = 0;
+       info.object_space = 0;
+       info.num_packages = 1;
+
+       status = acpi_ut_walk_package_tree (obj_desc, NULL,
+                        acpi_ut_resolve_reference, &info);
+
+       return_ACPI_STATUS (status);
 }
-#endif
+
 
 /*******************************************************************************
  *
@@ -928,7 +1018,7 @@ acpi_ut_walk_package_tree (
        acpi_operand_object     *this_source_obj;
 
 
-       FUNCTION_TRACE ("Ut_walk_package_tree");
+       ACPI_FUNCTION_TRACE ("Ut_walk_package_tree");
 
 
        state = acpi_ut_create_pkg_state (source_object, target_object, 0);
@@ -942,24 +1032,19 @@ acpi_ut_walk_package_tree (
                                  state->pkg.source_object->package.elements[this_index];
 
                /*
-                * Check for
+                * Check for:
                 * 1) An uninitialized package element.  It is completely
-                *      legal to declare a package and leave it uninitialized
+                *    legal to declare a package and leave it uninitialized
                 * 2) Not an internal object - can be a namespace node instead
                 * 3) Any type other than a package.  Packages are handled in else
-                *      case below.
+                *    case below.
                 */
                if ((!this_source_obj) ||
-                       (!VALID_DESCRIPTOR_TYPE (
-                                       this_source_obj, ACPI_DESC_TYPE_INTERNAL)) ||
-                       (!IS_THIS_OBJECT_TYPE (
-                                       this_source_obj, ACPI_TYPE_PACKAGE))) {
-
+                       (ACPI_GET_DESCRIPTOR_TYPE (this_source_obj) != ACPI_DESC_TYPE_INTERNAL) ||
+                       (this_source_obj->common.type != ACPI_TYPE_PACKAGE)) {
                        status = walk_callback (ACPI_COPY_TYPE_SIMPLE, this_source_obj,
                                         state, context);
                        if (ACPI_FAILURE (status)) {
-                               /* TBD: must delete package created up to this point */
-
                                return_ACPI_STATUS (status);
                        }
 
@@ -975,7 +1060,6 @@ acpi_ut_walk_package_tree (
                                acpi_ut_delete_generic_state (state);
                                state = acpi_ut_pop_generic_state (&state_list);
 
-
                                /* Finished when there are no more states */
 
                                if (!state) {
@@ -994,32 +1078,23 @@ acpi_ut_walk_package_tree (
                                state->pkg.index++;
                        }
                }
-
                else {
-                       /* This is a sub-object of type package */
+                       /* This is a subobject of type package */
 
                        status = walk_callback (ACPI_COPY_TYPE_PACKAGE, this_source_obj,
                                          state, context);
                        if (ACPI_FAILURE (status)) {
-                               /* TBD: must delete package created up to this point */
-
                                return_ACPI_STATUS (status);
                        }
 
-
-                       /*
-                        * The callback above returned a new target package object.
-                        */
-
                        /*
                         * Push the current state and create a new one
+                        * The callback above returned a new target package object.
                         */
                        acpi_ut_push_generic_state (&state_list, state);
                        state = acpi_ut_create_pkg_state (this_source_obj,
                                           state->pkg.this_target_obj, 0);
                        if (!state) {
-                               /* TBD: must delete package created up to this point */
-
                                return_ACPI_STATUS (AE_NO_MEMORY);
                        }
                }
@@ -1027,7 +1102,89 @@ acpi_ut_walk_package_tree (
 
        /* We should never get here */
 
-       return (AE_AML_INTERNAL);
+       return_ACPI_STATUS (AE_AML_INTERNAL);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ut_generate_checksum
+ *
+ * PARAMETERS:  Buffer          - Buffer to be scanned
+ *              Length          - number of bytes to examine
+ *
+ * RETURN:      checksum
+ *
+ * DESCRIPTION: Generate a checksum on a raw buffer
+ *
+ ******************************************************************************/
+
+u8
+acpi_ut_generate_checksum (
+       u8                      *buffer,
+       u32                     length)
+{
+       u32                     i;
+       signed char             sum = 0;
+
+       for (i = 0; i < length; i++) {
+               sum = (signed char) (sum + buffer[i]);
+       }
+
+       return ((u8) (0 - sum));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ut_get_resource_end_tag
+ *
+ * PARAMETERS:  Obj_desc        - The resource template buffer object
+ *
+ * RETURN:      Pointer to the end tag
+ *
+ * DESCRIPTION: Find the END_TAG resource descriptor in a resource template
+ *
+ ******************************************************************************/
+
+
+u8 *
+acpi_ut_get_resource_end_tag (
+       acpi_operand_object     *obj_desc)
+{
+       u8                      buffer_byte;
+       u8                      *buffer;
+       u8                      *end_buffer;
+
+
+       buffer    = obj_desc->buffer.pointer;
+       end_buffer = buffer + obj_desc->buffer.length;
+
+       while (buffer < end_buffer) {
+               buffer_byte = *buffer;
+               if (buffer_byte & ACPI_RDESC_TYPE_MASK) {
+                       /* Large Descriptor - Length is next 2 bytes */
+
+                       buffer += ((*(buffer+1) | (*(buffer+2) << 8)) + 3);
+               }
+               else {
+                       /* Small Descriptor.  End Tag will be found here */
+
+                       if ((buffer_byte & ACPI_RDESC_SMALL_MASK) == ACPI_RDESC_TYPE_END_TAG) {
+                               /* Found the end tag descriptor, all done. */
+
+                               return (buffer);
+                       }
+
+                       /* Length is in the header */
+
+                       buffer += ((buffer_byte & 0x07) + 1);
+               }
+       }
+
+       /* End tag not found */
+
+       return (NULL);
 }
 
 
index 31ca07ed63d2ba6e9e7073d4e8fab4a3413ef7aa..600f648628233112f86f3d915068c4d723049dc0 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: utobject - ACPI object create/delete/size/cache routines
- *              $Revision: 57 $
+ *              $Revision: 68 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -32,7 +32,7 @@
 
 
 #define _COMPONENT          ACPI_UTILITIES
-        MODULE_NAME         ("utobject")
+        ACPI_MODULE_NAME    ("utobject")
 
 
 /*******************************************************************************
@@ -62,26 +62,46 @@ acpi_ut_create_internal_object_dbg (
        NATIVE_CHAR             *module_name,
        u32                     line_number,
        u32                     component_id,
-       acpi_object_type8       type)
+       acpi_object_type        type)
 {
        acpi_operand_object     *object;
+       acpi_operand_object     *second_object;
 
 
-       FUNCTION_TRACE_STR ("Ut_create_internal_object_dbg", acpi_ut_get_type_name (type));
+       ACPI_FUNCTION_TRACE_STR ("Ut_create_internal_object_dbg", acpi_ut_get_type_name (type));
 
 
        /* Allocate the raw object descriptor */
 
        object = acpi_ut_allocate_object_desc_dbg (module_name, line_number, component_id);
        if (!object) {
-               /* Allocation failure */
-
                return_PTR (NULL);
        }
 
+       switch (type) {
+       case ACPI_TYPE_REGION:
+       case ACPI_TYPE_BUFFER_FIELD:
+
+               /* These types require a secondary object */
+
+               second_object = acpi_ut_allocate_object_desc_dbg (module_name, line_number, component_id);
+               if (!second_object) {
+                       acpi_ut_delete_object_desc (object);
+                       return_PTR (NULL);
+               }
+
+               second_object->common.type = INTERNAL_TYPE_EXTRA;
+               second_object->common.reference_count = 1;
+
+               /* Link the second object to the first */
+
+               object->common.next_object = second_object;
+               break;
+       }
+
        /* Save the object type in the object descriptor */
 
-       object->common.type = type;
+       object->common.type = (u8) type;
 
        /* Init the reference count */
 
@@ -108,7 +128,7 @@ acpi_ut_valid_internal_object (
        void                    *object)
 {
 
-       PROC_NAME ("Ut_valid_internal_object");
+       ACPI_FUNCTION_NAME ("Ut_valid_internal_object");
 
 
        /* Check for a null pointer */
@@ -121,31 +141,33 @@ acpi_ut_valid_internal_object (
 
        /* Check the descriptor type field */
 
-       if (!VALID_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_INTERNAL)) {
-               /* Not an ACPI internal object, do some further checking */
+       switch (ACPI_GET_DESCRIPTOR_TYPE (object)) {
+       case ACPI_DESC_TYPE_INTERNAL:
 
-               if (VALID_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_NAMED)) {
-                       ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-                               "**** Obj %p is a named obj, not ACPI obj\n", object));
-               }
+               /* The object appears to be a valid acpi_operand_object  */
 
-               else if (VALID_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_PARSER)) {
-                       ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-                               "**** Obj %p is a parser obj, not ACPI obj\n", object));
-               }
+               return (TRUE);
 
-               else {
-                       ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-                               "**** Obj %p is of unknown type\n", object));
-               }
+       case ACPI_DESC_TYPE_NAMED:
 
-               return (FALSE);
-       }
+               ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+                       "**** Obj %p is a named obj, not ACPI obj\n", object));
+               break;
 
+       case ACPI_DESC_TYPE_PARSER:
 
-       /* The object appears to be a valid acpi_operand_object  */
+               ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+                       "**** Obj %p is a parser obj, not ACPI obj\n", object));
+               break;
 
-       return (TRUE);
+       default:
+
+               ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+                       "**** Obj %p is of unknown type\n", object));
+               break;
+       }
+
+       return (FALSE);
 }
 
 
@@ -174,12 +196,12 @@ acpi_ut_allocate_object_desc_dbg (
        acpi_operand_object     *object;
 
 
-       FUNCTION_TRACE ("Ut_allocate_object_desc_dbg");
+       ACPI_FUNCTION_TRACE ("Ut_allocate_object_desc_dbg");
 
 
        object = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_OPERAND);
        if (!object) {
-               _REPORT_ERROR (module_name, line_number, component_id,
+               _ACPI_REPORT_ERROR (module_name, line_number, component_id,
                                  ("Could not allocate an object descriptor\n"));
 
                return_PTR (NULL);
@@ -188,7 +210,7 @@ acpi_ut_allocate_object_desc_dbg (
 
        /* Mark the descriptor type */
 
-       object->common.data_type = ACPI_DESC_TYPE_INTERNAL;
+       ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_INTERNAL);
 
        ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n",
                        object, sizeof (acpi_operand_object)));
@@ -213,12 +235,12 @@ void
 acpi_ut_delete_object_desc (
        acpi_operand_object     *object)
 {
-       FUNCTION_TRACE_PTR ("Ut_delete_object_desc", object);
+       ACPI_FUNCTION_TRACE_PTR ("Ut_delete_object_desc", object);
 
 
        /* Object must be an acpi_operand_object  */
 
-       if (object->common.data_type != ACPI_DESC_TYPE_INTERNAL) {
+       if (ACPI_GET_DESCRIPTOR_TYPE (object) != ACPI_DESC_TYPE_INTERNAL) {
                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
                        "Obj %p is not an ACPI object\n", object));
                return_VOID;
@@ -247,7 +269,7 @@ void
 acpi_ut_delete_object_cache (
        void)
 {
-       FUNCTION_TRACE ("Ut_delete_object_cache");
+       ACPI_FUNCTION_TRACE ("Ut_delete_object_cache");
 
 
        acpi_ut_delete_generic_cache (ACPI_MEM_LIST_OPERAND);
@@ -275,13 +297,13 @@ acpi_ut_delete_object_cache (
 acpi_status
 acpi_ut_get_simple_object_size (
        acpi_operand_object     *internal_object,
-       u32                     *obj_length)
+       ACPI_SIZE               *obj_length)
 {
-       u32                     length;
+       ACPI_SIZE               length;
        acpi_status             status = AE_OK;
 
 
-       FUNCTION_TRACE_PTR ("Ut_get_simple_object_size", internal_object);
+       ACPI_FUNCTION_TRACE_PTR ("Ut_get_simple_object_size", internal_object);
 
 
        /* Handle a null object (Could be a uninitialized package element -- which is legal) */
@@ -296,10 +318,10 @@ acpi_ut_get_simple_object_size (
 
        length = sizeof (acpi_object);
 
-       if (VALID_DESCRIPTOR_TYPE (internal_object, ACPI_DESC_TYPE_NAMED)) {
+       if (ACPI_GET_DESCRIPTOR_TYPE (internal_object) == ACPI_DESC_TYPE_NAMED) {
                /* Object is a named object (reference), just return the length */
 
-               *obj_length = (u32) ROUND_UP_TO_NATIVE_WORD (length);
+               *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD (length);
                return_ACPI_STATUS (status);
        }
 
@@ -337,23 +359,37 @@ acpi_ut_get_simple_object_size (
 
        case INTERNAL_TYPE_REFERENCE:
 
-               /*
-                * The only type that should be here is internal opcode NAMEPATH_OP -- since
-                * this means an object reference
-                */
-               if (internal_object->reference.opcode != AML_INT_NAMEPATH_OP) {
-                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-                               "Unsupported Reference opcode=%X in object %p\n",
-                               internal_object->reference.opcode, internal_object));
-                       status = AE_TYPE;
-               }
+               switch (internal_object->reference.opcode) {
+               case AML_ZERO_OP:
+               case AML_ONE_OP:
+               case AML_ONES_OP:
+               case AML_REVISION_OP:
+
+                       /* These Constant opcodes will be resolved to Integers */
+
+                       break;
+
+               case AML_INT_NAMEPATH_OP:
 
-               else {
                        /*
                         * Get the actual length of the full pathname to this object.
                         * The reference will be converted to the pathname to the object
                         */
-                       length += ROUND_UP_TO_NATIVE_WORD (acpi_ns_get_pathname_length (internal_object->reference.node));
+                       length += ACPI_ROUND_UP_TO_NATIVE_WORD (acpi_ns_get_pathname_length (internal_object->reference.node));
+                       break;
+
+               default:
+
+                       /*
+                        * No other reference opcodes are supported.
+                        * Notably, Locals and Args are not supported, by this may be
+                        * required eventually.
+                        */
+                       ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+                               "Unsupported Reference opcode=%X in object %p\n",
+                               internal_object->reference.opcode, internal_object));
+                       status = AE_TYPE;
+                       break;
                }
                break;
 
@@ -373,8 +409,7 @@ acpi_ut_get_simple_object_size (
         * on a machine word boundary. (preventing alignment faults on some
         * machines.)
         */
-       *obj_length = (u32) ROUND_UP_TO_NATIVE_WORD (length);
-
+       *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD (length);
        return_ACPI_STATUS (status);
 }
 
@@ -400,11 +435,11 @@ acpi_ut_get_element_length (
 {
        acpi_status             status = AE_OK;
        acpi_pkg_info           *info = (acpi_pkg_info *) context;
-       u32                     object_space;
+       ACPI_SIZE               object_space;
 
 
        switch (object_type) {
-       case 0:
+       case ACPI_COPY_TYPE_SIMPLE:
 
                /*
                 * Simple object - just get the size (Null object/entry is handled
@@ -419,18 +454,15 @@ acpi_ut_get_element_length (
                break;
 
 
-       case 1:
-               /* Package - nothing much to do here, let the walk handle it */
+       case ACPI_COPY_TYPE_PACKAGE:
+
+               /* Package object - nothing much to do here, let the walk handle it */
 
                info->num_packages++;
                state->pkg.this_target_obj = NULL;
                break;
-
-       default:
-               return (AE_BAD_PARAMETER);
        }
 
-
        return (status);
 }
 
@@ -455,13 +487,13 @@ acpi_ut_get_element_length (
 acpi_status
 acpi_ut_get_package_object_size (
        acpi_operand_object     *internal_object,
-       u32                     *obj_length)
+       ACPI_SIZE               *obj_length)
 {
        acpi_status             status;
        acpi_pkg_info           info;
 
 
-       FUNCTION_TRACE_PTR ("Ut_get_package_object_size", internal_object);
+       ACPI_FUNCTION_TRACE_PTR ("Ut_get_package_object_size", internal_object);
 
 
        info.length      = 0;
@@ -470,13 +502,16 @@ acpi_ut_get_package_object_size (
 
        status = acpi_ut_walk_package_tree (internal_object, NULL,
                         acpi_ut_get_element_length, &info);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
+       }
 
        /*
         * We have handled all of the objects in all levels of the package.
         * just add the length of the package objects themselves.
         * Round up to the next machine word.
         */
-       info.length += ROUND_UP_TO_NATIVE_WORD (sizeof (acpi_object)) *
+       info.length += ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (acpi_object)) *
                          info.num_packages;
 
        /* Return the total package length */
@@ -503,19 +538,18 @@ acpi_ut_get_package_object_size (
 acpi_status
 acpi_ut_get_object_size(
        acpi_operand_object     *internal_object,
-       u32                     *obj_length)
+       ACPI_SIZE               *obj_length)
 {
        acpi_status             status;
 
 
-       FUNCTION_ENTRY ();
+       ACPI_FUNCTION_ENTRY ();
 
 
-       if ((VALID_DESCRIPTOR_TYPE (internal_object, ACPI_DESC_TYPE_INTERNAL)) &&
-               (IS_THIS_OBJECT_TYPE (internal_object, ACPI_TYPE_PACKAGE))) {
+       if ((ACPI_GET_DESCRIPTOR_TYPE (internal_object) == ACPI_DESC_TYPE_INTERNAL) &&
+               (internal_object->common.type == ACPI_TYPE_PACKAGE)) {
                status = acpi_ut_get_package_object_size (internal_object, obj_length);
        }
-
        else {
                status = acpi_ut_get_simple_object_size (internal_object, obj_length);
        }
index 1ff0f24a706755bd71f446397e71192a1674f9c8..38e7b31840c51d4a2e408e1a5ec062ce96540a41 100644 (file)
@@ -1,12 +1,12 @@
 /******************************************************************************
  *
  * Module Name: utxface - External interfaces for "global" ACPI functions
- *              $Revision: 82 $
+ *              $Revision: 92 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ *  Copyright (C) 2000 - 2002, R. Byron Moore
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 #include "amlcode.h"
 #include "acdebug.h"
 #include "acexcep.h"
+#include "acparser.h"
+#include "acdispat.h"
 
 
 #define _COMPONENT          ACPI_UTILITIES
-        MODULE_NAME         ("utxface")
+        ACPI_MODULE_NAME    ("utxface")
 
 
 /*******************************************************************************
@@ -57,10 +59,10 @@ acpi_initialize_subsystem (
 {
        acpi_status             status;
 
-       FUNCTION_TRACE ("Acpi_initialize_subsystem");
+       ACPI_FUNCTION_TRACE ("Acpi_initialize_subsystem");
 
 
-       DEBUG_EXEC(acpi_ut_init_stack_ptr_trace ());
+       ACPI_DEBUG_EXEC (acpi_ut_init_stack_ptr_trace ());
 
 
        /* Initialize all globals used by the subsystem */
@@ -71,7 +73,7 @@ acpi_initialize_subsystem (
 
        status = acpi_os_initialize ();
        if (ACPI_FAILURE (status)) {
-               REPORT_ERROR (("OSD failed to initialize, %s\n",
+               ACPI_REPORT_ERROR (("OSD failed to initialize, %s\n",
                        acpi_format_exception (status)));
                return_ACPI_STATUS (status);
        }
@@ -80,7 +82,7 @@ acpi_initialize_subsystem (
 
        status = acpi_ut_mutex_initialize ();
        if (ACPI_FAILURE (status)) {
-               REPORT_ERROR (("Global mutex creation failure, %s\n",
+               ACPI_REPORT_ERROR (("Global mutex creation failure, %s\n",
                        acpi_format_exception (status)));
                return_ACPI_STATUS (status);
        }
@@ -92,7 +94,7 @@ acpi_initialize_subsystem (
 
        status = acpi_ns_root_initialize ();
        if (ACPI_FAILURE (status)) {
-               REPORT_ERROR (("Namespace initialization failure, %s\n",
+               ACPI_REPORT_ERROR (("Namespace initialization failure, %s\n",
                        acpi_format_exception (status)));
                return_ACPI_STATUS (status);
        }
@@ -100,7 +102,7 @@ acpi_initialize_subsystem (
 
        /* If configured, initialize the AML debugger */
 
-       DEBUGGER_EXEC (acpi_db_initialize ());
+       ACPI_DEBUGGER_EXEC (acpi_db_initialize ());
 
        return_ACPI_STATUS (status);
 }
@@ -126,20 +128,13 @@ acpi_enable_subsystem (
        acpi_status             status = AE_OK;
 
 
-       FUNCTION_TRACE ("Acpi_enable_subsystem");
+       ACPI_FUNCTION_TRACE ("Acpi_enable_subsystem");
 
 
-       /* Sanity check the FADT for valid values */
-
-       status = acpi_ut_validate_fadt ();
-       if (ACPI_FAILURE (status)) {
-               return_ACPI_STATUS (status);
-       }
-
        /*
-        * Install the default Op_region handlers. These are
-        * installed unless other handlers have already been
-        * installed via the Install_address_space_handler interface
+        * Install the default Op_region handlers. These are installed unless
+        * other handlers have already been installed via the
+        * Install_address_space_handler interface
         */
        if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
                ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Installing default address space handlers\n"));
@@ -152,6 +147,7 @@ acpi_enable_subsystem (
 
        /*
         * We must initialize the hardware before we can enable ACPI.
+        * FADT values are validated here.
         */
        if (!(flags & ACPI_NO_HARDWARE_INIT)) {
                ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI hardware\n"));
@@ -190,6 +186,16 @@ acpi_enable_subsystem (
                }
        }
 
+       /* Install SCI handler, Global Lock handler, GPE handlers */
+
+       if (!(flags & ACPI_NO_HANDLER_INIT)) {
+               ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Installing SCI/GL/GPE handlers\n"));
+
+               status = acpi_ev_handler_initialize ();
+               if (ACPI_FAILURE (status)) {
+                       return_ACPI_STATUS (status);
+               }
+       }
 
        /*
         * Initialize all device objects in the namespace
@@ -204,7 +210,6 @@ acpi_enable_subsystem (
                }
        }
 
-
        /*
         * Initialize the objects that remain uninitialized.  This
         * runs the executable AML that is part of the declaration of Op_regions
@@ -219,8 +224,14 @@ acpi_enable_subsystem (
                }
        }
 
-       acpi_gbl_startup_flags |= ACPI_INITIALIZED_OK;
+       /*
+        * Empty the caches (delete the cached objects) on the assumption that
+        * the table load filled them up more than they will be at runtime --
+        * thus wasting non-paged memory.
+        */
+       status = acpi_purge_cached_objects ();
 
+       acpi_gbl_startup_flags |= ACPI_INITIALIZED_OK;
        return_ACPI_STATUS (status);
 }
 
@@ -240,16 +251,12 @@ acpi_enable_subsystem (
 acpi_status
 acpi_terminate (void)
 {
-       FUNCTION_TRACE ("Acpi_terminate");
+       ACPI_FUNCTION_TRACE ("Acpi_terminate");
 
 
        /* Terminate the AML Debugger if present */
 
-       DEBUGGER_EXEC(acpi_gbl_db_terminate_threads = TRUE);
-
-       /* TBD: [Investigate] This is no longer needed?*/
-/*    Acpi_ut_release_mutex (ACPI_MTX_DEBUG_CMD_READY); */
-
+       ACPI_DEBUGGER_EXEC(acpi_gbl_db_terminate_threads = TRUE);
 
        /* Shutdown and free all resources */
 
@@ -328,42 +335,39 @@ acpi_get_system_info (
 {
        acpi_system_info        *info_ptr;
        u32                     i;
+       acpi_status             status;
 
 
-       FUNCTION_TRACE ("Acpi_get_system_info");
+       ACPI_FUNCTION_TRACE ("Acpi_get_system_info");
 
 
-       /*
-        *  Must have a valid buffer
-        */
-       if ((!out_buffer)         ||
-               (!out_buffer->pointer)) {
-               return_ACPI_STATUS (AE_BAD_PARAMETER);
+       /* Parameter validation */
+
+       status = acpi_ut_validate_buffer (out_buffer);
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
        }
 
-       if (out_buffer->length < sizeof (acpi_system_info)) {
-               /*
-                *  Caller's buffer is too small
-                */
-               out_buffer->length = sizeof (acpi_system_info);
+       /* Validate/Allocate/Clear caller buffer */
 
-               return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
+       status = acpi_ut_initialize_buffer (out_buffer, sizeof (acpi_system_info));
+       if (ACPI_FAILURE (status)) {
+               return_ACPI_STATUS (status);
        }
 
-
        /*
-        *  Set return length and get data
+        * Populate the return buffer
         */
-       out_buffer->length = sizeof (acpi_system_info);
        info_ptr = (acpi_system_info *) out_buffer->pointer;
 
        info_ptr->acpi_ca_version   = ACPI_CA_VERSION;
 
        /* System flags (ACPI capabilities) */
 
-       info_ptr->flags             = acpi_gbl_system_flags;
+       info_ptr->flags             = ACPI_SYS_MODE_ACPI;
 
        /* Timer resolution - 24 or 32 bits  */
+
        if (!acpi_gbl_FADT) {
                info_ptr->timer_resolution = 0;
        }
@@ -395,3 +399,28 @@ acpi_get_system_info (
 }
 
 
+/*****************************************************************************
+ *
+ * FUNCTION:    Acpi_purge_cached_objects
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Empty all caches (delete the cached objects)
+ *
+ ****************************************************************************/
+
+acpi_status
+acpi_purge_cached_objects (void)
+{
+       ACPI_FUNCTION_TRACE ("Acpi_purge_cached_objects");
+
+
+       acpi_ut_delete_generic_state_cache ();
+       acpi_ut_delete_object_cache ();
+       acpi_ds_delete_walk_state_cache ();
+       acpi_ps_delete_parse_cache ();
+
+       return_ACPI_STATUS (AE_OK);
+}