aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/namespace
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/namespace')
-rw-r--r--drivers/acpi/namespace/nsaccess.c36
-rw-r--r--drivers/acpi/namespace/nsalloc.c14
-rw-r--r--drivers/acpi/namespace/nsdump.c13
-rw-r--r--drivers/acpi/namespace/nsdumpdv.c2
-rw-r--r--drivers/acpi/namespace/nseval.c13
-rw-r--r--drivers/acpi/namespace/nsinit.c9
-rw-r--r--drivers/acpi/namespace/nsload.c160
-rw-r--r--drivers/acpi/namespace/nsnames.c2
-rw-r--r--drivers/acpi/namespace/nsobject.c2
-rw-r--r--drivers/acpi/namespace/nsparse.c52
-rw-r--r--drivers/acpi/namespace/nssearch.c9
-rw-r--r--drivers/acpi/namespace/nsutils.c9
-rw-r--r--drivers/acpi/namespace/nswalk.c65
-rw-r--r--drivers/acpi/namespace/nsxfeval.c13
-rw-r--r--drivers/acpi/namespace/nsxfname.c47
-rw-r--r--drivers/acpi/namespace/nsxfobj.c2
16 files changed, 193 insertions, 255 deletions
diff --git a/drivers/acpi/namespace/nsaccess.c b/drivers/acpi/namespace/nsaccess.c
index c1c6c236df9a..57faf598bad8 100644
--- a/drivers/acpi/namespace/nsaccess.c
+++ b/drivers/acpi/namespace/nsaccess.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2006, R. Byron Moore 8 * Copyright (C) 2000 - 2007, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -195,31 +195,27 @@ acpi_status acpi_ns_root_initialize(void)
195 obj_desc->mutex.sync_level = 195 obj_desc->mutex.sync_level =
196 (u8) (ACPI_TO_INTEGER(val) - 1); 196 (u8) (ACPI_TO_INTEGER(val) - 1);
197 197
198 if (ACPI_STRCMP(init_val->name, "_GL_") == 0) { 198 /* Create a mutex */
199 199
200 /* Create a counting semaphore for the global lock */ 200 status =
201 acpi_os_create_mutex(&obj_desc->mutex.
202 os_mutex);
203 if (ACPI_FAILURE(status)) {
204 acpi_ut_remove_reference(obj_desc);
205 goto unlock_and_exit;
206 }
201 207
202 status = 208 /* Special case for ACPI Global Lock */
203 acpi_os_create_semaphore
204 (ACPI_NO_UNIT_LIMIT, 1,
205 &acpi_gbl_global_lock_semaphore);
206 if (ACPI_FAILURE(status)) {
207 acpi_ut_remove_reference
208 (obj_desc);
209 goto unlock_and_exit;
210 }
211 209
212 /* Mark this mutex as very special */ 210 if (ACPI_STRCMP(init_val->name, "_GL_") == 0) {
211 acpi_gbl_global_lock_mutex =
212 obj_desc->mutex.os_mutex;
213 213
214 obj_desc->mutex.os_mutex = 214 /* Create additional counting semaphore for global lock */
215 ACPI_GLOBAL_LOCK;
216 } else {
217 /* Create a mutex */
218 215
219 status = 216 status =
220 acpi_os_create_mutex(&obj_desc-> 217 acpi_os_create_semaphore(1, 0,
221 mutex. 218 &acpi_gbl_global_lock_semaphore);
222 os_mutex);
223 if (ACPI_FAILURE(status)) { 219 if (ACPI_FAILURE(status)) {
224 acpi_ut_remove_reference 220 acpi_ut_remove_reference
225 (obj_desc); 221 (obj_desc);
diff --git a/drivers/acpi/namespace/nsalloc.c b/drivers/acpi/namespace/nsalloc.c
index 55b407aae266..1d693d8ad2d8 100644
--- a/drivers/acpi/namespace/nsalloc.c
+++ b/drivers/acpi/namespace/nsalloc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2006, R. Byron Moore 8 * Copyright (C) 2000 - 2007, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -61,6 +61,9 @@ ACPI_MODULE_NAME("nsalloc")
61struct acpi_namespace_node *acpi_ns_create_node(u32 name) 61struct acpi_namespace_node *acpi_ns_create_node(u32 name)
62{ 62{
63 struct acpi_namespace_node *node; 63 struct acpi_namespace_node *node;
64#ifdef ACPI_DBG_TRACK_ALLOCATIONS
65 u32 temp;
66#endif
64 67
65 ACPI_FUNCTION_TRACE(ns_create_node); 68 ACPI_FUNCTION_TRACE(ns_create_node);
66 69
@@ -71,6 +74,15 @@ struct acpi_namespace_node *acpi_ns_create_node(u32 name)
71 74
72 ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_allocated++); 75 ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_allocated++);
73 76
77#ifdef ACPI_DBG_TRACK_ALLOCATIONS
78 temp =
79 acpi_gbl_ns_node_list->total_allocated -
80 acpi_gbl_ns_node_list->total_freed;
81 if (temp > acpi_gbl_ns_node_list->max_occupied) {
82 acpi_gbl_ns_node_list->max_occupied = temp;
83 }
84#endif
85
74 node->name.integer = name; 86 node->name.integer = name;
75 ACPI_SET_DESCRIPTOR_TYPE(node, ACPI_DESC_TYPE_NAMED); 87 ACPI_SET_DESCRIPTOR_TYPE(node, ACPI_DESC_TYPE_NAMED);
76 return_PTR(node); 88 return_PTR(node);
diff --git a/drivers/acpi/namespace/nsdump.c b/drivers/acpi/namespace/nsdump.c
index d72df66aa965..1fc4f86676e1 100644
--- a/drivers/acpi/namespace/nsdump.c
+++ b/drivers/acpi/namespace/nsdump.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2006, R. Byron Moore 8 * Copyright (C) 2000 - 2007, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -205,7 +205,7 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
205 205
206 if (!acpi_ut_valid_acpi_name(this_node->name.integer)) { 206 if (!acpi_ut_valid_acpi_name(this_node->name.integer)) {
207 this_node->name.integer = 207 this_node->name.integer =
208 acpi_ut_repair_name(this_node->name.integer); 208 acpi_ut_repair_name(this_node->name.ascii);
209 209
210 ACPI_WARNING((AE_INFO, "Invalid ACPI Name %08X", 210 ACPI_WARNING((AE_INFO, "Invalid ACPI Name %08X",
211 this_node->name.integer)); 211 this_node->name.integer));
@@ -226,6 +226,12 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
226 obj_desc = acpi_ns_get_attached_object(this_node); 226 obj_desc = acpi_ns_get_attached_object(this_node);
227 acpi_dbg_level = dbg_level; 227 acpi_dbg_level = dbg_level;
228 228
229 /* Temp nodes are those nodes created by a control method */
230
231 if (this_node->flags & ANOBJ_TEMPORARY) {
232 acpi_os_printf("(T) ");
233 }
234
229 switch (info->display_type & ACPI_DISPLAY_MASK) { 235 switch (info->display_type & ACPI_DISPLAY_MASK) {
230 case ACPI_DISPLAY_SUMMARY: 236 case ACPI_DISPLAY_SUMMARY:
231 237
@@ -623,7 +629,8 @@ acpi_ns_dump_objects(acpi_object_type type,
623 info.display_type = display_type; 629 info.display_type = display_type;
624 630
625 (void)acpi_ns_walk_namespace(type, start_handle, max_depth, 631 (void)acpi_ns_walk_namespace(type, start_handle, max_depth,
626 ACPI_NS_WALK_NO_UNLOCK, 632 ACPI_NS_WALK_NO_UNLOCK |
633 ACPI_NS_WALK_TEMP_NODES,
627 acpi_ns_dump_one_object, (void *)&info, 634 acpi_ns_dump_one_object, (void *)&info,
628 NULL); 635 NULL);
629} 636}
diff --git a/drivers/acpi/namespace/nsdumpdv.c b/drivers/acpi/namespace/nsdumpdv.c
index c6bf5d30fca3..5097e167939e 100644
--- a/drivers/acpi/namespace/nsdumpdv.c
+++ b/drivers/acpi/namespace/nsdumpdv.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2006, R. Byron Moore 8 * Copyright (C) 2000 - 2007, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/namespace/nseval.c b/drivers/acpi/namespace/nseval.c
index 4b0a4a8c9843..aa6370c67ec1 100644
--- a/drivers/acpi/namespace/nseval.c
+++ b/drivers/acpi/namespace/nseval.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2006, R. Byron Moore 8 * Copyright (C) 2000 - 2007, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -154,11 +154,7 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info *info)
154 * Execute the method via the interpreter. The interpreter is locked 154 * Execute the method via the interpreter. The interpreter is locked
155 * here before calling into the AML parser 155 * here before calling into the AML parser
156 */ 156 */
157 status = acpi_ex_enter_interpreter(); 157 acpi_ex_enter_interpreter();
158 if (ACPI_FAILURE(status)) {
159 return_ACPI_STATUS(status);
160 }
161
162 status = acpi_ps_execute_method(info); 158 status = acpi_ps_execute_method(info);
163 acpi_ex_exit_interpreter(); 159 acpi_ex_exit_interpreter();
164 } else { 160 } else {
@@ -182,10 +178,7 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info *info)
182 * resolution, we must lock it because we could access an opregion. 178 * resolution, we must lock it because we could access an opregion.
183 * The opregion access code assumes that the interpreter is locked. 179 * The opregion access code assumes that the interpreter is locked.
184 */ 180 */
185 status = acpi_ex_enter_interpreter(); 181 acpi_ex_enter_interpreter();
186 if (ACPI_FAILURE(status)) {
187 return_ACPI_STATUS(status);
188 }
189 182
190 /* Function has a strange interface */ 183 /* Function has a strange interface */
191 184
diff --git a/drivers/acpi/namespace/nsinit.c b/drivers/acpi/namespace/nsinit.c
index aec8488c0019..326af8fc0ce7 100644
--- a/drivers/acpi/namespace/nsinit.c
+++ b/drivers/acpi/namespace/nsinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2006, R. Byron Moore 8 * Copyright (C) 2000 - 2007, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -213,7 +213,7 @@ acpi_ns_init_one_object(acpi_handle obj_handle,
213 u32 level, void *context, void **return_value) 213 u32 level, void *context, void **return_value)
214{ 214{
215 acpi_object_type type; 215 acpi_object_type type;
216 acpi_status status; 216 acpi_status status = AE_OK;
217 struct acpi_init_walk_info *info = 217 struct acpi_init_walk_info *info =
218 (struct acpi_init_walk_info *)context; 218 (struct acpi_init_walk_info *)context;
219 struct acpi_namespace_node *node = 219 struct acpi_namespace_node *node =
@@ -267,10 +267,7 @@ acpi_ns_init_one_object(acpi_handle obj_handle,
267 /* 267 /*
268 * Must lock the interpreter before executing AML code 268 * Must lock the interpreter before executing AML code
269 */ 269 */
270 status = acpi_ex_enter_interpreter(); 270 acpi_ex_enter_interpreter();
271 if (ACPI_FAILURE(status)) {
272 return (status);
273 }
274 271
275 /* 272 /*
276 * Each of these types can contain executable AML code within the 273 * Each of these types can contain executable AML code within the
diff --git a/drivers/acpi/namespace/nsload.c b/drivers/acpi/namespace/nsload.c
index fe75d888e183..d4f9654fd20f 100644
--- a/drivers/acpi/namespace/nsload.c
+++ b/drivers/acpi/namespace/nsload.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2006, R. Byron Moore 8 * Copyright (C) 2000 - 2007, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -44,13 +44,12 @@
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include <acpi/acnamesp.h>
46#include <acpi/acdispat.h> 46#include <acpi/acdispat.h>
47#include <acpi/actables.h>
47 48
48#define _COMPONENT ACPI_NAMESPACE 49#define _COMPONENT ACPI_NAMESPACE
49ACPI_MODULE_NAME("nsload") 50ACPI_MODULE_NAME("nsload")
50 51
51/* Local prototypes */ 52/* Local prototypes */
52static acpi_status acpi_ns_load_table_by_type(acpi_table_type table_type);
53
54#ifdef ACPI_FUTURE_IMPLEMENTATION 53#ifdef ACPI_FUTURE_IMPLEMENTATION
55acpi_status acpi_ns_unload_namespace(acpi_handle handle); 54acpi_status acpi_ns_unload_namespace(acpi_handle handle);
56 55
@@ -62,7 +61,7 @@ static acpi_status acpi_ns_delete_subtree(acpi_handle start_handle);
62 * 61 *
63 * FUNCTION: acpi_ns_load_table 62 * FUNCTION: acpi_ns_load_table
64 * 63 *
65 * PARAMETERS: table_desc - Descriptor for table to be loaded 64 * PARAMETERS: table_index - Index for table to be loaded
66 * Node - Owning NS node 65 * Node - Owning NS node
67 * 66 *
68 * RETURN: Status 67 * RETURN: Status
@@ -72,42 +71,13 @@ static acpi_status acpi_ns_delete_subtree(acpi_handle start_handle);
72 ******************************************************************************/ 71 ******************************************************************************/
73 72
74acpi_status 73acpi_status
75acpi_ns_load_table(struct acpi_table_desc *table_desc, 74acpi_ns_load_table(acpi_native_uint table_index,
76 struct acpi_namespace_node *node) 75 struct acpi_namespace_node *node)
77{ 76{
78 acpi_status status; 77 acpi_status status;
79 78
80 ACPI_FUNCTION_TRACE(ns_load_table); 79 ACPI_FUNCTION_TRACE(ns_load_table);
81 80
82 /* Check if table contains valid AML (must be DSDT, PSDT, SSDT, etc.) */
83
84 if (!
85 (acpi_gbl_table_data[table_desc->type].
86 flags & ACPI_TABLE_EXECUTABLE)) {
87
88 /* Just ignore this table */
89
90 return_ACPI_STATUS(AE_OK);
91 }
92
93 /* Check validity of the AML start and length */
94
95 if (!table_desc->aml_start) {
96 ACPI_ERROR((AE_INFO, "Null AML pointer"));
97 return_ACPI_STATUS(AE_BAD_PARAMETER);
98 }
99
100 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "AML block at %p\n",
101 table_desc->aml_start));
102
103 /* Ignore table if there is no AML contained within */
104
105 if (!table_desc->aml_length) {
106 ACPI_WARNING((AE_INFO, "Zero-length AML block in table [%4.4s]",
107 table_desc->pointer->signature));
108 return_ACPI_STATUS(AE_OK);
109 }
110
111 /* 81 /*
112 * Parse the table and load the namespace with all named 82 * Parse the table and load the namespace with all named
113 * objects found within. Control methods are NOT parsed 83 * objects found within. Control methods are NOT parsed
@@ -117,15 +87,34 @@ acpi_ns_load_table(struct acpi_table_desc *table_desc,
117 * to another control method, we can't continue parsing 87 * to another control method, we can't continue parsing
118 * because we don't know how many arguments to parse next! 88 * because we don't know how many arguments to parse next!
119 */ 89 */
90 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
91 if (ACPI_FAILURE(status)) {
92 return_ACPI_STATUS(status);
93 }
94
95 /* If table already loaded into namespace, just return */
96
97 if (acpi_tb_is_table_loaded(table_index)) {
98 status = AE_ALREADY_EXISTS;
99 goto unlock;
100 }
101
120 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 102 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
121 "**** Loading table into namespace ****\n")); 103 "**** Loading table into namespace ****\n"));
122 104
123 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 105 status = acpi_tb_allocate_owner_id(table_index);
124 if (ACPI_FAILURE(status)) { 106 if (ACPI_FAILURE(status)) {
125 return_ACPI_STATUS(status); 107 goto unlock;
108 }
109
110 status = acpi_ns_parse_table(table_index, node->child);
111 if (ACPI_SUCCESS(status)) {
112 acpi_tb_set_table_loaded_flag(table_index, TRUE);
113 } else {
114 acpi_tb_release_owner_id(table_index);
126 } 115 }
127 116
128 status = acpi_ns_parse_table(table_desc, node->child); 117 unlock:
129 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 118 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
130 119
131 if (ACPI_FAILURE(status)) { 120 if (ACPI_FAILURE(status)) {
@@ -141,7 +130,7 @@ acpi_ns_load_table(struct acpi_table_desc *table_desc,
141 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 130 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
142 "**** Begin Table Method Parsing and Object Initialization ****\n")); 131 "**** Begin Table Method Parsing and Object Initialization ****\n"));
143 132
144 status = acpi_ds_initialize_objects(table_desc, node); 133 status = acpi_ds_initialize_objects(table_index, node);
145 134
146 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 135 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
147 "**** Completed Table Method Parsing and Object Initialization ****\n")); 136 "**** Completed Table Method Parsing and Object Initialization ****\n"));
@@ -149,99 +138,7 @@ acpi_ns_load_table(struct acpi_table_desc *table_desc,
149 return_ACPI_STATUS(status); 138 return_ACPI_STATUS(status);
150} 139}
151 140
152/******************************************************************************* 141#ifdef ACPI_OBSOLETE_FUNCTIONS
153 *
154 * FUNCTION: acpi_ns_load_table_by_type
155 *
156 * PARAMETERS: table_type - Id of the table type to load
157 *
158 * RETURN: Status
159 *
160 * DESCRIPTION: Load an ACPI table or tables into the namespace. All tables
161 * of the given type are loaded. The mechanism allows this
162 * routine to be called repeatedly.
163 *
164 ******************************************************************************/
165
166static acpi_status acpi_ns_load_table_by_type(acpi_table_type table_type)
167{
168 u32 i;
169 acpi_status status;
170 struct acpi_table_desc *table_desc;
171
172 ACPI_FUNCTION_TRACE(ns_load_table_by_type);
173
174 status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
175 if (ACPI_FAILURE(status)) {
176 return_ACPI_STATUS(status);
177 }
178
179 /*
180 * Table types supported are:
181 * DSDT (one), SSDT/PSDT (multiple)
182 */
183 switch (table_type) {
184 case ACPI_TABLE_ID_DSDT:
185
186 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Namespace load: DSDT\n"));
187
188 table_desc = acpi_gbl_table_lists[ACPI_TABLE_ID_DSDT].next;
189
190 /* If table already loaded into namespace, just return */
191
192 if (table_desc->loaded_into_namespace) {
193 goto unlock_and_exit;
194 }
195
196 /* Now load the single DSDT */
197
198 status = acpi_ns_load_table(table_desc, acpi_gbl_root_node);
199 if (ACPI_SUCCESS(status)) {
200 table_desc->loaded_into_namespace = TRUE;
201 }
202 break;
203
204 case ACPI_TABLE_ID_SSDT:
205 case ACPI_TABLE_ID_PSDT:
206
207 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
208 "Namespace load: %d SSDT or PSDTs\n",
209 acpi_gbl_table_lists[table_type].count));
210
211 /*
212 * Traverse list of SSDT or PSDT tables
213 */
214 table_desc = acpi_gbl_table_lists[table_type].next;
215 for (i = 0; i < acpi_gbl_table_lists[table_type].count; i++) {
216 /*
217 * Only attempt to load table into namespace if it is not
218 * already loaded!
219 */
220 if (!table_desc->loaded_into_namespace) {
221 status =
222 acpi_ns_load_table(table_desc,
223 acpi_gbl_root_node);
224 if (ACPI_FAILURE(status)) {
225 break;
226 }
227
228 table_desc->loaded_into_namespace = TRUE;
229 }
230
231 table_desc = table_desc->next;
232 }
233 break;
234
235 default:
236 status = AE_SUPPORT;
237 break;
238 }
239
240 unlock_and_exit:
241 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
242 return_ACPI_STATUS(status);
243}
244
245/******************************************************************************* 142/*******************************************************************************
246 * 143 *
247 * FUNCTION: acpi_load_namespace 144 * FUNCTION: acpi_load_namespace
@@ -288,6 +185,7 @@ acpi_status acpi_ns_load_namespace(void)
288 185
289 return_ACPI_STATUS(status); 186 return_ACPI_STATUS(status);
290} 187}
188#endif
291 189
292#ifdef ACPI_FUTURE_IMPLEMENTATION 190#ifdef ACPI_FUTURE_IMPLEMENTATION
293/******************************************************************************* 191/*******************************************************************************
diff --git a/drivers/acpi/namespace/nsnames.c b/drivers/acpi/namespace/nsnames.c
index 97b8332c9746..cbd94af08cc5 100644
--- a/drivers/acpi/namespace/nsnames.c
+++ b/drivers/acpi/namespace/nsnames.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2006, R. Byron Moore 8 * Copyright (C) 2000 - 2007, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/namespace/nsobject.c b/drivers/acpi/namespace/nsobject.c
index aabe8794b908..d9d7377bc6e6 100644
--- a/drivers/acpi/namespace/nsobject.c
+++ b/drivers/acpi/namespace/nsobject.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2006, R. Byron Moore 9 * Copyright (C) 2000 - 2007, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/namespace/nsparse.c b/drivers/acpi/namespace/nsparse.c
index 155505a4ef69..e696aa847990 100644
--- a/drivers/acpi/namespace/nsparse.c
+++ b/drivers/acpi/namespace/nsparse.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2006, R. Byron Moore 8 * Copyright (C) 2000 - 2007, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -45,6 +45,7 @@
45#include <acpi/acnamesp.h> 45#include <acpi/acnamesp.h>
46#include <acpi/acparser.h> 46#include <acpi/acparser.h>
47#include <acpi/acdispat.h> 47#include <acpi/acdispat.h>
48#include <acpi/actables.h>
48 49
49#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
50ACPI_MODULE_NAME("nsparse") 51ACPI_MODULE_NAME("nsparse")
@@ -62,14 +63,24 @@ ACPI_MODULE_NAME("nsparse")
62 * 63 *
63 ******************************************************************************/ 64 ******************************************************************************/
64acpi_status 65acpi_status
65acpi_ns_one_complete_parse(u8 pass_number, struct acpi_table_desc *table_desc) 66acpi_ns_one_complete_parse(acpi_native_uint pass_number,
67 acpi_native_uint table_index)
66{ 68{
67 union acpi_parse_object *parse_root; 69 union acpi_parse_object *parse_root;
68 acpi_status status; 70 acpi_status status;
71 acpi_native_uint aml_length;
72 u8 *aml_start;
69 struct acpi_walk_state *walk_state; 73 struct acpi_walk_state *walk_state;
74 struct acpi_table_header *table;
75 acpi_owner_id owner_id;
70 76
71 ACPI_FUNCTION_TRACE(ns_one_complete_parse); 77 ACPI_FUNCTION_TRACE(ns_one_complete_parse);
72 78
79 status = acpi_tb_get_owner_id(table_index, &owner_id);
80 if (ACPI_FAILURE(status)) {
81 return_ACPI_STATUS(status);
82 }
83
73 /* Create and init a Root Node */ 84 /* Create and init a Root Node */
74 85
75 parse_root = acpi_ps_create_scope_op(); 86 parse_root = acpi_ps_create_scope_op();
@@ -79,26 +90,41 @@ acpi_ns_one_complete_parse(u8 pass_number, struct acpi_table_desc *table_desc)
79 90
80 /* Create and initialize a new walk state */ 91 /* Create and initialize a new walk state */
81 92
82 walk_state = acpi_ds_create_walk_state(table_desc->owner_id, 93 walk_state = acpi_ds_create_walk_state(owner_id, NULL, NULL, NULL);
83 NULL, NULL, NULL);
84 if (!walk_state) { 94 if (!walk_state) {
85 acpi_ps_free_op(parse_root); 95 acpi_ps_free_op(parse_root);
86 return_ACPI_STATUS(AE_NO_MEMORY); 96 return_ACPI_STATUS(AE_NO_MEMORY);
87 } 97 }
88 98
89 status = acpi_ds_init_aml_walk(walk_state, parse_root, NULL, 99 status = acpi_get_table_by_index(table_index, &table);
90 table_desc->aml_start, 100 if (ACPI_FAILURE(status)) {
91 table_desc->aml_length, NULL, 101 acpi_ds_delete_walk_state(walk_state);
92 pass_number); 102 acpi_ps_free_op(parse_root);
103 return_ACPI_STATUS(status);
104 }
105
106 /* Table must consist of at least a complete header */
107
108 if (table->length < sizeof(struct acpi_table_header)) {
109 status = AE_BAD_HEADER;
110 } else {
111 aml_start = (u8 *) table + sizeof(struct acpi_table_header);
112 aml_length = table->length - sizeof(struct acpi_table_header);
113 status = acpi_ds_init_aml_walk(walk_state, parse_root, NULL,
114 aml_start, aml_length, NULL,
115 (u8) pass_number);
116 }
117
93 if (ACPI_FAILURE(status)) { 118 if (ACPI_FAILURE(status)) {
94 acpi_ds_delete_walk_state(walk_state); 119 acpi_ds_delete_walk_state(walk_state);
120 acpi_ps_delete_parse_tree(parse_root);
95 return_ACPI_STATUS(status); 121 return_ACPI_STATUS(status);
96 } 122 }
97 123
98 /* Parse the AML */ 124 /* Parse the AML */
99 125
100 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "*PARSE* pass %d parse\n", 126 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "*PARSE* pass %d parse\n",
101 pass_number)); 127 (unsigned)pass_number));
102 status = acpi_ps_parse_aml(walk_state); 128 status = acpi_ps_parse_aml(walk_state);
103 129
104 acpi_ps_delete_parse_tree(parse_root); 130 acpi_ps_delete_parse_tree(parse_root);
@@ -119,7 +145,7 @@ acpi_ns_one_complete_parse(u8 pass_number, struct acpi_table_desc *table_desc)
119 ******************************************************************************/ 145 ******************************************************************************/
120 146
121acpi_status 147acpi_status
122acpi_ns_parse_table(struct acpi_table_desc *table_desc, 148acpi_ns_parse_table(acpi_native_uint table_index,
123 struct acpi_namespace_node *start_node) 149 struct acpi_namespace_node *start_node)
124{ 150{
125 acpi_status status; 151 acpi_status status;
@@ -134,10 +160,10 @@ acpi_ns_parse_table(struct acpi_table_desc *table_desc,
134 * each Parser Op subtree is deleted when it is finished. This saves 160 * each Parser Op subtree is deleted when it is finished. This saves
135 * a great deal of memory, and allows a small cache of parse objects 161 * a great deal of memory, and allows a small cache of parse objects
136 * to service the entire parse. The second pass of the parse then 162 * to service the entire parse. The second pass of the parse then
137 * performs another complete parse of the AML.. 163 * performs another complete parse of the AML.
138 */ 164 */
139 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "**** Start pass 1\n")); 165 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "**** Start pass 1\n"));
140 status = acpi_ns_one_complete_parse(1, table_desc); 166 status = acpi_ns_one_complete_parse(ACPI_IMODE_LOAD_PASS1, table_index);
141 if (ACPI_FAILURE(status)) { 167 if (ACPI_FAILURE(status)) {
142 return_ACPI_STATUS(status); 168 return_ACPI_STATUS(status);
143 } 169 }
@@ -152,7 +178,7 @@ acpi_ns_parse_table(struct acpi_table_desc *table_desc,
152 * parse objects are all cached. 178 * parse objects are all cached.
153 */ 179 */
154 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "**** Start pass 2\n")); 180 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "**** Start pass 2\n"));
155 status = acpi_ns_one_complete_parse(2, table_desc); 181 status = acpi_ns_one_complete_parse(ACPI_IMODE_LOAD_PASS2, table_index);
156 if (ACPI_FAILURE(status)) { 182 if (ACPI_FAILURE(status)) {
157 return_ACPI_STATUS(status); 183 return_ACPI_STATUS(status);
158 } 184 }
diff --git a/drivers/acpi/namespace/nssearch.c b/drivers/acpi/namespace/nssearch.c
index 500e2bbcfaf7..e863be665ce8 100644
--- a/drivers/acpi/namespace/nssearch.c
+++ b/drivers/acpi/namespace/nssearch.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2006, R. Byron Moore 8 * Copyright (C) 2000 - 2007, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -321,7 +321,8 @@ acpi_ns_search_and_enter(u32 target_name,
321 * even though there are a few bad names. 321 * even though there are a few bad names.
322 */ 322 */
323 if (!acpi_ut_valid_acpi_name(target_name)) { 323 if (!acpi_ut_valid_acpi_name(target_name)) {
324 target_name = acpi_ut_repair_name(target_name); 324 target_name =
325 acpi_ut_repair_name(ACPI_CAST_PTR(char, &target_name));
325 326
326 /* Report warning only if in strict mode or debug mode */ 327 /* Report warning only if in strict mode or debug mode */
327 328
@@ -401,6 +402,10 @@ acpi_ns_search_and_enter(u32 target_name,
401 } 402 }
402#endif 403#endif
403 404
405 if (flags & ACPI_NS_TEMPORARY) {
406 new_node->flags |= ANOBJ_TEMPORARY;
407 }
408
404 /* Install the new object into the parent's list of children */ 409 /* Install the new object into the parent's list of children */
405 410
406 acpi_ns_install_node(walk_state, node, new_node, type); 411 acpi_ns_install_node(walk_state, node, new_node, type);
diff --git a/drivers/acpi/namespace/nsutils.c b/drivers/acpi/namespace/nsutils.c
index aa4e799d9a8c..90fd059615ff 100644
--- a/drivers/acpi/namespace/nsutils.c
+++ b/drivers/acpi/namespace/nsutils.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2006, R. Byron Moore 9 * Copyright (C) 2000 - 2007, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -770,13 +770,6 @@ void acpi_ns_terminate(void)
770 } 770 }
771 771
772 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Namespace freed\n")); 772 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Namespace freed\n"));
773
774 /*
775 * 2) Now we can delete the ACPI tables
776 */
777 acpi_tb_delete_all_tables();
778 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n"));
779
780 return_VOID; 773 return_VOID;
781} 774}
782 775
diff --git a/drivers/acpi/namespace/nswalk.c b/drivers/acpi/namespace/nswalk.c
index c8f6bef16ed0..94eb8f332d94 100644
--- a/drivers/acpi/namespace/nswalk.c
+++ b/drivers/acpi/namespace/nswalk.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2006, R. Byron Moore 8 * Copyright (C) 2000 - 2007, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -126,7 +126,7 @@ struct acpi_namespace_node *acpi_ns_get_next_node(acpi_object_type type,
126 * PARAMETERS: Type - acpi_object_type to search for 126 * PARAMETERS: Type - acpi_object_type to search for
127 * start_node - Handle in namespace where search begins 127 * start_node - Handle in namespace where search begins
128 * max_depth - Depth to which search is to reach 128 * max_depth - Depth to which search is to reach
129 * unlock_before_callback- Whether to unlock the NS before invoking 129 * Flags - Whether to unlock the NS before invoking
130 * the callback routine 130 * the callback routine
131 * user_function - Called when an object of "Type" is found 131 * user_function - Called when an object of "Type" is found
132 * Context - Passed to user function 132 * Context - Passed to user function
@@ -153,7 +153,7 @@ acpi_status
153acpi_ns_walk_namespace(acpi_object_type type, 153acpi_ns_walk_namespace(acpi_object_type type,
154 acpi_handle start_node, 154 acpi_handle start_node,
155 u32 max_depth, 155 u32 max_depth,
156 u8 unlock_before_callback, 156 u32 flags,
157 acpi_walk_callback user_function, 157 acpi_walk_callback user_function,
158 void *context, void **return_value) 158 void *context, void **return_value)
159{ 159{
@@ -193,20 +193,34 @@ acpi_ns_walk_namespace(acpi_object_type type,
193 acpi_ns_get_next_node(ACPI_TYPE_ANY, parent_node, 193 acpi_ns_get_next_node(ACPI_TYPE_ANY, parent_node,
194 child_node); 194 child_node);
195 if (child_node) { 195 if (child_node) {
196 /* 196
197 * Found node, Get the type if we are not 197 /* Found next child, get the type if we are not searching for ANY */
198 * searching for ANY 198
199 */
200 if (type != ACPI_TYPE_ANY) { 199 if (type != ACPI_TYPE_ANY) {
201 child_type = child_node->type; 200 child_type = child_node->type;
202 } 201 }
203 202
204 if (child_type == type) { 203 /*
204 * Ignore all temporary namespace nodes (created during control
205 * method execution) unless told otherwise. These temporary nodes
206 * can cause a race condition because they can be deleted during the
207 * execution of the user function (if the namespace is unlocked before
208 * invocation of the user function.) Only the debugger namespace dump
209 * will examine the temporary nodes.
210 */
211 if ((child_node->flags & ANOBJ_TEMPORARY) &&
212 !(flags & ACPI_NS_WALK_TEMP_NODES)) {
213 status = AE_CTRL_DEPTH;
214 }
215
216 /* Type must match requested type */
217
218 else if (child_type == type) {
205 /* 219 /*
206 * Found a matching node, invoke the user 220 * Found a matching node, invoke the user callback function.
207 * callback function 221 * Unlock the namespace if flag is set.
208 */ 222 */
209 if (unlock_before_callback) { 223 if (flags & ACPI_NS_WALK_UNLOCK) {
210 mutex_status = 224 mutex_status =
211 acpi_ut_release_mutex 225 acpi_ut_release_mutex
212 (ACPI_MTX_NAMESPACE); 226 (ACPI_MTX_NAMESPACE);
@@ -216,10 +230,11 @@ acpi_ns_walk_namespace(acpi_object_type type,
216 } 230 }
217 } 231 }
218 232
219 status = user_function(child_node, level, 233 status =
220 context, return_value); 234 user_function(child_node, level, context,
235 return_value);
221 236
222 if (unlock_before_callback) { 237 if (flags & ACPI_NS_WALK_UNLOCK) {
223 mutex_status = 238 mutex_status =
224 acpi_ut_acquire_mutex 239 acpi_ut_acquire_mutex
225 (ACPI_MTX_NAMESPACE); 240 (ACPI_MTX_NAMESPACE);
@@ -251,20 +266,17 @@ acpi_ns_walk_namespace(acpi_object_type type,
251 } 266 }
252 267
253 /* 268 /*
254 * Depth first search: 269 * Depth first search: Attempt to go down another level in the
255 * Attempt to go down another level in the namespace 270 * namespace if we are allowed to. Don't go any further if we have
256 * if we are allowed to. Don't go any further if we 271 * reached the caller specified maximum depth or if the user
257 * have reached the caller specified maximum depth 272 * function has specified that the maximum depth has been reached.
258 * or if the user function has specified that the
259 * maximum depth has been reached.
260 */ 273 */
261 if ((level < max_depth) && (status != AE_CTRL_DEPTH)) { 274 if ((level < max_depth) && (status != AE_CTRL_DEPTH)) {
262 if (acpi_ns_get_next_node 275 if (acpi_ns_get_next_node
263 (ACPI_TYPE_ANY, child_node, NULL)) { 276 (ACPI_TYPE_ANY, child_node, NULL)) {
264 /* 277
265 * There is at least one child of this 278 /* There is at least one child of this node, visit it */
266 * node, visit the onde 279
267 */
268 level++; 280 level++;
269 parent_node = child_node; 281 parent_node = child_node;
270 child_node = NULL; 282 child_node = NULL;
@@ -272,9 +284,8 @@ acpi_ns_walk_namespace(acpi_object_type type,
272 } 284 }
273 } else { 285 } else {
274 /* 286 /*
275 * No more children of this node (acpi_ns_get_next_node 287 * No more children of this node (acpi_ns_get_next_node failed), go
276 * failed), go back upwards in the namespace tree to 288 * back upwards in the namespace tree to the node's parent.
277 * the node's parent.
278 */ 289 */
279 level--; 290 level--;
280 child_node = parent_node; 291 child_node = parent_node;
diff --git a/drivers/acpi/namespace/nsxfeval.c b/drivers/acpi/namespace/nsxfeval.c
index dca6799ac678..7ac6ace50059 100644
--- a/drivers/acpi/namespace/nsxfeval.c
+++ b/drivers/acpi/namespace/nsxfeval.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2006, R. Byron Moore 9 * Copyright (C) 2000 - 2007, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -170,7 +170,6 @@ acpi_evaluate_object(acpi_handle handle,
170 struct acpi_buffer *return_buffer) 170 struct acpi_buffer *return_buffer)
171{ 171{
172 acpi_status status; 172 acpi_status status;
173 acpi_status status2;
174 struct acpi_evaluate_info *info; 173 struct acpi_evaluate_info *info;
175 acpi_size buffer_space_needed; 174 acpi_size buffer_space_needed;
176 u32 i; 175 u32 i;
@@ -329,14 +328,12 @@ acpi_evaluate_object(acpi_handle handle,
329 * Delete the internal return object. NOTE: Interpreter must be 328 * Delete the internal return object. NOTE: Interpreter must be
330 * locked to avoid race condition. 329 * locked to avoid race condition.
331 */ 330 */
332 status2 = acpi_ex_enter_interpreter(); 331 acpi_ex_enter_interpreter();
333 if (ACPI_SUCCESS(status2)) {
334 332
335 /* Remove one reference on the return object (should delete it) */ 333 /* Remove one reference on the return object (should delete it) */
336 334
337 acpi_ut_remove_reference(info->return_object); 335 acpi_ut_remove_reference(info->return_object);
338 acpi_ex_exit_interpreter(); 336 acpi_ex_exit_interpreter();
339 }
340 } 337 }
341 338
342 cleanup: 339 cleanup:
diff --git a/drivers/acpi/namespace/nsxfname.c b/drivers/acpi/namespace/nsxfname.c
index 978213a6c19f..b489781b22a8 100644
--- a/drivers/acpi/namespace/nsxfname.c
+++ b/drivers/acpi/namespace/nsxfname.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2006, R. Byron Moore 9 * Copyright (C) 2000 - 2007, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -84,38 +84,41 @@ acpi_get_handle(acpi_handle parent,
84 /* Convert a parent handle to a prefix node */ 84 /* Convert a parent handle to a prefix node */
85 85
86 if (parent) { 86 if (parent) {
87 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
88 if (ACPI_FAILURE(status)) {
89 return (status);
90 }
91
92 prefix_node = acpi_ns_map_handle_to_node(parent); 87 prefix_node = acpi_ns_map_handle_to_node(parent);
93 if (!prefix_node) { 88 if (!prefix_node) {
94 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
95 return (AE_BAD_PARAMETER); 89 return (AE_BAD_PARAMETER);
96 } 90 }
91 }
92
93 /*
94 * Valid cases are:
95 * 1) Fully qualified pathname
96 * 2) Parent + Relative pathname
97 *
98 * Error for <null Parent + relative path>
99 */
100 if (acpi_ns_valid_root_prefix(pathname[0])) {
97 101
98 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 102 /* Pathname is fully qualified (starts with '\') */
99 if (ACPI_FAILURE(status)) { 103
100 return (status); 104 /* Special case for root-only, since we can't search for it */
105
106 if (!ACPI_STRCMP(pathname, ACPI_NS_ROOT_PATH)) {
107 *ret_handle =
108 acpi_ns_convert_entry_to_handle(acpi_gbl_root_node);
109 return (AE_OK);
101 } 110 }
102 } 111 } else if (!prefix_node) {
103 112
104 /* Special case for root, since we can't search for it */ 113 /* Relative path with null prefix is disallowed */
105 114
106 if (ACPI_STRCMP(pathname, ACPI_NS_ROOT_PATH) == 0) { 115 return (AE_BAD_PARAMETER);
107 *ret_handle =
108 acpi_ns_convert_entry_to_handle(acpi_gbl_root_node);
109 return (AE_OK);
110 } 116 }
111 117
112 /* 118 /* Find the Node and convert to a handle */
113 * Find the Node and convert to a handle
114 */
115 status = acpi_ns_get_node(prefix_node, pathname, ACPI_NS_NO_UPSEARCH,
116 &node);
117 119
118 *ret_handle = NULL; 120 status =
121 acpi_ns_get_node(prefix_node, pathname, ACPI_NS_NO_UPSEARCH, &node);
119 if (ACPI_SUCCESS(status)) { 122 if (ACPI_SUCCESS(status)) {
120 *ret_handle = acpi_ns_convert_entry_to_handle(node); 123 *ret_handle = acpi_ns_convert_entry_to_handle(node);
121 } 124 }
diff --git a/drivers/acpi/namespace/nsxfobj.c b/drivers/acpi/namespace/nsxfobj.c
index a18b1c223129..faa375887201 100644
--- a/drivers/acpi/namespace/nsxfobj.c
+++ b/drivers/acpi/namespace/nsxfobj.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2006, R. Byron Moore 9 * Copyright (C) 2000 - 2007, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without