aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/utilities
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2009-01-09 00:13:17 -0500
committerLen Brown <len.brown@intel.com>2009-01-09 03:30:47 -0500
commit95b482a8d31116f3f5c2a5089569393234d06385 (patch)
treef32aec8673a285a9d188948be97af3034ee06e93 /drivers/acpi/utilities
parent6620e0c49f577454b772fb381543d60ae53eb885 (diff)
ACPICA: create acpica/ directory
also, delete sleep/ and delete ACPI_CFLAGS from Makefile Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/utilities')
-rw-r--r--drivers/acpi/utilities/Makefile9
-rw-r--r--drivers/acpi/utilities/utalloc.c383
-rw-r--r--drivers/acpi/utilities/utcopy.c970
-rw-r--r--drivers/acpi/utilities/utdebug.c651
-rw-r--r--drivers/acpi/utilities/utdelete.c677
-rw-r--r--drivers/acpi/utilities/uteval.c752
-rw-r--r--drivers/acpi/utilities/utglobal.c823
-rw-r--r--drivers/acpi/utilities/utinit.c152
-rw-r--r--drivers/acpi/utilities/utmath.c312
-rw-r--r--drivers/acpi/utilities/utmisc.c1093
-rw-r--r--drivers/acpi/utilities/utmutex.c342
-rw-r--r--drivers/acpi/utilities/utobject.c677
-rw-r--r--drivers/acpi/utilities/utresrc.c616
-rw-r--r--drivers/acpi/utilities/utstate.c347
-rw-r--r--drivers/acpi/utilities/utxface.c512
15 files changed, 0 insertions, 8316 deletions
diff --git a/drivers/acpi/utilities/Makefile b/drivers/acpi/utilities/Makefile
deleted file mode 100644
index 66a71a54cb0d..000000000000
--- a/drivers/acpi/utilities/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
1#
2# Makefile for all Linux ACPI interpreter subdirectories
3#
4
5obj-y := utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \
6 utcopy.o utdelete.o utglobal.o utmath.o utobject.o \
7 utstate.o utmutex.o utobject.o utresrc.o
8
9EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c
deleted file mode 100644
index 2a017b29aa41..000000000000
--- a/drivers/acpi/utilities/utalloc.c
+++ /dev/null
@@ -1,383 +0,0 @@
1/******************************************************************************
2 *
3 * Module Name: utalloc - local memory allocation routines
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include <acpi/accommon.h>
46#include <acpi/acdebug.h>
47
48#define _COMPONENT ACPI_UTILITIES
49ACPI_MODULE_NAME("utalloc")
50
51/*******************************************************************************
52 *
53 * FUNCTION: acpi_ut_create_caches
54 *
55 * PARAMETERS: None
56 *
57 * RETURN: Status
58 *
59 * DESCRIPTION: Create all local caches
60 *
61 ******************************************************************************/
62acpi_status acpi_ut_create_caches(void)
63{
64 acpi_status status;
65
66 /* Object Caches, for frequently used objects */
67
68 status =
69 acpi_os_create_cache("Acpi-Namespace",
70 sizeof(struct acpi_namespace_node),
71 ACPI_MAX_NAMESPACE_CACHE_DEPTH,
72 &acpi_gbl_namespace_cache);
73 if (ACPI_FAILURE(status)) {
74 return (status);
75 }
76
77 status =
78 acpi_os_create_cache("Acpi-State", sizeof(union acpi_generic_state),
79 ACPI_MAX_STATE_CACHE_DEPTH,
80 &acpi_gbl_state_cache);
81 if (ACPI_FAILURE(status)) {
82 return (status);
83 }
84
85 status =
86 acpi_os_create_cache("Acpi-Parse",
87 sizeof(struct acpi_parse_obj_common),
88 ACPI_MAX_PARSE_CACHE_DEPTH,
89 &acpi_gbl_ps_node_cache);
90 if (ACPI_FAILURE(status)) {
91 return (status);
92 }
93
94 status =
95 acpi_os_create_cache("Acpi-ParseExt",
96 sizeof(struct acpi_parse_obj_named),
97 ACPI_MAX_EXTPARSE_CACHE_DEPTH,
98 &acpi_gbl_ps_node_ext_cache);
99 if (ACPI_FAILURE(status)) {
100 return (status);
101 }
102
103 status =
104 acpi_os_create_cache("Acpi-Operand",
105 sizeof(union acpi_operand_object),
106 ACPI_MAX_OBJECT_CACHE_DEPTH,
107 &acpi_gbl_operand_cache);
108 if (ACPI_FAILURE(status)) {
109 return (status);
110 }
111#ifdef ACPI_DBG_TRACK_ALLOCATIONS
112
113 /* Memory allocation lists */
114
115 status = acpi_ut_create_list("Acpi-Global", 0, &acpi_gbl_global_list);
116 if (ACPI_FAILURE(status)) {
117 return (status);
118 }
119
120 status =
121 acpi_ut_create_list("Acpi-Namespace",
122 sizeof(struct acpi_namespace_node),
123 &acpi_gbl_ns_node_list);
124 if (ACPI_FAILURE(status)) {
125 return (status);
126 }
127#endif
128
129 return (AE_OK);
130}
131
132/*******************************************************************************
133 *
134 * FUNCTION: acpi_ut_delete_caches
135 *
136 * PARAMETERS: None
137 *
138 * RETURN: Status
139 *
140 * DESCRIPTION: Purge and delete all local caches
141 *
142 ******************************************************************************/
143
144acpi_status acpi_ut_delete_caches(void)
145{
146#ifdef ACPI_DBG_TRACK_ALLOCATIONS
147 char buffer[7];
148
149 if (acpi_gbl_display_final_mem_stats) {
150 ACPI_STRCPY(buffer, "MEMORY");
151 (void)acpi_db_display_statistics(buffer);
152 }
153#endif
154
155 (void)acpi_os_delete_cache(acpi_gbl_namespace_cache);
156 acpi_gbl_namespace_cache = NULL;
157
158 (void)acpi_os_delete_cache(acpi_gbl_state_cache);
159 acpi_gbl_state_cache = NULL;
160
161 (void)acpi_os_delete_cache(acpi_gbl_operand_cache);
162 acpi_gbl_operand_cache = NULL;
163
164 (void)acpi_os_delete_cache(acpi_gbl_ps_node_cache);
165 acpi_gbl_ps_node_cache = NULL;
166
167 (void)acpi_os_delete_cache(acpi_gbl_ps_node_ext_cache);
168 acpi_gbl_ps_node_ext_cache = NULL;
169
170#ifdef ACPI_DBG_TRACK_ALLOCATIONS
171
172 /* Debug only - display leftover memory allocation, if any */
173
174 acpi_ut_dump_allocations(ACPI_UINT32_MAX, NULL);
175
176 /* Free memory lists */
177
178 ACPI_FREE(acpi_gbl_global_list);
179 acpi_gbl_global_list = NULL;
180
181 ACPI_FREE(acpi_gbl_ns_node_list);
182 acpi_gbl_ns_node_list = NULL;
183#endif
184
185 return (AE_OK);
186}
187
188/*******************************************************************************
189 *
190 * FUNCTION: acpi_ut_validate_buffer
191 *
192 * PARAMETERS: Buffer - Buffer descriptor to be validated
193 *
194 * RETURN: Status
195 *
196 * DESCRIPTION: Perform parameter validation checks on an struct acpi_buffer
197 *
198 ******************************************************************************/
199
200acpi_status acpi_ut_validate_buffer(struct acpi_buffer * buffer)
201{
202
203 /* Obviously, the structure pointer must be valid */
204
205 if (!buffer) {
206 return (AE_BAD_PARAMETER);
207 }
208
209 /* Special semantics for the length */
210
211 if ((buffer->length == ACPI_NO_BUFFER) ||
212 (buffer->length == ACPI_ALLOCATE_BUFFER) ||
213 (buffer->length == ACPI_ALLOCATE_LOCAL_BUFFER)) {
214 return (AE_OK);
215 }
216
217 /* Length is valid, the buffer pointer must be also */
218
219 if (!buffer->pointer) {
220 return (AE_BAD_PARAMETER);
221 }
222
223 return (AE_OK);
224}
225
226/*******************************************************************************
227 *
228 * FUNCTION: acpi_ut_initialize_buffer
229 *
230 * PARAMETERS: Buffer - Buffer to be validated
231 * required_length - Length needed
232 *
233 * RETURN: Status
234 *
235 * DESCRIPTION: Validate that the buffer is of the required length or
236 * allocate a new buffer. Returned buffer is always zeroed.
237 *
238 ******************************************************************************/
239
240acpi_status
241acpi_ut_initialize_buffer(struct acpi_buffer * buffer,
242 acpi_size required_length)
243{
244 acpi_size input_buffer_length;
245
246 /* Parameter validation */
247
248 if (!buffer || !required_length) {
249 return (AE_BAD_PARAMETER);
250 }
251
252 /*
253 * Buffer->Length is used as both an input and output parameter. Get the
254 * input actual length and set the output required buffer length.
255 */
256 input_buffer_length = buffer->length;
257 buffer->length = required_length;
258
259 /*
260 * The input buffer length contains the actual buffer length, or the type
261 * of buffer to be allocated by this routine.
262 */
263 switch (input_buffer_length) {
264 case ACPI_NO_BUFFER:
265
266 /* Return the exception (and the required buffer length) */
267
268 return (AE_BUFFER_OVERFLOW);
269
270 case ACPI_ALLOCATE_BUFFER:
271
272 /* Allocate a new buffer */
273
274 buffer->pointer = acpi_os_allocate(required_length);
275 break;
276
277 case ACPI_ALLOCATE_LOCAL_BUFFER:
278
279 /* Allocate a new buffer with local interface to allow tracking */
280
281 buffer->pointer = ACPI_ALLOCATE(required_length);
282 break;
283
284 default:
285
286 /* Existing buffer: Validate the size of the buffer */
287
288 if (input_buffer_length < required_length) {
289 return (AE_BUFFER_OVERFLOW);
290 }
291 break;
292 }
293
294 /* Validate allocation from above or input buffer pointer */
295
296 if (!buffer->pointer) {
297 return (AE_NO_MEMORY);
298 }
299
300 /* Have a valid buffer, clear it */
301
302 ACPI_MEMSET(buffer->pointer, 0, required_length);
303 return (AE_OK);
304}
305
306#ifdef NOT_USED_BY_LINUX
307/*******************************************************************************
308 *
309 * FUNCTION: acpi_ut_allocate
310 *
311 * PARAMETERS: Size - Size of the allocation
312 * Component - Component type of caller
313 * Module - Source file name of caller
314 * Line - Line number of caller
315 *
316 * RETURN: Address of the allocated memory on success, NULL on failure.
317 *
318 * DESCRIPTION: Subsystem equivalent of malloc.
319 *
320 ******************************************************************************/
321
322void *acpi_ut_allocate(acpi_size size,
323 u32 component, const char *module, u32 line)
324{
325 void *allocation;
326
327 ACPI_FUNCTION_TRACE_U32(ut_allocate, size);
328
329 /* Check for an inadvertent size of zero bytes */
330
331 if (!size) {
332 ACPI_WARNING((module, line,
333 "Attempt to allocate zero bytes, allocating 1 byte"));
334 size = 1;
335 }
336
337 allocation = acpi_os_allocate(size);
338 if (!allocation) {
339
340 /* Report allocation error */
341
342 ACPI_WARNING((module, line,
343 "Could not allocate size %X", (u32) size));
344
345 return_PTR(NULL);
346 }
347
348 return_PTR(allocation);
349}
350
351/*******************************************************************************
352 *
353 * FUNCTION: acpi_ut_allocate_zeroed
354 *
355 * PARAMETERS: Size - Size of the allocation
356 * Component - Component type of caller
357 * Module - Source file name of caller
358 * Line - Line number of caller
359 *
360 * RETURN: Address of the allocated memory on success, NULL on failure.
361 *
362 * DESCRIPTION: Subsystem equivalent of calloc. Allocate and zero memory.
363 *
364 ******************************************************************************/
365
366void *acpi_ut_allocate_zeroed(acpi_size size,
367 u32 component, const char *module, u32 line)
368{
369 void *allocation;
370
371 ACPI_FUNCTION_ENTRY();
372
373 allocation = acpi_ut_allocate(size, component, module, line);
374 if (allocation) {
375
376 /* Clear the memory block */
377
378 ACPI_MEMSET(allocation, 0, size);
379 }
380
381 return (allocation);
382}
383#endif
diff --git a/drivers/acpi/utilities/utcopy.c b/drivers/acpi/utilities/utcopy.c
deleted file mode 100644
index e6f3002312e5..000000000000
--- a/drivers/acpi/utilities/utcopy.c
+++ /dev/null
@@ -1,970 +0,0 @@
1/******************************************************************************
2 *
3 * Module Name: utcopy - Internal to external object translation utilities
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include <acpi/accommon.h>
46#include <acpi/acnamesp.h>
47
48
49#define _COMPONENT ACPI_UTILITIES
50ACPI_MODULE_NAME("utcopy")
51
52/* Local prototypes */
53static acpi_status
54acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object,
55 union acpi_object *external_object,
56 u8 * data_space, acpi_size * buffer_space_used);
57
58static acpi_status
59acpi_ut_copy_ielement_to_ielement(u8 object_type,
60 union acpi_operand_object *source_object,
61 union acpi_generic_state *state,
62 void *context);
63
64static acpi_status
65acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object *internal_object,
66 u8 * buffer, acpi_size * space_used);
67
68static acpi_status
69acpi_ut_copy_esimple_to_isimple(union acpi_object *user_obj,
70 union acpi_operand_object **return_obj);
71
72static acpi_status
73acpi_ut_copy_epackage_to_ipackage(union acpi_object *external_object,
74 union acpi_operand_object **internal_object);
75
76static acpi_status
77acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
78 union acpi_operand_object *dest_desc);
79
80static acpi_status
81acpi_ut_copy_ielement_to_eelement(u8 object_type,
82 union acpi_operand_object *source_object,
83 union acpi_generic_state *state,
84 void *context);
85
86static acpi_status
87acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj,
88 union acpi_operand_object *dest_obj,
89 struct acpi_walk_state *walk_state);
90
91/*******************************************************************************
92 *
93 * FUNCTION: acpi_ut_copy_isimple_to_esimple
94 *
95 * PARAMETERS: internal_object - Source object to be copied
96 * external_object - Where to return the copied object
97 * data_space - Where object data is returned (such as
98 * buffer and string data)
99 * buffer_space_used - Length of data_space that was used
100 *
101 * RETURN: Status
102 *
103 * DESCRIPTION: This function is called to copy a simple internal object to
104 * an external object.
105 *
106 * The data_space buffer is assumed to have sufficient space for
107 * the object.
108 *
109 ******************************************************************************/
110
111static acpi_status
112acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object,
113 union acpi_object *external_object,
114 u8 * data_space, acpi_size * buffer_space_used)
115{
116 acpi_status status = AE_OK;
117
118 ACPI_FUNCTION_TRACE(ut_copy_isimple_to_esimple);
119
120 *buffer_space_used = 0;
121
122 /*
123 * Check for NULL object case (could be an uninitialized
124 * package element)
125 */
126 if (!internal_object) {
127 return_ACPI_STATUS(AE_OK);
128 }
129
130 /* Always clear the external object */
131
132 ACPI_MEMSET(external_object, 0, sizeof(union acpi_object));
133
134 /*
135 * In general, the external object will be the same type as
136 * the internal object
137 */
138 external_object->type = ACPI_GET_OBJECT_TYPE(internal_object);
139
140 /* However, only a limited number of external types are supported */
141
142 switch (ACPI_GET_OBJECT_TYPE(internal_object)) {
143 case ACPI_TYPE_STRING:
144
145 external_object->string.pointer = (char *)data_space;
146 external_object->string.length = internal_object->string.length;
147 *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD((acpi_size)
148 internal_object->
149 string.
150 length + 1);
151
152 ACPI_MEMCPY((void *)data_space,
153 (void *)internal_object->string.pointer,
154 (acpi_size) internal_object->string.length + 1);
155 break;
156
157 case ACPI_TYPE_BUFFER:
158
159 external_object->buffer.pointer = data_space;
160 external_object->buffer.length = internal_object->buffer.length;
161 *buffer_space_used =
162 ACPI_ROUND_UP_TO_NATIVE_WORD(internal_object->string.
163 length);
164
165 ACPI_MEMCPY((void *)data_space,
166 (void *)internal_object->buffer.pointer,
167 internal_object->buffer.length);
168 break;
169
170 case ACPI_TYPE_INTEGER:
171
172 external_object->integer.value = internal_object->integer.value;
173 break;
174
175 case ACPI_TYPE_LOCAL_REFERENCE:
176
177 /* This is an object reference. */
178
179 switch (internal_object->reference.class) {
180 case ACPI_REFCLASS_NAME:
181
182 /*
183 * For namepath, return the object handle ("reference")
184 * We are referring to the namespace node
185 */
186 external_object->reference.handle =
187 internal_object->reference.node;
188 external_object->reference.actual_type =
189 acpi_ns_get_type(internal_object->reference.node);
190 break;
191
192 default:
193
194 /* All other reference types are unsupported */
195
196 return_ACPI_STATUS(AE_TYPE);
197 }
198 break;
199
200 case ACPI_TYPE_PROCESSOR:
201
202 external_object->processor.proc_id =
203 internal_object->processor.proc_id;
204 external_object->processor.pblk_address =
205 internal_object->processor.address;
206 external_object->processor.pblk_length =
207 internal_object->processor.length;
208 break;
209
210 case ACPI_TYPE_POWER:
211
212 external_object->power_resource.system_level =
213 internal_object->power_resource.system_level;
214
215 external_object->power_resource.resource_order =
216 internal_object->power_resource.resource_order;
217 break;
218
219 default:
220 /*
221 * There is no corresponding external object type
222 */
223 ACPI_ERROR((AE_INFO,
224 "Unsupported object type, cannot convert to external object: %s",
225 acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE
226 (internal_object))));
227
228 return_ACPI_STATUS(AE_SUPPORT);
229 }
230
231 return_ACPI_STATUS(status);
232}
233
234/*******************************************************************************
235 *
236 * FUNCTION: acpi_ut_copy_ielement_to_eelement
237 *
238 * PARAMETERS: acpi_pkg_callback
239 *
240 * RETURN: Status
241 *
242 * DESCRIPTION: Copy one package element to another package element
243 *
244 ******************************************************************************/
245
246static acpi_status
247acpi_ut_copy_ielement_to_eelement(u8 object_type,
248 union acpi_operand_object *source_object,
249 union acpi_generic_state *state,
250 void *context)
251{
252 acpi_status status = AE_OK;
253 struct acpi_pkg_info *info = (struct acpi_pkg_info *)context;
254 acpi_size object_space;
255 u32 this_index;
256 union acpi_object *target_object;
257
258 ACPI_FUNCTION_ENTRY();
259
260 this_index = state->pkg.index;
261 target_object = (union acpi_object *)
262 &((union acpi_object *)(state->pkg.dest_object))->package.
263 elements[this_index];
264
265 switch (object_type) {
266 case ACPI_COPY_TYPE_SIMPLE:
267
268 /*
269 * This is a simple or null object
270 */
271 status = acpi_ut_copy_isimple_to_esimple(source_object,
272 target_object,
273 info->free_space,
274 &object_space);
275 if (ACPI_FAILURE(status)) {
276 return (status);
277 }
278 break;
279
280 case ACPI_COPY_TYPE_PACKAGE:
281
282 /*
283 * Build the package object
284 */
285 target_object->type = ACPI_TYPE_PACKAGE;
286 target_object->package.count = source_object->package.count;
287 target_object->package.elements =
288 ACPI_CAST_PTR(union acpi_object, info->free_space);
289
290 /*
291 * Pass the new package object back to the package walk routine
292 */
293 state->pkg.this_target_obj = target_object;
294
295 /*
296 * Save space for the array of objects (Package elements)
297 * update the buffer length counter
298 */
299 object_space = ACPI_ROUND_UP_TO_NATIVE_WORD((acpi_size)
300 target_object->
301 package.count *
302 sizeof(union
303 acpi_object));
304 break;
305
306 default:
307 return (AE_BAD_PARAMETER);
308 }
309
310 info->free_space += object_space;
311 info->length += object_space;
312 return (status);
313}
314
315/*******************************************************************************
316 *
317 * FUNCTION: acpi_ut_copy_ipackage_to_epackage
318 *
319 * PARAMETERS: internal_object - Pointer to the object we are returning
320 * Buffer - Where the object is returned
321 * space_used - Where the object length is returned
322 *
323 * RETURN: Status
324 *
325 * DESCRIPTION: This function is called to place a package object in a user
326 * buffer. A package object by definition contains other objects.
327 *
328 * The buffer is assumed to have sufficient space for the object.
329 * The caller must have verified the buffer length needed using the
330 * acpi_ut_get_object_size function before calling this function.
331 *
332 ******************************************************************************/
333
334static acpi_status
335acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object *internal_object,
336 u8 * buffer, acpi_size * space_used)
337{
338 union acpi_object *external_object;
339 acpi_status status;
340 struct acpi_pkg_info info;
341
342 ACPI_FUNCTION_TRACE(ut_copy_ipackage_to_epackage);
343
344 /*
345 * First package at head of the buffer
346 */
347 external_object = ACPI_CAST_PTR(union acpi_object, buffer);
348
349 /*
350 * Free space begins right after the first package
351 */
352 info.length = ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object));
353 info.free_space =
354 buffer + ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object));
355 info.object_space = 0;
356 info.num_packages = 1;
357
358 external_object->type = ACPI_GET_OBJECT_TYPE(internal_object);
359 external_object->package.count = internal_object->package.count;
360 external_object->package.elements = ACPI_CAST_PTR(union acpi_object,
361 info.free_space);
362
363 /*
364 * Leave room for an array of ACPI_OBJECTS in the buffer
365 * and move the free space past it
366 */
367 info.length += (acpi_size) external_object->package.count *
368 ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object));
369 info.free_space += external_object->package.count *
370 ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object));
371
372 status = acpi_ut_walk_package_tree(internal_object, external_object,
373 acpi_ut_copy_ielement_to_eelement,
374 &info);
375
376 *space_used = info.length;
377 return_ACPI_STATUS(status);
378}
379
380/*******************************************************************************
381 *
382 * FUNCTION: acpi_ut_copy_iobject_to_eobject
383 *
384 * PARAMETERS: internal_object - The internal object to be converted
385 * buffer_ptr - Where the object is returned
386 *
387 * RETURN: Status
388 *
389 * DESCRIPTION: This function is called to build an API object to be returned to
390 * the caller.
391 *
392 ******************************************************************************/
393
394acpi_status
395acpi_ut_copy_iobject_to_eobject(union acpi_operand_object *internal_object,
396 struct acpi_buffer *ret_buffer)
397{
398 acpi_status status;
399
400 ACPI_FUNCTION_TRACE(ut_copy_iobject_to_eobject);
401
402 if (ACPI_GET_OBJECT_TYPE(internal_object) == ACPI_TYPE_PACKAGE) {
403 /*
404 * Package object: Copy all subobjects (including
405 * nested packages)
406 */
407 status = acpi_ut_copy_ipackage_to_epackage(internal_object,
408 ret_buffer->pointer,
409 &ret_buffer->length);
410 } else {
411 /*
412 * Build a simple object (no nested objects)
413 */
414 status = acpi_ut_copy_isimple_to_esimple(internal_object,
415 ACPI_CAST_PTR(union
416 acpi_object,
417 ret_buffer->
418 pointer),
419 ACPI_ADD_PTR(u8,
420 ret_buffer->
421 pointer,
422 ACPI_ROUND_UP_TO_NATIVE_WORD
423 (sizeof
424 (union
425 acpi_object))),
426 &ret_buffer->length);
427 /*
428 * build simple does not include the object size in the length
429 * so we add it in here
430 */
431 ret_buffer->length += sizeof(union acpi_object);
432 }
433
434 return_ACPI_STATUS(status);
435}
436
437/*******************************************************************************
438 *
439 * FUNCTION: acpi_ut_copy_esimple_to_isimple
440 *
441 * PARAMETERS: external_object - The external object to be converted
442 * ret_internal_object - Where the internal object is returned
443 *
444 * RETURN: Status
445 *
446 * DESCRIPTION: This function copies an external object to an internal one.
447 * NOTE: Pointers can be copied, we don't need to copy data.
448 * (The pointers have to be valid in our address space no matter
449 * what we do with them!)
450 *
451 ******************************************************************************/
452
453static acpi_status
454acpi_ut_copy_esimple_to_isimple(union acpi_object *external_object,
455 union acpi_operand_object **ret_internal_object)
456{
457 union acpi_operand_object *internal_object;
458
459 ACPI_FUNCTION_TRACE(ut_copy_esimple_to_isimple);
460
461 /*
462 * Simple types supported are: String, Buffer, Integer
463 */
464 switch (external_object->type) {
465 case ACPI_TYPE_STRING:
466 case ACPI_TYPE_BUFFER:
467 case ACPI_TYPE_INTEGER:
468 case ACPI_TYPE_LOCAL_REFERENCE:
469
470 internal_object = acpi_ut_create_internal_object((u8)
471 external_object->
472 type);
473 if (!internal_object) {
474 return_ACPI_STATUS(AE_NO_MEMORY);
475 }
476 break;
477
478 case ACPI_TYPE_ANY: /* This is the case for a NULL object */
479
480 *ret_internal_object = NULL;
481 return_ACPI_STATUS(AE_OK);
482
483 default:
484 /* All other types are not supported */
485
486 ACPI_ERROR((AE_INFO,
487 "Unsupported object type, cannot convert to internal object: %s",
488 acpi_ut_get_type_name(external_object->type)));
489
490 return_ACPI_STATUS(AE_SUPPORT);
491 }
492
493 /* Must COPY string and buffer contents */
494
495 switch (external_object->type) {
496 case ACPI_TYPE_STRING:
497
498 internal_object->string.pointer =
499 ACPI_ALLOCATE_ZEROED((acpi_size) external_object->string.
500 length + 1);
501 if (!internal_object->string.pointer) {
502 goto error_exit;
503 }
504
505 ACPI_MEMCPY(internal_object->string.pointer,
506 external_object->string.pointer,
507 external_object->string.length);
508
509 internal_object->string.length = external_object->string.length;
510 break;
511
512 case ACPI_TYPE_BUFFER:
513
514 internal_object->buffer.pointer =
515 ACPI_ALLOCATE_ZEROED(external_object->buffer.length);
516 if (!internal_object->buffer.pointer) {
517 goto error_exit;
518 }
519
520 ACPI_MEMCPY(internal_object->buffer.pointer,
521 external_object->buffer.pointer,
522 external_object->buffer.length);
523
524 internal_object->buffer.length = external_object->buffer.length;
525
526 /* Mark buffer data valid */
527
528 internal_object->buffer.flags |= AOPOBJ_DATA_VALID;
529 break;
530
531 case ACPI_TYPE_INTEGER:
532
533 internal_object->integer.value = external_object->integer.value;
534 break;
535
536 case ACPI_TYPE_LOCAL_REFERENCE:
537
538 /* TBD: should validate incoming handle */
539
540 internal_object->reference.class = ACPI_REFCLASS_NAME;
541 internal_object->reference.node =
542 external_object->reference.handle;
543 break;
544
545 default:
546 /* Other types can't get here */
547 break;
548 }
549
550 *ret_internal_object = internal_object;
551 return_ACPI_STATUS(AE_OK);
552
553 error_exit:
554 acpi_ut_remove_reference(internal_object);
555 return_ACPI_STATUS(AE_NO_MEMORY);
556}
557
558/*******************************************************************************
559 *
560 * FUNCTION: acpi_ut_copy_epackage_to_ipackage
561 *
562 * PARAMETERS: external_object - The external object to be converted
563 * internal_object - Where the internal object is returned
564 *
565 * RETURN: Status
566 *
567 * DESCRIPTION: Copy an external package object to an internal package.
568 * Handles nested packages.
569 *
570 ******************************************************************************/
571
572static acpi_status
573acpi_ut_copy_epackage_to_ipackage(union acpi_object *external_object,
574 union acpi_operand_object **internal_object)
575{
576 acpi_status status = AE_OK;
577 union acpi_operand_object *package_object;
578 union acpi_operand_object **package_elements;
579 u32 i;
580
581 ACPI_FUNCTION_TRACE(ut_copy_epackage_to_ipackage);
582
583 /* Create the package object */
584
585 package_object =
586 acpi_ut_create_package_object(external_object->package.count);
587 if (!package_object) {
588 return_ACPI_STATUS(AE_NO_MEMORY);
589 }
590
591 package_elements = package_object->package.elements;
592
593 /*
594 * Recursive implementation. Probably ok, since nested external packages
595 * as parameters should be very rare.
596 */
597 for (i = 0; i < external_object->package.count; i++) {
598 status =
599 acpi_ut_copy_eobject_to_iobject(&external_object->package.
600 elements[i],
601 &package_elements[i]);
602 if (ACPI_FAILURE(status)) {
603
604 /* Truncate package and delete it */
605
606 package_object->package.count = i;
607 package_elements[i] = NULL;
608 acpi_ut_remove_reference(package_object);
609 return_ACPI_STATUS(status);
610 }
611 }
612
613 /* Mark package data valid */
614
615 package_object->package.flags |= AOPOBJ_DATA_VALID;
616
617 *internal_object = package_object;
618 return_ACPI_STATUS(status);
619}
620
621/*******************************************************************************
622 *
623 * FUNCTION: acpi_ut_copy_eobject_to_iobject
624 *
625 * PARAMETERS: external_object - The external object to be converted
626 * internal_object - Where the internal object is returned
627 *
628 * RETURN: Status - the status of the call
629 *
630 * DESCRIPTION: Converts an external object to an internal object.
631 *
632 ******************************************************************************/
633
634acpi_status
635acpi_ut_copy_eobject_to_iobject(union acpi_object *external_object,
636 union acpi_operand_object **internal_object)
637{
638 acpi_status status;
639
640 ACPI_FUNCTION_TRACE(ut_copy_eobject_to_iobject);
641
642 if (external_object->type == ACPI_TYPE_PACKAGE) {
643 status =
644 acpi_ut_copy_epackage_to_ipackage(external_object,
645 internal_object);
646 } else {
647 /*
648 * Build a simple object (no nested objects)
649 */
650 status =
651 acpi_ut_copy_esimple_to_isimple(external_object,
652 internal_object);
653 }
654
655 return_ACPI_STATUS(status);
656}
657
658/*******************************************************************************
659 *
660 * FUNCTION: acpi_ut_copy_simple_object
661 *
662 * PARAMETERS: source_desc - The internal object to be copied
663 * dest_desc - New target object
664 *
665 * RETURN: Status
666 *
667 * DESCRIPTION: Simple copy of one internal object to another. Reference count
668 * of the destination object is preserved.
669 *
670 ******************************************************************************/
671
672static acpi_status
673acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
674 union acpi_operand_object *dest_desc)
675{
676 u16 reference_count;
677 union acpi_operand_object *next_object;
678
679 /* Save fields from destination that we don't want to overwrite */
680
681 reference_count = dest_desc->common.reference_count;
682 next_object = dest_desc->common.next_object;
683
684 /* Copy the entire source object over the destination object */
685
686 ACPI_MEMCPY((char *)dest_desc, (char *)source_desc,
687 sizeof(union acpi_operand_object));
688
689 /* Restore the saved fields */
690
691 dest_desc->common.reference_count = reference_count;
692 dest_desc->common.next_object = next_object;
693
694 /* New object is not static, regardless of source */
695
696 dest_desc->common.flags &= ~AOPOBJ_STATIC_POINTER;
697
698 /* Handle the objects with extra data */
699
700 switch (ACPI_GET_OBJECT_TYPE(dest_desc)) {
701 case ACPI_TYPE_BUFFER:
702 /*
703 * Allocate and copy the actual buffer if and only if:
704 * 1) There is a valid buffer pointer
705 * 2) The buffer has a length > 0
706 */
707 if ((source_desc->buffer.pointer) &&
708 (source_desc->buffer.length)) {
709 dest_desc->buffer.pointer =
710 ACPI_ALLOCATE(source_desc->buffer.length);
711 if (!dest_desc->buffer.pointer) {
712 return (AE_NO_MEMORY);
713 }
714
715 /* Copy the actual buffer data */
716
717 ACPI_MEMCPY(dest_desc->buffer.pointer,
718 source_desc->buffer.pointer,
719 source_desc->buffer.length);
720 }
721 break;
722
723 case ACPI_TYPE_STRING:
724 /*
725 * Allocate and copy the actual string if and only if:
726 * 1) There is a valid string pointer
727 * (Pointer to a NULL string is allowed)
728 */
729 if (source_desc->string.pointer) {
730 dest_desc->string.pointer =
731 ACPI_ALLOCATE((acpi_size) source_desc->string.
732 length + 1);
733 if (!dest_desc->string.pointer) {
734 return (AE_NO_MEMORY);
735 }
736
737 /* Copy the actual string data */
738
739 ACPI_MEMCPY(dest_desc->string.pointer,
740 source_desc->string.pointer,
741 (acpi_size) source_desc->string.length + 1);
742 }
743 break;
744
745 case ACPI_TYPE_LOCAL_REFERENCE:
746 /*
747 * We copied the reference object, so we now must add a reference
748 * to the object pointed to by the reference
749 *
750 * DDBHandle reference (from Load/load_table) is a special reference,
751 * it does not have a Reference.Object, so does not need to
752 * increase the reference count
753 */
754 if (source_desc->reference.class == ACPI_REFCLASS_TABLE) {
755 break;
756 }
757
758 acpi_ut_add_reference(source_desc->reference.object);
759 break;
760
761 case ACPI_TYPE_REGION:
762 /*
763 * We copied the Region Handler, so we now must add a reference
764 */
765 if (dest_desc->region.handler) {
766 acpi_ut_add_reference(dest_desc->region.handler);
767 }
768 break;
769
770 default:
771 /* Nothing to do for other simple objects */
772 break;
773 }
774
775 return (AE_OK);
776}
777
778/*******************************************************************************
779 *
780 * FUNCTION: acpi_ut_copy_ielement_to_ielement
781 *
782 * PARAMETERS: acpi_pkg_callback
783 *
784 * RETURN: Status
785 *
786 * DESCRIPTION: Copy one package element to another package element
787 *
788 ******************************************************************************/
789
790static acpi_status
791acpi_ut_copy_ielement_to_ielement(u8 object_type,
792 union acpi_operand_object *source_object,
793 union acpi_generic_state *state,
794 void *context)
795{
796 acpi_status status = AE_OK;
797 u32 this_index;
798 union acpi_operand_object **this_target_ptr;
799 union acpi_operand_object *target_object;
800
801 ACPI_FUNCTION_ENTRY();
802
803 this_index = state->pkg.index;
804 this_target_ptr = (union acpi_operand_object **)
805 &state->pkg.dest_object->package.elements[this_index];
806
807 switch (object_type) {
808 case ACPI_COPY_TYPE_SIMPLE:
809
810 /* A null source object indicates a (legal) null package element */
811
812 if (source_object) {
813 /*
814 * This is a simple object, just copy it
815 */
816 target_object =
817 acpi_ut_create_internal_object(ACPI_GET_OBJECT_TYPE
818 (source_object));
819 if (!target_object) {
820 return (AE_NO_MEMORY);
821 }
822
823 status =
824 acpi_ut_copy_simple_object(source_object,
825 target_object);
826 if (ACPI_FAILURE(status)) {
827 goto error_exit;
828 }
829
830 *this_target_ptr = target_object;
831 } else {
832 /* Pass through a null element */
833
834 *this_target_ptr = NULL;
835 }
836 break;
837
838 case ACPI_COPY_TYPE_PACKAGE:
839
840 /*
841 * This object is a package - go down another nesting level
842 * Create and build the package object
843 */
844 target_object =
845 acpi_ut_create_package_object(source_object->package.count);
846 if (!target_object) {
847 return (AE_NO_MEMORY);
848 }
849
850 target_object->common.flags = source_object->common.flags;
851
852 /* Pass the new package object back to the package walk routine */
853
854 state->pkg.this_target_obj = target_object;
855
856 /* Store the object pointer in the parent package object */
857
858 *this_target_ptr = target_object;
859 break;
860
861 default:
862 return (AE_BAD_PARAMETER);
863 }
864
865 return (status);
866
867 error_exit:
868 acpi_ut_remove_reference(target_object);
869 return (status);
870}
871
872/*******************************************************************************
873 *
874 * FUNCTION: acpi_ut_copy_ipackage_to_ipackage
875 *
876 * PARAMETERS: *source_obj - Pointer to the source package object
877 * *dest_obj - Where the internal object is returned
878 *
879 * RETURN: Status - the status of the call
880 *
881 * DESCRIPTION: This function is called to copy an internal package object
882 * into another internal package object.
883 *
884 ******************************************************************************/
885
886static acpi_status
887acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj,
888 union acpi_operand_object *dest_obj,
889 struct acpi_walk_state *walk_state)
890{
891 acpi_status status = AE_OK;
892
893 ACPI_FUNCTION_TRACE(ut_copy_ipackage_to_ipackage);
894
895 dest_obj->common.type = ACPI_GET_OBJECT_TYPE(source_obj);
896 dest_obj->common.flags = source_obj->common.flags;
897 dest_obj->package.count = source_obj->package.count;
898
899 /*
900 * Create the object array and walk the source package tree
901 */
902 dest_obj->package.elements = ACPI_ALLOCATE_ZEROED(((acpi_size)
903 source_obj->package.
904 count +
905 1) * sizeof(void *));
906 if (!dest_obj->package.elements) {
907 ACPI_ERROR((AE_INFO, "Package allocation failure"));
908 return_ACPI_STATUS(AE_NO_MEMORY);
909 }
910
911 /*
912 * Copy the package element-by-element by walking the package "tree".
913 * This handles nested packages of arbitrary depth.
914 */
915 status = acpi_ut_walk_package_tree(source_obj, dest_obj,
916 acpi_ut_copy_ielement_to_ielement,
917 walk_state);
918 if (ACPI_FAILURE(status)) {
919
920 /* On failure, delete the destination package object */
921
922 acpi_ut_remove_reference(dest_obj);
923 }
924
925 return_ACPI_STATUS(status);
926}
927
928/*******************************************************************************
929 *
930 * FUNCTION: acpi_ut_copy_iobject_to_iobject
931 *
932 * PARAMETERS: walk_state - Current walk state
933 * source_desc - The internal object to be copied
934 * dest_desc - Where the copied object is returned
935 *
936 * RETURN: Status
937 *
938 * DESCRIPTION: Copy an internal object to a new internal object
939 *
940 ******************************************************************************/
941
942acpi_status
943acpi_ut_copy_iobject_to_iobject(union acpi_operand_object *source_desc,
944 union acpi_operand_object **dest_desc,
945 struct acpi_walk_state *walk_state)
946{
947 acpi_status status = AE_OK;
948
949 ACPI_FUNCTION_TRACE(ut_copy_iobject_to_iobject);
950
951 /* Create the top level object */
952
953 *dest_desc =
954 acpi_ut_create_internal_object(ACPI_GET_OBJECT_TYPE(source_desc));
955 if (!*dest_desc) {
956 return_ACPI_STATUS(AE_NO_MEMORY);
957 }
958
959 /* Copy the object and possible subobjects */
960
961 if (ACPI_GET_OBJECT_TYPE(source_desc) == ACPI_TYPE_PACKAGE) {
962 status =
963 acpi_ut_copy_ipackage_to_ipackage(source_desc, *dest_desc,
964 walk_state);
965 } else {
966 status = acpi_ut_copy_simple_object(source_desc, *dest_desc);
967 }
968
969 return_ACPI_STATUS(status);
970}
diff --git a/drivers/acpi/utilities/utdebug.c b/drivers/acpi/utilities/utdebug.c
deleted file mode 100644
index 9a3538c497d0..000000000000
--- a/drivers/acpi/utilities/utdebug.c
+++ /dev/null
@@ -1,651 +0,0 @@
1/******************************************************************************
2 *
3 * Module Name: utdebug - Debug print routines
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include <acpi/accommon.h>
46
47#define _COMPONENT ACPI_UTILITIES
48ACPI_MODULE_NAME("utdebug")
49#ifdef ACPI_DEBUG_OUTPUT
50static acpi_thread_id acpi_gbl_prev_thread_id;
51static char *acpi_gbl_fn_entry_str = "----Entry";
52static char *acpi_gbl_fn_exit_str = "----Exit-";
53
54/* Local prototypes */
55
56static const char *acpi_ut_trim_function_name(const char *function_name);
57
58/*******************************************************************************
59 *
60 * FUNCTION: acpi_ut_init_stack_ptr_trace
61 *
62 * PARAMETERS: None
63 *
64 * RETURN: None
65 *
66 * DESCRIPTION: Save the current CPU stack pointer at subsystem startup
67 *
68 ******************************************************************************/
69
70void acpi_ut_init_stack_ptr_trace(void)
71{
72 acpi_size current_sp;
73
74 acpi_gbl_entry_stack_pointer = &current_sp;
75}
76
77/*******************************************************************************
78 *
79 * FUNCTION: acpi_ut_track_stack_ptr
80 *
81 * PARAMETERS: None
82 *
83 * RETURN: None
84 *
85 * DESCRIPTION: Save the current CPU stack pointer
86 *
87 ******************************************************************************/
88
89void acpi_ut_track_stack_ptr(void)
90{
91 acpi_size current_sp;
92
93 if (&current_sp < acpi_gbl_lowest_stack_pointer) {
94 acpi_gbl_lowest_stack_pointer = &current_sp;
95 }
96
97 if (acpi_gbl_nesting_level > acpi_gbl_deepest_nesting) {
98 acpi_gbl_deepest_nesting = acpi_gbl_nesting_level;
99 }
100}
101
102/*******************************************************************************
103 *
104 * FUNCTION: acpi_ut_trim_function_name
105 *
106 * PARAMETERS: function_name - Ascii string containing a procedure name
107 *
108 * RETURN: Updated pointer to the function name
109 *
110 * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present.
111 * This allows compiler macros such as __func__ to be used
112 * with no change to the debug output.
113 *
114 ******************************************************************************/
115
116static const char *acpi_ut_trim_function_name(const char *function_name)
117{
118
119 /* All Function names are longer than 4 chars, check is safe */
120
121 if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_MIXED) {
122
123 /* This is the case where the original source has not been modified */
124
125 return (function_name + 4);
126 }
127
128 if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_LOWER) {
129
130 /* This is the case where the source has been 'linuxized' */
131
132 return (function_name + 5);
133 }
134
135 return (function_name);
136}
137
138/*******************************************************************************
139 *
140 * FUNCTION: acpi_debug_print
141 *
142 * PARAMETERS: requested_debug_level - Requested debug print level
143 * line_number - Caller's line number (for error output)
144 * function_name - Caller's procedure name
145 * module_name - Caller's module name
146 * component_id - Caller's component ID
147 * Format - Printf format field
148 * ... - Optional printf arguments
149 *
150 * RETURN: None
151 *
152 * DESCRIPTION: Print error message with prefix consisting of the module name,
153 * line number, and component ID.
154 *
155 ******************************************************************************/
156
157void ACPI_INTERNAL_VAR_XFACE
158acpi_debug_print(u32 requested_debug_level,
159 u32 line_number,
160 const char *function_name,
161 const char *module_name,
162 u32 component_id, const char *format, ...)
163{
164 acpi_thread_id thread_id;
165 va_list args;
166
167 /*
168 * Stay silent if the debug level or component ID is disabled
169 */
170 if (!(requested_debug_level & acpi_dbg_level) ||
171 !(component_id & acpi_dbg_layer)) {
172 return;
173 }
174
175 /*
176 * Thread tracking and context switch notification
177 */
178 thread_id = acpi_os_get_thread_id();
179 if (thread_id != acpi_gbl_prev_thread_id) {
180 if (ACPI_LV_THREADS & acpi_dbg_level) {
181 acpi_os_printf
182 ("\n**** Context Switch from TID %lX to TID %lX ****\n\n",
183 (unsigned long)acpi_gbl_prev_thread_id,
184 (unsigned long)thread_id);
185 }
186
187 acpi_gbl_prev_thread_id = thread_id;
188 }
189
190 /*
191 * Display the module name, current line number, thread ID (if requested),
192 * current procedure nesting level, and the current procedure name
193 */
194 acpi_os_printf("%8s-%04ld ", module_name, line_number);
195
196 if (ACPI_LV_THREADS & acpi_dbg_level) {
197 acpi_os_printf("[%04lX] ", (unsigned long)thread_id);
198 }
199
200 acpi_os_printf("[%02ld] %-22.22s: ",
201 acpi_gbl_nesting_level,
202 acpi_ut_trim_function_name(function_name));
203
204 va_start(args, format);
205 acpi_os_vprintf(format, args);
206 va_end(args);
207}
208
209ACPI_EXPORT_SYMBOL(acpi_debug_print)
210
211/*******************************************************************************
212 *
213 * FUNCTION: acpi_debug_print_raw
214 *
215 * PARAMETERS: requested_debug_level - Requested debug print level
216 * line_number - Caller's line number
217 * function_name - Caller's procedure name
218 * module_name - Caller's module name
219 * component_id - Caller's component ID
220 * Format - Printf format field
221 * ... - Optional printf arguments
222 *
223 * RETURN: None
224 *
225 * DESCRIPTION: Print message with no headers. Has same interface as
226 * debug_print so that the same macros can be used.
227 *
228 ******************************************************************************/
229void ACPI_INTERNAL_VAR_XFACE
230acpi_debug_print_raw(u32 requested_debug_level,
231 u32 line_number,
232 const char *function_name,
233 const char *module_name,
234 u32 component_id, const char *format, ...)
235{
236 va_list args;
237
238 if (!(requested_debug_level & acpi_dbg_level) ||
239 !(component_id & acpi_dbg_layer)) {
240 return;
241 }
242
243 va_start(args, format);
244 acpi_os_vprintf(format, args);
245 va_end(args);
246}
247
248ACPI_EXPORT_SYMBOL(acpi_debug_print_raw)
249
250/*******************************************************************************
251 *
252 * FUNCTION: acpi_ut_trace
253 *
254 * PARAMETERS: line_number - Caller's line number
255 * function_name - Caller's procedure name
256 * module_name - Caller's module name
257 * component_id - Caller's component ID
258 *
259 * RETURN: None
260 *
261 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
262 * set in debug_level
263 *
264 ******************************************************************************/
265void
266acpi_ut_trace(u32 line_number,
267 const char *function_name,
268 const char *module_name, u32 component_id)
269{
270
271 acpi_gbl_nesting_level++;
272 acpi_ut_track_stack_ptr();
273
274 acpi_debug_print(ACPI_LV_FUNCTIONS,
275 line_number, function_name, module_name, component_id,
276 "%s\n", acpi_gbl_fn_entry_str);
277}
278
279ACPI_EXPORT_SYMBOL(acpi_ut_trace)
280
281/*******************************************************************************
282 *
283 * FUNCTION: acpi_ut_trace_ptr
284 *
285 * PARAMETERS: line_number - Caller's line number
286 * function_name - Caller's procedure name
287 * module_name - Caller's module name
288 * component_id - Caller's component ID
289 * Pointer - Pointer to display
290 *
291 * RETURN: None
292 *
293 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
294 * set in debug_level
295 *
296 ******************************************************************************/
297void
298acpi_ut_trace_ptr(u32 line_number,
299 const char *function_name,
300 const char *module_name, u32 component_id, void *pointer)
301{
302 acpi_gbl_nesting_level++;
303 acpi_ut_track_stack_ptr();
304
305 acpi_debug_print(ACPI_LV_FUNCTIONS,
306 line_number, function_name, module_name, component_id,
307 "%s %p\n", acpi_gbl_fn_entry_str, pointer);
308}
309
310/*******************************************************************************
311 *
312 * FUNCTION: acpi_ut_trace_str
313 *
314 * PARAMETERS: line_number - Caller's line number
315 * function_name - Caller's procedure name
316 * module_name - Caller's module name
317 * component_id - Caller's component ID
318 * String - Additional string to display
319 *
320 * RETURN: None
321 *
322 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
323 * set in debug_level
324 *
325 ******************************************************************************/
326
327void
328acpi_ut_trace_str(u32 line_number,
329 const char *function_name,
330 const char *module_name, u32 component_id, char *string)
331{
332
333 acpi_gbl_nesting_level++;
334 acpi_ut_track_stack_ptr();
335
336 acpi_debug_print(ACPI_LV_FUNCTIONS,
337 line_number, function_name, module_name, component_id,
338 "%s %s\n", acpi_gbl_fn_entry_str, string);
339}
340
341/*******************************************************************************
342 *
343 * FUNCTION: acpi_ut_trace_u32
344 *
345 * PARAMETERS: line_number - Caller's line number
346 * function_name - Caller's procedure name
347 * module_name - Caller's module name
348 * component_id - Caller's component ID
349 * Integer - Integer to display
350 *
351 * RETURN: None
352 *
353 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
354 * set in debug_level
355 *
356 ******************************************************************************/
357
358void
359acpi_ut_trace_u32(u32 line_number,
360 const char *function_name,
361 const char *module_name, u32 component_id, u32 integer)
362{
363
364 acpi_gbl_nesting_level++;
365 acpi_ut_track_stack_ptr();
366
367 acpi_debug_print(ACPI_LV_FUNCTIONS,
368 line_number, function_name, module_name, component_id,
369 "%s %08X\n", acpi_gbl_fn_entry_str, integer);
370}
371
372/*******************************************************************************
373 *
374 * FUNCTION: acpi_ut_exit
375 *
376 * PARAMETERS: line_number - Caller's line number
377 * function_name - Caller's procedure name
378 * module_name - Caller's module name
379 * component_id - Caller's component ID
380 *
381 * RETURN: None
382 *
383 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
384 * set in debug_level
385 *
386 ******************************************************************************/
387
388void
389acpi_ut_exit(u32 line_number,
390 const char *function_name,
391 const char *module_name, u32 component_id)
392{
393
394 acpi_debug_print(ACPI_LV_FUNCTIONS,
395 line_number, function_name, module_name, component_id,
396 "%s\n", acpi_gbl_fn_exit_str);
397
398 acpi_gbl_nesting_level--;
399}
400
401ACPI_EXPORT_SYMBOL(acpi_ut_exit)
402
403/*******************************************************************************
404 *
405 * FUNCTION: acpi_ut_status_exit
406 *
407 * PARAMETERS: line_number - Caller's line number
408 * function_name - Caller's procedure name
409 * module_name - Caller's module name
410 * component_id - Caller's component ID
411 * Status - Exit status code
412 *
413 * RETURN: None
414 *
415 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
416 * set in debug_level. Prints exit status also.
417 *
418 ******************************************************************************/
419void
420acpi_ut_status_exit(u32 line_number,
421 const char *function_name,
422 const char *module_name,
423 u32 component_id, acpi_status status)
424{
425
426 if (ACPI_SUCCESS(status)) {
427 acpi_debug_print(ACPI_LV_FUNCTIONS,
428 line_number, function_name, module_name,
429 component_id, "%s %s\n", acpi_gbl_fn_exit_str,
430 acpi_format_exception(status));
431 } else {
432 acpi_debug_print(ACPI_LV_FUNCTIONS,
433 line_number, function_name, module_name,
434 component_id, "%s ****Exception****: %s\n",
435 acpi_gbl_fn_exit_str,
436 acpi_format_exception(status));
437 }
438
439 acpi_gbl_nesting_level--;
440}
441
442ACPI_EXPORT_SYMBOL(acpi_ut_status_exit)
443
444/*******************************************************************************
445 *
446 * FUNCTION: acpi_ut_value_exit
447 *
448 * PARAMETERS: line_number - Caller's line number
449 * function_name - Caller's procedure name
450 * module_name - Caller's module name
451 * component_id - Caller's component ID
452 * Value - Value to be printed with exit msg
453 *
454 * RETURN: None
455 *
456 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
457 * set in debug_level. Prints exit value also.
458 *
459 ******************************************************************************/
460void
461acpi_ut_value_exit(u32 line_number,
462 const char *function_name,
463 const char *module_name,
464 u32 component_id, acpi_integer value)
465{
466
467 acpi_debug_print(ACPI_LV_FUNCTIONS,
468 line_number, function_name, module_name, component_id,
469 "%s %8.8X%8.8X\n", acpi_gbl_fn_exit_str,
470 ACPI_FORMAT_UINT64(value));
471
472 acpi_gbl_nesting_level--;
473}
474
475ACPI_EXPORT_SYMBOL(acpi_ut_value_exit)
476
477/*******************************************************************************
478 *
479 * FUNCTION: acpi_ut_ptr_exit
480 *
481 * PARAMETERS: line_number - Caller's line number
482 * function_name - Caller's procedure name
483 * module_name - Caller's module name
484 * component_id - Caller's component ID
485 * Ptr - Pointer to display
486 *
487 * RETURN: None
488 *
489 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
490 * set in debug_level. Prints exit value also.
491 *
492 ******************************************************************************/
493void
494acpi_ut_ptr_exit(u32 line_number,
495 const char *function_name,
496 const char *module_name, u32 component_id, u8 *ptr)
497{
498
499 acpi_debug_print(ACPI_LV_FUNCTIONS,
500 line_number, function_name, module_name, component_id,
501 "%s %p\n", acpi_gbl_fn_exit_str, ptr);
502
503 acpi_gbl_nesting_level--;
504}
505
506#endif
507
508/*******************************************************************************
509 *
510 * FUNCTION: acpi_ut_dump_buffer
511 *
512 * PARAMETERS: Buffer - Buffer to dump
513 * Count - Amount to dump, in bytes
514 * Display - BYTE, WORD, DWORD, or QWORD display
515 * component_iD - Caller's component ID
516 *
517 * RETURN: None
518 *
519 * DESCRIPTION: Generic dump buffer in both hex and ascii.
520 *
521 ******************************************************************************/
522
523void acpi_ut_dump_buffer2(u8 * buffer, u32 count, u32 display)
524{
525 u32 i = 0;
526 u32 j;
527 u32 temp32;
528 u8 buf_char;
529
530 if (!buffer) {
531 acpi_os_printf("Null Buffer Pointer in DumpBuffer!\n");
532 return;
533 }
534
535 if ((count < 4) || (count & 0x01)) {
536 display = DB_BYTE_DISPLAY;
537 }
538
539 /* Nasty little dump buffer routine! */
540
541 while (i < count) {
542
543 /* Print current offset */
544
545 acpi_os_printf("%6.4X: ", i);
546
547 /* Print 16 hex chars */
548
549 for (j = 0; j < 16;) {
550 if (i + j >= count) {
551
552 /* Dump fill spaces */
553
554 acpi_os_printf("%*s", ((display * 2) + 1), " ");
555 j += display;
556 continue;
557 }
558
559 switch (display) {
560 case DB_BYTE_DISPLAY:
561 default: /* Default is BYTE display */
562
563 acpi_os_printf("%02X ",
564 buffer[(acpi_size) i + j]);
565 break;
566
567 case DB_WORD_DISPLAY:
568
569 ACPI_MOVE_16_TO_32(&temp32,
570 &buffer[(acpi_size) i + j]);
571 acpi_os_printf("%04X ", temp32);
572 break;
573
574 case DB_DWORD_DISPLAY:
575
576 ACPI_MOVE_32_TO_32(&temp32,
577 &buffer[(acpi_size) i + j]);
578 acpi_os_printf("%08X ", temp32);
579 break;
580
581 case DB_QWORD_DISPLAY:
582
583 ACPI_MOVE_32_TO_32(&temp32,
584 &buffer[(acpi_size) i + j]);
585 acpi_os_printf("%08X", temp32);
586
587 ACPI_MOVE_32_TO_32(&temp32,
588 &buffer[(acpi_size) i + j +
589 4]);
590 acpi_os_printf("%08X ", temp32);
591 break;
592 }
593
594 j += display;
595 }
596
597 /*
598 * Print the ASCII equivalent characters but watch out for the bad
599 * unprintable ones (printable chars are 0x20 through 0x7E)
600 */
601 acpi_os_printf(" ");
602 for (j = 0; j < 16; j++) {
603 if (i + j >= count) {
604 acpi_os_printf("\n");
605 return;
606 }
607
608 buf_char = buffer[(acpi_size) i + j];
609 if (ACPI_IS_PRINT(buf_char)) {
610 acpi_os_printf("%c", buf_char);
611 } else {
612 acpi_os_printf(".");
613 }
614 }
615
616 /* Done with that line. */
617
618 acpi_os_printf("\n");
619 i += 16;
620 }
621
622 return;
623}
624
625/*******************************************************************************
626 *
627 * FUNCTION: acpi_ut_dump_buffer
628 *
629 * PARAMETERS: Buffer - Buffer to dump
630 * Count - Amount to dump, in bytes
631 * Display - BYTE, WORD, DWORD, or QWORD display
632 * component_iD - Caller's component ID
633 *
634 * RETURN: None
635 *
636 * DESCRIPTION: Generic dump buffer in both hex and ascii.
637 *
638 ******************************************************************************/
639
640void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id)
641{
642
643 /* Only dump the buffer if tracing is enabled */
644
645 if (!((ACPI_LV_TABLES & acpi_dbg_level) &&
646 (component_id & acpi_dbg_layer))) {
647 return;
648 }
649
650 acpi_ut_dump_buffer2(buffer, count, display);
651}
diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c
deleted file mode 100644
index 5b4e3b1a7523..000000000000
--- a/drivers/acpi/utilities/utdelete.c
+++ /dev/null
@@ -1,677 +0,0 @@
1/*******************************************************************************
2 *
3 * Module Name: utdelete - object deletion and reference count utilities
4 *
5 ******************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include <acpi/accommon.h>
46#include <acpi/acinterp.h>
47#include <acpi/acnamesp.h>
48#include <acpi/acevents.h>
49
50#define _COMPONENT ACPI_UTILITIES
51ACPI_MODULE_NAME("utdelete")
52
53/* Local prototypes */
54static void acpi_ut_delete_internal_obj(union acpi_operand_object *object);
55
56static void
57acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action);
58
59/*******************************************************************************
60 *
61 * FUNCTION: acpi_ut_delete_internal_obj
62 *
63 * PARAMETERS: Object - Object to be deleted
64 *
65 * RETURN: None
66 *
67 * DESCRIPTION: Low level object deletion, after reference counts have been
68 * updated (All reference counts, including sub-objects!)
69 *
70 ******************************************************************************/
71
72static void acpi_ut_delete_internal_obj(union acpi_operand_object *object)
73{
74 void *obj_pointer = NULL;
75 union acpi_operand_object *handler_desc;
76 union acpi_operand_object *second_desc;
77 union acpi_operand_object *next_desc;
78
79 ACPI_FUNCTION_TRACE_PTR(ut_delete_internal_obj, object);
80
81 if (!object) {
82 return_VOID;
83 }
84
85 /*
86 * Must delete or free any pointers within the object that are not
87 * actual ACPI objects (for example, a raw buffer pointer).
88 */
89 switch (ACPI_GET_OBJECT_TYPE(object)) {
90 case ACPI_TYPE_STRING:
91
92 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
93 "**** String %p, ptr %p\n", object,
94 object->string.pointer));
95
96 /* Free the actual string buffer */
97
98 if (!(object->common.flags & AOPOBJ_STATIC_POINTER)) {
99
100 /* But only if it is NOT a pointer into an ACPI table */
101
102 obj_pointer = object->string.pointer;
103 }
104 break;
105
106 case ACPI_TYPE_BUFFER:
107
108 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
109 "**** Buffer %p, ptr %p\n", object,
110 object->buffer.pointer));
111
112 /* Free the actual buffer */
113
114 if (!(object->common.flags & AOPOBJ_STATIC_POINTER)) {
115
116 /* But only if it is NOT a pointer into an ACPI table */
117
118 obj_pointer = object->buffer.pointer;
119 }
120 break;
121
122 case ACPI_TYPE_PACKAGE:
123
124 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
125 " **** Package of count %X\n",
126 object->package.count));
127
128 /*
129 * Elements of the package are not handled here, they are deleted
130 * separately
131 */
132
133 /* Free the (variable length) element pointer array */
134
135 obj_pointer = object->package.elements;
136 break;
137
138 /*
139 * These objects have a possible list of notify handlers.
140 * Device object also may have a GPE block.
141 */
142 case ACPI_TYPE_DEVICE:
143
144 if (object->device.gpe_block) {
145 (void)acpi_ev_delete_gpe_block(object->device.
146 gpe_block);
147 }
148
149 /*lint -fallthrough */
150
151 case ACPI_TYPE_PROCESSOR:
152 case ACPI_TYPE_THERMAL:
153
154 /* Walk the notify handler list for this object */
155
156 handler_desc = object->common_notify.handler;
157 while (handler_desc) {
158 next_desc = handler_desc->address_space.next;
159 acpi_ut_remove_reference(handler_desc);
160 handler_desc = next_desc;
161 }
162 break;
163
164 case ACPI_TYPE_MUTEX:
165
166 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
167 "***** Mutex %p, OS Mutex %p\n",
168 object, object->mutex.os_mutex));
169
170 if (object == acpi_gbl_global_lock_mutex) {
171
172 /* Global Lock has extra semaphore */
173
174 (void)
175 acpi_os_delete_semaphore
176 (acpi_gbl_global_lock_semaphore);
177 acpi_gbl_global_lock_semaphore = NULL;
178
179 acpi_os_delete_mutex(object->mutex.os_mutex);
180 acpi_gbl_global_lock_mutex = NULL;
181 } else {
182 acpi_ex_unlink_mutex(object);
183 acpi_os_delete_mutex(object->mutex.os_mutex);
184 }
185 break;
186
187 case ACPI_TYPE_EVENT:
188
189 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
190 "***** Event %p, OS Semaphore %p\n",
191 object, object->event.os_semaphore));
192
193 (void)acpi_os_delete_semaphore(object->event.os_semaphore);
194 object->event.os_semaphore = NULL;
195 break;
196
197 case ACPI_TYPE_METHOD:
198
199 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
200 "***** Method %p\n", object));
201
202 /* Delete the method mutex if it exists */
203
204 if (object->method.mutex) {
205 acpi_os_delete_mutex(object->method.mutex->mutex.
206 os_mutex);
207 acpi_ut_delete_object_desc(object->method.mutex);
208 object->method.mutex = NULL;
209 }
210 break;
211
212 case ACPI_TYPE_REGION:
213
214 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
215 "***** Region %p\n", object));
216
217 second_desc = acpi_ns_get_secondary_object(object);
218 if (second_desc) {
219 /*
220 * Free the region_context if and only if the handler is one of the
221 * default handlers -- and therefore, we created the context object
222 * locally, it was not created by an external caller.
223 */
224 handler_desc = object->region.handler;
225 if (handler_desc) {
226 if (handler_desc->address_space.handler_flags &
227 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) {
228
229 /* Deactivate region and free region context */
230
231 if (handler_desc->address_space.setup) {
232 (void)handler_desc->
233 address_space.setup(object,
234 ACPI_REGION_DEACTIVATE,
235 handler_desc->
236 address_space.
237 context,
238 &second_desc->
239 extra.
240 region_context);
241 }
242 }
243
244 acpi_ut_remove_reference(handler_desc);
245 }
246
247 /* Now we can free the Extra object */
248
249 acpi_ut_delete_object_desc(second_desc);
250 }
251 break;
252
253 case ACPI_TYPE_BUFFER_FIELD:
254
255 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
256 "***** Buffer Field %p\n", object));
257
258 second_desc = acpi_ns_get_secondary_object(object);
259 if (second_desc) {
260 acpi_ut_delete_object_desc(second_desc);
261 }
262 break;
263
264 case ACPI_TYPE_LOCAL_BANK_FIELD:
265
266 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
267 "***** Bank Field %p\n", object));
268
269 second_desc = acpi_ns_get_secondary_object(object);
270 if (second_desc) {
271 acpi_ut_delete_object_desc(second_desc);
272 }
273 break;
274
275 default:
276 break;
277 }
278
279 /* Free any allocated memory (pointer within the object) found above */
280
281 if (obj_pointer) {
282 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
283 "Deleting Object Subptr %p\n", obj_pointer));
284 ACPI_FREE(obj_pointer);
285 }
286
287 /* Now the object can be safely deleted */
288
289 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Deleting Object %p [%s]\n",
290 object, acpi_ut_get_object_type_name(object)));
291
292 acpi_ut_delete_object_desc(object);
293 return_VOID;
294}
295
296/*******************************************************************************
297 *
298 * FUNCTION: acpi_ut_delete_internal_object_list
299 *
300 * PARAMETERS: obj_list - Pointer to the list to be deleted
301 *
302 * RETURN: None
303 *
304 * DESCRIPTION: This function deletes an internal object list, including both
305 * simple objects and package objects
306 *
307 ******************************************************************************/
308
309void acpi_ut_delete_internal_object_list(union acpi_operand_object **obj_list)
310{
311 union acpi_operand_object **internal_obj;
312
313 ACPI_FUNCTION_TRACE(ut_delete_internal_object_list);
314
315 /* Walk the null-terminated internal list */
316
317 for (internal_obj = obj_list; *internal_obj; internal_obj++) {
318 acpi_ut_remove_reference(*internal_obj);
319 }
320
321 /* Free the combined parameter pointer list and object array */
322
323 ACPI_FREE(obj_list);
324 return_VOID;
325}
326
327/*******************************************************************************
328 *
329 * FUNCTION: acpi_ut_update_ref_count
330 *
331 * PARAMETERS: Object - Object whose ref count is to be updated
332 * Action - What to do
333 *
334 * RETURN: New ref count
335 *
336 * DESCRIPTION: Modify the ref count and return it.
337 *
338 ******************************************************************************/
339
340static void
341acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action)
342{
343 u16 count;
344 u16 new_count;
345
346 ACPI_FUNCTION_NAME(ut_update_ref_count);
347
348 if (!object) {
349 return;
350 }
351
352 count = object->common.reference_count;
353 new_count = count;
354
355 /*
356 * Perform the reference count action (increment, decrement, force delete)
357 */
358 switch (action) {
359 case REF_INCREMENT:
360
361 new_count++;
362 object->common.reference_count = new_count;
363
364 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
365 "Obj %p Refs=%X, [Incremented]\n",
366 object, new_count));
367 break;
368
369 case REF_DECREMENT:
370
371 if (count < 1) {
372 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
373 "Obj %p Refs=%X, can't decrement! (Set to 0)\n",
374 object, new_count));
375
376 new_count = 0;
377 } else {
378 new_count--;
379
380 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
381 "Obj %p Refs=%X, [Decremented]\n",
382 object, new_count));
383 }
384
385 if (ACPI_GET_OBJECT_TYPE(object) == ACPI_TYPE_METHOD) {
386 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
387 "Method Obj %p Refs=%X, [Decremented]\n",
388 object, new_count));
389 }
390
391 object->common.reference_count = new_count;
392 if (new_count == 0) {
393 acpi_ut_delete_internal_obj(object);
394 }
395 break;
396
397 case REF_FORCE_DELETE:
398
399 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
400 "Obj %p Refs=%X, Force delete! (Set to 0)\n",
401 object, count));
402
403 new_count = 0;
404 object->common.reference_count = new_count;
405 acpi_ut_delete_internal_obj(object);
406 break;
407
408 default:
409
410 ACPI_ERROR((AE_INFO, "Unknown action (%X)", action));
411 break;
412 }
413
414 /*
415 * Sanity check the reference count, for debug purposes only.
416 * (A deleted object will have a huge reference count)
417 */
418 if (count > ACPI_MAX_REFERENCE_COUNT) {
419 ACPI_WARNING((AE_INFO,
420 "Large Reference Count (%X) in object %p", count,
421 object));
422 }
423}
424
425/*******************************************************************************
426 *
427 * FUNCTION: acpi_ut_update_object_reference
428 *
429 * PARAMETERS: Object - Increment ref count for this object
430 * and all sub-objects
431 * Action - Either REF_INCREMENT or REF_DECREMENT or
432 * REF_FORCE_DELETE
433 *
434 * RETURN: Status
435 *
436 * DESCRIPTION: Increment the object reference count
437 *
438 * Object references are incremented when:
439 * 1) An object is attached to a Node (namespace object)
440 * 2) An object is copied (all subobjects must be incremented)
441 *
442 * Object references are decremented when:
443 * 1) An object is detached from an Node
444 *
445 ******************************************************************************/
446
447acpi_status
448acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
449{
450 acpi_status status = AE_OK;
451 union acpi_generic_state *state_list = NULL;
452 union acpi_operand_object *next_object = NULL;
453 union acpi_generic_state *state;
454 u32 i;
455
456 ACPI_FUNCTION_TRACE_PTR(ut_update_object_reference, object);
457
458 while (object) {
459
460 /* Make sure that this isn't a namespace handle */
461
462 if (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED) {
463 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
464 "Object %p is NS handle\n", object));
465 return_ACPI_STATUS(AE_OK);
466 }
467
468 /*
469 * All sub-objects must have their reference count incremented also.
470 * Different object types have different subobjects.
471 */
472 switch (ACPI_GET_OBJECT_TYPE(object)) {
473 case ACPI_TYPE_DEVICE:
474 case ACPI_TYPE_PROCESSOR:
475 case ACPI_TYPE_POWER:
476 case ACPI_TYPE_THERMAL:
477
478 /* Update the notify objects for these types (if present) */
479
480 acpi_ut_update_ref_count(object->common_notify.
481 system_notify, action);
482 acpi_ut_update_ref_count(object->common_notify.
483 device_notify, action);
484 break;
485
486 case ACPI_TYPE_PACKAGE:
487 /*
488 * We must update all the sub-objects of the package,
489 * each of whom may have their own sub-objects.
490 */
491 for (i = 0; i < object->package.count; i++) {
492 /*
493 * Push each element onto the stack for later processing.
494 * Note: There can be null elements within the package,
495 * these are simply ignored
496 */
497 status =
498 acpi_ut_create_update_state_and_push
499 (object->package.elements[i], action,
500 &state_list);
501 if (ACPI_FAILURE(status)) {
502 goto error_exit;
503 }
504 }
505 break;
506
507 case ACPI_TYPE_BUFFER_FIELD:
508
509 next_object = object->buffer_field.buffer_obj;
510 break;
511
512 case ACPI_TYPE_LOCAL_REGION_FIELD:
513
514 next_object = object->field.region_obj;
515 break;
516
517 case ACPI_TYPE_LOCAL_BANK_FIELD:
518
519 next_object = object->bank_field.bank_obj;
520 status =
521 acpi_ut_create_update_state_and_push(object->
522 bank_field.
523 region_obj,
524 action,
525 &state_list);
526 if (ACPI_FAILURE(status)) {
527 goto error_exit;
528 }
529 break;
530
531 case ACPI_TYPE_LOCAL_INDEX_FIELD:
532
533 next_object = object->index_field.index_obj;
534 status =
535 acpi_ut_create_update_state_and_push(object->
536 index_field.
537 data_obj,
538 action,
539 &state_list);
540 if (ACPI_FAILURE(status)) {
541 goto error_exit;
542 }
543 break;
544
545 case ACPI_TYPE_LOCAL_REFERENCE:
546 /*
547 * The target of an Index (a package, string, or buffer) or a named
548 * reference must track changes to the ref count of the index or
549 * target object.
550 */
551 if ((object->reference.class == ACPI_REFCLASS_INDEX) ||
552 (object->reference.class == ACPI_REFCLASS_NAME)) {
553 next_object = object->reference.object;
554 }
555 break;
556
557 case ACPI_TYPE_REGION:
558 default:
559 break; /* No subobjects for all other types */
560 }
561
562 /*
563 * Now we can update the count in the main object. This can only
564 * happen after we update the sub-objects in case this causes the
565 * main object to be deleted.
566 */
567 acpi_ut_update_ref_count(object, action);
568 object = NULL;
569
570 /* Move on to the next object to be updated */
571
572 if (next_object) {
573 object = next_object;
574 next_object = NULL;
575 } else if (state_list) {
576 state = acpi_ut_pop_generic_state(&state_list);
577 object = state->update.object;
578 acpi_ut_delete_generic_state(state);
579 }
580 }
581
582 return_ACPI_STATUS(AE_OK);
583
584 error_exit:
585
586 ACPI_EXCEPTION((AE_INFO, status,
587 "Could not update object reference count"));
588
589 /* Free any stacked Update State objects */
590
591 while (state_list) {
592 state = acpi_ut_pop_generic_state(&state_list);
593 acpi_ut_delete_generic_state(state);
594 }
595
596 return_ACPI_STATUS(status);
597}
598
599/*******************************************************************************
600 *
601 * FUNCTION: acpi_ut_add_reference
602 *
603 * PARAMETERS: Object - Object whose reference count is to be
604 * incremented
605 *
606 * RETURN: None
607 *
608 * DESCRIPTION: Add one reference to an ACPI object
609 *
610 ******************************************************************************/
611
612void acpi_ut_add_reference(union acpi_operand_object *object)
613{
614
615 ACPI_FUNCTION_TRACE_PTR(ut_add_reference, object);
616
617 /* Ensure that we have a valid object */
618
619 if (!acpi_ut_valid_internal_object(object)) {
620 return_VOID;
621 }
622
623 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
624 "Obj %p Current Refs=%X [To Be Incremented]\n",
625 object, object->common.reference_count));
626
627 /* Increment the reference count */
628
629 (void)acpi_ut_update_object_reference(object, REF_INCREMENT);
630 return_VOID;
631}
632
633/*******************************************************************************
634 *
635 * FUNCTION: acpi_ut_remove_reference
636 *
637 * PARAMETERS: Object - Object whose ref count will be decremented
638 *
639 * RETURN: None
640 *
641 * DESCRIPTION: Decrement the reference count of an ACPI internal object
642 *
643 ******************************************************************************/
644
645void acpi_ut_remove_reference(union acpi_operand_object *object)
646{
647
648 ACPI_FUNCTION_TRACE_PTR(ut_remove_reference, object);
649
650 /*
651 * Allow a NULL pointer to be passed in, just ignore it. This saves
652 * each caller from having to check. Also, ignore NS nodes.
653 *
654 */
655 if (!object ||
656 (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED)) {
657 return_VOID;
658 }
659
660 /* Ensure that we have a valid object */
661
662 if (!acpi_ut_valid_internal_object(object)) {
663 return_VOID;
664 }
665
666 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
667 "Obj %p Current Refs=%X [To Be Decremented]\n",
668 object, object->common.reference_count));
669
670 /*
671 * Decrement the reference count, and only actually delete the object
672 * if the reference count becomes 0. (Must also decrement the ref count
673 * of all subobjects!)
674 */
675 (void)acpi_ut_update_object_reference(object, REF_DECREMENT);
676 return_VOID;
677}
diff --git a/drivers/acpi/utilities/uteval.c b/drivers/acpi/utilities/uteval.c
deleted file mode 100644
index e1e438cd54a9..000000000000
--- a/drivers/acpi/utilities/uteval.c
+++ /dev/null
@@ -1,752 +0,0 @@
1/******************************************************************************
2 *
3 * Module Name: uteval - Object evaluation
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include <acpi/accommon.h>
46#include <acpi/acnamesp.h>
47#include <acpi/acinterp.h>
48
49#define _COMPONENT ACPI_UTILITIES
50ACPI_MODULE_NAME("uteval")
51
52/* Local prototypes */
53static void
54acpi_ut_copy_id_string(char *destination, char *source, acpi_size max_length);
55
56static acpi_status
57acpi_ut_translate_one_cid(union acpi_operand_object *obj_desc,
58 struct acpi_compatible_id *one_cid);
59
60/*
61 * Strings supported by the _OSI predefined (internal) method.
62 */
63static char *acpi_interfaces_supported[] = {
64 /* Operating System Vendor Strings */
65
66 "Windows 2000", /* Windows 2000 */
67 "Windows 2001", /* Windows XP */
68 "Windows 2001 SP1", /* Windows XP SP1 */
69 "Windows 2001 SP2", /* Windows XP SP2 */
70 "Windows 2001.1", /* Windows Server 2003 */
71 "Windows 2001.1 SP1", /* Windows Server 2003 SP1 - Added 03/2006 */
72 "Windows 2006", /* Windows Vista - Added 03/2006 */
73
74 /* Feature Group Strings */
75
76 "Extended Address Space Descriptor"
77 /*
78 * All "optional" feature group strings (features that are implemented
79 * by the host) should be implemented in the host version of
80 * acpi_os_validate_interface and should not be added here.
81 */
82};
83
84/*******************************************************************************
85 *
86 * FUNCTION: acpi_ut_osi_implementation
87 *
88 * PARAMETERS: walk_state - Current walk state
89 *
90 * RETURN: Status
91 *
92 * DESCRIPTION: Implementation of the _OSI predefined control method
93 *
94 ******************************************************************************/
95
96acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state)
97{
98 acpi_status status;
99 union acpi_operand_object *string_desc;
100 union acpi_operand_object *return_desc;
101 u32 i;
102
103 ACPI_FUNCTION_TRACE(ut_osi_implementation);
104
105 /* Validate the string input argument */
106
107 string_desc = walk_state->arguments[0].object;
108 if (!string_desc || (string_desc->common.type != ACPI_TYPE_STRING)) {
109 return_ACPI_STATUS(AE_TYPE);
110 }
111
112 /* Create a return object */
113
114 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
115 if (!return_desc) {
116 return_ACPI_STATUS(AE_NO_MEMORY);
117 }
118
119 /* Default return value is SUPPORTED */
120
121 return_desc->integer.value = ACPI_UINT32_MAX;
122 walk_state->return_desc = return_desc;
123
124 /* Compare input string to static table of supported interfaces */
125
126 for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_interfaces_supported); i++) {
127 if (!ACPI_STRCMP
128 (string_desc->string.pointer,
129 acpi_interfaces_supported[i])) {
130
131 /* The interface is supported */
132
133 return_ACPI_STATUS(AE_OK);
134 }
135 }
136
137 /*
138 * Did not match the string in the static table, call the host OSL to
139 * check for a match with one of the optional strings (such as
140 * "Module Device", "3.0 Thermal Model", etc.)
141 */
142 status = acpi_os_validate_interface(string_desc->string.pointer);
143 if (ACPI_SUCCESS(status)) {
144
145 /* The interface is supported */
146
147 return_ACPI_STATUS(AE_OK);
148 }
149
150 /* The interface is not supported */
151
152 return_desc->integer.value = 0;
153 return_ACPI_STATUS(AE_OK);
154}
155
156/*******************************************************************************
157 *
158 * FUNCTION: acpi_osi_invalidate
159 *
160 * PARAMETERS: interface_string
161 *
162 * RETURN: Status
163 *
164 * DESCRIPTION: invalidate string in pre-defiend _OSI string list
165 *
166 ******************************************************************************/
167
168acpi_status acpi_osi_invalidate(char *interface)
169{
170 int i;
171
172 for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_interfaces_supported); i++) {
173 if (!ACPI_STRCMP(interface, acpi_interfaces_supported[i])) {
174 *acpi_interfaces_supported[i] = '\0';
175 return AE_OK;
176 }
177 }
178 return AE_NOT_FOUND;
179}
180
181/*******************************************************************************
182 *
183 * FUNCTION: acpi_ut_evaluate_object
184 *
185 * PARAMETERS: prefix_node - Starting node
186 * Path - Path to object from starting node
187 * expected_return_types - Bitmap of allowed return types
188 * return_desc - Where a return value is stored
189 *
190 * RETURN: Status
191 *
192 * DESCRIPTION: Evaluates a namespace object and verifies the type of the
193 * return object. Common code that simplifies accessing objects
194 * that have required return objects of fixed types.
195 *
196 * NOTE: Internal function, no parameter validation
197 *
198 ******************************************************************************/
199
200acpi_status
201acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
202 char *path,
203 u32 expected_return_btypes,
204 union acpi_operand_object **return_desc)
205{
206 struct acpi_evaluate_info *info;
207 acpi_status status;
208 u32 return_btype;
209
210 ACPI_FUNCTION_TRACE(ut_evaluate_object);
211
212 /* Allocate the evaluation information block */
213
214 info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
215 if (!info) {
216 return_ACPI_STATUS(AE_NO_MEMORY);
217 }
218
219 info->prefix_node = prefix_node;
220 info->pathname = path;
221
222 /* Evaluate the object/method */
223
224 status = acpi_ns_evaluate(info);
225 if (ACPI_FAILURE(status)) {
226 if (status == AE_NOT_FOUND) {
227 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
228 "[%4.4s.%s] was not found\n",
229 acpi_ut_get_node_name(prefix_node),
230 path));
231 } else {
232 ACPI_ERROR_METHOD("Method execution failed",
233 prefix_node, path, status);
234 }
235
236 goto cleanup;
237 }
238
239 /* Did we get a return object? */
240
241 if (!info->return_object) {
242 if (expected_return_btypes) {
243 ACPI_ERROR_METHOD("No object was returned from",
244 prefix_node, path, AE_NOT_EXIST);
245
246 status = AE_NOT_EXIST;
247 }
248
249 goto cleanup;
250 }
251
252 /* Map the return object type to the bitmapped type */
253
254 switch (ACPI_GET_OBJECT_TYPE(info->return_object)) {
255 case ACPI_TYPE_INTEGER:
256 return_btype = ACPI_BTYPE_INTEGER;
257 break;
258
259 case ACPI_TYPE_BUFFER:
260 return_btype = ACPI_BTYPE_BUFFER;
261 break;
262
263 case ACPI_TYPE_STRING:
264 return_btype = ACPI_BTYPE_STRING;
265 break;
266
267 case ACPI_TYPE_PACKAGE:
268 return_btype = ACPI_BTYPE_PACKAGE;
269 break;
270
271 default:
272 return_btype = 0;
273 break;
274 }
275
276 if ((acpi_gbl_enable_interpreter_slack) && (!expected_return_btypes)) {
277 /*
278 * We received a return object, but one was not expected. This can
279 * happen frequently if the "implicit return" feature is enabled.
280 * Just delete the return object and return AE_OK.
281 */
282 acpi_ut_remove_reference(info->return_object);
283 goto cleanup;
284 }
285
286 /* Is the return object one of the expected types? */
287
288 if (!(expected_return_btypes & return_btype)) {
289 ACPI_ERROR_METHOD("Return object type is incorrect",
290 prefix_node, path, AE_TYPE);
291
292 ACPI_ERROR((AE_INFO,
293 "Type returned from %s was incorrect: %s, expected Btypes: %X",
294 path,
295 acpi_ut_get_object_type_name(info->return_object),
296 expected_return_btypes));
297
298 /* On error exit, we must delete the return object */
299
300 acpi_ut_remove_reference(info->return_object);
301 status = AE_TYPE;
302 goto cleanup;
303 }
304
305 /* Object type is OK, return it */
306
307 *return_desc = info->return_object;
308
309 cleanup:
310 ACPI_FREE(info);
311 return_ACPI_STATUS(status);
312}
313
314/*******************************************************************************
315 *
316 * FUNCTION: acpi_ut_evaluate_numeric_object
317 *
318 * PARAMETERS: object_name - Object name to be evaluated
319 * device_node - Node for the device
320 * Address - Where the value is returned
321 *
322 * RETURN: Status
323 *
324 * DESCRIPTION: Evaluates a numeric namespace object for a selected device
325 * and stores result in *Address.
326 *
327 * NOTE: Internal function, no parameter validation
328 *
329 ******************************************************************************/
330
331acpi_status
332acpi_ut_evaluate_numeric_object(char *object_name,
333 struct acpi_namespace_node *device_node,
334 acpi_integer * address)
335{
336 union acpi_operand_object *obj_desc;
337 acpi_status status;
338
339 ACPI_FUNCTION_TRACE(ut_evaluate_numeric_object);
340
341 status = acpi_ut_evaluate_object(device_node, object_name,
342 ACPI_BTYPE_INTEGER, &obj_desc);
343 if (ACPI_FAILURE(status)) {
344 return_ACPI_STATUS(status);
345 }
346
347 /* Get the returned Integer */
348
349 *address = obj_desc->integer.value;
350
351 /* On exit, we must delete the return object */
352
353 acpi_ut_remove_reference(obj_desc);
354 return_ACPI_STATUS(status);
355}
356
357/*******************************************************************************
358 *
359 * FUNCTION: acpi_ut_copy_id_string
360 *
361 * PARAMETERS: Destination - Where to copy the string
362 * Source - Source string
363 * max_length - Length of the destination buffer
364 *
365 * RETURN: None
366 *
367 * DESCRIPTION: Copies an ID string for the _HID, _CID, and _UID methods.
368 * Performs removal of a leading asterisk if present -- workaround
369 * for a known issue on a bunch of machines.
370 *
371 ******************************************************************************/
372
373static void
374acpi_ut_copy_id_string(char *destination, char *source, acpi_size max_length)
375{
376
377 /*
378 * Workaround for ID strings that have a leading asterisk. This construct
379 * is not allowed by the ACPI specification (ID strings must be
380 * alphanumeric), but enough existing machines have this embedded in their
381 * ID strings that the following code is useful.
382 */
383 if (*source == '*') {
384 source++;
385 }
386
387 /* Do the actual copy */
388
389 ACPI_STRNCPY(destination, source, max_length);
390}
391
392/*******************************************************************************
393 *
394 * FUNCTION: acpi_ut_execute_HID
395 *
396 * PARAMETERS: device_node - Node for the device
397 * Hid - Where the HID is returned
398 *
399 * RETURN: Status
400 *
401 * DESCRIPTION: Executes the _HID control method that returns the hardware
402 * ID of the device.
403 *
404 * NOTE: Internal function, no parameter validation
405 *
406 ******************************************************************************/
407
408acpi_status
409acpi_ut_execute_HID(struct acpi_namespace_node *device_node,
410 struct acpica_device_id *hid)
411{
412 union acpi_operand_object *obj_desc;
413 acpi_status status;
414
415 ACPI_FUNCTION_TRACE(ut_execute_HID);
416
417 status = acpi_ut_evaluate_object(device_node, METHOD_NAME__HID,
418 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING,
419 &obj_desc);
420 if (ACPI_FAILURE(status)) {
421 return_ACPI_STATUS(status);
422 }
423
424 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
425
426 /* Convert the Numeric HID to string */
427
428 acpi_ex_eisa_id_to_string((u32) obj_desc->integer.value,
429 hid->value);
430 } else {
431 /* Copy the String HID from the returned object */
432
433 acpi_ut_copy_id_string(hid->value, obj_desc->string.pointer,
434 sizeof(hid->value));
435 }
436
437 /* On exit, we must delete the return object */
438
439 acpi_ut_remove_reference(obj_desc);
440 return_ACPI_STATUS(status);
441}
442
443/*******************************************************************************
444 *
445 * FUNCTION: acpi_ut_translate_one_cid
446 *
447 * PARAMETERS: obj_desc - _CID object, must be integer or string
448 * one_cid - Where the CID string is returned
449 *
450 * RETURN: Status
451 *
452 * DESCRIPTION: Return a numeric or string _CID value as a string.
453 * (Compatible ID)
454 *
455 * NOTE: Assumes a maximum _CID string length of
456 * ACPI_MAX_CID_LENGTH.
457 *
458 ******************************************************************************/
459
460static acpi_status
461acpi_ut_translate_one_cid(union acpi_operand_object *obj_desc,
462 struct acpi_compatible_id *one_cid)
463{
464
465 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
466 case ACPI_TYPE_INTEGER:
467
468 /* Convert the Numeric CID to string */
469
470 acpi_ex_eisa_id_to_string((u32) obj_desc->integer.value,
471 one_cid->value);
472 return (AE_OK);
473
474 case ACPI_TYPE_STRING:
475
476 if (obj_desc->string.length > ACPI_MAX_CID_LENGTH) {
477 return (AE_AML_STRING_LIMIT);
478 }
479
480 /* Copy the String CID from the returned object */
481
482 acpi_ut_copy_id_string(one_cid->value, obj_desc->string.pointer,
483 ACPI_MAX_CID_LENGTH);
484 return (AE_OK);
485
486 default:
487
488 return (AE_TYPE);
489 }
490}
491
492/*******************************************************************************
493 *
494 * FUNCTION: acpi_ut_execute_CID
495 *
496 * PARAMETERS: device_node - Node for the device
497 * return_cid_list - Where the CID list is returned
498 *
499 * RETURN: Status
500 *
501 * DESCRIPTION: Executes the _CID control method that returns one or more
502 * compatible hardware IDs for the device.
503 *
504 * NOTE: Internal function, no parameter validation
505 *
506 ******************************************************************************/
507
508acpi_status
509acpi_ut_execute_CID(struct acpi_namespace_node * device_node,
510 struct acpi_compatible_id_list ** return_cid_list)
511{
512 union acpi_operand_object *obj_desc;
513 acpi_status status;
514 u32 count;
515 u32 size;
516 struct acpi_compatible_id_list *cid_list;
517 u32 i;
518
519 ACPI_FUNCTION_TRACE(ut_execute_CID);
520
521 /* Evaluate the _CID method for this device */
522
523 status = acpi_ut_evaluate_object(device_node, METHOD_NAME__CID,
524 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING
525 | ACPI_BTYPE_PACKAGE, &obj_desc);
526 if (ACPI_FAILURE(status)) {
527 return_ACPI_STATUS(status);
528 }
529
530 /* Get the number of _CIDs returned */
531
532 count = 1;
533 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) {
534 count = obj_desc->package.count;
535 }
536
537 /* Allocate a worst-case buffer for the _CIDs */
538
539 size = (((count - 1) * sizeof(struct acpi_compatible_id)) +
540 sizeof(struct acpi_compatible_id_list));
541
542 cid_list = ACPI_ALLOCATE_ZEROED((acpi_size) size);
543 if (!cid_list) {
544 return_ACPI_STATUS(AE_NO_MEMORY);
545 }
546
547 /* Init CID list */
548
549 cid_list->count = count;
550 cid_list->size = size;
551
552 /*
553 * A _CID can return either a single compatible ID or a package of
554 * compatible IDs. Each compatible ID can be one of the following:
555 * 1) Integer (32 bit compressed EISA ID) or
556 * 2) String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss")
557 */
558
559 /* The _CID object can be either a single CID or a package (list) of CIDs */
560
561 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) {
562
563 /* Translate each package element */
564
565 for (i = 0; i < count; i++) {
566 status =
567 acpi_ut_translate_one_cid(obj_desc->package.
568 elements[i],
569 &cid_list->id[i]);
570 if (ACPI_FAILURE(status)) {
571 break;
572 }
573 }
574 } else {
575 /* Only one CID, translate to a string */
576
577 status = acpi_ut_translate_one_cid(obj_desc, cid_list->id);
578 }
579
580 /* Cleanup on error */
581
582 if (ACPI_FAILURE(status)) {
583 ACPI_FREE(cid_list);
584 } else {
585 *return_cid_list = cid_list;
586 }
587
588 /* On exit, we must delete the _CID return object */
589
590 acpi_ut_remove_reference(obj_desc);
591 return_ACPI_STATUS(status);
592}
593
594/*******************************************************************************
595 *
596 * FUNCTION: acpi_ut_execute_UID
597 *
598 * PARAMETERS: device_node - Node for the device
599 * Uid - Where the UID is returned
600 *
601 * RETURN: Status
602 *
603 * DESCRIPTION: Executes the _UID control method that returns the hardware
604 * ID of the device.
605 *
606 * NOTE: Internal function, no parameter validation
607 *
608 ******************************************************************************/
609
610acpi_status
611acpi_ut_execute_UID(struct acpi_namespace_node *device_node,
612 struct acpica_device_id *uid)
613{
614 union acpi_operand_object *obj_desc;
615 acpi_status status;
616
617 ACPI_FUNCTION_TRACE(ut_execute_UID);
618
619 status = acpi_ut_evaluate_object(device_node, METHOD_NAME__UID,
620 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING,
621 &obj_desc);
622 if (ACPI_FAILURE(status)) {
623 return_ACPI_STATUS(status);
624 }
625
626 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
627
628 /* Convert the Numeric UID to string */
629
630 acpi_ex_unsigned_integer_to_string(obj_desc->integer.value,
631 uid->value);
632 } else {
633 /* Copy the String UID from the returned object */
634
635 acpi_ut_copy_id_string(uid->value, obj_desc->string.pointer,
636 sizeof(uid->value));
637 }
638
639 /* On exit, we must delete the return object */
640
641 acpi_ut_remove_reference(obj_desc);
642 return_ACPI_STATUS(status);
643}
644
645/*******************************************************************************
646 *
647 * FUNCTION: acpi_ut_execute_STA
648 *
649 * PARAMETERS: device_node - Node for the device
650 * Flags - Where the status flags are returned
651 *
652 * RETURN: Status
653 *
654 * DESCRIPTION: Executes _STA for selected device and stores results in
655 * *Flags.
656 *
657 * NOTE: Internal function, no parameter validation
658 *
659 ******************************************************************************/
660
661acpi_status
662acpi_ut_execute_STA(struct acpi_namespace_node *device_node, u32 * flags)
663{
664 union acpi_operand_object *obj_desc;
665 acpi_status status;
666
667 ACPI_FUNCTION_TRACE(ut_execute_STA);
668
669 status = acpi_ut_evaluate_object(device_node, METHOD_NAME__STA,
670 ACPI_BTYPE_INTEGER, &obj_desc);
671 if (ACPI_FAILURE(status)) {
672 if (AE_NOT_FOUND == status) {
673 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
674 "_STA on %4.4s was not found, assuming device is present\n",
675 acpi_ut_get_node_name(device_node)));
676
677 *flags = ACPI_UINT32_MAX;
678 status = AE_OK;
679 }
680
681 return_ACPI_STATUS(status);
682 }
683
684 /* Extract the status flags */
685
686 *flags = (u32) obj_desc->integer.value;
687
688 /* On exit, we must delete the return object */
689
690 acpi_ut_remove_reference(obj_desc);
691 return_ACPI_STATUS(status);
692}
693
694/*******************************************************************************
695 *
696 * FUNCTION: acpi_ut_execute_Sxds
697 *
698 * PARAMETERS: device_node - Node for the device
699 * Flags - Where the status flags are returned
700 *
701 * RETURN: Status
702 *
703 * DESCRIPTION: Executes _STA for selected device and stores results in
704 * *Flags.
705 *
706 * NOTE: Internal function, no parameter validation
707 *
708 ******************************************************************************/
709
710acpi_status
711acpi_ut_execute_sxds(struct acpi_namespace_node *device_node, u8 * highest)
712{
713 union acpi_operand_object *obj_desc;
714 acpi_status status;
715 u32 i;
716
717 ACPI_FUNCTION_TRACE(ut_execute_sxds);
718
719 for (i = 0; i < 4; i++) {
720 highest[i] = 0xFF;
721 status = acpi_ut_evaluate_object(device_node,
722 ACPI_CAST_PTR(char,
723 acpi_gbl_highest_dstate_names
724 [i]),
725 ACPI_BTYPE_INTEGER, &obj_desc);
726 if (ACPI_FAILURE(status)) {
727 if (status != AE_NOT_FOUND) {
728 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
729 "%s on Device %4.4s, %s\n",
730 ACPI_CAST_PTR(char,
731 acpi_gbl_highest_dstate_names
732 [i]),
733 acpi_ut_get_node_name
734 (device_node),
735 acpi_format_exception
736 (status)));
737
738 return_ACPI_STATUS(status);
739 }
740 } else {
741 /* Extract the Dstate value */
742
743 highest[i] = (u8) obj_desc->integer.value;
744
745 /* Delete the return object */
746
747 acpi_ut_remove_reference(obj_desc);
748 }
749 }
750
751 return_ACPI_STATUS(AE_OK);
752}
diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c
deleted file mode 100644
index 3e28d8c4045d..000000000000
--- a/drivers/acpi/utilities/utglobal.c
+++ /dev/null
@@ -1,823 +0,0 @@
1/******************************************************************************
2 *
3 * Module Name: utglobal - Global variables for the ACPI subsystem
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#define DEFINE_ACPI_GLOBALS
45
46#include <acpi/acpi.h>
47#include <acpi/accommon.h>
48#include <acpi/acnamesp.h>
49
50#define _COMPONENT ACPI_UTILITIES
51ACPI_MODULE_NAME("utglobal")
52
53/*******************************************************************************
54 *
55 * Static global variable initialization.
56 *
57 ******************************************************************************/
58/*
59 * We want the debug switches statically initialized so they
60 * are already set when the debugger is entered.
61 */
62/* Debug switch - level and trace mask */
63u32 acpi_dbg_level = ACPI_DEBUG_DEFAULT;
64
65/* Debug switch - layer (component) mask */
66
67u32 acpi_dbg_layer = 0;
68u32 acpi_gbl_nesting_level = 0;
69
70/* Debugger globals */
71
72u8 acpi_gbl_db_terminate_threads = FALSE;
73u8 acpi_gbl_abort_method = FALSE;
74u8 acpi_gbl_method_executing = FALSE;
75
76/* System flags */
77
78u32 acpi_gbl_startup_flags = 0;
79
80/* System starts uninitialized */
81
82u8 acpi_gbl_shutdown = TRUE;
83
84const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT] = {
85 "\\_S0_",
86 "\\_S1_",
87 "\\_S2_",
88 "\\_S3_",
89 "\\_S4_",
90 "\\_S5_"
91};
92
93const char *acpi_gbl_highest_dstate_names[4] = {
94 "_S1D",
95 "_S2D",
96 "_S3D",
97 "_S4D"
98};
99
100/*******************************************************************************
101 *
102 * FUNCTION: acpi_format_exception
103 *
104 * PARAMETERS: Status - The acpi_status code to be formatted
105 *
106 * RETURN: A string containing the exception text. A valid pointer is
107 * always returned.
108 *
109 * DESCRIPTION: This function translates an ACPI exception into an ASCII string
110 * It is here instead of utxface.c so it is always present.
111 *
112 ******************************************************************************/
113
114const char *acpi_format_exception(acpi_status status)
115{
116 const char *exception = NULL;
117
118 ACPI_FUNCTION_ENTRY();
119
120 exception = acpi_ut_validate_exception(status);
121 if (!exception) {
122
123 /* Exception code was not recognized */
124
125 ACPI_ERROR((AE_INFO,
126 "Unknown exception code: 0x%8.8X", status));
127
128 exception = "UNKNOWN_STATUS_CODE";
129 dump_stack();
130 }
131
132 return (ACPI_CAST_PTR(const char, exception));
133}
134
135ACPI_EXPORT_SYMBOL(acpi_format_exception)
136
137/*******************************************************************************
138 *
139 * Namespace globals
140 *
141 ******************************************************************************/
142/*
143 * Predefined ACPI Names (Built-in to the Interpreter)
144 *
145 * NOTES:
146 * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run
147 * during the initialization sequence.
148 * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to
149 * perform a Notify() operation on it.
150 */
151const struct acpi_predefined_names acpi_gbl_pre_defined_names[] = {
152 {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL},
153 {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL},
154 {"_SB_", ACPI_TYPE_DEVICE, NULL},
155 {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL},
156 {"_TZ_", ACPI_TYPE_THERMAL, NULL},
157 {"_REV", ACPI_TYPE_INTEGER, (char *)ACPI_CA_SUPPORT_LEVEL},
158 {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME},
159 {"_GL_", ACPI_TYPE_MUTEX, (char *)1},
160
161#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
162 {"_OSI", ACPI_TYPE_METHOD, (char *)1},
163#endif
164
165 /* Table terminator */
166
167 {NULL, ACPI_TYPE_ANY, NULL}
168};
169
170/*
171 * Properties of the ACPI Object Types, both internal and external.
172 * The table is indexed by values of acpi_object_type
173 */
174const u8 acpi_gbl_ns_properties[] = {
175 ACPI_NS_NORMAL, /* 00 Any */
176 ACPI_NS_NORMAL, /* 01 Number */
177 ACPI_NS_NORMAL, /* 02 String */
178 ACPI_NS_NORMAL, /* 03 Buffer */
179 ACPI_NS_NORMAL, /* 04 Package */
180 ACPI_NS_NORMAL, /* 05 field_unit */
181 ACPI_NS_NEWSCOPE, /* 06 Device */
182 ACPI_NS_NORMAL, /* 07 Event */
183 ACPI_NS_NEWSCOPE, /* 08 Method */
184 ACPI_NS_NORMAL, /* 09 Mutex */
185 ACPI_NS_NORMAL, /* 10 Region */
186 ACPI_NS_NEWSCOPE, /* 11 Power */
187 ACPI_NS_NEWSCOPE, /* 12 Processor */
188 ACPI_NS_NEWSCOPE, /* 13 Thermal */
189 ACPI_NS_NORMAL, /* 14 buffer_field */
190 ACPI_NS_NORMAL, /* 15 ddb_handle */
191 ACPI_NS_NORMAL, /* 16 Debug Object */
192 ACPI_NS_NORMAL, /* 17 def_field */
193 ACPI_NS_NORMAL, /* 18 bank_field */
194 ACPI_NS_NORMAL, /* 19 index_field */
195 ACPI_NS_NORMAL, /* 20 Reference */
196 ACPI_NS_NORMAL, /* 21 Alias */
197 ACPI_NS_NORMAL, /* 22 method_alias */
198 ACPI_NS_NORMAL, /* 23 Notify */
199 ACPI_NS_NORMAL, /* 24 Address Handler */
200 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */
201 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */
202 ACPI_NS_NEWSCOPE, /* 27 Scope */
203 ACPI_NS_NORMAL, /* 28 Extra */
204 ACPI_NS_NORMAL, /* 29 Data */
205 ACPI_NS_NORMAL /* 30 Invalid */
206};
207
208/* Hex to ASCII conversion table */
209
210static const char acpi_gbl_hex_to_ascii[] = {
211 '0', '1', '2', '3', '4', '5', '6', '7',
212 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
213};
214
215/*******************************************************************************
216 *
217 * FUNCTION: acpi_ut_hex_to_ascii_char
218 *
219 * PARAMETERS: Integer - Contains the hex digit
220 * Position - bit position of the digit within the
221 * integer (multiple of 4)
222 *
223 * RETURN: The converted Ascii character
224 *
225 * DESCRIPTION: Convert a hex digit to an Ascii character
226 *
227 ******************************************************************************/
228
229char acpi_ut_hex_to_ascii_char(acpi_integer integer, u32 position)
230{
231
232 return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]);
233}
234
235/******************************************************************************
236 *
237 * Event and Hardware globals
238 *
239 ******************************************************************************/
240
241struct acpi_bit_register_info acpi_gbl_bit_register_info[ACPI_NUM_BITREG] = {
242 /* Name Parent Register Register Bit Position Register Bit Mask */
243
244 /* ACPI_BITREG_TIMER_STATUS */ {ACPI_REGISTER_PM1_STATUS,
245 ACPI_BITPOSITION_TIMER_STATUS,
246 ACPI_BITMASK_TIMER_STATUS},
247 /* ACPI_BITREG_BUS_MASTER_STATUS */ {ACPI_REGISTER_PM1_STATUS,
248 ACPI_BITPOSITION_BUS_MASTER_STATUS,
249 ACPI_BITMASK_BUS_MASTER_STATUS},
250 /* ACPI_BITREG_GLOBAL_LOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS,
251 ACPI_BITPOSITION_GLOBAL_LOCK_STATUS,
252 ACPI_BITMASK_GLOBAL_LOCK_STATUS},
253 /* ACPI_BITREG_POWER_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS,
254 ACPI_BITPOSITION_POWER_BUTTON_STATUS,
255 ACPI_BITMASK_POWER_BUTTON_STATUS},
256 /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS,
257 ACPI_BITPOSITION_SLEEP_BUTTON_STATUS,
258 ACPI_BITMASK_SLEEP_BUTTON_STATUS},
259 /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS,
260 ACPI_BITPOSITION_RT_CLOCK_STATUS,
261 ACPI_BITMASK_RT_CLOCK_STATUS},
262 /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS,
263 ACPI_BITPOSITION_WAKE_STATUS,
264 ACPI_BITMASK_WAKE_STATUS},
265 /* ACPI_BITREG_PCIEXP_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS,
266 ACPI_BITPOSITION_PCIEXP_WAKE_STATUS,
267 ACPI_BITMASK_PCIEXP_WAKE_STATUS},
268
269 /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
270 ACPI_BITPOSITION_TIMER_ENABLE,
271 ACPI_BITMASK_TIMER_ENABLE},
272 /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
273 ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE,
274 ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
275 /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
276 ACPI_BITPOSITION_POWER_BUTTON_ENABLE,
277 ACPI_BITMASK_POWER_BUTTON_ENABLE},
278 /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
279 ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE,
280 ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
281 /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
282 ACPI_BITPOSITION_RT_CLOCK_ENABLE,
283 ACPI_BITMASK_RT_CLOCK_ENABLE},
284 /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE,
285 ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE,
286 ACPI_BITMASK_PCIEXP_WAKE_DISABLE},
287
288 /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL,
289 ACPI_BITPOSITION_SCI_ENABLE,
290 ACPI_BITMASK_SCI_ENABLE},
291 /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL,
292 ACPI_BITPOSITION_BUS_MASTER_RLD,
293 ACPI_BITMASK_BUS_MASTER_RLD},
294 /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL,
295 ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE,
296 ACPI_BITMASK_GLOBAL_LOCK_RELEASE},
297 /* ACPI_BITREG_SLEEP_TYPE_A */ {ACPI_REGISTER_PM1_CONTROL,
298 ACPI_BITPOSITION_SLEEP_TYPE_X,
299 ACPI_BITMASK_SLEEP_TYPE_X},
300 /* ACPI_BITREG_SLEEP_TYPE_B */ {ACPI_REGISTER_PM1_CONTROL,
301 ACPI_BITPOSITION_SLEEP_TYPE_X,
302 ACPI_BITMASK_SLEEP_TYPE_X},
303 /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL,
304 ACPI_BITPOSITION_SLEEP_ENABLE,
305 ACPI_BITMASK_SLEEP_ENABLE},
306
307 /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL,
308 ACPI_BITPOSITION_ARB_DISABLE,
309 ACPI_BITMASK_ARB_DISABLE}
310};
311
312struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] = {
313 /* ACPI_EVENT_PMTIMER */ {ACPI_BITREG_TIMER_STATUS,
314 ACPI_BITREG_TIMER_ENABLE,
315 ACPI_BITMASK_TIMER_STATUS,
316 ACPI_BITMASK_TIMER_ENABLE},
317 /* ACPI_EVENT_GLOBAL */ {ACPI_BITREG_GLOBAL_LOCK_STATUS,
318 ACPI_BITREG_GLOBAL_LOCK_ENABLE,
319 ACPI_BITMASK_GLOBAL_LOCK_STATUS,
320 ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
321 /* ACPI_EVENT_POWER_BUTTON */ {ACPI_BITREG_POWER_BUTTON_STATUS,
322 ACPI_BITREG_POWER_BUTTON_ENABLE,
323 ACPI_BITMASK_POWER_BUTTON_STATUS,
324 ACPI_BITMASK_POWER_BUTTON_ENABLE},
325 /* ACPI_EVENT_SLEEP_BUTTON */ {ACPI_BITREG_SLEEP_BUTTON_STATUS,
326 ACPI_BITREG_SLEEP_BUTTON_ENABLE,
327 ACPI_BITMASK_SLEEP_BUTTON_STATUS,
328 ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
329 /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS,
330 ACPI_BITREG_RT_CLOCK_ENABLE,
331 ACPI_BITMASK_RT_CLOCK_STATUS,
332 ACPI_BITMASK_RT_CLOCK_ENABLE},
333};
334
335/*******************************************************************************
336 *
337 * FUNCTION: acpi_ut_get_region_name
338 *
339 * PARAMETERS: None.
340 *
341 * RETURN: Status
342 *
343 * DESCRIPTION: Translate a Space ID into a name string (Debug only)
344 *
345 ******************************************************************************/
346
347/* Region type decoding */
348
349const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = {
350 "SystemMemory",
351 "SystemIO",
352 "PCI_Config",
353 "EmbeddedControl",
354 "SMBus",
355 "SystemCMOS",
356 "PCIBARTarget",
357 "DataTable"
358};
359
360char *acpi_ut_get_region_name(u8 space_id)
361{
362
363 if (space_id >= ACPI_USER_REGION_BEGIN) {
364 return ("UserDefinedRegion");
365 } else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS) {
366 return ("InvalidSpaceId");
367 }
368
369 return (ACPI_CAST_PTR(char, acpi_gbl_region_types[space_id]));
370}
371
372/*******************************************************************************
373 *
374 * FUNCTION: acpi_ut_get_event_name
375 *
376 * PARAMETERS: None.
377 *
378 * RETURN: Status
379 *
380 * DESCRIPTION: Translate a Event ID into a name string (Debug only)
381 *
382 ******************************************************************************/
383
384/* Event type decoding */
385
386static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = {
387 "PM_Timer",
388 "GlobalLock",
389 "PowerButton",
390 "SleepButton",
391 "RealTimeClock",
392};
393
394char *acpi_ut_get_event_name(u32 event_id)
395{
396
397 if (event_id > ACPI_EVENT_MAX) {
398 return ("InvalidEventID");
399 }
400
401 return (ACPI_CAST_PTR(char, acpi_gbl_event_types[event_id]));
402}
403
404/*******************************************************************************
405 *
406 * FUNCTION: acpi_ut_get_type_name
407 *
408 * PARAMETERS: None.
409 *
410 * RETURN: Status
411 *
412 * DESCRIPTION: Translate a Type ID into a name string (Debug only)
413 *
414 ******************************************************************************/
415
416/*
417 * Elements of acpi_gbl_ns_type_names below must match
418 * one-to-one with values of acpi_object_type
419 *
420 * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching;
421 * when stored in a table it really means that we have thus far seen no
422 * evidence to indicate what type is actually going to be stored for this entry.
423 */
424static const char acpi_gbl_bad_type[] = "UNDEFINED";
425
426/* Printable names of the ACPI object types */
427
428static const char *acpi_gbl_ns_type_names[] = {
429 /* 00 */ "Untyped",
430 /* 01 */ "Integer",
431 /* 02 */ "String",
432 /* 03 */ "Buffer",
433 /* 04 */ "Package",
434 /* 05 */ "FieldUnit",
435 /* 06 */ "Device",
436 /* 07 */ "Event",
437 /* 08 */ "Method",
438 /* 09 */ "Mutex",
439 /* 10 */ "Region",
440 /* 11 */ "Power",
441 /* 12 */ "Processor",
442 /* 13 */ "Thermal",
443 /* 14 */ "BufferField",
444 /* 15 */ "DdbHandle",
445 /* 16 */ "DebugObject",
446 /* 17 */ "RegionField",
447 /* 18 */ "BankField",
448 /* 19 */ "IndexField",
449 /* 20 */ "Reference",
450 /* 21 */ "Alias",
451 /* 22 */ "MethodAlias",
452 /* 23 */ "Notify",
453 /* 24 */ "AddrHandler",
454 /* 25 */ "ResourceDesc",
455 /* 26 */ "ResourceFld",
456 /* 27 */ "Scope",
457 /* 28 */ "Extra",
458 /* 29 */ "Data",
459 /* 30 */ "Invalid"
460};
461
462char *acpi_ut_get_type_name(acpi_object_type type)
463{
464
465 if (type > ACPI_TYPE_INVALID) {
466 return (ACPI_CAST_PTR(char, acpi_gbl_bad_type));
467 }
468
469 return (ACPI_CAST_PTR(char, acpi_gbl_ns_type_names[type]));
470}
471
472char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc)
473{
474
475 if (!obj_desc) {
476 return ("[NULL Object Descriptor]");
477 }
478
479 return (acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE(obj_desc)));
480}
481
482/*******************************************************************************
483 *
484 * FUNCTION: acpi_ut_get_node_name
485 *
486 * PARAMETERS: Object - A namespace node
487 *
488 * RETURN: Pointer to a string
489 *
490 * DESCRIPTION: Validate the node and return the node's ACPI name.
491 *
492 ******************************************************************************/
493
494char *acpi_ut_get_node_name(void *object)
495{
496 struct acpi_namespace_node *node = (struct acpi_namespace_node *)object;
497
498 /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */
499
500 if (!object) {
501 return ("NULL");
502 }
503
504 /* Check for Root node */
505
506 if ((object == ACPI_ROOT_OBJECT) || (object == acpi_gbl_root_node)) {
507 return ("\"\\\" ");
508 }
509
510 /* Descriptor must be a namespace node */
511
512 if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) {
513 return ("####");
514 }
515
516 /* Name must be a valid ACPI name */
517
518 if (!acpi_ut_valid_acpi_name(node->name.integer)) {
519 node->name.integer = acpi_ut_repair_name(node->name.ascii);
520 }
521
522 /* Return the name */
523
524 return (node->name.ascii);
525}
526
527/*******************************************************************************
528 *
529 * FUNCTION: acpi_ut_get_descriptor_name
530 *
531 * PARAMETERS: Object - An ACPI object
532 *
533 * RETURN: Pointer to a string
534 *
535 * DESCRIPTION: Validate object and return the descriptor type
536 *
537 ******************************************************************************/
538
539/* Printable names of object descriptor types */
540
541static const char *acpi_gbl_desc_type_names[] = {
542 /* 00 */ "Invalid",
543 /* 01 */ "Cached",
544 /* 02 */ "State-Generic",
545 /* 03 */ "State-Update",
546 /* 04 */ "State-Package",
547 /* 05 */ "State-Control",
548 /* 06 */ "State-RootParseScope",
549 /* 07 */ "State-ParseScope",
550 /* 08 */ "State-WalkScope",
551 /* 09 */ "State-Result",
552 /* 10 */ "State-Notify",
553 /* 11 */ "State-Thread",
554 /* 12 */ "Walk",
555 /* 13 */ "Parser",
556 /* 14 */ "Operand",
557 /* 15 */ "Node"
558};
559
560char *acpi_ut_get_descriptor_name(void *object)
561{
562
563 if (!object) {
564 return ("NULL OBJECT");
565 }
566
567 if (ACPI_GET_DESCRIPTOR_TYPE(object) > ACPI_DESC_TYPE_MAX) {
568 return (ACPI_CAST_PTR(char, acpi_gbl_bad_type));
569 }
570
571 return (ACPI_CAST_PTR(char,
572 acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE
573 (object)]));
574
575}
576
577/*******************************************************************************
578 *
579 * FUNCTION: acpi_ut_get_reference_name
580 *
581 * PARAMETERS: Object - An ACPI reference object
582 *
583 * RETURN: Pointer to a string
584 *
585 * DESCRIPTION: Decode a reference object sub-type to a string.
586 *
587 ******************************************************************************/
588
589/* Printable names of reference object sub-types */
590
591static const char *acpi_gbl_ref_class_names[] = {
592 /* 00 */ "Local",
593 /* 01 */ "Argument",
594 /* 02 */ "RefOf",
595 /* 03 */ "Index",
596 /* 04 */ "DdbHandle",
597 /* 05 */ "Named Object",
598 /* 06 */ "Debug"
599};
600
601const char *acpi_ut_get_reference_name(union acpi_operand_object *object)
602{
603 if (!object)
604 return "NULL Object";
605
606 if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND)
607 return "Not an Operand object";
608
609 if (object->common.type != ACPI_TYPE_LOCAL_REFERENCE)
610 return "Not a Reference object";
611
612 if (object->reference.class > ACPI_REFCLASS_MAX)
613 return "Unknown Reference class";
614
615 return acpi_gbl_ref_class_names[object->reference.class];
616}
617
618#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
619/*
620 * Strings and procedures used for debug only
621 */
622
623/*******************************************************************************
624 *
625 * FUNCTION: acpi_ut_get_mutex_name
626 *
627 * PARAMETERS: mutex_id - The predefined ID for this mutex.
628 *
629 * RETURN: String containing the name of the mutex. Always returns a valid
630 * pointer.
631 *
632 * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
633 *
634 ******************************************************************************/
635
636char *acpi_ut_get_mutex_name(u32 mutex_id)
637{
638
639 if (mutex_id > ACPI_MAX_MUTEX) {
640 return ("Invalid Mutex ID");
641 }
642
643 return (acpi_gbl_mutex_names[mutex_id]);
644}
645
646/*******************************************************************************
647 *
648 * FUNCTION: acpi_ut_get_notify_name
649 *
650 * PARAMETERS: notify_value - Value from the Notify() request
651 *
652 * RETURN: String corresponding to the Notify Value.
653 *
654 * DESCRIPTION: Translate a Notify Value to a notify namestring.
655 *
656 ******************************************************************************/
657
658/* Names for Notify() values, used for debug output */
659
660static const char *acpi_gbl_notify_value_names[] = {
661 "Bus Check",
662 "Device Check",
663 "Device Wake",
664 "Eject Request",
665 "Device Check Light",
666 "Frequency Mismatch",
667 "Bus Mode Mismatch",
668 "Power Fault",
669 "Capabilities Check",
670 "Device PLD Check",
671 "Reserved",
672 "System Locality Update"
673};
674
675const char *acpi_ut_get_notify_name(u32 notify_value)
676{
677
678 if (notify_value <= ACPI_NOTIFY_MAX) {
679 return (acpi_gbl_notify_value_names[notify_value]);
680 } else if (notify_value <= ACPI_MAX_SYS_NOTIFY) {
681 return ("Reserved");
682 } else { /* Greater or equal to 0x80 */
683
684 return ("**Device Specific**");
685 }
686}
687#endif
688
689/*******************************************************************************
690 *
691 * FUNCTION: acpi_ut_valid_object_type
692 *
693 * PARAMETERS: Type - Object type to be validated
694 *
695 * RETURN: TRUE if valid object type, FALSE otherwise
696 *
697 * DESCRIPTION: Validate an object type
698 *
699 ******************************************************************************/
700
701u8 acpi_ut_valid_object_type(acpi_object_type type)
702{
703
704 if (type > ACPI_TYPE_LOCAL_MAX) {
705
706 /* Note: Assumes all TYPEs are contiguous (external/local) */
707
708 return (FALSE);
709 }
710
711 return (TRUE);
712}
713
714/*******************************************************************************
715 *
716 * FUNCTION: acpi_ut_init_globals
717 *
718 * PARAMETERS: None
719 *
720 * RETURN: Status
721 *
722 * DESCRIPTION: Init library globals. All globals that require specific
723 * initialization should be initialized here!
724 *
725 ******************************************************************************/
726
727acpi_status acpi_ut_init_globals(void)
728{
729 acpi_status status;
730 u32 i;
731
732 ACPI_FUNCTION_TRACE(ut_init_globals);
733
734 /* Create all memory caches */
735
736 status = acpi_ut_create_caches();
737 if (ACPI_FAILURE(status)) {
738 return_ACPI_STATUS(status);
739 }
740
741 /* Mutex locked flags */
742
743 for (i = 0; i < ACPI_NUM_MUTEX; i++) {
744 acpi_gbl_mutex_info[i].mutex = NULL;
745 acpi_gbl_mutex_info[i].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
746 acpi_gbl_mutex_info[i].use_count = 0;
747 }
748
749 for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) {
750 acpi_gbl_owner_id_mask[i] = 0;
751 }
752 acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000; /* Last ID is never valid */
753
754 /* GPE support */
755
756 acpi_gbl_gpe_xrupt_list_head = NULL;
757 acpi_gbl_gpe_fadt_blocks[0] = NULL;
758 acpi_gbl_gpe_fadt_blocks[1] = NULL;
759 acpi_current_gpe_count = 0;
760
761 /* Global handlers */
762
763 acpi_gbl_system_notify.handler = NULL;
764 acpi_gbl_device_notify.handler = NULL;
765 acpi_gbl_exception_handler = NULL;
766 acpi_gbl_init_handler = NULL;
767 acpi_gbl_table_handler = NULL;
768
769 /* Global Lock support */
770
771 acpi_gbl_global_lock_semaphore = NULL;
772 acpi_gbl_global_lock_mutex = NULL;
773 acpi_gbl_global_lock_acquired = FALSE;
774 acpi_gbl_global_lock_handle = 0;
775 acpi_gbl_global_lock_present = FALSE;
776
777 /* Miscellaneous variables */
778
779 acpi_gbl_cm_single_step = FALSE;
780 acpi_gbl_db_terminate_threads = FALSE;
781 acpi_gbl_shutdown = FALSE;
782 acpi_gbl_ns_lookup_count = 0;
783 acpi_gbl_ps_find_count = 0;
784 acpi_gbl_acpi_hardware_present = TRUE;
785 acpi_gbl_last_owner_id_index = 0;
786 acpi_gbl_next_owner_id_offset = 0;
787 acpi_gbl_trace_method_name = 0;
788 acpi_gbl_trace_dbg_level = 0;
789 acpi_gbl_trace_dbg_layer = 0;
790 acpi_gbl_debugger_configuration = DEBUGGER_THREADING;
791 acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT;
792
793 /* Hardware oriented */
794
795 acpi_gbl_events_initialized = FALSE;
796 acpi_gbl_system_awake_and_running = TRUE;
797
798 /* Namespace */
799
800 acpi_gbl_root_node = NULL;
801 acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME;
802 acpi_gbl_root_node_struct.descriptor_type = ACPI_DESC_TYPE_NAMED;
803 acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE;
804 acpi_gbl_root_node_struct.child = NULL;
805 acpi_gbl_root_node_struct.peer = NULL;
806 acpi_gbl_root_node_struct.object = NULL;
807 acpi_gbl_root_node_struct.flags = ANOBJ_END_OF_PEER_LIST;
808
809#ifdef ACPI_DEBUG_OUTPUT
810 acpi_gbl_lowest_stack_pointer = ACPI_CAST_PTR(acpi_size, ACPI_SIZE_MAX);
811#endif
812
813#ifdef ACPI_DBG_TRACK_ALLOCATIONS
814 acpi_gbl_display_final_mem_stats = FALSE;
815#endif
816
817 return_ACPI_STATUS(AE_OK);
818}
819
820ACPI_EXPORT_SYMBOL(acpi_gbl_FADT)
821ACPI_EXPORT_SYMBOL(acpi_dbg_level)
822ACPI_EXPORT_SYMBOL(acpi_dbg_layer)
823ACPI_EXPORT_SYMBOL(acpi_current_gpe_count)
diff --git a/drivers/acpi/utilities/utinit.c b/drivers/acpi/utilities/utinit.c
deleted file mode 100644
index 9316ec36a836..000000000000
--- a/drivers/acpi/utilities/utinit.c
+++ /dev/null
@@ -1,152 +0,0 @@
1/******************************************************************************
2 *
3 * Module Name: utinit - Common ACPI subsystem initialization
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include <acpi/accommon.h>
46#include <acpi/acnamesp.h>
47#include <acpi/acevents.h>
48#include <acpi/actables.h>
49
50#define _COMPONENT ACPI_UTILITIES
51ACPI_MODULE_NAME("utinit")
52
53/* Local prototypes */
54static void acpi_ut_terminate(void);
55
56/******************************************************************************
57 *
58 * FUNCTION: acpi_ut_terminate
59 *
60 * PARAMETERS: none
61 *
62 * RETURN: none
63 *
64 * DESCRIPTION: Free global memory
65 *
66 ******************************************************************************/
67
68static void acpi_ut_terminate(void)
69{
70 struct acpi_gpe_block_info *gpe_block;
71 struct acpi_gpe_block_info *next_gpe_block;
72 struct acpi_gpe_xrupt_info *gpe_xrupt_info;
73 struct acpi_gpe_xrupt_info *next_gpe_xrupt_info;
74
75 ACPI_FUNCTION_TRACE(ut_terminate);
76
77 /* Free global GPE blocks and related info structures */
78
79 gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head;
80 while (gpe_xrupt_info) {
81 gpe_block = gpe_xrupt_info->gpe_block_list_head;
82 while (gpe_block) {
83 next_gpe_block = gpe_block->next;
84 ACPI_FREE(gpe_block->event_info);
85 ACPI_FREE(gpe_block->register_info);
86 ACPI_FREE(gpe_block);
87
88 gpe_block = next_gpe_block;
89 }
90 next_gpe_xrupt_info = gpe_xrupt_info->next;
91 ACPI_FREE(gpe_xrupt_info);
92 gpe_xrupt_info = next_gpe_xrupt_info;
93 }
94
95 return_VOID;
96}
97
98/*******************************************************************************
99 *
100 * FUNCTION: acpi_ut_subsystem_shutdown
101 *
102 * PARAMETERS: none
103 *
104 * RETURN: none
105 *
106 * DESCRIPTION: Shutdown the various subsystems. Don't delete the mutex
107 * objects here -- because the AML debugger may be still running.
108 *
109 ******************************************************************************/
110
111void acpi_ut_subsystem_shutdown(void)
112{
113
114 ACPI_FUNCTION_TRACE(ut_subsystem_shutdown);
115
116 /* Just exit if subsystem is already shutdown */
117
118 if (acpi_gbl_shutdown) {
119 ACPI_ERROR((AE_INFO, "ACPI Subsystem is already terminated"));
120 return_VOID;
121 }
122
123 /* Subsystem appears active, go ahead and shut it down */
124
125 acpi_gbl_shutdown = TRUE;
126 acpi_gbl_startup_flags = 0;
127 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n"));
128
129#ifndef ACPI_ASL_COMPILER
130
131 /* Close the acpi_event Handling */
132
133 acpi_ev_terminate();
134#endif
135
136 /* Close the Namespace */
137
138 acpi_ns_terminate();
139
140 /* Delete the ACPI tables */
141
142 acpi_tb_terminate();
143
144 /* Close the globals */
145
146 acpi_ut_terminate();
147
148 /* Purge the local caches */
149
150 (void)acpi_ut_delete_caches();
151 return_VOID;
152}
diff --git a/drivers/acpi/utilities/utmath.c b/drivers/acpi/utilities/utmath.c
deleted file mode 100644
index 616d7b271c9a..000000000000
--- a/drivers/acpi/utilities/utmath.c
+++ /dev/null
@@ -1,312 +0,0 @@
1/*******************************************************************************
2 *
3 * Module Name: utmath - Integer math support routines
4 *
5 ******************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include <acpi/accommon.h>
46
47#define _COMPONENT ACPI_UTILITIES
48ACPI_MODULE_NAME("utmath")
49
50/*
51 * Support for double-precision integer divide. This code is included here
52 * in order to support kernel environments where the double-precision math
53 * library is not available.
54 */
55#ifndef ACPI_USE_NATIVE_DIVIDE
56/*******************************************************************************
57 *
58 * FUNCTION: acpi_ut_short_divide
59 *
60 * PARAMETERS: Dividend - 64-bit dividend
61 * Divisor - 32-bit divisor
62 * out_quotient - Pointer to where the quotient is returned
63 * out_remainder - Pointer to where the remainder is returned
64 *
65 * RETURN: Status (Checks for divide-by-zero)
66 *
67 * DESCRIPTION: Perform a short (maximum 64 bits divided by 32 bits)
68 * divide and modulo. The result is a 64-bit quotient and a
69 * 32-bit remainder.
70 *
71 ******************************************************************************/
72acpi_status
73acpi_ut_short_divide(acpi_integer dividend,
74 u32 divisor,
75 acpi_integer * out_quotient, u32 * out_remainder)
76{
77 union uint64_overlay dividend_ovl;
78 union uint64_overlay quotient;
79 u32 remainder32;
80
81 ACPI_FUNCTION_TRACE(ut_short_divide);
82
83 /* Always check for a zero divisor */
84
85 if (divisor == 0) {
86 ACPI_ERROR((AE_INFO, "Divide by zero"));
87 return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO);
88 }
89
90 dividend_ovl.full = dividend;
91
92 /*
93 * The quotient is 64 bits, the remainder is always 32 bits,
94 * and is generated by the second divide.
95 */
96 ACPI_DIV_64_BY_32(0, dividend_ovl.part.hi, divisor,
97 quotient.part.hi, remainder32);
98 ACPI_DIV_64_BY_32(remainder32, dividend_ovl.part.lo, divisor,
99 quotient.part.lo, remainder32);
100
101 /* Return only what was requested */
102
103 if (out_quotient) {
104 *out_quotient = quotient.full;
105 }
106 if (out_remainder) {
107 *out_remainder = remainder32;
108 }
109
110 return_ACPI_STATUS(AE_OK);
111}
112
113/*******************************************************************************
114 *
115 * FUNCTION: acpi_ut_divide
116 *
117 * PARAMETERS: in_dividend - Dividend
118 * in_divisor - Divisor
119 * out_quotient - Pointer to where the quotient is returned
120 * out_remainder - Pointer to where the remainder is returned
121 *
122 * RETURN: Status (Checks for divide-by-zero)
123 *
124 * DESCRIPTION: Perform a divide and modulo.
125 *
126 ******************************************************************************/
127
128acpi_status
129acpi_ut_divide(acpi_integer in_dividend,
130 acpi_integer in_divisor,
131 acpi_integer * out_quotient, acpi_integer * out_remainder)
132{
133 union uint64_overlay dividend;
134 union uint64_overlay divisor;
135 union uint64_overlay quotient;
136 union uint64_overlay remainder;
137 union uint64_overlay normalized_dividend;
138 union uint64_overlay normalized_divisor;
139 u32 partial1;
140 union uint64_overlay partial2;
141 union uint64_overlay partial3;
142
143 ACPI_FUNCTION_TRACE(ut_divide);
144
145 /* Always check for a zero divisor */
146
147 if (in_divisor == 0) {
148 ACPI_ERROR((AE_INFO, "Divide by zero"));
149 return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO);
150 }
151
152 divisor.full = in_divisor;
153 dividend.full = in_dividend;
154 if (divisor.part.hi == 0) {
155 /*
156 * 1) Simplest case is where the divisor is 32 bits, we can
157 * just do two divides
158 */
159 remainder.part.hi = 0;
160
161 /*
162 * The quotient is 64 bits, the remainder is always 32 bits,
163 * and is generated by the second divide.
164 */
165 ACPI_DIV_64_BY_32(0, dividend.part.hi, divisor.part.lo,
166 quotient.part.hi, partial1);
167 ACPI_DIV_64_BY_32(partial1, dividend.part.lo, divisor.part.lo,
168 quotient.part.lo, remainder.part.lo);
169 }
170
171 else {
172 /*
173 * 2) The general case where the divisor is a full 64 bits
174 * is more difficult
175 */
176 quotient.part.hi = 0;
177 normalized_dividend = dividend;
178 normalized_divisor = divisor;
179
180 /* Normalize the operands (shift until the divisor is < 32 bits) */
181
182 do {
183 ACPI_SHIFT_RIGHT_64(normalized_divisor.part.hi,
184 normalized_divisor.part.lo);
185 ACPI_SHIFT_RIGHT_64(normalized_dividend.part.hi,
186 normalized_dividend.part.lo);
187
188 } while (normalized_divisor.part.hi != 0);
189
190 /* Partial divide */
191
192 ACPI_DIV_64_BY_32(normalized_dividend.part.hi,
193 normalized_dividend.part.lo,
194 normalized_divisor.part.lo,
195 quotient.part.lo, partial1);
196
197 /*
198 * The quotient is always 32 bits, and simply requires adjustment.
199 * The 64-bit remainder must be generated.
200 */
201 partial1 = quotient.part.lo * divisor.part.hi;
202 partial2.full =
203 (acpi_integer) quotient.part.lo * divisor.part.lo;
204 partial3.full = (acpi_integer) partial2.part.hi + partial1;
205
206 remainder.part.hi = partial3.part.lo;
207 remainder.part.lo = partial2.part.lo;
208
209 if (partial3.part.hi == 0) {
210 if (partial3.part.lo >= dividend.part.hi) {
211 if (partial3.part.lo == dividend.part.hi) {
212 if (partial2.part.lo > dividend.part.lo) {
213 quotient.part.lo--;
214 remainder.full -= divisor.full;
215 }
216 } else {
217 quotient.part.lo--;
218 remainder.full -= divisor.full;
219 }
220 }
221
222 remainder.full = remainder.full - dividend.full;
223 remainder.part.hi = (u32) - ((s32) remainder.part.hi);
224 remainder.part.lo = (u32) - ((s32) remainder.part.lo);
225
226 if (remainder.part.lo) {
227 remainder.part.hi--;
228 }
229 }
230 }
231
232 /* Return only what was requested */
233
234 if (out_quotient) {
235 *out_quotient = quotient.full;
236 }
237 if (out_remainder) {
238 *out_remainder = remainder.full;
239 }
240
241 return_ACPI_STATUS(AE_OK);
242}
243
244#else
245/*******************************************************************************
246 *
247 * FUNCTION: acpi_ut_short_divide, acpi_ut_divide
248 *
249 * PARAMETERS: See function headers above
250 *
251 * DESCRIPTION: Native versions of the ut_divide functions. Use these if either
252 * 1) The target is a 64-bit platform and therefore 64-bit
253 * integer math is supported directly by the machine.
254 * 2) The target is a 32-bit or 16-bit platform, and the
255 * double-precision integer math library is available to
256 * perform the divide.
257 *
258 ******************************************************************************/
259acpi_status
260acpi_ut_short_divide(acpi_integer in_dividend,
261 u32 divisor,
262 acpi_integer * out_quotient, u32 * out_remainder)
263{
264
265 ACPI_FUNCTION_TRACE(ut_short_divide);
266
267 /* Always check for a zero divisor */
268
269 if (divisor == 0) {
270 ACPI_ERROR((AE_INFO, "Divide by zero"));
271 return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO);
272 }
273
274 /* Return only what was requested */
275
276 if (out_quotient) {
277 *out_quotient = in_dividend / divisor;
278 }
279 if (out_remainder) {
280 *out_remainder = (u32) (in_dividend % divisor);
281 }
282
283 return_ACPI_STATUS(AE_OK);
284}
285
286acpi_status
287acpi_ut_divide(acpi_integer in_dividend,
288 acpi_integer in_divisor,
289 acpi_integer * out_quotient, acpi_integer * out_remainder)
290{
291 ACPI_FUNCTION_TRACE(ut_divide);
292
293 /* Always check for a zero divisor */
294
295 if (in_divisor == 0) {
296 ACPI_ERROR((AE_INFO, "Divide by zero"));
297 return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO);
298 }
299
300 /* Return only what was requested */
301
302 if (out_quotient) {
303 *out_quotient = in_dividend / in_divisor;
304 }
305 if (out_remainder) {
306 *out_remainder = in_dividend % in_divisor;
307 }
308
309 return_ACPI_STATUS(AE_OK);
310}
311
312#endif
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c
deleted file mode 100644
index 8f8b407142ee..000000000000
--- a/drivers/acpi/utilities/utmisc.c
+++ /dev/null
@@ -1,1093 +0,0 @@
1/*******************************************************************************
2 *
3 * Module Name: utmisc - common utility procedures
4 *
5 ******************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <linux/module.h>
45
46#include <acpi/acpi.h>
47#include <acpi/accommon.h>
48#include <acpi/acnamesp.h>
49
50#define _COMPONENT ACPI_UTILITIES
51ACPI_MODULE_NAME("utmisc")
52
53/*******************************************************************************
54 *
55 * FUNCTION: acpi_ut_validate_exception
56 *
57 * PARAMETERS: Status - The acpi_status code to be formatted
58 *
59 * RETURN: A string containing the exception text. NULL if exception is
60 * not valid.
61 *
62 * DESCRIPTION: This function validates and translates an ACPI exception into
63 * an ASCII string.
64 *
65 ******************************************************************************/
66const char *acpi_ut_validate_exception(acpi_status status)
67{
68 u32 sub_status;
69 const char *exception = NULL;
70
71 ACPI_FUNCTION_ENTRY();
72
73 /*
74 * Status is composed of two parts, a "type" and an actual code
75 */
76 sub_status = (status & ~AE_CODE_MASK);
77
78 switch (status & AE_CODE_MASK) {
79 case AE_CODE_ENVIRONMENTAL:
80
81 if (sub_status <= AE_CODE_ENV_MAX) {
82 exception = acpi_gbl_exception_names_env[sub_status];
83 }
84 break;
85
86 case AE_CODE_PROGRAMMER:
87
88 if (sub_status <= AE_CODE_PGM_MAX) {
89 exception = acpi_gbl_exception_names_pgm[sub_status];
90 }
91 break;
92
93 case AE_CODE_ACPI_TABLES:
94
95 if (sub_status <= AE_CODE_TBL_MAX) {
96 exception = acpi_gbl_exception_names_tbl[sub_status];
97 }
98 break;
99
100 case AE_CODE_AML:
101
102 if (sub_status <= AE_CODE_AML_MAX) {
103 exception = acpi_gbl_exception_names_aml[sub_status];
104 }
105 break;
106
107 case AE_CODE_CONTROL:
108
109 if (sub_status <= AE_CODE_CTRL_MAX) {
110 exception = acpi_gbl_exception_names_ctrl[sub_status];
111 }
112 break;
113
114 default:
115 break;
116 }
117
118 return (ACPI_CAST_PTR(const char, exception));
119}
120
121/*******************************************************************************
122 *
123 * FUNCTION: acpi_ut_is_aml_table
124 *
125 * PARAMETERS: Table - An ACPI table
126 *
127 * RETURN: TRUE if table contains executable AML; FALSE otherwise
128 *
129 * DESCRIPTION: Check ACPI Signature for a table that contains AML code.
130 * Currently, these are DSDT,SSDT,PSDT. All other table types are
131 * data tables that do not contain AML code.
132 *
133 ******************************************************************************/
134
135u8 acpi_ut_is_aml_table(struct acpi_table_header *table)
136{
137
138 /* These are the only tables that contain executable AML */
139
140 if (ACPI_COMPARE_NAME(table->signature, ACPI_SIG_DSDT) ||
141 ACPI_COMPARE_NAME(table->signature, ACPI_SIG_PSDT) ||
142 ACPI_COMPARE_NAME(table->signature, ACPI_SIG_SSDT)) {
143 return (TRUE);
144 }
145
146 return (FALSE);
147}
148
149/*******************************************************************************
150 *
151 * FUNCTION: acpi_ut_allocate_owner_id
152 *
153 * PARAMETERS: owner_id - Where the new owner ID is returned
154 *
155 * RETURN: Status
156 *
157 * DESCRIPTION: Allocate a table or method owner ID. The owner ID is used to
158 * track objects created by the table or method, to be deleted
159 * when the method exits or the table is unloaded.
160 *
161 ******************************************************************************/
162
163acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id)
164{
165 u32 i;
166 u32 j;
167 u32 k;
168 acpi_status status;
169
170 ACPI_FUNCTION_TRACE(ut_allocate_owner_id);
171
172 /* Guard against multiple allocations of ID to the same location */
173
174 if (*owner_id) {
175 ACPI_ERROR((AE_INFO, "Owner ID [%2.2X] already exists",
176 *owner_id));
177 return_ACPI_STATUS(AE_ALREADY_EXISTS);
178 }
179
180 /* Mutex for the global ID mask */
181
182 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
183 if (ACPI_FAILURE(status)) {
184 return_ACPI_STATUS(status);
185 }
186
187 /*
188 * Find a free owner ID, cycle through all possible IDs on repeated
189 * allocations. (ACPI_NUM_OWNERID_MASKS + 1) because first index may have
190 * to be scanned twice.
191 */
192 for (i = 0, j = acpi_gbl_last_owner_id_index;
193 i < (ACPI_NUM_OWNERID_MASKS + 1); i++, j++) {
194 if (j >= ACPI_NUM_OWNERID_MASKS) {
195 j = 0; /* Wraparound to start of mask array */
196 }
197
198 for (k = acpi_gbl_next_owner_id_offset; k < 32; k++) {
199 if (acpi_gbl_owner_id_mask[j] == ACPI_UINT32_MAX) {
200
201 /* There are no free IDs in this mask */
202
203 break;
204 }
205
206 if (!(acpi_gbl_owner_id_mask[j] & (1 << k))) {
207 /*
208 * Found a free ID. The actual ID is the bit index plus one,
209 * making zero an invalid Owner ID. Save this as the last ID
210 * allocated and update the global ID mask.
211 */
212 acpi_gbl_owner_id_mask[j] |= (1 << k);
213
214 acpi_gbl_last_owner_id_index = (u8) j;
215 acpi_gbl_next_owner_id_offset = (u8) (k + 1);
216
217 /*
218 * Construct encoded ID from the index and bit position
219 *
220 * Note: Last [j].k (bit 255) is never used and is marked
221 * permanently allocated (prevents +1 overflow)
222 */
223 *owner_id =
224 (acpi_owner_id) ((k + 1) + ACPI_MUL_32(j));
225
226 ACPI_DEBUG_PRINT((ACPI_DB_VALUES,
227 "Allocated OwnerId: %2.2X\n",
228 (unsigned int)*owner_id));
229 goto exit;
230 }
231 }
232
233 acpi_gbl_next_owner_id_offset = 0;
234 }
235
236 /*
237 * All owner_ids have been allocated. This typically should
238 * not happen since the IDs are reused after deallocation. The IDs are
239 * allocated upon table load (one per table) and method execution, and
240 * they are released when a table is unloaded or a method completes
241 * execution.
242 *
243 * If this error happens, there may be very deep nesting of invoked control
244 * methods, or there may be a bug where the IDs are not released.
245 */
246 status = AE_OWNER_ID_LIMIT;
247 ACPI_ERROR((AE_INFO,
248 "Could not allocate new OwnerId (255 max), AE_OWNER_ID_LIMIT"));
249
250 exit:
251 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
252 return_ACPI_STATUS(status);
253}
254
255/*******************************************************************************
256 *
257 * FUNCTION: acpi_ut_release_owner_id
258 *
259 * PARAMETERS: owner_id_ptr - Pointer to a previously allocated owner_iD
260 *
261 * RETURN: None. No error is returned because we are either exiting a
262 * control method or unloading a table. Either way, we would
263 * ignore any error anyway.
264 *
265 * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 255
266 *
267 ******************************************************************************/
268
269void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr)
270{
271 acpi_owner_id owner_id = *owner_id_ptr;
272 acpi_status status;
273 u32 index;
274 u32 bit;
275
276 ACPI_FUNCTION_TRACE_U32(ut_release_owner_id, owner_id);
277
278 /* Always clear the input owner_id (zero is an invalid ID) */
279
280 *owner_id_ptr = 0;
281
282 /* Zero is not a valid owner_iD */
283
284 if (owner_id == 0) {
285 ACPI_ERROR((AE_INFO, "Invalid OwnerId: %2.2X", owner_id));
286 return_VOID;
287 }
288
289 /* Mutex for the global ID mask */
290
291 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
292 if (ACPI_FAILURE(status)) {
293 return_VOID;
294 }
295
296 /* Normalize the ID to zero */
297
298 owner_id--;
299
300 /* Decode ID to index/offset pair */
301
302 index = ACPI_DIV_32(owner_id);
303 bit = 1 << ACPI_MOD_32(owner_id);
304
305 /* Free the owner ID only if it is valid */
306
307 if (acpi_gbl_owner_id_mask[index] & bit) {
308 acpi_gbl_owner_id_mask[index] ^= bit;
309 } else {
310 ACPI_ERROR((AE_INFO,
311 "Release of non-allocated OwnerId: %2.2X",
312 owner_id + 1));
313 }
314
315 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
316 return_VOID;
317}
318
319/*******************************************************************************
320 *
321 * FUNCTION: acpi_ut_strupr (strupr)
322 *
323 * PARAMETERS: src_string - The source string to convert
324 *
325 * RETURN: None
326 *
327 * DESCRIPTION: Convert string to uppercase
328 *
329 * NOTE: This is not a POSIX function, so it appears here, not in utclib.c
330 *
331 ******************************************************************************/
332
333void acpi_ut_strupr(char *src_string)
334{
335 char *string;
336
337 ACPI_FUNCTION_ENTRY();
338
339 if (!src_string) {
340 return;
341 }
342
343 /* Walk entire string, uppercasing the letters */
344
345 for (string = src_string; *string; string++) {
346 *string = (char)ACPI_TOUPPER(*string);
347 }
348
349 return;
350}
351
352/*******************************************************************************
353 *
354 * FUNCTION: acpi_ut_print_string
355 *
356 * PARAMETERS: String - Null terminated ASCII string
357 * max_length - Maximum output length
358 *
359 * RETURN: None
360 *
361 * DESCRIPTION: Dump an ASCII string with support for ACPI-defined escape
362 * sequences.
363 *
364 ******************************************************************************/
365
366void acpi_ut_print_string(char *string, u8 max_length)
367{
368 u32 i;
369
370 if (!string) {
371 acpi_os_printf("<\"NULL STRING PTR\">");
372 return;
373 }
374
375 acpi_os_printf("\"");
376 for (i = 0; string[i] && (i < max_length); i++) {
377
378 /* Escape sequences */
379
380 switch (string[i]) {
381 case 0x07:
382 acpi_os_printf("\\a"); /* BELL */
383 break;
384
385 case 0x08:
386 acpi_os_printf("\\b"); /* BACKSPACE */
387 break;
388
389 case 0x0C:
390 acpi_os_printf("\\f"); /* FORMFEED */
391 break;
392
393 case 0x0A:
394 acpi_os_printf("\\n"); /* LINEFEED */
395 break;
396
397 case 0x0D:
398 acpi_os_printf("\\r"); /* CARRIAGE RETURN */
399 break;
400
401 case 0x09:
402 acpi_os_printf("\\t"); /* HORIZONTAL TAB */
403 break;
404
405 case 0x0B:
406 acpi_os_printf("\\v"); /* VERTICAL TAB */
407 break;
408
409 case '\'': /* Single Quote */
410 case '\"': /* Double Quote */
411 case '\\': /* Backslash */
412 acpi_os_printf("\\%c", (int)string[i]);
413 break;
414
415 default:
416
417 /* Check for printable character or hex escape */
418
419 if (ACPI_IS_PRINT(string[i])) {
420 /* This is a normal character */
421
422 acpi_os_printf("%c", (int)string[i]);
423 } else {
424 /* All others will be Hex escapes */
425
426 acpi_os_printf("\\x%2.2X", (s32) string[i]);
427 }
428 break;
429 }
430 }
431 acpi_os_printf("\"");
432
433 if (i == max_length && string[i]) {
434 acpi_os_printf("...");
435 }
436}
437
438/*******************************************************************************
439 *
440 * FUNCTION: acpi_ut_dword_byte_swap
441 *
442 * PARAMETERS: Value - Value to be converted
443 *
444 * RETURN: u32 integer with bytes swapped
445 *
446 * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes)
447 *
448 ******************************************************************************/
449
450u32 acpi_ut_dword_byte_swap(u32 value)
451{
452 union {
453 u32 value;
454 u8 bytes[4];
455 } out;
456 union {
457 u32 value;
458 u8 bytes[4];
459 } in;
460
461 ACPI_FUNCTION_ENTRY();
462
463 in.value = value;
464
465 out.bytes[0] = in.bytes[3];
466 out.bytes[1] = in.bytes[2];
467 out.bytes[2] = in.bytes[1];
468 out.bytes[3] = in.bytes[0];
469
470 return (out.value);
471}
472
473/*******************************************************************************
474 *
475 * FUNCTION: acpi_ut_set_integer_width
476 *
477 * PARAMETERS: Revision From DSDT header
478 *
479 * RETURN: None
480 *
481 * DESCRIPTION: Set the global integer bit width based upon the revision
482 * of the DSDT. For Revision 1 and 0, Integers are 32 bits.
483 * For Revision 2 and above, Integers are 64 bits. Yes, this
484 * makes a difference.
485 *
486 ******************************************************************************/
487
488void acpi_ut_set_integer_width(u8 revision)
489{
490
491 if (revision < 2) {
492
493 /* 32-bit case */
494
495 acpi_gbl_integer_bit_width = 32;
496 acpi_gbl_integer_nybble_width = 8;
497 acpi_gbl_integer_byte_width = 4;
498 } else {
499 /* 64-bit case (ACPI 2.0+) */
500
501 acpi_gbl_integer_bit_width = 64;
502 acpi_gbl_integer_nybble_width = 16;
503 acpi_gbl_integer_byte_width = 8;
504 }
505}
506
507#ifdef ACPI_DEBUG_OUTPUT
508/*******************************************************************************
509 *
510 * FUNCTION: acpi_ut_display_init_pathname
511 *
512 * PARAMETERS: Type - Object type of the node
513 * obj_handle - Handle whose pathname will be displayed
514 * Path - Additional path string to be appended.
515 * (NULL if no extra path)
516 *
517 * RETURN: acpi_status
518 *
519 * DESCRIPTION: Display full pathname of an object, DEBUG ONLY
520 *
521 ******************************************************************************/
522
523void
524acpi_ut_display_init_pathname(u8 type,
525 struct acpi_namespace_node *obj_handle,
526 char *path)
527{
528 acpi_status status;
529 struct acpi_buffer buffer;
530
531 ACPI_FUNCTION_ENTRY();
532
533 /* Only print the path if the appropriate debug level is enabled */
534
535 if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
536 return;
537 }
538
539 /* Get the full pathname to the node */
540
541 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
542 status = acpi_ns_handle_to_pathname(obj_handle, &buffer);
543 if (ACPI_FAILURE(status)) {
544 return;
545 }
546
547 /* Print what we're doing */
548
549 switch (type) {
550 case ACPI_TYPE_METHOD:
551 acpi_os_printf("Executing ");
552 break;
553
554 default:
555 acpi_os_printf("Initializing ");
556 break;
557 }
558
559 /* Print the object type and pathname */
560
561 acpi_os_printf("%-12s %s",
562 acpi_ut_get_type_name(type), (char *)buffer.pointer);
563
564 /* Extra path is used to append names like _STA, _INI, etc. */
565
566 if (path) {
567 acpi_os_printf(".%s", path);
568 }
569 acpi_os_printf("\n");
570
571 ACPI_FREE(buffer.pointer);
572}
573#endif
574
575/*******************************************************************************
576 *
577 * FUNCTION: acpi_ut_valid_acpi_char
578 *
579 * PARAMETERS: Char - The character to be examined
580 * Position - Byte position (0-3)
581 *
582 * RETURN: TRUE if the character is valid, FALSE otherwise
583 *
584 * DESCRIPTION: Check for a valid ACPI character. Must be one of:
585 * 1) Upper case alpha
586 * 2) numeric
587 * 3) underscore
588 *
589 * We allow a '!' as the last character because of the ASF! table
590 *
591 ******************************************************************************/
592
593u8 acpi_ut_valid_acpi_char(char character, u32 position)
594{
595
596 if (!((character >= 'A' && character <= 'Z') ||
597 (character >= '0' && character <= '9') || (character == '_'))) {
598
599 /* Allow a '!' in the last position */
600
601 if (character == '!' && position == 3) {
602 return (TRUE);
603 }
604
605 return (FALSE);
606 }
607
608 return (TRUE);
609}
610
611/*******************************************************************************
612 *
613 * FUNCTION: acpi_ut_valid_acpi_name
614 *
615 * PARAMETERS: Name - The name to be examined
616 *
617 * RETURN: TRUE if the name is valid, FALSE otherwise
618 *
619 * DESCRIPTION: Check for a valid ACPI name. Each character must be one of:
620 * 1) Upper case alpha
621 * 2) numeric
622 * 3) underscore
623 *
624 ******************************************************************************/
625
626u8 acpi_ut_valid_acpi_name(u32 name)
627{
628 u32 i;
629
630 ACPI_FUNCTION_ENTRY();
631
632 for (i = 0; i < ACPI_NAME_SIZE; i++) {
633 if (!acpi_ut_valid_acpi_char
634 ((ACPI_CAST_PTR(char, &name))[i], i)) {
635 return (FALSE);
636 }
637 }
638
639 return (TRUE);
640}
641
642/*******************************************************************************
643 *
644 * FUNCTION: acpi_ut_repair_name
645 *
646 * PARAMETERS: Name - The ACPI name to be repaired
647 *
648 * RETURN: Repaired version of the name
649 *
650 * DESCRIPTION: Repair an ACPI name: Change invalid characters to '*' and
651 * return the new name.
652 *
653 ******************************************************************************/
654
655acpi_name acpi_ut_repair_name(char *name)
656{
657 u32 i;
658 char new_name[ACPI_NAME_SIZE];
659
660 for (i = 0; i < ACPI_NAME_SIZE; i++) {
661 new_name[i] = name[i];
662
663 /*
664 * Replace a bad character with something printable, yet technically
665 * still invalid. This prevents any collisions with existing "good"
666 * names in the namespace.
667 */
668 if (!acpi_ut_valid_acpi_char(name[i], i)) {
669 new_name[i] = '*';
670 }
671 }
672
673 return (*(u32 *) new_name);
674}
675
676/*******************************************************************************
677 *
678 * FUNCTION: acpi_ut_strtoul64
679 *
680 * PARAMETERS: String - Null terminated string
681 * Base - Radix of the string: 16 or ACPI_ANY_BASE;
682 * ACPI_ANY_BASE means 'in behalf of to_integer'
683 * ret_integer - Where the converted integer is returned
684 *
685 * RETURN: Status and Converted value
686 *
687 * DESCRIPTION: Convert a string into an unsigned value. Performs either a
688 * 32-bit or 64-bit conversion, depending on the current mode
689 * of the interpreter.
690 * NOTE: Does not support Octal strings, not needed.
691 *
692 ******************************************************************************/
693
694acpi_status
695acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer)
696{
697 u32 this_digit = 0;
698 acpi_integer return_value = 0;
699 acpi_integer quotient;
700 acpi_integer dividend;
701 u32 to_integer_op = (base == ACPI_ANY_BASE);
702 u32 mode32 = (acpi_gbl_integer_byte_width == 4);
703 u8 valid_digits = 0;
704 u8 sign_of0x = 0;
705 u8 term = 0;
706
707 ACPI_FUNCTION_TRACE_STR(ut_stroul64, string);
708
709 switch (base) {
710 case ACPI_ANY_BASE:
711 case 16:
712 break;
713
714 default:
715 /* Invalid Base */
716 return_ACPI_STATUS(AE_BAD_PARAMETER);
717 }
718
719 if (!string) {
720 goto error_exit;
721 }
722
723 /* Skip over any white space in the buffer */
724
725 while ((*string) && (ACPI_IS_SPACE(*string) || *string == '\t')) {
726 string++;
727 }
728
729 if (to_integer_op) {
730 /*
731 * Base equal to ACPI_ANY_BASE means 'to_integer operation case'.
732 * We need to determine if it is decimal or hexadecimal.
733 */
734 if ((*string == '0') && (ACPI_TOLOWER(*(string + 1)) == 'x')) {
735 sign_of0x = 1;
736 base = 16;
737
738 /* Skip over the leading '0x' */
739 string += 2;
740 } else {
741 base = 10;
742 }
743 }
744
745 /* Any string left? Check that '0x' is not followed by white space. */
746
747 if (!(*string) || ACPI_IS_SPACE(*string) || *string == '\t') {
748 if (to_integer_op) {
749 goto error_exit;
750 } else {
751 goto all_done;
752 }
753 }
754
755 /*
756 * Perform a 32-bit or 64-bit conversion, depending upon the current
757 * execution mode of the interpreter
758 */
759 dividend = (mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX;
760
761 /* Main loop: convert the string to a 32- or 64-bit integer */
762
763 while (*string) {
764 if (ACPI_IS_DIGIT(*string)) {
765
766 /* Convert ASCII 0-9 to Decimal value */
767
768 this_digit = ((u8) * string) - '0';
769 } else if (base == 10) {
770
771 /* Digit is out of range; possible in to_integer case only */
772
773 term = 1;
774 } else {
775 this_digit = (u8) ACPI_TOUPPER(*string);
776 if (ACPI_IS_XDIGIT((char)this_digit)) {
777
778 /* Convert ASCII Hex char to value */
779
780 this_digit = this_digit - 'A' + 10;
781 } else {
782 term = 1;
783 }
784 }
785
786 if (term) {
787 if (to_integer_op) {
788 goto error_exit;
789 } else {
790 break;
791 }
792 } else if ((valid_digits == 0) && (this_digit == 0)
793 && !sign_of0x) {
794
795 /* Skip zeros */
796 string++;
797 continue;
798 }
799
800 valid_digits++;
801
802 if (sign_of0x && ((valid_digits > 16)
803 || ((valid_digits > 8) && mode32))) {
804 /*
805 * This is to_integer operation case.
806 * No any restrictions for string-to-integer conversion,
807 * see ACPI spec.
808 */
809 goto error_exit;
810 }
811
812 /* Divide the digit into the correct position */
813
814 (void)
815 acpi_ut_short_divide((dividend - (acpi_integer) this_digit),
816 base, &quotient, NULL);
817
818 if (return_value > quotient) {
819 if (to_integer_op) {
820 goto error_exit;
821 } else {
822 break;
823 }
824 }
825
826 return_value *= base;
827 return_value += this_digit;
828 string++;
829 }
830
831 /* All done, normal exit */
832
833 all_done:
834
835 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",
836 ACPI_FORMAT_UINT64(return_value)));
837
838 *ret_integer = return_value;
839 return_ACPI_STATUS(AE_OK);
840
841 error_exit:
842 /* Base was set/validated above */
843
844 if (base == 10) {
845 return_ACPI_STATUS(AE_BAD_DECIMAL_CONSTANT);
846 } else {
847 return_ACPI_STATUS(AE_BAD_HEX_CONSTANT);
848 }
849}
850
851/*******************************************************************************
852 *
853 * FUNCTION: acpi_ut_create_update_state_and_push
854 *
855 * PARAMETERS: Object - Object to be added to the new state
856 * Action - Increment/Decrement
857 * state_list - List the state will be added to
858 *
859 * RETURN: Status
860 *
861 * DESCRIPTION: Create a new state and push it
862 *
863 ******************************************************************************/
864
865acpi_status
866acpi_ut_create_update_state_and_push(union acpi_operand_object *object,
867 u16 action,
868 union acpi_generic_state **state_list)
869{
870 union acpi_generic_state *state;
871
872 ACPI_FUNCTION_ENTRY();
873
874 /* Ignore null objects; these are expected */
875
876 if (!object) {
877 return (AE_OK);
878 }
879
880 state = acpi_ut_create_update_state(object, action);
881 if (!state) {
882 return (AE_NO_MEMORY);
883 }
884
885 acpi_ut_push_generic_state(state_list, state);
886 return (AE_OK);
887}
888
889/*******************************************************************************
890 *
891 * FUNCTION: acpi_ut_walk_package_tree
892 *
893 * PARAMETERS: source_object - The package to walk
894 * target_object - Target object (if package is being copied)
895 * walk_callback - Called once for each package element
896 * Context - Passed to the callback function
897 *
898 * RETURN: Status
899 *
900 * DESCRIPTION: Walk through a package
901 *
902 ******************************************************************************/
903
904acpi_status
905acpi_ut_walk_package_tree(union acpi_operand_object * source_object,
906 void *target_object,
907 acpi_pkg_callback walk_callback, void *context)
908{
909 acpi_status status = AE_OK;
910 union acpi_generic_state *state_list = NULL;
911 union acpi_generic_state *state;
912 u32 this_index;
913 union acpi_operand_object *this_source_obj;
914
915 ACPI_FUNCTION_TRACE(ut_walk_package_tree);
916
917 state = acpi_ut_create_pkg_state(source_object, target_object, 0);
918 if (!state) {
919 return_ACPI_STATUS(AE_NO_MEMORY);
920 }
921
922 while (state) {
923
924 /* Get one element of the package */
925
926 this_index = state->pkg.index;
927 this_source_obj = (union acpi_operand_object *)
928 state->pkg.source_object->package.elements[this_index];
929
930 /*
931 * Check for:
932 * 1) An uninitialized package element. It is completely
933 * legal to declare a package and leave it uninitialized
934 * 2) Not an internal object - can be a namespace node instead
935 * 3) Any type other than a package. Packages are handled in else
936 * case below.
937 */
938 if ((!this_source_obj) ||
939 (ACPI_GET_DESCRIPTOR_TYPE(this_source_obj) !=
940 ACPI_DESC_TYPE_OPERAND)
941 || (ACPI_GET_OBJECT_TYPE(this_source_obj) !=
942 ACPI_TYPE_PACKAGE)) {
943 status =
944 walk_callback(ACPI_COPY_TYPE_SIMPLE,
945 this_source_obj, state, context);
946 if (ACPI_FAILURE(status)) {
947 return_ACPI_STATUS(status);
948 }
949
950 state->pkg.index++;
951 while (state->pkg.index >=
952 state->pkg.source_object->package.count) {
953 /*
954 * We've handled all of the objects at this level, This means
955 * that we have just completed a package. That package may
956 * have contained one or more packages itself.
957 *
958 * Delete this state and pop the previous state (package).
959 */
960 acpi_ut_delete_generic_state(state);
961 state = acpi_ut_pop_generic_state(&state_list);
962
963 /* Finished when there are no more states */
964
965 if (!state) {
966 /*
967 * We have handled all of the objects in the top level
968 * package just add the length of the package objects
969 * and exit
970 */
971 return_ACPI_STATUS(AE_OK);
972 }
973
974 /*
975 * Go back up a level and move the index past the just
976 * completed package object.
977 */
978 state->pkg.index++;
979 }
980 } else {
981 /* This is a subobject of type package */
982
983 status =
984 walk_callback(ACPI_COPY_TYPE_PACKAGE,
985 this_source_obj, state, context);
986 if (ACPI_FAILURE(status)) {
987 return_ACPI_STATUS(status);
988 }
989
990 /*
991 * Push the current state and create a new one
992 * The callback above returned a new target package object.
993 */
994 acpi_ut_push_generic_state(&state_list, state);
995 state = acpi_ut_create_pkg_state(this_source_obj,
996 state->pkg.
997 this_target_obj, 0);
998 if (!state) {
999
1000 /* Free any stacked Update State objects */
1001
1002 while (state_list) {
1003 state =
1004 acpi_ut_pop_generic_state
1005 (&state_list);
1006 acpi_ut_delete_generic_state(state);
1007 }
1008 return_ACPI_STATUS(AE_NO_MEMORY);
1009 }
1010 }
1011 }
1012
1013 /* We should never get here */
1014
1015 return_ACPI_STATUS(AE_AML_INTERNAL);
1016}
1017
1018/*******************************************************************************
1019 *
1020 * FUNCTION: acpi_error, acpi_exception, acpi_warning, acpi_info
1021 *
1022 * PARAMETERS: module_name - Caller's module name (for error output)
1023 * line_number - Caller's line number (for error output)
1024 * Format - Printf format string + additional args
1025 *
1026 * RETURN: None
1027 *
1028 * DESCRIPTION: Print message with module/line/version info
1029 *
1030 ******************************************************************************/
1031
1032void ACPI_INTERNAL_VAR_XFACE
1033acpi_error(const char *module_name, u32 line_number, const char *format, ...)
1034{
1035 va_list args;
1036
1037 acpi_os_printf("ACPI Error (%s-%04d): ", module_name, line_number);
1038
1039 va_start(args, format);
1040 acpi_os_vprintf(format, args);
1041 acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
1042 va_end(args);
1043}
1044
1045void ACPI_INTERNAL_VAR_XFACE
1046acpi_exception(const char *module_name,
1047 u32 line_number, acpi_status status, const char *format, ...)
1048{
1049 va_list args;
1050
1051 acpi_os_printf("ACPI Exception (%s-%04d): %s, ", module_name,
1052 line_number, acpi_format_exception(status));
1053
1054 va_start(args, format);
1055 acpi_os_vprintf(format, args);
1056 acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
1057 va_end(args);
1058}
1059
1060void ACPI_INTERNAL_VAR_XFACE
1061acpi_warning(const char *module_name, u32 line_number, const char *format, ...)
1062{
1063 va_list args;
1064
1065 acpi_os_printf("ACPI Warning (%s-%04d): ", module_name, line_number);
1066
1067 va_start(args, format);
1068 acpi_os_vprintf(format, args);
1069 acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
1070 va_end(args);
1071}
1072
1073void ACPI_INTERNAL_VAR_XFACE
1074acpi_info(const char *module_name, u32 line_number, const char *format, ...)
1075{
1076 va_list args;
1077
1078 /*
1079 * Removed module_name, line_number, and acpica version, not needed
1080 * for info output
1081 */
1082 acpi_os_printf("ACPI: ");
1083
1084 va_start(args, format);
1085 acpi_os_vprintf(format, args);
1086 acpi_os_printf("\n");
1087 va_end(args);
1088}
1089
1090ACPI_EXPORT_SYMBOL(acpi_error)
1091ACPI_EXPORT_SYMBOL(acpi_exception)
1092ACPI_EXPORT_SYMBOL(acpi_warning)
1093ACPI_EXPORT_SYMBOL(acpi_info)
diff --git a/drivers/acpi/utilities/utmutex.c b/drivers/acpi/utilities/utmutex.c
deleted file mode 100644
index 7b48ba3f3f8a..000000000000
--- a/drivers/acpi/utilities/utmutex.c
+++ /dev/null
@@ -1,342 +0,0 @@
1/*******************************************************************************
2 *
3 * Module Name: utmutex - local mutex support
4 *
5 ******************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include <acpi/accommon.h>
46
47#define _COMPONENT ACPI_UTILITIES
48ACPI_MODULE_NAME("utmutex")
49
50/* Local prototypes */
51static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id);
52
53static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id);
54
55/*******************************************************************************
56 *
57 * FUNCTION: acpi_ut_mutex_initialize
58 *
59 * PARAMETERS: None.
60 *
61 * RETURN: Status
62 *
63 * DESCRIPTION: Create the system mutex objects.
64 *
65 ******************************************************************************/
66
67acpi_status acpi_ut_mutex_initialize(void)
68{
69 u32 i;
70 acpi_status status;
71
72 ACPI_FUNCTION_TRACE(ut_mutex_initialize);
73
74 /*
75 * Create each of the predefined mutex objects
76 */
77 for (i = 0; i < ACPI_NUM_MUTEX; i++) {
78 status = acpi_ut_create_mutex(i);
79 if (ACPI_FAILURE(status)) {
80 return_ACPI_STATUS(status);
81 }
82 }
83
84 /* Create the spinlocks for use at interrupt level */
85
86 spin_lock_init(acpi_gbl_gpe_lock);
87 spin_lock_init(acpi_gbl_hardware_lock);
88
89 return_ACPI_STATUS(status);
90}
91
92/*******************************************************************************
93 *
94 * FUNCTION: acpi_ut_mutex_terminate
95 *
96 * PARAMETERS: None.
97 *
98 * RETURN: None.
99 *
100 * DESCRIPTION: Delete all of the system mutex objects.
101 *
102 ******************************************************************************/
103
104void acpi_ut_mutex_terminate(void)
105{
106 u32 i;
107
108 ACPI_FUNCTION_TRACE(ut_mutex_terminate);
109
110 /*
111 * Delete each predefined mutex object
112 */
113 for (i = 0; i < ACPI_NUM_MUTEX; i++) {
114 (void)acpi_ut_delete_mutex(i);
115 }
116
117 /* Delete the spinlocks */
118
119 acpi_os_delete_lock(acpi_gbl_gpe_lock);
120 acpi_os_delete_lock(acpi_gbl_hardware_lock);
121 return_VOID;
122}
123
124/*******************************************************************************
125 *
126 * FUNCTION: acpi_ut_create_mutex
127 *
128 * PARAMETERS: mutex_iD - ID of the mutex to be created
129 *
130 * RETURN: Status
131 *
132 * DESCRIPTION: Create a mutex object.
133 *
134 ******************************************************************************/
135
136static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id)
137{
138 acpi_status status = AE_OK;
139
140 ACPI_FUNCTION_TRACE_U32(ut_create_mutex, mutex_id);
141
142 if (mutex_id > ACPI_MAX_MUTEX) {
143 return_ACPI_STATUS(AE_BAD_PARAMETER);
144 }
145
146 if (!acpi_gbl_mutex_info[mutex_id].mutex) {
147 status =
148 acpi_os_create_mutex(&acpi_gbl_mutex_info[mutex_id].mutex);
149 acpi_gbl_mutex_info[mutex_id].thread_id =
150 ACPI_MUTEX_NOT_ACQUIRED;
151 acpi_gbl_mutex_info[mutex_id].use_count = 0;
152 }
153
154 return_ACPI_STATUS(status);
155}
156
157/*******************************************************************************
158 *
159 * FUNCTION: acpi_ut_delete_mutex
160 *
161 * PARAMETERS: mutex_iD - ID of the mutex to be deleted
162 *
163 * RETURN: Status
164 *
165 * DESCRIPTION: Delete a mutex object.
166 *
167 ******************************************************************************/
168
169static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id)
170{
171
172 ACPI_FUNCTION_TRACE_U32(ut_delete_mutex, mutex_id);
173
174 if (mutex_id > ACPI_MAX_MUTEX) {
175 return_ACPI_STATUS(AE_BAD_PARAMETER);
176 }
177
178 acpi_os_delete_mutex(acpi_gbl_mutex_info[mutex_id].mutex);
179
180 acpi_gbl_mutex_info[mutex_id].mutex = NULL;
181 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
182
183 return_ACPI_STATUS(AE_OK);
184}
185
186/*******************************************************************************
187 *
188 * FUNCTION: acpi_ut_acquire_mutex
189 *
190 * PARAMETERS: mutex_iD - ID of the mutex to be acquired
191 *
192 * RETURN: Status
193 *
194 * DESCRIPTION: Acquire a mutex object.
195 *
196 ******************************************************************************/
197
198acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id)
199{
200 acpi_status status;
201 acpi_thread_id this_thread_id;
202
203 ACPI_FUNCTION_NAME(ut_acquire_mutex);
204
205 if (mutex_id > ACPI_MAX_MUTEX) {
206 return (AE_BAD_PARAMETER);
207 }
208
209 this_thread_id = acpi_os_get_thread_id();
210
211#ifdef ACPI_MUTEX_DEBUG
212 {
213 u32 i;
214 /*
215 * Mutex debug code, for internal debugging only.
216 *
217 * Deadlock prevention. Check if this thread owns any mutexes of value
218 * greater than or equal to this one. If so, the thread has violated
219 * the mutex ordering rule. This indicates a coding error somewhere in
220 * the ACPI subsystem code.
221 */
222 for (i = mutex_id; i < ACPI_NUM_MUTEX; i++) {
223 if (acpi_gbl_mutex_info[i].thread_id == this_thread_id) {
224 if (i == mutex_id) {
225 ACPI_ERROR((AE_INFO,
226 "Mutex [%s] already acquired by this thread [%X]",
227 acpi_ut_get_mutex_name
228 (mutex_id),
229 this_thread_id));
230
231 return (AE_ALREADY_ACQUIRED);
232 }
233
234 ACPI_ERROR((AE_INFO,
235 "Invalid acquire order: Thread %X owns [%s], wants [%s]",
236 this_thread_id,
237 acpi_ut_get_mutex_name(i),
238 acpi_ut_get_mutex_name(mutex_id)));
239
240 return (AE_ACQUIRE_DEADLOCK);
241 }
242 }
243 }
244#endif
245
246 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
247 "Thread %lX attempting to acquire Mutex [%s]\n",
248 (unsigned long)this_thread_id,
249 acpi_ut_get_mutex_name(mutex_id)));
250
251 status = acpi_os_acquire_mutex(acpi_gbl_mutex_info[mutex_id].mutex,
252 ACPI_WAIT_FOREVER);
253 if (ACPI_SUCCESS(status)) {
254 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
255 "Thread %lX acquired Mutex [%s]\n",
256 (unsigned long)this_thread_id,
257 acpi_ut_get_mutex_name(mutex_id)));
258
259 acpi_gbl_mutex_info[mutex_id].use_count++;
260 acpi_gbl_mutex_info[mutex_id].thread_id = this_thread_id;
261 } else {
262 ACPI_EXCEPTION((AE_INFO, status,
263 "Thread %lX could not acquire Mutex [%X]",
264 (unsigned long)this_thread_id, mutex_id));
265 }
266
267 return (status);
268}
269
270/*******************************************************************************
271 *
272 * FUNCTION: acpi_ut_release_mutex
273 *
274 * PARAMETERS: mutex_iD - ID of the mutex to be released
275 *
276 * RETURN: Status
277 *
278 * DESCRIPTION: Release a mutex object.
279 *
280 ******************************************************************************/
281
282acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id)
283{
284 acpi_thread_id this_thread_id;
285
286 ACPI_FUNCTION_NAME(ut_release_mutex);
287
288 this_thread_id = acpi_os_get_thread_id();
289 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
290 "Thread %lX releasing Mutex [%s]\n",
291 (unsigned long)this_thread_id,
292 acpi_ut_get_mutex_name(mutex_id)));
293
294 if (mutex_id > ACPI_MAX_MUTEX) {
295 return (AE_BAD_PARAMETER);
296 }
297
298 /*
299 * Mutex must be acquired in order to release it!
300 */
301 if (acpi_gbl_mutex_info[mutex_id].thread_id == ACPI_MUTEX_NOT_ACQUIRED) {
302 ACPI_ERROR((AE_INFO,
303 "Mutex [%X] is not acquired, cannot release",
304 mutex_id));
305
306 return (AE_NOT_ACQUIRED);
307 }
308#ifdef ACPI_MUTEX_DEBUG
309 {
310 u32 i;
311 /*
312 * Mutex debug code, for internal debugging only.
313 *
314 * Deadlock prevention. Check if this thread owns any mutexes of value
315 * greater than this one. If so, the thread has violated the mutex
316 * ordering rule. This indicates a coding error somewhere in
317 * the ACPI subsystem code.
318 */
319 for (i = mutex_id; i < ACPI_NUM_MUTEX; i++) {
320 if (acpi_gbl_mutex_info[i].thread_id == this_thread_id) {
321 if (i == mutex_id) {
322 continue;
323 }
324
325 ACPI_ERROR((AE_INFO,
326 "Invalid release order: owns [%s], releasing [%s]",
327 acpi_ut_get_mutex_name(i),
328 acpi_ut_get_mutex_name(mutex_id)));
329
330 return (AE_RELEASE_DEADLOCK);
331 }
332 }
333 }
334#endif
335
336 /* Mark unlocked FIRST */
337
338 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
339
340 acpi_os_release_mutex(acpi_gbl_mutex_info[mutex_id].mutex);
341 return (AE_OK);
342}
diff --git a/drivers/acpi/utilities/utobject.c b/drivers/acpi/utilities/utobject.c
deleted file mode 100644
index 964b23c11610..000000000000
--- a/drivers/acpi/utilities/utobject.c
+++ /dev/null
@@ -1,677 +0,0 @@
1/******************************************************************************
2 *
3 * Module Name: utobject - ACPI object create/delete/size/cache routines
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include <acpi/accommon.h>
46#include <acpi/acnamesp.h>
47
48#define _COMPONENT ACPI_UTILITIES
49ACPI_MODULE_NAME("utobject")
50
51/* Local prototypes */
52static acpi_status
53acpi_ut_get_simple_object_size(union acpi_operand_object *obj,
54 acpi_size * obj_length);
55
56static acpi_status
57acpi_ut_get_package_object_size(union acpi_operand_object *obj,
58 acpi_size * obj_length);
59
60static acpi_status
61acpi_ut_get_element_length(u8 object_type,
62 union acpi_operand_object *source_object,
63 union acpi_generic_state *state, void *context);
64
65/*******************************************************************************
66 *
67 * FUNCTION: acpi_ut_create_internal_object_dbg
68 *
69 * PARAMETERS: module_name - Source file name of caller
70 * line_number - Line number of caller
71 * component_id - Component type of caller
72 * Type - ACPI Type of the new object
73 *
74 * RETURN: A new internal object, null on failure
75 *
76 * DESCRIPTION: Create and initialize a new internal object.
77 *
78 * NOTE: We always allocate the worst-case object descriptor because
79 * these objects are cached, and we want them to be
80 * one-size-satisifies-any-request. This in itself may not be
81 * the most memory efficient, but the efficiency of the object
82 * cache should more than make up for this!
83 *
84 ******************************************************************************/
85
86union acpi_operand_object *acpi_ut_create_internal_object_dbg(const char
87 *module_name,
88 u32 line_number,
89 u32 component_id,
90 acpi_object_type
91 type)
92{
93 union acpi_operand_object *object;
94 union acpi_operand_object *second_object;
95
96 ACPI_FUNCTION_TRACE_STR(ut_create_internal_object_dbg,
97 acpi_ut_get_type_name(type));
98
99 /* Allocate the raw object descriptor */
100
101 object =
102 acpi_ut_allocate_object_desc_dbg(module_name, line_number,
103 component_id);
104 if (!object) {
105 return_PTR(NULL);
106 }
107
108 switch (type) {
109 case ACPI_TYPE_REGION:
110 case ACPI_TYPE_BUFFER_FIELD:
111 case ACPI_TYPE_LOCAL_BANK_FIELD:
112
113 /* These types require a secondary object */
114
115 second_object = acpi_ut_allocate_object_desc_dbg(module_name,
116 line_number,
117 component_id);
118 if (!second_object) {
119 acpi_ut_delete_object_desc(object);
120 return_PTR(NULL);
121 }
122
123 second_object->common.type = ACPI_TYPE_LOCAL_EXTRA;
124 second_object->common.reference_count = 1;
125
126 /* Link the second object to the first */
127
128 object->common.next_object = second_object;
129 break;
130
131 default:
132 /* All others have no secondary object */
133 break;
134 }
135
136 /* Save the object type in the object descriptor */
137
138 object->common.type = (u8) type;
139
140 /* Init the reference count */
141
142 object->common.reference_count = 1;
143
144 /* Any per-type initialization should go here */
145
146 return_PTR(object);
147}
148
149/*******************************************************************************
150 *
151 * FUNCTION: acpi_ut_create_package_object
152 *
153 * PARAMETERS: Count - Number of package elements
154 *
155 * RETURN: Pointer to a new Package object, null on failure
156 *
157 * DESCRIPTION: Create a fully initialized package object
158 *
159 ******************************************************************************/
160
161union acpi_operand_object *acpi_ut_create_package_object(u32 count)
162{
163 union acpi_operand_object *package_desc;
164 union acpi_operand_object **package_elements;
165
166 ACPI_FUNCTION_TRACE_U32(ut_create_package_object, count);
167
168 /* Create a new Package object */
169
170 package_desc = acpi_ut_create_internal_object(ACPI_TYPE_PACKAGE);
171 if (!package_desc) {
172 return_PTR(NULL);
173 }
174
175 /*
176 * Create the element array. Count+1 allows the array to be null
177 * terminated.
178 */
179 package_elements = ACPI_ALLOCATE_ZEROED(((acpi_size) count +
180 1) * sizeof(void *));
181 if (!package_elements) {
182 acpi_ut_remove_reference(package_desc);
183 return_PTR(NULL);
184 }
185
186 package_desc->package.count = count;
187 package_desc->package.elements = package_elements;
188 return_PTR(package_desc);
189}
190
191/*******************************************************************************
192 *
193 * FUNCTION: acpi_ut_create_buffer_object
194 *
195 * PARAMETERS: buffer_size - Size of buffer to be created
196 *
197 * RETURN: Pointer to a new Buffer object, null on failure
198 *
199 * DESCRIPTION: Create a fully initialized buffer object
200 *
201 ******************************************************************************/
202
203union acpi_operand_object *acpi_ut_create_buffer_object(acpi_size buffer_size)
204{
205 union acpi_operand_object *buffer_desc;
206 u8 *buffer = NULL;
207
208 ACPI_FUNCTION_TRACE_U32(ut_create_buffer_object, buffer_size);
209
210 /* Create a new Buffer object */
211
212 buffer_desc = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER);
213 if (!buffer_desc) {
214 return_PTR(NULL);
215 }
216
217 /* Create an actual buffer only if size > 0 */
218
219 if (buffer_size > 0) {
220
221 /* Allocate the actual buffer */
222
223 buffer = ACPI_ALLOCATE_ZEROED(buffer_size);
224 if (!buffer) {
225 ACPI_ERROR((AE_INFO, "Could not allocate size %X",
226 (u32) buffer_size));
227 acpi_ut_remove_reference(buffer_desc);
228 return_PTR(NULL);
229 }
230 }
231
232 /* Complete buffer object initialization */
233
234 buffer_desc->buffer.flags |= AOPOBJ_DATA_VALID;
235 buffer_desc->buffer.pointer = buffer;
236 buffer_desc->buffer.length = (u32) buffer_size;
237
238 /* Return the new buffer descriptor */
239
240 return_PTR(buffer_desc);
241}
242
243/*******************************************************************************
244 *
245 * FUNCTION: acpi_ut_create_string_object
246 *
247 * PARAMETERS: string_size - Size of string to be created. Does not
248 * include NULL terminator, this is added
249 * automatically.
250 *
251 * RETURN: Pointer to a new String object
252 *
253 * DESCRIPTION: Create a fully initialized string object
254 *
255 ******************************************************************************/
256
257union acpi_operand_object *acpi_ut_create_string_object(acpi_size string_size)
258{
259 union acpi_operand_object *string_desc;
260 char *string;
261
262 ACPI_FUNCTION_TRACE_U32(ut_create_string_object, string_size);
263
264 /* Create a new String object */
265
266 string_desc = acpi_ut_create_internal_object(ACPI_TYPE_STRING);
267 if (!string_desc) {
268 return_PTR(NULL);
269 }
270
271 /*
272 * Allocate the actual string buffer -- (Size + 1) for NULL terminator.
273 * NOTE: Zero-length strings are NULL terminated
274 */
275 string = ACPI_ALLOCATE_ZEROED(string_size + 1);
276 if (!string) {
277 ACPI_ERROR((AE_INFO, "Could not allocate size %X",
278 (u32) string_size));
279 acpi_ut_remove_reference(string_desc);
280 return_PTR(NULL);
281 }
282
283 /* Complete string object initialization */
284
285 string_desc->string.pointer = string;
286 string_desc->string.length = (u32) string_size;
287
288 /* Return the new string descriptor */
289
290 return_PTR(string_desc);
291}
292
293/*******************************************************************************
294 *
295 * FUNCTION: acpi_ut_valid_internal_object
296 *
297 * PARAMETERS: Object - Object to be validated
298 *
299 * RETURN: TRUE if object is valid, FALSE otherwise
300 *
301 * DESCRIPTION: Validate a pointer to be an union acpi_operand_object
302 *
303 ******************************************************************************/
304
305u8 acpi_ut_valid_internal_object(void *object)
306{
307
308 ACPI_FUNCTION_NAME(ut_valid_internal_object);
309
310 /* Check for a null pointer */
311
312 if (!object) {
313 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "**** Null Object Ptr\n"));
314 return (FALSE);
315 }
316
317 /* Check the descriptor type field */
318
319 switch (ACPI_GET_DESCRIPTOR_TYPE(object)) {
320 case ACPI_DESC_TYPE_OPERAND:
321
322 /* The object appears to be a valid union acpi_operand_object */
323
324 return (TRUE);
325
326 default:
327 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
328 "%p is not not an ACPI operand obj [%s]\n",
329 object, acpi_ut_get_descriptor_name(object)));
330 break;
331 }
332
333 return (FALSE);
334}
335
336/*******************************************************************************
337 *
338 * FUNCTION: acpi_ut_allocate_object_desc_dbg
339 *
340 * PARAMETERS: module_name - Caller's module name (for error output)
341 * line_number - Caller's line number (for error output)
342 * component_id - Caller's component ID (for error output)
343 *
344 * RETURN: Pointer to newly allocated object descriptor. Null on error
345 *
346 * DESCRIPTION: Allocate a new object descriptor. Gracefully handle
347 * error conditions.
348 *
349 ******************************************************************************/
350
351void *acpi_ut_allocate_object_desc_dbg(const char *module_name,
352 u32 line_number, u32 component_id)
353{
354 union acpi_operand_object *object;
355
356 ACPI_FUNCTION_TRACE(ut_allocate_object_desc_dbg);
357
358 object = acpi_os_acquire_object(acpi_gbl_operand_cache);
359 if (!object) {
360 ACPI_ERROR((module_name, line_number,
361 "Could not allocate an object descriptor"));
362
363 return_PTR(NULL);
364 }
365
366 /* Mark the descriptor type */
367
368 memset(object, 0, sizeof(union acpi_operand_object));
369 ACPI_SET_DESCRIPTOR_TYPE(object, ACPI_DESC_TYPE_OPERAND);
370
371 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "%p Size %X\n",
372 object, (u32) sizeof(union acpi_operand_object)));
373
374 return_PTR(object);
375}
376
377/*******************************************************************************
378 *
379 * FUNCTION: acpi_ut_delete_object_desc
380 *
381 * PARAMETERS: Object - An Acpi internal object to be deleted
382 *
383 * RETURN: None.
384 *
385 * DESCRIPTION: Free an ACPI object descriptor or add it to the object cache
386 *
387 ******************************************************************************/
388
389void acpi_ut_delete_object_desc(union acpi_operand_object *object)
390{
391 ACPI_FUNCTION_TRACE_PTR(ut_delete_object_desc, object);
392
393 /* Object must be an union acpi_operand_object */
394
395 if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) {
396 ACPI_ERROR((AE_INFO,
397 "%p is not an ACPI Operand object [%s]", object,
398 acpi_ut_get_descriptor_name(object)));
399 return_VOID;
400 }
401
402 (void)acpi_os_release_object(acpi_gbl_operand_cache, object);
403 return_VOID;
404}
405
406/*******************************************************************************
407 *
408 * FUNCTION: acpi_ut_get_simple_object_size
409 *
410 * PARAMETERS: internal_object - An ACPI operand object
411 * obj_length - Where the length is returned
412 *
413 * RETURN: Status
414 *
415 * DESCRIPTION: This function is called to determine the space required to
416 * contain a simple object for return to an external user.
417 *
418 * The length includes the object structure plus any additional
419 * needed space.
420 *
421 ******************************************************************************/
422
423static acpi_status
424acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object,
425 acpi_size * obj_length)
426{
427 acpi_size length;
428 acpi_size size;
429 acpi_status status = AE_OK;
430
431 ACPI_FUNCTION_TRACE_PTR(ut_get_simple_object_size, internal_object);
432
433 /*
434 * Handle a null object (Could be a uninitialized package
435 * element -- which is legal)
436 */
437 if (!internal_object) {
438 *obj_length = sizeof(union acpi_object);
439 return_ACPI_STATUS(AE_OK);
440 }
441
442 /* Start with the length of the Acpi object */
443
444 length = sizeof(union acpi_object);
445
446 if (ACPI_GET_DESCRIPTOR_TYPE(internal_object) == ACPI_DESC_TYPE_NAMED) {
447
448 /* Object is a named object (reference), just return the length */
449
450 *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD(length);
451 return_ACPI_STATUS(status);
452 }
453
454 /*
455 * The final length depends on the object type
456 * Strings and Buffers are packed right up against the parent object and
457 * must be accessed bytewise or there may be alignment problems on
458 * certain processors
459 */
460 switch (ACPI_GET_OBJECT_TYPE(internal_object)) {
461 case ACPI_TYPE_STRING:
462
463 length += (acpi_size) internal_object->string.length + 1;
464 break;
465
466 case ACPI_TYPE_BUFFER:
467
468 length += (acpi_size) internal_object->buffer.length;
469 break;
470
471 case ACPI_TYPE_INTEGER:
472 case ACPI_TYPE_PROCESSOR:
473 case ACPI_TYPE_POWER:
474
475 /* No extra data for these types */
476
477 break;
478
479 case ACPI_TYPE_LOCAL_REFERENCE:
480
481 switch (internal_object->reference.class) {
482 case ACPI_REFCLASS_NAME:
483
484 /*
485 * Get the actual length of the full pathname to this object.
486 * The reference will be converted to the pathname to the object
487 */
488 size =
489 acpi_ns_get_pathname_length(internal_object->
490 reference.node);
491 if (!size) {
492 return_ACPI_STATUS(AE_BAD_PARAMETER);
493 }
494
495 length += ACPI_ROUND_UP_TO_NATIVE_WORD(size);
496 break;
497
498 default:
499
500 /*
501 * No other reference opcodes are supported.
502 * Notably, Locals and Args are not supported, but this may be
503 * required eventually.
504 */
505 ACPI_ERROR((AE_INFO,
506 "Cannot convert to external object - "
507 "unsupported Reference Class [%s] %X in object %p",
508 acpi_ut_get_reference_name(internal_object),
509 internal_object->reference.class,
510 internal_object));
511 status = AE_TYPE;
512 break;
513 }
514 break;
515
516 default:
517
518 ACPI_ERROR((AE_INFO, "Cannot convert to external object - "
519 "unsupported type [%s] %X in object %p",
520 acpi_ut_get_object_type_name(internal_object),
521 ACPI_GET_OBJECT_TYPE(internal_object),
522 internal_object));
523 status = AE_TYPE;
524 break;
525 }
526
527 /*
528 * Account for the space required by the object rounded up to the next
529 * multiple of the machine word size. This keeps each object aligned
530 * on a machine word boundary. (preventing alignment faults on some
531 * machines.)
532 */
533 *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD(length);
534 return_ACPI_STATUS(status);
535}
536
537/*******************************************************************************
538 *
539 * FUNCTION: acpi_ut_get_element_length
540 *
541 * PARAMETERS: acpi_pkg_callback
542 *
543 * RETURN: Status
544 *
545 * DESCRIPTION: Get the length of one package element.
546 *
547 ******************************************************************************/
548
549static acpi_status
550acpi_ut_get_element_length(u8 object_type,
551 union acpi_operand_object *source_object,
552 union acpi_generic_state *state, void *context)
553{
554 acpi_status status = AE_OK;
555 struct acpi_pkg_info *info = (struct acpi_pkg_info *)context;
556 acpi_size object_space;
557
558 switch (object_type) {
559 case ACPI_COPY_TYPE_SIMPLE:
560
561 /*
562 * Simple object - just get the size (Null object/entry is handled
563 * here also) and sum it into the running package length
564 */
565 status =
566 acpi_ut_get_simple_object_size(source_object,
567 &object_space);
568 if (ACPI_FAILURE(status)) {
569 return (status);
570 }
571
572 info->length += object_space;
573 break;
574
575 case ACPI_COPY_TYPE_PACKAGE:
576
577 /* Package object - nothing much to do here, let the walk handle it */
578
579 info->num_packages++;
580 state->pkg.this_target_obj = NULL;
581 break;
582
583 default:
584
585 /* No other types allowed */
586
587 return (AE_BAD_PARAMETER);
588 }
589
590 return (status);
591}
592
593/*******************************************************************************
594 *
595 * FUNCTION: acpi_ut_get_package_object_size
596 *
597 * PARAMETERS: internal_object - An ACPI internal object
598 * obj_length - Where the length is returned
599 *
600 * RETURN: Status
601 *
602 * DESCRIPTION: This function is called to determine the space required to
603 * contain a package object for return to an external user.
604 *
605 * This is moderately complex since a package contains other
606 * objects including packages.
607 *
608 ******************************************************************************/
609
610static acpi_status
611acpi_ut_get_package_object_size(union acpi_operand_object *internal_object,
612 acpi_size * obj_length)
613{
614 acpi_status status;
615 struct acpi_pkg_info info;
616
617 ACPI_FUNCTION_TRACE_PTR(ut_get_package_object_size, internal_object);
618
619 info.length = 0;
620 info.object_space = 0;
621 info.num_packages = 1;
622
623 status = acpi_ut_walk_package_tree(internal_object, NULL,
624 acpi_ut_get_element_length, &info);
625 if (ACPI_FAILURE(status)) {
626 return_ACPI_STATUS(status);
627 }
628
629 /*
630 * We have handled all of the objects in all levels of the package.
631 * just add the length of the package objects themselves.
632 * Round up to the next machine word.
633 */
634 info.length += ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object)) *
635 (acpi_size) info.num_packages;
636
637 /* Return the total package length */
638
639 *obj_length = info.length;
640 return_ACPI_STATUS(status);
641}
642
643/*******************************************************************************
644 *
645 * FUNCTION: acpi_ut_get_object_size
646 *
647 * PARAMETERS: internal_object - An ACPI internal object
648 * obj_length - Where the length will be returned
649 *
650 * RETURN: Status
651 *
652 * DESCRIPTION: This function is called to determine the space required to
653 * contain an object for return to an API user.
654 *
655 ******************************************************************************/
656
657acpi_status
658acpi_ut_get_object_size(union acpi_operand_object *internal_object,
659 acpi_size * obj_length)
660{
661 acpi_status status;
662
663 ACPI_FUNCTION_ENTRY();
664
665 if ((ACPI_GET_DESCRIPTOR_TYPE(internal_object) ==
666 ACPI_DESC_TYPE_OPERAND)
667 && (ACPI_GET_OBJECT_TYPE(internal_object) == ACPI_TYPE_PACKAGE)) {
668 status =
669 acpi_ut_get_package_object_size(internal_object,
670 obj_length);
671 } else {
672 status =
673 acpi_ut_get_simple_object_size(internal_object, obj_length);
674 }
675
676 return (status);
677}
diff --git a/drivers/acpi/utilities/utresrc.c b/drivers/acpi/utilities/utresrc.c
deleted file mode 100644
index 0755c5cdbe18..000000000000
--- a/drivers/acpi/utilities/utresrc.c
+++ /dev/null
@@ -1,616 +0,0 @@
1/*******************************************************************************
2 *
3 * Module Name: utresrc - Resource management utilities
4 *
5 ******************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include <acpi/accommon.h>
46#include <acpi/amlresrc.h>
47
48#define _COMPONENT ACPI_UTILITIES
49ACPI_MODULE_NAME("utresrc")
50#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER)
51/*
52 * Strings used to decode resource descriptors.
53 * Used by both the disasssembler and the debugger resource dump routines
54 */
55const char *acpi_gbl_bm_decode[] = {
56 "NotBusMaster",
57 "BusMaster"
58};
59
60const char *acpi_gbl_config_decode[] = {
61 "0 - Good Configuration",
62 "1 - Acceptable Configuration",
63 "2 - Suboptimal Configuration",
64 "3 - ***Invalid Configuration***",
65};
66
67const char *acpi_gbl_consume_decode[] = {
68 "ResourceProducer",
69 "ResourceConsumer"
70};
71
72const char *acpi_gbl_dec_decode[] = {
73 "PosDecode",
74 "SubDecode"
75};
76
77const char *acpi_gbl_he_decode[] = {
78 "Level",
79 "Edge"
80};
81
82const char *acpi_gbl_io_decode[] = {
83 "Decode10",
84 "Decode16"
85};
86
87const char *acpi_gbl_ll_decode[] = {
88 "ActiveHigh",
89 "ActiveLow"
90};
91
92const char *acpi_gbl_max_decode[] = {
93 "MaxNotFixed",
94 "MaxFixed"
95};
96
97const char *acpi_gbl_mem_decode[] = {
98 "NonCacheable",
99 "Cacheable",
100 "WriteCombining",
101 "Prefetchable"
102};
103
104const char *acpi_gbl_min_decode[] = {
105 "MinNotFixed",
106 "MinFixed"
107};
108
109const char *acpi_gbl_mtp_decode[] = {
110 "AddressRangeMemory",
111 "AddressRangeReserved",
112 "AddressRangeACPI",
113 "AddressRangeNVS"
114};
115
116const char *acpi_gbl_rng_decode[] = {
117 "InvalidRanges",
118 "NonISAOnlyRanges",
119 "ISAOnlyRanges",
120 "EntireRange"
121};
122
123const char *acpi_gbl_rw_decode[] = {
124 "ReadOnly",
125 "ReadWrite"
126};
127
128const char *acpi_gbl_shr_decode[] = {
129 "Exclusive",
130 "Shared"
131};
132
133const char *acpi_gbl_siz_decode[] = {
134 "Transfer8",
135 "Transfer8_16",
136 "Transfer16",
137 "InvalidSize"
138};
139
140const char *acpi_gbl_trs_decode[] = {
141 "DenseTranslation",
142 "SparseTranslation"
143};
144
145const char *acpi_gbl_ttp_decode[] = {
146 "TypeStatic",
147 "TypeTranslation"
148};
149
150const char *acpi_gbl_typ_decode[] = {
151 "Compatibility",
152 "TypeA",
153 "TypeB",
154 "TypeF"
155};
156
157#endif
158
159/*
160 * Base sizes of the raw AML resource descriptors, indexed by resource type.
161 * Zero indicates a reserved (and therefore invalid) resource type.
162 */
163const u8 acpi_gbl_resource_aml_sizes[] = {
164 /* Small descriptors */
165
166 0,
167 0,
168 0,
169 0,
170 ACPI_AML_SIZE_SMALL(struct aml_resource_irq),
171 ACPI_AML_SIZE_SMALL(struct aml_resource_dma),
172 ACPI_AML_SIZE_SMALL(struct aml_resource_start_dependent),
173 ACPI_AML_SIZE_SMALL(struct aml_resource_end_dependent),
174 ACPI_AML_SIZE_SMALL(struct aml_resource_io),
175 ACPI_AML_SIZE_SMALL(struct aml_resource_fixed_io),
176 0,
177 0,
178 0,
179 0,
180 ACPI_AML_SIZE_SMALL(struct aml_resource_vendor_small),
181 ACPI_AML_SIZE_SMALL(struct aml_resource_end_tag),
182
183 /* Large descriptors */
184
185 0,
186 ACPI_AML_SIZE_LARGE(struct aml_resource_memory24),
187 ACPI_AML_SIZE_LARGE(struct aml_resource_generic_register),
188 0,
189 ACPI_AML_SIZE_LARGE(struct aml_resource_vendor_large),
190 ACPI_AML_SIZE_LARGE(struct aml_resource_memory32),
191 ACPI_AML_SIZE_LARGE(struct aml_resource_fixed_memory32),
192 ACPI_AML_SIZE_LARGE(struct aml_resource_address32),
193 ACPI_AML_SIZE_LARGE(struct aml_resource_address16),
194 ACPI_AML_SIZE_LARGE(struct aml_resource_extended_irq),
195 ACPI_AML_SIZE_LARGE(struct aml_resource_address64),
196 ACPI_AML_SIZE_LARGE(struct aml_resource_extended_address64)
197};
198
199/*
200 * Resource types, used to validate the resource length field.
201 * The length of fixed-length types must match exactly, variable
202 * lengths must meet the minimum required length, etc.
203 * Zero indicates a reserved (and therefore invalid) resource type.
204 */
205static const u8 acpi_gbl_resource_types[] = {
206 /* Small descriptors */
207
208 0,
209 0,
210 0,
211 0,
212 ACPI_SMALL_VARIABLE_LENGTH,
213 ACPI_FIXED_LENGTH,
214 ACPI_SMALL_VARIABLE_LENGTH,
215 ACPI_FIXED_LENGTH,
216 ACPI_FIXED_LENGTH,
217 ACPI_FIXED_LENGTH,
218 0,
219 0,
220 0,
221 0,
222 ACPI_VARIABLE_LENGTH,
223 ACPI_FIXED_LENGTH,
224
225 /* Large descriptors */
226
227 0,
228 ACPI_FIXED_LENGTH,
229 ACPI_FIXED_LENGTH,
230 0,
231 ACPI_VARIABLE_LENGTH,
232 ACPI_FIXED_LENGTH,
233 ACPI_FIXED_LENGTH,
234 ACPI_VARIABLE_LENGTH,
235 ACPI_VARIABLE_LENGTH,
236 ACPI_VARIABLE_LENGTH,
237 ACPI_VARIABLE_LENGTH,
238 ACPI_FIXED_LENGTH
239};
240
241/*******************************************************************************
242 *
243 * FUNCTION: acpi_ut_walk_aml_resources
244 *
245 * PARAMETERS: Aml - Pointer to the raw AML resource template
246 * aml_length - Length of the entire template
247 * user_function - Called once for each descriptor found. If
248 * NULL, a pointer to the end_tag is returned
249 * Context - Passed to user_function
250 *
251 * RETURN: Status
252 *
253 * DESCRIPTION: Walk a raw AML resource list(buffer). User function called
254 * once for each resource found.
255 *
256 ******************************************************************************/
257
258acpi_status
259acpi_ut_walk_aml_resources(u8 * aml,
260 acpi_size aml_length,
261 acpi_walk_aml_callback user_function, void **context)
262{
263 acpi_status status;
264 u8 *end_aml;
265 u8 resource_index;
266 u32 length;
267 u32 offset = 0;
268
269 ACPI_FUNCTION_TRACE(ut_walk_aml_resources);
270
271 /* The absolute minimum resource template is one end_tag descriptor */
272
273 if (aml_length < sizeof(struct aml_resource_end_tag)) {
274 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
275 }
276
277 /* Point to the end of the resource template buffer */
278
279 end_aml = aml + aml_length;
280
281 /* Walk the byte list, abort on any invalid descriptor type or length */
282
283 while (aml < end_aml) {
284
285 /* Validate the Resource Type and Resource Length */
286
287 status = acpi_ut_validate_resource(aml, &resource_index);
288 if (ACPI_FAILURE(status)) {
289 return_ACPI_STATUS(status);
290 }
291
292 /* Get the length of this descriptor */
293
294 length = acpi_ut_get_descriptor_length(aml);
295
296 /* Invoke the user function */
297
298 if (user_function) {
299 status =
300 user_function(aml, length, offset, resource_index,
301 context);
302 if (ACPI_FAILURE(status)) {
303 return (status);
304 }
305 }
306
307 /* An end_tag descriptor terminates this resource template */
308
309 if (acpi_ut_get_resource_type(aml) ==
310 ACPI_RESOURCE_NAME_END_TAG) {
311 /*
312 * There must be at least one more byte in the buffer for
313 * the 2nd byte of the end_tag
314 */
315 if ((aml + 1) >= end_aml) {
316 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
317 }
318
319 /* Return the pointer to the end_tag if requested */
320
321 if (!user_function) {
322 *context = aml;
323 }
324
325 /* Normal exit */
326
327 return_ACPI_STATUS(AE_OK);
328 }
329
330 aml += length;
331 offset += length;
332 }
333
334 /* Did not find an end_tag descriptor */
335
336 return (AE_AML_NO_RESOURCE_END_TAG);
337}
338
339/*******************************************************************************
340 *
341 * FUNCTION: acpi_ut_validate_resource
342 *
343 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
344 * return_index - Where the resource index is returned. NULL
345 * if the index is not required.
346 *
347 * RETURN: Status, and optionally the Index into the global resource tables
348 *
349 * DESCRIPTION: Validate an AML resource descriptor by checking the Resource
350 * Type and Resource Length. Returns an index into the global
351 * resource information/dispatch tables for later use.
352 *
353 ******************************************************************************/
354
355acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
356{
357 u8 resource_type;
358 u8 resource_index;
359 acpi_rs_length resource_length;
360 acpi_rs_length minimum_resource_length;
361
362 ACPI_FUNCTION_ENTRY();
363
364 /*
365 * 1) Validate the resource_type field (Byte 0)
366 */
367 resource_type = ACPI_GET8(aml);
368
369 /*
370 * Byte 0 contains the descriptor name (Resource Type)
371 * Examine the large/small bit in the resource header
372 */
373 if (resource_type & ACPI_RESOURCE_NAME_LARGE) {
374
375 /* Verify the large resource type (name) against the max */
376
377 if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) {
378 return (AE_AML_INVALID_RESOURCE_TYPE);
379 }
380
381 /*
382 * Large Resource Type -- bits 6:0 contain the name
383 * Translate range 0x80-0x8B to index range 0x10-0x1B
384 */
385 resource_index = (u8) (resource_type - 0x70);
386 } else {
387 /*
388 * Small Resource Type -- bits 6:3 contain the name
389 * Shift range to index range 0x00-0x0F
390 */
391 resource_index = (u8)
392 ((resource_type & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3);
393 }
394
395 /* Check validity of the resource type, zero indicates name is invalid */
396
397 if (!acpi_gbl_resource_types[resource_index]) {
398 return (AE_AML_INVALID_RESOURCE_TYPE);
399 }
400
401 /*
402 * 2) Validate the resource_length field. This ensures that the length
403 * is at least reasonable, and guarantees that it is non-zero.
404 */
405 resource_length = acpi_ut_get_resource_length(aml);
406 minimum_resource_length = acpi_gbl_resource_aml_sizes[resource_index];
407
408 /* Validate based upon the type of resource - fixed length or variable */
409
410 switch (acpi_gbl_resource_types[resource_index]) {
411 case ACPI_FIXED_LENGTH:
412
413 /* Fixed length resource, length must match exactly */
414
415 if (resource_length != minimum_resource_length) {
416 return (AE_AML_BAD_RESOURCE_LENGTH);
417 }
418 break;
419
420 case ACPI_VARIABLE_LENGTH:
421
422 /* Variable length resource, length must be at least the minimum */
423
424 if (resource_length < minimum_resource_length) {
425 return (AE_AML_BAD_RESOURCE_LENGTH);
426 }
427 break;
428
429 case ACPI_SMALL_VARIABLE_LENGTH:
430
431 /* Small variable length resource, length can be (Min) or (Min-1) */
432
433 if ((resource_length > minimum_resource_length) ||
434 (resource_length < (minimum_resource_length - 1))) {
435 return (AE_AML_BAD_RESOURCE_LENGTH);
436 }
437 break;
438
439 default:
440
441 /* Shouldn't happen (because of validation earlier), but be sure */
442
443 return (AE_AML_INVALID_RESOURCE_TYPE);
444 }
445
446 /* Optionally return the resource table index */
447
448 if (return_index) {
449 *return_index = resource_index;
450 }
451
452 return (AE_OK);
453}
454
455/*******************************************************************************
456 *
457 * FUNCTION: acpi_ut_get_resource_type
458 *
459 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
460 *
461 * RETURN: The Resource Type with no extraneous bits (except the
462 * Large/Small descriptor bit -- this is left alone)
463 *
464 * DESCRIPTION: Extract the Resource Type/Name from the first byte of
465 * a resource descriptor.
466 *
467 ******************************************************************************/
468
469u8 acpi_ut_get_resource_type(void *aml)
470{
471 ACPI_FUNCTION_ENTRY();
472
473 /*
474 * Byte 0 contains the descriptor name (Resource Type)
475 * Examine the large/small bit in the resource header
476 */
477 if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) {
478
479 /* Large Resource Type -- bits 6:0 contain the name */
480
481 return (ACPI_GET8(aml));
482 } else {
483 /* Small Resource Type -- bits 6:3 contain the name */
484
485 return ((u8) (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_SMALL_MASK));
486 }
487}
488
489/*******************************************************************************
490 *
491 * FUNCTION: acpi_ut_get_resource_length
492 *
493 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
494 *
495 * RETURN: Byte Length
496 *
497 * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By
498 * definition, this does not include the size of the descriptor
499 * header or the length field itself.
500 *
501 ******************************************************************************/
502
503u16 acpi_ut_get_resource_length(void *aml)
504{
505 acpi_rs_length resource_length;
506
507 ACPI_FUNCTION_ENTRY();
508
509 /*
510 * Byte 0 contains the descriptor name (Resource Type)
511 * Examine the large/small bit in the resource header
512 */
513 if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) {
514
515 /* Large Resource type -- bytes 1-2 contain the 16-bit length */
516
517 ACPI_MOVE_16_TO_16(&resource_length, ACPI_ADD_PTR(u8, aml, 1));
518
519 } else {
520 /* Small Resource type -- bits 2:0 of byte 0 contain the length */
521
522 resource_length = (u16) (ACPI_GET8(aml) &
523 ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK);
524 }
525
526 return (resource_length);
527}
528
529/*******************************************************************************
530 *
531 * FUNCTION: acpi_ut_get_resource_header_length
532 *
533 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
534 *
535 * RETURN: Length of the AML header (depends on large/small descriptor)
536 *
537 * DESCRIPTION: Get the length of the header for this resource.
538 *
539 ******************************************************************************/
540
541u8 acpi_ut_get_resource_header_length(void *aml)
542{
543 ACPI_FUNCTION_ENTRY();
544
545 /* Examine the large/small bit in the resource header */
546
547 if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) {
548 return (sizeof(struct aml_resource_large_header));
549 } else {
550 return (sizeof(struct aml_resource_small_header));
551 }
552}
553
554/*******************************************************************************
555 *
556 * FUNCTION: acpi_ut_get_descriptor_length
557 *
558 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
559 *
560 * RETURN: Byte length
561 *
562 * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the
563 * length of the descriptor header and the length field itself.
564 * Used to walk descriptor lists.
565 *
566 ******************************************************************************/
567
568u32 acpi_ut_get_descriptor_length(void *aml)
569{
570 ACPI_FUNCTION_ENTRY();
571
572 /*
573 * Get the Resource Length (does not include header length) and add
574 * the header length (depends on if this is a small or large resource)
575 */
576 return (acpi_ut_get_resource_length(aml) +
577 acpi_ut_get_resource_header_length(aml));
578}
579
580/*******************************************************************************
581 *
582 * FUNCTION: acpi_ut_get_resource_end_tag
583 *
584 * PARAMETERS: obj_desc - The resource template buffer object
585 * end_tag - Where the pointer to the end_tag is returned
586 *
587 * RETURN: Status, pointer to the end tag
588 *
589 * DESCRIPTION: Find the end_tag resource descriptor in an AML resource template
590 * Note: allows a buffer length of zero.
591 *
592 ******************************************************************************/
593
594acpi_status
595acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc,
596 u8 ** end_tag)
597{
598 acpi_status status;
599
600 ACPI_FUNCTION_TRACE(ut_get_resource_end_tag);
601
602 /* Allow a buffer length of zero */
603
604 if (!obj_desc->buffer.length) {
605 *end_tag = obj_desc->buffer.pointer;
606 return_ACPI_STATUS(AE_OK);
607 }
608
609 /* Validate the template and get a pointer to the end_tag */
610
611 status = acpi_ut_walk_aml_resources(obj_desc->buffer.pointer,
612 obj_desc->buffer.length, NULL,
613 (void **)end_tag);
614
615 return_ACPI_STATUS(status);
616}
diff --git a/drivers/acpi/utilities/utstate.c b/drivers/acpi/utilities/utstate.c
deleted file mode 100644
index 54c3461e2f26..000000000000
--- a/drivers/acpi/utilities/utstate.c
+++ /dev/null
@@ -1,347 +0,0 @@
1/*******************************************************************************
2 *
3 * Module Name: utstate - state object support procedures
4 *
5 ******************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include <acpi/accommon.h>
46
47#define _COMPONENT ACPI_UTILITIES
48ACPI_MODULE_NAME("utstate")
49
50/*******************************************************************************
51 *
52 * FUNCTION: acpi_ut_create_pkg_state_and_push
53 *
54 * PARAMETERS: Object - Object to be added to the new state
55 * Action - Increment/Decrement
56 * state_list - List the state will be added to
57 *
58 * RETURN: Status
59 *
60 * DESCRIPTION: Create a new state and push it
61 *
62 ******************************************************************************/
63acpi_status
64acpi_ut_create_pkg_state_and_push(void *internal_object,
65 void *external_object,
66 u16 index,
67 union acpi_generic_state **state_list)
68{
69 union acpi_generic_state *state;
70
71 ACPI_FUNCTION_ENTRY();
72
73 state =
74 acpi_ut_create_pkg_state(internal_object, external_object, index);
75 if (!state) {
76 return (AE_NO_MEMORY);
77 }
78
79 acpi_ut_push_generic_state(state_list, state);
80 return (AE_OK);
81}
82
83/*******************************************************************************
84 *
85 * FUNCTION: acpi_ut_push_generic_state
86 *
87 * PARAMETERS: list_head - Head of the state stack
88 * State - State object to push
89 *
90 * RETURN: None
91 *
92 * DESCRIPTION: Push a state object onto a state stack
93 *
94 ******************************************************************************/
95
96void
97acpi_ut_push_generic_state(union acpi_generic_state **list_head,
98 union acpi_generic_state *state)
99{
100 ACPI_FUNCTION_TRACE(ut_push_generic_state);
101
102 /* Push the state object onto the front of the list (stack) */
103
104 state->common.next = *list_head;
105 *list_head = state;
106
107 return_VOID;
108}
109
110/*******************************************************************************
111 *
112 * FUNCTION: acpi_ut_pop_generic_state
113 *
114 * PARAMETERS: list_head - Head of the state stack
115 *
116 * RETURN: The popped state object
117 *
118 * DESCRIPTION: Pop a state object from a state stack
119 *
120 ******************************************************************************/
121
122union acpi_generic_state *acpi_ut_pop_generic_state(union acpi_generic_state
123 **list_head)
124{
125 union acpi_generic_state *state;
126
127 ACPI_FUNCTION_TRACE(ut_pop_generic_state);
128
129 /* Remove the state object at the head of the list (stack) */
130
131 state = *list_head;
132 if (state) {
133
134 /* Update the list head */
135
136 *list_head = state->common.next;
137 }
138
139 return_PTR(state);
140}
141
142/*******************************************************************************
143 *
144 * FUNCTION: acpi_ut_create_generic_state
145 *
146 * PARAMETERS: None
147 *
148 * RETURN: The new state object. NULL on failure.
149 *
150 * DESCRIPTION: Create a generic state object. Attempt to obtain one from
151 * the global state cache; If none available, create a new one.
152 *
153 ******************************************************************************/
154
155union acpi_generic_state *acpi_ut_create_generic_state(void)
156{
157 union acpi_generic_state *state;
158
159 ACPI_FUNCTION_ENTRY();
160
161 state = acpi_os_acquire_object(acpi_gbl_state_cache);
162 if (state) {
163
164 /* Initialize */
165 memset(state, 0, sizeof(union acpi_generic_state));
166 state->common.descriptor_type = ACPI_DESC_TYPE_STATE;
167 }
168
169 return (state);
170}
171
172/*******************************************************************************
173 *
174 * FUNCTION: acpi_ut_create_thread_state
175 *
176 * PARAMETERS: None
177 *
178 * RETURN: New Thread State. NULL on failure
179 *
180 * DESCRIPTION: Create a "Thread State" - a flavor of the generic state used
181 * to track per-thread info during method execution
182 *
183 ******************************************************************************/
184
185struct acpi_thread_state *acpi_ut_create_thread_state(void)
186{
187 union acpi_generic_state *state;
188
189 ACPI_FUNCTION_TRACE(ut_create_thread_state);
190
191 /* Create the generic state object */
192
193 state = acpi_ut_create_generic_state();
194 if (!state) {
195 return_PTR(NULL);
196 }
197
198 /* Init fields specific to the update struct */
199
200 state->common.descriptor_type = ACPI_DESC_TYPE_STATE_THREAD;
201 state->thread.thread_id = acpi_os_get_thread_id();
202
203 /* Check for invalid thread ID - zero is very bad, it will break things */
204
205 if (!state->thread.thread_id) {
206 ACPI_ERROR((AE_INFO, "Invalid zero ID from AcpiOsGetThreadId"));
207 state->thread.thread_id = (acpi_thread_id) 1;
208 }
209
210 return_PTR((struct acpi_thread_state *)state);
211}
212
213/*******************************************************************************
214 *
215 * FUNCTION: acpi_ut_create_update_state
216 *
217 * PARAMETERS: Object - Initial Object to be installed in the state
218 * Action - Update action to be performed
219 *
220 * RETURN: New state object, null on failure
221 *
222 * DESCRIPTION: Create an "Update State" - a flavor of the generic state used
223 * to update reference counts and delete complex objects such
224 * as packages.
225 *
226 ******************************************************************************/
227
228union acpi_generic_state *acpi_ut_create_update_state(union acpi_operand_object
229 *object, u16 action)
230{
231 union acpi_generic_state *state;
232
233 ACPI_FUNCTION_TRACE_PTR(ut_create_update_state, object);
234
235 /* Create the generic state object */
236
237 state = acpi_ut_create_generic_state();
238 if (!state) {
239 return_PTR(NULL);
240 }
241
242 /* Init fields specific to the update struct */
243
244 state->common.descriptor_type = ACPI_DESC_TYPE_STATE_UPDATE;
245 state->update.object = object;
246 state->update.value = action;
247
248 return_PTR(state);
249}
250
251/*******************************************************************************
252 *
253 * FUNCTION: acpi_ut_create_pkg_state
254 *
255 * PARAMETERS: Object - Initial Object to be installed in the state
256 * Action - Update action to be performed
257 *
258 * RETURN: New state object, null on failure
259 *
260 * DESCRIPTION: Create a "Package State"
261 *
262 ******************************************************************************/
263
264union acpi_generic_state *acpi_ut_create_pkg_state(void *internal_object,
265 void *external_object,
266 u16 index)
267{
268 union acpi_generic_state *state;
269
270 ACPI_FUNCTION_TRACE_PTR(ut_create_pkg_state, internal_object);
271
272 /* Create the generic state object */
273
274 state = acpi_ut_create_generic_state();
275 if (!state) {
276 return_PTR(NULL);
277 }
278
279 /* Init fields specific to the update struct */
280
281 state->common.descriptor_type = ACPI_DESC_TYPE_STATE_PACKAGE;
282 state->pkg.source_object = (union acpi_operand_object *)internal_object;
283 state->pkg.dest_object = external_object;
284 state->pkg.index = index;
285 state->pkg.num_packages = 1;
286
287 return_PTR(state);
288}
289
290/*******************************************************************************
291 *
292 * FUNCTION: acpi_ut_create_control_state
293 *
294 * PARAMETERS: None
295 *
296 * RETURN: New state object, null on failure
297 *
298 * DESCRIPTION: Create a "Control State" - a flavor of the generic state used
299 * to support nested IF/WHILE constructs in the AML.
300 *
301 ******************************************************************************/
302
303union acpi_generic_state *acpi_ut_create_control_state(void)
304{
305 union acpi_generic_state *state;
306
307 ACPI_FUNCTION_TRACE(ut_create_control_state);
308
309 /* Create the generic state object */
310
311 state = acpi_ut_create_generic_state();
312 if (!state) {
313 return_PTR(NULL);
314 }
315
316 /* Init fields specific to the control struct */
317
318 state->common.descriptor_type = ACPI_DESC_TYPE_STATE_CONTROL;
319 state->common.state = ACPI_CONTROL_CONDITIONAL_EXECUTING;
320
321 return_PTR(state);
322}
323
324/*******************************************************************************
325 *
326 * FUNCTION: acpi_ut_delete_generic_state
327 *
328 * PARAMETERS: State - The state object to be deleted
329 *
330 * RETURN: None
331 *
332 * DESCRIPTION: Release a state object to the state cache. NULL state objects
333 * are ignored.
334 *
335 ******************************************************************************/
336
337void acpi_ut_delete_generic_state(union acpi_generic_state *state)
338{
339 ACPI_FUNCTION_TRACE(ut_delete_generic_state);
340
341 /* Ignore null state */
342
343 if (state) {
344 (void)acpi_os_release_object(acpi_gbl_state_cache, state);
345 }
346 return_VOID;
347}
diff --git a/drivers/acpi/utilities/utxface.c b/drivers/acpi/utilities/utxface.c
deleted file mode 100644
index 5b27724a2749..000000000000
--- a/drivers/acpi/utilities/utxface.c
+++ /dev/null
@@ -1,512 +0,0 @@
1/******************************************************************************
2 *
3 * Module Name: utxface - External interfaces for "global" ACPI functions
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include <acpi/accommon.h>
46#include <acpi/acevents.h>
47#include <acpi/acnamesp.h>
48#include <acpi/acdebug.h>
49#include <acpi/actables.h>
50
51#define _COMPONENT ACPI_UTILITIES
52ACPI_MODULE_NAME("utxface")
53
54#ifndef ACPI_ASL_COMPILER
55/*******************************************************************************
56 *
57 * FUNCTION: acpi_initialize_subsystem
58 *
59 * PARAMETERS: None
60 *
61 * RETURN: Status
62 *
63 * DESCRIPTION: Initializes all global variables. This is the first function
64 * called, so any early initialization belongs here.
65 *
66 ******************************************************************************/
67acpi_status __init acpi_initialize_subsystem(void)
68{
69 acpi_status status;
70
71 ACPI_FUNCTION_TRACE(acpi_initialize_subsystem);
72
73 acpi_gbl_startup_flags = ACPI_SUBSYSTEM_INITIALIZE;
74 ACPI_DEBUG_EXEC(acpi_ut_init_stack_ptr_trace());
75
76 /* Initialize the OS-Dependent layer */
77
78 status = acpi_os_initialize();
79 if (ACPI_FAILURE(status)) {
80 ACPI_EXCEPTION((AE_INFO, status, "During OSL initialization"));
81 return_ACPI_STATUS(status);
82 }
83
84 /* Initialize all globals used by the subsystem */
85
86 status = acpi_ut_init_globals();
87 if (ACPI_FAILURE(status)) {
88 ACPI_EXCEPTION((AE_INFO, status,
89 "During initialization of globals"));
90 return_ACPI_STATUS(status);
91 }
92
93 /* Create the default mutex objects */
94
95 status = acpi_ut_mutex_initialize();
96 if (ACPI_FAILURE(status)) {
97 ACPI_EXCEPTION((AE_INFO, status,
98 "During Global Mutex creation"));
99 return_ACPI_STATUS(status);
100 }
101
102 /*
103 * Initialize the namespace manager and
104 * the root of the namespace tree
105 */
106 status = acpi_ns_root_initialize();
107 if (ACPI_FAILURE(status)) {
108 ACPI_EXCEPTION((AE_INFO, status,
109 "During Namespace initialization"));
110 return_ACPI_STATUS(status);
111 }
112
113 /* If configured, initialize the AML debugger */
114
115 ACPI_DEBUGGER_EXEC(status = acpi_db_initialize());
116 return_ACPI_STATUS(status);
117}
118
119/*******************************************************************************
120 *
121 * FUNCTION: acpi_enable_subsystem
122 *
123 * PARAMETERS: Flags - Init/enable Options
124 *
125 * RETURN: Status
126 *
127 * DESCRIPTION: Completes the subsystem initialization including hardware.
128 * Puts system into ACPI mode if it isn't already.
129 *
130 ******************************************************************************/
131acpi_status acpi_enable_subsystem(u32 flags)
132{
133 acpi_status status = AE_OK;
134
135 ACPI_FUNCTION_TRACE(acpi_enable_subsystem);
136
137 /* Enable ACPI mode */
138
139 if (!(flags & ACPI_NO_ACPI_ENABLE)) {
140 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
141 "[Init] Going into ACPI mode\n"));
142
143 acpi_gbl_original_mode = acpi_hw_get_mode();
144
145 status = acpi_enable();
146 if (ACPI_FAILURE(status)) {
147 ACPI_WARNING((AE_INFO, "AcpiEnable failed"));
148 return_ACPI_STATUS(status);
149 }
150 }
151
152 /*
153 * Obtain a permanent mapping for the FACS. This is required for the
154 * Global Lock and the Firmware Waking Vector
155 */
156 status = acpi_tb_initialize_facs();
157 if (ACPI_FAILURE(status)) {
158 ACPI_WARNING((AE_INFO, "Could not map the FACS table"));
159 return_ACPI_STATUS(status);
160 }
161
162 /*
163 * Install the default op_region handlers. These are installed unless
164 * other handlers have already been installed via the
165 * install_address_space_handler interface.
166 */
167 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
168 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
169 "[Init] Installing default address space handlers\n"));
170
171 status = acpi_ev_install_region_handlers();
172 if (ACPI_FAILURE(status)) {
173 return_ACPI_STATUS(status);
174 }
175 }
176
177 /*
178 * Initialize ACPI Event handling (Fixed and General Purpose)
179 *
180 * Note1: We must have the hardware and events initialized before we can
181 * execute any control methods safely. Any control method can require
182 * ACPI hardware support, so the hardware must be fully initialized before
183 * any method execution!
184 *
185 * Note2: Fixed events are initialized and enabled here. GPEs are
186 * initialized, but cannot be enabled until after the hardware is
187 * completely initialized (SCI and global_lock activated)
188 */
189 if (!(flags & ACPI_NO_EVENT_INIT)) {
190 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
191 "[Init] Initializing ACPI events\n"));
192
193 status = acpi_ev_initialize_events();
194 if (ACPI_FAILURE(status)) {
195 return_ACPI_STATUS(status);
196 }
197 }
198
199 /*
200 * Install the SCI handler and Global Lock handler. This completes the
201 * hardware initialization.
202 */
203 if (!(flags & ACPI_NO_HANDLER_INIT)) {
204 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
205 "[Init] Installing SCI/GL handlers\n"));
206
207 status = acpi_ev_install_xrupt_handlers();
208 if (ACPI_FAILURE(status)) {
209 return_ACPI_STATUS(status);
210 }
211 }
212
213 return_ACPI_STATUS(status);
214}
215
216ACPI_EXPORT_SYMBOL(acpi_enable_subsystem)
217
218/*******************************************************************************
219 *
220 * FUNCTION: acpi_initialize_objects
221 *
222 * PARAMETERS: Flags - Init/enable Options
223 *
224 * RETURN: Status
225 *
226 * DESCRIPTION: Completes namespace initialization by initializing device
227 * objects and executing AML code for Regions, buffers, etc.
228 *
229 ******************************************************************************/
230acpi_status acpi_initialize_objects(u32 flags)
231{
232 acpi_status status = AE_OK;
233
234 ACPI_FUNCTION_TRACE(acpi_initialize_objects);
235
236 /*
237 * Run all _REG methods
238 *
239 * Note: Any objects accessed by the _REG methods will be automatically
240 * initialized, even if they contain executable AML (see the call to
241 * acpi_ns_initialize_objects below).
242 */
243 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
244 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
245 "[Init] Executing _REG OpRegion methods\n"));
246
247 status = acpi_ev_initialize_op_regions();
248 if (ACPI_FAILURE(status)) {
249 return_ACPI_STATUS(status);
250 }
251 }
252
253 /*
254 * Initialize the objects that remain uninitialized. This runs the
255 * executable AML that may be part of the declaration of these objects:
256 * operation_regions, buffer_fields, Buffers, and Packages.
257 */
258 if (!(flags & ACPI_NO_OBJECT_INIT)) {
259 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
260 "[Init] Completing Initialization of ACPI Objects\n"));
261
262 status = acpi_ns_initialize_objects();
263 if (ACPI_FAILURE(status)) {
264 return_ACPI_STATUS(status);
265 }
266 }
267
268 /*
269 * Initialize all device objects in the namespace. This runs the device
270 * _STA and _INI methods.
271 */
272 if (!(flags & ACPI_NO_DEVICE_INIT)) {
273 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
274 "[Init] Initializing ACPI Devices\n"));
275
276 status = acpi_ns_initialize_devices();
277 if (ACPI_FAILURE(status)) {
278 return_ACPI_STATUS(status);
279 }
280 }
281
282 /*
283 * Complete the GPE initialization for the GPE blocks defined in the FADT
284 * (GPE block 0 and 1).
285 *
286 * Note1: This is where the _PRW methods are executed for the GPEs. These
287 * methods can only be executed after the SCI and Global Lock handlers are
288 * installed and initialized.
289 *
290 * Note2: Currently, there seems to be no need to run the _REG methods
291 * before execution of the _PRW methods and enabling of the GPEs.
292 */
293 if (!(flags & ACPI_NO_EVENT_INIT)) {
294 status = acpi_ev_install_fadt_gpes();
295 if (ACPI_FAILURE(status))
296 return (status);
297 }
298
299 /*
300 * Empty the caches (delete the cached objects) on the assumption that
301 * the table load filled them up more than they will be at runtime --
302 * thus wasting non-paged memory.
303 */
304 status = acpi_purge_cached_objects();
305
306 acpi_gbl_startup_flags |= ACPI_INITIALIZED_OK;
307 return_ACPI_STATUS(status);
308}
309
310ACPI_EXPORT_SYMBOL(acpi_initialize_objects)
311
312#endif
313/*******************************************************************************
314 *
315 * FUNCTION: acpi_terminate
316 *
317 * PARAMETERS: None
318 *
319 * RETURN: Status
320 *
321 * DESCRIPTION: Shutdown the ACPI subsystem. Release all resources.
322 *
323 ******************************************************************************/
324acpi_status acpi_terminate(void)
325{
326 acpi_status status;
327
328 ACPI_FUNCTION_TRACE(acpi_terminate);
329
330 /* Terminate the AML Debugger if present */
331
332 ACPI_DEBUGGER_EXEC(acpi_gbl_db_terminate_threads = TRUE);
333
334 /* Shutdown and free all resources */
335
336 acpi_ut_subsystem_shutdown();
337
338 /* Free the mutex objects */
339
340 acpi_ut_mutex_terminate();
341
342#ifdef ACPI_DEBUGGER
343
344 /* Shut down the debugger */
345
346 acpi_db_terminate();
347#endif
348
349 /* Now we can shutdown the OS-dependent layer */
350
351 status = acpi_os_terminate();
352 return_ACPI_STATUS(status);
353}
354
355ACPI_EXPORT_SYMBOL(acpi_terminate)
356#ifndef ACPI_ASL_COMPILER
357#ifdef ACPI_FUTURE_USAGE
358/*******************************************************************************
359 *
360 * FUNCTION: acpi_subsystem_status
361 *
362 * PARAMETERS: None
363 *
364 * RETURN: Status of the ACPI subsystem
365 *
366 * DESCRIPTION: Other drivers that use the ACPI subsystem should call this
367 * before making any other calls, to ensure the subsystem
368 * initialized successfully.
369 *
370 ******************************************************************************/
371acpi_status acpi_subsystem_status(void)
372{
373
374 if (acpi_gbl_startup_flags & ACPI_INITIALIZED_OK) {
375 return (AE_OK);
376 } else {
377 return (AE_ERROR);
378 }
379}
380
381ACPI_EXPORT_SYMBOL(acpi_subsystem_status)
382
383/*******************************************************************************
384 *
385 * FUNCTION: acpi_get_system_info
386 *
387 * PARAMETERS: out_buffer - A buffer to receive the resources for the
388 * device
389 *
390 * RETURN: Status - the status of the call
391 *
392 * DESCRIPTION: This function is called to get information about the current
393 * state of the ACPI subsystem. It will return system information
394 * in the out_buffer.
395 *
396 * If the function fails an appropriate status will be returned
397 * and the value of out_buffer is undefined.
398 *
399 ******************************************************************************/
400acpi_status acpi_get_system_info(struct acpi_buffer * out_buffer)
401{
402 struct acpi_system_info *info_ptr;
403 acpi_status status;
404
405 ACPI_FUNCTION_TRACE(acpi_get_system_info);
406
407 /* Parameter validation */
408
409 status = acpi_ut_validate_buffer(out_buffer);
410 if (ACPI_FAILURE(status)) {
411 return_ACPI_STATUS(status);
412 }
413
414 /* Validate/Allocate/Clear caller buffer */
415
416 status =
417 acpi_ut_initialize_buffer(out_buffer,
418 sizeof(struct acpi_system_info));
419 if (ACPI_FAILURE(status)) {
420 return_ACPI_STATUS(status);
421 }
422
423 /*
424 * Populate the return buffer
425 */
426 info_ptr = (struct acpi_system_info *)out_buffer->pointer;
427
428 info_ptr->acpi_ca_version = ACPI_CA_VERSION;
429
430 /* System flags (ACPI capabilities) */
431
432 info_ptr->flags = ACPI_SYS_MODE_ACPI;
433
434 /* Timer resolution - 24 or 32 bits */
435
436 if (acpi_gbl_FADT.flags & ACPI_FADT_32BIT_TIMER) {
437 info_ptr->timer_resolution = 24;
438 } else {
439 info_ptr->timer_resolution = 32;
440 }
441
442 /* Clear the reserved fields */
443
444 info_ptr->reserved1 = 0;
445 info_ptr->reserved2 = 0;
446
447 /* Current debug levels */
448
449 info_ptr->debug_layer = acpi_dbg_layer;
450 info_ptr->debug_level = acpi_dbg_level;
451
452 return_ACPI_STATUS(AE_OK);
453}
454
455ACPI_EXPORT_SYMBOL(acpi_get_system_info)
456
457/*****************************************************************************
458 *
459 * FUNCTION: acpi_install_initialization_handler
460 *
461 * PARAMETERS: Handler - Callback procedure
462 * Function - Not (currently) used, see below
463 *
464 * RETURN: Status
465 *
466 * DESCRIPTION: Install an initialization handler
467 *
468 * TBD: When a second function is added, must save the Function also.
469 *
470 ****************************************************************************/
471acpi_status
472acpi_install_initialization_handler(acpi_init_handler handler, u32 function)
473{
474
475 if (!handler) {
476 return (AE_BAD_PARAMETER);
477 }
478
479 if (acpi_gbl_init_handler) {
480 return (AE_ALREADY_EXISTS);
481 }
482
483 acpi_gbl_init_handler = handler;
484 return AE_OK;
485}
486
487ACPI_EXPORT_SYMBOL(acpi_install_initialization_handler)
488#endif /* ACPI_FUTURE_USAGE */
489/*****************************************************************************
490 *
491 * FUNCTION: acpi_purge_cached_objects
492 *
493 * PARAMETERS: None
494 *
495 * RETURN: Status
496 *
497 * DESCRIPTION: Empty all caches (delete the cached objects)
498 *
499 ****************************************************************************/
500acpi_status acpi_purge_cached_objects(void)
501{
502 ACPI_FUNCTION_TRACE(acpi_purge_cached_objects);
503
504 (void)acpi_os_purge_cache(acpi_gbl_state_cache);
505 (void)acpi_os_purge_cache(acpi_gbl_operand_cache);
506 (void)acpi_os_purge_cache(acpi_gbl_ps_node_cache);
507 (void)acpi_os_purge_cache(acpi_gbl_ps_node_ext_cache);
508 return_ACPI_STATUS(AE_OK);
509}
510
511ACPI_EXPORT_SYMBOL(acpi_purge_cached_objects)
512#endif