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