summaryrefslogtreecommitdiffstats
path: root/drivers/acpi/namespace
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2000-10-05 01:18:40 +0000
committerRalf Baechle <ralf@linux-mips.org>2000-10-05 01:18:40 +0000
commit012bb3e61e5eced6c610f9e036372bf0c8def2d1 (patch)
tree87efc733f9b164e8c85c0336f92c8fb7eff6d183 /drivers/acpi/namespace
parent625a1589d3d6464b5d90b8a0918789e3afffd220 (diff)
Merge with Linux 2.4.0-test9. Please check DECstation, I had a number
of rejects to fixup while integrating Linus patches. I also found that this kernel will only boot SMP on Origin; the UP kernel freeze soon after bootup with SCSI timeout messages. I commit this anyway since I found that the last CVS versions had the same problem.
Diffstat (limited to 'drivers/acpi/namespace')
-rw-r--r--drivers/acpi/namespace/Makefile28
-rw-r--r--drivers/acpi/namespace/nsaccess.c322
-rw-r--r--drivers/acpi/namespace/nsalloc.c543
-rw-r--r--drivers/acpi/namespace/nsdump.c36
-rw-r--r--drivers/acpi/namespace/nseval.c208
-rw-r--r--drivers/acpi/namespace/nsload.c159
-rw-r--r--drivers/acpi/namespace/nsnames.c387
-rw-r--r--drivers/acpi/namespace/nsobject.c295
-rw-r--r--drivers/acpi/namespace/nssearch.c568
-rw-r--r--drivers/acpi/namespace/nsutils.c456
-rw-r--r--drivers/acpi/namespace/nswalk.c109
-rw-r--r--drivers/acpi/namespace/nsxfname.c111
-rw-r--r--drivers/acpi/namespace/nsxfobj.c120
13 files changed, 1204 insertions, 2138 deletions
diff --git a/drivers/acpi/namespace/Makefile b/drivers/acpi/namespace/Makefile
new file mode 100644
index 000000000..edd897133
--- /dev/null
+++ b/drivers/acpi/namespace/Makefile
@@ -0,0 +1,28 @@
+#
+# Makefile for all Linux ACPI interpreter subdirectories
+#
+
+SUB_DIRS :=
+MOD_SUB_DIRS := $(SUB_DIRS)
+MOD_IN_SUB_DIRS :=
+ALL_SUB_DIRS := $(SUB_DIRS)
+
+O_TARGET := ../$(shell basename `pwd`).o
+O_OBJS :=
+M_OBJS :=
+
+ACPI_OBJS := $(patsubst %.c,%.o,$(wildcard *.c))
+
+EXTRA_CFLAGS += -I../include
+
+EXTRA_CFLAGS += $(ACPI_CFLAGS)
+
+# if the interpreter is used, it overrides arch/i386/kernel/acpi.c
+ifeq ($(CONFIG_ACPI_INTERPRETER),y)
+ O_OBJS := $(ACPI_OBJS)
+endif
+
+include $(TOPDIR)/Rules.make
+
+clean:
+ $(RM) *.o
diff --git a/drivers/acpi/namespace/nsaccess.c b/drivers/acpi/namespace/nsaccess.c
index 7cb9ac409..e04ffe4e9 100644
--- a/drivers/acpi/namespace/nsaccess.c
+++ b/drivers/acpi/namespace/nsaccess.c
@@ -1,9 +1,9 @@
-
-/******************************************************************************
+/*******************************************************************************
*
* Module Name: nsaccess - Top-level functions for accessing ACPI namespace
+ * $Revision: 108 $
*
- *****************************************************************************/
+ ******************************************************************************/
/*
* Copyright (C) 2000 R. Byron Moore
@@ -26,59 +26,16 @@
#include "acpi.h"
#include "amlcode.h"
-#include "interp.h"
-#include "namesp.h"
-#include "dispatch.h"
+#include "acinterp.h"
+#include "acnamesp.h"
+#include "acdispat.h"
#define _COMPONENT NAMESPACE
- MODULE_NAME ("nsaccess");
-
-
-/****************************************************************************
- *
- * FUNCTION: Acpi_ns_root_create_scope
- *
- * PARAMETERS: Entry - NTE for which a scope will be created
- *
- * RETURN: Status
- *
- * DESCRIPTION: Create a scope table for the given name table entry
- *
- * MUTEX: Expects namespace to be locked
- *
- ***************************************************************************/
-
-ACPI_STATUS
-acpi_ns_root_create_scope (
- ACPI_NAMED_OBJECT *entry)
-{
-
- /* Allocate a scope table */
-
- if (entry->child_table) {
- return (AE_EXIST);
- }
-
- entry->child_table = acpi_ns_allocate_name_table (NS_TABLE_SIZE);
- if (!entry->child_table) {
- /* root name table allocation failure */
-
- REPORT_ERROR ("Root name table allocation failure");
- return (AE_NO_MEMORY);
- }
-
- /*
- * Init the scope first entry -- since it is the exemplar of
- * the scope (Some fields are duplicated to new entries!)
- */
- acpi_ns_initialize_table (entry->child_table, NULL, entry);
- return (AE_OK);
-
-}
+ MODULE_NAME ("nsaccess")
-/****************************************************************************
+/*******************************************************************************
*
* FUNCTION: Acpi_ns_root_initialize
*
@@ -86,40 +43,41 @@ acpi_ns_root_create_scope (
*
* RETURN: Status
*
- * DESCRIPTION: Allocate and initialize the root name table
+ * DESCRIPTION: Allocate and initialize the default root named objects
*
* MUTEX: Locks namespace for entire execution
*
- ***************************************************************************/
+ ******************************************************************************/
ACPI_STATUS
acpi_ns_root_initialize (void)
{
ACPI_STATUS status = AE_OK;
PREDEFINED_NAMES *init_val = NULL;
- ACPI_NAMED_OBJECT *new_entry;
- ACPI_OBJECT_INTERNAL *obj_desc;
+ ACPI_NAMESPACE_NODE *new_node;
+ ACPI_OPERAND_OBJECT *obj_desc;
acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE);
/*
- * Root is initially NULL, so a non-NULL value indicates
+ * The global root ptr is initially NULL, so a non-NULL value indicates
* that Acpi_ns_root_initialize() has already been called; just return.
*/
- if (acpi_gbl_root_object->child_table) {
+ if (acpi_gbl_root_node) {
status = AE_OK;
goto unlock_and_exit;
}
- /* Create the root scope */
+ /*
+ * 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;
- status = acpi_ns_root_create_scope (acpi_gbl_root_object);
- if (ACPI_FAILURE (status)) {
- goto unlock_and_exit;
- }
/* Enter the pre-defined names in the name table */
@@ -127,25 +85,25 @@ acpi_ns_root_initialize (void)
status = acpi_ns_lookup (NULL, init_val->name,
(OBJECT_TYPE_INTERNAL) init_val->type,
IMODE_LOAD_PASS2, NS_NO_UPSEARCH,
- NULL, &new_entry);
+ NULL, &new_node);
+
+ if (ACPI_FAILURE (status) ||
+ (!new_node))
/*
- * if name entered successfully
- * && its entry in Pre_defined_names[] specifies an
- * initial value
+ * Name entered successfully.
+ * If entry in Pre_defined_names[] specifies an
+ * initial value, create the initial value.
*/
- if ((status == AE_OK) &&
- new_entry && init_val->val)
- {
+ if (init_val->val) {
/*
* Entry requests an initial value, allocate a
* descriptor for it.
*/
- obj_desc =
- acpi_cm_create_internal_object (
- (OBJECT_TYPE_INTERNAL) init_val->type);
+ obj_desc = acpi_cm_create_internal_object (
+ (OBJECT_TYPE_INTERNAL) init_val->type);
if (!obj_desc) {
status = AE_NO_MEMORY;
@@ -164,23 +122,22 @@ acpi_ns_root_initialize (void)
case ACPI_TYPE_NUMBER:
obj_desc->number.value =
- (u32) STRTOUL (init_val->val, NULL, 10);
+ (u32) STRTOUL (init_val->val, NULL, 10);
break;
case ACPI_TYPE_STRING:
obj_desc->string.length =
- (u16) STRLEN (init_val->val);
+ (u16) STRLEN (init_val->val);
/*
* Allocate a buffer for the string. All
* String.Pointers must be allocated buffers!
* (makes deletion simpler)
*/
- obj_desc->string.pointer =
- acpi_cm_allocate ((ACPI_SIZE)
- (obj_desc->string.length + 1));
+ obj_desc->string.pointer = acpi_cm_allocate (
+ (obj_desc->string.length + 1));
if (!obj_desc->string.pointer) {
REPORT_ERROR ("Initial value string"
@@ -191,24 +148,22 @@ acpi_ns_root_initialize (void)
goto unlock_and_exit;
}
- STRCPY ((char *) obj_desc->string.pointer,
- init_val->val);
+ STRCPY (obj_desc->string.pointer, init_val->val);
break;
case ACPI_TYPE_MUTEX:
obj_desc->mutex.sync_level =
- (u16) STRTOUL (init_val->val, NULL, 10);
+ (u16) STRTOUL (init_val->val, NULL, 10);
if (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);
+ status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT,
+ 1, &obj_desc->mutex.semaphore);
if (ACPI_FAILURE (status)) {
goto unlock_and_exit;
@@ -218,8 +173,7 @@ acpi_ns_root_initialize (void)
* global lock, save it
*/
- acpi_gbl_global_lock_semaphore =
- obj_desc->mutex.semaphore;
+ acpi_gbl_global_lock_semaphore = obj_desc->mutex.semaphore;
}
else {
@@ -232,11 +186,6 @@ acpi_ns_root_initialize (void)
goto unlock_and_exit;
}
}
-
- /* TBD: [Restructure] These fields may be obsolete */
-
- obj_desc->mutex.lock_count = 0;
- obj_desc->mutex.thread_id = 0;
break;
@@ -247,9 +196,9 @@ acpi_ns_root_initialize (void)
continue;
}
- /* Store pointer to value descriptor in nte */
+ /* Store pointer to value descriptor in the Node */
- acpi_ns_attach_object (new_entry, obj_desc,
+ acpi_ns_attach_object (new_node, obj_desc,
obj_desc->common.type);
}
}
@@ -261,16 +210,19 @@ unlock_and_exit:
}
-/****************************************************************************
+/*******************************************************************************
*
* FUNCTION: Acpi_ns_lookup
*
- * PARAMETERS: Prefix_scope - Search scope if name is not fully qualified
+ * PARAMETERS: Prefix_node - Search scope if name is not fully qualified
* Pathname - Search pathname, in internal format
* (as represented in the AML stream)
* Type - Type associated with name
* Interpreter_mode - IMODE_LOAD_PASS2 => add name if not found
- * Ret_entry - Where the new entry (NTE) is placed
+ * Flags - Flags describing the search restrictions
+ * Walk_state - Current state of the walk
+ * Return_node - Where the Node is placed (if found
+ * or created successfully)
*
* RETURN: Status
*
@@ -279,55 +231,42 @@ unlock_and_exit:
*
* MUTEX: Assumes namespace is locked.
*
- ***************************************************************************/
+ ******************************************************************************/
ACPI_STATUS
acpi_ns_lookup (
ACPI_GENERIC_STATE *scope_info,
- char *pathname,
+ NATIVE_CHAR *pathname,
OBJECT_TYPE_INTERNAL type,
OPERATING_MODE interpreter_mode,
u32 flags,
ACPI_WALK_STATE *walk_state,
- ACPI_NAMED_OBJECT **ret_entry)
+ ACPI_NAMESPACE_NODE **return_node)
{
ACPI_STATUS status;
- ACPI_NAME_TABLE *prefix_scope;
- ACPI_NAME_TABLE *table_to_search = NULL;
- ACPI_NAME_TABLE *scope_to_push = NULL;
- ACPI_NAMED_OBJECT *this_entry = NULL;
+ 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;
OBJECT_TYPE_INTERNAL type_to_check_for;
OBJECT_TYPE_INTERNAL this_search_type;
- if (!ret_entry) {
+ if (!return_node) {
return (AE_BAD_PARAMETER);
}
acpi_gbl_ns_lookup_count++;
- *ret_entry = ENTRY_NOT_FOUND;
- if (!acpi_gbl_root_object->child_table) {
- /*
- * If the name space has not been initialized:
- * - In Pass1 of Load mode, we need to initialize it
- * before trying to define a name.
- * - In Exec mode, there are no names to be found.
- */
+ *return_node = ENTRY_NOT_FOUND;
- if (IMODE_LOAD_PASS1 == interpreter_mode) {
- if ((status = acpi_ns_root_initialize ()) != AE_OK) {
- return (status);
- }
- }
- else {
- return (AE_NOT_FOUND);
- }
- }
+ if (!acpi_gbl_root_node) {
+ return (AE_NO_NAMESPACE);
+ }
/*
* Get the prefix scope.
@@ -335,12 +274,12 @@ acpi_ns_lookup (
*/
if ((!scope_info) ||
- (!scope_info->scope.name_table))
+ (!scope_info->scope.node))
{
- prefix_scope = acpi_gbl_root_object->child_table;
+ prefix_node = acpi_gbl_root_node;
}
else {
- prefix_scope = scope_info->scope.name_table;
+ prefix_node = scope_info->scope.node;
}
@@ -369,6 +308,8 @@ acpi_ns_lookup (
}
+ /* TBD: [Restructure] - Move the pathname stuff into a new procedure */
+
/* Examine the name pointer */
if (!pathname) {
@@ -376,7 +317,7 @@ acpi_ns_lookup (
null_name_path = TRUE;
num_segments = 0;
- this_entry = acpi_gbl_root_object;
+ this_node = acpi_gbl_root_node;
}
@@ -403,14 +344,16 @@ acpi_ns_lookup (
if (*pathname == AML_ROOT_PREFIX) {
/* Pathname is fully qualified, look in root name table */
- table_to_search = acpi_gbl_root_object->child_table;
+ current_node = acpi_gbl_root_node;
+
/* point to segment part */
+
pathname++;
/* Direct reference to root, "\" */
if (!(*pathname)) {
- this_entry = acpi_gbl_root_object;
+ this_node = acpi_gbl_root_node;
goto check_for_new_scope_and_exit;
}
}
@@ -418,7 +361,7 @@ acpi_ns_lookup (
else {
/* Pathname is relative to current scope, start there */
- table_to_search = prefix_scope;
+ current_node = prefix_node;
/*
* Handle up-prefix (carat). More than one prefix
@@ -426,23 +369,22 @@ acpi_ns_lookup (
*/
while (*pathname == AML_PARENT_PREFIX) {
-
/* Point to segment part or next Parent_prefix */
pathname++;
/* Backup to the parent's scope */
- table_to_search = table_to_search->parent_table;
- if (!table_to_search) {
+ this_node = acpi_ns_get_parent_object (current_node);
+ if (!this_node) {
/* Current scope has no parent scope */
- REPORT_ERROR ("Ns_lookup: Too many parent"
- "prefixes or scope has no parent");
-
+ REPORT_ERROR ("Too many parent prefixes (^) - reached root");
return (AE_NOT_FOUND);
}
+
+ current_node = this_node;
}
}
@@ -454,14 +396,18 @@ acpi_ns_lookup (
if (*pathname == AML_DUAL_NAME_PREFIX) {
num_segments = 2;
+
/* point to first segment */
+
pathname++;
}
else if (*pathname == AML_MULTI_NAME_PREFIX_OP) {
- num_segments = (s32)* (u8 *) ++pathname;
+ num_segments = (u32)* (u8 *) ++pathname;
+
/* point to first segment */
+
pathname++;
}
@@ -484,32 +430,32 @@ acpi_ns_lookup (
*/
- while (num_segments-- && table_to_search) {
+ while (num_segments-- && current_node) {
/*
- * Search for the current segment in the table where
- * it should be.
- * Type is significant only at the last (topmost) level.
+ * 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
+ * the type of the final target object.)
*/
this_search_type = ACPI_TYPE_ANY;
if (!num_segments) {
this_search_type = type;
}
+ /* Pluck and ACPI name from the front of the pathname */
+
MOVE_UNALIGNED32_TO_32 (&simple_name, pathname);
+
+ /* Try to find the ACPI name */
+
status = acpi_ns_search_and_enter (simple_name, walk_state,
- table_to_search, interpreter_mode,
+ current_node, interpreter_mode,
this_search_type, flags,
- &this_entry);
+ &this_node);
- if (status != AE_OK) {
+ if (ACPI_FAILURE (status)) {
if (status == AE_NOT_FOUND) {
- /* Name not in ACPI namespace */
-
- if (IMODE_LOAD_PASS1 == interpreter_mode ||
- IMODE_LOAD_PASS2 == interpreter_mode)
- {
- REPORT_ERROR ("Name table overflow");
- }
+ /* Name not found in ACPI namespace */
}
@@ -518,92 +464,54 @@ acpi_ns_lookup (
/*
- * If 1) last segment (Num_segments == 0)
+ * If 1) This is the last segment (Num_segments == 0)
* 2) and looking for a specific type
* (Not checking for TYPE_ANY)
* 3) which is not a local type (TYPE_DEF_ANY)
* 4) which is not a local type (TYPE_SCOPE)
* 5) which is not a local type (TYPE_INDEX_FIELD_DEFN)
- * 6) and type of entry is known (not TYPE_ANY)
- * 7) and entry does not match request
+ * 6) and type of object is known (not TYPE_ANY)
+ * 7) and object does not match request
*
* Then we have a type mismatch. Just warn and ignore it.
*/
- if ((num_segments == 0) &&
- (type_to_check_for != ACPI_TYPE_ANY) &&
- (type_to_check_for != INTERNAL_TYPE_DEF_ANY) &&
- (type_to_check_for != INTERNAL_TYPE_SCOPE) &&
- (type_to_check_for != INTERNAL_TYPE_INDEX_FIELD_DEFN) &&
- (this_entry->type != ACPI_TYPE_ANY) &&
- (this_entry->type != type_to_check_for))
+ if ((num_segments == 0) &&
+ (type_to_check_for != ACPI_TYPE_ANY) &&
+ (type_to_check_for != INTERNAL_TYPE_DEF_ANY) &&
+ (type_to_check_for != INTERNAL_TYPE_SCOPE) &&
+ (type_to_check_for != INTERNAL_TYPE_INDEX_FIELD_DEFN) &&
+ (this_node->type != ACPI_TYPE_ANY) &&
+ (this_node->type != type_to_check_for))
{
- /* Complain about type mismatch */
+ /* Complain about a type mismatch */
REPORT_WARNING ("Type mismatch");
}
/*
- * If last segment and not looking for a specific type, but type of
- * found entry is known, use that type to see if it opens a scope.
+ * If this is the last name segment and we are not looking for a
+ * 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)) {
- type = this_entry->type;
+ type = this_node->type;
}
if ((num_segments || acpi_ns_opens_scope (type)) &&
- (this_entry->child_table == NULL))
+ (this_node->child == NULL))
{
/*
* More segments or the type implies enclosed scope,
* and the next scope has not been allocated.
*/
- if ((IMODE_LOAD_PASS1 == interpreter_mode) ||
- (IMODE_LOAD_PASS2 == interpreter_mode))
- {
- /*
- * First or second pass load mode
- * ==> locate the next scope
- */
-
- this_entry->child_table =
- acpi_ns_allocate_name_table (NS_TABLE_SIZE);
-
- if (!this_entry->child_table) {
- return (AE_NO_MEMORY);
- }
- }
-
- /* Now complain if there is no next scope */
-
- if (this_entry->child_table == NULL) {
- if (IMODE_LOAD_PASS1 == interpreter_mode ||
- IMODE_LOAD_PASS2 == interpreter_mode)
- {
- REPORT_ERROR ("Name Table allocation failure");
- return (AE_NOT_FOUND);
- }
-
- return (AE_NOT_FOUND);
- }
-
-
- /* Scope table initialization */
-
- if (IMODE_LOAD_PASS1 == interpreter_mode ||
- IMODE_LOAD_PASS2 == interpreter_mode)
- {
- /* Initialize the new table */
-
- acpi_ns_initialize_table (this_entry->child_table,
- table_to_search,
- this_entry);
- }
}
- table_to_search = this_entry->child_table;
+ current_node = this_node;
+
/* point to next name segment */
+
pathname += ACPI_NAME_SIZE;
}
@@ -629,7 +537,7 @@ check_for_new_scope_and_exit:
scope_to_push = NULL;
}
else {
- scope_to_push = this_entry->child_table;
+ scope_to_push = this_node;
}
status = acpi_ds_scope_stack_push (scope_to_push, type,
@@ -641,7 +549,7 @@ check_for_new_scope_and_exit:
}
}
- *ret_entry = this_entry;
+ *return_node = this_node;
return (AE_OK);
}
diff --git a/drivers/acpi/namespace/nsalloc.c b/drivers/acpi/namespace/nsalloc.c
index 414f3791a..0b8272724 100644
--- a/drivers/acpi/namespace/nsalloc.c
+++ b/drivers/acpi/namespace/nsalloc.c
@@ -1,9 +1,9 @@
-
-/******************************************************************************
+/*******************************************************************************
*
* Module Name: nsalloc - Namespace allocation and deletion utilities
+ * $Revision: 41 $
*
- *****************************************************************************/
+ ******************************************************************************/
/*
* Copyright (C) 2000 R. Byron Moore
@@ -25,46 +25,303 @@
#include "acpi.h"
-#include "namesp.h"
-#include "interp.h"
+#include "acnamesp.h"
+#include "acinterp.h"
#define _COMPONENT NAMESPACE
- MODULE_NAME ("nsalloc");
+ MODULE_NAME ("nsalloc")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: Acpi_ns_create_node
+ *
+ * PARAMETERS:
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION:
+ *
+ ******************************************************************************/
+
+ACPI_NAMESPACE_NODE *
+acpi_ns_create_node (
+ u32 acpi_name)
+{
+ ACPI_NAMESPACE_NODE *node;
+
+
+ node = acpi_cm_callocate (sizeof (ACPI_NAMESPACE_NODE));
+ if (!node) {
+ return (NULL);
+ }
+
+ INCREMENT_NAME_TABLE_METRICS (sizeof (ACPI_NAMESPACE_NODE));
+
+ node->data_type = ACPI_DESC_TYPE_NAMED;
+ node->name = acpi_name;
+ node->reference_count = 1;
+
+ return (node);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: Acpi_ns_delete_node
+ *
+ * PARAMETERS:
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION:
+ *
+ ******************************************************************************/
+
+void
+acpi_ns_delete_node (
+ ACPI_NAMESPACE_NODE *node)
+{
+ ACPI_NAMESPACE_NODE *parent_node;
+ ACPI_NAMESPACE_NODE *prev_node;
+ ACPI_NAMESPACE_NODE *next_node;
+
+
+ parent_node = acpi_ns_get_parent_object (node);
+
+ prev_node = NULL;
+ next_node = parent_node->child;
+
+ while (next_node != node) {
+ prev_node = next_node;
+ next_node = prev_node->peer;
+ }
+
+ if (prev_node) {
+ prev_node->peer = next_node->peer;
+ if (next_node->flags & ANOBJ_END_OF_PEER_LIST) {
+ prev_node->flags |= ANOBJ_END_OF_PEER_LIST;
+ }
+ }
+ else {
+ parent_node->child = next_node->peer;
+ }
+
+
+ DECREMENT_NAME_TABLE_METRICS (sizeof (ACPI_NAMESPACE_NODE));
+
+ /*
+ * Detach an object if there is one
+ */
+
+ if (node->object) {
+ acpi_ns_detach_object (node);
+ }
+
+ acpi_cm_free (node);
+
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: Acpi_ns_install_node
+ *
+ * PARAMETERS: Walk_state - Current state of the walk
+ * Parent_node - The parent of the new Node
+ * Node - The new Node to install
+ * Type - ACPI object type of the new Node
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Initialize a new entry within a namespace table.
+ *
+ ******************************************************************************/
+
+void
+acpi_ns_install_node (
+ ACPI_WALK_STATE *walk_state,
+ ACPI_NAMESPACE_NODE *parent_node, /* Parent */
+ ACPI_NAMESPACE_NODE *node, /* New Child*/
+ OBJECT_TYPE_INTERNAL type)
+{
+ u16 owner_id = TABLE_ID_DSDT;
+ ACPI_NAMESPACE_NODE *child_node;
+
+
+ /*
+ * Get the owner ID from the Walk state
+ * The owner ID is used to track table deletion and
+ * deletion of objects created by methods
+ */
+ if (walk_state) {
+ owner_id = walk_state->owner_id;
+ }
+
+
+ /* link the new entry into the parent and existing children */
+
+ /* TBD: Could be first, last, or alphabetic */
+
+ 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;
+ }
+
+ child_node->peer = node;
+
+ /* Clear end-of-list flag */
+
+ child_node->flags &= ~ANOBJ_END_OF_PEER_LIST;
+ }
+
+ /* Init the new entry */
+
+ node->owner_id = owner_id;
+ node->flags |= ANOBJ_END_OF_PEER_LIST;
+ node->peer = parent_node;
+
+
+ /*
+ * If adding a name with unknown type, or having to
+ * add the region in order to define fields in it, we
+ * have a forward reference.
+ */
+
+ if ((ACPI_TYPE_ANY == type) ||
+ (INTERNAL_TYPE_DEF_FIELD_DEFN == type) ||
+ (INTERNAL_TYPE_BANK_FIELD_DEFN == type))
+ {
+ /*
+ * We don't want to abort here, however!
+ * We will fill in the actual type when the
+ * real definition is found later.
+ */
+
+ }
+
+ /*
+ * The Def_field_defn and Bank_field_defn cases are actually
+ * looking up the Region in which the field will be defined
+ */
+
+ if ((INTERNAL_TYPE_DEF_FIELD_DEFN == type) ||
+ (INTERNAL_TYPE_BANK_FIELD_DEFN == type))
+ {
+ type = ACPI_TYPE_REGION;
+ }
+
+ /*
+ * Scope, Def_any, and Index_field_defn are bogus "types" which do
+ * not actually have anything to do with the type of the name
+ * being looked up. Save any other value of Type as the type of
+ * the entry.
+ */
+
+ if ((type != INTERNAL_TYPE_SCOPE) &&
+ (type != INTERNAL_TYPE_DEF_ANY) &&
+ (type != INTERNAL_TYPE_INDEX_FIELD_DEFN))
+ {
+ node->type = (u8) type;
+ }
+
+ /*
+ * Increment the reference count(s) of all parents up to
+ * the root!
+ */
+
+ while ((node = acpi_ns_get_parent_object (node)) != NULL) {
+ node->reference_count++;
+ }
+
+ return;
+}
-/****************************************************************************
+/*******************************************************************************
*
- * FUNCTION: Acpi_ns_allocate_name_table
+ * FUNCTION: Acpi_ns_delete_children
*
- * PARAMETERS: Nte_count - Count of NTEs to allocate
+ * PARAMETERS: Parent_node - Delete this objects children
*
- * RETURN: The address of the first nte in the array, or NULL
+ * RETURN: None.
*
- * DESCRIPTION: Allocate an array of nte, including prepended link space
- * Array is set to all zeros via Acpi_os_callcate().
+ * DESCRIPTION: Delete all children of the parent object. Deletes a
+ * "scope".
*
- ***************************************************************************/
+ ******************************************************************************/
-ACPI_NAME_TABLE *
-acpi_ns_allocate_name_table (
- u32 num_entries)
+void
+acpi_ns_delete_children (
+ ACPI_NAMESPACE_NODE *parent_node)
{
- ACPI_NAME_TABLE *name_table = NULL;
- ACPI_SIZE alloc_size;
+ ACPI_NAMESPACE_NODE *child_node;
+ ACPI_NAMESPACE_NODE *next_node;
+ u8 flags;
+
+
+ if (!parent_node) {
+ return;
+ }
+
+ /* If no children, all done! */
+
+ child_node = parent_node->child;
+ if (!child_node) {
+ return;
+ }
+
+ /*
+ * Deallocate all children at this level
+ */
+ do
+ {
+ /* Get the things we need */
+
+ next_node = child_node->peer;
+ flags = child_node->flags;
+
+ /* Grandchildren should have all been deleted already */
+
+ /* Now we can free this child object */
- alloc_size = sizeof (ACPI_NAME_TABLE) + ((num_entries - 1) *
- sizeof (ACPI_NAMED_OBJECT));
+ DECREMENT_NAME_TABLE_METRICS (sizeof (ACPI_NAMESPACE_NODE));
- name_table = acpi_cm_callocate (alloc_size);
+ /*
+ * Detach an object if there is one
+ */
+
+ if (child_node->object) {
+ acpi_ns_detach_object (child_node);
+ }
+
+ acpi_cm_free (child_node);
+
+ /* And move on to the next child in the list */
+
+ child_node = next_node;
+ } while (!(flags & ANOBJ_END_OF_PEER_LIST));
- return (name_table);
+
+ /* Clear the parent's child pointer */
+
+ parent_node->child = NULL;
+
+ return;
}
-/****************************************************************************
+/*******************************************************************************
*
* FUNCTION: Acpi_ns_delete_namespace_subtree
*
@@ -72,22 +329,27 @@ acpi_ns_allocate_name_table (
*
* RETURN: None.
*
- * DESCRIPTION: Delete a subtree of the namespace. This includes all objects stored
- * within the subtree. Scope tables are deleted also
+ * DESCRIPTION: Delete a subtree of the namespace. This includes all objects
+ * stored within the subtree. Scope tables are deleted also
*
- ***************************************************************************/
+ ******************************************************************************/
ACPI_STATUS
acpi_ns_delete_namespace_subtree (
- ACPI_NAMED_OBJECT *parent_entry)
+ ACPI_NAMESPACE_NODE *parent_node)
{
- ACPI_NAMED_OBJECT *child_entry;
+ ACPI_NAMESPACE_NODE *child_node;
+ ACPI_OPERAND_OBJECT *obj_desc;
u32 level;
- ACPI_OBJECT_INTERNAL *obj_desc;
- child_entry = 0;
- level = 1;
+ if (!parent_node) {
+ return (AE_OK);
+ }
+
+
+ child_node = 0;
+ level = 1;
/*
* Traverse the tree of objects until we bubble back up
@@ -100,53 +362,32 @@ acpi_ns_delete_namespace_subtree (
* Null returned if not found
*/
- child_entry = acpi_ns_get_next_object (ACPI_TYPE_ANY,
- parent_entry,
- child_entry);
-
- if (child_entry) {
+ child_node = acpi_ns_get_next_object (ACPI_TYPE_ANY, parent_node,
+ child_node);
+ if (child_node) {
/*
* Found an object - delete the object within
* the Value field
*/
- obj_desc = acpi_ns_get_attached_object (child_entry);
+ obj_desc = acpi_ns_get_attached_object (child_node);
if (obj_desc) {
- acpi_ns_detach_object (child_entry);
+ acpi_ns_detach_object (child_node);
acpi_cm_remove_reference (obj_desc);
}
- /*
- * Clear the NTE in case this scope is reused
- * (e.g., a control method scope)
- */
-
- child_entry->type = ACPI_TYPE_ANY;
- child_entry->name = 0;
-
/* Check if this object has any children */
- if (acpi_ns_get_next_object (ACPI_TYPE_ANY, child_entry, 0)) {
+ if (acpi_ns_get_next_object (ACPI_TYPE_ANY, child_node, 0)) {
/*
* There is at least one child of this object,
* visit the object
*/
level++;
- parent_entry = child_entry;
- child_entry = 0;
- }
-
- else {
- /*
- * There may be a name table even if there are
- * no children
- */
-
- acpi_ns_delete_name_table (child_entry->child_table);
- child_entry->child_table = NULL;
-
+ parent_node = child_node;
+ child_node = 0;
}
}
@@ -158,26 +399,18 @@ acpi_ns_delete_namespace_subtree (
level--;
/*
- * Delete the scope (Name Table) associated with
- * the parent object
+ * Now delete all of the children of this parent
+ * all at the same time.
*/
- /* Don't delete the top level scope, this allows
- * the dynamic deletion of objects created underneath
- * control methods!
- */
-
- if (level != 0) {
- acpi_ns_delete_name_table (parent_entry->child_table);
- parent_entry->child_table = NULL;
- }
+ acpi_ns_delete_children (parent_node);
/* New "last child" is this parent object */
- child_entry = parent_entry;
+ child_node = parent_node;
/* Now we can move up the tree to the grandparent */
- parent_entry = acpi_ns_get_parent_entry (parent_entry);
+ parent_node = acpi_ns_get_parent_object (parent_node);
}
}
@@ -186,70 +419,55 @@ acpi_ns_delete_namespace_subtree (
}
-/****************************************************************************
+/*******************************************************************************
*
* FUNCTION: Acpi_ns_remove_reference
*
- * PARAMETERS: Entry - NTE whose reference count is to be decremented
+ * PARAMETERS: Node - Named object whose reference count is to be
+ * decremented
*
* RETURN: None.
*
- * DESCRIPTION: Remove an NTE reference. Decrements the reference count of
- * all parent NTEs up to the root. Any NTE along the way that
- * reaches zero references is freed.
+ * DESCRIPTION: Remove a Node reference. Decrements the reference count
+ * of all parent Nodes up to the root. Any object along
+ * the way that reaches zero references is freed.
*
- ***************************************************************************/
+ ******************************************************************************/
void
acpi_ns_remove_reference (
- ACPI_NAMED_OBJECT *entry)
+ ACPI_NAMESPACE_NODE *node)
{
- ACPI_NAMED_OBJECT *this_entry;
-
-
- /* There may be a name table even if there are no children */
-
- acpi_ns_delete_name_table (entry->child_table);
- entry->child_table = NULL;
+ ACPI_NAMESPACE_NODE *next_node;
/*
- * Decrement the reference count(s) of all parents up to the root,
- * And delete anything with zero remaining references.
+ * Decrement the reference count(s) of this object and all
+ * objects up to the root, Delete anything with zero remaining references.
*/
- this_entry = entry;
- while (this_entry) {
- /* Decrement the reference */
+ next_node = node;
+ while (next_node) {
+ /* Decrement the reference count on this object*/
- this_entry->reference_count--;
+ next_node->reference_count--;
- /* Delete entry if no more references */
-
- if (!this_entry->reference_count) {
- /* Delete the scope if present */
-
- if (this_entry->child_table) {
- acpi_ns_delete_name_table (this_entry->child_table);
- this_entry->child_table = NULL;
- }
-
- /*
- * Mark the entry free
- * (This doesn't deallocate anything)
- */
+ /* Delete the object if no more references */
- acpi_ns_free_table_entry (this_entry);
+ if (!next_node->reference_count) {
+ /* Delete all children and delete the object */
+ acpi_ns_delete_children (next_node);
+ acpi_ns_delete_node (next_node);
}
/* Move up to parent */
- this_entry = acpi_ns_get_parent_entry (this_entry);
+ next_node = acpi_ns_get_parent_object (next_node);
}
}
-/****************************************************************************
+/*******************************************************************************
*
* FUNCTION: Acpi_ns_delete_namespace_by_owner
*
@@ -261,21 +479,21 @@ acpi_ns_remove_reference (
* specific ID. Used to delete entire ACPI tables. All
* reference counts are updated.
*
- ***************************************************************************/
+ ******************************************************************************/
ACPI_STATUS
acpi_ns_delete_namespace_by_owner (
u16 owner_id)
{
- ACPI_NAMED_OBJECT *child_entry;
+ ACPI_NAMESPACE_NODE *child_node;
u32 level;
- ACPI_OBJECT_INTERNAL *obj_desc;
- ACPI_NAMED_OBJECT *parent_entry;
+ ACPI_OPERAND_OBJECT *obj_desc;
+ ACPI_NAMESPACE_NODE *parent_node;
- parent_entry = acpi_gbl_root_object;
- child_entry = 0;
- level = 1;
+ parent_node = acpi_gbl_root_node;
+ child_node = 0;
+ level = 1;
/*
* Traverse the tree of objects until we bubble back up
@@ -288,73 +506,60 @@ acpi_ns_delete_namespace_by_owner (
* Null returned if not found
*/
- child_entry = acpi_ns_get_next_object (ACPI_TYPE_ANY,
- parent_entry,
- child_entry);
+ child_node = acpi_ns_get_next_object (ACPI_TYPE_ANY, parent_node,
+ child_node);
- if (child_entry) {
- if (child_entry->owner_id == owner_id) {
+ if (child_node) {
+ if (child_node->owner_id == owner_id) {
/*
* Found an object - delete the object within
* the Value field
*/
- obj_desc = acpi_ns_get_attached_object (child_entry);
+ obj_desc = acpi_ns_get_attached_object (child_node);
if (obj_desc) {
- acpi_ns_detach_object (child_entry);
+ acpi_ns_detach_object (child_node);
acpi_cm_remove_reference (obj_desc);
}
}
/* Check if this object has any children */
- if (acpi_ns_get_next_object (ACPI_TYPE_ANY, child_entry, 0)) {
+ if (acpi_ns_get_next_object (ACPI_TYPE_ANY, child_node, 0)) {
/*
* There is at least one child of this object,
* visit the object
*/
level++;
- parent_entry = child_entry;
- child_entry = 0;
+ parent_node = child_node;
+ child_node = 0;
}
- else if (child_entry->owner_id == owner_id) {
- acpi_ns_remove_reference (child_entry);
+ else if (child_node->owner_id == owner_id) {
+ acpi_ns_remove_reference (child_node);
}
}
else {
/*
- * No more children in this object.
- * We will move up to the grandparent.
+ * No more children in this object. Move up to grandparent.
*/
level--;
- /*
- * Delete the scope (Name Table) associated with
- * the parent object
- */
- /* Don't delete the top level scope, this allows
- * the dynamic deletion of objects created underneath
- * control methods!
- */
-
-
if (level != 0) {
- if (parent_entry->owner_id == owner_id) {
- acpi_ns_remove_reference (parent_entry);
+ if (parent_node->owner_id == owner_id) {
+ acpi_ns_remove_reference (parent_node);
}
}
-
/* New "last child" is this parent object */
- child_entry = parent_entry;
+ child_node = parent_node;
/* Now we can move up the tree to the grandparent */
- parent_entry = acpi_ns_get_parent_entry (parent_entry);
+ parent_node = acpi_ns_get_parent_object (parent_node);
}
}
@@ -363,49 +568,3 @@ acpi_ns_delete_namespace_by_owner (
}
-/****************************************************************************
- *
- * FUNCTION: Acpi_ns_delete_name_table
- *
- * PARAMETERS: Scope - A handle to the scope to be deleted
- *
- * RETURN: None.
- *
- * DESCRIPTION: Delete a namespace Name Table with zero or
- * more appendages. The table and all appendages are deleted.
- *
- ***************************************************************************/
-
-void
-acpi_ns_delete_name_table (
- ACPI_NAME_TABLE *name_table)
-{
- ACPI_NAME_TABLE *this_table;
- ACPI_NAME_TABLE *next_table;
-
-
- if (!name_table) {
- return;
- }
-
- this_table = name_table;
-
-
- /*
- * Deallocate the name table and all appendages
- */
- do
- {
- next_table = this_table->next_table;
-
- /* Now we can free the table */
-
- acpi_cm_free (this_table);
- this_table = next_table;
-
- } while (this_table);
-
- return;
-}
-
-
diff --git a/drivers/acpi/namespace/nsdump.c b/drivers/acpi/namespace/nsdump.c
new file mode 100644
index 000000000..117af81e3
--- /dev/null
+++ b/drivers/acpi/namespace/nsdump.c
@@ -0,0 +1,36 @@
+/******************************************************************************
+ *
+ * Module Name: nsdump - table dumping routines for debug
+ * $Revision: 78 $
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 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 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
+ */
+
+
+#include "acpi.h"
+#include "acinterp.h"
+#include "acnamesp.h"
+#include "actables.h"
+
+
+#define _COMPONENT NAMESPACE
+ MODULE_NAME ("nsdump")
+
+
diff --git a/drivers/acpi/namespace/nseval.c b/drivers/acpi/namespace/nseval.c
index ea3e15621..2df17e94f 100644
--- a/drivers/acpi/namespace/nseval.c
+++ b/drivers/acpi/namespace/nseval.c
@@ -1,10 +1,10 @@
-
-/******************************************************************************
+/*******************************************************************************
*
* Module Name: nseval - Object evaluation interfaces -- includes control
* method lookup and execution.
+ * $Revision: 76 $
*
- *****************************************************************************/
+ ******************************************************************************/
/*
* Copyright (C) 2000 R. Byron Moore
@@ -27,20 +27,20 @@
#include "acpi.h"
#include "amlcode.h"
-#include "parser.h"
-#include "interp.h"
-#include "namesp.h"
+#include "acparser.h"
+#include "acinterp.h"
+#include "acnamesp.h"
#define _COMPONENT NAMESPACE
- MODULE_NAME ("nseval");
+ MODULE_NAME ("nseval")
-/****************************************************************************
+/*******************************************************************************
*
* FUNCTION: Acpi_ns_evaluate_relative
*
- * PARAMETERS: Rel_obj_entry - NTE of the relative containing object
+ * PARAMETERS: Handle - The relative containing object
* *Pathname - Name of method to execute, If NULL, the
* handle is the object to execute
* **Params - List of parameters to pass to the method,
@@ -56,19 +56,19 @@
*
* MUTEX: Locks Namespace
*
- ****************************************************************************/
+ ******************************************************************************/
ACPI_STATUS
acpi_ns_evaluate_relative (
- ACPI_NAMED_OBJECT *handle,
- char *pathname,
- ACPI_OBJECT_INTERNAL **params,
- ACPI_OBJECT_INTERNAL **return_object)
+ ACPI_NAMESPACE_NODE *handle,
+ NATIVE_CHAR *pathname,
+ ACPI_OPERAND_OBJECT **params,
+ ACPI_OPERAND_OBJECT **return_object)
{
- ACPI_NAMED_OBJECT *rel_obj_entry;
+ ACPI_NAMESPACE_NODE *prefix_node;
ACPI_STATUS status;
- ACPI_NAMED_OBJECT *obj_entry = NULL;
- char *internal_path = NULL;
+ ACPI_NAMESPACE_NODE *node = NULL;
+ NATIVE_CHAR *internal_path = NULL;
ACPI_GENERIC_STATE scope_info;
@@ -86,12 +86,12 @@ acpi_ns_evaluate_relative (
return (status);
}
- /* Get the prefix handle and NTE */
+ /* Get the prefix handle and Node */
acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE);
- rel_obj_entry = acpi_ns_convert_handle_to_entry (handle);
- if (!rel_obj_entry) {
+ prefix_node = acpi_ns_convert_handle_to_entry (handle);
+ if (!prefix_node) {
acpi_cm_release_mutex (ACPI_MTX_NAMESPACE);
status = AE_BAD_PARAMETER;
goto cleanup;
@@ -99,15 +99,14 @@ acpi_ns_evaluate_relative (
/* Lookup the name in the namespace */
- scope_info.scope.name_table = rel_obj_entry->child_table;
+ scope_info.scope.node = prefix_node->child;
status = acpi_ns_lookup (&scope_info, internal_path, ACPI_TYPE_ANY,
- IMODE_EXECUTE,
- NS_NO_UPSEARCH, NULL,
- &obj_entry);
+ IMODE_EXECUTE, NS_NO_UPSEARCH, NULL,
+ &node);
acpi_cm_release_mutex (ACPI_MTX_NAMESPACE);
- if (status != AE_OK) {
+ if (ACPI_FAILURE (status)) {
goto cleanup;
}
@@ -116,7 +115,7 @@ acpi_ns_evaluate_relative (
* to evaluate it.
*/
- status = acpi_ns_evaluate_by_handle (obj_entry, params, return_object);
+ status = acpi_ns_evaluate_by_handle (node, params, return_object);
cleanup:
@@ -128,7 +127,7 @@ cleanup:
}
-/****************************************************************************
+/*******************************************************************************
*
* FUNCTION: Acpi_ns_evaluate_by_name
*
@@ -146,26 +145,24 @@ cleanup:
*
* MUTEX: Locks Namespace
*
- ****************************************************************************/
+ ******************************************************************************/
ACPI_STATUS
acpi_ns_evaluate_by_name (
- char *pathname,
- ACPI_OBJECT_INTERNAL **params,
- ACPI_OBJECT_INTERNAL **return_object)
+ NATIVE_CHAR *pathname,
+ ACPI_OPERAND_OBJECT **params,
+ ACPI_OPERAND_OBJECT **return_object)
{
ACPI_STATUS status;
- ACPI_NAMED_OBJECT *obj_entry = NULL;
- char *internal_path = NULL;
+ ACPI_NAMESPACE_NODE *node = NULL;
+ NATIVE_CHAR *internal_path = NULL;
/* Build an internal name string for the method */
- if (pathname[0] != '\\' || pathname[1] != '/') {
- status = acpi_ns_internalize_name (pathname, &internal_path);
- if (ACPI_FAILURE (status)) {
- return (status);
- }
+ status = acpi_ns_internalize_name (pathname, &internal_path);
+ if (ACPI_FAILURE (status)) {
+ return (status);
}
acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE);
@@ -173,13 +170,12 @@ acpi_ns_evaluate_by_name (
/* Lookup the name in the namespace */
status = acpi_ns_lookup (NULL, internal_path, ACPI_TYPE_ANY,
- IMODE_EXECUTE,
- NS_NO_UPSEARCH, NULL,
- &obj_entry);
+ IMODE_EXECUTE, NS_NO_UPSEARCH, NULL,
+ &node);
acpi_cm_release_mutex (ACPI_MTX_NAMESPACE);
- if (status != AE_OK) {
+ if (ACPI_FAILURE (status)) {
goto cleanup;
}
@@ -188,7 +184,7 @@ acpi_ns_evaluate_by_name (
* to evaluate it.
*/
- status = acpi_ns_evaluate_by_handle (obj_entry, params, return_object);
+ status = acpi_ns_evaluate_by_handle (node, params, return_object);
cleanup:
@@ -203,16 +199,16 @@ cleanup:
}
-/****************************************************************************
+/*******************************************************************************
*
* FUNCTION: Acpi_ns_evaluate_by_handle
*
- * PARAMETERS: Obj_entry - NTE of method to execute
- * *Return_object - Where to put method's return value (if
- * any). If NULL, no value is returned.
+ * PARAMETERS: Handle - Method Node to execute
* **Params - List of parameters to pass to the method,
* terminated by NULL. Params itself may be
* NULL if no parameters are being passed.
+ * *Return_object - Where to put method's return value (if
+ * any). If NULL, no value is returned.
*
* RETURN: Status
*
@@ -220,22 +216,22 @@ cleanup:
*
* MUTEX: Locks Namespace
*
- ****************************************************************************/
+ ******************************************************************************/
ACPI_STATUS
acpi_ns_evaluate_by_handle (
- ACPI_NAMED_OBJECT *handle,
- ACPI_OBJECT_INTERNAL **params,
- ACPI_OBJECT_INTERNAL **return_object)
+ ACPI_NAMESPACE_NODE *handle,
+ ACPI_OPERAND_OBJECT **params,
+ ACPI_OPERAND_OBJECT **return_object)
{
- ACPI_NAMED_OBJECT *obj_entry;
+ ACPI_NAMESPACE_NODE *node;
ACPI_STATUS status;
- ACPI_OBJECT_INTERNAL *local_return_object;
+ ACPI_OPERAND_OBJECT *local_return_object;
/* Check if namespace has been initialized */
- if (!acpi_gbl_root_object->child_table) {
+ if (!acpi_gbl_root_node) {
return (AE_NO_NAMESPACE);
}
@@ -251,12 +247,12 @@ acpi_ns_evaluate_by_handle (
*return_object = NULL;
}
- /* Get the prefix handle and NTE */
+ /* Get the prefix handle and Node */
acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE);
- obj_entry = acpi_ns_convert_handle_to_entry (handle);
- if (!obj_entry) {
+ node = acpi_ns_convert_handle_to_entry (handle);
+ if (!node) {
status = AE_BAD_PARAMETER;
goto unlock_and_exit;
}
@@ -271,14 +267,11 @@ acpi_ns_evaluate_by_handle (
* In both cases, the namespace is unlocked by the
* Acpi_ns* procedure
*/
-
- if (acpi_ns_get_type (obj_entry) == ACPI_TYPE_METHOD) {
+ if (acpi_ns_get_type (node) == ACPI_TYPE_METHOD) {
/*
* Case 1) We have an actual control method to execute
*/
-
- status = acpi_ns_execute_control_method (obj_entry,
- params,
+ status = acpi_ns_execute_control_method (node, params,
&local_return_object);
}
@@ -287,9 +280,7 @@ acpi_ns_evaluate_by_handle (
* Case 2) Object is NOT a method, just return its
* current value
*/
-
- status = acpi_ns_get_object_value (obj_entry,
- &local_return_object);
+ status = acpi_ns_get_object_value (node, &local_return_object);
}
@@ -297,7 +288,6 @@ acpi_ns_evaluate_by_handle (
* Check if there is a return value on the stack that must
* be dealt with
*/
-
if (status == AE_CTRL_RETURN_VALUE) {
/*
* If the Method returned a value and the caller
@@ -305,13 +295,11 @@ acpi_ns_evaluate_by_handle (
* the returned value to the object descriptor provided
* by the caller.
*/
-
if (return_object) {
/*
* Valid return object, copy the pointer to
* the returned object
*/
-
*return_object = local_return_object;
}
@@ -327,7 +315,6 @@ acpi_ns_evaluate_by_handle (
* Namespace was unlocked by the handling Acpi_ns* function,
* so we just return
*/
-
return (status);
@@ -338,14 +325,16 @@ unlock_and_exit:
}
-/****************************************************************************
+/*******************************************************************************
*
* FUNCTION: Acpi_ns_execute_control_method
*
- * PARAMETERS: Method_entry - The Nte of the object/method
+ * PARAMETERS: Method_node - The object/method
* **Params - List of parameters to pass to the method,
* terminated by NULL. Params itself may be
* NULL if no parameters are being passed.
+ * **Return_obj_desc - List of result objects to be returned
+ * from the method.
*
* RETURN: Status
*
@@ -353,36 +342,31 @@ unlock_and_exit:
*
* MUTEX: Assumes namespace is locked
*
- ****************************************************************************/
+ ******************************************************************************/
ACPI_STATUS
acpi_ns_execute_control_method (
- ACPI_NAMED_OBJECT *method_entry,
- ACPI_OBJECT_INTERNAL **params,
- ACPI_OBJECT_INTERNAL **return_obj_desc)
+ ACPI_NAMESPACE_NODE *method_node,
+ ACPI_OPERAND_OBJECT **params,
+ ACPI_OPERAND_OBJECT **return_obj_desc)
{
ACPI_STATUS status;
- ACPI_OBJECT_INTERNAL *obj_desc;
+ ACPI_OPERAND_OBJECT *obj_desc;
/* Verify that there is a method associated with this object */
- obj_desc = acpi_ns_get_attached_object ((ACPI_HANDLE) method_entry);
+ obj_desc = acpi_ns_get_attached_object ((ACPI_HANDLE) method_node);
if (!obj_desc) {
return (AE_ERROR);
}
- /*
- * Valid method, Set the current scope to that of the Method,
- * and execute it.
- */
-
/*
* Unlock the namespace before execution. This allows namespace access
* via the external Acpi* interfaces while a method is being executed.
* However, any namespace deletion must acquire both the namespace and
- * interpter locks to ensure that no thread is using the portion of the
+ * interpreter locks to ensure that no thread is using the portion of the
* namespace that is being deleted.
*/
@@ -391,17 +375,17 @@ acpi_ns_execute_control_method (
/*
* Excecute the method via the interpreter
*/
- status = acpi_aml_execute_method (method_entry, params, return_obj_desc);
+ status = acpi_aml_execute_method (method_node, params, return_obj_desc);
return (status);
}
-/****************************************************************************
+/*******************************************************************************
*
* FUNCTION: Acpi_ns_get_object_value
*
- * PARAMETERS: Object_entry - The Nte of the object
+ * PARAMETERS: Node - The object
*
* RETURN: Status
*
@@ -409,30 +393,29 @@ acpi_ns_execute_control_method (
*
* MUTEX: Assumes namespace is locked
*
- ****************************************************************************/
+ ******************************************************************************/
ACPI_STATUS
acpi_ns_get_object_value (
- ACPI_NAMED_OBJECT *object_entry,
- ACPI_OBJECT_INTERNAL **return_obj_desc)
+ ACPI_NAMESPACE_NODE *node,
+ ACPI_OPERAND_OBJECT **return_obj_desc)
{
ACPI_STATUS status = AE_OK;
- ACPI_OBJECT_INTERNAL *obj_desc;
- ACPI_OBJECT_INTERNAL *val_desc;
+ ACPI_OPERAND_OBJECT *obj_desc;
+ ACPI_OPERAND_OBJECT *val_desc;
/*
* We take the value from certain objects directly
*/
- if ((object_entry->type == ACPI_TYPE_PROCESSOR) ||
- (object_entry->type == ACPI_TYPE_POWER))
+ if ((node->type == ACPI_TYPE_PROCESSOR) ||
+ (node->type == ACPI_TYPE_POWER))
{
-
/*
* Create a Reference object to contain the object
*/
- obj_desc = acpi_cm_create_internal_object (object_entry->type);
+ obj_desc = acpi_cm_create_internal_object (node->type);
if (!obj_desc) {
status = AE_NO_MEMORY;
goto unlock_and_exit;
@@ -442,7 +425,7 @@ acpi_ns_get_object_value (
* Get the attached object
*/
- val_desc = acpi_ns_get_attached_object (object_entry);
+ val_desc = acpi_ns_get_attached_object (node);
if (!val_desc) {
status = AE_NULL_OBJECT;
goto unlock_and_exit;
@@ -452,10 +435,25 @@ acpi_ns_get_object_value (
* Just copy from the original to the return object
*/
- MEMCPY (&obj_desc->common.first_non_common_byte,
- &val_desc->common.first_non_common_byte,
- (sizeof(ACPI_OBJECT_COMMON) -
- sizeof(obj_desc->common.first_non_common_byte)));
+ switch (node->type)
+ {
+ case ACPI_TYPE_PROCESSOR:
+ obj_desc->processor.proc_id = val_desc->processor.proc_id;
+ obj_desc->processor.address = val_desc->processor.address;
+ obj_desc->processor.sys_handler = val_desc->processor.sys_handler;
+ obj_desc->processor.drv_handler = val_desc->processor.drv_handler;
+ obj_desc->processor.addr_handler = val_desc->processor.addr_handler;
+
+ break;
+
+ case ACPI_TYPE_POWER:
+ obj_desc->power_resource.system_level = val_desc->power_resource.system_level;
+ obj_desc->power_resource.resource_order = val_desc->power_resource.resource_order;
+ obj_desc->power_resource.sys_handler = val_desc->power_resource.sys_handler;
+ obj_desc->power_resource.drv_handler = val_desc->power_resource.drv_handler;
+
+ break;
+ }
}
@@ -475,15 +473,19 @@ acpi_ns_get_object_value (
/* Construct a descriptor pointing to the name */
obj_desc->reference.op_code = (u8) AML_NAME_OP;
- obj_desc->reference.object = (void *) object_entry;
+ obj_desc->reference.object = (void *) node;
/*
* Use Acpi_aml_resolve_to_value() to get the associated value.
* The call to Acpi_aml_resolve_to_value causes
* Obj_desc (allocated above) to always be deleted.
+ *
+ * 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
*/
- status = acpi_aml_resolve_to_value (&obj_desc);
+ status = acpi_aml_resolve_to_value (&obj_desc, NULL);
}
/*
@@ -491,7 +493,7 @@ acpi_ns_get_object_value (
* placed in Obj_desc.
*/
- if (status == AE_OK) {
+ if (ACPI_SUCCESS (status)) {
status = AE_CTRL_RETURN_VALUE;
*return_obj_desc = obj_desc;
diff --git a/drivers/acpi/namespace/nsload.c b/drivers/acpi/namespace/nsload.c
index 4b6b3f309..8faa8ea4f 100644
--- a/drivers/acpi/namespace/nsload.c
+++ b/drivers/acpi/namespace/nsload.c
@@ -1,7 +1,7 @@
-
/******************************************************************************
*
* Module Name: nsload - namespace loading/expanding/contracting procedures
+ * $Revision: 28 $
*
*****************************************************************************/
@@ -25,16 +25,16 @@
#include "acpi.h"
-#include "interp.h"
-#include "namesp.h"
+#include "acinterp.h"
+#include "acnamesp.h"
#include "amlcode.h"
-#include "parser.h"
-#include "dispatch.h"
-#include "debugger.h"
+#include "acparser.h"
+#include "acdispat.h"
+#include "acdebug.h"
#define _COMPONENT NAMESPACE
- MODULE_NAME ("nsload");
+ MODULE_NAME ("nsload")
/*******************************************************************************
@@ -42,7 +42,7 @@
* FUNCTION: Acpi_ns_parse_table
*
* PARAMETERS: Table_desc - An ACPI table descriptor for table to parse
- * Scope - Where to enter the table into the namespace
+ * Start_node - Where to enter the table into the namespace
*
* RETURN: Status
*
@@ -53,50 +53,85 @@
ACPI_STATUS
acpi_ns_parse_table (
ACPI_TABLE_DESC *table_desc,
- ACPI_NAME_TABLE *scope)
+ ACPI_NAMESPACE_NODE *start_node)
{
ACPI_STATUS status;
- /* Create the root object */
+ /*
+ * AML Parse, pass 1
+ *
+ * In this pass, we load most of the namespace. Control methods
+ * are not parsed until later. A parse tree is not created. Instead,
+ * each Parser Op subtree is deleted when it is finished. This saves
+ * a great deal of memory, and allows a small cache of parse objects
+ * to service the entire parse. The second pass of the parse then
+ * performs another complete parse of the AML..
+ */
+
+ /* Create and init a Root Node */
acpi_gbl_parsed_namespace_root = acpi_ps_alloc_op (AML_SCOPE_OP);
if (!acpi_gbl_parsed_namespace_root) {
return (AE_NO_MEMORY);
}
- /* Initialize the root object */
+ ((ACPI_PARSE2_OBJECT *) acpi_gbl_parsed_namespace_root)->name = ACPI_ROOT_NAME;
- ((ACPI_NAMED_OP *) acpi_gbl_parsed_namespace_root)->name = ACPI_ROOT_NAME;
/* Pass 1: Parse everything except control method bodies */
status = acpi_ps_parse_aml (acpi_gbl_parsed_namespace_root,
table_desc->aml_pointer,
- table_desc->aml_length, 0);
+ table_desc->aml_length,
+ ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE,
+ NULL, NULL, NULL,
+ acpi_ds_load1_begin_op,
+ acpi_ds_load1_end_op);
if (ACPI_FAILURE (status)) {
return (status);
}
-
-#ifndef PARSER_ONLY
- status = acpi_ps_walk_parsed_aml (acpi_ps_get_child (acpi_gbl_parsed_namespace_root),
- acpi_gbl_parsed_namespace_root, NULL,
- scope, NULL, NULL,
- table_desc->table_id,
- acpi_ds_load2_begin_op,
- acpi_ds_load2_end_op);
+ acpi_ps_delete_parse_tree (acpi_gbl_parsed_namespace_root);
/*
- * Now that the internal namespace has been constructed, we can delete the
- * parsed namespace, since it is no longer needed
+ * AML Parse, pass 2
+ *
+ * In this pass, we resolve forward references and other things
+ * that could not be completed during the first pass.
+ * Another complete parse of the AML is performed, but the
+ * overhead of this is compensated for by the fact that the
+ * parse objects are all cached.
*/
+ /* Create and init a Root Node */
+
+ acpi_gbl_parsed_namespace_root = acpi_ps_alloc_op (AML_SCOPE_OP);
+ if (!acpi_gbl_parsed_namespace_root) {
+ return (AE_NO_MEMORY);
+ }
+
+ ((ACPI_PARSE2_OBJECT *) acpi_gbl_parsed_namespace_root)->name = ACPI_ROOT_NAME;
+
+
+ /* Pass 2: Resolve forward references */
+
+ status = acpi_ps_parse_aml (acpi_gbl_parsed_namespace_root,
+ table_desc->aml_pointer,
+ table_desc->aml_length,
+ ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE,
+ NULL, NULL, NULL,
+ acpi_ds_load2_begin_op,
+ acpi_ds_load2_end_op);
+
+ if (ACPI_FAILURE (status)) {
+ return (status);
+ }
+
acpi_ps_delete_parse_tree (acpi_gbl_parsed_namespace_root);
acpi_gbl_parsed_namespace_root = NULL;
-#endif
return (status);
@@ -120,7 +155,7 @@ acpi_ns_parse_table (
ACPI_STATUS
acpi_ns_load_table (
ACPI_TABLE_DESC *table_desc,
- ACPI_NAMED_OBJECT *entry)
+ ACPI_NAMESPACE_NODE *node)
{
ACPI_STATUS status;
@@ -146,7 +181,7 @@ acpi_ns_load_table (
*/
acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE);
- status = acpi_ns_parse_table (table_desc, entry->child_table);
+ status = acpi_ns_parse_table (table_desc, node->child);
acpi_cm_release_mutex (ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE (status)) {
@@ -160,7 +195,7 @@ acpi_ns_load_table (
* parse trees.
*/
- status = acpi_ds_initialize_objects (table_desc, entry);
+ status = acpi_ds_initialize_objects (table_desc, node);
return (status);
}
@@ -222,7 +257,7 @@ acpi_ns_load_table_by_type (
/* Now load the single DSDT */
- status = acpi_ns_load_table (table_desc, acpi_gbl_root_object);
+ status = acpi_ns_load_table (table_desc, acpi_gbl_root_node);
if (ACPI_SUCCESS (status)) {
table_desc->loaded_into_namespace = TRUE;
}
@@ -247,7 +282,7 @@ acpi_ns_load_table_by_type (
if (!table_desc->loaded_into_namespace) {
status = acpi_ns_load_table (table_desc,
- acpi_gbl_root_object);
+ acpi_gbl_root_node);
if (ACPI_FAILURE (status)) {
break;
}
@@ -276,7 +311,7 @@ acpi_ns_load_table_by_type (
if (!table_desc->loaded_into_namespace) {
status = acpi_ns_load_table (table_desc,
- acpi_gbl_root_object);
+ acpi_gbl_root_node);
if (ACPI_FAILURE (status)) {
break;
}
@@ -306,52 +341,6 @@ unlock_and_exit:
/******************************************************************************
*
- * FUNCTION: Acpi_ns_free_table_entry
- *
- * PARAMETERS: Entry - The entry to be deleted
- *
- * RETURNS None
- *
- * DESCRIPTION: Free an entry in a namespace table. Delete any objects contained
- * in the entry, unlink the entry, then mark it unused.
- *
- ******************************************************************************/
-
-void
-acpi_ns_free_table_entry (
- ACPI_NAMED_OBJECT *entry)
-{
-
- if (!entry) {
- return;
- }
-
- /*
- * Need to delete
- * 1) The scope, if any
- * 2) An attached object, if any
- */
-
- if (entry->child_table) {
- acpi_cm_free (entry->child_table);
- entry->child_table = NULL;
- }
-
- if (entry->object) {
- acpi_ns_detach_object (entry->object);
- entry->object = NULL;
- }
-
- /* Mark the entry unallocated */
-
- entry->name = 0;
-
- return;
-}
-
-
-/******************************************************************************
- *
* FUNCTION: Acpi_ns_delete_subtree
*
* PARAMETERS: Start_handle - Handle in namespace where search begins
@@ -394,15 +383,6 @@ acpi_ns_delete_subtree (
child_handle,
&next_child_handle);
- /*
- * Regardless of the success or failure of the
- * previous operation, we are done with the previous
- * object (if there was one), and any children it
- * may have had. So we can now safely delete it (and
- * its scope, if any)
- */
-
- acpi_ns_free_table_entry (child_handle);
child_handle = next_child_handle;
@@ -432,6 +412,11 @@ acpi_ns_delete_subtree (
* the object's parent
*/
level--;
+
+ /* Delete all children now */
+
+ acpi_ns_delete_children (child_handle);
+
child_handle = parent_handle;
acpi_get_parent (parent_handle, &parent_handle);
}
@@ -439,7 +424,7 @@ acpi_ns_delete_subtree (
/* Now delete the starting object, and we are done */
- acpi_ns_free_table_entry ((ACPI_NAMED_OBJECT*) child_handle);
+ acpi_ns_delete_node (child_handle);
return (AE_OK);
@@ -469,7 +454,7 @@ acpi_ns_unload_namespace (
/* Parameter validation */
- if (!acpi_gbl_root_object->child_table) {
+ if (!acpi_gbl_root_node) {
return (AE_NO_NAMESPACE);
}
diff --git a/drivers/acpi/namespace/nsnames.c b/drivers/acpi/namespace/nsnames.c
index 1c4ab7c0b..3c18cf87f 100644
--- a/drivers/acpi/namespace/nsnames.c
+++ b/drivers/acpi/namespace/nsnames.c
@@ -1,9 +1,9 @@
-
-/******************************************************************************
+/*******************************************************************************
*
* Module Name: nsnames - Name manipulation and search
+ * $Revision: 48 $
*
- *****************************************************************************/
+ ******************************************************************************/
/*
* Copyright (C) 2000 R. Byron Moore
@@ -26,42 +26,40 @@
#include "acpi.h"
#include "amlcode.h"
-#include "interp.h"
-#include "namesp.h"
+#include "acinterp.h"
+#include "acnamesp.h"
#define _COMPONENT NAMESPACE
- MODULE_NAME ("nsnames");
+ MODULE_NAME ("nsnames")
-/****************************************************************************
+/*******************************************************************************
*
- * FUNCTION: Acpi_ns_name_of_scope
+ * FUNCTION: Acpi_ns_get_table_pathname
*
- * PARAMETERS: Scope - Scope whose name is needed
+ * PARAMETERS: Node - Scope whose name is needed
*
* RETURN: Pointer to storage containing the fully qualified name of
* the scope, in Label format (all segments strung together
* with no separators)
*
- * DESCRIPTION: Used via Acpi_ns_name_of_current_scope() and Acpi_ns_last_fQN()
- * for label generation in the interpreter, and for debug
- * printing in Acpi_ns_search_table().
+ * DESCRIPTION: Used for debug printing in Acpi_ns_search_table().
*
- ***************************************************************************/
+ ******************************************************************************/
-char *
-acpi_ns_name_of_scope (
- ACPI_NAME_TABLE *scope)
+NATIVE_CHAR *
+acpi_ns_get_table_pathname (
+ ACPI_NAMESPACE_NODE *node)
{
- char *name_buffer;
- ACPI_SIZE size;
+ NATIVE_CHAR *name_buffer;
+ u32 size;
ACPI_NAME name;
- ACPI_NAMED_OBJECT *entry_to_search;
- ACPI_NAMED_OBJECT *parent_entry;
+ ACPI_NAMESPACE_NODE *child_node;
+ ACPI_NAMESPACE_NODE *parent_node;
- if (!acpi_gbl_root_object->child_table || !scope) {
+ if (!acpi_gbl_root_node || !node) {
/*
* If the name space has not been initialized,
* this function should not have been called.
@@ -69,26 +67,26 @@ acpi_ns_name_of_scope (
return (NULL);
}
- entry_to_search = scope->entries;
+ child_node = node->child;
- /* Calculate required buffer size based on depth below root NT */
+ /* Calculate required buffer size based on depth below root */
size = 1;
- parent_entry = entry_to_search;
- while (parent_entry) {
- parent_entry = acpi_ns_get_parent_entry (parent_entry);
- if (parent_entry) {
+ parent_node = child_node;
+ while (parent_node) {
+ parent_node = acpi_ns_get_parent_object (parent_node);
+ if (parent_node) {
size += ACPI_NAME_SIZE;
}
}
- /* Allocate the buffer */
+ /* Allocate a buffer to be returned to caller */
name_buffer = acpi_cm_callocate (size + 1);
if (!name_buffer) {
- REPORT_ERROR ("Ns_name_of_scope: allocation failure");
+ REPORT_ERROR ("Ns_get_table_pathname: allocation failure");
return (NULL);
}
@@ -97,15 +95,15 @@ acpi_ns_name_of_scope (
name_buffer[size] = '\0';
while ((size > ACPI_NAME_SIZE) &&
- acpi_ns_get_parent_entry (entry_to_search))
+ acpi_ns_get_parent_object (child_node))
{
size -= ACPI_NAME_SIZE;
- name = acpi_ns_find_parent_name (entry_to_search);
+ name = acpi_ns_find_parent_name (child_node);
/* Put the name into the buffer */
MOVE_UNALIGNED32_TO_32 ((name_buffer + size), &name);
- entry_to_search = acpi_ns_get_parent_entry (entry_to_search);
+ child_node = acpi_ns_get_parent_object (child_node);
}
name_buffer[--size] = AML_ROOT_PREFIX;
@@ -115,69 +113,39 @@ acpi_ns_name_of_scope (
}
-/****************************************************************************
- *
- * FUNCTION: Acpi_ns_name_of_current_scope
- *
- * PARAMETERS: none
- *
- * RETURN: pointer to storage containing the name of the current scope
- *
- ***************************************************************************/
-
-char *
-acpi_ns_name_of_current_scope (
- ACPI_WALK_STATE *walk_state)
-{
- char *scope_name;
-
-
- if (walk_state && walk_state->scope_info) {
- scope_name =
- acpi_ns_name_of_scope (walk_state->scope_info->scope.name_table);
-
- return (scope_name);
- }
-
- REPORT_ERROR ("Current scope pointer is invalid");
-
- return (NULL);
-}
-
-
-/****************************************************************************
+/*******************************************************************************
*
* FUNCTION: Acpi_ns_handle_to_pathname
*
- * PARAMETERS: Target_handle - Handle of nte whose name is to be found
+ * 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
*
- * RETURN: Status, Buffer is filled with pathname if status == AE_OK
+ * 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,
- char *user_buffer)
+ NATIVE_CHAR *user_buffer)
{
ACPI_STATUS status = AE_OK;
- ACPI_NAMED_OBJECT *entry_to_search = NULL;
- ACPI_NAMED_OBJECT *temp = NULL;
- ACPI_SIZE path_length = 0;
- ACPI_SIZE size;
+ ACPI_NAMESPACE_NODE *node;
+ ACPI_NAMESPACE_NODE *next_node;
+ u32 path_length;
+ u32 size;
u32 user_buf_size;
ACPI_NAME name;
- u8 namespace_was_locked;
- if (!acpi_gbl_root_object->child_table || !target_handle) {
+ if (!acpi_gbl_root_node || !target_handle) {
/*
* If the name space has not been initialized,
* this function should not have been called.
@@ -186,13 +154,8 @@ acpi_ns_handle_to_pathname (
return (AE_NO_NAMESPACE);
}
- namespace_was_locked = acpi_gbl_acpi_mutex_info[ACPI_MTX_NAMESPACE].locked;
- if (!namespace_was_locked) {
- acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE);
- }
-
- entry_to_search = acpi_ns_convert_handle_to_entry (target_handle);
- if (!entry_to_search) {
+ node = acpi_ns_convert_handle_to_entry (target_handle);
+ if (!node) {
return (AE_BAD_PARAMETER);
}
@@ -200,9 +163,9 @@ acpi_ns_handle_to_pathname (
* Compute length of pathname as 5 * number of name segments.
* Go back up the parent tree to the root
*/
- for (size = 0, temp = entry_to_search;
- acpi_ns_get_parent_entry (temp);
- temp = acpi_ns_get_parent_entry (temp))
+ 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;
}
@@ -217,7 +180,7 @@ acpi_ns_handle_to_pathname (
if (path_length > user_buf_size) {
status = AE_BUFFER_OVERFLOW;
- goto unlock_and_exit;
+ goto exit;
}
/* Store null terminator */
@@ -228,19 +191,19 @@ acpi_ns_handle_to_pathname (
/* Put the original ACPI name at the end of the path */
MOVE_UNALIGNED32_TO_32 ((user_buffer + size),
- &entry_to_search->name);
+ &node->name);
user_buffer[--size] = PATH_SEPARATOR;
/* Build name backwards, putting "." between segments */
- while ((size > ACPI_NAME_SIZE) && entry_to_search) {
+ while ((size > ACPI_NAME_SIZE) && node) {
size -= ACPI_NAME_SIZE;
- name = acpi_ns_find_parent_name (entry_to_search);
+ name = acpi_ns_find_parent_name (node);
MOVE_UNALIGNED32_TO_32 ((user_buffer + size), &name);
user_buffer[--size] = PATH_SEPARATOR;
- entry_to_search = acpi_ns_get_parent_entry (entry_to_search);
+ node = acpi_ns_get_parent_object (node);
}
/*
@@ -250,254 +213,8 @@ acpi_ns_handle_to_pathname (
user_buffer[size] = '\\';
-
-unlock_and_exit:
-
- if (!namespace_was_locked) {
- acpi_cm_release_mutex (ACPI_MTX_NAMESPACE);
- }
-
+exit:
return (status);
}
-/****************************************************************************
- *
- * FUNCTION: Acpi_ns_pattern_match
- *
- * PARAMETERS: Obj_entry - A namespace entry
- * Search_for - Wildcard pattern string
- *
- * DESCRIPTION: Matches a namespace name against a wildcard pattern. Only
- * a very simple pattern - 4 chars, either a valid char or a "?"
- * to match any.
- *
- ***************************************************************************/
-
-u8
-acpi_ns_pattern_match (
- ACPI_NAMED_OBJECT *obj_entry,
- char *search_for)
-{
- s32 i;
-
-
- for (i = 0; i < ACPI_NAME_SIZE; i++) {
- if (search_for[i] != '?' &&
- search_for[i] != ((char *) &obj_entry->name)[i])
- {
- /* No match */
-
- return FALSE;
- }
- }
-
- /* name matches pattern */
-
- return TRUE;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION: Acpi_ns_name_compare
- *
- * PARAMETERS: Obj_handle - A namespace entry
- * Level - Current nesting level
- * Context - A FIND_CONTEXT structure
- *
- * DESCRIPTION: A User_function called by Acpi_ns_walk_namespace(). It performs
- * a pattern match for Acpi_ns_low_find_names(), and updates the list
- * and count as required.
- *
- ***************************************************************************/
-
-ACPI_STATUS
-acpi_ns_name_compare (
- ACPI_HANDLE obj_handle,
- u32 level,
- void *context,
- void **return_value)
-{
- FIND_CONTEXT *find = context;
-
-
- /* Match, yes or no? */
-
- if (acpi_ns_pattern_match ((ACPI_NAMED_OBJECT*) obj_handle,
- find->search_for))
- {
- /* Name matches pattern */
-
- if (find->list) {
- find->list[*(find->count)] = obj_handle;
- }
-
- ++*(find->count);
- }
-
- /* Don't terminate the walk */
- return AE_OK;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION: Acpi_ns_low_find_names
- *
- * PARAMETERS: *This_entry - Table to be searched
- * *Search_for - Pattern to be found.
- * 4 bytes, ? matches any character.
- * *Count - Output count of matches found.
- * Outermost caller should preset to 0
- * List[] - Output array of handles. If
- * null, only the count is obtained.
- * Max_depth - Maximum depth of search. Use
- * INT_MAX for an effectively
- * unlimited depth.
- *
- * DESCRIPTION: Low-level find name.
- * Traverse the name space finding names which match a search
- * pattern, and return an array of handles in List[].
- *
- ***************************************************************************/
-
-void
-acpi_ns_low_find_names (
- ACPI_NAMED_OBJECT *this_entry,
- char *search_for,
- s32 *count,
- ACPI_HANDLE list[],
- s32 max_depth)
-{
- FIND_CONTEXT find;
-
-
- if (0 == max_depth || !this_entry || !search_for || !count) {
- /*
- * Zero requested depth, nothing to search,
- * nothing to search for, or count pointer bad
- */
-
- return;
- }
-
- /* Init the context structure used by compare routine */
-
- find.list = list;
- find.count = count;
- find.search_for = search_for;
-
- /* Walk the namespace and find all matches */
-
- acpi_ns_walk_namespace (ACPI_TYPE_ANY, (ACPI_HANDLE) this_entry,
- max_depth, NS_WALK_NO_UNLOCK,
- acpi_ns_name_compare, &find, NULL);
-
- if (list) {
- /* null-terminate the output array */
-
- list[*count] = (ACPI_HANDLE) 0;
- }
-
- return;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION: Acpi_ns_find_names
-
- *
- * PARAMETERS: *Search_for - pattern to be found.
- * 4 bytes, ? matches any character.
- * If NULL, "????" will be used.
- * Start_handle - Root of subtree to be searched, or
- * NS_ALL to search the entire namespace
- * Max_depth - Maximum depth of search. Use INT_MAX
- * for an effectively unlimited depth.
- *
- * DESCRIPTION: Traverse the name space finding names which match a search
- * pattern, and return an array of handles. The end of the
- * array is marked by the value (ACPI_HANDLE)0. A return value
- * of (ACPI_HANDLE *)0 indicates that no matching names were
- * found or that space for the list could not be allocated.
- * if Start_handle is NS_ALL (null) search from the root,
- * else it is a handle whose children are to be searched.
- *
- ***************************************************************************/
-
-ACPI_HANDLE *
-acpi_ns_find_names (
- char *search_for,
- ACPI_HANDLE start_handle,
- s32 max_depth)
-{
- ACPI_HANDLE *list = NULL;
- s32 count;
-
-
- if (!acpi_gbl_root_object->child_table) {
- /*
- * If the name space has not been initialized,
- * there surely are no matching names.
- */
- return (NULL);
- }
-
- if (NS_ALL == start_handle) {
- /* base is root */
-
- start_handle = acpi_gbl_root_object;
- }
-
- else if (((ACPI_NAMED_OBJECT *) start_handle)->child_table) {
- /* base has children to search */
-
- start_handle =
- ((ACPI_NAMED_OBJECT *) start_handle)->child_table->entries;
- }
-
- else {
- /*
- * If base is not the root and has no children,
- * there is nothing to search.
- */
- return (NULL);
- }
-
- if (!search_for) {
- /* Search name not specified */
-
- search_for = "????";
- }
-
-
- /* Pass 1. Get required buffer size, don't try to build list */
-
- count = 0;
- acpi_ns_low_find_names (start_handle, search_for, &count,
- NULL, max_depth);
-
- if (0 == count) {
- return (NULL);
- }
-
- /* Allow for trailing null */
- count++;
-
- list = acpi_cm_callocate (count * sizeof(ACPI_HANDLE));
- if (!list) {
- REPORT_ERROR ("Ns_find_names: allocation failure");
- return (NULL);
- }
-
- /* Pass 2. Fill buffer */
-
- count = 0;
- acpi_ns_low_find_names (start_handle, search_for, &count, list, max_depth);
-
- return (list);
-}
-
-
diff --git a/drivers/acpi/namespace/nsobject.c b/drivers/acpi/namespace/nsobject.c
index 56e497bb0..df4c28239 100644
--- a/drivers/acpi/namespace/nsobject.c
+++ b/drivers/acpi/namespace/nsobject.c
@@ -1,10 +1,10 @@
-
-/******************************************************************************
+/*******************************************************************************
*
* Module Name: nsobject - Utilities for objects attached to namespace
- * table entries
+ * table entries
+ * $Revision: 44 $
*
- *****************************************************************************/
+ ******************************************************************************/
/*
* Copyright (C) 2000 R. Byron Moore
@@ -27,20 +27,20 @@
#include "acpi.h"
#include "amlcode.h"
-#include "namesp.h"
-#include "interp.h"
-#include "tables.h"
+#include "acnamesp.h"
+#include "acinterp.h"
+#include "actables.h"
#define _COMPONENT NAMESPACE
- MODULE_NAME ("nsobject");
+ MODULE_NAME ("nsobject")
-/****************************************************************************
+/*******************************************************************************
*
* FUNCTION: Acpi_ns_attach_object
*
- * PARAMETERS: Handle - Handle of nte
+ * PARAMETERS: Node - Parent Node
* Object - Object to be attached
* Type - Type of object, or ACPI_TYPE_ANY if not
* known
@@ -51,17 +51,16 @@
*
* MUTEX: Assumes namespace is locked
*
- ***************************************************************************/
+ ******************************************************************************/
ACPI_STATUS
acpi_ns_attach_object (
- ACPI_HANDLE handle,
- ACPI_HANDLE object,
+ ACPI_NAMESPACE_NODE *node,
+ ACPI_OPERAND_OBJECT *object,
OBJECT_TYPE_INTERNAL type)
{
- ACPI_NAMED_OBJECT *this_entry = (ACPI_NAMED_OBJECT*) handle;
- ACPI_OBJECT_INTERNAL *obj_desc;
- ACPI_OBJECT_INTERNAL *previous_obj_desc;
+ ACPI_OPERAND_OBJECT *obj_desc;
+ ACPI_OPERAND_OBJECT *previous_obj_desc;
OBJECT_TYPE_INTERNAL obj_type = ACPI_TYPE_ANY;
u8 flags;
u16 opcode;
@@ -71,17 +70,17 @@ acpi_ns_attach_object (
* Parameter validation
*/
- if (!acpi_gbl_root_object->child_table) {
+ if (!acpi_gbl_root_node) {
/* Name space not initialized */
REPORT_ERROR ("Ns_attach_object: Name space not initialized");
return (AE_NO_NAMESPACE);
}
- if (!handle) {
+ if (!node) {
/* Invalid handle */
- REPORT_ERROR ("Ns_attach_object: Null name handle");
+ REPORT_ERROR ("Ns_attach_object: Null Named_obj handle");
return (AE_BAD_PARAMETER);
}
@@ -93,7 +92,7 @@ acpi_ns_attach_object (
return (AE_BAD_PARAMETER);
}
- if (!VALID_DESCRIPTOR_TYPE (handle, ACPI_DESC_TYPE_NAMED)) {
+ if (!VALID_DESCRIPTOR_TYPE (node, ACPI_DESC_TYPE_NAMED)) {
/* Not a name handle */
REPORT_ERROR ("Ns_attach_object: Invalid handle");
@@ -102,15 +101,15 @@ acpi_ns_attach_object (
/* Check if this object is already attached */
- if (this_entry->object == object) {
+ if (node->object == object) {
return (AE_OK);
}
- /* Get the current flags field of the NTE */
+ /* Get the current flags field of the Node */
- flags = this_entry->flags;
- flags &= ~NTE_AML_ATTACHMENT;
+ flags = node->flags;
+ flags &= ~ANOBJ_AML_ATTACHMENT;
/* If null object, we will just install it */
@@ -121,27 +120,27 @@ acpi_ns_attach_object (
}
/*
- * If the object is an NTE with an attached object,
+ * If the object is an Node with an attached object,
* we will use that (attached) object
*/
else if (VALID_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_NAMED) &&
- ((ACPI_NAMED_OBJECT*) object)->object)
+ ((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_NAMED_OBJECT*) object)->object;
- obj_type = ((ACPI_NAMED_OBJECT*) object)->type;
+ obj_desc = ((ACPI_NAMESPACE_NODE *) object)->object;
+ obj_type = ((ACPI_NAMESPACE_NODE *) object)->type;
/*
* Copy appropriate flags
*/
- if (((ACPI_NAMED_OBJECT*) object)->flags & NTE_AML_ATTACHMENT) {
- flags |= NTE_AML_ATTACHMENT;
+ if (((ACPI_NAMESPACE_NODE *) object)->flags & ANOBJ_AML_ATTACHMENT) {
+ flags |= ANOBJ_AML_ATTACHMENT;
}
}
@@ -152,7 +151,7 @@ acpi_ns_attach_object (
*/
else {
- obj_desc = (ACPI_OBJECT_INTERNAL *) object;
+ obj_desc = (ACPI_OPERAND_OBJECT *) object;
/* If a valid type (non-ANY) was given, just use it */
@@ -173,10 +172,10 @@ acpi_ns_attach_object (
else if (acpi_tb_system_table_pointer (object)) {
/*
* Object points into the AML stream.
- * Set a flag bit in the NTE to indicate this
+ * Set a flag bit in the Node to indicate this
*/
- flags |= NTE_AML_ATTACHMENT;
+ flags |= ANOBJ_AML_ATTACHMENT;
/*
* The next byte (perhaps the next two bytes)
@@ -263,13 +262,13 @@ acpi_ns_attach_object (
/* Save the existing object (if any) for deletion later */
- previous_obj_desc = this_entry->object;
+ previous_obj_desc = node->object;
/* Install the object and set the type, flags */
- this_entry->object = obj_desc;
- this_entry->type = (u8) obj_type;
- this_entry->flags = flags;
+ node->object = obj_desc;
+ node->type = (u8) obj_type;
+ node->flags |= flags;
/*
@@ -277,86 +276,12 @@ acpi_ns_attach_object (
*/
if (previous_obj_desc) {
- /* One for the attach to the NTE */
- acpi_cm_remove_reference (previous_obj_desc);
- /* Now delete */
- acpi_cm_remove_reference (previous_obj_desc);
- }
-
- return (AE_OK);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION: Acpi_ns_attach_method
- *
- * PARAMETERS: Handle - Handle of nte to be set
- * Offset - Value to be set
- * Length - Length associated with value
- *
- * DESCRIPTION: Record the given offset and p-code length of the method
- * whose handle is passed
- *
- * MUTEX: Assumes namespace is locked
- *
- ***************************************************************************/
-
-ACPI_STATUS
-acpi_ns_attach_method (
- ACPI_HANDLE handle,
- u8 *pcode_addr,
- u32 pcode_length)
-{
- ACPI_OBJECT_INTERNAL *obj_desc;
- ACPI_OBJECT_INTERNAL *previous_obj_desc;
- ACPI_NAMED_OBJECT *this_entry = (ACPI_NAMED_OBJECT*) handle;
-
-
- /* Parameter validation */
-
- if (!acpi_gbl_root_object->child_table) {
- /* Name space uninitialized */
-
- REPORT_ERROR ("Ns_attach_method: name space uninitialized");
- return (AE_NO_NAMESPACE);
- }
-
- if (!handle) {
- /* Null name handle */
-
- REPORT_ERROR ("Ns_attach_method: null name handle");
- return (AE_BAD_PARAMETER);
- }
-
-
- /* Allocate a method descriptor */
-
- obj_desc = acpi_cm_create_internal_object (ACPI_TYPE_METHOD);
- if (!obj_desc) {
- /* Method allocation failure */
-
- REPORT_ERROR ("Ns_attach_method: allocation failure");
- return (AE_NO_MEMORY);
- }
-
- /* Init the method info */
+ /* One for the attach to the Node */
- obj_desc->method.pcode = pcode_addr;
- obj_desc->method.pcode_length = pcode_length;
-
- /* Update reference count and install */
-
- acpi_cm_add_reference (obj_desc);
-
- previous_obj_desc = this_entry->object;
- this_entry->object = obj_desc;
+ acpi_cm_remove_reference (previous_obj_desc);
+ /* Now delete */
- /*
- * Delete an existing object. Don't try to re-use in case it is shared
- */
- if (previous_obj_desc) {
acpi_cm_remove_reference (previous_obj_desc);
}
@@ -364,11 +289,11 @@ acpi_ns_attach_method (
}
-/****************************************************************************
+/*******************************************************************************
*
* FUNCTION: Acpi_ns_detach_object
*
- * PARAMETERS: Object - An object whose Value will be deleted
+ * PARAMETERS: Node - An object whose Value will be deleted
*
* RETURN: None.
*
@@ -376,24 +301,23 @@ acpi_ns_attach_method (
* Value is an allocated object, it is freed. Otherwise, the
* field is simply cleared.
*
- ***************************************************************************/
+ ******************************************************************************/
void
acpi_ns_detach_object (
- ACPI_HANDLE object)
+ ACPI_NAMESPACE_NODE *node)
{
- ACPI_NAMED_OBJECT *entry = object;
- ACPI_OBJECT_INTERNAL *obj_desc;
+ ACPI_OPERAND_OBJECT *obj_desc;
- obj_desc = entry->object;
+ obj_desc = node->object;
if (!obj_desc) {
return;
}
/* Clear the entry in all cases */
- entry->object = NULL;
+ node->object = NULL;
/* Found a valid value */
@@ -412,16 +336,16 @@ acpi_ns_detach_object (
}
-/****************************************************************************
+/*******************************************************************************
*
* FUNCTION: Acpi_ns_get_attached_object
*
- * PARAMETERS: Handle - Handle of nte to be examined
+ * PARAMETERS: Handle - Parent Node to be examined
*
- * RETURN: Current value of the object field from nte whose handle is
- * passed
+ * RETURN: Current value of the object field from the Node whose
+ * handle is passed
*
- ***************************************************************************/
+ ******************************************************************************/
void *
acpi_ns_get_attached_object (
@@ -435,122 +359,7 @@ acpi_ns_get_attached_object (
return (NULL);
}
- return (((ACPI_NAMED_OBJECT*) handle)->object);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION: Acpi_ns_compare_object
- *
- * PARAMETERS: Obj_handle - A namespace entry
- * Level - Current nesting level
- * Obj_desc - The value to be compared
- *
- * DESCRIPTION: A User_function called by Acpi_ns_walk_namespace(). It performs
- * a comparison for Acpi_ns_find_attached_object(). The comparison is against
- * the value in the value field of the Obj_handle (an NTE).
- * If a match is found, the handle is returned, which aborts
- * Acpi_ns_walk_namespace.
- *
- ***************************************************************************/
-
-ACPI_STATUS
-acpi_ns_compare_object (
- ACPI_HANDLE obj_handle,
- u32 level,
- void *obj_desc,
- void **return_value)
-{
-
- if (((ACPI_NAMED_OBJECT*) obj_handle)->object == obj_desc) {
- if (return_value) {
- *return_value = obj_handle;
- }
-
- /* Stop the walk */
- return AE_CTRL_TERMINATE;
- }
-
- /* Not found, continue the walk */
- return AE_OK;
-}
-
-
-/****************************************************************************
- *
- * FUNCTION: Acpi_ns_find_attached_object
- *
- * PARAMETERS: *Obj_desc - Value to be found in ptr_val field.
- * Start_handle - Root of subtree to be searched, or
- * NS_ALL to search the entire namespace
- * Max_depth - Maximum depth of search. Use INT_MAX
- * for an effectively unlimited depth.
- *
- * DESCRIPTION: Traverse the name space until finding a name whose Value field
- * matches the Obj_desc parameter, and return a handle to that
- * name, or (ACPI_HANDLE)0 if none exists.
- * if Start_handle is NS_ALL (null) search from the root,
- * else it is a handle whose children are to be searched.
- *
- ***************************************************************************/
-
-ACPI_HANDLE
-acpi_ns_find_attached_object (
- ACPI_OBJECT_INTERNAL *obj_desc,
- ACPI_HANDLE start_handle,
- s32 max_depth)
-{
- ACPI_HANDLE ret_object;
- ACPI_STATUS status;
-
-
- /* Parameter validation */
-
- if (!obj_desc) {
- return (NULL);
- }
-
- if (0 == max_depth) {
- return (NULL);
- }
-
- if (!acpi_gbl_root_object->child_table) {
- /*
- * If the name space has not been initialized,
- * there surely are no matching values.
- */
- return (NULL);
- }
-
- if (NS_ALL == start_handle) {
- start_handle = acpi_gbl_root_object;
- }
-
- else {
- /*
- * If base is not the root and has no children,
- * there is nothing to search.
- */
- return (NULL);
- }
-
-
- /*
- * Walk namespace until a match is found.
- * Either the matching object is returned, or NULL in case
- * of no match.
- */
- status = acpi_ns_walk_namespace (ACPI_TYPE_ANY, start_handle,
- max_depth, NS_WALK_NO_UNLOCK,
- acpi_ns_compare_object,
- obj_desc, &ret_object);
-
- if (ACPI_FAILURE (status)) {
- ret_object = NULL;
- }
-
- return (ret_object);
+ return (((ACPI_NAMESPACE_NODE *) handle)->object);
}
diff --git a/drivers/acpi/namespace/nssearch.c b/drivers/acpi/namespace/nssearch.c
index 19fad8ad6..b6abbd782 100644
--- a/drivers/acpi/namespace/nssearch.c
+++ b/drivers/acpi/namespace/nssearch.c
@@ -1,9 +1,9 @@
-
-/******************************************************************************
+/*******************************************************************************
*
* Module Name: nssearch - Namespace search
+ * $Revision: 57 $
*
- *****************************************************************************/
+ ******************************************************************************/
/*
* Copyright (C) 2000 R. Byron Moore
@@ -26,192 +26,132 @@
#include "acpi.h"
#include "amlcode.h"
-#include "interp.h"
-#include "namesp.h"
+#include "acinterp.h"
+#include "acnamesp.h"
#define _COMPONENT NAMESPACE
- MODULE_NAME ("nssearch");
+ MODULE_NAME ("nssearch")
-/****************************************************************************
+/*******************************************************************************
*
- * FUNCTION: Acpi_ns_search_one_scope
+ * FUNCTION: Acpi_ns_search_node
*
- * PARAMETERS: *Entry_name - Ascii ACPI name to search for
- * *Name_table - Starting table where search will begin
+ * PARAMETERS: *Target_name - Ascii ACPI name to search for
+ * *Node - Starting table where search will begin
* Type - Object type to match
- * **Ret_entry - Where the matched NTE is returned
- * *Ret_info - Where info about the search is returned
+ * **Return_node - Where the matched Named obj is returned
*
- * RETURN: Status and return information via NS_SEARCH_DATA
+ * RETURN: Status
*
* DESCRIPTION: Search a single namespace table. Performs a simple search,
* does not add entries or search parents.
*
- ***************************************************************************/
+ *
+ * Named object lists are built (and subsequently dumped) in the
+ * order in which the names are encountered during the namespace load;
+ *
+ * All namespace searching is linear in this implementation, but
+ * could be easily modified to support any improved search
+ * algorithm. However, the linear search was chosen for simplicity
+ * and because the trees are small and the other interpreter
+ * execution overhead is relatively high.
+ *
+ ******************************************************************************/
ACPI_STATUS
-acpi_ns_search_one_scope (
- u32 entry_name,
- ACPI_NAME_TABLE *name_table,
+acpi_ns_search_node (
+ u32 target_name,
+ ACPI_NAMESPACE_NODE *node,
OBJECT_TYPE_INTERNAL type,
- ACPI_NAMED_OBJECT **ret_entry,
- NS_SEARCH_DATA *ret_info)
+ ACPI_NAMESPACE_NODE **return_node)
{
- u32 position;
- ACPI_NAME_TABLE *this_table;
- ACPI_NAME_TABLE *previous_table = name_table;
- ACPI_NAMED_OBJECT *entries;
- u8 table_full = TRUE;
- ACPI_NAME_TABLE *table_with_empty_slots = NULL;
- u32 empty_slot_position = 0;
+ ACPI_NAMESPACE_NODE *next_node;
- /*
- * Name tables are built (and subsequently dumped) in the
- * order in which the names are encountered during the namespace load;
- *
- * All namespace searching will be linear; If a table overflows an
- * additional segment will be allocated and added (chained).
- *
- * Start linear search at top of table
- */
- position = 0;
- this_table = name_table;
- entries = this_table->entries;
-
-
- /* Init return data */
-
- if (ret_info) {
- ret_info->name_table = this_table;
- }
-
/*
- * Search entire name table, including all linked appendages
+ * Search for name in this table, which is to say that we must search
+ * for the name among the children of this object
*/
- while (this_table) {
- /*
- * Search for name in table, starting at Position. Stop
- * searching upon examining all entries in the table.
- *
- */
+ next_node = node->child;
+ while (next_node) {
+ /* Check for match against the name */
- entries = this_table->entries;
- while (position < NS_TABLE_SIZE) {
- /* Check for a valid entry */
-
- if (!entries[position].name) {
- if (table_full) {
- /*
- * There is room in the table for more
- * entries, if necessary
- */
-
- table_full = FALSE;
- table_with_empty_slots = this_table;
- empty_slot_position = position;
- }
- }
+ if (next_node->name == target_name) {
+ /*
+ * Found matching entry. Capture type if
+ * appropriate before returning the entry.
+ */
+
+ /*
+ * The Def_field_defn and Bank_field_defn cases
+ * are actually looking up the Region in which
+ * the field will be defined
+ */
- /* Search for name in table */
-
- else if (entries[position].name == entry_name) {
- /*
- * Found matching entry. Capture type if
- * appropriate before returning the entry.
- */
-
- /*
- * The Def_field_defn and Bank_field_defn cases
- * are actually looking up the Region in which
- * the field will be defined
- */
-
- if ((INTERNAL_TYPE_DEF_FIELD_DEFN == type) ||
- (INTERNAL_TYPE_BANK_FIELD_DEFN == type))
- {
- type = ACPI_TYPE_REGION;
- }
-
- /*
- * Scope, Def_any, and Index_field_defn are bogus
- * "types" which do not actually have anything
- * to do with the type of the name being looked
- * up. For any other value of Type, if the type
- * stored in the entry is Any (i.e. unknown),
- * save the actual type.
- */
-
- if (type != INTERNAL_TYPE_SCOPE &&
- type != INTERNAL_TYPE_DEF_ANY &&
- type != INTERNAL_TYPE_INDEX_FIELD_DEFN &&
- entries[position].type == ACPI_TYPE_ANY)
- {
- entries[position].type = (u8) type;
- }
-
- *ret_entry = &entries[position];
- return (AE_OK);
+ if ((INTERNAL_TYPE_DEF_FIELD_DEFN == type) ||
+ (INTERNAL_TYPE_BANK_FIELD_DEFN == type))
+ {
+ type = ACPI_TYPE_REGION;
}
+ /*
+ * Scope, Def_any, and Index_field_defn are bogus
+ * "types" which do not actually have anything
+ * to do with the type of the name being looked
+ * up. For any other value of Type, if the type
+ * stored in the entry is Any (i.e. unknown),
+ * save the actual type.
+ */
- /* Didn't match name, move on to the next entry */
+ if (type != INTERNAL_TYPE_SCOPE &&
+ type != INTERNAL_TYPE_DEF_ANY &&
+ type != INTERNAL_TYPE_INDEX_FIELD_DEFN &&
+ next_node->type == ACPI_TYPE_ANY)
+ {
+ next_node->type = (u8) type;
+ }
- position++;
+ *return_node = next_node;
+ return (AE_OK);
}
/*
- * Just examined last slot in this table, move on
- * to next appendate.
- * All appendages, even to the root NT, contain
- * NS_TABLE_SIZE entries.
+ * The last entry in the list points back to the parent,
+ * so a flag is used to indicate the end-of-list
*/
+ if (next_node->flags & ANOBJ_END_OF_PEER_LIST) {
+ /* Searched entire list, we are done */
+
+ break;
+ }
- previous_table = this_table;
- this_table = this_table->next_table;
+ /* Didn't match name, move on to the next peer object */
- position = 0;
+ next_node = next_node->peer;
}
/* Searched entire table, not found */
- if (ret_info) {
- /*
- * Save info on if/where a slot is available
- * (name was not found)
- */
-
- ret_info->table_full = table_full;
- if (table_full) {
- ret_info->name_table = previous_table;
- }
-
- else {
- ret_info->position = empty_slot_position;
- ret_info->name_table = table_with_empty_slots;
- }
- }
-
return (AE_NOT_FOUND);
}
-/****************************************************************************
+/*******************************************************************************
*
* FUNCTION: Acpi_ns_search_parent_tree
*
- * PARAMETERS: *Entry_name - Ascii ACPI name to search for
- * *Name_table - Starting table where search will begin
+ * PARAMETERS: *Target_name - Ascii ACPI name to search for
+ * *Node - Starting table where search will begin
* Type - Object type to match
- * **Ret_entry - Where the matched NTE is returned
+ * **Return_node - Where the matched Named Obj is returned
*
* RETURN: Status
*
@@ -227,274 +167,79 @@ acpi_ns_search_one_scope (
* indicates that the name is not found" (From ACPI Specification,
* section 5.3)
*
- ***************************************************************************/
-
+ ******************************************************************************/
ACPI_STATUS
acpi_ns_search_parent_tree (
- u32 entry_name,
- ACPI_NAME_TABLE *name_table,
+ u32 target_name,
+ ACPI_NAMESPACE_NODE *node,
OBJECT_TYPE_INTERNAL type,
- ACPI_NAMED_OBJECT **ret_entry)
+ ACPI_NAMESPACE_NODE **return_node)
{
ACPI_STATUS status;
- ACPI_NAMED_OBJECT *parent_entry;
- ACPI_NAMED_OBJECT *entries;
+ ACPI_NAMESPACE_NODE *parent_node;
- entries = name_table->entries;
+ parent_node = acpi_ns_get_parent_object (node);
/*
- * If no parent or type is "local", we won't be searching the
- * parent tree.
+ * If there is no parent (at the root) or type is "local", we won't be
+ * searching the parent tree.
*/
-
- if (!acpi_ns_local (type) &&
- name_table->parent_entry)
+ if ((acpi_ns_local (type)) ||
+ (!parent_node))
{
- parent_entry = name_table->parent_entry;
- /*
- * Search parents until found or we have backed up to
- * the root
- */
-
- while (parent_entry) {
- /* Search parent scope */
- /* TBD: [Investigate] Why ACPI_TYPE_ANY? */
-
- status = acpi_ns_search_one_scope (entry_name,
- parent_entry->child_table,
- ACPI_TYPE_ANY,
- ret_entry, NULL);
-
- if (status == AE_OK) {
- return (status);
- }
-
- /*
- * Not found here, go up another level
- * (until we reach the root)
- */
-
- parent_entry = acpi_ns_get_parent_entry (parent_entry);
- }
-
- /* Not found in parent tree */
- }
-
-
- return (AE_NOT_FOUND);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION: Acpi_ns_create_and_link_new_table
- *
- * PARAMETERS: *Name_table - The table that is to be "extended" by
- * the creation of an appendage table.
- *
- * RETURN: Status
- *
- * DESCRIPTION: Allocate a new namespace table, initialize it, and link it
- * into the parent table.
- *
- * NOTE: We are in the first or second pass load mode, want to
- * add a new table entry, and the current table is full.
- *
- ***************************************************************************/
-
-ACPI_STATUS
-acpi_ns_create_and_link_new_table (
- ACPI_NAME_TABLE *name_table)
-{
- ACPI_NAME_TABLE *new_table;
- ACPI_NAMED_OBJECT *parent_entry;
- ACPI_STATUS status = AE_OK;
-
-
- /* Sanity check on the data structure */
-
- if (name_table->next_table) {
- /* We should never get here (an appendage already allocated) */
-
- return (AE_AML_INTERNAL);
- }
-
-
- /*
- * We can use the parent entries from the current table
- * Since the parent information remains the same.
- */
- parent_entry = name_table->parent_entry;
-
-
- /* Allocate and chain an appendage to the filled table */
-
- new_table = acpi_ns_allocate_name_table (NS_TABLE_SIZE);
- if (!new_table) {
- REPORT_ERROR ("Name Table appendage allocation failure");
- return (AE_NO_MEMORY);
- }
-
- /*
- * Allocation successful. Init the new table.
- */
- name_table->next_table = new_table;
- acpi_ns_initialize_table (new_table, parent_entry->child_table,
- parent_entry);
-
- return (status);
-}
-
-
-/****************************************************************************
- *
- * FUNCTION: Acpi_ns_initialize_table
- *
- * PARAMETERS: New_table - The new table to be initialized
- * Parent_table - The parent (owner) scope
- * Parent_entry - The NTE for the parent
- *
- * RETURN: None
- *
- * DESCRIPTION: Initialize a new namespace table. Simple, but called
- * from several places -- code should be kept in one place.
- *
- ***************************************************************************/
-
-void
-acpi_ns_initialize_table (
- ACPI_NAME_TABLE *new_table,
- ACPI_NAME_TABLE *parent_table,
- ACPI_NAMED_OBJECT *parent_entry)
-{
- u8 i;
-
-
- new_table->parent_entry = parent_entry;
- new_table->parent_table = parent_table;
-
- /* Init each named object entry in the table */
- for (i = 0; i < NS_TABLE_SIZE; i++) {
- new_table->entries[i].this_index = i;
- new_table->entries[i].data_type = ACPI_DESC_TYPE_NAMED;
+ return (AE_NOT_FOUND);
}
-}
-
-
-/****************************************************************************
- *
- * FUNCTION: Acpi_ns_initialize_entry
- *
- * PARAMETERS: Name_table - The containing table for the new NTE
- * Position - Position (index) of the new NTE in the table
- * Entry_name - ACPI name of the new entry
- * Type - ACPI object type of the new entry
- * Previous_entry - Link back to the previous entry (can span
- * multiple tables)
- *
- * RETURN: None
- *
- * DESCRIPTION: Initialize a new entry within a namespace table.
- *
- ***************************************************************************/
-
-void
-acpi_ns_initialize_entry (
- ACPI_WALK_STATE *walk_state,
- ACPI_NAME_TABLE *name_table,
- u32 position,
- u32 entry_name,
- OBJECT_TYPE_INTERNAL type)
-{
- ACPI_NAMED_OBJECT *new_entry;
- u16 owner_id = TABLE_ID_DSDT;
- ACPI_NAMED_OBJECT *entries;
+ /* Search the parent tree */
/*
- * Get the owner ID from the Walk state
- * The owner ID is used to track table deletion and
- * deletion of objects created by methods
+ * Search parents until found the target or we have backed up to
+ * the root
*/
- if (walk_state) {
- owner_id = walk_state->owner_id;
- }
-
- /* The new entry is given by two parameters */
-
- entries = name_table->entries;
- new_entry = &entries[position];
- /* Init the new entry */
+ while (parent_node) {
+ /* Search parent scope */
+ /* TBD: [Investigate] Why ACPI_TYPE_ANY? */
- new_entry->data_type = ACPI_DESC_TYPE_NAMED;
- new_entry->name = entry_name;
- new_entry->owner_id = owner_id;
- new_entry->reference_count = 1;
+ status = acpi_ns_search_node (target_name, parent_node,
+ ACPI_TYPE_ANY, return_node);
+ if (ACPI_SUCCESS (status)) {
+ return (status);
+ }
- /*
- * If adding a name with unknown type, or having to
- * add the region in order to define fields in it, we
- * have a forward reference.
- */
-
- if ((ACPI_TYPE_ANY == type) ||
- (INTERNAL_TYPE_DEF_FIELD_DEFN == type) ||
- (INTERNAL_TYPE_BANK_FIELD_DEFN == type))
- {
/*
- * We don't want to abort here, however!
- * We will fill in the actual type when the
- * real definition is found later.
+ * Not found here, go up another level
+ * (until we reach the root)
*/
+ parent_node = acpi_ns_get_parent_object (parent_node);
}
- /*
- * The Def_field_defn and Bank_field_defn cases are actually
- * looking up the Region in which the field will be defined
- */
-
- if ((INTERNAL_TYPE_DEF_FIELD_DEFN == type) ||
- (INTERNAL_TYPE_BANK_FIELD_DEFN == type))
- {
- type = ACPI_TYPE_REGION;
- }
- /*
- * Scope, Def_any, and Index_field_defn are bogus "types" which do
- * not actually have anything to do with the type of the name
- * being looked up. Save any other value of Type as the type of
- * the entry.
- */
+ /* Not found in parent tree */
- if ((type != INTERNAL_TYPE_SCOPE) &&
- (type != INTERNAL_TYPE_DEF_ANY) &&
- (type != INTERNAL_TYPE_INDEX_FIELD_DEFN))
- {
- new_entry->type = (u8) type;
- }
-
- return;
+ return (AE_NOT_FOUND);
}
-/****************************************************************************
+/*******************************************************************************
*
* FUNCTION: Acpi_ns_search_and_enter
*
- * PARAMETERS: Entry_name - Ascii ACPI name to search for (4 chars)
- * *Name_table - Starting table where search will begin
- * Interpreter_mode - Add names only in MODE_Load_pass_x. Otherwise,
- * search only.
+ * PARAMETERS: Target_name - Ascii ACPI name to search for (4 chars)
+ * Walk_state - Current state of the walk
+ * *Node - Starting table where search will begin
+ * Interpreter_mode - Add names only in MODE_Load_pass_x.
+ * Otherwise,search only.
* Type - Object type to match
- * **Ret_entry - Where the matched NTE is returned
+ * Flags - Flags describing the search restrictions
+ * **Return_node - Where the Node is returned
*
* RETURN: Status
*
@@ -506,51 +251,48 @@ acpi_ns_initialize_entry (
* In IMODE_EXECUTE, search only.
* In other modes, search and add if not found.
*
- ***************************************************************************/
+ ******************************************************************************/
ACPI_STATUS
acpi_ns_search_and_enter (
- u32 entry_name,
+ u32 target_name,
ACPI_WALK_STATE *walk_state,
- ACPI_NAME_TABLE *name_table,
+ ACPI_NAMESPACE_NODE *node,
OPERATING_MODE interpreter_mode,
OBJECT_TYPE_INTERNAL type,
u32 flags,
- ACPI_NAMED_OBJECT **ret_entry)
+ ACPI_NAMESPACE_NODE **return_node)
{
- u32 position; /* position in table */
ACPI_STATUS status;
- NS_SEARCH_DATA search_info;
- ACPI_NAMED_OBJECT *entry;
- ACPI_NAMED_OBJECT *entries;
+ ACPI_NAMESPACE_NODE *new_node;
/* Parameter validation */
- if (!name_table || !entry_name || !ret_entry) {
- REPORT_ERROR ("Ns_search_and_enter: bad parameter");
+ if (!node || !target_name || !return_node) {
+ REPORT_ERROR ("Ns_search_and_enter: bad (null)parameter");
return (AE_BAD_PARAMETER);
}
/* Name must consist of printable characters */
- if (!acpi_cm_valid_acpi_name (entry_name)) {
+ if (!acpi_cm_valid_acpi_name (target_name)) {
+ REPORT_ERROR ("Ns_search_and_enter: Bad character in ACPI Name");
return (AE_BAD_CHARACTER);
}
/* Try to find the name in the table specified by the caller */
- *ret_entry = ENTRY_NOT_FOUND;
- status = acpi_ns_search_one_scope (entry_name, name_table,
- type, ret_entry, &search_info);
+ *return_node = ENTRY_NOT_FOUND;
+ status = acpi_ns_search_node (target_name, node,
+ type, return_node);
if (status != AE_NOT_FOUND) {
/*
* Either found it or there was an error
* -- finished either way
*/
-
return (status);
}
@@ -573,10 +315,9 @@ acpi_ns_search_and_enter (
* to ACPI specification
*/
- status = acpi_ns_search_parent_tree (entry_name, name_table,
- type, ret_entry);
-
- if (status == AE_OK) {
+ status = acpi_ns_search_parent_tree (target_name, node,
+ type, return_node);
+ if (ACPI_SUCCESS (status)) {
return (status);
}
}
@@ -585,61 +326,22 @@ acpi_ns_search_and_enter (
/*
* In execute mode, just search, never add names. Exit now.
*/
-
if (interpreter_mode == IMODE_EXECUTE) {
return (AE_NOT_FOUND);
}
- /*
- * Extract the pertinent info from the search result struct.
- * Name_table and position might now point to an appendage
- */
- name_table = search_info.name_table;
- position = search_info.position;
-
-
- /*
- * This block handles the case where the existing table is full.
- * we must allocate a new table before we can initialize a new entry
- */
-
- if (search_info.table_full) {
- status = acpi_ns_create_and_link_new_table (name_table);
- if (status != AE_OK) {
- return (status);
- }
-
- /* Point to the first slot in the new table */
+ /* Create the new named object */
- name_table = name_table->next_table;
- position = 0;
+ new_node = acpi_ns_create_node (target_name);
+ if (!new_node) {
+ return (AE_NO_MEMORY);
}
+ /* Install the new object into the parent's list of children */
- /*
- * There is room in the table (or we have just allocated a new one.)
- * Initialize the new entry
- */
-
- acpi_ns_initialize_entry (walk_state, name_table, position,
- entry_name, type);
-
-
- entries = name_table->entries;
- *ret_entry = &entries[position];
- entry = &entries[position];
-
- /*
- * Increment the reference count(s) of all parents up to
- * the root!
- */
-
- while (acpi_ns_get_parent_entry (entry)) {
- entry = acpi_ns_get_parent_entry (entry);
- entry->reference_count++;
- }
-
+ acpi_ns_install_node (walk_state, node, new_node, type);
+ *return_node = new_node;
return (AE_OK);
}
diff --git a/drivers/acpi/namespace/nsutils.c b/drivers/acpi/namespace/nsutils.c
index c938ede93..3d5a98a07 100644
--- a/drivers/acpi/namespace/nsutils.c
+++ b/drivers/acpi/namespace/nsutils.c
@@ -1,8 +1,8 @@
-
/******************************************************************************
*
* Module Name: nsutils - Utilities for accessing ACPI namespace, accessing
- * parents and siblings and Scope manipulation
+ * parents and siblings and Scope manipulation
+ * $Revision: 69 $
*
*****************************************************************************/
@@ -26,13 +26,13 @@
#include "acpi.h"
-#include "namesp.h"
-#include "interp.h"
+#include "acnamesp.h"
+#include "acinterp.h"
#include "amlcode.h"
-#include "tables.h"
+#include "actables.h"
#define _COMPONENT NAMESPACE
- MODULE_NAME ("nsutils");
+ MODULE_NAME ("nsutils")
/****************************************************************************
@@ -49,7 +49,7 @@
u8
acpi_ns_valid_root_prefix (
- char prefix)
+ NATIVE_CHAR prefix)
{
return ((u8) (prefix == '\\'));
@@ -70,7 +70,7 @@ acpi_ns_valid_root_prefix (
u8
acpi_ns_valid_path_separator (
- char sep)
+ NATIVE_CHAR sep)
{
return ((u8) (sep == '.'));
@@ -81,9 +81,9 @@ acpi_ns_valid_path_separator (
*
* FUNCTION: Acpi_ns_get_type
*
- * PARAMETERS: Handle - Handle of nte to be examined
+ * PARAMETERS: Handle - Parent Node to be examined
*
- * RETURN: Type field from nte whose handle is passed
+ * RETURN: Type field from Node whose handle is passed
*
***************************************************************************/
@@ -93,13 +93,11 @@ acpi_ns_get_type (
{
if (!handle) {
- /* Handle invalid */
-
REPORT_WARNING ("Ns_get_type: Null handle");
return (ACPI_TYPE_ANY);
}
- return (((ACPI_NAMED_OBJECT*) handle)->type);
+ return (((ACPI_NAMESPACE_NODE *) handle)->type);
}
@@ -114,19 +112,19 @@ acpi_ns_get_type (
*
***************************************************************************/
-s32
+u32
acpi_ns_local (
OBJECT_TYPE_INTERNAL type)
{
if (!acpi_cm_valid_object_type (type)) {
- /* type code out of range */
+ /* Type code out of range */
REPORT_WARNING ("Ns_local: Invalid Object Type");
return (NSP_NORMAL);
}
- return ((s32) acpi_gbl_ns_properties[type] & NSP_LOCAL);
+ return ((u32) acpi_gbl_ns_properties[type] & NSP_LOCAL);
}
@@ -147,12 +145,12 @@ acpi_ns_local (
ACPI_STATUS
acpi_ns_internalize_name (
- char *external_name,
- char **converted_name)
+ NATIVE_CHAR *external_name,
+ NATIVE_CHAR **converted_name)
{
- char *result = NULL;
- char *internal_name;
- ACPI_SIZE num_segments;
+ NATIVE_CHAR *result = NULL;
+ NATIVE_CHAR *internal_name;
+ u32 num_segments;
u8 fully_qualified = FALSE;
u32 i;
@@ -235,7 +233,7 @@ acpi_ns_internalize_name (
}
else {
- /* Convert char to uppercase and save it */
+ /* Convert s8 to uppercase and save it */
result[i] = (char) TOUPPER (*external_name);
external_name++;
@@ -273,166 +271,17 @@ acpi_ns_internalize_name (
/****************************************************************************
*
- * FUNCTION: Acpi_ns_externalize_name
- *
- * PARAMETERS: *Internal_name - Internal representation of name
- * **Converted_name - Where to return the resulting
- * external representation of name
- *
- * RETURN: Status
- *
- * DESCRIPTION: Convert internal name (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30)
- * to its external form (e.g. "\_PR_.CPU0")
- *
- ****************************************************************************/
-
-ACPI_STATUS
-acpi_ns_externalize_name (
- u32 internal_name_length,
- char *internal_name,
- u32 *converted_name_length,
- char **converted_name)
-{
- u32 prefix_length = 0;
- u32 names_index = 0;
- u32 names_count = 0;
- u32 i = 0;
- u32 j = 0;
-
- if (internal_name_length < 0 ||
- !internal_name ||
- !converted_name_length ||
- !converted_name)
- {
- return (AE_BAD_PARAMETER);
- }
-
- /*
- * Check for a prefix (one '\' | one or more '^').
- */
- switch (internal_name[0])
- {
- case '\\':
- prefix_length = 1;
- break;
-
- case '^':
- for (i = 0; i < internal_name_length; i++) {
- if (internal_name[i] != '^') {
- prefix_length = i + 1;
- }
- }
-
- if (i == internal_name_length) {
- prefix_length = i;
- }
-
- break;
- }
-
- /*
- * Check for object names. Note that there could be 0-255 of these
- * 4-byte elements.
- */
- if (prefix_length < internal_name_length) {
- switch (internal_name[prefix_length])
- {
-
- /* <count> 4-byte names */
-
- case AML_MULTI_NAME_PREFIX_OP:
- names_index = prefix_length + 2;
- names_count = (u32) internal_name[prefix_length + 1];
- break;
-
-
- /* two 4-byte names */
-
- case AML_DUAL_NAME_PREFIX:
- names_index = prefix_length + 1;
- names_count = 2;
- break;
-
-
- /* Null_name */
-
- case 0:
- names_index = 0;
- names_count = 0;
- break;
-
-
- /* one 4-byte name */
-
- default:
- names_index = prefix_length;
- names_count = 1;
- break;
- }
- }
-
- /*
- * Calculate the length of Converted_name, which equals the length
- * 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;
-
- /*
- * 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");
- return (AE_BAD_PATHNAME);
- }
-
- /*
- * Build Converted_name...
- */
-
- (*converted_name) = acpi_cm_callocate (*converted_name_length);
- if (!(*converted_name)) {
- return (AE_NO_MEMORY);
- }
-
- j = 0;
-
- for (i = 0; i < prefix_length; i++) {
- (*converted_name)[j++] = internal_name[i];
- }
-
- if (names_count > 0) {
- for (i = 0; i < names_count; i++) {
- if (i > 0) {
- (*converted_name)[j++] = '.';
- }
-
- (*converted_name)[j++] = internal_name[names_index++];
- (*converted_name)[j++] = internal_name[names_index++];
- (*converted_name)[j++] = internal_name[names_index++];
- (*converted_name)[j++] = internal_name[names_index++];
- }
- }
-
- return (AE_OK);
-}
-
-
-/****************************************************************************
- *
* FUNCTION: Acpi_ns_convert_handle_to_entry
*
- * PARAMETERS: Handle - Handle to be converted to an NTE
+ * PARAMETERS: Handle - Handle to be converted to an Node
*
* RETURN: A Name table entry pointer
*
- * DESCRIPTION: Convert a namespace handle to a real NTE
+ * DESCRIPTION: Convert a namespace handle to a real Node
*
****************************************************************************/
-ACPI_NAMED_OBJECT*
+ACPI_NAMESPACE_NODE *
acpi_ns_convert_handle_to_entry (
ACPI_HANDLE handle)
{
@@ -444,21 +293,21 @@ acpi_ns_convert_handle_to_entry (
*/
if (!handle) {
- return NULL;
+ return (NULL);
}
if (handle == ACPI_ROOT_OBJECT) {
- return acpi_gbl_root_object;
+ return (acpi_gbl_root_node);
}
/* We can at least attempt to verify the handle */
if (!VALID_DESCRIPTOR_TYPE (handle, ACPI_DESC_TYPE_NAMED)) {
- return NULL;
+ return (NULL);
}
- return (ACPI_NAMED_OBJECT*) handle;
+ return ((ACPI_NAMESPACE_NODE *) handle);
}
@@ -466,16 +315,17 @@ acpi_ns_convert_handle_to_entry (
*
* FUNCTION: Acpi_ns_convert_entry_to_handle
*
- * PARAMETERS: Nte - NTE to be converted to a Handle
+ * PARAMETERS: Node - Node to be converted to a Handle
*
* RETURN: An USER ACPI_HANDLE
*
- * DESCRIPTION: Convert a real NTE to a namespace handle
+ * DESCRIPTION: Convert a real Node to a namespace handle
*
****************************************************************************/
ACPI_HANDLE
-acpi_ns_convert_entry_to_handle(ACPI_NAMED_OBJECT*nte)
+acpi_ns_convert_entry_to_handle (
+ ACPI_NAMESPACE_NODE *node)
{
@@ -485,21 +335,21 @@ acpi_ns_convert_entry_to_handle(ACPI_NAMED_OBJECT*nte)
* and keep all pointers within this subsystem!
*/
- return (ACPI_HANDLE) nte;
+ return ((ACPI_HANDLE) node);
/* ---------------------------------------------------
- if (!Nte) {
- return NULL;
+ if (!Node) {
+ return (NULL);
}
- if (Nte == Acpi_gbl_Root_object) {
- return ACPI_ROOT_OBJECT;
+ if (Node == Acpi_gbl_Root_node) {
+ return (ACPI_ROOT_OBJECT);
}
- return (ACPI_HANDLE) Nte;
+ return ((ACPI_HANDLE) Node);
------------------------------------------------------*/
}
@@ -519,11 +369,11 @@ acpi_ns_convert_entry_to_handle(ACPI_NAMED_OBJECT*nte)
void
acpi_ns_terminate (void)
{
- ACPI_OBJECT_INTERNAL *obj_desc;
- ACPI_NAMED_OBJECT *entry;
+ ACPI_OPERAND_OBJECT *obj_desc;
+ ACPI_NAMESPACE_NODE *this_node;
- entry = acpi_gbl_root_object;
+ this_node = acpi_gbl_root_node;
/*
* 1) Free the entire namespace -- all objects, tables, and stacks
@@ -533,22 +383,19 @@ acpi_ns_terminate (void)
* (additional table descriptors)
*/
- acpi_ns_delete_namespace_subtree (entry);
+ acpi_ns_delete_namespace_subtree (this_node);
/* Detach any object(s) attached to the root */
- obj_desc = acpi_ns_get_attached_object (entry);
+ obj_desc = acpi_ns_get_attached_object (this_node);
if (obj_desc) {
- acpi_ns_detach_object (entry);
+ acpi_ns_detach_object (this_node);
acpi_cm_remove_reference (obj_desc);
}
- acpi_ns_delete_name_table (entry->child_table);
- entry->child_table = NULL;
+ acpi_ns_delete_children (this_node);
- REPORT_SUCCESS ("Entire namespace and objects deleted");
-
/*
* 2) Now we can delete the ACPI tables
*/
@@ -570,7 +417,7 @@ acpi_ns_terminate (void)
*
***************************************************************************/
-s32
+u32
acpi_ns_opens_scope (
OBJECT_TYPE_INTERNAL type)
{
@@ -582,47 +429,46 @@ acpi_ns_opens_scope (
return (NSP_NORMAL);
}
- return (((s32) acpi_gbl_ns_properties[type]) & NSP_NEWSCOPE);
+ return (((u32) acpi_gbl_ns_properties[type]) & NSP_NEWSCOPE);
}
/****************************************************************************
*
- * FUNCTION: Acpi_ns_get_named_object
+ * FUNCTION: Acpi_ns_get_node
*
* PARAMETERS: *Pathname - Name to be found, in external (ASL) format. The
* \ (backslash) and ^ (carat) prefixes, and the
* . (period) to separate segments are supported.
- * In_scope - Root of subtree to be searched, or NS_ALL for the
+ * Start_node - Root of subtree to be searched, or NS_ALL for the
* root of the name space. If Name is fully
- * qualified (first char is '\'), the passed value
+ * qualified (first s8 is '\'), the passed value
* of Scope will not be accessed.
- * Out_nte - Where the Nte is returned
+ * Return_node - Where the Node is returned
*
* DESCRIPTION: Look up a name relative to a given scope and return the
- * corresponding NTE. NOTE: Scope can be null.
+ * corresponding Node. NOTE: Scope can be null.
*
* MUTEX: Locks namespace
*
***************************************************************************/
ACPI_STATUS
-acpi_ns_get_named_object (
- char *pathname,
- ACPI_NAME_TABLE *in_scope,
- ACPI_NAMED_OBJECT **out_nte)
+acpi_ns_get_node (
+ NATIVE_CHAR *pathname,
+ ACPI_NAMESPACE_NODE *start_node,
+ ACPI_NAMESPACE_NODE **return_node)
{
ACPI_GENERIC_STATE scope_info;
ACPI_STATUS status;
- ACPI_NAMED_OBJECT *obj_entry = NULL;
- char *internal_path = NULL;
+ NATIVE_CHAR *internal_path = NULL;
- scope_info.scope.name_table = in_scope;
+ scope_info.scope.node = start_node;
/* Ensure that the namespace has been initialized */
- if (!acpi_gbl_root_object->child_table) {
+ if (!acpi_gbl_root_node) {
return (AE_NO_NAMESPACE);
}
@@ -643,13 +489,13 @@ acpi_ns_get_named_object (
/* NS_ALL means start from the root */
- if (NS_ALL == scope_info.scope.name_table) {
- scope_info.scope.name_table = acpi_gbl_root_object->child_table;
+ if (NS_ALL == scope_info.scope.node) {
+ scope_info.scope.node = acpi_gbl_root_node;
}
else {
- scope_info.scope.name_table = in_scope;
- if (!scope_info.scope.name_table) {
+ scope_info.scope.node = start_node;
+ if (!scope_info.scope.node) {
status = AE_BAD_PARAMETER;
goto unlock_and_exit;
}
@@ -660,12 +506,8 @@ acpi_ns_get_named_object (
status = acpi_ns_lookup (&scope_info, internal_path,
ACPI_TYPE_ANY, IMODE_EXECUTE,
NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE,
- NULL, &obj_entry);
-
+ NULL, return_node);
- /* Return what was wanted - the NTE that matches the name */
-
- *out_nte = obj_entry;
unlock_and_exit:
@@ -684,11 +526,11 @@ unlock_and_exit:
*
* FUNCTION: Acpi_ns_find_parent_name
*
- * PARAMETERS: *Child_entry - nte whose name is to be found
+ * PARAMETERS: *Child_node - Named Obj whose name is to be found
*
* RETURN: The ACPI name
*
- * DESCRIPTION: Search for the given nte in its parent scope and return the
+ * DESCRIPTION: Search for the given obj in its parent scope and return the
* name segment, or "????" if the parent name can't be found
* (which "should not happen").
*
@@ -696,18 +538,18 @@ unlock_and_exit:
ACPI_NAME
acpi_ns_find_parent_name (
- ACPI_NAMED_OBJECT *child_entry)
+ ACPI_NAMESPACE_NODE *child_node)
{
- ACPI_NAMED_OBJECT *parent_entry;
+ ACPI_NAMESPACE_NODE *parent_node;
- if (child_entry) {
- /* Valid entry. Get the parent Nte */
+ if (child_node) {
+ /* Valid entry. Get the parent Node */
- parent_entry = acpi_ns_get_parent_entry (child_entry);
- if (parent_entry) {
- if (parent_entry->name) {
- return (parent_entry->name);
+ parent_node = acpi_ns_get_parent_object (child_node);
+ if (parent_node) {
+ if (parent_node->name) {
+ return (parent_node->name);
}
}
@@ -717,92 +559,12 @@ acpi_ns_find_parent_name (
return (ACPI_UNKNOWN_NAME);
}
-/****************************************************************************
- *
- * FUNCTION: Acpi_ns_exist_downstream_sibling
- *
- * PARAMETERS: *This_entry - pointer to first nte to examine
- *
- * RETURN: TRUE if sibling is found, FALSE otherwise
- *
- * DESCRIPTION: Searches remainder of scope being processed to determine
- * whether there is a downstream sibling to the current
- * object. This function is used to determine what type of
- * line drawing character to use when displaying namespace
- * trees.
- *
- ***************************************************************************/
-
-u8
-acpi_ns_exist_downstream_sibling (
- ACPI_NAMED_OBJECT *this_entry)
-{
-
- if (!this_entry) {
- return FALSE;
- }
-
- if (this_entry->name) {
- return TRUE;
- }
-
-
-/* TBD: what did this really do?
- if (This_entry->Next_entry) {
- return TRUE;
- }
-*/
- return FALSE;
-}
-
/****************************************************************************
*
- * FUNCTION: Acpi_ns_get_owner_table
+ * FUNCTION: Acpi_ns_get_parent_object
*
- * PARAMETERS:
- *
- * RETURN:
- *
- * DESCRIPTION:
- *
- ***************************************************************************/
-
-
-ACPI_NAME_TABLE *
-acpi_ns_get_owner_table (
- ACPI_NAMED_OBJECT *this_entry)
-{
-
- /*
- * Given an entry in the Name_table->Entries field of a name table,
- * we can create a pointer to the beginning of the table as follows:
- *
- * 1) Starting with the the pointer to the entry,
- * 2) Subtract the entry index * size of each entry to get a
- * pointer to Entries[0]
- * 3) Subtract the size of NAME_TABLE structure to get a pointer
- * to the start.
- *
- * This saves having to put a pointer in every entry that points
- * back to the beginning of the table and/or a pointer back to
- * the parent.
- */
-
- return (ACPI_NAME_TABLE *) ((char *) this_entry -
- (this_entry->this_index *
- sizeof (ACPI_NAMED_OBJECT)) -
- (sizeof (ACPI_NAME_TABLE) -
- sizeof (ACPI_NAMED_OBJECT)));
-
-}
-
-
-/****************************************************************************
- *
- * FUNCTION: Acpi_ns_get_parent_entry
- *
- * PARAMETERS: This_entry - Current table entry
+ * PARAMETERS: Node - Current table entry
*
* RETURN: Parent entry of the given entry
*
@@ -811,76 +573,58 @@ acpi_ns_get_owner_table (
***************************************************************************/
-ACPI_NAMED_OBJECT *
-acpi_ns_get_parent_entry (
- ACPI_NAMED_OBJECT *this_entry)
+ACPI_NAMESPACE_NODE *
+acpi_ns_get_parent_object (
+ ACPI_NAMESPACE_NODE *node)
{
- ACPI_NAME_TABLE *name_table;
- name_table = acpi_ns_get_owner_table (this_entry);
-
/*
- * Now that we have a pointer to the name table, we can just pluck
- * the parent
+ * Walk to the end of this peer list.
+ * The last entry is marked with a flag and the peer
+ * pointer is really a pointer back to the parent.
+ * This saves putting a parent back pointer in each and
+ * every named object!
*/
- return (name_table->parent_entry);
+ while (!(node->flags & ANOBJ_END_OF_PEER_LIST)) {
+ node = node->peer;
+ }
+
+
+ return (node->peer);
}
/****************************************************************************
*
- * FUNCTION: Acpi_ns_get_next_valid_entry
+ * FUNCTION: Acpi_ns_get_next_valid_object
*
- * PARAMETERS: This_entry - Current table entry
+ * PARAMETERS: Node - Current table entry
*
* RETURN: Next valid object in the table. NULL if no more valid
* objects
*
* DESCRIPTION: Find the next valid object within a name table.
+ * Useful for implementing NULL-end-of-list loops.
*
***************************************************************************/
-ACPI_NAMED_OBJECT *
-acpi_ns_get_next_valid_entry (
- ACPI_NAMED_OBJECT *this_entry)
+ACPI_NAMESPACE_NODE *
+acpi_ns_get_next_valid_object (
+ ACPI_NAMESPACE_NODE *node)
{
- ACPI_NAME_TABLE *name_table;
- u32 index;
-
-
- index = this_entry->this_index + 1;
- name_table = acpi_ns_get_owner_table (this_entry);
-
-
- while (name_table) {
- if (index >= NS_TABLE_SIZE) {
- /* We are at the end of this table */
- name_table = name_table->next_table;
- index = 0;
- continue;
- }
-
-
- /* Is this a valid (occupied) slot? */
-
- if (name_table->entries[index].name) {
- /* Found a valid entry, all done */
+ /* If we are at the end of this peer list, return NULL */
- return (&name_table->entries[index]);
- }
-
- /* Go to the next slot */
-
- index++;
+ if (node->flags & ANOBJ_END_OF_PEER_LIST) {
+ return NULL;
}
- /* No more valid entries in this name table */
+ /* Otherwise just return the next peer */
- return NULL;
+ return (node->peer);
}
diff --git a/drivers/acpi/namespace/nswalk.c b/drivers/acpi/namespace/nswalk.c
index 6fcb14b76..3682266b3 100644
--- a/drivers/acpi/namespace/nswalk.c
+++ b/drivers/acpi/namespace/nswalk.c
@@ -1,7 +1,7 @@
-
/******************************************************************************
*
* Module Name: nswalk - Functions for walking the APCI namespace
+ * $Revision: 17 $
*
*****************************************************************************/
@@ -25,90 +25,85 @@
#include "acpi.h"
-#include "interp.h"
-#include "namesp.h"
+#include "acinterp.h"
+#include "acnamesp.h"
#define _COMPONENT NAMESPACE
- MODULE_NAME ("nswalk");
+ MODULE_NAME ("nswalk")
/****************************************************************************
*
* FUNCTION: Acpi_get_next_object
*
- * PARAMETERS: Type - Type of object to be searched for
- * Parent - Parent object whose children we are getting
- * Last_child - Previous child that was found.
- * The NEXT child will be returned
- * Ret_handle - Where handle to the next object is placed
+ * PARAMETERS: Type - Type of object to be searched for
+ * Parent - Parent object whose children we are
+ * getting
+ * Last_child - Previous child that was found.
+ * The NEXT child will be returned
*
- * RETURN: Status
+ * RETURN: ACPI_NAMESPACE_NODE - Pointer to the NEXT child or NULL if
+ * none is found.
*
- * DESCRIPTION: Return the next peer object within the namespace. If Handle is
- * valid, Scope is ignored. Otherwise, the first object within
- * Scope is returned.
+ * DESCRIPTION: Return the next peer object within the namespace. If Handle
+ * is valid, Scope is ignored. Otherwise, the first object
+ * within Scope is returned.
*
- ******************************************************************************/
+ ****************************************************************************/
-ACPI_NAMED_OBJECT*
+ACPI_NAMESPACE_NODE *
acpi_ns_get_next_object (
OBJECT_TYPE_INTERNAL type,
- ACPI_NAMED_OBJECT *parent,
- ACPI_NAMED_OBJECT *child)
+ ACPI_NAMESPACE_NODE *parent_node,
+ ACPI_NAMESPACE_NODE *child_node)
{
- ACPI_NAMED_OBJECT *this_entry = NULL;
+ ACPI_NAMESPACE_NODE *next_node = NULL;
- if (!child) {
+ if (!child_node) {
/* It's really the parent's _scope_ that we want */
- if (parent->child_table) {
- this_entry = parent->child_table->entries;
+ if (parent_node->child) {
+ next_node = parent_node->child;
}
}
else {
/* Start search at the NEXT object */
- this_entry = acpi_ns_get_next_valid_entry (child);
+ next_node = acpi_ns_get_next_valid_object (child_node);
}
/* If any type is OK, we are done */
if (type == ACPI_TYPE_ANY) {
- /* Make sure this is valid entry first */
-
- if ((!this_entry) ||
- (!this_entry->name))
- {
- return NULL;
- }
+ /* Next_node is NULL if we are at the end-of-list */
- return (this_entry);
+ return (next_node);
}
/* Must search for the object -- but within this scope only */
- while (this_entry) {
+ while (next_node) {
/* If type matches, we are done */
- if (this_entry->type == type) {
- return (this_entry);
+ if (next_node->type == type) {
+ return (next_node);
}
/* Otherwise, move on to the next object */
- this_entry = acpi_ns_get_next_valid_entry (this_entry);
+ next_node = acpi_ns_get_next_valid_object (next_node);
}
/* Not found */
- return NULL;
+ return (NULL);
}
@@ -117,7 +112,7 @@ acpi_ns_get_next_object (
* FUNCTION: Acpi_ns_walk_namespace
*
* PARAMETERS: Type - ACPI_OBJECT_TYPE to search for
- * Start_object - Handle in namespace where search begins
+ * Start_node - Handle in namespace where search begins
* Max_depth - Depth to which search is to reach
* Unlock_before_callback- Whether to unlock the NS before invoking
* the callback routine
@@ -145,7 +140,7 @@ acpi_ns_get_next_object (
ACPI_STATUS
acpi_ns_walk_namespace (
OBJECT_TYPE_INTERNAL type,
- ACPI_HANDLE start_object,
+ ACPI_HANDLE start_node,
u32 max_depth,
u8 unlock_before_callback,
WALK_CALLBACK user_function,
@@ -153,25 +148,25 @@ acpi_ns_walk_namespace (
void **return_value)
{
ACPI_STATUS status;
- ACPI_NAMED_OBJECT *child_entry;
- ACPI_NAMED_OBJECT *parent_entry;
+ ACPI_NAMESPACE_NODE *child_node;
+ ACPI_NAMESPACE_NODE *parent_node;
OBJECT_TYPE_INTERNAL child_type;
u32 level;
- /* Special case for the namespace root object */
+ /* Special case for the namespace Root Node */
- if (start_object == ACPI_ROOT_OBJECT) {
- start_object = acpi_gbl_root_object;
+ if (start_node == ACPI_ROOT_OBJECT) {
+ start_node = acpi_gbl_root_node;
}
/* Null child means "get first object" */
- parent_entry = start_object;
- child_entry = 0;
- child_type = ACPI_TYPE_ANY;
- level = 1;
+ parent_node = start_node;
+ child_node = 0;
+ child_type = ACPI_TYPE_ANY;
+ level = 1;
/*
* Traverse the tree of objects until we bubble back up to where we
@@ -186,18 +181,18 @@ acpi_ns_walk_namespace (
*/
status = AE_OK;
- child_entry = acpi_ns_get_next_object (ACPI_TYPE_ANY,
- parent_entry,
- child_entry);
+ child_node = acpi_ns_get_next_object (ACPI_TYPE_ANY,
+ parent_node,
+ child_node);
- if (child_entry) {
+ if (child_node) {
/*
* Found an object, Get the type if we are not
* searching for ANY
*/
if (type != ACPI_TYPE_ANY) {
- child_type = child_entry->type;
+ child_type = child_node->type;
}
if (child_type == type) {
@@ -210,7 +205,7 @@ acpi_ns_walk_namespace (
acpi_cm_release_mutex (ACPI_MTX_NAMESPACE);
}
- status = user_function (child_entry, level,
+ status = user_function (child_node, level,
context, return_value);
if (unlock_before_callback) {
@@ -247,15 +242,15 @@ acpi_ns_walk_namespace (
if ((level < max_depth) && (status != AE_CTRL_DEPTH)) {
if (acpi_ns_get_next_object (ACPI_TYPE_ANY,
- child_entry, 0))
+ child_node, 0))
{
/*
* There is at least one child of this
* object, visit the object
*/
level++;
- parent_entry = child_entry;
- child_entry = 0;
+ parent_node = child_node;
+ child_node = 0;
}
}
}
@@ -267,8 +262,8 @@ acpi_ns_walk_namespace (
* the object's parent.
*/
level--;
- child_entry = parent_entry;
- parent_entry = acpi_ns_get_parent_entry (parent_entry);
+ child_node = parent_node;
+ parent_node = acpi_ns_get_parent_object (parent_node);
}
}
diff --git a/drivers/acpi/namespace/nsxfname.c b/drivers/acpi/namespace/nsxfname.c
index 2622a9be8..dc02c6407 100644
--- a/drivers/acpi/namespace/nsxfname.c
+++ b/drivers/acpi/namespace/nsxfname.c
@@ -2,6 +2,7 @@
*
* Module Name: nsxfname - Public interfaces to the ACPI subsystem
* ACPI Namespace oriented interfaces
+ * $Revision: 64 $
*
*****************************************************************************/
@@ -25,16 +26,16 @@
#include "acpi.h"
-#include "interp.h"
-#include "namesp.h"
+#include "acinterp.h"
+#include "acnamesp.h"
#include "amlcode.h"
-#include "parser.h"
-#include "dispatch.h"
-#include "events.h"
+#include "acparser.h"
+#include "acdispat.h"
+#include "acevents.h"
#define _COMPONENT NAMESPACE
- MODULE_NAME ("nsxfname");
+ MODULE_NAME ("nsxfname")
/******************************************************************************
@@ -64,21 +65,6 @@ acpi_load_namespace (
}
- /* Init the hardware */
-
- /*
- * TBD: [Restructure] Should this should be moved elsewhere,
- * like Acpi_enable! ??
- */
-
- /* we need to be able to call this interface repeatedly! */
- /* Does H/W require init before loading the namespace? */
-
- status = acpi_cm_hardware_initialize ();
- if (ACPI_FAILURE (status)) {
- return (status);
- }
-
/*
* Load the namespace. The DSDT is required,
* but the SSDT and PSDT tables are optional.
@@ -131,24 +117,24 @@ acpi_get_handle (
ACPI_HANDLE *ret_handle)
{
ACPI_STATUS status;
- ACPI_NAMED_OBJECT *this_entry;
- ACPI_NAME_TABLE *scope = NULL;
+ ACPI_NAMESPACE_NODE *node;
+ ACPI_NAMESPACE_NODE *prefix_node = NULL;
if (!ret_handle || !pathname) {
- return AE_BAD_PARAMETER;
+ return (AE_BAD_PARAMETER);
}
if (parent) {
acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE);
- this_entry = acpi_ns_convert_handle_to_entry (parent);
- if (!this_entry) {
+ node = acpi_ns_convert_handle_to_entry (parent);
+ if (!node) {
acpi_cm_release_mutex (ACPI_MTX_NAMESPACE);
- return AE_BAD_PARAMETER;
+ return (AE_BAD_PARAMETER);
}
- scope = this_entry->child_table;
+ prefix_node = node->child;
acpi_cm_release_mutex (ACPI_MTX_NAMESPACE);
}
@@ -156,17 +142,20 @@ acpi_get_handle (
/* TBD: [Investigate] Check for both forward and backslash?? */
if (STRCMP (pathname, NS_ROOT_PATH) == 0) {
- *ret_handle = acpi_ns_convert_entry_to_handle (acpi_gbl_root_object);
- return AE_OK;
+ *ret_handle = acpi_ns_convert_entry_to_handle (acpi_gbl_root_node);
+ return (AE_OK);
}
/*
- * Find the Nte and convert to the user format
+ * Find the Node and convert to the user format
*/
- this_entry = NULL;
- status = acpi_ns_get_named_object (pathname, scope, &this_entry);
+ node = NULL;
+ status = acpi_ns_get_node (pathname, prefix_node, &node);
- *ret_handle = acpi_ns_convert_entry_to_handle (this_entry);
+ *ret_handle = NULL;
+ if(ACPI_SUCCESS(status)) {
+ *ret_handle = acpi_ns_convert_entry_to_handle (node);
+ }
return (status);
}
@@ -195,13 +184,13 @@ acpi_get_name (
ACPI_BUFFER *ret_path_ptr)
{
ACPI_STATUS status;
- ACPI_NAMED_OBJECT *obj_entry;
+ ACPI_NAMESPACE_NODE *node;
/* Buffer pointer must be valid always */
if (!ret_path_ptr || (name_type > ACPI_NAME_TYPE_MAX)) {
- return AE_BAD_PARAMETER;
+ return (AE_BAD_PARAMETER);
}
/* Allow length to be zero and ignore the pointer */
@@ -209,7 +198,7 @@ acpi_get_name (
if ((ret_path_ptr->length) &&
(!ret_path_ptr->pointer))
{
- return AE_BAD_PARAMETER;
+ return (AE_BAD_PARAMETER);
}
if (name_type == ACPI_FULL_PATHNAME) {
@@ -217,17 +206,17 @@ acpi_get_name (
status = acpi_ns_handle_to_pathname (handle, &ret_path_ptr->length,
ret_path_ptr->pointer);
- return status;
+ return (status);
}
/*
* Wants the single segment ACPI name.
- * Validate handle and convert to an NTE
+ * Validate handle and convert to an Node
*/
acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE);
- obj_entry = acpi_ns_convert_handle_to_entry (handle);
- if (!obj_entry) {
+ node = acpi_ns_convert_handle_to_entry (handle);
+ if (!node) {
status = AE_BAD_PARAMETER;
goto unlock_and_exit;
}
@@ -240,18 +229,18 @@ acpi_get_name (
goto unlock_and_exit;
}
- /* Just copy the ACPI name from the NTE and zero terminate it */
+ /* Just copy the ACPI name from the Node and zero terminate it */
- STRNCPY (ret_path_ptr->pointer, (char *) &obj_entry->name,
+ STRNCPY (ret_path_ptr->pointer, (NATIVE_CHAR *) &node->name,
ACPI_NAME_SIZE);
- ((char *) ret_path_ptr->pointer) [ACPI_NAME_SIZE] = 0;
+ ((NATIVE_CHAR *) ret_path_ptr->pointer) [ACPI_NAME_SIZE] = 0;
status = AE_OK;
unlock_and_exit:
acpi_cm_release_mutex (ACPI_MTX_NAMESPACE);
- return status;
+ return (status);
}
@@ -279,27 +268,27 @@ acpi_get_object_info (
ACPI_STATUS status;
u32 device_status = 0;
u32 address = 0;
- ACPI_NAMED_OBJECT *device_entry;
+ ACPI_NAMESPACE_NODE *device_node;
/* Parameter validation */
if (!device || !info) {
- return AE_BAD_PARAMETER;
+ return (AE_BAD_PARAMETER);
}
acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE);
- device_entry = acpi_ns_convert_handle_to_entry (device);
- if (!device_entry) {
+ device_node = acpi_ns_convert_handle_to_entry (device);
+ if (!device_node) {
acpi_cm_release_mutex (ACPI_MTX_NAMESPACE);
- return AE_BAD_PARAMETER;
+ return (AE_BAD_PARAMETER);
}
- info->type = device_entry->type;
- info->name = device_entry->name;
- info->parent =
- acpi_ns_convert_entry_to_handle (acpi_ns_get_parent_entry (device_entry));
+ info->type = device_node->type;
+ info->name = device_node->name;
+ info->parent = acpi_ns_convert_entry_to_handle (
+ acpi_ns_get_parent_object (device_node));
acpi_cm_release_mutex (ACPI_MTX_NAMESPACE);
@@ -307,17 +296,17 @@ acpi_get_object_info (
* If not a device, we are all done.
*/
if (info->type != ACPI_TYPE_DEVICE) {
- return AE_OK;
+ return (AE_OK);
}
/* Get extra info for ACPI devices */
- info->valid = 0;
+ info->valid = 0;
/* Execute the _HID method and save the result */
- status = acpi_cm_execute_HID (device_entry, &hid);
+ status = acpi_cm_execute_HID (device_node, &hid);
if (ACPI_SUCCESS (status)) {
if (hid.type == STRING_PTR_DEVICE_ID) {
STRCPY (info->hardware_id, hid.data.string_ptr);
@@ -331,7 +320,7 @@ acpi_get_object_info (
/* Execute the _UID method and save the result */
- status = acpi_cm_execute_UID (device_entry, &uid);
+ status = acpi_cm_execute_UID (device_node, &uid);
if (ACPI_SUCCESS (status)) {
if (hid.type == STRING_PTR_DEVICE_ID) {
STRCPY (info->unique_id, uid.data.string_ptr);
@@ -348,7 +337,7 @@ acpi_get_object_info (
* _STA is not always present
*/
- status = acpi_cm_execute_STA (device_entry, &device_status);
+ status = acpi_cm_execute_STA (device_node, &device_status);
if (ACPI_SUCCESS (status)) {
info->current_status = device_status;
info->valid |= ACPI_VALID_STA;
@@ -360,13 +349,13 @@ acpi_get_object_info (
*/
status = acpi_cm_evaluate_numeric_object (METHOD_NAME__ADR,
- device_entry, &address);
+ device_node, &address);
if (ACPI_SUCCESS (status)) {
info->address = address;
info->valid |= ACPI_VALID_ADR;
}
- return AE_OK;
+ return (AE_OK);
}
diff --git a/drivers/acpi/namespace/nsxfobj.c b/drivers/acpi/namespace/nsxfobj.c
index 09c5e4e3d..9b254ea99 100644
--- a/drivers/acpi/namespace/nsxfobj.c
+++ b/drivers/acpi/namespace/nsxfobj.c
@@ -1,10 +1,10 @@
-
-/******************************************************************************
+/*******************************************************************************
*
* Module Name: nsxfobj - Public interfaces to the ACPI subsystem
* ACPI Object oriented interfaces
+ * $Revision: 65 $
*
- *****************************************************************************/
+ ******************************************************************************/
/*
* Copyright (C) 2000 R. Byron Moore
@@ -26,15 +26,15 @@
#include "acpi.h"
-#include "interp.h"
-#include "namesp.h"
+#include "acinterp.h"
+#include "acnamesp.h"
#define _COMPONENT NAMESPACE
- MODULE_NAME ("nsxfobj");
+ MODULE_NAME ("nsxfobj")
-/****************************************************************************
+/*******************************************************************************
*
* FUNCTION: Acpi_evaluate_object
*
@@ -54,7 +54,7 @@
* parameters if necessary. One of "Handle" or "Pathname" must
* be valid (non-null)
*
- ****************************************************************************/
+ ******************************************************************************/
ACPI_STATUS
acpi_evaluate_object (
@@ -64,9 +64,9 @@ acpi_evaluate_object (
ACPI_BUFFER *return_buffer)
{
ACPI_STATUS status;
- ACPI_OBJECT_INTERNAL **param_ptr = NULL;
- ACPI_OBJECT_INTERNAL *return_obj = NULL;
- ACPI_OBJECT_INTERNAL *object_ptr = NULL;
+ ACPI_OPERAND_OBJECT **param_ptr = NULL;
+ ACPI_OPERAND_OBJECT *return_obj = NULL;
+ ACPI_OPERAND_OBJECT *object_ptr = NULL;
u32 buffer_space_needed;
u32 user_buffer_length;
u32 count;
@@ -85,12 +85,11 @@ acpi_evaluate_object (
/*
* Allocate a new parameter block for the internal objects
* Add 1 to count to allow for null terminated internal list
- * TBD: [Restructure] merge into single allocation!
*/
count = param_objects->count;
param_length = (count + 1) * sizeof (void *);
- object_length = count * sizeof (ACPI_OBJECT_INTERNAL);
+ object_length = count * sizeof (ACPI_OPERAND_OBJECT);
param_ptr = acpi_cm_callocate (param_length + /* Parameter List part */
object_length); /* Actual objects */
@@ -98,7 +97,7 @@ acpi_evaluate_object (
return (AE_NO_MEMORY);
}
- object_ptr = (ACPI_OBJECT_INTERNAL *) ((u8 *) param_ptr +
+ object_ptr = (ACPI_OPERAND_OBJECT *) ((u8 *) param_ptr +
param_length);
/*
@@ -169,18 +168,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,
- param_ptr,
- &return_obj);
+ status = acpi_ns_evaluate_by_handle (handle, param_ptr, &return_obj);
}
else {
/*
* Both a Handle and a relative Pathname
*/
- status = acpi_ns_evaluate_relative (handle, pathname,
- param_ptr,
- &return_obj);
+ status = acpi_ns_evaluate_relative (handle, pathname, param_ptr,
+ &return_obj);
}
}
@@ -195,11 +191,9 @@ acpi_evaluate_object (
return_buffer->length = 0;
if (return_obj) {
- if (VALID_DESCRIPTOR_TYPE (return_obj,
- ACPI_DESC_TYPE_NAMED))
- {
+ if (VALID_DESCRIPTOR_TYPE (return_obj, ACPI_DESC_TYPE_NAMED)) {
/*
- * If we got an NTE as a return object,
+ * 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
@@ -210,7 +204,7 @@ acpi_evaluate_object (
* types at a later date if necessary.
*/
status = AE_TYPE;
- return_obj = NULL; /* No need to delete an NTE */
+ return_obj = NULL; /* No need to delete an Node */
}
if (ACPI_SUCCESS (status)) {
@@ -241,9 +235,8 @@ acpi_evaluate_object (
/*
* We have enough space for the object, build it
*/
- status =
- acpi_cm_build_external_object (return_obj,
- return_buffer);
+ status = acpi_cm_build_external_object (return_obj,
+ return_buffer);
return_buffer->length = buffer_space_needed;
}
}
@@ -276,7 +269,7 @@ acpi_evaluate_object (
}
-/****************************************************************************
+/*******************************************************************************
*
* FUNCTION: Acpi_get_next_object
*
@@ -302,15 +295,15 @@ acpi_get_next_object (
ACPI_HANDLE *ret_handle)
{
ACPI_STATUS status = AE_OK;
- ACPI_NAMED_OBJECT *entry;
- ACPI_NAMED_OBJECT *parent_entry = NULL;
- ACPI_NAMED_OBJECT *child_entry = NULL;
+ ACPI_NAMESPACE_NODE *node;
+ ACPI_NAMESPACE_NODE *parent_node = NULL;
+ ACPI_NAMESPACE_NODE *child_node = NULL;
/* Parameter validation */
if (type > ACPI_TYPE_MAX) {
- return AE_BAD_PARAMETER;
+ return (AE_BAD_PARAMETER);
}
acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE);
@@ -320,8 +313,8 @@ acpi_get_next_object (
if (!child) {
/* Start search at the beginning of the specified scope */
- parent_entry = acpi_ns_convert_handle_to_entry (parent);
- if (!parent_entry) {
+ parent_node = acpi_ns_convert_handle_to_entry (parent);
+ if (!parent_node) {
status = AE_BAD_PARAMETER;
goto unlock_and_exit;
}
@@ -332,8 +325,8 @@ acpi_get_next_object (
else {
/* Convert and validate the handle */
- child_entry = acpi_ns_convert_handle_to_entry (child);
- if (!child_entry) {
+ child_node = acpi_ns_convert_handle_to_entry (child);
+ if (!child_node) {
status = AE_BAD_PARAMETER;
goto unlock_and_exit;
}
@@ -342,26 +335,26 @@ acpi_get_next_object (
/* Internal function does the real work */
- entry = acpi_ns_get_next_object ((OBJECT_TYPE_INTERNAL) type,
- parent_entry, child_entry);
- if (!entry) {
+ node = acpi_ns_get_next_object ((OBJECT_TYPE_INTERNAL) type,
+ parent_node, child_node);
+ if (!node) {
status = AE_NOT_FOUND;
goto unlock_and_exit;
}
if (ret_handle) {
- *ret_handle = acpi_ns_convert_entry_to_handle (entry);
+ *ret_handle = acpi_ns_convert_entry_to_handle (node);
}
unlock_and_exit:
acpi_cm_release_mutex (ACPI_MTX_NAMESPACE);
- return status;
+ return (status);
}
-/****************************************************************************
+/*******************************************************************************
*
* FUNCTION: Acpi_get_type
*
@@ -379,44 +372,43 @@ acpi_get_type (
ACPI_HANDLE handle,
ACPI_OBJECT_TYPE *ret_type)
{
- ACPI_NAMED_OBJECT *object;
+ ACPI_NAMESPACE_NODE *node;
/* Parameter Validation */
if (!ret_type) {
- return AE_BAD_PARAMETER;
+ return (AE_BAD_PARAMETER);
}
/*
- * Special case for the predefined Root Object
+ * Special case for the predefined Root Node
* (return type ANY)
*/
-
if (handle == ACPI_ROOT_OBJECT) {
*ret_type = ACPI_TYPE_ANY;
- return AE_OK;
+ return (AE_OK);
}
acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE);
/* Convert and validate the handle */
- object = acpi_ns_convert_handle_to_entry (handle);
- if (!object) {
+ node = acpi_ns_convert_handle_to_entry (handle);
+ if (!node) {
acpi_cm_release_mutex (ACPI_MTX_NAMESPACE);
- return AE_BAD_PARAMETER;
+ return (AE_BAD_PARAMETER);
}
- *ret_type = object->type;
+ *ret_type = node->type;
acpi_cm_release_mutex (ACPI_MTX_NAMESPACE);
- return AE_OK;
+ return (AE_OK);
}
-/****************************************************************************
+/*******************************************************************************
*
* FUNCTION: Acpi_get_parent
*
@@ -435,7 +427,7 @@ acpi_get_parent (
ACPI_HANDLE handle,
ACPI_HANDLE *ret_handle)
{
- ACPI_NAMED_OBJECT *object;
+ ACPI_NAMESPACE_NODE *node;
ACPI_STATUS status = AE_OK;
@@ -443,13 +435,13 @@ acpi_get_parent (
if (!ret_handle) {
- return AE_BAD_PARAMETER;
+ return (AE_BAD_PARAMETER);
}
- /* Special case for the predefined Root Object (no parent) */
+ /* Special case for the predefined Root Node (no parent) */
if (handle == ACPI_ROOT_OBJECT) {
- return AE_NULL_ENTRY;
+ return (AE_NULL_ENTRY);
}
@@ -457,8 +449,8 @@ acpi_get_parent (
/* Convert and validate the handle */
- object = acpi_ns_convert_handle_to_entry (handle);
- if (!object) {
+ node = acpi_ns_convert_handle_to_entry (handle);
+ if (!node) {
status = AE_BAD_PARAMETER;
goto unlock_and_exit;
}
@@ -467,11 +459,11 @@ acpi_get_parent (
/* Get the parent entry */
*ret_handle =
- acpi_ns_convert_entry_to_handle (acpi_ns_get_parent_entry (object));
+ acpi_ns_convert_entry_to_handle (acpi_ns_get_parent_object (node));
/* Return exeption if parent is null */
- if (!acpi_ns_get_parent_entry (object)) {
+ if (!acpi_ns_get_parent_object (node)) {
status = AE_NULL_ENTRY;
}
@@ -479,11 +471,11 @@ acpi_get_parent (
unlock_and_exit:
acpi_cm_release_mutex (ACPI_MTX_NAMESPACE);
- return AE_OK;
+ return (status);
}
-/******************************************************************************
+/*******************************************************************************
*
* FUNCTION: Acpi_walk_namespace
*