Commit 091f4d718620a79698e1c8ca3e9acbf78eb62da3
Committed by
Len Brown
1 parent
5f8902acf8
Exists in
master
and in
7 other branches
ACPICA: Predefined name repair: fix NULL package elements
For the predefined methods that return fixed-length packages (or subpackages), attempt repair for a NULL element. Create an Integer of value 0, a NULL String, or a zero-length buffer as appropriate. http://www.acpica.org/bugzilla/show_bug.cgi?id=818 Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lin Ming <ming.m.lin@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
Showing 5 changed files with 209 additions and 92 deletions Inline Diff
drivers/acpi/acpica/aclocal.h
1 | /****************************************************************************** | 1 | /****************************************************************************** |
2 | * | 2 | * |
3 | * Name: aclocal.h - Internal data types used across the ACPI subsystem | 3 | * Name: aclocal.h - Internal data types used across the ACPI subsystem |
4 | * | 4 | * |
5 | *****************************************************************************/ | 5 | *****************************************************************************/ |
6 | 6 | ||
7 | /* | 7 | /* |
8 | * Copyright (C) 2000 - 2010, Intel Corp. | 8 | * Copyright (C) 2000 - 2010, Intel Corp. |
9 | * All rights reserved. | 9 | * All rights reserved. |
10 | * | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright |
15 | * notice, this list of conditions, and the following disclaimer, | 15 | * notice, this list of conditions, and the following disclaimer, |
16 | * without modification. | 16 | * without modification. |
17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | 17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
18 | * substantially similar to the "NO WARRANTY" disclaimer below | 18 | * substantially similar to the "NO WARRANTY" disclaimer below |
19 | * ("Disclaimer") and any redistribution must be conditioned upon | 19 | * ("Disclaimer") and any redistribution must be conditioned upon |
20 | * including a substantially similar Disclaimer requirement for further | 20 | * including a substantially similar Disclaimer requirement for further |
21 | * binary redistribution. | 21 | * binary redistribution. |
22 | * 3. Neither the names of the above-listed copyright holders nor the names | 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 | 23 | * of any contributors may be used to endorse or promote products derived |
24 | * from this software without specific prior written permission. | 24 | * from this software without specific prior written permission. |
25 | * | 25 | * |
26 | * Alternatively, this software may be distributed under the terms of the | 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 | 27 | * GNU General Public License ("GPL") version 2 as published by the Free |
28 | * Software Foundation. | 28 | * Software Foundation. |
29 | * | 29 | * |
30 | * NO WARRANTY | 30 | * NO WARRANTY |
31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | 33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR |
34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | 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 | 40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
41 | * POSSIBILITY OF SUCH DAMAGES. | 41 | * POSSIBILITY OF SUCH DAMAGES. |
42 | */ | 42 | */ |
43 | 43 | ||
44 | #ifndef __ACLOCAL_H__ | 44 | #ifndef __ACLOCAL_H__ |
45 | #define __ACLOCAL_H__ | 45 | #define __ACLOCAL_H__ |
46 | 46 | ||
47 | /* acpisrc:struct_defs -- for acpisrc conversion */ | 47 | /* acpisrc:struct_defs -- for acpisrc conversion */ |
48 | 48 | ||
49 | #define ACPI_SERIALIZED 0xFF | 49 | #define ACPI_SERIALIZED 0xFF |
50 | 50 | ||
51 | typedef u32 acpi_mutex_handle; | 51 | typedef u32 acpi_mutex_handle; |
52 | #define ACPI_GLOBAL_LOCK (acpi_semaphore) (-1) | 52 | #define ACPI_GLOBAL_LOCK (acpi_semaphore) (-1) |
53 | 53 | ||
54 | /* Total number of aml opcodes defined */ | 54 | /* Total number of aml opcodes defined */ |
55 | 55 | ||
56 | #define AML_NUM_OPCODES 0x7F | 56 | #define AML_NUM_OPCODES 0x7F |
57 | 57 | ||
58 | /* Forward declarations */ | 58 | /* Forward declarations */ |
59 | 59 | ||
60 | struct acpi_walk_state; | 60 | struct acpi_walk_state; |
61 | struct acpi_obj_mutex; | 61 | struct acpi_obj_mutex; |
62 | union acpi_parse_object; | 62 | union acpi_parse_object; |
63 | 63 | ||
64 | /***************************************************************************** | 64 | /***************************************************************************** |
65 | * | 65 | * |
66 | * Mutex typedefs and structs | 66 | * Mutex typedefs and structs |
67 | * | 67 | * |
68 | ****************************************************************************/ | 68 | ****************************************************************************/ |
69 | 69 | ||
70 | /* | 70 | /* |
71 | * Predefined handles for the mutex objects used within the subsystem | 71 | * Predefined handles for the mutex objects used within the subsystem |
72 | * All mutex objects are automatically created by acpi_ut_mutex_initialize. | 72 | * All mutex objects are automatically created by acpi_ut_mutex_initialize. |
73 | * | 73 | * |
74 | * The acquire/release ordering protocol is implied via this list. Mutexes | 74 | * The acquire/release ordering protocol is implied via this list. Mutexes |
75 | * with a lower value must be acquired before mutexes with a higher value. | 75 | * with a lower value must be acquired before mutexes with a higher value. |
76 | * | 76 | * |
77 | * NOTE: any changes here must be reflected in the acpi_gbl_mutex_names | 77 | * NOTE: any changes here must be reflected in the acpi_gbl_mutex_names |
78 | * table below also! | 78 | * table below also! |
79 | */ | 79 | */ |
80 | #define ACPI_MTX_INTERPRETER 0 /* AML Interpreter, main lock */ | 80 | #define ACPI_MTX_INTERPRETER 0 /* AML Interpreter, main lock */ |
81 | #define ACPI_MTX_NAMESPACE 1 /* ACPI Namespace */ | 81 | #define ACPI_MTX_NAMESPACE 1 /* ACPI Namespace */ |
82 | #define ACPI_MTX_TABLES 2 /* Data for ACPI tables */ | 82 | #define ACPI_MTX_TABLES 2 /* Data for ACPI tables */ |
83 | #define ACPI_MTX_EVENTS 3 /* Data for ACPI events */ | 83 | #define ACPI_MTX_EVENTS 3 /* Data for ACPI events */ |
84 | #define ACPI_MTX_CACHES 4 /* Internal caches, general purposes */ | 84 | #define ACPI_MTX_CACHES 4 /* Internal caches, general purposes */ |
85 | #define ACPI_MTX_MEMORY 5 /* Debug memory tracking lists */ | 85 | #define ACPI_MTX_MEMORY 5 /* Debug memory tracking lists */ |
86 | #define ACPI_MTX_DEBUG_CMD_COMPLETE 6 /* AML debugger */ | 86 | #define ACPI_MTX_DEBUG_CMD_COMPLETE 6 /* AML debugger */ |
87 | #define ACPI_MTX_DEBUG_CMD_READY 7 /* AML debugger */ | 87 | #define ACPI_MTX_DEBUG_CMD_READY 7 /* AML debugger */ |
88 | 88 | ||
89 | #define ACPI_MAX_MUTEX 7 | 89 | #define ACPI_MAX_MUTEX 7 |
90 | #define ACPI_NUM_MUTEX ACPI_MAX_MUTEX+1 | 90 | #define ACPI_NUM_MUTEX ACPI_MAX_MUTEX+1 |
91 | 91 | ||
92 | #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) | 92 | #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) |
93 | #ifdef DEFINE_ACPI_GLOBALS | 93 | #ifdef DEFINE_ACPI_GLOBALS |
94 | 94 | ||
95 | /* Debug names for the mutexes above */ | 95 | /* Debug names for the mutexes above */ |
96 | 96 | ||
97 | static char *acpi_gbl_mutex_names[ACPI_NUM_MUTEX] = { | 97 | static char *acpi_gbl_mutex_names[ACPI_NUM_MUTEX] = { |
98 | "ACPI_MTX_Interpreter", | 98 | "ACPI_MTX_Interpreter", |
99 | "ACPI_MTX_Namespace", | 99 | "ACPI_MTX_Namespace", |
100 | "ACPI_MTX_Tables", | 100 | "ACPI_MTX_Tables", |
101 | "ACPI_MTX_Events", | 101 | "ACPI_MTX_Events", |
102 | "ACPI_MTX_Caches", | 102 | "ACPI_MTX_Caches", |
103 | "ACPI_MTX_Memory", | 103 | "ACPI_MTX_Memory", |
104 | "ACPI_MTX_CommandComplete", | 104 | "ACPI_MTX_CommandComplete", |
105 | "ACPI_MTX_CommandReady" | 105 | "ACPI_MTX_CommandReady" |
106 | }; | 106 | }; |
107 | 107 | ||
108 | #endif | 108 | #endif |
109 | #endif | 109 | #endif |
110 | 110 | ||
111 | /* Lock structure for reader/writer interfaces */ | 111 | /* Lock structure for reader/writer interfaces */ |
112 | 112 | ||
113 | struct acpi_rw_lock { | 113 | struct acpi_rw_lock { |
114 | acpi_mutex writer_mutex; | 114 | acpi_mutex writer_mutex; |
115 | acpi_mutex reader_mutex; | 115 | acpi_mutex reader_mutex; |
116 | u32 num_readers; | 116 | u32 num_readers; |
117 | }; | 117 | }; |
118 | 118 | ||
119 | /* | 119 | /* |
120 | * Predefined handles for spinlocks used within the subsystem. | 120 | * Predefined handles for spinlocks used within the subsystem. |
121 | * These spinlocks are created by acpi_ut_mutex_initialize | 121 | * These spinlocks are created by acpi_ut_mutex_initialize |
122 | */ | 122 | */ |
123 | #define ACPI_LOCK_GPES 0 | 123 | #define ACPI_LOCK_GPES 0 |
124 | #define ACPI_LOCK_HARDWARE 1 | 124 | #define ACPI_LOCK_HARDWARE 1 |
125 | 125 | ||
126 | #define ACPI_MAX_LOCK 1 | 126 | #define ACPI_MAX_LOCK 1 |
127 | #define ACPI_NUM_LOCK ACPI_MAX_LOCK+1 | 127 | #define ACPI_NUM_LOCK ACPI_MAX_LOCK+1 |
128 | 128 | ||
129 | /* This Thread ID means that the mutex is not in use (unlocked) */ | 129 | /* This Thread ID means that the mutex is not in use (unlocked) */ |
130 | 130 | ||
131 | #define ACPI_MUTEX_NOT_ACQUIRED (acpi_thread_id) 0 | 131 | #define ACPI_MUTEX_NOT_ACQUIRED (acpi_thread_id) 0 |
132 | 132 | ||
133 | /* Table for the global mutexes */ | 133 | /* Table for the global mutexes */ |
134 | 134 | ||
135 | struct acpi_mutex_info { | 135 | struct acpi_mutex_info { |
136 | acpi_mutex mutex; | 136 | acpi_mutex mutex; |
137 | u32 use_count; | 137 | u32 use_count; |
138 | acpi_thread_id thread_id; | 138 | acpi_thread_id thread_id; |
139 | }; | 139 | }; |
140 | 140 | ||
141 | /* Lock flag parameter for various interfaces */ | 141 | /* Lock flag parameter for various interfaces */ |
142 | 142 | ||
143 | #define ACPI_MTX_DO_NOT_LOCK 0 | 143 | #define ACPI_MTX_DO_NOT_LOCK 0 |
144 | #define ACPI_MTX_LOCK 1 | 144 | #define ACPI_MTX_LOCK 1 |
145 | 145 | ||
146 | /* Field access granularities */ | 146 | /* Field access granularities */ |
147 | 147 | ||
148 | #define ACPI_FIELD_BYTE_GRANULARITY 1 | 148 | #define ACPI_FIELD_BYTE_GRANULARITY 1 |
149 | #define ACPI_FIELD_WORD_GRANULARITY 2 | 149 | #define ACPI_FIELD_WORD_GRANULARITY 2 |
150 | #define ACPI_FIELD_DWORD_GRANULARITY 4 | 150 | #define ACPI_FIELD_DWORD_GRANULARITY 4 |
151 | #define ACPI_FIELD_QWORD_GRANULARITY 8 | 151 | #define ACPI_FIELD_QWORD_GRANULARITY 8 |
152 | 152 | ||
153 | #define ACPI_ENTRY_NOT_FOUND NULL | 153 | #define ACPI_ENTRY_NOT_FOUND NULL |
154 | 154 | ||
155 | /***************************************************************************** | 155 | /***************************************************************************** |
156 | * | 156 | * |
157 | * Namespace typedefs and structs | 157 | * Namespace typedefs and structs |
158 | * | 158 | * |
159 | ****************************************************************************/ | 159 | ****************************************************************************/ |
160 | 160 | ||
161 | /* Operational modes of the AML interpreter/scanner */ | 161 | /* Operational modes of the AML interpreter/scanner */ |
162 | 162 | ||
163 | typedef enum { | 163 | typedef enum { |
164 | ACPI_IMODE_LOAD_PASS1 = 0x01, | 164 | ACPI_IMODE_LOAD_PASS1 = 0x01, |
165 | ACPI_IMODE_LOAD_PASS2 = 0x02, | 165 | ACPI_IMODE_LOAD_PASS2 = 0x02, |
166 | ACPI_IMODE_EXECUTE = 0x03 | 166 | ACPI_IMODE_EXECUTE = 0x03 |
167 | } acpi_interpreter_mode; | 167 | } acpi_interpreter_mode; |
168 | 168 | ||
169 | /* | 169 | /* |
170 | * The Namespace Node describes a named object that appears in the AML. | 170 | * The Namespace Node describes a named object that appears in the AML. |
171 | * descriptor_type is used to differentiate between internal descriptors. | 171 | * descriptor_type is used to differentiate between internal descriptors. |
172 | * | 172 | * |
173 | * The node is optimized for both 32-bit and 64-bit platforms: | 173 | * The node is optimized for both 32-bit and 64-bit platforms: |
174 | * 20 bytes for the 32-bit case, 32 bytes for the 64-bit case. | 174 | * 20 bytes for the 32-bit case, 32 bytes for the 64-bit case. |
175 | * | 175 | * |
176 | * Note: The descriptor_type and Type fields must appear in the identical | 176 | * Note: The descriptor_type and Type fields must appear in the identical |
177 | * position in both the struct acpi_namespace_node and union acpi_operand_object | 177 | * position in both the struct acpi_namespace_node and union acpi_operand_object |
178 | * structures. | 178 | * structures. |
179 | */ | 179 | */ |
180 | struct acpi_namespace_node { | 180 | struct acpi_namespace_node { |
181 | union acpi_operand_object *object; /* Interpreter object */ | 181 | union acpi_operand_object *object; /* Interpreter object */ |
182 | u8 descriptor_type; /* Differentiate object descriptor types */ | 182 | u8 descriptor_type; /* Differentiate object descriptor types */ |
183 | u8 type; /* ACPI Type associated with this name */ | 183 | u8 type; /* ACPI Type associated with this name */ |
184 | u8 flags; /* Miscellaneous flags */ | 184 | u8 flags; /* Miscellaneous flags */ |
185 | acpi_owner_id owner_id; /* Node creator */ | 185 | acpi_owner_id owner_id; /* Node creator */ |
186 | union acpi_name_union name; /* ACPI Name, always 4 chars per ACPI spec */ | 186 | union acpi_name_union name; /* ACPI Name, always 4 chars per ACPI spec */ |
187 | struct acpi_namespace_node *child; /* First child */ | 187 | struct acpi_namespace_node *child; /* First child */ |
188 | struct acpi_namespace_node *peer; /* Peer. Parent if ANOBJ_END_OF_PEER_LIST set */ | 188 | struct acpi_namespace_node *peer; /* Peer. Parent if ANOBJ_END_OF_PEER_LIST set */ |
189 | 189 | ||
190 | /* | 190 | /* |
191 | * The following fields are used by the ASL compiler and disassembler only | 191 | * The following fields are used by the ASL compiler and disassembler only |
192 | */ | 192 | */ |
193 | #ifdef ACPI_LARGE_NAMESPACE_NODE | 193 | #ifdef ACPI_LARGE_NAMESPACE_NODE |
194 | union acpi_parse_object *op; | 194 | union acpi_parse_object *op; |
195 | u32 value; | 195 | u32 value; |
196 | u32 length; | 196 | u32 length; |
197 | #endif | 197 | #endif |
198 | }; | 198 | }; |
199 | 199 | ||
200 | /* Namespace Node flags */ | 200 | /* Namespace Node flags */ |
201 | 201 | ||
202 | #define ANOBJ_END_OF_PEER_LIST 0x01 /* End-of-list, Peer field points to parent */ | 202 | #define ANOBJ_END_OF_PEER_LIST 0x01 /* End-of-list, Peer field points to parent */ |
203 | #define ANOBJ_TEMPORARY 0x02 /* Node is create by a method and is temporary */ | 203 | #define ANOBJ_TEMPORARY 0x02 /* Node is create by a method and is temporary */ |
204 | #define ANOBJ_METHOD_ARG 0x04 /* Node is a method argument */ | 204 | #define ANOBJ_METHOD_ARG 0x04 /* Node is a method argument */ |
205 | #define ANOBJ_METHOD_LOCAL 0x08 /* Node is a method local */ | 205 | #define ANOBJ_METHOD_LOCAL 0x08 /* Node is a method local */ |
206 | #define ANOBJ_SUBTREE_HAS_INI 0x10 /* Used to optimize device initialization */ | 206 | #define ANOBJ_SUBTREE_HAS_INI 0x10 /* Used to optimize device initialization */ |
207 | #define ANOBJ_EVALUATED 0x20 /* Set on first evaluation of node */ | 207 | #define ANOBJ_EVALUATED 0x20 /* Set on first evaluation of node */ |
208 | #define ANOBJ_ALLOCATED_BUFFER 0x40 /* Method AML buffer is dynamic (install_method) */ | 208 | #define ANOBJ_ALLOCATED_BUFFER 0x40 /* Method AML buffer is dynamic (install_method) */ |
209 | 209 | ||
210 | #define ANOBJ_IS_EXTERNAL 0x08 /* i_aSL only: This object created via External() */ | 210 | #define ANOBJ_IS_EXTERNAL 0x08 /* i_aSL only: This object created via External() */ |
211 | #define ANOBJ_METHOD_NO_RETVAL 0x10 /* i_aSL only: Method has no return value */ | 211 | #define ANOBJ_METHOD_NO_RETVAL 0x10 /* i_aSL only: Method has no return value */ |
212 | #define ANOBJ_METHOD_SOME_NO_RETVAL 0x20 /* i_aSL only: Method has at least one return value */ | 212 | #define ANOBJ_METHOD_SOME_NO_RETVAL 0x20 /* i_aSL only: Method has at least one return value */ |
213 | #define ANOBJ_IS_BIT_OFFSET 0x40 /* i_aSL only: Reference is a bit offset */ | 213 | #define ANOBJ_IS_BIT_OFFSET 0x40 /* i_aSL only: Reference is a bit offset */ |
214 | #define ANOBJ_IS_REFERENCED 0x80 /* i_aSL only: Object was referenced */ | 214 | #define ANOBJ_IS_REFERENCED 0x80 /* i_aSL only: Object was referenced */ |
215 | 215 | ||
216 | /* One internal RSDT for table management */ | 216 | /* One internal RSDT for table management */ |
217 | 217 | ||
218 | struct acpi_internal_rsdt { | 218 | struct acpi_internal_rsdt { |
219 | struct acpi_table_desc *tables; | 219 | struct acpi_table_desc *tables; |
220 | u32 count; | 220 | u32 count; |
221 | u32 size; | 221 | u32 size; |
222 | u8 flags; | 222 | u8 flags; |
223 | }; | 223 | }; |
224 | 224 | ||
225 | /* Flags for above */ | 225 | /* Flags for above */ |
226 | 226 | ||
227 | #define ACPI_ROOT_ORIGIN_UNKNOWN (0) /* ~ORIGIN_ALLOCATED */ | 227 | #define ACPI_ROOT_ORIGIN_UNKNOWN (0) /* ~ORIGIN_ALLOCATED */ |
228 | #define ACPI_ROOT_ORIGIN_ALLOCATED (1) | 228 | #define ACPI_ROOT_ORIGIN_ALLOCATED (1) |
229 | #define ACPI_ROOT_ALLOW_RESIZE (2) | 229 | #define ACPI_ROOT_ALLOW_RESIZE (2) |
230 | 230 | ||
231 | /* Predefined (fixed) table indexes */ | 231 | /* Predefined (fixed) table indexes */ |
232 | 232 | ||
233 | #define ACPI_TABLE_INDEX_DSDT (0) | 233 | #define ACPI_TABLE_INDEX_DSDT (0) |
234 | #define ACPI_TABLE_INDEX_FACS (1) | 234 | #define ACPI_TABLE_INDEX_FACS (1) |
235 | 235 | ||
236 | struct acpi_find_context { | 236 | struct acpi_find_context { |
237 | char *search_for; | 237 | char *search_for; |
238 | acpi_handle *list; | 238 | acpi_handle *list; |
239 | u32 *count; | 239 | u32 *count; |
240 | }; | 240 | }; |
241 | 241 | ||
242 | struct acpi_ns_search_data { | 242 | struct acpi_ns_search_data { |
243 | struct acpi_namespace_node *node; | 243 | struct acpi_namespace_node *node; |
244 | }; | 244 | }; |
245 | 245 | ||
246 | /* Object types used during package copies */ | 246 | /* Object types used during package copies */ |
247 | 247 | ||
248 | #define ACPI_COPY_TYPE_SIMPLE 0 | 248 | #define ACPI_COPY_TYPE_SIMPLE 0 |
249 | #define ACPI_COPY_TYPE_PACKAGE 1 | 249 | #define ACPI_COPY_TYPE_PACKAGE 1 |
250 | 250 | ||
251 | /* Info structure used to convert external<->internal namestrings */ | 251 | /* Info structure used to convert external<->internal namestrings */ |
252 | 252 | ||
253 | struct acpi_namestring_info { | 253 | struct acpi_namestring_info { |
254 | const char *external_name; | 254 | const char *external_name; |
255 | const char *next_external_char; | 255 | const char *next_external_char; |
256 | char *internal_name; | 256 | char *internal_name; |
257 | u32 length; | 257 | u32 length; |
258 | u32 num_segments; | 258 | u32 num_segments; |
259 | u32 num_carats; | 259 | u32 num_carats; |
260 | u8 fully_qualified; | 260 | u8 fully_qualified; |
261 | }; | 261 | }; |
262 | 262 | ||
263 | /* Field creation info */ | 263 | /* Field creation info */ |
264 | 264 | ||
265 | struct acpi_create_field_info { | 265 | struct acpi_create_field_info { |
266 | struct acpi_namespace_node *region_node; | 266 | struct acpi_namespace_node *region_node; |
267 | struct acpi_namespace_node *field_node; | 267 | struct acpi_namespace_node *field_node; |
268 | struct acpi_namespace_node *register_node; | 268 | struct acpi_namespace_node *register_node; |
269 | struct acpi_namespace_node *data_register_node; | 269 | struct acpi_namespace_node *data_register_node; |
270 | u32 bank_value; | 270 | u32 bank_value; |
271 | u32 field_bit_position; | 271 | u32 field_bit_position; |
272 | u32 field_bit_length; | 272 | u32 field_bit_length; |
273 | u8 field_flags; | 273 | u8 field_flags; |
274 | u8 attribute; | 274 | u8 attribute; |
275 | u8 field_type; | 275 | u8 field_type; |
276 | }; | 276 | }; |
277 | 277 | ||
278 | typedef | 278 | typedef |
279 | acpi_status(*ACPI_INTERNAL_METHOD) (struct acpi_walk_state * walk_state); | 279 | acpi_status(*ACPI_INTERNAL_METHOD) (struct acpi_walk_state * walk_state); |
280 | 280 | ||
281 | /* | 281 | /* |
282 | * Bitmapped ACPI types. Used internally only | 282 | * Bitmapped ACPI types. Used internally only |
283 | */ | 283 | */ |
284 | #define ACPI_BTYPE_ANY 0x00000000 | 284 | #define ACPI_BTYPE_ANY 0x00000000 |
285 | #define ACPI_BTYPE_INTEGER 0x00000001 | 285 | #define ACPI_BTYPE_INTEGER 0x00000001 |
286 | #define ACPI_BTYPE_STRING 0x00000002 | 286 | #define ACPI_BTYPE_STRING 0x00000002 |
287 | #define ACPI_BTYPE_BUFFER 0x00000004 | 287 | #define ACPI_BTYPE_BUFFER 0x00000004 |
288 | #define ACPI_BTYPE_PACKAGE 0x00000008 | 288 | #define ACPI_BTYPE_PACKAGE 0x00000008 |
289 | #define ACPI_BTYPE_FIELD_UNIT 0x00000010 | 289 | #define ACPI_BTYPE_FIELD_UNIT 0x00000010 |
290 | #define ACPI_BTYPE_DEVICE 0x00000020 | 290 | #define ACPI_BTYPE_DEVICE 0x00000020 |
291 | #define ACPI_BTYPE_EVENT 0x00000040 | 291 | #define ACPI_BTYPE_EVENT 0x00000040 |
292 | #define ACPI_BTYPE_METHOD 0x00000080 | 292 | #define ACPI_BTYPE_METHOD 0x00000080 |
293 | #define ACPI_BTYPE_MUTEX 0x00000100 | 293 | #define ACPI_BTYPE_MUTEX 0x00000100 |
294 | #define ACPI_BTYPE_REGION 0x00000200 | 294 | #define ACPI_BTYPE_REGION 0x00000200 |
295 | #define ACPI_BTYPE_POWER 0x00000400 | 295 | #define ACPI_BTYPE_POWER 0x00000400 |
296 | #define ACPI_BTYPE_PROCESSOR 0x00000800 | 296 | #define ACPI_BTYPE_PROCESSOR 0x00000800 |
297 | #define ACPI_BTYPE_THERMAL 0x00001000 | 297 | #define ACPI_BTYPE_THERMAL 0x00001000 |
298 | #define ACPI_BTYPE_BUFFER_FIELD 0x00002000 | 298 | #define ACPI_BTYPE_BUFFER_FIELD 0x00002000 |
299 | #define ACPI_BTYPE_DDB_HANDLE 0x00004000 | 299 | #define ACPI_BTYPE_DDB_HANDLE 0x00004000 |
300 | #define ACPI_BTYPE_DEBUG_OBJECT 0x00008000 | 300 | #define ACPI_BTYPE_DEBUG_OBJECT 0x00008000 |
301 | #define ACPI_BTYPE_REFERENCE 0x00010000 | 301 | #define ACPI_BTYPE_REFERENCE 0x00010000 |
302 | #define ACPI_BTYPE_RESOURCE 0x00020000 | 302 | #define ACPI_BTYPE_RESOURCE 0x00020000 |
303 | 303 | ||
304 | #define ACPI_BTYPE_COMPUTE_DATA (ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER) | 304 | #define ACPI_BTYPE_COMPUTE_DATA (ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER) |
305 | 305 | ||
306 | #define ACPI_BTYPE_DATA (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_PACKAGE) | 306 | #define ACPI_BTYPE_DATA (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_PACKAGE) |
307 | #define ACPI_BTYPE_DATA_REFERENCE (ACPI_BTYPE_DATA | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE) | 307 | #define ACPI_BTYPE_DATA_REFERENCE (ACPI_BTYPE_DATA | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE) |
308 | #define ACPI_BTYPE_DEVICE_OBJECTS (ACPI_BTYPE_DEVICE | ACPI_BTYPE_THERMAL | ACPI_BTYPE_PROCESSOR) | 308 | #define ACPI_BTYPE_DEVICE_OBJECTS (ACPI_BTYPE_DEVICE | ACPI_BTYPE_THERMAL | ACPI_BTYPE_PROCESSOR) |
309 | #define ACPI_BTYPE_OBJECTS_AND_REFS 0x0001FFFF /* ARG or LOCAL */ | 309 | #define ACPI_BTYPE_OBJECTS_AND_REFS 0x0001FFFF /* ARG or LOCAL */ |
310 | #define ACPI_BTYPE_ALL_OBJECTS 0x0000FFFF | 310 | #define ACPI_BTYPE_ALL_OBJECTS 0x0000FFFF |
311 | 311 | ||
312 | /* | 312 | /* |
313 | * Information structure for ACPI predefined names. | 313 | * Information structure for ACPI predefined names. |
314 | * Each entry in the table contains the following items: | 314 | * Each entry in the table contains the following items: |
315 | * | 315 | * |
316 | * Name - The ACPI reserved name | 316 | * Name - The ACPI reserved name |
317 | * param_count - Number of arguments to the method | 317 | * param_count - Number of arguments to the method |
318 | * expected_return_btypes - Allowed type(s) for the return value | 318 | * expected_return_btypes - Allowed type(s) for the return value |
319 | */ | 319 | */ |
320 | struct acpi_name_info { | 320 | struct acpi_name_info { |
321 | char name[ACPI_NAME_SIZE]; | 321 | char name[ACPI_NAME_SIZE]; |
322 | u8 param_count; | 322 | u8 param_count; |
323 | u8 expected_btypes; | 323 | u8 expected_btypes; |
324 | }; | 324 | }; |
325 | 325 | ||
326 | /* | 326 | /* |
327 | * Secondary information structures for ACPI predefined objects that return | 327 | * Secondary information structures for ACPI predefined objects that return |
328 | * package objects. This structure appears as the next entry in the table | 328 | * package objects. This structure appears as the next entry in the table |
329 | * after the NAME_INFO structure above. | 329 | * after the NAME_INFO structure above. |
330 | * | 330 | * |
331 | * The reason for this is to minimize the size of the predefined name table. | 331 | * The reason for this is to minimize the size of the predefined name table. |
332 | */ | 332 | */ |
333 | 333 | ||
334 | /* | 334 | /* |
335 | * Used for ACPI_PTYPE1_FIXED, ACPI_PTYPE1_VAR, ACPI_PTYPE2, | 335 | * Used for ACPI_PTYPE1_FIXED, ACPI_PTYPE1_VAR, ACPI_PTYPE2, |
336 | * ACPI_PTYPE2_MIN, ACPI_PTYPE2_PKG_COUNT, ACPI_PTYPE2_COUNT | 336 | * ACPI_PTYPE2_MIN, ACPI_PTYPE2_PKG_COUNT, ACPI_PTYPE2_COUNT |
337 | */ | 337 | */ |
338 | struct acpi_package_info { | 338 | struct acpi_package_info { |
339 | u8 type; | 339 | u8 type; |
340 | u8 object_type1; | 340 | u8 object_type1; |
341 | u8 count1; | 341 | u8 count1; |
342 | u8 object_type2; | 342 | u8 object_type2; |
343 | u8 count2; | 343 | u8 count2; |
344 | u8 reserved; | 344 | u8 reserved; |
345 | }; | 345 | }; |
346 | 346 | ||
347 | /* Used for ACPI_PTYPE2_FIXED */ | 347 | /* Used for ACPI_PTYPE2_FIXED */ |
348 | 348 | ||
349 | struct acpi_package_info2 { | 349 | struct acpi_package_info2 { |
350 | u8 type; | 350 | u8 type; |
351 | u8 count; | 351 | u8 count; |
352 | u8 object_type[4]; | 352 | u8 object_type[4]; |
353 | }; | 353 | }; |
354 | 354 | ||
355 | /* Used for ACPI_PTYPE1_OPTION */ | 355 | /* Used for ACPI_PTYPE1_OPTION */ |
356 | 356 | ||
357 | struct acpi_package_info3 { | 357 | struct acpi_package_info3 { |
358 | u8 type; | 358 | u8 type; |
359 | u8 count; | 359 | u8 count; |
360 | u8 object_type[2]; | 360 | u8 object_type[2]; |
361 | u8 tail_object_type; | 361 | u8 tail_object_type; |
362 | u8 reserved; | 362 | u8 reserved; |
363 | }; | 363 | }; |
364 | 364 | ||
365 | union acpi_predefined_info { | 365 | union acpi_predefined_info { |
366 | struct acpi_name_info info; | 366 | struct acpi_name_info info; |
367 | struct acpi_package_info ret_info; | 367 | struct acpi_package_info ret_info; |
368 | struct acpi_package_info2 ret_info2; | 368 | struct acpi_package_info2 ret_info2; |
369 | struct acpi_package_info3 ret_info3; | 369 | struct acpi_package_info3 ret_info3; |
370 | }; | 370 | }; |
371 | 371 | ||
372 | /* Data block used during object validation */ | 372 | /* Data block used during object validation */ |
373 | 373 | ||
374 | struct acpi_predefined_data { | 374 | struct acpi_predefined_data { |
375 | char *pathname; | 375 | char *pathname; |
376 | const union acpi_predefined_info *predefined; | 376 | const union acpi_predefined_info *predefined; |
377 | union acpi_operand_object *parent_package; | ||
377 | u32 flags; | 378 | u32 flags; |
378 | u8 node_flags; | 379 | u8 node_flags; |
379 | }; | 380 | }; |
380 | 381 | ||
381 | /* Defines for Flags field above */ | 382 | /* Defines for Flags field above */ |
382 | 383 | ||
383 | #define ACPI_OBJECT_REPAIRED 1 | 384 | #define ACPI_OBJECT_REPAIRED 1 |
384 | 385 | ||
385 | /* | 386 | /* |
386 | * Bitmapped return value types | 387 | * Bitmapped return value types |
387 | * Note: the actual data types must be contiguous, a loop in nspredef.c | 388 | * Note: the actual data types must be contiguous, a loop in nspredef.c |
388 | * depends on this. | 389 | * depends on this. |
389 | */ | 390 | */ |
390 | #define ACPI_RTYPE_ANY 0x00 | 391 | #define ACPI_RTYPE_ANY 0x00 |
391 | #define ACPI_RTYPE_NONE 0x01 | 392 | #define ACPI_RTYPE_NONE 0x01 |
392 | #define ACPI_RTYPE_INTEGER 0x02 | 393 | #define ACPI_RTYPE_INTEGER 0x02 |
393 | #define ACPI_RTYPE_STRING 0x04 | 394 | #define ACPI_RTYPE_STRING 0x04 |
394 | #define ACPI_RTYPE_BUFFER 0x08 | 395 | #define ACPI_RTYPE_BUFFER 0x08 |
395 | #define ACPI_RTYPE_PACKAGE 0x10 | 396 | #define ACPI_RTYPE_PACKAGE 0x10 |
396 | #define ACPI_RTYPE_REFERENCE 0x20 | 397 | #define ACPI_RTYPE_REFERENCE 0x20 |
397 | #define ACPI_RTYPE_ALL 0x3F | 398 | #define ACPI_RTYPE_ALL 0x3F |
398 | 399 | ||
399 | #define ACPI_NUM_RTYPES 5 /* Number of actual object types */ | 400 | #define ACPI_NUM_RTYPES 5 /* Number of actual object types */ |
400 | 401 | ||
401 | /***************************************************************************** | 402 | /***************************************************************************** |
402 | * | 403 | * |
403 | * Event typedefs and structs | 404 | * Event typedefs and structs |
404 | * | 405 | * |
405 | ****************************************************************************/ | 406 | ****************************************************************************/ |
406 | 407 | ||
407 | /* Dispatch info for each GPE -- either a method or handler, cannot be both */ | 408 | /* Dispatch info for each GPE -- either a method or handler, cannot be both */ |
408 | 409 | ||
409 | struct acpi_handler_info { | 410 | struct acpi_handler_info { |
410 | acpi_event_handler address; /* Address of handler, if any */ | 411 | acpi_event_handler address; /* Address of handler, if any */ |
411 | void *context; /* Context to be passed to handler */ | 412 | void *context; /* Context to be passed to handler */ |
412 | struct acpi_namespace_node *method_node; /* Method node for this GPE level (saved) */ | 413 | struct acpi_namespace_node *method_node; /* Method node for this GPE level (saved) */ |
413 | }; | 414 | }; |
414 | 415 | ||
415 | union acpi_gpe_dispatch_info { | 416 | union acpi_gpe_dispatch_info { |
416 | struct acpi_namespace_node *method_node; /* Method node for this GPE level */ | 417 | struct acpi_namespace_node *method_node; /* Method node for this GPE level */ |
417 | struct acpi_handler_info *handler; | 418 | struct acpi_handler_info *handler; |
418 | }; | 419 | }; |
419 | 420 | ||
420 | /* | 421 | /* |
421 | * Information about a GPE, one per each GPE in an array. | 422 | * Information about a GPE, one per each GPE in an array. |
422 | * NOTE: Important to keep this struct as small as possible. | 423 | * NOTE: Important to keep this struct as small as possible. |
423 | */ | 424 | */ |
424 | struct acpi_gpe_event_info { | 425 | struct acpi_gpe_event_info { |
425 | union acpi_gpe_dispatch_info dispatch; /* Either Method or Handler */ | 426 | union acpi_gpe_dispatch_info dispatch; /* Either Method or Handler */ |
426 | struct acpi_gpe_register_info *register_info; /* Backpointer to register info */ | 427 | struct acpi_gpe_register_info *register_info; /* Backpointer to register info */ |
427 | u8 flags; /* Misc info about this GPE */ | 428 | u8 flags; /* Misc info about this GPE */ |
428 | u8 gpe_number; /* This GPE */ | 429 | u8 gpe_number; /* This GPE */ |
429 | }; | 430 | }; |
430 | 431 | ||
431 | /* Information about a GPE register pair, one per each status/enable pair in an array */ | 432 | /* Information about a GPE register pair, one per each status/enable pair in an array */ |
432 | 433 | ||
433 | struct acpi_gpe_register_info { | 434 | struct acpi_gpe_register_info { |
434 | struct acpi_generic_address status_address; /* Address of status reg */ | 435 | struct acpi_generic_address status_address; /* Address of status reg */ |
435 | struct acpi_generic_address enable_address; /* Address of enable reg */ | 436 | struct acpi_generic_address enable_address; /* Address of enable reg */ |
436 | u8 enable_for_wake; /* GPEs to keep enabled when sleeping */ | 437 | u8 enable_for_wake; /* GPEs to keep enabled when sleeping */ |
437 | u8 enable_for_run; /* GPEs to keep enabled when running */ | 438 | u8 enable_for_run; /* GPEs to keep enabled when running */ |
438 | u8 base_gpe_number; /* Base GPE number for this register */ | 439 | u8 base_gpe_number; /* Base GPE number for this register */ |
439 | }; | 440 | }; |
440 | 441 | ||
441 | /* | 442 | /* |
442 | * Information about a GPE register block, one per each installed block -- | 443 | * Information about a GPE register block, one per each installed block -- |
443 | * GPE0, GPE1, and one per each installed GPE Block Device. | 444 | * GPE0, GPE1, and one per each installed GPE Block Device. |
444 | */ | 445 | */ |
445 | struct acpi_gpe_block_info { | 446 | struct acpi_gpe_block_info { |
446 | struct acpi_namespace_node *node; | 447 | struct acpi_namespace_node *node; |
447 | struct acpi_gpe_block_info *previous; | 448 | struct acpi_gpe_block_info *previous; |
448 | struct acpi_gpe_block_info *next; | 449 | struct acpi_gpe_block_info *next; |
449 | struct acpi_gpe_xrupt_info *xrupt_block; /* Backpointer to interrupt block */ | 450 | struct acpi_gpe_xrupt_info *xrupt_block; /* Backpointer to interrupt block */ |
450 | struct acpi_gpe_register_info *register_info; /* One per GPE register pair */ | 451 | struct acpi_gpe_register_info *register_info; /* One per GPE register pair */ |
451 | struct acpi_gpe_event_info *event_info; /* One for each GPE */ | 452 | struct acpi_gpe_event_info *event_info; /* One for each GPE */ |
452 | struct acpi_generic_address block_address; /* Base address of the block */ | 453 | struct acpi_generic_address block_address; /* Base address of the block */ |
453 | u32 register_count; /* Number of register pairs in block */ | 454 | u32 register_count; /* Number of register pairs in block */ |
454 | u8 block_base_number; /* Base GPE number for this block */ | 455 | u8 block_base_number; /* Base GPE number for this block */ |
455 | }; | 456 | }; |
456 | 457 | ||
457 | /* Information about GPE interrupt handlers, one per each interrupt level used for GPEs */ | 458 | /* Information about GPE interrupt handlers, one per each interrupt level used for GPEs */ |
458 | 459 | ||
459 | struct acpi_gpe_xrupt_info { | 460 | struct acpi_gpe_xrupt_info { |
460 | struct acpi_gpe_xrupt_info *previous; | 461 | struct acpi_gpe_xrupt_info *previous; |
461 | struct acpi_gpe_xrupt_info *next; | 462 | struct acpi_gpe_xrupt_info *next; |
462 | struct acpi_gpe_block_info *gpe_block_list_head; /* List of GPE blocks for this xrupt */ | 463 | struct acpi_gpe_block_info *gpe_block_list_head; /* List of GPE blocks for this xrupt */ |
463 | u32 interrupt_number; /* System interrupt number */ | 464 | u32 interrupt_number; /* System interrupt number */ |
464 | }; | 465 | }; |
465 | 466 | ||
466 | struct acpi_gpe_walk_info { | 467 | struct acpi_gpe_walk_info { |
467 | struct acpi_namespace_node *gpe_device; | 468 | struct acpi_namespace_node *gpe_device; |
468 | struct acpi_gpe_block_info *gpe_block; | 469 | struct acpi_gpe_block_info *gpe_block; |
469 | }; | 470 | }; |
470 | 471 | ||
471 | struct acpi_gpe_device_info { | 472 | struct acpi_gpe_device_info { |
472 | u32 index; | 473 | u32 index; |
473 | u32 next_block_base_index; | 474 | u32 next_block_base_index; |
474 | acpi_status status; | 475 | acpi_status status; |
475 | struct acpi_namespace_node *gpe_device; | 476 | struct acpi_namespace_node *gpe_device; |
476 | }; | 477 | }; |
477 | 478 | ||
478 | typedef acpi_status(*acpi_gpe_callback) (struct acpi_gpe_xrupt_info *gpe_xrupt_info, | 479 | typedef acpi_status(*acpi_gpe_callback) (struct acpi_gpe_xrupt_info *gpe_xrupt_info, |
479 | struct acpi_gpe_block_info *gpe_block, void *context); | 480 | struct acpi_gpe_block_info *gpe_block, void *context); |
480 | 481 | ||
481 | /* Information about each particular fixed event */ | 482 | /* Information about each particular fixed event */ |
482 | 483 | ||
483 | struct acpi_fixed_event_handler { | 484 | struct acpi_fixed_event_handler { |
484 | acpi_event_handler handler; /* Address of handler. */ | 485 | acpi_event_handler handler; /* Address of handler. */ |
485 | void *context; /* Context to be passed to handler */ | 486 | void *context; /* Context to be passed to handler */ |
486 | }; | 487 | }; |
487 | 488 | ||
488 | struct acpi_fixed_event_info { | 489 | struct acpi_fixed_event_info { |
489 | u8 status_register_id; | 490 | u8 status_register_id; |
490 | u8 enable_register_id; | 491 | u8 enable_register_id; |
491 | u16 status_bit_mask; | 492 | u16 status_bit_mask; |
492 | u16 enable_bit_mask; | 493 | u16 enable_bit_mask; |
493 | }; | 494 | }; |
494 | 495 | ||
495 | /* Information used during field processing */ | 496 | /* Information used during field processing */ |
496 | 497 | ||
497 | struct acpi_field_info { | 498 | struct acpi_field_info { |
498 | u8 skip_field; | 499 | u8 skip_field; |
499 | u8 field_flag; | 500 | u8 field_flag; |
500 | u32 pkg_length; | 501 | u32 pkg_length; |
501 | }; | 502 | }; |
502 | 503 | ||
503 | /***************************************************************************** | 504 | /***************************************************************************** |
504 | * | 505 | * |
505 | * Generic "state" object for stacks | 506 | * Generic "state" object for stacks |
506 | * | 507 | * |
507 | ****************************************************************************/ | 508 | ****************************************************************************/ |
508 | 509 | ||
509 | #define ACPI_CONTROL_NORMAL 0xC0 | 510 | #define ACPI_CONTROL_NORMAL 0xC0 |
510 | #define ACPI_CONTROL_CONDITIONAL_EXECUTING 0xC1 | 511 | #define ACPI_CONTROL_CONDITIONAL_EXECUTING 0xC1 |
511 | #define ACPI_CONTROL_PREDICATE_EXECUTING 0xC2 | 512 | #define ACPI_CONTROL_PREDICATE_EXECUTING 0xC2 |
512 | #define ACPI_CONTROL_PREDICATE_FALSE 0xC3 | 513 | #define ACPI_CONTROL_PREDICATE_FALSE 0xC3 |
513 | #define ACPI_CONTROL_PREDICATE_TRUE 0xC4 | 514 | #define ACPI_CONTROL_PREDICATE_TRUE 0xC4 |
514 | 515 | ||
515 | #define ACPI_STATE_COMMON \ | 516 | #define ACPI_STATE_COMMON \ |
516 | void *next; \ | 517 | void *next; \ |
517 | u8 descriptor_type; /* To differentiate various internal objs */\ | 518 | u8 descriptor_type; /* To differentiate various internal objs */\ |
518 | u8 flags; \ | 519 | u8 flags; \ |
519 | u16 value; \ | 520 | u16 value; \ |
520 | u16 state; | 521 | u16 state; |
521 | 522 | ||
522 | /* There are 2 bytes available here until the next natural alignment boundary */ | 523 | /* There are 2 bytes available here until the next natural alignment boundary */ |
523 | 524 | ||
524 | struct acpi_common_state { | 525 | struct acpi_common_state { |
525 | ACPI_STATE_COMMON}; | 526 | ACPI_STATE_COMMON}; |
526 | 527 | ||
527 | /* | 528 | /* |
528 | * Update state - used to traverse complex objects such as packages | 529 | * Update state - used to traverse complex objects such as packages |
529 | */ | 530 | */ |
530 | struct acpi_update_state { | 531 | struct acpi_update_state { |
531 | ACPI_STATE_COMMON union acpi_operand_object *object; | 532 | ACPI_STATE_COMMON union acpi_operand_object *object; |
532 | }; | 533 | }; |
533 | 534 | ||
534 | /* | 535 | /* |
535 | * Pkg state - used to traverse nested package structures | 536 | * Pkg state - used to traverse nested package structures |
536 | */ | 537 | */ |
537 | struct acpi_pkg_state { | 538 | struct acpi_pkg_state { |
538 | ACPI_STATE_COMMON u16 index; | 539 | ACPI_STATE_COMMON u16 index; |
539 | union acpi_operand_object *source_object; | 540 | union acpi_operand_object *source_object; |
540 | union acpi_operand_object *dest_object; | 541 | union acpi_operand_object *dest_object; |
541 | struct acpi_walk_state *walk_state; | 542 | struct acpi_walk_state *walk_state; |
542 | void *this_target_obj; | 543 | void *this_target_obj; |
543 | u32 num_packages; | 544 | u32 num_packages; |
544 | }; | 545 | }; |
545 | 546 | ||
546 | /* | 547 | /* |
547 | * Control state - one per if/else and while constructs. | 548 | * Control state - one per if/else and while constructs. |
548 | * Allows nesting of these constructs | 549 | * Allows nesting of these constructs |
549 | */ | 550 | */ |
550 | struct acpi_control_state { | 551 | struct acpi_control_state { |
551 | ACPI_STATE_COMMON u16 opcode; | 552 | ACPI_STATE_COMMON u16 opcode; |
552 | union acpi_parse_object *predicate_op; | 553 | union acpi_parse_object *predicate_op; |
553 | u8 *aml_predicate_start; /* Start of if/while predicate */ | 554 | u8 *aml_predicate_start; /* Start of if/while predicate */ |
554 | u8 *package_end; /* End of if/while block */ | 555 | u8 *package_end; /* End of if/while block */ |
555 | u32 loop_count; /* While() loop counter */ | 556 | u32 loop_count; /* While() loop counter */ |
556 | }; | 557 | }; |
557 | 558 | ||
558 | /* | 559 | /* |
559 | * Scope state - current scope during namespace lookups | 560 | * Scope state - current scope during namespace lookups |
560 | */ | 561 | */ |
561 | struct acpi_scope_state { | 562 | struct acpi_scope_state { |
562 | ACPI_STATE_COMMON struct acpi_namespace_node *node; | 563 | ACPI_STATE_COMMON struct acpi_namespace_node *node; |
563 | }; | 564 | }; |
564 | 565 | ||
565 | struct acpi_pscope_state { | 566 | struct acpi_pscope_state { |
566 | ACPI_STATE_COMMON u32 arg_count; /* Number of fixed arguments */ | 567 | ACPI_STATE_COMMON u32 arg_count; /* Number of fixed arguments */ |
567 | union acpi_parse_object *op; /* Current op being parsed */ | 568 | union acpi_parse_object *op; /* Current op being parsed */ |
568 | u8 *arg_end; /* Current argument end */ | 569 | u8 *arg_end; /* Current argument end */ |
569 | u8 *pkg_end; /* Current package end */ | 570 | u8 *pkg_end; /* Current package end */ |
570 | u32 arg_list; /* Next argument to parse */ | 571 | u32 arg_list; /* Next argument to parse */ |
571 | }; | 572 | }; |
572 | 573 | ||
573 | /* | 574 | /* |
574 | * Thread state - one per thread across multiple walk states. Multiple walk | 575 | * Thread state - one per thread across multiple walk states. Multiple walk |
575 | * states are created when there are nested control methods executing. | 576 | * states are created when there are nested control methods executing. |
576 | */ | 577 | */ |
577 | struct acpi_thread_state { | 578 | struct acpi_thread_state { |
578 | ACPI_STATE_COMMON u8 current_sync_level; /* Mutex Sync (nested acquire) level */ | 579 | ACPI_STATE_COMMON u8 current_sync_level; /* Mutex Sync (nested acquire) level */ |
579 | struct acpi_walk_state *walk_state_list; /* Head of list of walk_states for this thread */ | 580 | struct acpi_walk_state *walk_state_list; /* Head of list of walk_states for this thread */ |
580 | union acpi_operand_object *acquired_mutex_list; /* List of all currently acquired mutexes */ | 581 | union acpi_operand_object *acquired_mutex_list; /* List of all currently acquired mutexes */ |
581 | acpi_thread_id thread_id; /* Running thread ID */ | 582 | acpi_thread_id thread_id; /* Running thread ID */ |
582 | }; | 583 | }; |
583 | 584 | ||
584 | /* | 585 | /* |
585 | * Result values - used to accumulate the results of nested | 586 | * Result values - used to accumulate the results of nested |
586 | * AML arguments | 587 | * AML arguments |
587 | */ | 588 | */ |
588 | struct acpi_result_values { | 589 | struct acpi_result_values { |
589 | ACPI_STATE_COMMON | 590 | ACPI_STATE_COMMON |
590 | union acpi_operand_object *obj_desc[ACPI_RESULTS_FRAME_OBJ_NUM]; | 591 | union acpi_operand_object *obj_desc[ACPI_RESULTS_FRAME_OBJ_NUM]; |
591 | }; | 592 | }; |
592 | 593 | ||
593 | typedef | 594 | typedef |
594 | acpi_status(*acpi_parse_downwards) (struct acpi_walk_state * walk_state, | 595 | acpi_status(*acpi_parse_downwards) (struct acpi_walk_state * walk_state, |
595 | union acpi_parse_object ** out_op); | 596 | union acpi_parse_object ** out_op); |
596 | 597 | ||
597 | typedef acpi_status(*acpi_parse_upwards) (struct acpi_walk_state * walk_state); | 598 | typedef acpi_status(*acpi_parse_upwards) (struct acpi_walk_state * walk_state); |
598 | 599 | ||
599 | /* | 600 | /* |
600 | * Notify info - used to pass info to the deferred notify | 601 | * Notify info - used to pass info to the deferred notify |
601 | * handler/dispatcher. | 602 | * handler/dispatcher. |
602 | */ | 603 | */ |
603 | struct acpi_notify_info { | 604 | struct acpi_notify_info { |
604 | ACPI_STATE_COMMON struct acpi_namespace_node *node; | 605 | ACPI_STATE_COMMON struct acpi_namespace_node *node; |
605 | union acpi_operand_object *handler_obj; | 606 | union acpi_operand_object *handler_obj; |
606 | }; | 607 | }; |
607 | 608 | ||
608 | /* Generic state is union of structs above */ | 609 | /* Generic state is union of structs above */ |
609 | 610 | ||
610 | union acpi_generic_state { | 611 | union acpi_generic_state { |
611 | struct acpi_common_state common; | 612 | struct acpi_common_state common; |
612 | struct acpi_control_state control; | 613 | struct acpi_control_state control; |
613 | struct acpi_update_state update; | 614 | struct acpi_update_state update; |
614 | struct acpi_scope_state scope; | 615 | struct acpi_scope_state scope; |
615 | struct acpi_pscope_state parse_scope; | 616 | struct acpi_pscope_state parse_scope; |
616 | struct acpi_pkg_state pkg; | 617 | struct acpi_pkg_state pkg; |
617 | struct acpi_thread_state thread; | 618 | struct acpi_thread_state thread; |
618 | struct acpi_result_values results; | 619 | struct acpi_result_values results; |
619 | struct acpi_notify_info notify; | 620 | struct acpi_notify_info notify; |
620 | }; | 621 | }; |
621 | 622 | ||
622 | /***************************************************************************** | 623 | /***************************************************************************** |
623 | * | 624 | * |
624 | * Interpreter typedefs and structs | 625 | * Interpreter typedefs and structs |
625 | * | 626 | * |
626 | ****************************************************************************/ | 627 | ****************************************************************************/ |
627 | 628 | ||
628 | typedef acpi_status(*ACPI_EXECUTE_OP) (struct acpi_walk_state * walk_state); | 629 | typedef acpi_status(*ACPI_EXECUTE_OP) (struct acpi_walk_state * walk_state); |
629 | 630 | ||
630 | /***************************************************************************** | 631 | /***************************************************************************** |
631 | * | 632 | * |
632 | * Parser typedefs and structs | 633 | * Parser typedefs and structs |
633 | * | 634 | * |
634 | ****************************************************************************/ | 635 | ****************************************************************************/ |
635 | 636 | ||
636 | /* | 637 | /* |
637 | * AML opcode, name, and argument layout | 638 | * AML opcode, name, and argument layout |
638 | */ | 639 | */ |
639 | struct acpi_opcode_info { | 640 | struct acpi_opcode_info { |
640 | #if defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUG_OUTPUT) | 641 | #if defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUG_OUTPUT) |
641 | char *name; /* Opcode name (disassembler/debug only) */ | 642 | char *name; /* Opcode name (disassembler/debug only) */ |
642 | #endif | 643 | #endif |
643 | u32 parse_args; /* Grammar/Parse time arguments */ | 644 | u32 parse_args; /* Grammar/Parse time arguments */ |
644 | u32 runtime_args; /* Interpret time arguments */ | 645 | u32 runtime_args; /* Interpret time arguments */ |
645 | u16 flags; /* Misc flags */ | 646 | u16 flags; /* Misc flags */ |
646 | u8 object_type; /* Corresponding internal object type */ | 647 | u8 object_type; /* Corresponding internal object type */ |
647 | u8 class; /* Opcode class */ | 648 | u8 class; /* Opcode class */ |
648 | u8 type; /* Opcode type */ | 649 | u8 type; /* Opcode type */ |
649 | }; | 650 | }; |
650 | 651 | ||
651 | union acpi_parse_value { | 652 | union acpi_parse_value { |
652 | acpi_integer integer; /* Integer constant (Up to 64 bits) */ | 653 | acpi_integer integer; /* Integer constant (Up to 64 bits) */ |
653 | struct uint64_struct integer64; /* Structure overlay for 2 32-bit Dwords */ | 654 | struct uint64_struct integer64; /* Structure overlay for 2 32-bit Dwords */ |
654 | u32 size; /* bytelist or field size */ | 655 | u32 size; /* bytelist or field size */ |
655 | char *string; /* NULL terminated string */ | 656 | char *string; /* NULL terminated string */ |
656 | u8 *buffer; /* buffer or string */ | 657 | u8 *buffer; /* buffer or string */ |
657 | char *name; /* NULL terminated string */ | 658 | char *name; /* NULL terminated string */ |
658 | union acpi_parse_object *arg; /* arguments and contained ops */ | 659 | union acpi_parse_object *arg; /* arguments and contained ops */ |
659 | }; | 660 | }; |
660 | 661 | ||
661 | #ifdef ACPI_DISASSEMBLER | 662 | #ifdef ACPI_DISASSEMBLER |
662 | #define ACPI_DISASM_ONLY_MEMBERS(a) a; | 663 | #define ACPI_DISASM_ONLY_MEMBERS(a) a; |
663 | #else | 664 | #else |
664 | #define ACPI_DISASM_ONLY_MEMBERS(a) | 665 | #define ACPI_DISASM_ONLY_MEMBERS(a) |
665 | #endif | 666 | #endif |
666 | 667 | ||
667 | #define ACPI_PARSE_COMMON \ | 668 | #define ACPI_PARSE_COMMON \ |
668 | union acpi_parse_object *parent; /* Parent op */\ | 669 | union acpi_parse_object *parent; /* Parent op */\ |
669 | u8 descriptor_type; /* To differentiate various internal objs */\ | 670 | u8 descriptor_type; /* To differentiate various internal objs */\ |
670 | u8 flags; /* Type of Op */\ | 671 | u8 flags; /* Type of Op */\ |
671 | u16 aml_opcode; /* AML opcode */\ | 672 | u16 aml_opcode; /* AML opcode */\ |
672 | u32 aml_offset; /* Offset of declaration in AML */\ | 673 | u32 aml_offset; /* Offset of declaration in AML */\ |
673 | union acpi_parse_object *next; /* Next op */\ | 674 | union acpi_parse_object *next; /* Next op */\ |
674 | struct acpi_namespace_node *node; /* For use by interpreter */\ | 675 | struct acpi_namespace_node *node; /* For use by interpreter */\ |
675 | union acpi_parse_value value; /* Value or args associated with the opcode */\ | 676 | union acpi_parse_value value; /* Value or args associated with the opcode */\ |
676 | u8 arg_list_length; /* Number of elements in the arg list */\ | 677 | u8 arg_list_length; /* Number of elements in the arg list */\ |
677 | ACPI_DISASM_ONLY_MEMBERS (\ | 678 | ACPI_DISASM_ONLY_MEMBERS (\ |
678 | u8 disasm_flags; /* Used during AML disassembly */\ | 679 | u8 disasm_flags; /* Used during AML disassembly */\ |
679 | u8 disasm_opcode; /* Subtype used for disassembly */\ | 680 | u8 disasm_opcode; /* Subtype used for disassembly */\ |
680 | char aml_op_name[16]) /* Op name (debug only) */ | 681 | char aml_op_name[16]) /* Op name (debug only) */ |
681 | 682 | ||
682 | #define ACPI_DASM_BUFFER 0x00 | 683 | #define ACPI_DASM_BUFFER 0x00 |
683 | #define ACPI_DASM_RESOURCE 0x01 | 684 | #define ACPI_DASM_RESOURCE 0x01 |
684 | #define ACPI_DASM_STRING 0x02 | 685 | #define ACPI_DASM_STRING 0x02 |
685 | #define ACPI_DASM_UNICODE 0x03 | 686 | #define ACPI_DASM_UNICODE 0x03 |
686 | #define ACPI_DASM_EISAID 0x04 | 687 | #define ACPI_DASM_EISAID 0x04 |
687 | #define ACPI_DASM_MATCHOP 0x05 | 688 | #define ACPI_DASM_MATCHOP 0x05 |
688 | #define ACPI_DASM_LNOT_PREFIX 0x06 | 689 | #define ACPI_DASM_LNOT_PREFIX 0x06 |
689 | #define ACPI_DASM_LNOT_SUFFIX 0x07 | 690 | #define ACPI_DASM_LNOT_SUFFIX 0x07 |
690 | #define ACPI_DASM_IGNORE 0x08 | 691 | #define ACPI_DASM_IGNORE 0x08 |
691 | 692 | ||
692 | /* | 693 | /* |
693 | * Generic operation (for example: If, While, Store) | 694 | * Generic operation (for example: If, While, Store) |
694 | */ | 695 | */ |
695 | struct acpi_parse_obj_common { | 696 | struct acpi_parse_obj_common { |
696 | ACPI_PARSE_COMMON}; | 697 | ACPI_PARSE_COMMON}; |
697 | 698 | ||
698 | /* | 699 | /* |
699 | * Extended Op for named ops (Scope, Method, etc.), deferred ops (Methods and op_regions), | 700 | * Extended Op for named ops (Scope, Method, etc.), deferred ops (Methods and op_regions), |
700 | * and bytelists. | 701 | * and bytelists. |
701 | */ | 702 | */ |
702 | struct acpi_parse_obj_named { | 703 | struct acpi_parse_obj_named { |
703 | ACPI_PARSE_COMMON u8 *path; | 704 | ACPI_PARSE_COMMON u8 *path; |
704 | u8 *data; /* AML body or bytelist data */ | 705 | u8 *data; /* AML body or bytelist data */ |
705 | u32 length; /* AML length */ | 706 | u32 length; /* AML length */ |
706 | u32 name; /* 4-byte name or zero if no name */ | 707 | u32 name; /* 4-byte name or zero if no name */ |
707 | }; | 708 | }; |
708 | 709 | ||
709 | /* This version is used by the i_aSL compiler only */ | 710 | /* This version is used by the i_aSL compiler only */ |
710 | 711 | ||
711 | #define ACPI_MAX_PARSEOP_NAME 20 | 712 | #define ACPI_MAX_PARSEOP_NAME 20 |
712 | 713 | ||
713 | struct acpi_parse_obj_asl { | 714 | struct acpi_parse_obj_asl { |
714 | ACPI_PARSE_COMMON union acpi_parse_object *child; | 715 | ACPI_PARSE_COMMON union acpi_parse_object *child; |
715 | union acpi_parse_object *parent_method; | 716 | union acpi_parse_object *parent_method; |
716 | char *filename; | 717 | char *filename; |
717 | char *external_name; | 718 | char *external_name; |
718 | char *namepath; | 719 | char *namepath; |
719 | char name_seg[4]; | 720 | char name_seg[4]; |
720 | u32 extra_value; | 721 | u32 extra_value; |
721 | u32 column; | 722 | u32 column; |
722 | u32 line_number; | 723 | u32 line_number; |
723 | u32 logical_line_number; | 724 | u32 logical_line_number; |
724 | u32 logical_byte_offset; | 725 | u32 logical_byte_offset; |
725 | u32 end_line; | 726 | u32 end_line; |
726 | u32 end_logical_line; | 727 | u32 end_logical_line; |
727 | u32 acpi_btype; | 728 | u32 acpi_btype; |
728 | u32 aml_length; | 729 | u32 aml_length; |
729 | u32 aml_subtree_length; | 730 | u32 aml_subtree_length; |
730 | u32 final_aml_length; | 731 | u32 final_aml_length; |
731 | u32 final_aml_offset; | 732 | u32 final_aml_offset; |
732 | u32 compile_flags; | 733 | u32 compile_flags; |
733 | u16 parse_opcode; | 734 | u16 parse_opcode; |
734 | u8 aml_opcode_length; | 735 | u8 aml_opcode_length; |
735 | u8 aml_pkg_len_bytes; | 736 | u8 aml_pkg_len_bytes; |
736 | u8 extra; | 737 | u8 extra; |
737 | char parse_op_name[ACPI_MAX_PARSEOP_NAME]; | 738 | char parse_op_name[ACPI_MAX_PARSEOP_NAME]; |
738 | }; | 739 | }; |
739 | 740 | ||
740 | union acpi_parse_object { | 741 | union acpi_parse_object { |
741 | struct acpi_parse_obj_common common; | 742 | struct acpi_parse_obj_common common; |
742 | struct acpi_parse_obj_named named; | 743 | struct acpi_parse_obj_named named; |
743 | struct acpi_parse_obj_asl asl; | 744 | struct acpi_parse_obj_asl asl; |
744 | }; | 745 | }; |
745 | 746 | ||
746 | /* | 747 | /* |
747 | * Parse state - one state per parser invocation and each control | 748 | * Parse state - one state per parser invocation and each control |
748 | * method. | 749 | * method. |
749 | */ | 750 | */ |
750 | struct acpi_parse_state { | 751 | struct acpi_parse_state { |
751 | u8 *aml_start; /* First AML byte */ | 752 | u8 *aml_start; /* First AML byte */ |
752 | u8 *aml; /* Next AML byte */ | 753 | u8 *aml; /* Next AML byte */ |
753 | u8 *aml_end; /* (last + 1) AML byte */ | 754 | u8 *aml_end; /* (last + 1) AML byte */ |
754 | u8 *pkg_start; /* Current package begin */ | 755 | u8 *pkg_start; /* Current package begin */ |
755 | u8 *pkg_end; /* Current package end */ | 756 | u8 *pkg_end; /* Current package end */ |
756 | union acpi_parse_object *start_op; /* Root of parse tree */ | 757 | union acpi_parse_object *start_op; /* Root of parse tree */ |
757 | struct acpi_namespace_node *start_node; | 758 | struct acpi_namespace_node *start_node; |
758 | union acpi_generic_state *scope; /* Current scope */ | 759 | union acpi_generic_state *scope; /* Current scope */ |
759 | union acpi_parse_object *start_scope; | 760 | union acpi_parse_object *start_scope; |
760 | u32 aml_size; | 761 | u32 aml_size; |
761 | }; | 762 | }; |
762 | 763 | ||
763 | /* Parse object flags */ | 764 | /* Parse object flags */ |
764 | 765 | ||
765 | #define ACPI_PARSEOP_GENERIC 0x01 | 766 | #define ACPI_PARSEOP_GENERIC 0x01 |
766 | #define ACPI_PARSEOP_NAMED 0x02 | 767 | #define ACPI_PARSEOP_NAMED 0x02 |
767 | #define ACPI_PARSEOP_DEFERRED 0x04 | 768 | #define ACPI_PARSEOP_DEFERRED 0x04 |
768 | #define ACPI_PARSEOP_BYTELIST 0x08 | 769 | #define ACPI_PARSEOP_BYTELIST 0x08 |
769 | #define ACPI_PARSEOP_IN_STACK 0x10 | 770 | #define ACPI_PARSEOP_IN_STACK 0x10 |
770 | #define ACPI_PARSEOP_TARGET 0x20 | 771 | #define ACPI_PARSEOP_TARGET 0x20 |
771 | #define ACPI_PARSEOP_IN_CACHE 0x80 | 772 | #define ACPI_PARSEOP_IN_CACHE 0x80 |
772 | 773 | ||
773 | /* Parse object disasm_flags */ | 774 | /* Parse object disasm_flags */ |
774 | 775 | ||
775 | #define ACPI_PARSEOP_IGNORE 0x01 | 776 | #define ACPI_PARSEOP_IGNORE 0x01 |
776 | #define ACPI_PARSEOP_PARAMLIST 0x02 | 777 | #define ACPI_PARSEOP_PARAMLIST 0x02 |
777 | #define ACPI_PARSEOP_EMPTY_TERMLIST 0x04 | 778 | #define ACPI_PARSEOP_EMPTY_TERMLIST 0x04 |
778 | #define ACPI_PARSEOP_SPECIAL 0x10 | 779 | #define ACPI_PARSEOP_SPECIAL 0x10 |
779 | 780 | ||
780 | /***************************************************************************** | 781 | /***************************************************************************** |
781 | * | 782 | * |
782 | * Hardware (ACPI registers) and PNP | 783 | * Hardware (ACPI registers) and PNP |
783 | * | 784 | * |
784 | ****************************************************************************/ | 785 | ****************************************************************************/ |
785 | 786 | ||
786 | struct acpi_bit_register_info { | 787 | struct acpi_bit_register_info { |
787 | u8 parent_register; | 788 | u8 parent_register; |
788 | u8 bit_position; | 789 | u8 bit_position; |
789 | u16 access_bit_mask; | 790 | u16 access_bit_mask; |
790 | }; | 791 | }; |
791 | 792 | ||
792 | /* | 793 | /* |
793 | * Some ACPI registers have bits that must be ignored -- meaning that they | 794 | * Some ACPI registers have bits that must be ignored -- meaning that they |
794 | * must be preserved. | 795 | * must be preserved. |
795 | */ | 796 | */ |
796 | #define ACPI_PM1_STATUS_PRESERVED_BITS 0x0800 /* Bit 11 */ | 797 | #define ACPI_PM1_STATUS_PRESERVED_BITS 0x0800 /* Bit 11 */ |
797 | 798 | ||
798 | /* Write-only bits must be zeroed by software */ | 799 | /* Write-only bits must be zeroed by software */ |
799 | 800 | ||
800 | #define ACPI_PM1_CONTROL_WRITEONLY_BITS 0x2004 /* Bits 13, 2 */ | 801 | #define ACPI_PM1_CONTROL_WRITEONLY_BITS 0x2004 /* Bits 13, 2 */ |
801 | 802 | ||
802 | /* For control registers, both ignored and reserved bits must be preserved */ | 803 | /* For control registers, both ignored and reserved bits must be preserved */ |
803 | 804 | ||
804 | /* | 805 | /* |
805 | * For PM1 control, the SCI enable bit (bit 0, SCI_EN) is defined by the | 806 | * For PM1 control, the SCI enable bit (bit 0, SCI_EN) is defined by the |
806 | * ACPI specification to be a "preserved" bit - "OSPM always preserves this | 807 | * ACPI specification to be a "preserved" bit - "OSPM always preserves this |
807 | * bit position", section 4.7.3.2.1. However, on some machines the OS must | 808 | * bit position", section 4.7.3.2.1. However, on some machines the OS must |
808 | * write a one to this bit after resume for the machine to work properly. | 809 | * write a one to this bit after resume for the machine to work properly. |
809 | * To enable this, we no longer attempt to preserve this bit. No machines | 810 | * To enable this, we no longer attempt to preserve this bit. No machines |
810 | * are known to fail if the bit is not preserved. (May 2009) | 811 | * are known to fail if the bit is not preserved. (May 2009) |
811 | */ | 812 | */ |
812 | #define ACPI_PM1_CONTROL_IGNORED_BITS 0x0200 /* Bit 9 */ | 813 | #define ACPI_PM1_CONTROL_IGNORED_BITS 0x0200 /* Bit 9 */ |
813 | #define ACPI_PM1_CONTROL_RESERVED_BITS 0xC1F8 /* Bits 14-15, 3-8 */ | 814 | #define ACPI_PM1_CONTROL_RESERVED_BITS 0xC1F8 /* Bits 14-15, 3-8 */ |
814 | #define ACPI_PM1_CONTROL_PRESERVED_BITS \ | 815 | #define ACPI_PM1_CONTROL_PRESERVED_BITS \ |
815 | (ACPI_PM1_CONTROL_IGNORED_BITS | ACPI_PM1_CONTROL_RESERVED_BITS) | 816 | (ACPI_PM1_CONTROL_IGNORED_BITS | ACPI_PM1_CONTROL_RESERVED_BITS) |
816 | 817 | ||
817 | #define ACPI_PM2_CONTROL_PRESERVED_BITS 0xFFFFFFFE /* All except bit 0 */ | 818 | #define ACPI_PM2_CONTROL_PRESERVED_BITS 0xFFFFFFFE /* All except bit 0 */ |
818 | 819 | ||
819 | /* | 820 | /* |
820 | * Register IDs | 821 | * Register IDs |
821 | * These are the full ACPI registers | 822 | * These are the full ACPI registers |
822 | */ | 823 | */ |
823 | #define ACPI_REGISTER_PM1_STATUS 0x01 | 824 | #define ACPI_REGISTER_PM1_STATUS 0x01 |
824 | #define ACPI_REGISTER_PM1_ENABLE 0x02 | 825 | #define ACPI_REGISTER_PM1_ENABLE 0x02 |
825 | #define ACPI_REGISTER_PM1_CONTROL 0x03 | 826 | #define ACPI_REGISTER_PM1_CONTROL 0x03 |
826 | #define ACPI_REGISTER_PM2_CONTROL 0x04 | 827 | #define ACPI_REGISTER_PM2_CONTROL 0x04 |
827 | #define ACPI_REGISTER_PM_TIMER 0x05 | 828 | #define ACPI_REGISTER_PM_TIMER 0x05 |
828 | #define ACPI_REGISTER_PROCESSOR_BLOCK 0x06 | 829 | #define ACPI_REGISTER_PROCESSOR_BLOCK 0x06 |
829 | #define ACPI_REGISTER_SMI_COMMAND_BLOCK 0x07 | 830 | #define ACPI_REGISTER_SMI_COMMAND_BLOCK 0x07 |
830 | 831 | ||
831 | /* Masks used to access the bit_registers */ | 832 | /* Masks used to access the bit_registers */ |
832 | 833 | ||
833 | #define ACPI_BITMASK_TIMER_STATUS 0x0001 | 834 | #define ACPI_BITMASK_TIMER_STATUS 0x0001 |
834 | #define ACPI_BITMASK_BUS_MASTER_STATUS 0x0010 | 835 | #define ACPI_BITMASK_BUS_MASTER_STATUS 0x0010 |
835 | #define ACPI_BITMASK_GLOBAL_LOCK_STATUS 0x0020 | 836 | #define ACPI_BITMASK_GLOBAL_LOCK_STATUS 0x0020 |
836 | #define ACPI_BITMASK_POWER_BUTTON_STATUS 0x0100 | 837 | #define ACPI_BITMASK_POWER_BUTTON_STATUS 0x0100 |
837 | #define ACPI_BITMASK_SLEEP_BUTTON_STATUS 0x0200 | 838 | #define ACPI_BITMASK_SLEEP_BUTTON_STATUS 0x0200 |
838 | #define ACPI_BITMASK_RT_CLOCK_STATUS 0x0400 | 839 | #define ACPI_BITMASK_RT_CLOCK_STATUS 0x0400 |
839 | #define ACPI_BITMASK_PCIEXP_WAKE_STATUS 0x4000 /* ACPI 3.0 */ | 840 | #define ACPI_BITMASK_PCIEXP_WAKE_STATUS 0x4000 /* ACPI 3.0 */ |
840 | #define ACPI_BITMASK_WAKE_STATUS 0x8000 | 841 | #define ACPI_BITMASK_WAKE_STATUS 0x8000 |
841 | 842 | ||
842 | #define ACPI_BITMASK_ALL_FIXED_STATUS (\ | 843 | #define ACPI_BITMASK_ALL_FIXED_STATUS (\ |
843 | ACPI_BITMASK_TIMER_STATUS | \ | 844 | ACPI_BITMASK_TIMER_STATUS | \ |
844 | ACPI_BITMASK_BUS_MASTER_STATUS | \ | 845 | ACPI_BITMASK_BUS_MASTER_STATUS | \ |
845 | ACPI_BITMASK_GLOBAL_LOCK_STATUS | \ | 846 | ACPI_BITMASK_GLOBAL_LOCK_STATUS | \ |
846 | ACPI_BITMASK_POWER_BUTTON_STATUS | \ | 847 | ACPI_BITMASK_POWER_BUTTON_STATUS | \ |
847 | ACPI_BITMASK_SLEEP_BUTTON_STATUS | \ | 848 | ACPI_BITMASK_SLEEP_BUTTON_STATUS | \ |
848 | ACPI_BITMASK_RT_CLOCK_STATUS | \ | 849 | ACPI_BITMASK_RT_CLOCK_STATUS | \ |
849 | ACPI_BITMASK_WAKE_STATUS) | 850 | ACPI_BITMASK_WAKE_STATUS) |
850 | 851 | ||
851 | #define ACPI_BITMASK_TIMER_ENABLE 0x0001 | 852 | #define ACPI_BITMASK_TIMER_ENABLE 0x0001 |
852 | #define ACPI_BITMASK_GLOBAL_LOCK_ENABLE 0x0020 | 853 | #define ACPI_BITMASK_GLOBAL_LOCK_ENABLE 0x0020 |
853 | #define ACPI_BITMASK_POWER_BUTTON_ENABLE 0x0100 | 854 | #define ACPI_BITMASK_POWER_BUTTON_ENABLE 0x0100 |
854 | #define ACPI_BITMASK_SLEEP_BUTTON_ENABLE 0x0200 | 855 | #define ACPI_BITMASK_SLEEP_BUTTON_ENABLE 0x0200 |
855 | #define ACPI_BITMASK_RT_CLOCK_ENABLE 0x0400 | 856 | #define ACPI_BITMASK_RT_CLOCK_ENABLE 0x0400 |
856 | #define ACPI_BITMASK_PCIEXP_WAKE_DISABLE 0x4000 /* ACPI 3.0 */ | 857 | #define ACPI_BITMASK_PCIEXP_WAKE_DISABLE 0x4000 /* ACPI 3.0 */ |
857 | 858 | ||
858 | #define ACPI_BITMASK_SCI_ENABLE 0x0001 | 859 | #define ACPI_BITMASK_SCI_ENABLE 0x0001 |
859 | #define ACPI_BITMASK_BUS_MASTER_RLD 0x0002 | 860 | #define ACPI_BITMASK_BUS_MASTER_RLD 0x0002 |
860 | #define ACPI_BITMASK_GLOBAL_LOCK_RELEASE 0x0004 | 861 | #define ACPI_BITMASK_GLOBAL_LOCK_RELEASE 0x0004 |
861 | #define ACPI_BITMASK_SLEEP_TYPE 0x1C00 | 862 | #define ACPI_BITMASK_SLEEP_TYPE 0x1C00 |
862 | #define ACPI_BITMASK_SLEEP_ENABLE 0x2000 | 863 | #define ACPI_BITMASK_SLEEP_ENABLE 0x2000 |
863 | 864 | ||
864 | #define ACPI_BITMASK_ARB_DISABLE 0x0001 | 865 | #define ACPI_BITMASK_ARB_DISABLE 0x0001 |
865 | 866 | ||
866 | /* Raw bit position of each bit_register */ | 867 | /* Raw bit position of each bit_register */ |
867 | 868 | ||
868 | #define ACPI_BITPOSITION_TIMER_STATUS 0x00 | 869 | #define ACPI_BITPOSITION_TIMER_STATUS 0x00 |
869 | #define ACPI_BITPOSITION_BUS_MASTER_STATUS 0x04 | 870 | #define ACPI_BITPOSITION_BUS_MASTER_STATUS 0x04 |
870 | #define ACPI_BITPOSITION_GLOBAL_LOCK_STATUS 0x05 | 871 | #define ACPI_BITPOSITION_GLOBAL_LOCK_STATUS 0x05 |
871 | #define ACPI_BITPOSITION_POWER_BUTTON_STATUS 0x08 | 872 | #define ACPI_BITPOSITION_POWER_BUTTON_STATUS 0x08 |
872 | #define ACPI_BITPOSITION_SLEEP_BUTTON_STATUS 0x09 | 873 | #define ACPI_BITPOSITION_SLEEP_BUTTON_STATUS 0x09 |
873 | #define ACPI_BITPOSITION_RT_CLOCK_STATUS 0x0A | 874 | #define ACPI_BITPOSITION_RT_CLOCK_STATUS 0x0A |
874 | #define ACPI_BITPOSITION_PCIEXP_WAKE_STATUS 0x0E /* ACPI 3.0 */ | 875 | #define ACPI_BITPOSITION_PCIEXP_WAKE_STATUS 0x0E /* ACPI 3.0 */ |
875 | #define ACPI_BITPOSITION_WAKE_STATUS 0x0F | 876 | #define ACPI_BITPOSITION_WAKE_STATUS 0x0F |
876 | 877 | ||
877 | #define ACPI_BITPOSITION_TIMER_ENABLE 0x00 | 878 | #define ACPI_BITPOSITION_TIMER_ENABLE 0x00 |
878 | #define ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE 0x05 | 879 | #define ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE 0x05 |
879 | #define ACPI_BITPOSITION_POWER_BUTTON_ENABLE 0x08 | 880 | #define ACPI_BITPOSITION_POWER_BUTTON_ENABLE 0x08 |
880 | #define ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE 0x09 | 881 | #define ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE 0x09 |
881 | #define ACPI_BITPOSITION_RT_CLOCK_ENABLE 0x0A | 882 | #define ACPI_BITPOSITION_RT_CLOCK_ENABLE 0x0A |
882 | #define ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE 0x0E /* ACPI 3.0 */ | 883 | #define ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE 0x0E /* ACPI 3.0 */ |
883 | 884 | ||
884 | #define ACPI_BITPOSITION_SCI_ENABLE 0x00 | 885 | #define ACPI_BITPOSITION_SCI_ENABLE 0x00 |
885 | #define ACPI_BITPOSITION_BUS_MASTER_RLD 0x01 | 886 | #define ACPI_BITPOSITION_BUS_MASTER_RLD 0x01 |
886 | #define ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE 0x02 | 887 | #define ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE 0x02 |
887 | #define ACPI_BITPOSITION_SLEEP_TYPE 0x0A | 888 | #define ACPI_BITPOSITION_SLEEP_TYPE 0x0A |
888 | #define ACPI_BITPOSITION_SLEEP_ENABLE 0x0D | 889 | #define ACPI_BITPOSITION_SLEEP_ENABLE 0x0D |
889 | 890 | ||
890 | #define ACPI_BITPOSITION_ARB_DISABLE 0x00 | 891 | #define ACPI_BITPOSITION_ARB_DISABLE 0x00 |
891 | 892 | ||
892 | /* Structs and definitions for _OSI support and I/O port validation */ | 893 | /* Structs and definitions for _OSI support and I/O port validation */ |
893 | 894 | ||
894 | #define ACPI_OSI_WIN_2000 0x01 | 895 | #define ACPI_OSI_WIN_2000 0x01 |
895 | #define ACPI_OSI_WIN_XP 0x02 | 896 | #define ACPI_OSI_WIN_XP 0x02 |
896 | #define ACPI_OSI_WIN_XP_SP1 0x03 | 897 | #define ACPI_OSI_WIN_XP_SP1 0x03 |
897 | #define ACPI_OSI_WINSRV_2003 0x04 | 898 | #define ACPI_OSI_WINSRV_2003 0x04 |
898 | #define ACPI_OSI_WIN_XP_SP2 0x05 | 899 | #define ACPI_OSI_WIN_XP_SP2 0x05 |
899 | #define ACPI_OSI_WINSRV_2003_SP1 0x06 | 900 | #define ACPI_OSI_WINSRV_2003_SP1 0x06 |
900 | #define ACPI_OSI_WIN_VISTA 0x07 | 901 | #define ACPI_OSI_WIN_VISTA 0x07 |
901 | #define ACPI_OSI_WINSRV_2008 0x08 | 902 | #define ACPI_OSI_WINSRV_2008 0x08 |
902 | #define ACPI_OSI_WIN_VISTA_SP1 0x09 | 903 | #define ACPI_OSI_WIN_VISTA_SP1 0x09 |
903 | #define ACPI_OSI_WIN_7 0x0A | 904 | #define ACPI_OSI_WIN_7 0x0A |
904 | 905 | ||
905 | #define ACPI_ALWAYS_ILLEGAL 0x00 | 906 | #define ACPI_ALWAYS_ILLEGAL 0x00 |
906 | 907 | ||
907 | struct acpi_interface_info { | 908 | struct acpi_interface_info { |
908 | char *name; | 909 | char *name; |
909 | u8 value; | 910 | u8 value; |
910 | }; | 911 | }; |
911 | 912 | ||
912 | struct acpi_port_info { | 913 | struct acpi_port_info { |
913 | char *name; | 914 | char *name; |
914 | u16 start; | 915 | u16 start; |
915 | u16 end; | 916 | u16 end; |
916 | u8 osi_dependency; | 917 | u8 osi_dependency; |
917 | }; | 918 | }; |
918 | 919 | ||
919 | /***************************************************************************** | 920 | /***************************************************************************** |
920 | * | 921 | * |
921 | * Resource descriptors | 922 | * Resource descriptors |
922 | * | 923 | * |
923 | ****************************************************************************/ | 924 | ****************************************************************************/ |
924 | 925 | ||
925 | /* resource_type values */ | 926 | /* resource_type values */ |
926 | 927 | ||
927 | #define ACPI_ADDRESS_TYPE_MEMORY_RANGE 0 | 928 | #define ACPI_ADDRESS_TYPE_MEMORY_RANGE 0 |
928 | #define ACPI_ADDRESS_TYPE_IO_RANGE 1 | 929 | #define ACPI_ADDRESS_TYPE_IO_RANGE 1 |
929 | #define ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE 2 | 930 | #define ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE 2 |
930 | 931 | ||
931 | /* Resource descriptor types and masks */ | 932 | /* Resource descriptor types and masks */ |
932 | 933 | ||
933 | #define ACPI_RESOURCE_NAME_LARGE 0x80 | 934 | #define ACPI_RESOURCE_NAME_LARGE 0x80 |
934 | #define ACPI_RESOURCE_NAME_SMALL 0x00 | 935 | #define ACPI_RESOURCE_NAME_SMALL 0x00 |
935 | 936 | ||
936 | #define ACPI_RESOURCE_NAME_SMALL_MASK 0x78 /* Bits 6:3 contain the type */ | 937 | #define ACPI_RESOURCE_NAME_SMALL_MASK 0x78 /* Bits 6:3 contain the type */ |
937 | #define ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK 0x07 /* Bits 2:0 contain the length */ | 938 | #define ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK 0x07 /* Bits 2:0 contain the length */ |
938 | #define ACPI_RESOURCE_NAME_LARGE_MASK 0x7F /* Bits 6:0 contain the type */ | 939 | #define ACPI_RESOURCE_NAME_LARGE_MASK 0x7F /* Bits 6:0 contain the type */ |
939 | 940 | ||
940 | /* | 941 | /* |
941 | * Small resource descriptor "names" as defined by the ACPI specification. | 942 | * Small resource descriptor "names" as defined by the ACPI specification. |
942 | * Note: Bits 2:0 are used for the descriptor length | 943 | * Note: Bits 2:0 are used for the descriptor length |
943 | */ | 944 | */ |
944 | #define ACPI_RESOURCE_NAME_IRQ 0x20 | 945 | #define ACPI_RESOURCE_NAME_IRQ 0x20 |
945 | #define ACPI_RESOURCE_NAME_DMA 0x28 | 946 | #define ACPI_RESOURCE_NAME_DMA 0x28 |
946 | #define ACPI_RESOURCE_NAME_START_DEPENDENT 0x30 | 947 | #define ACPI_RESOURCE_NAME_START_DEPENDENT 0x30 |
947 | #define ACPI_RESOURCE_NAME_END_DEPENDENT 0x38 | 948 | #define ACPI_RESOURCE_NAME_END_DEPENDENT 0x38 |
948 | #define ACPI_RESOURCE_NAME_IO 0x40 | 949 | #define ACPI_RESOURCE_NAME_IO 0x40 |
949 | #define ACPI_RESOURCE_NAME_FIXED_IO 0x48 | 950 | #define ACPI_RESOURCE_NAME_FIXED_IO 0x48 |
950 | #define ACPI_RESOURCE_NAME_RESERVED_S1 0x50 | 951 | #define ACPI_RESOURCE_NAME_RESERVED_S1 0x50 |
951 | #define ACPI_RESOURCE_NAME_RESERVED_S2 0x58 | 952 | #define ACPI_RESOURCE_NAME_RESERVED_S2 0x58 |
952 | #define ACPI_RESOURCE_NAME_RESERVED_S3 0x60 | 953 | #define ACPI_RESOURCE_NAME_RESERVED_S3 0x60 |
953 | #define ACPI_RESOURCE_NAME_RESERVED_S4 0x68 | 954 | #define ACPI_RESOURCE_NAME_RESERVED_S4 0x68 |
954 | #define ACPI_RESOURCE_NAME_VENDOR_SMALL 0x70 | 955 | #define ACPI_RESOURCE_NAME_VENDOR_SMALL 0x70 |
955 | #define ACPI_RESOURCE_NAME_END_TAG 0x78 | 956 | #define ACPI_RESOURCE_NAME_END_TAG 0x78 |
956 | 957 | ||
957 | /* | 958 | /* |
958 | * Large resource descriptor "names" as defined by the ACPI specification. | 959 | * Large resource descriptor "names" as defined by the ACPI specification. |
959 | * Note: includes the Large Descriptor bit in bit[7] | 960 | * Note: includes the Large Descriptor bit in bit[7] |
960 | */ | 961 | */ |
961 | #define ACPI_RESOURCE_NAME_MEMORY24 0x81 | 962 | #define ACPI_RESOURCE_NAME_MEMORY24 0x81 |
962 | #define ACPI_RESOURCE_NAME_GENERIC_REGISTER 0x82 | 963 | #define ACPI_RESOURCE_NAME_GENERIC_REGISTER 0x82 |
963 | #define ACPI_RESOURCE_NAME_RESERVED_L1 0x83 | 964 | #define ACPI_RESOURCE_NAME_RESERVED_L1 0x83 |
964 | #define ACPI_RESOURCE_NAME_VENDOR_LARGE 0x84 | 965 | #define ACPI_RESOURCE_NAME_VENDOR_LARGE 0x84 |
965 | #define ACPI_RESOURCE_NAME_MEMORY32 0x85 | 966 | #define ACPI_RESOURCE_NAME_MEMORY32 0x85 |
966 | #define ACPI_RESOURCE_NAME_FIXED_MEMORY32 0x86 | 967 | #define ACPI_RESOURCE_NAME_FIXED_MEMORY32 0x86 |
967 | #define ACPI_RESOURCE_NAME_ADDRESS32 0x87 | 968 | #define ACPI_RESOURCE_NAME_ADDRESS32 0x87 |
968 | #define ACPI_RESOURCE_NAME_ADDRESS16 0x88 | 969 | #define ACPI_RESOURCE_NAME_ADDRESS16 0x88 |
969 | #define ACPI_RESOURCE_NAME_EXTENDED_IRQ 0x89 | 970 | #define ACPI_RESOURCE_NAME_EXTENDED_IRQ 0x89 |
970 | #define ACPI_RESOURCE_NAME_ADDRESS64 0x8A | 971 | #define ACPI_RESOURCE_NAME_ADDRESS64 0x8A |
971 | #define ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 0x8B | 972 | #define ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 0x8B |
972 | #define ACPI_RESOURCE_NAME_LARGE_MAX 0x8B | 973 | #define ACPI_RESOURCE_NAME_LARGE_MAX 0x8B |
973 | 974 | ||
974 | /***************************************************************************** | 975 | /***************************************************************************** |
975 | * | 976 | * |
976 | * Miscellaneous | 977 | * Miscellaneous |
977 | * | 978 | * |
978 | ****************************************************************************/ | 979 | ****************************************************************************/ |
979 | 980 | ||
980 | #define ACPI_ASCII_ZERO 0x30 | 981 | #define ACPI_ASCII_ZERO 0x30 |
981 | 982 | ||
982 | /***************************************************************************** | 983 | /***************************************************************************** |
983 | * | 984 | * |
984 | * Debugger | 985 | * Debugger |
985 | * | 986 | * |
986 | ****************************************************************************/ | 987 | ****************************************************************************/ |
987 | 988 | ||
988 | struct acpi_db_method_info { | 989 | struct acpi_db_method_info { |
989 | acpi_handle main_thread_gate; | 990 | acpi_handle main_thread_gate; |
990 | acpi_handle thread_complete_gate; | 991 | acpi_handle thread_complete_gate; |
991 | u32 *threads; | 992 | u32 *threads; |
992 | u32 num_threads; | 993 | u32 num_threads; |
993 | u32 num_created; | 994 | u32 num_created; |
994 | u32 num_completed; | 995 | u32 num_completed; |
995 | 996 | ||
996 | char *name; | 997 | char *name; |
997 | u32 flags; | 998 | u32 flags; |
998 | u32 num_loops; | 999 | u32 num_loops; |
999 | char pathname[128]; | 1000 | char pathname[128]; |
1000 | char **args; | 1001 | char **args; |
1001 | 1002 | ||
1002 | /* | 1003 | /* |
1003 | * Arguments to be passed to method for the command | 1004 | * Arguments to be passed to method for the command |
1004 | * Threads - | 1005 | * Threads - |
1005 | * the Number of threads, ID of current thread and | 1006 | * the Number of threads, ID of current thread and |
1006 | * Index of current thread inside all them created. | 1007 | * Index of current thread inside all them created. |
1007 | */ | 1008 | */ |
1008 | char init_args; | 1009 | char init_args; |
1009 | char *arguments[4]; | 1010 | char *arguments[4]; |
1010 | char num_threads_str[11]; | 1011 | char num_threads_str[11]; |
1011 | char id_of_thread_str[11]; | 1012 | char id_of_thread_str[11]; |
1012 | char index_of_thread_str[11]; | 1013 | char index_of_thread_str[11]; |
1013 | }; | 1014 | }; |
1014 | 1015 | ||
1015 | struct acpi_integrity_info { | 1016 | struct acpi_integrity_info { |
1016 | u32 nodes; | 1017 | u32 nodes; |
1017 | u32 objects; | 1018 | u32 objects; |
1018 | }; | 1019 | }; |
1019 | 1020 | ||
1020 | #define ACPI_DB_REDIRECTABLE_OUTPUT 0x01 | 1021 | #define ACPI_DB_REDIRECTABLE_OUTPUT 0x01 |
1021 | #define ACPI_DB_CONSOLE_OUTPUT 0x02 | 1022 | #define ACPI_DB_CONSOLE_OUTPUT 0x02 |
1022 | #define ACPI_DB_DUPLICATE_OUTPUT 0x03 | 1023 | #define ACPI_DB_DUPLICATE_OUTPUT 0x03 |
1023 | 1024 | ||
1024 | /***************************************************************************** | 1025 | /***************************************************************************** |
1025 | * | 1026 | * |
1026 | * Debug | 1027 | * Debug |
1027 | * | 1028 | * |
1028 | ****************************************************************************/ | 1029 | ****************************************************************************/ |
1029 | 1030 | ||
1030 | /* Entry for a memory allocation (debug only) */ | 1031 | /* Entry for a memory allocation (debug only) */ |
1031 | 1032 | ||
1032 | #define ACPI_MEM_MALLOC 0 | 1033 | #define ACPI_MEM_MALLOC 0 |
1033 | #define ACPI_MEM_CALLOC 1 | 1034 | #define ACPI_MEM_CALLOC 1 |
1034 | #define ACPI_MAX_MODULE_NAME 16 | 1035 | #define ACPI_MAX_MODULE_NAME 16 |
1035 | 1036 | ||
1036 | #define ACPI_COMMON_DEBUG_MEM_HEADER \ | 1037 | #define ACPI_COMMON_DEBUG_MEM_HEADER \ |
1037 | struct acpi_debug_mem_block *previous; \ | 1038 | struct acpi_debug_mem_block *previous; \ |
1038 | struct acpi_debug_mem_block *next; \ | 1039 | struct acpi_debug_mem_block *next; \ |
1039 | u32 size; \ | 1040 | u32 size; \ |
1040 | u32 component; \ | 1041 | u32 component; \ |
1041 | u32 line; \ | 1042 | u32 line; \ |
1042 | char module[ACPI_MAX_MODULE_NAME]; \ | 1043 | char module[ACPI_MAX_MODULE_NAME]; \ |
1043 | u8 alloc_type; | 1044 | u8 alloc_type; |
1044 | 1045 | ||
1045 | struct acpi_debug_mem_header { | 1046 | struct acpi_debug_mem_header { |
1046 | ACPI_COMMON_DEBUG_MEM_HEADER}; | 1047 | ACPI_COMMON_DEBUG_MEM_HEADER}; |
1047 | 1048 | ||
1048 | struct acpi_debug_mem_block { | 1049 | struct acpi_debug_mem_block { |
1049 | ACPI_COMMON_DEBUG_MEM_HEADER u64 user_space; | 1050 | ACPI_COMMON_DEBUG_MEM_HEADER u64 user_space; |
1050 | }; | 1051 | }; |
1051 | 1052 | ||
1052 | #define ACPI_MEM_LIST_GLOBAL 0 | 1053 | #define ACPI_MEM_LIST_GLOBAL 0 |
1053 | #define ACPI_MEM_LIST_NSNODE 1 | 1054 | #define ACPI_MEM_LIST_NSNODE 1 |
1054 | #define ACPI_MEM_LIST_MAX 1 | 1055 | #define ACPI_MEM_LIST_MAX 1 |
1055 | #define ACPI_NUM_MEM_LISTS 2 | 1056 | #define ACPI_NUM_MEM_LISTS 2 |
1056 | 1057 | ||
1057 | #endif /* __ACLOCAL_H__ */ | 1058 | #endif /* __ACLOCAL_H__ */ |
1058 | 1059 |
drivers/acpi/acpica/acnamesp.h
1 | /****************************************************************************** | 1 | /****************************************************************************** |
2 | * | 2 | * |
3 | * Name: acnamesp.h - Namespace subcomponent prototypes and defines | 3 | * Name: acnamesp.h - Namespace subcomponent prototypes and defines |
4 | * | 4 | * |
5 | *****************************************************************************/ | 5 | *****************************************************************************/ |
6 | 6 | ||
7 | /* | 7 | /* |
8 | * Copyright (C) 2000 - 2010, Intel Corp. | 8 | * Copyright (C) 2000 - 2010, Intel Corp. |
9 | * All rights reserved. | 9 | * All rights reserved. |
10 | * | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright |
15 | * notice, this list of conditions, and the following disclaimer, | 15 | * notice, this list of conditions, and the following disclaimer, |
16 | * without modification. | 16 | * without modification. |
17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | 17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
18 | * substantially similar to the "NO WARRANTY" disclaimer below | 18 | * substantially similar to the "NO WARRANTY" disclaimer below |
19 | * ("Disclaimer") and any redistribution must be conditioned upon | 19 | * ("Disclaimer") and any redistribution must be conditioned upon |
20 | * including a substantially similar Disclaimer requirement for further | 20 | * including a substantially similar Disclaimer requirement for further |
21 | * binary redistribution. | 21 | * binary redistribution. |
22 | * 3. Neither the names of the above-listed copyright holders nor the names | 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 | 23 | * of any contributors may be used to endorse or promote products derived |
24 | * from this software without specific prior written permission. | 24 | * from this software without specific prior written permission. |
25 | * | 25 | * |
26 | * Alternatively, this software may be distributed under the terms of the | 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 | 27 | * GNU General Public License ("GPL") version 2 as published by the Free |
28 | * Software Foundation. | 28 | * Software Foundation. |
29 | * | 29 | * |
30 | * NO WARRANTY | 30 | * NO WARRANTY |
31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | 33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR |
34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | 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 | 40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
41 | * POSSIBILITY OF SUCH DAMAGES. | 41 | * POSSIBILITY OF SUCH DAMAGES. |
42 | */ | 42 | */ |
43 | 43 | ||
44 | #ifndef __ACNAMESP_H__ | 44 | #ifndef __ACNAMESP_H__ |
45 | #define __ACNAMESP_H__ | 45 | #define __ACNAMESP_H__ |
46 | 46 | ||
47 | /* To search the entire name space, pass this as search_base */ | 47 | /* To search the entire name space, pass this as search_base */ |
48 | 48 | ||
49 | #define ACPI_NS_ALL ((acpi_handle)0) | 49 | #define ACPI_NS_ALL ((acpi_handle)0) |
50 | 50 | ||
51 | /* | 51 | /* |
52 | * Elements of acpi_ns_properties are bit significant | 52 | * Elements of acpi_ns_properties are bit significant |
53 | * and should be one-to-one with values of acpi_object_type | 53 | * and should be one-to-one with values of acpi_object_type |
54 | */ | 54 | */ |
55 | #define ACPI_NS_NORMAL 0 | 55 | #define ACPI_NS_NORMAL 0 |
56 | #define ACPI_NS_NEWSCOPE 1 /* a definition of this type opens a name scope */ | 56 | #define ACPI_NS_NEWSCOPE 1 /* a definition of this type opens a name scope */ |
57 | #define ACPI_NS_LOCAL 2 /* suppress search of enclosing scopes */ | 57 | #define ACPI_NS_LOCAL 2 /* suppress search of enclosing scopes */ |
58 | 58 | ||
59 | /* Flags for acpi_ns_lookup, acpi_ns_search_and_enter */ | 59 | /* Flags for acpi_ns_lookup, acpi_ns_search_and_enter */ |
60 | 60 | ||
61 | #define ACPI_NS_NO_UPSEARCH 0 | 61 | #define ACPI_NS_NO_UPSEARCH 0 |
62 | #define ACPI_NS_SEARCH_PARENT 0x01 | 62 | #define ACPI_NS_SEARCH_PARENT 0x01 |
63 | #define ACPI_NS_DONT_OPEN_SCOPE 0x02 | 63 | #define ACPI_NS_DONT_OPEN_SCOPE 0x02 |
64 | #define ACPI_NS_NO_PEER_SEARCH 0x04 | 64 | #define ACPI_NS_NO_PEER_SEARCH 0x04 |
65 | #define ACPI_NS_ERROR_IF_FOUND 0x08 | 65 | #define ACPI_NS_ERROR_IF_FOUND 0x08 |
66 | #define ACPI_NS_PREFIX_IS_SCOPE 0x10 | 66 | #define ACPI_NS_PREFIX_IS_SCOPE 0x10 |
67 | #define ACPI_NS_EXTERNAL 0x20 | 67 | #define ACPI_NS_EXTERNAL 0x20 |
68 | #define ACPI_NS_TEMPORARY 0x40 | 68 | #define ACPI_NS_TEMPORARY 0x40 |
69 | 69 | ||
70 | /* Flags for acpi_ns_walk_namespace */ | 70 | /* Flags for acpi_ns_walk_namespace */ |
71 | 71 | ||
72 | #define ACPI_NS_WALK_NO_UNLOCK 0 | 72 | #define ACPI_NS_WALK_NO_UNLOCK 0 |
73 | #define ACPI_NS_WALK_UNLOCK 0x01 | 73 | #define ACPI_NS_WALK_UNLOCK 0x01 |
74 | #define ACPI_NS_WALK_TEMP_NODES 0x02 | 74 | #define ACPI_NS_WALK_TEMP_NODES 0x02 |
75 | 75 | ||
76 | /* Object is not a package element */ | 76 | /* Object is not a package element */ |
77 | 77 | ||
78 | #define ACPI_NOT_PACKAGE_ELEMENT ACPI_UINT32_MAX | 78 | #define ACPI_NOT_PACKAGE_ELEMENT ACPI_UINT32_MAX |
79 | 79 | ||
80 | /* Always emit warning message, not dependent on node flags */ | 80 | /* Always emit warning message, not dependent on node flags */ |
81 | 81 | ||
82 | #define ACPI_WARN_ALWAYS 0 | 82 | #define ACPI_WARN_ALWAYS 0 |
83 | 83 | ||
84 | /* | 84 | /* |
85 | * nsinit - Namespace initialization | 85 | * nsinit - Namespace initialization |
86 | */ | 86 | */ |
87 | acpi_status acpi_ns_initialize_objects(void); | 87 | acpi_status acpi_ns_initialize_objects(void); |
88 | 88 | ||
89 | acpi_status acpi_ns_initialize_devices(void); | 89 | acpi_status acpi_ns_initialize_devices(void); |
90 | 90 | ||
91 | /* | 91 | /* |
92 | * nsload - Namespace loading | 92 | * nsload - Namespace loading |
93 | */ | 93 | */ |
94 | acpi_status acpi_ns_load_namespace(void); | 94 | acpi_status acpi_ns_load_namespace(void); |
95 | 95 | ||
96 | acpi_status | 96 | acpi_status |
97 | acpi_ns_load_table(u32 table_index, struct acpi_namespace_node *node); | 97 | acpi_ns_load_table(u32 table_index, struct acpi_namespace_node *node); |
98 | 98 | ||
99 | /* | 99 | /* |
100 | * nswalk - walk the namespace | 100 | * nswalk - walk the namespace |
101 | */ | 101 | */ |
102 | acpi_status | 102 | acpi_status |
103 | acpi_ns_walk_namespace(acpi_object_type type, | 103 | acpi_ns_walk_namespace(acpi_object_type type, |
104 | acpi_handle start_object, | 104 | acpi_handle start_object, |
105 | u32 max_depth, | 105 | u32 max_depth, |
106 | u32 flags, | 106 | u32 flags, |
107 | acpi_walk_callback pre_order_visit, | 107 | acpi_walk_callback pre_order_visit, |
108 | acpi_walk_callback post_order_visit, | 108 | acpi_walk_callback post_order_visit, |
109 | void *context, void **return_value); | 109 | void *context, void **return_value); |
110 | 110 | ||
111 | struct acpi_namespace_node *acpi_ns_get_next_node(struct acpi_namespace_node | 111 | struct acpi_namespace_node *acpi_ns_get_next_node(struct acpi_namespace_node |
112 | *parent, | 112 | *parent, |
113 | struct acpi_namespace_node | 113 | struct acpi_namespace_node |
114 | *child); | 114 | *child); |
115 | 115 | ||
116 | struct acpi_namespace_node *acpi_ns_get_next_node_typed(acpi_object_type type, | 116 | struct acpi_namespace_node *acpi_ns_get_next_node_typed(acpi_object_type type, |
117 | struct | 117 | struct |
118 | acpi_namespace_node | 118 | acpi_namespace_node |
119 | *parent, | 119 | *parent, |
120 | struct | 120 | struct |
121 | acpi_namespace_node | 121 | acpi_namespace_node |
122 | *child); | 122 | *child); |
123 | 123 | ||
124 | /* | 124 | /* |
125 | * nsparse - table parsing | 125 | * nsparse - table parsing |
126 | */ | 126 | */ |
127 | acpi_status | 127 | acpi_status |
128 | acpi_ns_parse_table(u32 table_index, struct acpi_namespace_node *start_node); | 128 | acpi_ns_parse_table(u32 table_index, struct acpi_namespace_node *start_node); |
129 | 129 | ||
130 | acpi_status | 130 | acpi_status |
131 | acpi_ns_one_complete_parse(u32 pass_number, | 131 | acpi_ns_one_complete_parse(u32 pass_number, |
132 | u32 table_index, | 132 | u32 table_index, |
133 | struct acpi_namespace_node *start_node); | 133 | struct acpi_namespace_node *start_node); |
134 | 134 | ||
135 | /* | 135 | /* |
136 | * nsaccess - Top-level namespace access | 136 | * nsaccess - Top-level namespace access |
137 | */ | 137 | */ |
138 | acpi_status acpi_ns_root_initialize(void); | 138 | acpi_status acpi_ns_root_initialize(void); |
139 | 139 | ||
140 | acpi_status | 140 | acpi_status |
141 | acpi_ns_lookup(union acpi_generic_state *scope_info, | 141 | acpi_ns_lookup(union acpi_generic_state *scope_info, |
142 | char *name, | 142 | char *name, |
143 | acpi_object_type type, | 143 | acpi_object_type type, |
144 | acpi_interpreter_mode interpreter_mode, | 144 | acpi_interpreter_mode interpreter_mode, |
145 | u32 flags, | 145 | u32 flags, |
146 | struct acpi_walk_state *walk_state, | 146 | struct acpi_walk_state *walk_state, |
147 | struct acpi_namespace_node **ret_node); | 147 | struct acpi_namespace_node **ret_node); |
148 | 148 | ||
149 | /* | 149 | /* |
150 | * nsalloc - Named object allocation/deallocation | 150 | * nsalloc - Named object allocation/deallocation |
151 | */ | 151 | */ |
152 | struct acpi_namespace_node *acpi_ns_create_node(u32 name); | 152 | struct acpi_namespace_node *acpi_ns_create_node(u32 name); |
153 | 153 | ||
154 | void acpi_ns_delete_node(struct acpi_namespace_node *node); | 154 | void acpi_ns_delete_node(struct acpi_namespace_node *node); |
155 | 155 | ||
156 | void acpi_ns_remove_node(struct acpi_namespace_node *node); | 156 | void acpi_ns_remove_node(struct acpi_namespace_node *node); |
157 | 157 | ||
158 | void | 158 | void |
159 | acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_handle); | 159 | acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_handle); |
160 | 160 | ||
161 | void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id); | 161 | void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id); |
162 | 162 | ||
163 | void acpi_ns_detach_object(struct acpi_namespace_node *node); | 163 | void acpi_ns_detach_object(struct acpi_namespace_node *node); |
164 | 164 | ||
165 | void acpi_ns_delete_children(struct acpi_namespace_node *parent); | 165 | void acpi_ns_delete_children(struct acpi_namespace_node *parent); |
166 | 166 | ||
167 | int acpi_ns_compare_names(char *name1, char *name2); | 167 | int acpi_ns_compare_names(char *name1, char *name2); |
168 | 168 | ||
169 | /* | 169 | /* |
170 | * nsdump - Namespace dump/print utilities | 170 | * nsdump - Namespace dump/print utilities |
171 | */ | 171 | */ |
172 | #ifdef ACPI_FUTURE_USAGE | 172 | #ifdef ACPI_FUTURE_USAGE |
173 | void acpi_ns_dump_tables(acpi_handle search_base, u32 max_depth); | 173 | void acpi_ns_dump_tables(acpi_handle search_base, u32 max_depth); |
174 | #endif /* ACPI_FUTURE_USAGE */ | 174 | #endif /* ACPI_FUTURE_USAGE */ |
175 | 175 | ||
176 | void acpi_ns_dump_entry(acpi_handle handle, u32 debug_level); | 176 | void acpi_ns_dump_entry(acpi_handle handle, u32 debug_level); |
177 | 177 | ||
178 | void | 178 | void |
179 | acpi_ns_dump_pathname(acpi_handle handle, char *msg, u32 level, u32 component); | 179 | acpi_ns_dump_pathname(acpi_handle handle, char *msg, u32 level, u32 component); |
180 | 180 | ||
181 | void acpi_ns_print_pathname(u32 num_segments, char *pathname); | 181 | void acpi_ns_print_pathname(u32 num_segments, char *pathname); |
182 | 182 | ||
183 | acpi_status | 183 | acpi_status |
184 | acpi_ns_dump_one_object(acpi_handle obj_handle, | 184 | acpi_ns_dump_one_object(acpi_handle obj_handle, |
185 | u32 level, void *context, void **return_value); | 185 | u32 level, void *context, void **return_value); |
186 | 186 | ||
187 | #ifdef ACPI_FUTURE_USAGE | 187 | #ifdef ACPI_FUTURE_USAGE |
188 | void | 188 | void |
189 | acpi_ns_dump_objects(acpi_object_type type, | 189 | acpi_ns_dump_objects(acpi_object_type type, |
190 | u8 display_type, | 190 | u8 display_type, |
191 | u32 max_depth, | 191 | u32 max_depth, |
192 | acpi_owner_id owner_id, acpi_handle start_handle); | 192 | acpi_owner_id owner_id, acpi_handle start_handle); |
193 | #endif /* ACPI_FUTURE_USAGE */ | 193 | #endif /* ACPI_FUTURE_USAGE */ |
194 | 194 | ||
195 | /* | 195 | /* |
196 | * nseval - Namespace evaluation functions | 196 | * nseval - Namespace evaluation functions |
197 | */ | 197 | */ |
198 | acpi_status acpi_ns_evaluate(struct acpi_evaluate_info *info); | 198 | acpi_status acpi_ns_evaluate(struct acpi_evaluate_info *info); |
199 | 199 | ||
200 | void acpi_ns_exec_module_code_list(void); | 200 | void acpi_ns_exec_module_code_list(void); |
201 | 201 | ||
202 | /* | 202 | /* |
203 | * nspredef - Support for predefined/reserved names | 203 | * nspredef - Support for predefined/reserved names |
204 | */ | 204 | */ |
205 | acpi_status | 205 | acpi_status |
206 | acpi_ns_check_predefined_names(struct acpi_namespace_node *node, | 206 | acpi_ns_check_predefined_names(struct acpi_namespace_node *node, |
207 | u32 user_param_count, | 207 | u32 user_param_count, |
208 | acpi_status return_status, | 208 | acpi_status return_status, |
209 | union acpi_operand_object **return_object); | 209 | union acpi_operand_object **return_object); |
210 | 210 | ||
211 | const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct | 211 | const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct |
212 | acpi_namespace_node | 212 | acpi_namespace_node |
213 | *node); | 213 | *node); |
214 | 214 | ||
215 | void | 215 | void |
216 | acpi_ns_check_parameter_count(char *pathname, | 216 | acpi_ns_check_parameter_count(char *pathname, |
217 | struct acpi_namespace_node *node, | 217 | struct acpi_namespace_node *node, |
218 | u32 user_param_count, | 218 | u32 user_param_count, |
219 | const union acpi_predefined_info *info); | 219 | const union acpi_predefined_info *info); |
220 | 220 | ||
221 | /* | 221 | /* |
222 | * nsnames - Name and Scope manipulation | 222 | * nsnames - Name and Scope manipulation |
223 | */ | 223 | */ |
224 | u32 acpi_ns_opens_scope(acpi_object_type type); | 224 | u32 acpi_ns_opens_scope(acpi_object_type type); |
225 | 225 | ||
226 | acpi_status | 226 | acpi_status |
227 | acpi_ns_build_external_path(struct acpi_namespace_node *node, | 227 | acpi_ns_build_external_path(struct acpi_namespace_node *node, |
228 | acpi_size size, char *name_buffer); | 228 | acpi_size size, char *name_buffer); |
229 | 229 | ||
230 | char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node); | 230 | char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node); |
231 | 231 | ||
232 | char *acpi_ns_name_of_current_scope(struct acpi_walk_state *walk_state); | 232 | char *acpi_ns_name_of_current_scope(struct acpi_walk_state *walk_state); |
233 | 233 | ||
234 | acpi_status | 234 | acpi_status |
235 | acpi_ns_handle_to_pathname(acpi_handle target_handle, | 235 | acpi_ns_handle_to_pathname(acpi_handle target_handle, |
236 | struct acpi_buffer *buffer); | 236 | struct acpi_buffer *buffer); |
237 | 237 | ||
238 | u8 | 238 | u8 |
239 | acpi_ns_pattern_match(struct acpi_namespace_node *obj_node, char *search_for); | 239 | acpi_ns_pattern_match(struct acpi_namespace_node *obj_node, char *search_for); |
240 | 240 | ||
241 | acpi_status | 241 | acpi_status |
242 | acpi_ns_get_node(struct acpi_namespace_node *prefix_node, | 242 | acpi_ns_get_node(struct acpi_namespace_node *prefix_node, |
243 | const char *external_pathname, | 243 | const char *external_pathname, |
244 | u32 flags, struct acpi_namespace_node **out_node); | 244 | u32 flags, struct acpi_namespace_node **out_node); |
245 | 245 | ||
246 | acpi_size acpi_ns_get_pathname_length(struct acpi_namespace_node *node); | 246 | acpi_size acpi_ns_get_pathname_length(struct acpi_namespace_node *node); |
247 | 247 | ||
248 | /* | 248 | /* |
249 | * nsobject - Object management for namespace nodes | 249 | * nsobject - Object management for namespace nodes |
250 | */ | 250 | */ |
251 | acpi_status | 251 | acpi_status |
252 | acpi_ns_attach_object(struct acpi_namespace_node *node, | 252 | acpi_ns_attach_object(struct acpi_namespace_node *node, |
253 | union acpi_operand_object *object, acpi_object_type type); | 253 | union acpi_operand_object *object, acpi_object_type type); |
254 | 254 | ||
255 | union acpi_operand_object *acpi_ns_get_attached_object(struct | 255 | union acpi_operand_object *acpi_ns_get_attached_object(struct |
256 | acpi_namespace_node | 256 | acpi_namespace_node |
257 | *node); | 257 | *node); |
258 | 258 | ||
259 | union acpi_operand_object *acpi_ns_get_secondary_object(union | 259 | union acpi_operand_object *acpi_ns_get_secondary_object(union |
260 | acpi_operand_object | 260 | acpi_operand_object |
261 | *obj_desc); | 261 | *obj_desc); |
262 | 262 | ||
263 | acpi_status | 263 | acpi_status |
264 | acpi_ns_attach_data(struct acpi_namespace_node *node, | 264 | acpi_ns_attach_data(struct acpi_namespace_node *node, |
265 | acpi_object_handler handler, void *data); | 265 | acpi_object_handler handler, void *data); |
266 | 266 | ||
267 | acpi_status | 267 | acpi_status |
268 | acpi_ns_detach_data(struct acpi_namespace_node *node, | 268 | acpi_ns_detach_data(struct acpi_namespace_node *node, |
269 | acpi_object_handler handler); | 269 | acpi_object_handler handler); |
270 | 270 | ||
271 | acpi_status | 271 | acpi_status |
272 | acpi_ns_get_attached_data(struct acpi_namespace_node *node, | 272 | acpi_ns_get_attached_data(struct acpi_namespace_node *node, |
273 | acpi_object_handler handler, void **data); | 273 | acpi_object_handler handler, void **data); |
274 | 274 | ||
275 | /* | 275 | /* |
276 | * nsrepair - General return object repair for all | 276 | * nsrepair - General return object repair for all |
277 | * predefined methods/objects | 277 | * predefined methods/objects |
278 | */ | 278 | */ |
279 | acpi_status | 279 | acpi_status |
280 | acpi_ns_repair_object(struct acpi_predefined_data *data, | 280 | acpi_ns_repair_object(struct acpi_predefined_data *data, |
281 | u32 expected_btypes, | 281 | u32 expected_btypes, |
282 | u32 package_index, | 282 | u32 package_index, |
283 | union acpi_operand_object **return_object_ptr); | 283 | union acpi_operand_object **return_object_ptr); |
284 | 284 | ||
285 | acpi_status | 285 | acpi_status |
286 | acpi_ns_repair_package_list(struct acpi_predefined_data *data, | 286 | acpi_ns_repair_package_list(struct acpi_predefined_data *data, |
287 | union acpi_operand_object **obj_desc_ptr); | 287 | union acpi_operand_object **obj_desc_ptr); |
288 | 288 | ||
289 | acpi_status | ||
290 | acpi_ns_repair_null_element(struct acpi_predefined_data *data, | ||
291 | u32 expected_btypes, | ||
292 | u32 package_index, | ||
293 | union acpi_operand_object **return_object_ptr); | ||
294 | |||
295 | void | ||
296 | acpi_ns_remove_null_elements(struct acpi_predefined_data *data, | ||
297 | u8 package_type, | ||
298 | union acpi_operand_object *obj_desc); | ||
299 | |||
289 | /* | 300 | /* |
290 | * nsrepair2 - Return object repair for specific | 301 | * nsrepair2 - Return object repair for specific |
291 | * predefined methods/objects | 302 | * predefined methods/objects |
292 | */ | 303 | */ |
293 | acpi_status | 304 | acpi_status |
294 | acpi_ns_complex_repairs(struct acpi_predefined_data *data, | 305 | acpi_ns_complex_repairs(struct acpi_predefined_data *data, |
295 | struct acpi_namespace_node *node, | 306 | struct acpi_namespace_node *node, |
296 | acpi_status validate_status, | 307 | acpi_status validate_status, |
297 | union acpi_operand_object **return_object_ptr); | 308 | union acpi_operand_object **return_object_ptr); |
298 | |||
299 | void | ||
300 | acpi_ns_remove_null_elements(struct acpi_predefined_data *data, | ||
301 | u8 package_type, | ||
302 | union acpi_operand_object *obj_desc); | ||
303 | 309 | ||
304 | /* | 310 | /* |
305 | * nssearch - Namespace searching and entry | 311 | * nssearch - Namespace searching and entry |
306 | */ | 312 | */ |
307 | acpi_status | 313 | acpi_status |
308 | acpi_ns_search_and_enter(u32 entry_name, | 314 | acpi_ns_search_and_enter(u32 entry_name, |
309 | struct acpi_walk_state *walk_state, | 315 | struct acpi_walk_state *walk_state, |
310 | struct acpi_namespace_node *node, | 316 | struct acpi_namespace_node *node, |
311 | acpi_interpreter_mode interpreter_mode, | 317 | acpi_interpreter_mode interpreter_mode, |
312 | acpi_object_type type, | 318 | acpi_object_type type, |
313 | u32 flags, struct acpi_namespace_node **ret_node); | 319 | u32 flags, struct acpi_namespace_node **ret_node); |
314 | 320 | ||
315 | acpi_status | 321 | acpi_status |
316 | acpi_ns_search_one_scope(u32 entry_name, | 322 | acpi_ns_search_one_scope(u32 entry_name, |
317 | struct acpi_namespace_node *node, | 323 | struct acpi_namespace_node *node, |
318 | acpi_object_type type, | 324 | acpi_object_type type, |
319 | struct acpi_namespace_node **ret_node); | 325 | struct acpi_namespace_node **ret_node); |
320 | 326 | ||
321 | void | 327 | void |
322 | acpi_ns_install_node(struct acpi_walk_state *walk_state, | 328 | acpi_ns_install_node(struct acpi_walk_state *walk_state, |
323 | struct acpi_namespace_node *parent_node, | 329 | struct acpi_namespace_node *parent_node, |
324 | struct acpi_namespace_node *node, acpi_object_type type); | 330 | struct acpi_namespace_node *node, acpi_object_type type); |
325 | 331 | ||
326 | /* | 332 | /* |
327 | * nsutils - Utility functions | 333 | * nsutils - Utility functions |
328 | */ | 334 | */ |
329 | u8 acpi_ns_valid_root_prefix(char prefix); | 335 | u8 acpi_ns_valid_root_prefix(char prefix); |
330 | 336 | ||
331 | acpi_object_type acpi_ns_get_type(struct acpi_namespace_node *node); | 337 | acpi_object_type acpi_ns_get_type(struct acpi_namespace_node *node); |
332 | 338 | ||
333 | u32 acpi_ns_local(acpi_object_type type); | 339 | u32 acpi_ns_local(acpi_object_type type); |
334 | 340 | ||
335 | void | 341 | void |
336 | acpi_ns_report_error(const char *module_name, | 342 | acpi_ns_report_error(const char *module_name, |
337 | u32 line_number, | 343 | u32 line_number, |
338 | const char *internal_name, acpi_status lookup_status); | 344 | const char *internal_name, acpi_status lookup_status); |
339 | 345 | ||
340 | void | 346 | void |
341 | acpi_ns_report_method_error(const char *module_name, | 347 | acpi_ns_report_method_error(const char *module_name, |
342 | u32 line_number, | 348 | u32 line_number, |
343 | const char *message, | 349 | const char *message, |
344 | struct acpi_namespace_node *node, | 350 | struct acpi_namespace_node *node, |
345 | const char *path, acpi_status lookup_status); | 351 | const char *path, acpi_status lookup_status); |
346 | 352 | ||
347 | void | 353 | void |
348 | acpi_ns_print_node_pathname(struct acpi_namespace_node *node, const char *msg); | 354 | acpi_ns_print_node_pathname(struct acpi_namespace_node *node, const char *msg); |
349 | 355 | ||
350 | acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info); | 356 | acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info); |
351 | 357 | ||
352 | void acpi_ns_get_internal_name_length(struct acpi_namestring_info *info); | 358 | void acpi_ns_get_internal_name_length(struct acpi_namestring_info *info); |
353 | 359 | ||
354 | acpi_status | 360 | acpi_status |
355 | acpi_ns_internalize_name(const char *dotted_name, char **converted_name); | 361 | acpi_ns_internalize_name(const char *dotted_name, char **converted_name); |
356 | 362 | ||
357 | acpi_status | 363 | acpi_status |
358 | acpi_ns_externalize_name(u32 internal_name_length, | 364 | acpi_ns_externalize_name(u32 internal_name_length, |
359 | const char *internal_name, | 365 | const char *internal_name, |
360 | u32 * converted_name_length, char **converted_name); | 366 | u32 * converted_name_length, char **converted_name); |
361 | 367 | ||
362 | struct acpi_namespace_node *acpi_ns_validate_handle(acpi_handle handle); | 368 | struct acpi_namespace_node *acpi_ns_validate_handle(acpi_handle handle); |
363 | 369 | ||
364 | void acpi_ns_terminate(void); | 370 | void acpi_ns_terminate(void); |
365 | 371 | ||
366 | struct acpi_namespace_node *acpi_ns_get_parent_node(struct acpi_namespace_node | 372 | struct acpi_namespace_node *acpi_ns_get_parent_node(struct acpi_namespace_node |
367 | *node); | 373 | *node); |
368 | 374 | ||
369 | struct acpi_namespace_node *acpi_ns_get_next_valid_node(struct | 375 | struct acpi_namespace_node *acpi_ns_get_next_valid_node(struct |
drivers/acpi/acpica/nspredef.c
1 | /****************************************************************************** | 1 | /****************************************************************************** |
2 | * | 2 | * |
3 | * Module Name: nspredef - Validation of ACPI predefined methods and objects | 3 | * Module Name: nspredef - Validation of ACPI predefined methods and objects |
4 | * $Revision: 1.1 $ | 4 | * $Revision: 1.1 $ |
5 | * | 5 | * |
6 | *****************************************************************************/ | 6 | *****************************************************************************/ |
7 | 7 | ||
8 | /* | 8 | /* |
9 | * Copyright (C) 2000 - 2010, Intel Corp. | 9 | * Copyright (C) 2000 - 2010, Intel Corp. |
10 | * All rights reserved. | 10 | * All rights reserved. |
11 | * | 11 | * |
12 | * Redistribution and use in source and binary forms, with or without | 12 | * Redistribution and use in source and binary forms, with or without |
13 | * modification, are permitted provided that the following conditions | 13 | * modification, are permitted provided that the following conditions |
14 | * are met: | 14 | * are met: |
15 | * 1. Redistributions of source code must retain the above copyright | 15 | * 1. Redistributions of source code must retain the above copyright |
16 | * notice, this list of conditions, and the following disclaimer, | 16 | * notice, this list of conditions, and the following disclaimer, |
17 | * without modification. | 17 | * without modification. |
18 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | 18 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
19 | * substantially similar to the "NO WARRANTY" disclaimer below | 19 | * substantially similar to the "NO WARRANTY" disclaimer below |
20 | * ("Disclaimer") and any redistribution must be conditioned upon | 20 | * ("Disclaimer") and any redistribution must be conditioned upon |
21 | * including a substantially similar Disclaimer requirement for further | 21 | * including a substantially similar Disclaimer requirement for further |
22 | * binary redistribution. | 22 | * binary redistribution. |
23 | * 3. Neither the names of the above-listed copyright holders nor the names | 23 | * 3. Neither the names of the above-listed copyright holders nor the names |
24 | * of any contributors may be used to endorse or promote products derived | 24 | * of any contributors may be used to endorse or promote products derived |
25 | * from this software without specific prior written permission. | 25 | * from this software without specific prior written permission. |
26 | * | 26 | * |
27 | * Alternatively, this software may be distributed under the terms of the | 27 | * Alternatively, this software may be distributed under the terms of the |
28 | * GNU General Public License ("GPL") version 2 as published by the Free | 28 | * GNU General Public License ("GPL") version 2 as published by the Free |
29 | * Software Foundation. | 29 | * Software Foundation. |
30 | * | 30 | * |
31 | * NO WARRANTY | 31 | * NO WARRANTY |
32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
33 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 33 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
34 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | 34 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR |
35 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 35 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
36 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 36 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
38 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 38 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
39 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 39 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
40 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | 40 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
41 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 41 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
42 | * POSSIBILITY OF SUCH DAMAGES. | 42 | * POSSIBILITY OF SUCH DAMAGES. |
43 | */ | 43 | */ |
44 | 44 | ||
45 | #define ACPI_CREATE_PREDEFINED_TABLE | 45 | #define ACPI_CREATE_PREDEFINED_TABLE |
46 | 46 | ||
47 | #include <acpi/acpi.h> | 47 | #include <acpi/acpi.h> |
48 | #include "accommon.h" | 48 | #include "accommon.h" |
49 | #include "acnamesp.h" | 49 | #include "acnamesp.h" |
50 | #include "acpredef.h" | 50 | #include "acpredef.h" |
51 | 51 | ||
52 | #define _COMPONENT ACPI_NAMESPACE | 52 | #define _COMPONENT ACPI_NAMESPACE |
53 | ACPI_MODULE_NAME("nspredef") | 53 | ACPI_MODULE_NAME("nspredef") |
54 | 54 | ||
55 | /******************************************************************************* | 55 | /******************************************************************************* |
56 | * | 56 | * |
57 | * This module validates predefined ACPI objects that appear in the namespace, | 57 | * This module validates predefined ACPI objects that appear in the namespace, |
58 | * at the time they are evaluated (via acpi_evaluate_object). The purpose of this | 58 | * at the time they are evaluated (via acpi_evaluate_object). The purpose of this |
59 | * validation is to detect problems with BIOS-exposed predefined ACPI objects | 59 | * validation is to detect problems with BIOS-exposed predefined ACPI objects |
60 | * before the results are returned to the ACPI-related drivers. | 60 | * before the results are returned to the ACPI-related drivers. |
61 | * | 61 | * |
62 | * There are several areas that are validated: | 62 | * There are several areas that are validated: |
63 | * | 63 | * |
64 | * 1) The number of input arguments as defined by the method/object in the | 64 | * 1) The number of input arguments as defined by the method/object in the |
65 | * ASL is validated against the ACPI specification. | 65 | * ASL is validated against the ACPI specification. |
66 | * 2) The type of the return object (if any) is validated against the ACPI | 66 | * 2) The type of the return object (if any) is validated against the ACPI |
67 | * specification. | 67 | * specification. |
68 | * 3) For returned package objects, the count of package elements is | 68 | * 3) For returned package objects, the count of package elements is |
69 | * validated, as well as the type of each package element. Nested | 69 | * validated, as well as the type of each package element. Nested |
70 | * packages are supported. | 70 | * packages are supported. |
71 | * | 71 | * |
72 | * For any problems found, a warning message is issued. | 72 | * For any problems found, a warning message is issued. |
73 | * | 73 | * |
74 | ******************************************************************************/ | 74 | ******************************************************************************/ |
75 | /* Local prototypes */ | 75 | /* Local prototypes */ |
76 | static acpi_status | 76 | static acpi_status |
77 | acpi_ns_check_package(struct acpi_predefined_data *data, | 77 | acpi_ns_check_package(struct acpi_predefined_data *data, |
78 | union acpi_operand_object **return_object_ptr); | 78 | union acpi_operand_object **return_object_ptr); |
79 | 79 | ||
80 | static acpi_status | 80 | static acpi_status |
81 | acpi_ns_check_package_list(struct acpi_predefined_data *data, | 81 | acpi_ns_check_package_list(struct acpi_predefined_data *data, |
82 | const union acpi_predefined_info *package, | 82 | const union acpi_predefined_info *package, |
83 | union acpi_operand_object **elements, u32 count); | 83 | union acpi_operand_object **elements, u32 count); |
84 | 84 | ||
85 | static acpi_status | 85 | static acpi_status |
86 | acpi_ns_check_package_elements(struct acpi_predefined_data *data, | 86 | acpi_ns_check_package_elements(struct acpi_predefined_data *data, |
87 | union acpi_operand_object **elements, | 87 | union acpi_operand_object **elements, |
88 | u8 type1, | 88 | u8 type1, |
89 | u32 count1, | 89 | u32 count1, |
90 | u8 type2, u32 count2, u32 start_index); | 90 | u8 type2, u32 count2, u32 start_index); |
91 | 91 | ||
92 | static acpi_status | 92 | static acpi_status |
93 | acpi_ns_check_object_type(struct acpi_predefined_data *data, | 93 | acpi_ns_check_object_type(struct acpi_predefined_data *data, |
94 | union acpi_operand_object **return_object_ptr, | 94 | union acpi_operand_object **return_object_ptr, |
95 | u32 expected_btypes, u32 package_index); | 95 | u32 expected_btypes, u32 package_index); |
96 | 96 | ||
97 | static acpi_status | 97 | static acpi_status |
98 | acpi_ns_check_reference(struct acpi_predefined_data *data, | 98 | acpi_ns_check_reference(struct acpi_predefined_data *data, |
99 | union acpi_operand_object *return_object); | 99 | union acpi_operand_object *return_object); |
100 | 100 | ||
101 | static void acpi_ns_get_expected_types(char *buffer, u32 expected_btypes); | 101 | static void acpi_ns_get_expected_types(char *buffer, u32 expected_btypes); |
102 | 102 | ||
103 | /* | 103 | /* |
104 | * Names for the types that can be returned by the predefined objects. | 104 | * Names for the types that can be returned by the predefined objects. |
105 | * Used for warning messages. Must be in the same order as the ACPI_RTYPEs | 105 | * Used for warning messages. Must be in the same order as the ACPI_RTYPEs |
106 | */ | 106 | */ |
107 | static const char *acpi_rtype_names[] = { | 107 | static const char *acpi_rtype_names[] = { |
108 | "/Integer", | 108 | "/Integer", |
109 | "/String", | 109 | "/String", |
110 | "/Buffer", | 110 | "/Buffer", |
111 | "/Package", | 111 | "/Package", |
112 | "/Reference", | 112 | "/Reference", |
113 | }; | 113 | }; |
114 | 114 | ||
115 | /******************************************************************************* | 115 | /******************************************************************************* |
116 | * | 116 | * |
117 | * FUNCTION: acpi_ns_check_predefined_names | 117 | * FUNCTION: acpi_ns_check_predefined_names |
118 | * | 118 | * |
119 | * PARAMETERS: Node - Namespace node for the method/object | 119 | * PARAMETERS: Node - Namespace node for the method/object |
120 | * user_param_count - Number of parameters actually passed | 120 | * user_param_count - Number of parameters actually passed |
121 | * return_status - Status from the object evaluation | 121 | * return_status - Status from the object evaluation |
122 | * return_object_ptr - Pointer to the object returned from the | 122 | * return_object_ptr - Pointer to the object returned from the |
123 | * evaluation of a method or object | 123 | * evaluation of a method or object |
124 | * | 124 | * |
125 | * RETURN: Status | 125 | * RETURN: Status |
126 | * | 126 | * |
127 | * DESCRIPTION: Check an ACPI name for a match in the predefined name list. | 127 | * DESCRIPTION: Check an ACPI name for a match in the predefined name list. |
128 | * | 128 | * |
129 | ******************************************************************************/ | 129 | ******************************************************************************/ |
130 | 130 | ||
131 | acpi_status | 131 | acpi_status |
132 | acpi_ns_check_predefined_names(struct acpi_namespace_node *node, | 132 | acpi_ns_check_predefined_names(struct acpi_namespace_node *node, |
133 | u32 user_param_count, | 133 | u32 user_param_count, |
134 | acpi_status return_status, | 134 | acpi_status return_status, |
135 | union acpi_operand_object **return_object_ptr) | 135 | union acpi_operand_object **return_object_ptr) |
136 | { | 136 | { |
137 | union acpi_operand_object *return_object = *return_object_ptr; | 137 | union acpi_operand_object *return_object = *return_object_ptr; |
138 | acpi_status status = AE_OK; | 138 | acpi_status status = AE_OK; |
139 | const union acpi_predefined_info *predefined; | 139 | const union acpi_predefined_info *predefined; |
140 | char *pathname; | 140 | char *pathname; |
141 | struct acpi_predefined_data *data; | 141 | struct acpi_predefined_data *data; |
142 | 142 | ||
143 | /* Match the name for this method/object against the predefined list */ | 143 | /* Match the name for this method/object against the predefined list */ |
144 | 144 | ||
145 | predefined = acpi_ns_check_for_predefined_name(node); | 145 | predefined = acpi_ns_check_for_predefined_name(node); |
146 | 146 | ||
147 | /* Get the full pathname to the object, for use in warning messages */ | 147 | /* Get the full pathname to the object, for use in warning messages */ |
148 | 148 | ||
149 | pathname = acpi_ns_get_external_pathname(node); | 149 | pathname = acpi_ns_get_external_pathname(node); |
150 | if (!pathname) { | 150 | if (!pathname) { |
151 | return AE_OK; /* Could not get pathname, ignore */ | 151 | return AE_OK; /* Could not get pathname, ignore */ |
152 | } | 152 | } |
153 | 153 | ||
154 | /* | 154 | /* |
155 | * Check that the parameter count for this method matches the ASL | 155 | * Check that the parameter count for this method matches the ASL |
156 | * definition. For predefined names, ensure that both the caller and | 156 | * definition. For predefined names, ensure that both the caller and |
157 | * the method itself are in accordance with the ACPI specification. | 157 | * the method itself are in accordance with the ACPI specification. |
158 | */ | 158 | */ |
159 | acpi_ns_check_parameter_count(pathname, node, user_param_count, | 159 | acpi_ns_check_parameter_count(pathname, node, user_param_count, |
160 | predefined); | 160 | predefined); |
161 | 161 | ||
162 | /* If not a predefined name, we cannot validate the return object */ | 162 | /* If not a predefined name, we cannot validate the return object */ |
163 | 163 | ||
164 | if (!predefined) { | 164 | if (!predefined) { |
165 | goto cleanup; | 165 | goto cleanup; |
166 | } | 166 | } |
167 | 167 | ||
168 | /* | 168 | /* |
169 | * If the method failed or did not actually return an object, we cannot | 169 | * If the method failed or did not actually return an object, we cannot |
170 | * validate the return object | 170 | * validate the return object |
171 | */ | 171 | */ |
172 | if ((return_status != AE_OK) && (return_status != AE_CTRL_RETURN_VALUE)) { | 172 | if ((return_status != AE_OK) && (return_status != AE_CTRL_RETURN_VALUE)) { |
173 | goto cleanup; | 173 | goto cleanup; |
174 | } | 174 | } |
175 | 175 | ||
176 | /* | 176 | /* |
177 | * If there is no return value, check if we require a return value for | 177 | * If there is no return value, check if we require a return value for |
178 | * this predefined name. Either one return value is expected, or none, | 178 | * this predefined name. Either one return value is expected, or none, |
179 | * for both methods and other objects. | 179 | * for both methods and other objects. |
180 | * | 180 | * |
181 | * Exit now if there is no return object. Warning if one was expected. | 181 | * Exit now if there is no return object. Warning if one was expected. |
182 | */ | 182 | */ |
183 | if (!return_object) { | 183 | if (!return_object) { |
184 | if ((predefined->info.expected_btypes) && | 184 | if ((predefined->info.expected_btypes) && |
185 | (!(predefined->info.expected_btypes & ACPI_RTYPE_NONE))) { | 185 | (!(predefined->info.expected_btypes & ACPI_RTYPE_NONE))) { |
186 | ACPI_WARN_PREDEFINED((AE_INFO, pathname, | 186 | ACPI_WARN_PREDEFINED((AE_INFO, pathname, |
187 | ACPI_WARN_ALWAYS, | 187 | ACPI_WARN_ALWAYS, |
188 | "Missing expected return value")); | 188 | "Missing expected return value")); |
189 | 189 | ||
190 | status = AE_AML_NO_RETURN_VALUE; | 190 | status = AE_AML_NO_RETURN_VALUE; |
191 | } | 191 | } |
192 | goto cleanup; | 192 | goto cleanup; |
193 | } | 193 | } |
194 | 194 | ||
195 | /* | 195 | /* |
196 | * 1) We have a return value, but if one wasn't expected, just exit, this is | 196 | * 1) We have a return value, but if one wasn't expected, just exit, this is |
197 | * not a problem. For example, if the "Implicit Return" feature is | 197 | * not a problem. For example, if the "Implicit Return" feature is |
198 | * enabled, methods will always return a value. | 198 | * enabled, methods will always return a value. |
199 | * | 199 | * |
200 | * 2) If the return value can be of any type, then we cannot perform any | 200 | * 2) If the return value can be of any type, then we cannot perform any |
201 | * validation, exit. | 201 | * validation, exit. |
202 | */ | 202 | */ |
203 | if ((!predefined->info.expected_btypes) || | 203 | if ((!predefined->info.expected_btypes) || |
204 | (predefined->info.expected_btypes == ACPI_RTYPE_ALL)) { | 204 | (predefined->info.expected_btypes == ACPI_RTYPE_ALL)) { |
205 | goto cleanup; | 205 | goto cleanup; |
206 | } | 206 | } |
207 | 207 | ||
208 | /* Create the parameter data block for object validation */ | 208 | /* Create the parameter data block for object validation */ |
209 | 209 | ||
210 | data = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_predefined_data)); | 210 | data = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_predefined_data)); |
211 | if (!data) { | 211 | if (!data) { |
212 | goto cleanup; | 212 | goto cleanup; |
213 | } | 213 | } |
214 | data->predefined = predefined; | 214 | data->predefined = predefined; |
215 | data->node_flags = node->flags; | 215 | data->node_flags = node->flags; |
216 | data->pathname = pathname; | 216 | data->pathname = pathname; |
217 | 217 | ||
218 | /* | 218 | /* |
219 | * Check that the type of the main return object is what is expected | 219 | * Check that the type of the main return object is what is expected |
220 | * for this predefined name | 220 | * for this predefined name |
221 | */ | 221 | */ |
222 | status = acpi_ns_check_object_type(data, return_object_ptr, | 222 | status = acpi_ns_check_object_type(data, return_object_ptr, |
223 | predefined->info.expected_btypes, | 223 | predefined->info.expected_btypes, |
224 | ACPI_NOT_PACKAGE_ELEMENT); | 224 | ACPI_NOT_PACKAGE_ELEMENT); |
225 | if (ACPI_FAILURE(status)) { | 225 | if (ACPI_FAILURE(status)) { |
226 | goto exit; | 226 | goto exit; |
227 | } | 227 | } |
228 | 228 | ||
229 | /* | 229 | /* |
230 | * For returned Package objects, check the type of all sub-objects. | 230 | * For returned Package objects, check the type of all sub-objects. |
231 | * Note: Package may have been newly created by call above. | 231 | * Note: Package may have been newly created by call above. |
232 | */ | 232 | */ |
233 | if ((*return_object_ptr)->common.type == ACPI_TYPE_PACKAGE) { | 233 | if ((*return_object_ptr)->common.type == ACPI_TYPE_PACKAGE) { |
234 | data->parent_package = *return_object_ptr; | ||
234 | status = acpi_ns_check_package(data, return_object_ptr); | 235 | status = acpi_ns_check_package(data, return_object_ptr); |
235 | if (ACPI_FAILURE(status)) { | 236 | if (ACPI_FAILURE(status)) { |
236 | goto exit; | 237 | goto exit; |
237 | } | 238 | } |
238 | } | 239 | } |
239 | 240 | ||
240 | /* | 241 | /* |
241 | * The return object was OK, or it was successfully repaired above. | 242 | * The return object was OK, or it was successfully repaired above. |
242 | * Now make some additional checks such as verifying that package | 243 | * Now make some additional checks such as verifying that package |
243 | * objects are sorted correctly (if required) or buffer objects have | 244 | * objects are sorted correctly (if required) or buffer objects have |
244 | * the correct data width (bytes vs. dwords). These repairs are | 245 | * the correct data width (bytes vs. dwords). These repairs are |
245 | * performed on a per-name basis, i.e., the code is specific to | 246 | * performed on a per-name basis, i.e., the code is specific to |
246 | * particular predefined names. | 247 | * particular predefined names. |
247 | */ | 248 | */ |
248 | status = acpi_ns_complex_repairs(data, node, status, return_object_ptr); | 249 | status = acpi_ns_complex_repairs(data, node, status, return_object_ptr); |
249 | 250 | ||
250 | exit: | 251 | exit: |
251 | /* | 252 | /* |
252 | * If the object validation failed or if we successfully repaired one | 253 | * If the object validation failed or if we successfully repaired one |
253 | * or more objects, mark the parent node to suppress further warning | 254 | * or more objects, mark the parent node to suppress further warning |
254 | * messages during the next evaluation of the same method/object. | 255 | * messages during the next evaluation of the same method/object. |
255 | */ | 256 | */ |
256 | if (ACPI_FAILURE(status) || (data->flags & ACPI_OBJECT_REPAIRED)) { | 257 | if (ACPI_FAILURE(status) || (data->flags & ACPI_OBJECT_REPAIRED)) { |
257 | node->flags |= ANOBJ_EVALUATED; | 258 | node->flags |= ANOBJ_EVALUATED; |
258 | } | 259 | } |
259 | ACPI_FREE(data); | 260 | ACPI_FREE(data); |
260 | 261 | ||
261 | cleanup: | 262 | cleanup: |
262 | ACPI_FREE(pathname); | 263 | ACPI_FREE(pathname); |
263 | return (status); | 264 | return (status); |
264 | } | 265 | } |
265 | 266 | ||
266 | /******************************************************************************* | 267 | /******************************************************************************* |
267 | * | 268 | * |
268 | * FUNCTION: acpi_ns_check_parameter_count | 269 | * FUNCTION: acpi_ns_check_parameter_count |
269 | * | 270 | * |
270 | * PARAMETERS: Pathname - Full pathname to the node (for error msgs) | 271 | * PARAMETERS: Pathname - Full pathname to the node (for error msgs) |
271 | * Node - Namespace node for the method/object | 272 | * Node - Namespace node for the method/object |
272 | * user_param_count - Number of args passed in by the caller | 273 | * user_param_count - Number of args passed in by the caller |
273 | * Predefined - Pointer to entry in predefined name table | 274 | * Predefined - Pointer to entry in predefined name table |
274 | * | 275 | * |
275 | * RETURN: None | 276 | * RETURN: None |
276 | * | 277 | * |
277 | * DESCRIPTION: Check that the declared (in ASL/AML) parameter count for a | 278 | * DESCRIPTION: Check that the declared (in ASL/AML) parameter count for a |
278 | * predefined name is what is expected (i.e., what is defined in | 279 | * predefined name is what is expected (i.e., what is defined in |
279 | * the ACPI specification for this predefined name.) | 280 | * the ACPI specification for this predefined name.) |
280 | * | 281 | * |
281 | ******************************************************************************/ | 282 | ******************************************************************************/ |
282 | 283 | ||
283 | void | 284 | void |
284 | acpi_ns_check_parameter_count(char *pathname, | 285 | acpi_ns_check_parameter_count(char *pathname, |
285 | struct acpi_namespace_node *node, | 286 | struct acpi_namespace_node *node, |
286 | u32 user_param_count, | 287 | u32 user_param_count, |
287 | const union acpi_predefined_info *predefined) | 288 | const union acpi_predefined_info *predefined) |
288 | { | 289 | { |
289 | u32 param_count; | 290 | u32 param_count; |
290 | u32 required_params_current; | 291 | u32 required_params_current; |
291 | u32 required_params_old; | 292 | u32 required_params_old; |
292 | 293 | ||
293 | /* Methods have 0-7 parameters. All other types have zero. */ | 294 | /* Methods have 0-7 parameters. All other types have zero. */ |
294 | 295 | ||
295 | param_count = 0; | 296 | param_count = 0; |
296 | if (node->type == ACPI_TYPE_METHOD) { | 297 | if (node->type == ACPI_TYPE_METHOD) { |
297 | param_count = node->object->method.param_count; | 298 | param_count = node->object->method.param_count; |
298 | } | 299 | } |
299 | 300 | ||
300 | if (!predefined) { | 301 | if (!predefined) { |
301 | /* | 302 | /* |
302 | * Check the parameter count for non-predefined methods/objects. | 303 | * Check the parameter count for non-predefined methods/objects. |
303 | * | 304 | * |
304 | * Warning if too few or too many arguments have been passed by the | 305 | * Warning if too few or too many arguments have been passed by the |
305 | * caller. An incorrect number of arguments may not cause the method | 306 | * caller. An incorrect number of arguments may not cause the method |
306 | * to fail. However, the method will fail if there are too few | 307 | * to fail. However, the method will fail if there are too few |
307 | * arguments and the method attempts to use one of the missing ones. | 308 | * arguments and the method attempts to use one of the missing ones. |
308 | */ | 309 | */ |
309 | if (user_param_count < param_count) { | 310 | if (user_param_count < param_count) { |
310 | ACPI_WARN_PREDEFINED((AE_INFO, pathname, | 311 | ACPI_WARN_PREDEFINED((AE_INFO, pathname, |
311 | ACPI_WARN_ALWAYS, | 312 | ACPI_WARN_ALWAYS, |
312 | "Insufficient arguments - needs %u, found %u", | 313 | "Insufficient arguments - needs %u, found %u", |
313 | param_count, user_param_count)); | 314 | param_count, user_param_count)); |
314 | } else if (user_param_count > param_count) { | 315 | } else if (user_param_count > param_count) { |
315 | ACPI_WARN_PREDEFINED((AE_INFO, pathname, | 316 | ACPI_WARN_PREDEFINED((AE_INFO, pathname, |
316 | ACPI_WARN_ALWAYS, | 317 | ACPI_WARN_ALWAYS, |
317 | "Excess arguments - needs %u, found %u", | 318 | "Excess arguments - needs %u, found %u", |
318 | param_count, user_param_count)); | 319 | param_count, user_param_count)); |
319 | } | 320 | } |
320 | return; | 321 | return; |
321 | } | 322 | } |
322 | 323 | ||
323 | /* | 324 | /* |
324 | * Validate the user-supplied parameter count. | 325 | * Validate the user-supplied parameter count. |
325 | * Allow two different legal argument counts (_SCP, etc.) | 326 | * Allow two different legal argument counts (_SCP, etc.) |
326 | */ | 327 | */ |
327 | required_params_current = predefined->info.param_count & 0x0F; | 328 | required_params_current = predefined->info.param_count & 0x0F; |
328 | required_params_old = predefined->info.param_count >> 4; | 329 | required_params_old = predefined->info.param_count >> 4; |
329 | 330 | ||
330 | if (user_param_count != ACPI_UINT32_MAX) { | 331 | if (user_param_count != ACPI_UINT32_MAX) { |
331 | if ((user_param_count != required_params_current) && | 332 | if ((user_param_count != required_params_current) && |
332 | (user_param_count != required_params_old)) { | 333 | (user_param_count != required_params_old)) { |
333 | ACPI_WARN_PREDEFINED((AE_INFO, pathname, | 334 | ACPI_WARN_PREDEFINED((AE_INFO, pathname, |
334 | ACPI_WARN_ALWAYS, | 335 | ACPI_WARN_ALWAYS, |
335 | "Parameter count mismatch - " | 336 | "Parameter count mismatch - " |
336 | "caller passed %u, ACPI requires %u", | 337 | "caller passed %u, ACPI requires %u", |
337 | user_param_count, | 338 | user_param_count, |
338 | required_params_current)); | 339 | required_params_current)); |
339 | } | 340 | } |
340 | } | 341 | } |
341 | 342 | ||
342 | /* | 343 | /* |
343 | * Check that the ASL-defined parameter count is what is expected for | 344 | * Check that the ASL-defined parameter count is what is expected for |
344 | * this predefined name (parameter count as defined by the ACPI | 345 | * this predefined name (parameter count as defined by the ACPI |
345 | * specification) | 346 | * specification) |
346 | */ | 347 | */ |
347 | if ((param_count != required_params_current) && | 348 | if ((param_count != required_params_current) && |
348 | (param_count != required_params_old)) { | 349 | (param_count != required_params_old)) { |
349 | ACPI_WARN_PREDEFINED((AE_INFO, pathname, node->flags, | 350 | ACPI_WARN_PREDEFINED((AE_INFO, pathname, node->flags, |
350 | "Parameter count mismatch - ASL declared %u, ACPI requires %u", | 351 | "Parameter count mismatch - ASL declared %u, ACPI requires %u", |
351 | param_count, required_params_current)); | 352 | param_count, required_params_current)); |
352 | } | 353 | } |
353 | } | 354 | } |
354 | 355 | ||
355 | /******************************************************************************* | 356 | /******************************************************************************* |
356 | * | 357 | * |
357 | * FUNCTION: acpi_ns_check_for_predefined_name | 358 | * FUNCTION: acpi_ns_check_for_predefined_name |
358 | * | 359 | * |
359 | * PARAMETERS: Node - Namespace node for the method/object | 360 | * PARAMETERS: Node - Namespace node for the method/object |
360 | * | 361 | * |
361 | * RETURN: Pointer to entry in predefined table. NULL indicates not found. | 362 | * RETURN: Pointer to entry in predefined table. NULL indicates not found. |
362 | * | 363 | * |
363 | * DESCRIPTION: Check an object name against the predefined object list. | 364 | * DESCRIPTION: Check an object name against the predefined object list. |
364 | * | 365 | * |
365 | ******************************************************************************/ | 366 | ******************************************************************************/ |
366 | 367 | ||
367 | const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct | 368 | const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct |
368 | acpi_namespace_node | 369 | acpi_namespace_node |
369 | *node) | 370 | *node) |
370 | { | 371 | { |
371 | const union acpi_predefined_info *this_name; | 372 | const union acpi_predefined_info *this_name; |
372 | 373 | ||
373 | /* Quick check for a predefined name, first character must be underscore */ | 374 | /* Quick check for a predefined name, first character must be underscore */ |
374 | 375 | ||
375 | if (node->name.ascii[0] != '_') { | 376 | if (node->name.ascii[0] != '_') { |
376 | return (NULL); | 377 | return (NULL); |
377 | } | 378 | } |
378 | 379 | ||
379 | /* Search info table for a predefined method/object name */ | 380 | /* Search info table for a predefined method/object name */ |
380 | 381 | ||
381 | this_name = predefined_names; | 382 | this_name = predefined_names; |
382 | while (this_name->info.name[0]) { | 383 | while (this_name->info.name[0]) { |
383 | if (ACPI_COMPARE_NAME(node->name.ascii, this_name->info.name)) { | 384 | if (ACPI_COMPARE_NAME(node->name.ascii, this_name->info.name)) { |
384 | return (this_name); | 385 | return (this_name); |
385 | } | 386 | } |
386 | 387 | ||
387 | /* | 388 | /* |
388 | * Skip next entry in the table if this name returns a Package | 389 | * Skip next entry in the table if this name returns a Package |
389 | * (next entry contains the package info) | 390 | * (next entry contains the package info) |
390 | */ | 391 | */ |
391 | if (this_name->info.expected_btypes & ACPI_RTYPE_PACKAGE) { | 392 | if (this_name->info.expected_btypes & ACPI_RTYPE_PACKAGE) { |
392 | this_name++; | 393 | this_name++; |
393 | } | 394 | } |
394 | 395 | ||
395 | this_name++; | 396 | this_name++; |
396 | } | 397 | } |
397 | 398 | ||
398 | return (NULL); /* Not found */ | 399 | return (NULL); /* Not found */ |
399 | } | 400 | } |
400 | 401 | ||
401 | /******************************************************************************* | 402 | /******************************************************************************* |
402 | * | 403 | * |
403 | * FUNCTION: acpi_ns_check_package | 404 | * FUNCTION: acpi_ns_check_package |
404 | * | 405 | * |
405 | * PARAMETERS: Data - Pointer to validation data structure | 406 | * PARAMETERS: Data - Pointer to validation data structure |
406 | * return_object_ptr - Pointer to the object returned from the | 407 | * return_object_ptr - Pointer to the object returned from the |
407 | * evaluation of a method or object | 408 | * evaluation of a method or object |
408 | * | 409 | * |
409 | * RETURN: Status | 410 | * RETURN: Status |
410 | * | 411 | * |
411 | * DESCRIPTION: Check a returned package object for the correct count and | 412 | * DESCRIPTION: Check a returned package object for the correct count and |
412 | * correct type of all sub-objects. | 413 | * correct type of all sub-objects. |
413 | * | 414 | * |
414 | ******************************************************************************/ | 415 | ******************************************************************************/ |
415 | 416 | ||
416 | static acpi_status | 417 | static acpi_status |
417 | acpi_ns_check_package(struct acpi_predefined_data *data, | 418 | acpi_ns_check_package(struct acpi_predefined_data *data, |
418 | union acpi_operand_object **return_object_ptr) | 419 | union acpi_operand_object **return_object_ptr) |
419 | { | 420 | { |
420 | union acpi_operand_object *return_object = *return_object_ptr; | 421 | union acpi_operand_object *return_object = *return_object_ptr; |
421 | const union acpi_predefined_info *package; | 422 | const union acpi_predefined_info *package; |
422 | union acpi_operand_object **elements; | 423 | union acpi_operand_object **elements; |
423 | acpi_status status = AE_OK; | 424 | acpi_status status = AE_OK; |
424 | u32 expected_count; | 425 | u32 expected_count; |
425 | u32 count; | 426 | u32 count; |
426 | u32 i; | 427 | u32 i; |
427 | 428 | ||
428 | ACPI_FUNCTION_NAME(ns_check_package); | 429 | ACPI_FUNCTION_NAME(ns_check_package); |
429 | 430 | ||
430 | /* The package info for this name is in the next table entry */ | 431 | /* The package info for this name is in the next table entry */ |
431 | 432 | ||
432 | package = data->predefined + 1; | 433 | package = data->predefined + 1; |
433 | 434 | ||
434 | ACPI_DEBUG_PRINT((ACPI_DB_NAMES, | 435 | ACPI_DEBUG_PRINT((ACPI_DB_NAMES, |
435 | "%s Validating return Package of Type %X, Count %X\n", | 436 | "%s Validating return Package of Type %X, Count %X\n", |
436 | data->pathname, package->ret_info.type, | 437 | data->pathname, package->ret_info.type, |
437 | return_object->package.count)); | 438 | return_object->package.count)); |
438 | 439 | ||
439 | /* | 440 | /* |
440 | * For variable-length Packages, we can safely remove all embedded | 441 | * For variable-length Packages, we can safely remove all embedded |
441 | * and trailing NULL package elements | 442 | * and trailing NULL package elements |
442 | */ | 443 | */ |
443 | acpi_ns_remove_null_elements(data, package->ret_info.type, | 444 | acpi_ns_remove_null_elements(data, package->ret_info.type, |
444 | return_object); | 445 | return_object); |
445 | 446 | ||
446 | /* Extract package count and elements array */ | 447 | /* Extract package count and elements array */ |
447 | 448 | ||
448 | elements = return_object->package.elements; | 449 | elements = return_object->package.elements; |
449 | count = return_object->package.count; | 450 | count = return_object->package.count; |
450 | 451 | ||
451 | /* The package must have at least one element, else invalid */ | 452 | /* The package must have at least one element, else invalid */ |
452 | 453 | ||
453 | if (!count) { | 454 | if (!count) { |
454 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | 455 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, |
455 | "Return Package has no elements (empty)")); | 456 | "Return Package has no elements (empty)")); |
456 | 457 | ||
457 | return (AE_AML_OPERAND_VALUE); | 458 | return (AE_AML_OPERAND_VALUE); |
458 | } | 459 | } |
459 | 460 | ||
460 | /* | 461 | /* |
461 | * Decode the type of the expected package contents | 462 | * Decode the type of the expected package contents |
462 | * | 463 | * |
463 | * PTYPE1 packages contain no subpackages | 464 | * PTYPE1 packages contain no subpackages |
464 | * PTYPE2 packages contain sub-packages | 465 | * PTYPE2 packages contain sub-packages |
465 | */ | 466 | */ |
466 | switch (package->ret_info.type) { | 467 | switch (package->ret_info.type) { |
467 | case ACPI_PTYPE1_FIXED: | 468 | case ACPI_PTYPE1_FIXED: |
468 | 469 | ||
469 | /* | 470 | /* |
470 | * The package count is fixed and there are no sub-packages | 471 | * The package count is fixed and there are no sub-packages |
471 | * | 472 | * |
472 | * If package is too small, exit. | 473 | * If package is too small, exit. |
473 | * If package is larger than expected, issue warning but continue | 474 | * If package is larger than expected, issue warning but continue |
474 | */ | 475 | */ |
475 | expected_count = | 476 | expected_count = |
476 | package->ret_info.count1 + package->ret_info.count2; | 477 | package->ret_info.count1 + package->ret_info.count2; |
477 | if (count < expected_count) { | 478 | if (count < expected_count) { |
478 | goto package_too_small; | 479 | goto package_too_small; |
479 | } else if (count > expected_count) { | 480 | } else if (count > expected_count) { |
480 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, | 481 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, |
481 | "%s: Return Package is larger than needed - " | 482 | "%s: Return Package is larger than needed - " |
482 | "found %u, expected %u\n", | 483 | "found %u, expected %u\n", |
483 | data->pathname, count, | 484 | data->pathname, count, |
484 | expected_count)); | 485 | expected_count)); |
485 | } | 486 | } |
486 | 487 | ||
487 | /* Validate all elements of the returned package */ | 488 | /* Validate all elements of the returned package */ |
488 | 489 | ||
489 | status = acpi_ns_check_package_elements(data, elements, | 490 | status = acpi_ns_check_package_elements(data, elements, |
490 | package->ret_info. | 491 | package->ret_info. |
491 | object_type1, | 492 | object_type1, |
492 | package->ret_info. | 493 | package->ret_info. |
493 | count1, | 494 | count1, |
494 | package->ret_info. | 495 | package->ret_info. |
495 | object_type2, | 496 | object_type2, |
496 | package->ret_info. | 497 | package->ret_info. |
497 | count2, 0); | 498 | count2, 0); |
498 | break; | 499 | break; |
499 | 500 | ||
500 | case ACPI_PTYPE1_VAR: | 501 | case ACPI_PTYPE1_VAR: |
501 | 502 | ||
502 | /* | 503 | /* |
503 | * The package count is variable, there are no sub-packages, and all | 504 | * The package count is variable, there are no sub-packages, and all |
504 | * elements must be of the same type | 505 | * elements must be of the same type |
505 | */ | 506 | */ |
506 | for (i = 0; i < count; i++) { | 507 | for (i = 0; i < count; i++) { |
507 | status = acpi_ns_check_object_type(data, elements, | 508 | status = acpi_ns_check_object_type(data, elements, |
508 | package->ret_info. | 509 | package->ret_info. |
509 | object_type1, i); | 510 | object_type1, i); |
510 | if (ACPI_FAILURE(status)) { | 511 | if (ACPI_FAILURE(status)) { |
511 | return (status); | 512 | return (status); |
512 | } | 513 | } |
513 | elements++; | 514 | elements++; |
514 | } | 515 | } |
515 | break; | 516 | break; |
516 | 517 | ||
517 | case ACPI_PTYPE1_OPTION: | 518 | case ACPI_PTYPE1_OPTION: |
518 | 519 | ||
519 | /* | 520 | /* |
520 | * The package count is variable, there are no sub-packages. There are | 521 | * The package count is variable, there are no sub-packages. There are |
521 | * a fixed number of required elements, and a variable number of | 522 | * a fixed number of required elements, and a variable number of |
522 | * optional elements. | 523 | * optional elements. |
523 | * | 524 | * |
524 | * Check if package is at least as large as the minimum required | 525 | * Check if package is at least as large as the minimum required |
525 | */ | 526 | */ |
526 | expected_count = package->ret_info3.count; | 527 | expected_count = package->ret_info3.count; |
527 | if (count < expected_count) { | 528 | if (count < expected_count) { |
528 | goto package_too_small; | 529 | goto package_too_small; |
529 | } | 530 | } |
530 | 531 | ||
531 | /* Variable number of sub-objects */ | 532 | /* Variable number of sub-objects */ |
532 | 533 | ||
533 | for (i = 0; i < count; i++) { | 534 | for (i = 0; i < count; i++) { |
534 | if (i < package->ret_info3.count) { | 535 | if (i < package->ret_info3.count) { |
535 | 536 | ||
536 | /* These are the required package elements (0, 1, or 2) */ | 537 | /* These are the required package elements (0, 1, or 2) */ |
537 | 538 | ||
538 | status = | 539 | status = |
539 | acpi_ns_check_object_type(data, elements, | 540 | acpi_ns_check_object_type(data, elements, |
540 | package-> | 541 | package-> |
541 | ret_info3. | 542 | ret_info3. |
542 | object_type[i], | 543 | object_type[i], |
543 | i); | 544 | i); |
544 | if (ACPI_FAILURE(status)) { | 545 | if (ACPI_FAILURE(status)) { |
545 | return (status); | 546 | return (status); |
546 | } | 547 | } |
547 | } else { | 548 | } else { |
548 | /* These are the optional package elements */ | 549 | /* These are the optional package elements */ |
549 | 550 | ||
550 | status = | 551 | status = |
551 | acpi_ns_check_object_type(data, elements, | 552 | acpi_ns_check_object_type(data, elements, |
552 | package-> | 553 | package-> |
553 | ret_info3. | 554 | ret_info3. |
554 | tail_object_type, | 555 | tail_object_type, |
555 | i); | 556 | i); |
556 | if (ACPI_FAILURE(status)) { | 557 | if (ACPI_FAILURE(status)) { |
557 | return (status); | 558 | return (status); |
558 | } | 559 | } |
559 | } | 560 | } |
560 | elements++; | 561 | elements++; |
561 | } | 562 | } |
562 | break; | 563 | break; |
563 | 564 | ||
564 | case ACPI_PTYPE2_REV_FIXED: | 565 | case ACPI_PTYPE2_REV_FIXED: |
565 | 566 | ||
566 | /* First element is the (Integer) revision */ | 567 | /* First element is the (Integer) revision */ |
567 | 568 | ||
568 | status = acpi_ns_check_object_type(data, elements, | 569 | status = acpi_ns_check_object_type(data, elements, |
569 | ACPI_RTYPE_INTEGER, 0); | 570 | ACPI_RTYPE_INTEGER, 0); |
570 | if (ACPI_FAILURE(status)) { | 571 | if (ACPI_FAILURE(status)) { |
571 | return (status); | 572 | return (status); |
572 | } | 573 | } |
573 | 574 | ||
574 | elements++; | 575 | elements++; |
575 | count--; | 576 | count--; |
576 | 577 | ||
577 | /* Examine the sub-packages */ | 578 | /* Examine the sub-packages */ |
578 | 579 | ||
579 | status = | 580 | status = |
580 | acpi_ns_check_package_list(data, package, elements, count); | 581 | acpi_ns_check_package_list(data, package, elements, count); |
581 | break; | 582 | break; |
582 | 583 | ||
583 | case ACPI_PTYPE2_PKG_COUNT: | 584 | case ACPI_PTYPE2_PKG_COUNT: |
584 | 585 | ||
585 | /* First element is the (Integer) count of sub-packages to follow */ | 586 | /* First element is the (Integer) count of sub-packages to follow */ |
586 | 587 | ||
587 | status = acpi_ns_check_object_type(data, elements, | 588 | status = acpi_ns_check_object_type(data, elements, |
588 | ACPI_RTYPE_INTEGER, 0); | 589 | ACPI_RTYPE_INTEGER, 0); |
589 | if (ACPI_FAILURE(status)) { | 590 | if (ACPI_FAILURE(status)) { |
590 | return (status); | 591 | return (status); |
591 | } | 592 | } |
592 | 593 | ||
593 | /* | 594 | /* |
594 | * Count cannot be larger than the parent package length, but allow it | 595 | * Count cannot be larger than the parent package length, but allow it |
595 | * to be smaller. The >= accounts for the Integer above. | 596 | * to be smaller. The >= accounts for the Integer above. |
596 | */ | 597 | */ |
597 | expected_count = (u32) (*elements)->integer.value; | 598 | expected_count = (u32) (*elements)->integer.value; |
598 | if (expected_count >= count) { | 599 | if (expected_count >= count) { |
599 | goto package_too_small; | 600 | goto package_too_small; |
600 | } | 601 | } |
601 | 602 | ||
602 | count = expected_count; | 603 | count = expected_count; |
603 | elements++; | 604 | elements++; |
604 | 605 | ||
605 | /* Examine the sub-packages */ | 606 | /* Examine the sub-packages */ |
606 | 607 | ||
607 | status = | 608 | status = |
608 | acpi_ns_check_package_list(data, package, elements, count); | 609 | acpi_ns_check_package_list(data, package, elements, count); |
609 | break; | 610 | break; |
610 | 611 | ||
611 | case ACPI_PTYPE2: | 612 | case ACPI_PTYPE2: |
612 | case ACPI_PTYPE2_FIXED: | 613 | case ACPI_PTYPE2_FIXED: |
613 | case ACPI_PTYPE2_MIN: | 614 | case ACPI_PTYPE2_MIN: |
614 | case ACPI_PTYPE2_COUNT: | 615 | case ACPI_PTYPE2_COUNT: |
615 | 616 | ||
616 | /* | 617 | /* |
617 | * These types all return a single Package that consists of a | 618 | * These types all return a single Package that consists of a |
618 | * variable number of sub-Packages. | 619 | * variable number of sub-Packages. |
619 | * | 620 | * |
620 | * First, ensure that the first element is a sub-Package. If not, | 621 | * First, ensure that the first element is a sub-Package. If not, |
621 | * the BIOS may have incorrectly returned the object as a single | 622 | * the BIOS may have incorrectly returned the object as a single |
622 | * package instead of a Package of Packages (a common error if | 623 | * package instead of a Package of Packages (a common error if |
623 | * there is only one entry). We may be able to repair this by | 624 | * there is only one entry). We may be able to repair this by |
624 | * wrapping the returned Package with a new outer Package. | 625 | * wrapping the returned Package with a new outer Package. |
625 | */ | 626 | */ |
626 | if (*elements | 627 | if (*elements |
627 | && ((*elements)->common.type != ACPI_TYPE_PACKAGE)) { | 628 | && ((*elements)->common.type != ACPI_TYPE_PACKAGE)) { |
628 | 629 | ||
629 | /* Create the new outer package and populate it */ | 630 | /* Create the new outer package and populate it */ |
630 | 631 | ||
631 | status = | 632 | status = |
632 | acpi_ns_repair_package_list(data, | 633 | acpi_ns_repair_package_list(data, |
633 | return_object_ptr); | 634 | return_object_ptr); |
634 | if (ACPI_FAILURE(status)) { | 635 | if (ACPI_FAILURE(status)) { |
635 | return (status); | 636 | return (status); |
636 | } | 637 | } |
637 | 638 | ||
638 | /* Update locals to point to the new package (of 1 element) */ | 639 | /* Update locals to point to the new package (of 1 element) */ |
639 | 640 | ||
640 | return_object = *return_object_ptr; | 641 | return_object = *return_object_ptr; |
641 | elements = return_object->package.elements; | 642 | elements = return_object->package.elements; |
642 | count = 1; | 643 | count = 1; |
643 | } | 644 | } |
644 | 645 | ||
645 | /* Examine the sub-packages */ | 646 | /* Examine the sub-packages */ |
646 | 647 | ||
647 | status = | 648 | status = |
648 | acpi_ns_check_package_list(data, package, elements, count); | 649 | acpi_ns_check_package_list(data, package, elements, count); |
649 | break; | 650 | break; |
650 | 651 | ||
651 | default: | 652 | default: |
652 | 653 | ||
653 | /* Should not get here if predefined info table is correct */ | 654 | /* Should not get here if predefined info table is correct */ |
654 | 655 | ||
655 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | 656 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, |
656 | "Invalid internal return type in table entry: %X", | 657 | "Invalid internal return type in table entry: %X", |
657 | package->ret_info.type)); | 658 | package->ret_info.type)); |
658 | 659 | ||
659 | return (AE_AML_INTERNAL); | 660 | return (AE_AML_INTERNAL); |
660 | } | 661 | } |
661 | 662 | ||
662 | return (status); | 663 | return (status); |
663 | 664 | ||
664 | package_too_small: | 665 | package_too_small: |
665 | 666 | ||
666 | /* Error exit for the case with an incorrect package count */ | 667 | /* Error exit for the case with an incorrect package count */ |
667 | 668 | ||
668 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | 669 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, |
669 | "Return Package is too small - found %u elements, expected %u", | 670 | "Return Package is too small - found %u elements, expected %u", |
670 | count, expected_count)); | 671 | count, expected_count)); |
671 | 672 | ||
672 | return (AE_AML_OPERAND_VALUE); | 673 | return (AE_AML_OPERAND_VALUE); |
673 | } | 674 | } |
674 | 675 | ||
675 | /******************************************************************************* | 676 | /******************************************************************************* |
676 | * | 677 | * |
677 | * FUNCTION: acpi_ns_check_package_list | 678 | * FUNCTION: acpi_ns_check_package_list |
678 | * | 679 | * |
679 | * PARAMETERS: Data - Pointer to validation data structure | 680 | * PARAMETERS: Data - Pointer to validation data structure |
680 | * Package - Pointer to package-specific info for method | 681 | * Package - Pointer to package-specific info for method |
681 | * Elements - Element list of parent package. All elements | 682 | * Elements - Element list of parent package. All elements |
682 | * of this list should be of type Package. | 683 | * of this list should be of type Package. |
683 | * Count - Count of subpackages | 684 | * Count - Count of subpackages |
684 | * | 685 | * |
685 | * RETURN: Status | 686 | * RETURN: Status |
686 | * | 687 | * |
687 | * DESCRIPTION: Examine a list of subpackages | 688 | * DESCRIPTION: Examine a list of subpackages |
688 | * | 689 | * |
689 | ******************************************************************************/ | 690 | ******************************************************************************/ |
690 | 691 | ||
691 | static acpi_status | 692 | static acpi_status |
692 | acpi_ns_check_package_list(struct acpi_predefined_data *data, | 693 | acpi_ns_check_package_list(struct acpi_predefined_data *data, |
693 | const union acpi_predefined_info *package, | 694 | const union acpi_predefined_info *package, |
694 | union acpi_operand_object **elements, u32 count) | 695 | union acpi_operand_object **elements, u32 count) |
695 | { | 696 | { |
696 | union acpi_operand_object *sub_package; | 697 | union acpi_operand_object *sub_package; |
697 | union acpi_operand_object **sub_elements; | 698 | union acpi_operand_object **sub_elements; |
698 | acpi_status status; | 699 | acpi_status status; |
699 | u32 expected_count; | 700 | u32 expected_count; |
700 | u32 i; | 701 | u32 i; |
701 | u32 j; | 702 | u32 j; |
702 | 703 | ||
703 | /* | 704 | /* |
704 | * Validate each sub-Package in the parent Package | 705 | * Validate each sub-Package in the parent Package |
705 | * | 706 | * |
706 | * NOTE: assumes list of sub-packages contains no NULL elements. | 707 | * NOTE: assumes list of sub-packages contains no NULL elements. |
707 | * Any NULL elements should have been removed by earlier call | 708 | * Any NULL elements should have been removed by earlier call |
708 | * to acpi_ns_remove_null_elements. | 709 | * to acpi_ns_remove_null_elements. |
709 | */ | 710 | */ |
710 | for (i = 0; i < count; i++) { | 711 | for (i = 0; i < count; i++) { |
711 | sub_package = *elements; | 712 | sub_package = *elements; |
712 | sub_elements = sub_package->package.elements; | 713 | sub_elements = sub_package->package.elements; |
714 | data->parent_package = sub_package; | ||
713 | 715 | ||
714 | /* Each sub-object must be of type Package */ | 716 | /* Each sub-object must be of type Package */ |
715 | 717 | ||
716 | status = acpi_ns_check_object_type(data, &sub_package, | 718 | status = acpi_ns_check_object_type(data, &sub_package, |
717 | ACPI_RTYPE_PACKAGE, i); | 719 | ACPI_RTYPE_PACKAGE, i); |
718 | if (ACPI_FAILURE(status)) { | 720 | if (ACPI_FAILURE(status)) { |
719 | return (status); | 721 | return (status); |
720 | } | 722 | } |
721 | 723 | ||
722 | /* Examine the different types of expected sub-packages */ | 724 | /* Examine the different types of expected sub-packages */ |
723 | 725 | ||
726 | data->parent_package = sub_package; | ||
724 | switch (package->ret_info.type) { | 727 | switch (package->ret_info.type) { |
725 | case ACPI_PTYPE2: | 728 | case ACPI_PTYPE2: |
726 | case ACPI_PTYPE2_PKG_COUNT: | 729 | case ACPI_PTYPE2_PKG_COUNT: |
727 | case ACPI_PTYPE2_REV_FIXED: | 730 | case ACPI_PTYPE2_REV_FIXED: |
728 | 731 | ||
729 | /* Each subpackage has a fixed number of elements */ | 732 | /* Each subpackage has a fixed number of elements */ |
730 | 733 | ||
731 | expected_count = | 734 | expected_count = |
732 | package->ret_info.count1 + package->ret_info.count2; | 735 | package->ret_info.count1 + package->ret_info.count2; |
733 | if (sub_package->package.count < expected_count) { | 736 | if (sub_package->package.count < expected_count) { |
734 | goto package_too_small; | 737 | goto package_too_small; |
735 | } | 738 | } |
736 | 739 | ||
737 | status = | 740 | status = |
738 | acpi_ns_check_package_elements(data, sub_elements, | 741 | acpi_ns_check_package_elements(data, sub_elements, |
739 | package->ret_info. | 742 | package->ret_info. |
740 | object_type1, | 743 | object_type1, |
741 | package->ret_info. | 744 | package->ret_info. |
742 | count1, | 745 | count1, |
743 | package->ret_info. | 746 | package->ret_info. |
744 | object_type2, | 747 | object_type2, |
745 | package->ret_info. | 748 | package->ret_info. |
746 | count2, 0); | 749 | count2, 0); |
747 | if (ACPI_FAILURE(status)) { | 750 | if (ACPI_FAILURE(status)) { |
748 | return (status); | 751 | return (status); |
749 | } | 752 | } |
750 | break; | 753 | break; |
751 | 754 | ||
752 | case ACPI_PTYPE2_FIXED: | 755 | case ACPI_PTYPE2_FIXED: |
753 | 756 | ||
754 | /* Each sub-package has a fixed length */ | 757 | /* Each sub-package has a fixed length */ |
755 | 758 | ||
756 | expected_count = package->ret_info2.count; | 759 | expected_count = package->ret_info2.count; |
757 | if (sub_package->package.count < expected_count) { | 760 | if (sub_package->package.count < expected_count) { |
758 | goto package_too_small; | 761 | goto package_too_small; |
759 | } | 762 | } |
760 | 763 | ||
761 | /* Check the type of each sub-package element */ | 764 | /* Check the type of each sub-package element */ |
762 | 765 | ||
763 | for (j = 0; j < expected_count; j++) { | 766 | for (j = 0; j < expected_count; j++) { |
764 | status = | 767 | status = |
765 | acpi_ns_check_object_type(data, | 768 | acpi_ns_check_object_type(data, |
766 | &sub_elements[j], | 769 | &sub_elements[j], |
767 | package-> | 770 | package-> |
768 | ret_info2. | 771 | ret_info2. |
769 | object_type[j], | 772 | object_type[j], |
770 | j); | 773 | j); |
771 | if (ACPI_FAILURE(status)) { | 774 | if (ACPI_FAILURE(status)) { |
772 | return (status); | 775 | return (status); |
773 | } | 776 | } |
774 | } | 777 | } |
775 | break; | 778 | break; |
776 | 779 | ||
777 | case ACPI_PTYPE2_MIN: | 780 | case ACPI_PTYPE2_MIN: |
778 | 781 | ||
779 | /* Each sub-package has a variable but minimum length */ | 782 | /* Each sub-package has a variable but minimum length */ |
780 | 783 | ||
781 | expected_count = package->ret_info.count1; | 784 | expected_count = package->ret_info.count1; |
782 | if (sub_package->package.count < expected_count) { | 785 | if (sub_package->package.count < expected_count) { |
783 | goto package_too_small; | 786 | goto package_too_small; |
784 | } | 787 | } |
785 | 788 | ||
786 | /* Check the type of each sub-package element */ | 789 | /* Check the type of each sub-package element */ |
787 | 790 | ||
788 | status = | 791 | status = |
789 | acpi_ns_check_package_elements(data, sub_elements, | 792 | acpi_ns_check_package_elements(data, sub_elements, |
790 | package->ret_info. | 793 | package->ret_info. |
791 | object_type1, | 794 | object_type1, |
792 | sub_package->package. | 795 | sub_package->package. |
793 | count, 0, 0, 0); | 796 | count, 0, 0, 0); |
794 | if (ACPI_FAILURE(status)) { | 797 | if (ACPI_FAILURE(status)) { |
795 | return (status); | 798 | return (status); |
796 | } | 799 | } |
797 | break; | 800 | break; |
798 | 801 | ||
799 | case ACPI_PTYPE2_COUNT: | 802 | case ACPI_PTYPE2_COUNT: |
800 | 803 | ||
801 | /* | 804 | /* |
802 | * First element is the (Integer) count of elements, including | 805 | * First element is the (Integer) count of elements, including |
803 | * the count field. | 806 | * the count field (the ACPI name is num_elements) |
804 | */ | 807 | */ |
805 | status = acpi_ns_check_object_type(data, sub_elements, | 808 | status = acpi_ns_check_object_type(data, sub_elements, |
806 | ACPI_RTYPE_INTEGER, | 809 | ACPI_RTYPE_INTEGER, |
807 | 0); | 810 | 0); |
808 | if (ACPI_FAILURE(status)) { | 811 | if (ACPI_FAILURE(status)) { |
809 | return (status); | 812 | return (status); |
810 | } | 813 | } |
811 | 814 | ||
812 | /* | 815 | /* |
813 | * Make sure package is large enough for the Count and is | 816 | * Make sure package is large enough for the Count and is |
814 | * is as large as the minimum size | 817 | * is as large as the minimum size |
815 | */ | 818 | */ |
816 | expected_count = (u32)(*sub_elements)->integer.value; | 819 | expected_count = (u32)(*sub_elements)->integer.value; |
817 | if (sub_package->package.count < expected_count) { | 820 | if (sub_package->package.count < expected_count) { |
818 | goto package_too_small; | 821 | goto package_too_small; |
819 | } | 822 | } |
820 | if (sub_package->package.count < | 823 | if (sub_package->package.count < |
821 | package->ret_info.count1) { | 824 | package->ret_info.count1) { |
822 | expected_count = package->ret_info.count1; | 825 | expected_count = package->ret_info.count1; |
823 | goto package_too_small; | 826 | goto package_too_small; |
824 | } | 827 | } |
828 | if (expected_count == 0) { | ||
829 | /* | ||
830 | * Either the num_entries element was originally zero or it was | ||
831 | * a NULL element and repaired to an Integer of value zero. | ||
832 | * In either case, repair it by setting num_entries to be the | ||
833 | * actual size of the subpackage. | ||
834 | */ | ||
835 | expected_count = sub_package->package.count; | ||
836 | (*sub_elements)->integer.value = expected_count; | ||
837 | } | ||
825 | 838 | ||
826 | /* Check the type of each sub-package element */ | 839 | /* Check the type of each sub-package element */ |
827 | 840 | ||
828 | status = | 841 | status = |
829 | acpi_ns_check_package_elements(data, | 842 | acpi_ns_check_package_elements(data, |
830 | (sub_elements + 1), | 843 | (sub_elements + 1), |
831 | package->ret_info. | 844 | package->ret_info. |
832 | object_type1, | 845 | object_type1, |
833 | (expected_count - 1), | 846 | (expected_count - 1), |
834 | 0, 0, 1); | 847 | 0, 0, 1); |
835 | if (ACPI_FAILURE(status)) { | 848 | if (ACPI_FAILURE(status)) { |
836 | return (status); | 849 | return (status); |
837 | } | 850 | } |
838 | break; | 851 | break; |
839 | 852 | ||
840 | default: /* Should not get here, type was validated by caller */ | 853 | default: /* Should not get here, type was validated by caller */ |
841 | 854 | ||
842 | return (AE_AML_INTERNAL); | 855 | return (AE_AML_INTERNAL); |
843 | } | 856 | } |
844 | 857 | ||
845 | elements++; | 858 | elements++; |
846 | } | 859 | } |
847 | 860 | ||
848 | return (AE_OK); | 861 | return (AE_OK); |
849 | 862 | ||
850 | package_too_small: | 863 | package_too_small: |
851 | 864 | ||
852 | /* The sub-package count was smaller than required */ | 865 | /* The sub-package count was smaller than required */ |
853 | 866 | ||
854 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | 867 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, |
855 | "Return Sub-Package[%u] is too small - found %u elements, expected %u", | 868 | "Return Sub-Package[%u] is too small - found %u elements, expected %u", |
856 | i, sub_package->package.count, expected_count)); | 869 | i, sub_package->package.count, expected_count)); |
857 | 870 | ||
858 | return (AE_AML_OPERAND_VALUE); | 871 | return (AE_AML_OPERAND_VALUE); |
859 | } | 872 | } |
860 | 873 | ||
861 | /******************************************************************************* | 874 | /******************************************************************************* |
862 | * | 875 | * |
863 | * FUNCTION: acpi_ns_check_package_elements | 876 | * FUNCTION: acpi_ns_check_package_elements |
864 | * | 877 | * |
865 | * PARAMETERS: Data - Pointer to validation data structure | 878 | * PARAMETERS: Data - Pointer to validation data structure |
866 | * Elements - Pointer to the package elements array | 879 | * Elements - Pointer to the package elements array |
867 | * Type1 - Object type for first group | 880 | * Type1 - Object type for first group |
868 | * Count1 - Count for first group | 881 | * Count1 - Count for first group |
869 | * Type2 - Object type for second group | 882 | * Type2 - Object type for second group |
870 | * Count2 - Count for second group | 883 | * Count2 - Count for second group |
871 | * start_index - Start of the first group of elements | 884 | * start_index - Start of the first group of elements |
872 | * | 885 | * |
873 | * RETURN: Status | 886 | * RETURN: Status |
874 | * | 887 | * |
875 | * DESCRIPTION: Check that all elements of a package are of the correct object | 888 | * DESCRIPTION: Check that all elements of a package are of the correct object |
876 | * type. Supports up to two groups of different object types. | 889 | * type. Supports up to two groups of different object types. |
877 | * | 890 | * |
878 | ******************************************************************************/ | 891 | ******************************************************************************/ |
879 | 892 | ||
880 | static acpi_status | 893 | static acpi_status |
881 | acpi_ns_check_package_elements(struct acpi_predefined_data *data, | 894 | acpi_ns_check_package_elements(struct acpi_predefined_data *data, |
882 | union acpi_operand_object **elements, | 895 | union acpi_operand_object **elements, |
883 | u8 type1, | 896 | u8 type1, |
884 | u32 count1, | 897 | u32 count1, |
885 | u8 type2, u32 count2, u32 start_index) | 898 | u8 type2, u32 count2, u32 start_index) |
886 | { | 899 | { |
887 | union acpi_operand_object **this_element = elements; | 900 | union acpi_operand_object **this_element = elements; |
888 | acpi_status status; | 901 | acpi_status status; |
889 | u32 i; | 902 | u32 i; |
890 | 903 | ||
891 | /* | 904 | /* |
892 | * Up to two groups of package elements are supported by the data | 905 | * Up to two groups of package elements are supported by the data |
893 | * structure. All elements in each group must be of the same type. | 906 | * structure. All elements in each group must be of the same type. |
894 | * The second group can have a count of zero. | 907 | * The second group can have a count of zero. |
895 | */ | 908 | */ |
896 | for (i = 0; i < count1; i++) { | 909 | for (i = 0; i < count1; i++) { |
897 | status = acpi_ns_check_object_type(data, this_element, | 910 | status = acpi_ns_check_object_type(data, this_element, |
898 | type1, i + start_index); | 911 | type1, i + start_index); |
899 | if (ACPI_FAILURE(status)) { | 912 | if (ACPI_FAILURE(status)) { |
900 | return (status); | 913 | return (status); |
901 | } | 914 | } |
902 | this_element++; | 915 | this_element++; |
903 | } | 916 | } |
904 | 917 | ||
905 | for (i = 0; i < count2; i++) { | 918 | for (i = 0; i < count2; i++) { |
906 | status = acpi_ns_check_object_type(data, this_element, | 919 | status = acpi_ns_check_object_type(data, this_element, |
907 | type2, | 920 | type2, |
908 | (i + count1 + start_index)); | 921 | (i + count1 + start_index)); |
909 | if (ACPI_FAILURE(status)) { | 922 | if (ACPI_FAILURE(status)) { |
910 | return (status); | 923 | return (status); |
911 | } | 924 | } |
912 | this_element++; | 925 | this_element++; |
913 | } | 926 | } |
914 | 927 | ||
915 | return (AE_OK); | 928 | return (AE_OK); |
916 | } | 929 | } |
917 | 930 | ||
918 | /******************************************************************************* | 931 | /******************************************************************************* |
919 | * | 932 | * |
920 | * FUNCTION: acpi_ns_check_object_type | 933 | * FUNCTION: acpi_ns_check_object_type |
921 | * | 934 | * |
922 | * PARAMETERS: Data - Pointer to validation data structure | 935 | * PARAMETERS: Data - Pointer to validation data structure |
923 | * return_object_ptr - Pointer to the object returned from the | 936 | * return_object_ptr - Pointer to the object returned from the |
924 | * evaluation of a method or object | 937 | * evaluation of a method or object |
925 | * expected_btypes - Bitmap of expected return type(s) | 938 | * expected_btypes - Bitmap of expected return type(s) |
926 | * package_index - Index of object within parent package (if | 939 | * package_index - Index of object within parent package (if |
927 | * applicable - ACPI_NOT_PACKAGE_ELEMENT | 940 | * applicable - ACPI_NOT_PACKAGE_ELEMENT |
928 | * otherwise) | 941 | * otherwise) |
929 | * | 942 | * |
930 | * RETURN: Status | 943 | * RETURN: Status |
931 | * | 944 | * |
932 | * DESCRIPTION: Check the type of the return object against the expected object | 945 | * DESCRIPTION: Check the type of the return object against the expected object |
933 | * type(s). Use of Btype allows multiple expected object types. | 946 | * type(s). Use of Btype allows multiple expected object types. |
934 | * | 947 | * |
935 | ******************************************************************************/ | 948 | ******************************************************************************/ |
936 | 949 | ||
937 | static acpi_status | 950 | static acpi_status |
938 | acpi_ns_check_object_type(struct acpi_predefined_data *data, | 951 | acpi_ns_check_object_type(struct acpi_predefined_data *data, |
939 | union acpi_operand_object **return_object_ptr, | 952 | union acpi_operand_object **return_object_ptr, |
940 | u32 expected_btypes, u32 package_index) | 953 | u32 expected_btypes, u32 package_index) |
941 | { | 954 | { |
942 | union acpi_operand_object *return_object = *return_object_ptr; | 955 | union acpi_operand_object *return_object = *return_object_ptr; |
943 | acpi_status status = AE_OK; | 956 | acpi_status status = AE_OK; |
944 | u32 return_btype; | 957 | u32 return_btype; |
945 | char type_buffer[48]; /* Room for 5 types */ | 958 | char type_buffer[48]; /* Room for 5 types */ |
946 | 959 | ||
947 | /* | 960 | /* |
948 | * If we get a NULL return_object here, it is a NULL package element, | 961 | * If we get a NULL return_object here, it is a NULL package element. |
949 | * and this is always an error. | 962 | * Since all extraneous NULL package elements were removed earlier by a |
963 | * call to acpi_ns_remove_null_elements, this is an unexpected NULL element. | ||
964 | * We will attempt to repair it. | ||
950 | */ | 965 | */ |
951 | if (!return_object) { | 966 | if (!return_object) { |
967 | status = acpi_ns_repair_null_element(data, expected_btypes, | ||
968 | package_index, | ||
969 | return_object_ptr); | ||
970 | if (ACPI_SUCCESS(status)) { | ||
971 | return (AE_OK); /* Repair was successful */ | ||
972 | } | ||
952 | goto type_error_exit; | 973 | goto type_error_exit; |
953 | } | 974 | } |
954 | 975 | ||
955 | /* A Namespace node should not get here, but make sure */ | 976 | /* A Namespace node should not get here, but make sure */ |
956 | 977 | ||
957 | if (ACPI_GET_DESCRIPTOR_TYPE(return_object) == ACPI_DESC_TYPE_NAMED) { | 978 | if (ACPI_GET_DESCRIPTOR_TYPE(return_object) == ACPI_DESC_TYPE_NAMED) { |
958 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | 979 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, |
959 | "Invalid return type - Found a Namespace node [%4.4s] type %s", | 980 | "Invalid return type - Found a Namespace node [%4.4s] type %s", |
960 | return_object->node.name.ascii, | 981 | return_object->node.name.ascii, |
961 | acpi_ut_get_type_name(return_object->node. | 982 | acpi_ut_get_type_name(return_object->node. |
962 | type))); | 983 | type))); |
963 | return (AE_AML_OPERAND_TYPE); | 984 | return (AE_AML_OPERAND_TYPE); |
964 | } | 985 | } |
965 | 986 | ||
966 | /* | 987 | /* |
967 | * Convert the object type (ACPI_TYPE_xxx) to a bitmapped object type. | 988 | * Convert the object type (ACPI_TYPE_xxx) to a bitmapped object type. |
968 | * The bitmapped type allows multiple possible return types. | 989 | * The bitmapped type allows multiple possible return types. |
969 | * | 990 | * |
970 | * Note, the cases below must handle all of the possible types returned | 991 | * Note, the cases below must handle all of the possible types returned |
971 | * from all of the predefined names (including elements of returned | 992 | * from all of the predefined names (including elements of returned |
972 | * packages) | 993 | * packages) |
973 | */ | 994 | */ |
974 | switch (return_object->common.type) { | 995 | switch (return_object->common.type) { |
975 | case ACPI_TYPE_INTEGER: | 996 | case ACPI_TYPE_INTEGER: |
976 | return_btype = ACPI_RTYPE_INTEGER; | 997 | return_btype = ACPI_RTYPE_INTEGER; |
977 | break; | 998 | break; |
978 | 999 | ||
979 | case ACPI_TYPE_BUFFER: | 1000 | case ACPI_TYPE_BUFFER: |
980 | return_btype = ACPI_RTYPE_BUFFER; | 1001 | return_btype = ACPI_RTYPE_BUFFER; |
981 | break; | 1002 | break; |
982 | 1003 | ||
983 | case ACPI_TYPE_STRING: | 1004 | case ACPI_TYPE_STRING: |
984 | return_btype = ACPI_RTYPE_STRING; | 1005 | return_btype = ACPI_RTYPE_STRING; |
985 | break; | 1006 | break; |
986 | 1007 | ||
987 | case ACPI_TYPE_PACKAGE: | 1008 | case ACPI_TYPE_PACKAGE: |
988 | return_btype = ACPI_RTYPE_PACKAGE; | 1009 | return_btype = ACPI_RTYPE_PACKAGE; |
989 | break; | 1010 | break; |
990 | 1011 | ||
991 | case ACPI_TYPE_LOCAL_REFERENCE: | 1012 | case ACPI_TYPE_LOCAL_REFERENCE: |
992 | return_btype = ACPI_RTYPE_REFERENCE; | 1013 | return_btype = ACPI_RTYPE_REFERENCE; |
993 | break; | 1014 | break; |
994 | 1015 | ||
995 | default: | 1016 | default: |
996 | /* Not one of the supported objects, must be incorrect */ | 1017 | /* Not one of the supported objects, must be incorrect */ |
997 | 1018 | ||
998 | goto type_error_exit; | 1019 | goto type_error_exit; |
999 | } | 1020 | } |
1000 | 1021 | ||
1001 | /* Is the object one of the expected types? */ | 1022 | /* Is the object one of the expected types? */ |
1002 | 1023 | ||
1003 | if (return_btype & expected_btypes) { | 1024 | if (return_btype & expected_btypes) { |
1004 | 1025 | ||
1005 | /* For reference objects, check that the reference type is correct */ | 1026 | /* For reference objects, check that the reference type is correct */ |
1006 | 1027 | ||
1007 | if (return_object->common.type == ACPI_TYPE_LOCAL_REFERENCE) { | 1028 | if (return_object->common.type == ACPI_TYPE_LOCAL_REFERENCE) { |
1008 | status = acpi_ns_check_reference(data, return_object); | 1029 | status = acpi_ns_check_reference(data, return_object); |
1009 | } | 1030 | } |
1010 | 1031 | ||
1011 | return (status); | 1032 | return (status); |
1012 | } | 1033 | } |
1013 | 1034 | ||
1014 | /* Type mismatch -- attempt repair of the returned object */ | 1035 | /* Type mismatch -- attempt repair of the returned object */ |
1015 | 1036 | ||
1016 | status = acpi_ns_repair_object(data, expected_btypes, | 1037 | status = acpi_ns_repair_object(data, expected_btypes, |
1017 | package_index, return_object_ptr); | 1038 | package_index, return_object_ptr); |
1018 | if (ACPI_SUCCESS(status)) { | 1039 | if (ACPI_SUCCESS(status)) { |
1019 | return (AE_OK); /* Repair was successful */ | 1040 | return (AE_OK); /* Repair was successful */ |
1020 | } | 1041 | } |
1021 | 1042 | ||
1022 | type_error_exit: | 1043 | type_error_exit: |
1023 | 1044 | ||
1024 | /* Create a string with all expected types for this predefined object */ | 1045 | /* Create a string with all expected types for this predefined object */ |
1025 | 1046 | ||
1026 | acpi_ns_get_expected_types(type_buffer, expected_btypes); | 1047 | acpi_ns_get_expected_types(type_buffer, expected_btypes); |
1027 | 1048 | ||
1028 | if (package_index == ACPI_NOT_PACKAGE_ELEMENT) { | 1049 | if (package_index == ACPI_NOT_PACKAGE_ELEMENT) { |
1029 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | 1050 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, |
1030 | "Return type mismatch - found %s, expected %s", | 1051 | "Return type mismatch - found %s, expected %s", |
1031 | acpi_ut_get_object_type_name | 1052 | acpi_ut_get_object_type_name |
1032 | (return_object), type_buffer)); | 1053 | (return_object), type_buffer)); |
1033 | } else { | 1054 | } else { |
1034 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | 1055 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, |
1035 | "Return Package type mismatch at index %u - " | 1056 | "Return Package type mismatch at index %u - " |
1036 | "found %s, expected %s", package_index, | 1057 | "found %s, expected %s", package_index, |
1037 | acpi_ut_get_object_type_name | 1058 | acpi_ut_get_object_type_name |
1038 | (return_object), type_buffer)); | 1059 | (return_object), type_buffer)); |
1039 | } | 1060 | } |
1040 | 1061 | ||
1041 | return (AE_AML_OPERAND_TYPE); | 1062 | return (AE_AML_OPERAND_TYPE); |
1042 | } | 1063 | } |
1043 | 1064 | ||
1044 | /******************************************************************************* | 1065 | /******************************************************************************* |
1045 | * | 1066 | * |
1046 | * FUNCTION: acpi_ns_check_reference | 1067 | * FUNCTION: acpi_ns_check_reference |
1047 | * | 1068 | * |
1048 | * PARAMETERS: Data - Pointer to validation data structure | 1069 | * PARAMETERS: Data - Pointer to validation data structure |
1049 | * return_object - Object returned from the evaluation of a | 1070 | * return_object - Object returned from the evaluation of a |
1050 | * method or object | 1071 | * method or object |
1051 | * | 1072 | * |
1052 | * RETURN: Status | 1073 | * RETURN: Status |
1053 | * | 1074 | * |
1054 | * DESCRIPTION: Check a returned reference object for the correct reference | 1075 | * DESCRIPTION: Check a returned reference object for the correct reference |
1055 | * type. The only reference type that can be returned from a | 1076 | * type. The only reference type that can be returned from a |
1056 | * predefined method is a named reference. All others are invalid. | 1077 | * predefined method is a named reference. All others are invalid. |
1057 | * | 1078 | * |
1058 | ******************************************************************************/ | 1079 | ******************************************************************************/ |
1059 | 1080 | ||
1060 | static acpi_status | 1081 | static acpi_status |
1061 | acpi_ns_check_reference(struct acpi_predefined_data *data, | 1082 | acpi_ns_check_reference(struct acpi_predefined_data *data, |
1062 | union acpi_operand_object *return_object) | 1083 | union acpi_operand_object *return_object) |
1063 | { | 1084 | { |
1064 | 1085 | ||
1065 | /* | 1086 | /* |
1066 | * Check the reference object for the correct reference type (opcode). | 1087 | * Check the reference object for the correct reference type (opcode). |
1067 | * The only type of reference that can be converted to an union acpi_object is | 1088 | * The only type of reference that can be converted to an union acpi_object is |
1068 | * a reference to a named object (reference class: NAME) | 1089 | * a reference to a named object (reference class: NAME) |
1069 | */ | 1090 | */ |
1070 | if (return_object->reference.class == ACPI_REFCLASS_NAME) { | 1091 | if (return_object->reference.class == ACPI_REFCLASS_NAME) { |
1071 | return (AE_OK); | 1092 | return (AE_OK); |
1072 | } | 1093 | } |
1073 | 1094 | ||
1074 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | 1095 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, |
1075 | "Return type mismatch - unexpected reference object type [%s] %2.2X", | 1096 | "Return type mismatch - unexpected reference object type [%s] %2.2X", |
1076 | acpi_ut_get_reference_name(return_object), | 1097 | acpi_ut_get_reference_name(return_object), |
1077 | return_object->reference.class)); | 1098 | return_object->reference.class)); |
1078 | 1099 | ||
1079 | return (AE_AML_OPERAND_TYPE); | 1100 | return (AE_AML_OPERAND_TYPE); |
1080 | } | 1101 | } |
1081 | 1102 | ||
1082 | /******************************************************************************* | 1103 | /******************************************************************************* |
1083 | * | 1104 | * |
1084 | * FUNCTION: acpi_ns_get_expected_types | 1105 | * FUNCTION: acpi_ns_get_expected_types |
1085 | * | 1106 | * |
1086 | * PARAMETERS: Buffer - Pointer to where the string is returned | 1107 | * PARAMETERS: Buffer - Pointer to where the string is returned |
1087 | * expected_btypes - Bitmap of expected return type(s) | 1108 | * expected_btypes - Bitmap of expected return type(s) |
1088 | * | 1109 | * |
1089 | * RETURN: Buffer is populated with type names. | 1110 | * RETURN: Buffer is populated with type names. |
1090 | * | 1111 | * |
1091 | * DESCRIPTION: Translate the expected types bitmap into a string of ascii | 1112 | * DESCRIPTION: Translate the expected types bitmap into a string of ascii |
1092 | * names of expected types, for use in warning messages. | 1113 | * names of expected types, for use in warning messages. |
1093 | * | 1114 | * |
1094 | ******************************************************************************/ | 1115 | ******************************************************************************/ |
1095 | 1116 | ||
1096 | static void acpi_ns_get_expected_types(char *buffer, u32 expected_btypes) | 1117 | static void acpi_ns_get_expected_types(char *buffer, u32 expected_btypes) |
1097 | { | 1118 | { |
1098 | u32 this_rtype; | 1119 | u32 this_rtype; |
1099 | u32 i; | 1120 | u32 i; |
1100 | u32 j; | 1121 | u32 j; |
1101 | 1122 | ||
1102 | j = 1; | 1123 | j = 1; |
1103 | buffer[0] = 0; | 1124 | buffer[0] = 0; |
1104 | this_rtype = ACPI_RTYPE_INTEGER; | 1125 | this_rtype = ACPI_RTYPE_INTEGER; |
1105 | 1126 | ||
1106 | for (i = 0; i < ACPI_NUM_RTYPES; i++) { | 1127 | for (i = 0; i < ACPI_NUM_RTYPES; i++) { |
1107 | 1128 | ||
1108 | /* If one of the expected types, concatenate the name of this type */ | 1129 | /* If one of the expected types, concatenate the name of this type */ |
1109 | 1130 | ||
1110 | if (expected_btypes & this_rtype) { | 1131 | if (expected_btypes & this_rtype) { |
1111 | ACPI_STRCAT(buffer, &acpi_rtype_names[i][j]); | 1132 | ACPI_STRCAT(buffer, &acpi_rtype_names[i][j]); |
1112 | j = 0; /* Use name separator from now on */ | 1133 | j = 0; /* Use name separator from now on */ |
1113 | } | 1134 | } |
1114 | this_rtype <<= 1; /* Next Rtype */ | 1135 | this_rtype <<= 1; /* Next Rtype */ |
1115 | } | 1136 | } |
1116 | } | 1137 | } |
1117 | 1138 |
drivers/acpi/acpica/nsrepair.c
1 | /****************************************************************************** | 1 | /****************************************************************************** |
2 | * | 2 | * |
3 | * Module Name: nsrepair - Repair for objects returned by predefined methods | 3 | * Module Name: nsrepair - Repair for objects returned by predefined methods |
4 | * | 4 | * |
5 | *****************************************************************************/ | 5 | *****************************************************************************/ |
6 | 6 | ||
7 | /* | 7 | /* |
8 | * Copyright (C) 2000 - 2010, Intel Corp. | 8 | * Copyright (C) 2000 - 2010, Intel Corp. |
9 | * All rights reserved. | 9 | * All rights reserved. |
10 | * | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright |
15 | * notice, this list of conditions, and the following disclaimer, | 15 | * notice, this list of conditions, and the following disclaimer, |
16 | * without modification. | 16 | * without modification. |
17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | 17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
18 | * substantially similar to the "NO WARRANTY" disclaimer below | 18 | * substantially similar to the "NO WARRANTY" disclaimer below |
19 | * ("Disclaimer") and any redistribution must be conditioned upon | 19 | * ("Disclaimer") and any redistribution must be conditioned upon |
20 | * including a substantially similar Disclaimer requirement for further | 20 | * including a substantially similar Disclaimer requirement for further |
21 | * binary redistribution. | 21 | * binary redistribution. |
22 | * 3. Neither the names of the above-listed copyright holders nor the names | 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 | 23 | * of any contributors may be used to endorse or promote products derived |
24 | * from this software without specific prior written permission. | 24 | * from this software without specific prior written permission. |
25 | * | 25 | * |
26 | * Alternatively, this software may be distributed under the terms of the | 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 | 27 | * GNU General Public License ("GPL") version 2 as published by the Free |
28 | * Software Foundation. | 28 | * Software Foundation. |
29 | * | 29 | * |
30 | * NO WARRANTY | 30 | * NO WARRANTY |
31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | 33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR |
34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | 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 | 40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
41 | * POSSIBILITY OF SUCH DAMAGES. | 41 | * POSSIBILITY OF SUCH DAMAGES. |
42 | */ | 42 | */ |
43 | 43 | ||
44 | #include <acpi/acpi.h> | 44 | #include <acpi/acpi.h> |
45 | #include "accommon.h" | 45 | #include "accommon.h" |
46 | #include "acnamesp.h" | 46 | #include "acnamesp.h" |
47 | #include "acinterp.h" | 47 | #include "acinterp.h" |
48 | #include "acpredef.h" | ||
48 | 49 | ||
49 | #define _COMPONENT ACPI_NAMESPACE | 50 | #define _COMPONENT ACPI_NAMESPACE |
50 | ACPI_MODULE_NAME("nsrepair") | 51 | ACPI_MODULE_NAME("nsrepair") |
51 | 52 | ||
52 | /******************************************************************************* | 53 | /******************************************************************************* |
53 | * | 54 | * |
54 | * This module attempts to repair or convert objects returned by the | 55 | * This module attempts to repair or convert objects returned by the |
55 | * predefined methods to an object type that is expected, as per the ACPI | 56 | * predefined methods to an object type that is expected, as per the ACPI |
56 | * specification. The need for this code is dictated by the many machines that | 57 | * specification. The need for this code is dictated by the many machines that |
57 | * return incorrect types for the standard predefined methods. Performing these | 58 | * return incorrect types for the standard predefined methods. Performing these |
58 | * conversions here, in one place, eliminates the need for individual ACPI | 59 | * conversions here, in one place, eliminates the need for individual ACPI |
59 | * device drivers to do the same. Note: Most of these conversions are different | 60 | * device drivers to do the same. Note: Most of these conversions are different |
60 | * than the internal object conversion routines used for implicit object | 61 | * than the internal object conversion routines used for implicit object |
61 | * conversion. | 62 | * conversion. |
62 | * | 63 | * |
63 | * The following conversions can be performed as necessary: | 64 | * The following conversions can be performed as necessary: |
64 | * | 65 | * |
65 | * Integer -> String | 66 | * Integer -> String |
66 | * Integer -> Buffer | 67 | * Integer -> Buffer |
67 | * String -> Integer | 68 | * String -> Integer |
68 | * String -> Buffer | 69 | * String -> Buffer |
69 | * Buffer -> Integer | 70 | * Buffer -> Integer |
70 | * Buffer -> String | 71 | * Buffer -> String |
71 | * Buffer -> Package of Integers | 72 | * Buffer -> Package of Integers |
72 | * Package -> Package of one Package | 73 | * Package -> Package of one Package |
73 | * | 74 | * |
75 | * Additional possible repairs: | ||
76 | * | ||
77 | * Optional/unnecessary NULL package elements removed | ||
78 | * Required package elements that are NULL replaced by Integer/String/Buffer | ||
79 | * Incorrect standalone package wrapped with required outer package | ||
80 | * | ||
74 | ******************************************************************************/ | 81 | ******************************************************************************/ |
75 | /* Local prototypes */ | 82 | /* Local prototypes */ |
76 | static acpi_status | 83 | static acpi_status |
77 | acpi_ns_convert_to_integer(union acpi_operand_object *original_object, | 84 | acpi_ns_convert_to_integer(union acpi_operand_object *original_object, |
78 | union acpi_operand_object **return_object); | 85 | union acpi_operand_object **return_object); |
79 | 86 | ||
80 | static acpi_status | 87 | static acpi_status |
81 | acpi_ns_convert_to_string(union acpi_operand_object *original_object, | 88 | acpi_ns_convert_to_string(union acpi_operand_object *original_object, |
82 | union acpi_operand_object **return_object); | 89 | union acpi_operand_object **return_object); |
83 | 90 | ||
84 | static acpi_status | 91 | static acpi_status |
85 | acpi_ns_convert_to_buffer(union acpi_operand_object *original_object, | 92 | acpi_ns_convert_to_buffer(union acpi_operand_object *original_object, |
86 | union acpi_operand_object **return_object); | 93 | union acpi_operand_object **return_object); |
87 | 94 | ||
88 | static acpi_status | 95 | static acpi_status |
89 | acpi_ns_convert_to_package(union acpi_operand_object *original_object, | 96 | acpi_ns_convert_to_package(union acpi_operand_object *original_object, |
90 | union acpi_operand_object **return_object); | 97 | union acpi_operand_object **return_object); |
91 | 98 | ||
92 | /******************************************************************************* | 99 | /******************************************************************************* |
93 | * | 100 | * |
94 | * FUNCTION: acpi_ns_repair_object | 101 | * FUNCTION: acpi_ns_repair_object |
95 | * | 102 | * |
96 | * PARAMETERS: Data - Pointer to validation data structure | 103 | * PARAMETERS: Data - Pointer to validation data structure |
97 | * expected_btypes - Object types expected | 104 | * expected_btypes - Object types expected |
98 | * package_index - Index of object within parent package (if | 105 | * package_index - Index of object within parent package (if |
99 | * applicable - ACPI_NOT_PACKAGE_ELEMENT | 106 | * applicable - ACPI_NOT_PACKAGE_ELEMENT |
100 | * otherwise) | 107 | * otherwise) |
101 | * return_object_ptr - Pointer to the object returned from the | 108 | * return_object_ptr - Pointer to the object returned from the |
102 | * evaluation of a method or object | 109 | * evaluation of a method or object |
103 | * | 110 | * |
104 | * RETURN: Status. AE_OK if repair was successful. | 111 | * RETURN: Status. AE_OK if repair was successful. |
105 | * | 112 | * |
106 | * DESCRIPTION: Attempt to repair/convert a return object of a type that was | 113 | * DESCRIPTION: Attempt to repair/convert a return object of a type that was |
107 | * not expected. | 114 | * not expected. |
108 | * | 115 | * |
109 | ******************************************************************************/ | 116 | ******************************************************************************/ |
110 | 117 | ||
111 | acpi_status | 118 | acpi_status |
112 | acpi_ns_repair_object(struct acpi_predefined_data *data, | 119 | acpi_ns_repair_object(struct acpi_predefined_data *data, |
113 | u32 expected_btypes, | 120 | u32 expected_btypes, |
114 | u32 package_index, | 121 | u32 package_index, |
115 | union acpi_operand_object **return_object_ptr) | 122 | union acpi_operand_object **return_object_ptr) |
116 | { | 123 | { |
117 | union acpi_operand_object *return_object = *return_object_ptr; | 124 | union acpi_operand_object *return_object = *return_object_ptr; |
118 | union acpi_operand_object *new_object; | 125 | union acpi_operand_object *new_object; |
119 | acpi_status status; | 126 | acpi_status status; |
120 | 127 | ||
121 | ACPI_FUNCTION_NAME(ns_repair_object); | 128 | ACPI_FUNCTION_NAME(ns_repair_object); |
122 | 129 | ||
123 | /* | 130 | /* |
124 | * At this point, we know that the type of the returned object was not | 131 | * At this point, we know that the type of the returned object was not |
125 | * one of the expected types for this predefined name. Attempt to | 132 | * one of the expected types for this predefined name. Attempt to |
126 | * repair the object by converting it to one of the expected object | 133 | * repair the object by converting it to one of the expected object |
127 | * types for this predefined name. | 134 | * types for this predefined name. |
128 | */ | 135 | */ |
129 | if (expected_btypes & ACPI_RTYPE_INTEGER) { | 136 | if (expected_btypes & ACPI_RTYPE_INTEGER) { |
130 | status = acpi_ns_convert_to_integer(return_object, &new_object); | 137 | status = acpi_ns_convert_to_integer(return_object, &new_object); |
131 | if (ACPI_SUCCESS(status)) { | 138 | if (ACPI_SUCCESS(status)) { |
132 | goto object_repaired; | 139 | goto object_repaired; |
133 | } | 140 | } |
134 | } | 141 | } |
135 | if (expected_btypes & ACPI_RTYPE_STRING) { | 142 | if (expected_btypes & ACPI_RTYPE_STRING) { |
136 | status = acpi_ns_convert_to_string(return_object, &new_object); | 143 | status = acpi_ns_convert_to_string(return_object, &new_object); |
137 | if (ACPI_SUCCESS(status)) { | 144 | if (ACPI_SUCCESS(status)) { |
138 | goto object_repaired; | 145 | goto object_repaired; |
139 | } | 146 | } |
140 | } | 147 | } |
141 | if (expected_btypes & ACPI_RTYPE_BUFFER) { | 148 | if (expected_btypes & ACPI_RTYPE_BUFFER) { |
142 | status = acpi_ns_convert_to_buffer(return_object, &new_object); | 149 | status = acpi_ns_convert_to_buffer(return_object, &new_object); |
143 | if (ACPI_SUCCESS(status)) { | 150 | if (ACPI_SUCCESS(status)) { |
144 | goto object_repaired; | 151 | goto object_repaired; |
145 | } | 152 | } |
146 | } | 153 | } |
147 | if (expected_btypes & ACPI_RTYPE_PACKAGE) { | 154 | if (expected_btypes & ACPI_RTYPE_PACKAGE) { |
148 | status = acpi_ns_convert_to_package(return_object, &new_object); | 155 | status = acpi_ns_convert_to_package(return_object, &new_object); |
149 | if (ACPI_SUCCESS(status)) { | 156 | if (ACPI_SUCCESS(status)) { |
150 | goto object_repaired; | 157 | goto object_repaired; |
151 | } | 158 | } |
152 | } | 159 | } |
153 | 160 | ||
154 | /* We cannot repair this object */ | 161 | /* We cannot repair this object */ |
155 | 162 | ||
156 | return (AE_AML_OPERAND_TYPE); | 163 | return (AE_AML_OPERAND_TYPE); |
157 | 164 | ||
158 | object_repaired: | 165 | object_repaired: |
159 | 166 | ||
160 | /* Object was successfully repaired */ | 167 | /* Object was successfully repaired */ |
161 | 168 | ||
162 | /* | 169 | /* |
163 | * If the original object is a package element, we need to: | 170 | * If the original object is a package element, we need to: |
164 | * 1. Set the reference count of the new object to match the | 171 | * 1. Set the reference count of the new object to match the |
165 | * reference count of the old object. | 172 | * reference count of the old object. |
166 | * 2. Decrement the reference count of the original object. | 173 | * 2. Decrement the reference count of the original object. |
167 | */ | 174 | */ |
168 | if (package_index != ACPI_NOT_PACKAGE_ELEMENT) { | 175 | if (package_index != ACPI_NOT_PACKAGE_ELEMENT) { |
169 | new_object->common.reference_count = | 176 | new_object->common.reference_count = |
170 | return_object->common.reference_count; | 177 | return_object->common.reference_count; |
171 | 178 | ||
172 | if (return_object->common.reference_count > 1) { | 179 | if (return_object->common.reference_count > 1) { |
173 | return_object->common.reference_count--; | 180 | return_object->common.reference_count--; |
174 | } | 181 | } |
175 | 182 | ||
176 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, | 183 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, |
177 | "%s: Converted %s to expected %s at index %u\n", | 184 | "%s: Converted %s to expected %s at index %u\n", |
178 | data->pathname, | 185 | data->pathname, |
179 | acpi_ut_get_object_type_name(return_object), | 186 | acpi_ut_get_object_type_name(return_object), |
180 | acpi_ut_get_object_type_name(new_object), | 187 | acpi_ut_get_object_type_name(new_object), |
181 | package_index)); | 188 | package_index)); |
182 | } else { | 189 | } else { |
183 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, | 190 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, |
184 | "%s: Converted %s to expected %s\n", | 191 | "%s: Converted %s to expected %s\n", |
185 | data->pathname, | 192 | data->pathname, |
186 | acpi_ut_get_object_type_name(return_object), | 193 | acpi_ut_get_object_type_name(return_object), |
187 | acpi_ut_get_object_type_name(new_object))); | 194 | acpi_ut_get_object_type_name(new_object))); |
188 | } | 195 | } |
189 | 196 | ||
190 | /* Delete old object, install the new return object */ | 197 | /* Delete old object, install the new return object */ |
191 | 198 | ||
192 | acpi_ut_remove_reference(return_object); | 199 | acpi_ut_remove_reference(return_object); |
193 | *return_object_ptr = new_object; | 200 | *return_object_ptr = new_object; |
194 | data->flags |= ACPI_OBJECT_REPAIRED; | 201 | data->flags |= ACPI_OBJECT_REPAIRED; |
195 | return (AE_OK); | 202 | return (AE_OK); |
196 | } | 203 | } |
197 | 204 | ||
198 | /******************************************************************************* | 205 | /******************************************************************************* |
199 | * | 206 | * |
200 | * FUNCTION: acpi_ns_convert_to_integer | 207 | * FUNCTION: acpi_ns_convert_to_integer |
201 | * | 208 | * |
202 | * PARAMETERS: original_object - Object to be converted | 209 | * PARAMETERS: original_object - Object to be converted |
203 | * return_object - Where the new converted object is returned | 210 | * return_object - Where the new converted object is returned |
204 | * | 211 | * |
205 | * RETURN: Status. AE_OK if conversion was successful. | 212 | * RETURN: Status. AE_OK if conversion was successful. |
206 | * | 213 | * |
207 | * DESCRIPTION: Attempt to convert a String/Buffer object to an Integer. | 214 | * DESCRIPTION: Attempt to convert a String/Buffer object to an Integer. |
208 | * | 215 | * |
209 | ******************************************************************************/ | 216 | ******************************************************************************/ |
210 | 217 | ||
211 | static acpi_status | 218 | static acpi_status |
212 | acpi_ns_convert_to_integer(union acpi_operand_object *original_object, | 219 | acpi_ns_convert_to_integer(union acpi_operand_object *original_object, |
213 | union acpi_operand_object **return_object) | 220 | union acpi_operand_object **return_object) |
214 | { | 221 | { |
215 | union acpi_operand_object *new_object; | 222 | union acpi_operand_object *new_object; |
216 | acpi_status status; | 223 | acpi_status status; |
217 | u64 value = 0; | 224 | u64 value = 0; |
218 | u32 i; | 225 | u32 i; |
219 | 226 | ||
220 | switch (original_object->common.type) { | 227 | switch (original_object->common.type) { |
221 | case ACPI_TYPE_STRING: | 228 | case ACPI_TYPE_STRING: |
222 | 229 | ||
223 | /* String-to-Integer conversion */ | 230 | /* String-to-Integer conversion */ |
224 | 231 | ||
225 | status = acpi_ut_strtoul64(original_object->string.pointer, | 232 | status = acpi_ut_strtoul64(original_object->string.pointer, |
226 | ACPI_ANY_BASE, &value); | 233 | ACPI_ANY_BASE, &value); |
227 | if (ACPI_FAILURE(status)) { | 234 | if (ACPI_FAILURE(status)) { |
228 | return (status); | 235 | return (status); |
229 | } | 236 | } |
230 | break; | 237 | break; |
231 | 238 | ||
232 | case ACPI_TYPE_BUFFER: | 239 | case ACPI_TYPE_BUFFER: |
233 | 240 | ||
234 | /* Buffer-to-Integer conversion. Max buffer size is 64 bits. */ | 241 | /* Buffer-to-Integer conversion. Max buffer size is 64 bits. */ |
235 | 242 | ||
236 | if (original_object->buffer.length > 8) { | 243 | if (original_object->buffer.length > 8) { |
237 | return (AE_AML_OPERAND_TYPE); | 244 | return (AE_AML_OPERAND_TYPE); |
238 | } | 245 | } |
239 | 246 | ||
240 | /* Extract each buffer byte to create the integer */ | 247 | /* Extract each buffer byte to create the integer */ |
241 | 248 | ||
242 | for (i = 0; i < original_object->buffer.length; i++) { | 249 | for (i = 0; i < original_object->buffer.length; i++) { |
243 | value |= | 250 | value |= |
244 | ((u64) original_object->buffer. | 251 | ((u64) original_object->buffer. |
245 | pointer[i] << (i * 8)); | 252 | pointer[i] << (i * 8)); |
246 | } | 253 | } |
247 | break; | 254 | break; |
248 | 255 | ||
249 | default: | 256 | default: |
250 | return (AE_AML_OPERAND_TYPE); | 257 | return (AE_AML_OPERAND_TYPE); |
251 | } | 258 | } |
252 | 259 | ||
253 | new_object = acpi_ut_create_integer_object(value); | 260 | new_object = acpi_ut_create_integer_object(value); |
254 | if (!new_object) { | 261 | if (!new_object) { |
255 | return (AE_NO_MEMORY); | 262 | return (AE_NO_MEMORY); |
256 | } | 263 | } |
257 | 264 | ||
258 | *return_object = new_object; | 265 | *return_object = new_object; |
259 | return (AE_OK); | 266 | return (AE_OK); |
260 | } | 267 | } |
261 | 268 | ||
262 | /******************************************************************************* | 269 | /******************************************************************************* |
263 | * | 270 | * |
264 | * FUNCTION: acpi_ns_convert_to_string | 271 | * FUNCTION: acpi_ns_convert_to_string |
265 | * | 272 | * |
266 | * PARAMETERS: original_object - Object to be converted | 273 | * PARAMETERS: original_object - Object to be converted |
267 | * return_object - Where the new converted object is returned | 274 | * return_object - Where the new converted object is returned |
268 | * | 275 | * |
269 | * RETURN: Status. AE_OK if conversion was successful. | 276 | * RETURN: Status. AE_OK if conversion was successful. |
270 | * | 277 | * |
271 | * DESCRIPTION: Attempt to convert a Integer/Buffer object to a String. | 278 | * DESCRIPTION: Attempt to convert a Integer/Buffer object to a String. |
272 | * | 279 | * |
273 | ******************************************************************************/ | 280 | ******************************************************************************/ |
274 | 281 | ||
275 | static acpi_status | 282 | static acpi_status |
276 | acpi_ns_convert_to_string(union acpi_operand_object *original_object, | 283 | acpi_ns_convert_to_string(union acpi_operand_object *original_object, |
277 | union acpi_operand_object **return_object) | 284 | union acpi_operand_object **return_object) |
278 | { | 285 | { |
279 | union acpi_operand_object *new_object; | 286 | union acpi_operand_object *new_object; |
280 | acpi_size length; | 287 | acpi_size length; |
281 | acpi_status status; | 288 | acpi_status status; |
282 | 289 | ||
283 | switch (original_object->common.type) { | 290 | switch (original_object->common.type) { |
284 | case ACPI_TYPE_INTEGER: | 291 | case ACPI_TYPE_INTEGER: |
285 | /* | 292 | /* |
286 | * Integer-to-String conversion. Commonly, convert | 293 | * Integer-to-String conversion. Commonly, convert |
287 | * an integer of value 0 to a NULL string. The last element of | 294 | * an integer of value 0 to a NULL string. The last element of |
288 | * _BIF and _BIX packages occasionally need this fix. | 295 | * _BIF and _BIX packages occasionally need this fix. |
289 | */ | 296 | */ |
290 | if (original_object->integer.value == 0) { | 297 | if (original_object->integer.value == 0) { |
291 | 298 | ||
292 | /* Allocate a new NULL string object */ | 299 | /* Allocate a new NULL string object */ |
293 | 300 | ||
294 | new_object = acpi_ut_create_string_object(0); | 301 | new_object = acpi_ut_create_string_object(0); |
295 | if (!new_object) { | 302 | if (!new_object) { |
296 | return (AE_NO_MEMORY); | 303 | return (AE_NO_MEMORY); |
297 | } | 304 | } |
298 | } else { | 305 | } else { |
299 | status = | 306 | status = |
300 | acpi_ex_convert_to_string(original_object, | 307 | acpi_ex_convert_to_string(original_object, |
301 | &new_object, | 308 | &new_object, |
302 | ACPI_IMPLICIT_CONVERT_HEX); | 309 | ACPI_IMPLICIT_CONVERT_HEX); |
303 | if (ACPI_FAILURE(status)) { | 310 | if (ACPI_FAILURE(status)) { |
304 | return (status); | 311 | return (status); |
305 | } | 312 | } |
306 | } | 313 | } |
307 | break; | 314 | break; |
308 | 315 | ||
309 | case ACPI_TYPE_BUFFER: | 316 | case ACPI_TYPE_BUFFER: |
310 | /* | 317 | /* |
311 | * Buffer-to-String conversion. Use a to_string | 318 | * Buffer-to-String conversion. Use a to_string |
312 | * conversion, no transform performed on the buffer data. The best | 319 | * conversion, no transform performed on the buffer data. The best |
313 | * example of this is the _BIF method, where the string data from | 320 | * example of this is the _BIF method, where the string data from |
314 | * the battery is often (incorrectly) returned as buffer object(s). | 321 | * the battery is often (incorrectly) returned as buffer object(s). |
315 | */ | 322 | */ |
316 | length = 0; | 323 | length = 0; |
317 | while ((length < original_object->buffer.length) && | 324 | while ((length < original_object->buffer.length) && |
318 | (original_object->buffer.pointer[length])) { | 325 | (original_object->buffer.pointer[length])) { |
319 | length++; | 326 | length++; |
320 | } | 327 | } |
321 | 328 | ||
322 | /* Allocate a new string object */ | 329 | /* Allocate a new string object */ |
323 | 330 | ||
324 | new_object = acpi_ut_create_string_object(length); | 331 | new_object = acpi_ut_create_string_object(length); |
325 | if (!new_object) { | 332 | if (!new_object) { |
326 | return (AE_NO_MEMORY); | 333 | return (AE_NO_MEMORY); |
327 | } | 334 | } |
328 | 335 | ||
329 | /* | 336 | /* |
330 | * Copy the raw buffer data with no transform. String is already NULL | 337 | * Copy the raw buffer data with no transform. String is already NULL |
331 | * terminated at Length+1. | 338 | * terminated at Length+1. |
332 | */ | 339 | */ |
333 | ACPI_MEMCPY(new_object->string.pointer, | 340 | ACPI_MEMCPY(new_object->string.pointer, |
334 | original_object->buffer.pointer, length); | 341 | original_object->buffer.pointer, length); |
335 | break; | 342 | break; |
336 | 343 | ||
337 | default: | 344 | default: |
338 | return (AE_AML_OPERAND_TYPE); | 345 | return (AE_AML_OPERAND_TYPE); |
339 | } | 346 | } |
340 | 347 | ||
341 | *return_object = new_object; | 348 | *return_object = new_object; |
342 | return (AE_OK); | 349 | return (AE_OK); |
343 | } | 350 | } |
344 | 351 | ||
345 | /******************************************************************************* | 352 | /******************************************************************************* |
346 | * | 353 | * |
347 | * FUNCTION: acpi_ns_convert_to_buffer | 354 | * FUNCTION: acpi_ns_convert_to_buffer |
348 | * | 355 | * |
349 | * PARAMETERS: original_object - Object to be converted | 356 | * PARAMETERS: original_object - Object to be converted |
350 | * return_object - Where the new converted object is returned | 357 | * return_object - Where the new converted object is returned |
351 | * | 358 | * |
352 | * RETURN: Status. AE_OK if conversion was successful. | 359 | * RETURN: Status. AE_OK if conversion was successful. |
353 | * | 360 | * |
354 | * DESCRIPTION: Attempt to convert a Integer/String/Package object to a Buffer. | 361 | * DESCRIPTION: Attempt to convert a Integer/String/Package object to a Buffer. |
355 | * | 362 | * |
356 | ******************************************************************************/ | 363 | ******************************************************************************/ |
357 | 364 | ||
358 | static acpi_status | 365 | static acpi_status |
359 | acpi_ns_convert_to_buffer(union acpi_operand_object *original_object, | 366 | acpi_ns_convert_to_buffer(union acpi_operand_object *original_object, |
360 | union acpi_operand_object **return_object) | 367 | union acpi_operand_object **return_object) |
361 | { | 368 | { |
362 | union acpi_operand_object *new_object; | 369 | union acpi_operand_object *new_object; |
363 | acpi_status status; | 370 | acpi_status status; |
364 | union acpi_operand_object **elements; | 371 | union acpi_operand_object **elements; |
365 | u32 *dword_buffer; | 372 | u32 *dword_buffer; |
366 | u32 count; | 373 | u32 count; |
367 | u32 i; | 374 | u32 i; |
368 | 375 | ||
369 | switch (original_object->common.type) { | 376 | switch (original_object->common.type) { |
370 | case ACPI_TYPE_INTEGER: | 377 | case ACPI_TYPE_INTEGER: |
371 | /* | 378 | /* |
372 | * Integer-to-Buffer conversion. | 379 | * Integer-to-Buffer conversion. |
373 | * Convert the Integer to a packed-byte buffer. _MAT and other | 380 | * Convert the Integer to a packed-byte buffer. _MAT and other |
374 | * objects need this sometimes, if a read has been performed on a | 381 | * objects need this sometimes, if a read has been performed on a |
375 | * Field object that is less than or equal to the global integer | 382 | * Field object that is less than or equal to the global integer |
376 | * size (32 or 64 bits). | 383 | * size (32 or 64 bits). |
377 | */ | 384 | */ |
378 | status = | 385 | status = |
379 | acpi_ex_convert_to_buffer(original_object, &new_object); | 386 | acpi_ex_convert_to_buffer(original_object, &new_object); |
380 | if (ACPI_FAILURE(status)) { | 387 | if (ACPI_FAILURE(status)) { |
381 | return (status); | 388 | return (status); |
382 | } | 389 | } |
383 | break; | 390 | break; |
384 | 391 | ||
385 | case ACPI_TYPE_STRING: | 392 | case ACPI_TYPE_STRING: |
386 | 393 | ||
387 | /* String-to-Buffer conversion. Simple data copy */ | 394 | /* String-to-Buffer conversion. Simple data copy */ |
388 | 395 | ||
389 | new_object = | 396 | new_object = |
390 | acpi_ut_create_buffer_object(original_object->string. | 397 | acpi_ut_create_buffer_object(original_object->string. |
391 | length); | 398 | length); |
392 | if (!new_object) { | 399 | if (!new_object) { |
393 | return (AE_NO_MEMORY); | 400 | return (AE_NO_MEMORY); |
394 | } | 401 | } |
395 | 402 | ||
396 | ACPI_MEMCPY(new_object->buffer.pointer, | 403 | ACPI_MEMCPY(new_object->buffer.pointer, |
397 | original_object->string.pointer, | 404 | original_object->string.pointer, |
398 | original_object->string.length); | 405 | original_object->string.length); |
399 | break; | 406 | break; |
400 | 407 | ||
401 | case ACPI_TYPE_PACKAGE: | 408 | case ACPI_TYPE_PACKAGE: |
402 | /* | 409 | /* |
403 | * This case is often seen for predefined names that must return a | 410 | * This case is often seen for predefined names that must return a |
404 | * Buffer object with multiple DWORD integers within. For example, | 411 | * Buffer object with multiple DWORD integers within. For example, |
405 | * _FDE and _GTM. The Package can be converted to a Buffer. | 412 | * _FDE and _GTM. The Package can be converted to a Buffer. |
406 | */ | 413 | */ |
407 | 414 | ||
408 | /* All elements of the Package must be integers */ | 415 | /* All elements of the Package must be integers */ |
409 | 416 | ||
410 | elements = original_object->package.elements; | 417 | elements = original_object->package.elements; |
411 | count = original_object->package.count; | 418 | count = original_object->package.count; |
412 | 419 | ||
413 | for (i = 0; i < count; i++) { | 420 | for (i = 0; i < count; i++) { |
414 | if ((!*elements) || | 421 | if ((!*elements) || |
415 | ((*elements)->common.type != ACPI_TYPE_INTEGER)) { | 422 | ((*elements)->common.type != ACPI_TYPE_INTEGER)) { |
416 | return (AE_AML_OPERAND_TYPE); | 423 | return (AE_AML_OPERAND_TYPE); |
417 | } | 424 | } |
418 | elements++; | 425 | elements++; |
419 | } | 426 | } |
420 | 427 | ||
421 | /* Create the new buffer object to replace the Package */ | 428 | /* Create the new buffer object to replace the Package */ |
422 | 429 | ||
423 | new_object = acpi_ut_create_buffer_object(ACPI_MUL_4(count)); | 430 | new_object = acpi_ut_create_buffer_object(ACPI_MUL_4(count)); |
424 | if (!new_object) { | 431 | if (!new_object) { |
425 | return (AE_NO_MEMORY); | 432 | return (AE_NO_MEMORY); |
426 | } | 433 | } |
427 | 434 | ||
428 | /* Copy the package elements (integers) to the buffer as DWORDs */ | 435 | /* Copy the package elements (integers) to the buffer as DWORDs */ |
429 | 436 | ||
430 | elements = original_object->package.elements; | 437 | elements = original_object->package.elements; |
431 | dword_buffer = ACPI_CAST_PTR(u32, new_object->buffer.pointer); | 438 | dword_buffer = ACPI_CAST_PTR(u32, new_object->buffer.pointer); |
432 | 439 | ||
433 | for (i = 0; i < count; i++) { | 440 | for (i = 0; i < count; i++) { |
434 | *dword_buffer = (u32) (*elements)->integer.value; | 441 | *dword_buffer = (u32) (*elements)->integer.value; |
435 | dword_buffer++; | 442 | dword_buffer++; |
436 | elements++; | 443 | elements++; |
437 | } | 444 | } |
438 | break; | 445 | break; |
439 | 446 | ||
440 | default: | 447 | default: |
441 | return (AE_AML_OPERAND_TYPE); | 448 | return (AE_AML_OPERAND_TYPE); |
442 | } | 449 | } |
443 | 450 | ||
444 | *return_object = new_object; | 451 | *return_object = new_object; |
445 | return (AE_OK); | 452 | return (AE_OK); |
446 | } | 453 | } |
447 | 454 | ||
448 | /******************************************************************************* | 455 | /******************************************************************************* |
449 | * | 456 | * |
450 | * FUNCTION: acpi_ns_convert_to_package | 457 | * FUNCTION: acpi_ns_convert_to_package |
451 | * | 458 | * |
452 | * PARAMETERS: original_object - Object to be converted | 459 | * PARAMETERS: original_object - Object to be converted |
453 | * return_object - Where the new converted object is returned | 460 | * return_object - Where the new converted object is returned |
454 | * | 461 | * |
455 | * RETURN: Status. AE_OK if conversion was successful. | 462 | * RETURN: Status. AE_OK if conversion was successful. |
456 | * | 463 | * |
457 | * DESCRIPTION: Attempt to convert a Buffer object to a Package. Each byte of | 464 | * DESCRIPTION: Attempt to convert a Buffer object to a Package. Each byte of |
458 | * the buffer is converted to a single integer package element. | 465 | * the buffer is converted to a single integer package element. |
459 | * | 466 | * |
460 | ******************************************************************************/ | 467 | ******************************************************************************/ |
461 | 468 | ||
462 | static acpi_status | 469 | static acpi_status |
463 | acpi_ns_convert_to_package(union acpi_operand_object *original_object, | 470 | acpi_ns_convert_to_package(union acpi_operand_object *original_object, |
464 | union acpi_operand_object **return_object) | 471 | union acpi_operand_object **return_object) |
465 | { | 472 | { |
466 | union acpi_operand_object *new_object; | 473 | union acpi_operand_object *new_object; |
467 | union acpi_operand_object **elements; | 474 | union acpi_operand_object **elements; |
468 | u32 length; | 475 | u32 length; |
469 | u8 *buffer; | 476 | u8 *buffer; |
470 | 477 | ||
471 | switch (original_object->common.type) { | 478 | switch (original_object->common.type) { |
472 | case ACPI_TYPE_BUFFER: | 479 | case ACPI_TYPE_BUFFER: |
473 | 480 | ||
474 | /* Buffer-to-Package conversion */ | 481 | /* Buffer-to-Package conversion */ |
475 | 482 | ||
476 | length = original_object->buffer.length; | 483 | length = original_object->buffer.length; |
477 | new_object = acpi_ut_create_package_object(length); | 484 | new_object = acpi_ut_create_package_object(length); |
478 | if (!new_object) { | 485 | if (!new_object) { |
479 | return (AE_NO_MEMORY); | 486 | return (AE_NO_MEMORY); |
480 | } | 487 | } |
481 | 488 | ||
482 | /* Convert each buffer byte to an integer package element */ | 489 | /* Convert each buffer byte to an integer package element */ |
483 | 490 | ||
484 | elements = new_object->package.elements; | 491 | elements = new_object->package.elements; |
485 | buffer = original_object->buffer.pointer; | 492 | buffer = original_object->buffer.pointer; |
486 | 493 | ||
487 | while (length--) { | 494 | while (length--) { |
488 | *elements = | 495 | *elements = |
489 | acpi_ut_create_integer_object((u64) *buffer); | 496 | acpi_ut_create_integer_object((u64) *buffer); |
490 | if (!*elements) { | 497 | if (!*elements) { |
491 | acpi_ut_remove_reference(new_object); | 498 | acpi_ut_remove_reference(new_object); |
492 | return (AE_NO_MEMORY); | 499 | return (AE_NO_MEMORY); |
493 | } | 500 | } |
494 | elements++; | 501 | elements++; |
495 | buffer++; | 502 | buffer++; |
496 | } | 503 | } |
497 | break; | 504 | break; |
498 | 505 | ||
499 | default: | 506 | default: |
500 | return (AE_AML_OPERAND_TYPE); | 507 | return (AE_AML_OPERAND_TYPE); |
501 | } | 508 | } |
502 | 509 | ||
503 | *return_object = new_object; | 510 | *return_object = new_object; |
504 | return (AE_OK); | 511 | return (AE_OK); |
512 | } | ||
513 | |||
514 | /******************************************************************************* | ||
515 | * | ||
516 | * FUNCTION: acpi_ns_repair_null_element | ||
517 | * | ||
518 | * PARAMETERS: Data - Pointer to validation data structure | ||
519 | * expected_btypes - Object types expected | ||
520 | * package_index - Index of object within parent package (if | ||
521 | * applicable - ACPI_NOT_PACKAGE_ELEMENT | ||
522 | * otherwise) | ||
523 | * return_object_ptr - Pointer to the object returned from the | ||
524 | * evaluation of a method or object | ||
525 | * | ||
526 | * RETURN: Status. AE_OK if repair was successful. | ||
527 | * | ||
528 | * DESCRIPTION: Attempt to repair a NULL element of a returned Package object. | ||
529 | * | ||
530 | ******************************************************************************/ | ||
531 | |||
532 | acpi_status | ||
533 | acpi_ns_repair_null_element(struct acpi_predefined_data *data, | ||
534 | u32 expected_btypes, | ||
535 | u32 package_index, | ||
536 | union acpi_operand_object **return_object_ptr) | ||
537 | { | ||
538 | union acpi_operand_object *return_object = *return_object_ptr; | ||
539 | union acpi_operand_object *new_object; | ||
540 | |||
541 | ACPI_FUNCTION_NAME(ns_repair_null_element); | ||
542 | |||
543 | /* No repair needed if return object is non-NULL */ | ||
544 | |||
545 | if (return_object) { | ||
546 | return (AE_OK); | ||
547 | } | ||
548 | |||
549 | /* | ||
550 | * Attempt to repair a NULL element of a Package object. This applies to | ||
551 | * predefined names that return a fixed-length package and each element | ||
552 | * is required. It does not apply to variable-length packages where NULL | ||
553 | * elements are allowed, especially at the end of the package. | ||
554 | */ | ||
555 | if (expected_btypes & ACPI_RTYPE_INTEGER) { | ||
556 | |||
557 | /* Need an Integer - create a zero-value integer */ | ||
558 | |||
559 | new_object = acpi_ut_create_integer_object(0); | ||
560 | } else if (expected_btypes & ACPI_RTYPE_STRING) { | ||
561 | |||
562 | /* Need a String - create a NULL string */ | ||
563 | |||
564 | new_object = acpi_ut_create_string_object(0); | ||
565 | } else if (expected_btypes & ACPI_RTYPE_BUFFER) { | ||
566 | |||
567 | /* Need a Buffer - create a zero-length buffer */ | ||
568 | |||
569 | new_object = acpi_ut_create_buffer_object(0); | ||
570 | } else { | ||
571 | /* Error for all other expected types */ | ||
572 | |||
573 | return (AE_AML_OPERAND_TYPE); | ||
574 | } | ||
575 | |||
576 | if (!new_object) { | ||
577 | return (AE_NO_MEMORY); | ||
578 | } | ||
579 | |||
580 | /* Set the reference count according to the parent Package object */ | ||
581 | |||
582 | new_object->common.reference_count = | ||
583 | data->parent_package->common.reference_count; | ||
584 | |||
585 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, | ||
586 | "%s: Converted NULL package element to expected %s at index %u\n", | ||
587 | data->pathname, | ||
588 | acpi_ut_get_object_type_name(new_object), | ||
589 | package_index)); | ||
590 | |||
591 | *return_object_ptr = new_object; | ||
592 | data->flags |= ACPI_OBJECT_REPAIRED; | ||
593 | return (AE_OK); | ||
594 | } | ||
595 | |||
596 | /****************************************************************************** | ||
597 | * | ||
598 | * FUNCTION: acpi_ns_remove_null_elements | ||
599 | * | ||
600 | * PARAMETERS: Data - Pointer to validation data structure | ||
601 | * package_type - An acpi_return_package_types value | ||
602 | * obj_desc - A Package object | ||
603 | * | ||
604 | * RETURN: None. | ||
605 | * | ||
606 | * DESCRIPTION: Remove all NULL package elements from packages that contain | ||
607 | * a variable number of sub-packages. For these types of | ||
608 | * packages, NULL elements can be safely removed. | ||
609 | * | ||
610 | *****************************************************************************/ | ||
611 | |||
612 | void | ||
613 | acpi_ns_remove_null_elements(struct acpi_predefined_data *data, | ||
614 | u8 package_type, | ||
615 | union acpi_operand_object *obj_desc) | ||
616 | { | ||
617 | union acpi_operand_object **source; | ||
618 | union acpi_operand_object **dest; | ||
619 | u32 count; | ||
620 | u32 new_count; | ||
621 | u32 i; | ||
622 | |||
623 | ACPI_FUNCTION_NAME(ns_remove_null_elements); | ||
624 | |||
625 | /* | ||
626 | * PTYPE1 packages contain no subpackages. | ||
627 | * PTYPE2 packages contain a variable number of sub-packages. We can | ||
628 | * safely remove all NULL elements from the PTYPE2 packages. | ||
629 | */ | ||
630 | switch (package_type) { | ||
631 | case ACPI_PTYPE1_FIXED: | ||
632 | case ACPI_PTYPE1_VAR: | ||
633 | case ACPI_PTYPE1_OPTION: | ||
634 | return; | ||
635 | |||
636 | case ACPI_PTYPE2: | ||
637 | case ACPI_PTYPE2_COUNT: | ||
638 | case ACPI_PTYPE2_PKG_COUNT: | ||
639 | case ACPI_PTYPE2_FIXED: | ||
640 | case ACPI_PTYPE2_MIN: | ||
641 | case ACPI_PTYPE2_REV_FIXED: | ||
642 | break; | ||
643 | |||
644 | default: | ||
645 | return; | ||
646 | } | ||
647 | |||
648 | count = obj_desc->package.count; | ||
649 | new_count = count; | ||
650 | |||
651 | source = obj_desc->package.elements; | ||
652 | dest = source; | ||
653 | |||
654 | /* Examine all elements of the package object, remove nulls */ | ||
655 | |||
656 | for (i = 0; i < count; i++) { | ||
657 | if (!*source) { | ||
658 | new_count--; | ||
659 | } else { | ||
660 | *dest = *source; | ||
661 | dest++; | ||
662 | } | ||
663 | source++; | ||
664 | } | ||
665 | |||
666 | /* Update parent package if any null elements were removed */ | ||
667 | |||
668 | if (new_count < count) { | ||
669 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, | ||
670 | "%s: Found and removed %u NULL elements\n", | ||
671 | data->pathname, (count - new_count))); | ||
672 | |||
673 | /* NULL terminate list and update the package count */ | ||
674 | |||
675 | *dest = NULL; | ||
676 | obj_desc->package.count = new_count; | ||
677 | } | ||
505 | } | 678 | } |
506 | 679 | ||
507 | /******************************************************************************* | 680 | /******************************************************************************* |
508 | * | 681 | * |
509 | * FUNCTION: acpi_ns_repair_package_list | 682 | * FUNCTION: acpi_ns_repair_package_list |
510 | * | 683 | * |
511 | * PARAMETERS: Data - Pointer to validation data structure | 684 | * PARAMETERS: Data - Pointer to validation data structure |
512 | * obj_desc_ptr - Pointer to the object to repair. The new | 685 | * obj_desc_ptr - Pointer to the object to repair. The new |
513 | * package object is returned here, | 686 | * package object is returned here, |
514 | * overwriting the old object. | 687 | * overwriting the old object. |
515 | * | 688 | * |
516 | * RETURN: Status, new object in *obj_desc_ptr | 689 | * RETURN: Status, new object in *obj_desc_ptr |
517 | * | 690 | * |
518 | * DESCRIPTION: Repair a common problem with objects that are defined to return | 691 | * DESCRIPTION: Repair a common problem with objects that are defined to return |
519 | * a variable-length Package of Packages. If the variable-length | 692 | * a variable-length Package of Packages. If the variable-length |
520 | * is one, some BIOS code mistakenly simply declares a single | 693 | * is one, some BIOS code mistakenly simply declares a single |
521 | * Package instead of a Package with one sub-Package. This | 694 | * Package instead of a Package with one sub-Package. This |
522 | * function attempts to repair this error by wrapping a Package | 695 | * function attempts to repair this error by wrapping a Package |
523 | * object around the original Package, creating the correct | 696 | * object around the original Package, creating the correct |
524 | * Package with one sub-Package. | 697 | * Package with one sub-Package. |
525 | * | 698 | * |
526 | * Names that can be repaired in this manner include: | 699 | * Names that can be repaired in this manner include: |
527 | * _ALR, _CSD, _HPX, _MLS, _PRT, _PSS, _TRT, TSS | 700 | * _ALR, _CSD, _HPX, _MLS, _PRT, _PSS, _TRT, TSS |
528 | * | 701 | * |
529 | ******************************************************************************/ | 702 | ******************************************************************************/ |
530 | 703 | ||
531 | acpi_status | 704 | acpi_status |
532 | acpi_ns_repair_package_list(struct acpi_predefined_data *data, | 705 | acpi_ns_repair_package_list(struct acpi_predefined_data *data, |
533 | union acpi_operand_object **obj_desc_ptr) | 706 | union acpi_operand_object **obj_desc_ptr) |
534 | { | 707 | { |
535 | union acpi_operand_object *pkg_obj_desc; | 708 | union acpi_operand_object *pkg_obj_desc; |
536 | 709 | ||
537 | ACPI_FUNCTION_NAME(ns_repair_package_list); | 710 | ACPI_FUNCTION_NAME(ns_repair_package_list); |
538 | 711 | ||
539 | /* | 712 | /* |
540 | * Create the new outer package and populate it. The new package will | 713 | * Create the new outer package and populate it. The new package will |
541 | * have a single element, the lone subpackage. | 714 | * have a single element, the lone subpackage. |
542 | */ | 715 | */ |
543 | pkg_obj_desc = acpi_ut_create_package_object(1); | 716 | pkg_obj_desc = acpi_ut_create_package_object(1); |
544 | if (!pkg_obj_desc) { | 717 | if (!pkg_obj_desc) { |
545 | return (AE_NO_MEMORY); | 718 | return (AE_NO_MEMORY); |
546 | } | 719 | } |
547 | 720 | ||
548 | pkg_obj_desc->package.elements[0] = *obj_desc_ptr; | 721 | pkg_obj_desc->package.elements[0] = *obj_desc_ptr; |
549 | 722 | ||
550 | /* Return the new object in the object pointer */ | 723 | /* Return the new object in the object pointer */ |
551 | 724 | ||
552 | *obj_desc_ptr = pkg_obj_desc; | 725 | *obj_desc_ptr = pkg_obj_desc; |
553 | data->flags |= ACPI_OBJECT_REPAIRED; | 726 | data->flags |= ACPI_OBJECT_REPAIRED; |
554 | 727 | ||
555 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, | 728 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, |
556 | "%s: Repaired incorrectly formed Package\n", | 729 | "%s: Repaired incorrectly formed Package\n", |
557 | data->pathname)); | 730 | data->pathname)); |
558 | 731 | ||
559 | return (AE_OK); | 732 | return (AE_OK); |
560 | } | 733 | } |
561 | 734 |
drivers/acpi/acpica/nsrepair2.c
1 | /****************************************************************************** | 1 | /****************************************************************************** |
2 | * | 2 | * |
3 | * Module Name: nsrepair2 - Repair for objects returned by specific | 3 | * Module Name: nsrepair2 - Repair for objects returned by specific |
4 | * predefined methods | 4 | * predefined methods |
5 | * | 5 | * |
6 | *****************************************************************************/ | 6 | *****************************************************************************/ |
7 | 7 | ||
8 | /* | 8 | /* |
9 | * Copyright (C) 2000 - 2010, Intel Corp. | 9 | * Copyright (C) 2000 - 2010, Intel Corp. |
10 | * All rights reserved. | 10 | * All rights reserved. |
11 | * | 11 | * |
12 | * Redistribution and use in source and binary forms, with or without | 12 | * Redistribution and use in source and binary forms, with or without |
13 | * modification, are permitted provided that the following conditions | 13 | * modification, are permitted provided that the following conditions |
14 | * are met: | 14 | * are met: |
15 | * 1. Redistributions of source code must retain the above copyright | 15 | * 1. Redistributions of source code must retain the above copyright |
16 | * notice, this list of conditions, and the following disclaimer, | 16 | * notice, this list of conditions, and the following disclaimer, |
17 | * without modification. | 17 | * without modification. |
18 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | 18 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
19 | * substantially similar to the "NO WARRANTY" disclaimer below | 19 | * substantially similar to the "NO WARRANTY" disclaimer below |
20 | * ("Disclaimer") and any redistribution must be conditioned upon | 20 | * ("Disclaimer") and any redistribution must be conditioned upon |
21 | * including a substantially similar Disclaimer requirement for further | 21 | * including a substantially similar Disclaimer requirement for further |
22 | * binary redistribution. | 22 | * binary redistribution. |
23 | * 3. Neither the names of the above-listed copyright holders nor the names | 23 | * 3. Neither the names of the above-listed copyright holders nor the names |
24 | * of any contributors may be used to endorse or promote products derived | 24 | * of any contributors may be used to endorse or promote products derived |
25 | * from this software without specific prior written permission. | 25 | * from this software without specific prior written permission. |
26 | * | 26 | * |
27 | * Alternatively, this software may be distributed under the terms of the | 27 | * Alternatively, this software may be distributed under the terms of the |
28 | * GNU General Public License ("GPL") version 2 as published by the Free | 28 | * GNU General Public License ("GPL") version 2 as published by the Free |
29 | * Software Foundation. | 29 | * Software Foundation. |
30 | * | 30 | * |
31 | * NO WARRANTY | 31 | * NO WARRANTY |
32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
33 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 33 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
34 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | 34 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR |
35 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 35 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
36 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 36 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
38 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 38 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
39 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 39 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
40 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | 40 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
41 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 41 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
42 | * POSSIBILITY OF SUCH DAMAGES. | 42 | * POSSIBILITY OF SUCH DAMAGES. |
43 | */ | 43 | */ |
44 | 44 | ||
45 | #include <acpi/acpi.h> | 45 | #include <acpi/acpi.h> |
46 | #include "accommon.h" | 46 | #include "accommon.h" |
47 | #include "acnamesp.h" | 47 | #include "acnamesp.h" |
48 | #include "acpredef.h" | ||
49 | 48 | ||
50 | #define _COMPONENT ACPI_NAMESPACE | 49 | #define _COMPONENT ACPI_NAMESPACE |
51 | ACPI_MODULE_NAME("nsrepair2") | 50 | ACPI_MODULE_NAME("nsrepair2") |
52 | 51 | ||
53 | /* | 52 | /* |
54 | * Information structure and handler for ACPI predefined names that can | 53 | * Information structure and handler for ACPI predefined names that can |
55 | * be repaired on a per-name basis. | 54 | * be repaired on a per-name basis. |
56 | */ | 55 | */ |
57 | typedef | 56 | typedef |
58 | acpi_status(*acpi_repair_function) (struct acpi_predefined_data *data, | 57 | acpi_status(*acpi_repair_function) (struct acpi_predefined_data *data, |
59 | union acpi_operand_object **return_object_ptr); | 58 | union acpi_operand_object **return_object_ptr); |
60 | 59 | ||
61 | typedef struct acpi_repair_info { | 60 | typedef struct acpi_repair_info { |
62 | char name[ACPI_NAME_SIZE]; | 61 | char name[ACPI_NAME_SIZE]; |
63 | acpi_repair_function repair_function; | 62 | acpi_repair_function repair_function; |
64 | 63 | ||
65 | } acpi_repair_info; | 64 | } acpi_repair_info; |
66 | 65 | ||
67 | /* Local prototypes */ | 66 | /* Local prototypes */ |
68 | 67 | ||
69 | static const struct acpi_repair_info *acpi_ns_match_repairable_name(struct | 68 | static const struct acpi_repair_info *acpi_ns_match_repairable_name(struct |
70 | acpi_namespace_node | 69 | acpi_namespace_node |
71 | *node); | 70 | *node); |
72 | 71 | ||
73 | static acpi_status | 72 | static acpi_status |
74 | acpi_ns_repair_ALR(struct acpi_predefined_data *data, | 73 | acpi_ns_repair_ALR(struct acpi_predefined_data *data, |
75 | union acpi_operand_object **return_object_ptr); | 74 | union acpi_operand_object **return_object_ptr); |
76 | 75 | ||
77 | static acpi_status | 76 | static acpi_status |
78 | acpi_ns_repair_FDE(struct acpi_predefined_data *data, | 77 | acpi_ns_repair_FDE(struct acpi_predefined_data *data, |
79 | union acpi_operand_object **return_object_ptr); | 78 | union acpi_operand_object **return_object_ptr); |
80 | 79 | ||
81 | static acpi_status | 80 | static acpi_status |
82 | acpi_ns_repair_PSS(struct acpi_predefined_data *data, | 81 | acpi_ns_repair_PSS(struct acpi_predefined_data *data, |
83 | union acpi_operand_object **return_object_ptr); | 82 | union acpi_operand_object **return_object_ptr); |
84 | 83 | ||
85 | static acpi_status | 84 | static acpi_status |
86 | acpi_ns_repair_TSS(struct acpi_predefined_data *data, | 85 | acpi_ns_repair_TSS(struct acpi_predefined_data *data, |
87 | union acpi_operand_object **return_object_ptr); | 86 | union acpi_operand_object **return_object_ptr); |
88 | 87 | ||
89 | static acpi_status | 88 | static acpi_status |
90 | acpi_ns_check_sorted_list(struct acpi_predefined_data *data, | 89 | acpi_ns_check_sorted_list(struct acpi_predefined_data *data, |
91 | union acpi_operand_object *return_object, | 90 | union acpi_operand_object *return_object, |
92 | u32 expected_count, | 91 | u32 expected_count, |
93 | u32 sort_index, | 92 | u32 sort_index, |
94 | u8 sort_direction, char *sort_key_name); | 93 | u8 sort_direction, char *sort_key_name); |
95 | 94 | ||
96 | static void | 95 | static void |
97 | acpi_ns_sort_list(union acpi_operand_object **elements, | 96 | acpi_ns_sort_list(union acpi_operand_object **elements, |
98 | u32 count, u32 index, u8 sort_direction); | 97 | u32 count, u32 index, u8 sort_direction); |
99 | 98 | ||
100 | /* Values for sort_direction above */ | 99 | /* Values for sort_direction above */ |
101 | 100 | ||
102 | #define ACPI_SORT_ASCENDING 0 | 101 | #define ACPI_SORT_ASCENDING 0 |
103 | #define ACPI_SORT_DESCENDING 1 | 102 | #define ACPI_SORT_DESCENDING 1 |
104 | 103 | ||
105 | /* | 104 | /* |
106 | * This table contains the names of the predefined methods for which we can | 105 | * This table contains the names of the predefined methods for which we can |
107 | * perform more complex repairs. | 106 | * perform more complex repairs. |
108 | * | 107 | * |
109 | * As necessary: | 108 | * As necessary: |
110 | * | 109 | * |
111 | * _ALR: Sort the list ascending by ambient_illuminance | 110 | * _ALR: Sort the list ascending by ambient_illuminance |
112 | * _FDE: Convert Buffer of BYTEs to a Buffer of DWORDs | 111 | * _FDE: Convert Buffer of BYTEs to a Buffer of DWORDs |
113 | * _GTM: Convert Buffer of BYTEs to a Buffer of DWORDs | 112 | * _GTM: Convert Buffer of BYTEs to a Buffer of DWORDs |
114 | * _PSS: Sort the list descending by Power | 113 | * _PSS: Sort the list descending by Power |
115 | * _TSS: Sort the list descending by Power | 114 | * _TSS: Sort the list descending by Power |
116 | */ | 115 | */ |
117 | static const struct acpi_repair_info acpi_ns_repairable_names[] = { | 116 | static const struct acpi_repair_info acpi_ns_repairable_names[] = { |
118 | {"_ALR", acpi_ns_repair_ALR}, | 117 | {"_ALR", acpi_ns_repair_ALR}, |
119 | {"_FDE", acpi_ns_repair_FDE}, | 118 | {"_FDE", acpi_ns_repair_FDE}, |
120 | {"_GTM", acpi_ns_repair_FDE}, /* _GTM has same repair as _FDE */ | 119 | {"_GTM", acpi_ns_repair_FDE}, /* _GTM has same repair as _FDE */ |
121 | {"_PSS", acpi_ns_repair_PSS}, | 120 | {"_PSS", acpi_ns_repair_PSS}, |
122 | {"_TSS", acpi_ns_repair_TSS}, | 121 | {"_TSS", acpi_ns_repair_TSS}, |
123 | {{0, 0, 0, 0}, NULL} /* Table terminator */ | 122 | {{0, 0, 0, 0}, NULL} /* Table terminator */ |
124 | }; | 123 | }; |
125 | 124 | ||
126 | #define ACPI_FDE_FIELD_COUNT 5 | 125 | #define ACPI_FDE_FIELD_COUNT 5 |
127 | #define ACPI_FDE_BYTE_BUFFER_SIZE 5 | 126 | #define ACPI_FDE_BYTE_BUFFER_SIZE 5 |
128 | #define ACPI_FDE_DWORD_BUFFER_SIZE (ACPI_FDE_FIELD_COUNT * sizeof (u32)) | 127 | #define ACPI_FDE_DWORD_BUFFER_SIZE (ACPI_FDE_FIELD_COUNT * sizeof (u32)) |
129 | 128 | ||
130 | /****************************************************************************** | 129 | /****************************************************************************** |
131 | * | 130 | * |
132 | * FUNCTION: acpi_ns_complex_repairs | 131 | * FUNCTION: acpi_ns_complex_repairs |
133 | * | 132 | * |
134 | * PARAMETERS: Data - Pointer to validation data structure | 133 | * PARAMETERS: Data - Pointer to validation data structure |
135 | * Node - Namespace node for the method/object | 134 | * Node - Namespace node for the method/object |
136 | * validate_status - Original status of earlier validation | 135 | * validate_status - Original status of earlier validation |
137 | * return_object_ptr - Pointer to the object returned from the | 136 | * return_object_ptr - Pointer to the object returned from the |
138 | * evaluation of a method or object | 137 | * evaluation of a method or object |
139 | * | 138 | * |
140 | * RETURN: Status. AE_OK if repair was successful. If name is not | 139 | * RETURN: Status. AE_OK if repair was successful. If name is not |
141 | * matched, validate_status is returned. | 140 | * matched, validate_status is returned. |
142 | * | 141 | * |
143 | * DESCRIPTION: Attempt to repair/convert a return object of a type that was | 142 | * DESCRIPTION: Attempt to repair/convert a return object of a type that was |
144 | * not expected. | 143 | * not expected. |
145 | * | 144 | * |
146 | *****************************************************************************/ | 145 | *****************************************************************************/ |
147 | 146 | ||
148 | acpi_status | 147 | acpi_status |
149 | acpi_ns_complex_repairs(struct acpi_predefined_data *data, | 148 | acpi_ns_complex_repairs(struct acpi_predefined_data *data, |
150 | struct acpi_namespace_node *node, | 149 | struct acpi_namespace_node *node, |
151 | acpi_status validate_status, | 150 | acpi_status validate_status, |
152 | union acpi_operand_object **return_object_ptr) | 151 | union acpi_operand_object **return_object_ptr) |
153 | { | 152 | { |
154 | const struct acpi_repair_info *predefined; | 153 | const struct acpi_repair_info *predefined; |
155 | acpi_status status; | 154 | acpi_status status; |
156 | 155 | ||
157 | /* Check if this name is in the list of repairable names */ | 156 | /* Check if this name is in the list of repairable names */ |
158 | 157 | ||
159 | predefined = acpi_ns_match_repairable_name(node); | 158 | predefined = acpi_ns_match_repairable_name(node); |
160 | if (!predefined) { | 159 | if (!predefined) { |
161 | return (validate_status); | 160 | return (validate_status); |
162 | } | 161 | } |
163 | 162 | ||
164 | status = predefined->repair_function(data, return_object_ptr); | 163 | status = predefined->repair_function(data, return_object_ptr); |
165 | return (status); | 164 | return (status); |
166 | } | 165 | } |
167 | 166 | ||
168 | /****************************************************************************** | 167 | /****************************************************************************** |
169 | * | 168 | * |
170 | * FUNCTION: acpi_ns_match_repairable_name | 169 | * FUNCTION: acpi_ns_match_repairable_name |
171 | * | 170 | * |
172 | * PARAMETERS: Node - Namespace node for the method/object | 171 | * PARAMETERS: Node - Namespace node for the method/object |
173 | * | 172 | * |
174 | * RETURN: Pointer to entry in repair table. NULL indicates not found. | 173 | * RETURN: Pointer to entry in repair table. NULL indicates not found. |
175 | * | 174 | * |
176 | * DESCRIPTION: Check an object name against the repairable object list. | 175 | * DESCRIPTION: Check an object name against the repairable object list. |
177 | * | 176 | * |
178 | *****************************************************************************/ | 177 | *****************************************************************************/ |
179 | 178 | ||
180 | static const struct acpi_repair_info *acpi_ns_match_repairable_name(struct | 179 | static const struct acpi_repair_info *acpi_ns_match_repairable_name(struct |
181 | acpi_namespace_node | 180 | acpi_namespace_node |
182 | *node) | 181 | *node) |
183 | { | 182 | { |
184 | const struct acpi_repair_info *this_name; | 183 | const struct acpi_repair_info *this_name; |
185 | 184 | ||
186 | /* Search info table for a repairable predefined method/object name */ | 185 | /* Search info table for a repairable predefined method/object name */ |
187 | 186 | ||
188 | this_name = acpi_ns_repairable_names; | 187 | this_name = acpi_ns_repairable_names; |
189 | while (this_name->repair_function) { | 188 | while (this_name->repair_function) { |
190 | if (ACPI_COMPARE_NAME(node->name.ascii, this_name->name)) { | 189 | if (ACPI_COMPARE_NAME(node->name.ascii, this_name->name)) { |
191 | return (this_name); | 190 | return (this_name); |
192 | } | 191 | } |
193 | this_name++; | 192 | this_name++; |
194 | } | 193 | } |
195 | 194 | ||
196 | return (NULL); /* Not found */ | 195 | return (NULL); /* Not found */ |
197 | } | 196 | } |
198 | 197 | ||
199 | /****************************************************************************** | 198 | /****************************************************************************** |
200 | * | 199 | * |
201 | * FUNCTION: acpi_ns_repair_ALR | 200 | * FUNCTION: acpi_ns_repair_ALR |
202 | * | 201 | * |
203 | * PARAMETERS: Data - Pointer to validation data structure | 202 | * PARAMETERS: Data - Pointer to validation data structure |
204 | * return_object_ptr - Pointer to the object returned from the | 203 | * return_object_ptr - Pointer to the object returned from the |
205 | * evaluation of a method or object | 204 | * evaluation of a method or object |
206 | * | 205 | * |
207 | * RETURN: Status. AE_OK if object is OK or was repaired successfully | 206 | * RETURN: Status. AE_OK if object is OK or was repaired successfully |
208 | * | 207 | * |
209 | * DESCRIPTION: Repair for the _ALR object. If necessary, sort the object list | 208 | * DESCRIPTION: Repair for the _ALR object. If necessary, sort the object list |
210 | * ascending by the ambient illuminance values. | 209 | * ascending by the ambient illuminance values. |
211 | * | 210 | * |
212 | *****************************************************************************/ | 211 | *****************************************************************************/ |
213 | 212 | ||
214 | static acpi_status | 213 | static acpi_status |
215 | acpi_ns_repair_ALR(struct acpi_predefined_data *data, | 214 | acpi_ns_repair_ALR(struct acpi_predefined_data *data, |
216 | union acpi_operand_object **return_object_ptr) | 215 | union acpi_operand_object **return_object_ptr) |
217 | { | 216 | { |
218 | union acpi_operand_object *return_object = *return_object_ptr; | 217 | union acpi_operand_object *return_object = *return_object_ptr; |
219 | acpi_status status; | 218 | acpi_status status; |
220 | 219 | ||
221 | status = acpi_ns_check_sorted_list(data, return_object, 2, 1, | 220 | status = acpi_ns_check_sorted_list(data, return_object, 2, 1, |
222 | ACPI_SORT_ASCENDING, | 221 | ACPI_SORT_ASCENDING, |
223 | "AmbientIlluminance"); | 222 | "AmbientIlluminance"); |
224 | 223 | ||
225 | return (status); | 224 | return (status); |
226 | } | 225 | } |
227 | 226 | ||
228 | /****************************************************************************** | 227 | /****************************************************************************** |
229 | * | 228 | * |
230 | * FUNCTION: acpi_ns_repair_FDE | 229 | * FUNCTION: acpi_ns_repair_FDE |
231 | * | 230 | * |
232 | * PARAMETERS: Data - Pointer to validation data structure | 231 | * PARAMETERS: Data - Pointer to validation data structure |
233 | * return_object_ptr - Pointer to the object returned from the | 232 | * return_object_ptr - Pointer to the object returned from the |
234 | * evaluation of a method or object | 233 | * evaluation of a method or object |
235 | * | 234 | * |
236 | * RETURN: Status. AE_OK if object is OK or was repaired successfully | 235 | * RETURN: Status. AE_OK if object is OK or was repaired successfully |
237 | * | 236 | * |
238 | * DESCRIPTION: Repair for the _FDE and _GTM objects. The expected return | 237 | * DESCRIPTION: Repair for the _FDE and _GTM objects. The expected return |
239 | * value is a Buffer of 5 DWORDs. This function repairs a common | 238 | * value is a Buffer of 5 DWORDs. This function repairs a common |
240 | * problem where the return value is a Buffer of BYTEs, not | 239 | * problem where the return value is a Buffer of BYTEs, not |
241 | * DWORDs. | 240 | * DWORDs. |
242 | * | 241 | * |
243 | *****************************************************************************/ | 242 | *****************************************************************************/ |
244 | 243 | ||
245 | static acpi_status | 244 | static acpi_status |
246 | acpi_ns_repair_FDE(struct acpi_predefined_data *data, | 245 | acpi_ns_repair_FDE(struct acpi_predefined_data *data, |
247 | union acpi_operand_object **return_object_ptr) | 246 | union acpi_operand_object **return_object_ptr) |
248 | { | 247 | { |
249 | union acpi_operand_object *return_object = *return_object_ptr; | 248 | union acpi_operand_object *return_object = *return_object_ptr; |
250 | union acpi_operand_object *buffer_object; | 249 | union acpi_operand_object *buffer_object; |
251 | u8 *byte_buffer; | 250 | u8 *byte_buffer; |
252 | u32 *dword_buffer; | 251 | u32 *dword_buffer; |
253 | u32 i; | 252 | u32 i; |
254 | 253 | ||
255 | ACPI_FUNCTION_NAME(ns_repair_FDE); | 254 | ACPI_FUNCTION_NAME(ns_repair_FDE); |
256 | 255 | ||
257 | switch (return_object->common.type) { | 256 | switch (return_object->common.type) { |
258 | case ACPI_TYPE_BUFFER: | 257 | case ACPI_TYPE_BUFFER: |
259 | 258 | ||
260 | /* This is the expected type. Length should be (at least) 5 DWORDs */ | 259 | /* This is the expected type. Length should be (at least) 5 DWORDs */ |
261 | 260 | ||
262 | if (return_object->buffer.length >= ACPI_FDE_DWORD_BUFFER_SIZE) { | 261 | if (return_object->buffer.length >= ACPI_FDE_DWORD_BUFFER_SIZE) { |
263 | return (AE_OK); | 262 | return (AE_OK); |
264 | } | 263 | } |
265 | 264 | ||
266 | /* We can only repair if we have exactly 5 BYTEs */ | 265 | /* We can only repair if we have exactly 5 BYTEs */ |
267 | 266 | ||
268 | if (return_object->buffer.length != ACPI_FDE_BYTE_BUFFER_SIZE) { | 267 | if (return_object->buffer.length != ACPI_FDE_BYTE_BUFFER_SIZE) { |
269 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, | 268 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, |
270 | data->node_flags, | 269 | data->node_flags, |
271 | "Incorrect return buffer length %u, expected %u", | 270 | "Incorrect return buffer length %u, expected %u", |
272 | return_object->buffer.length, | 271 | return_object->buffer.length, |
273 | ACPI_FDE_DWORD_BUFFER_SIZE)); | 272 | ACPI_FDE_DWORD_BUFFER_SIZE)); |
274 | 273 | ||
275 | return (AE_AML_OPERAND_TYPE); | 274 | return (AE_AML_OPERAND_TYPE); |
276 | } | 275 | } |
277 | 276 | ||
278 | /* Create the new (larger) buffer object */ | 277 | /* Create the new (larger) buffer object */ |
279 | 278 | ||
280 | buffer_object = | 279 | buffer_object = |
281 | acpi_ut_create_buffer_object(ACPI_FDE_DWORD_BUFFER_SIZE); | 280 | acpi_ut_create_buffer_object(ACPI_FDE_DWORD_BUFFER_SIZE); |
282 | if (!buffer_object) { | 281 | if (!buffer_object) { |
283 | return (AE_NO_MEMORY); | 282 | return (AE_NO_MEMORY); |
284 | } | 283 | } |
285 | 284 | ||
286 | /* Expand each byte to a DWORD */ | 285 | /* Expand each byte to a DWORD */ |
287 | 286 | ||
288 | byte_buffer = return_object->buffer.pointer; | 287 | byte_buffer = return_object->buffer.pointer; |
289 | dword_buffer = | 288 | dword_buffer = |
290 | ACPI_CAST_PTR(u32, buffer_object->buffer.pointer); | 289 | ACPI_CAST_PTR(u32, buffer_object->buffer.pointer); |
291 | 290 | ||
292 | for (i = 0; i < ACPI_FDE_FIELD_COUNT; i++) { | 291 | for (i = 0; i < ACPI_FDE_FIELD_COUNT; i++) { |
293 | *dword_buffer = (u32) *byte_buffer; | 292 | *dword_buffer = (u32) *byte_buffer; |
294 | dword_buffer++; | 293 | dword_buffer++; |
295 | byte_buffer++; | 294 | byte_buffer++; |
296 | } | 295 | } |
297 | 296 | ||
298 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, | 297 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, |
299 | "%s Expanded Byte Buffer to expected DWord Buffer\n", | 298 | "%s Expanded Byte Buffer to expected DWord Buffer\n", |
300 | data->pathname)); | 299 | data->pathname)); |
301 | break; | 300 | break; |
302 | 301 | ||
303 | default: | 302 | default: |
304 | return (AE_AML_OPERAND_TYPE); | 303 | return (AE_AML_OPERAND_TYPE); |
305 | } | 304 | } |
306 | 305 | ||
307 | /* Delete the original return object, return the new buffer object */ | 306 | /* Delete the original return object, return the new buffer object */ |
308 | 307 | ||
309 | acpi_ut_remove_reference(return_object); | 308 | acpi_ut_remove_reference(return_object); |
310 | *return_object_ptr = buffer_object; | 309 | *return_object_ptr = buffer_object; |
311 | 310 | ||
312 | data->flags |= ACPI_OBJECT_REPAIRED; | 311 | data->flags |= ACPI_OBJECT_REPAIRED; |
313 | return (AE_OK); | 312 | return (AE_OK); |
314 | } | 313 | } |
315 | 314 | ||
316 | /****************************************************************************** | 315 | /****************************************************************************** |
317 | * | 316 | * |
318 | * FUNCTION: acpi_ns_repair_TSS | 317 | * FUNCTION: acpi_ns_repair_TSS |
319 | * | 318 | * |
320 | * PARAMETERS: Data - Pointer to validation data structure | 319 | * PARAMETERS: Data - Pointer to validation data structure |
321 | * return_object_ptr - Pointer to the object returned from the | 320 | * return_object_ptr - Pointer to the object returned from the |
322 | * evaluation of a method or object | 321 | * evaluation of a method or object |
323 | * | 322 | * |
324 | * RETURN: Status. AE_OK if object is OK or was repaired successfully | 323 | * RETURN: Status. AE_OK if object is OK or was repaired successfully |
325 | * | 324 | * |
326 | * DESCRIPTION: Repair for the _TSS object. If necessary, sort the object list | 325 | * DESCRIPTION: Repair for the _TSS object. If necessary, sort the object list |
327 | * descending by the power dissipation values. | 326 | * descending by the power dissipation values. |
328 | * | 327 | * |
329 | *****************************************************************************/ | 328 | *****************************************************************************/ |
330 | 329 | ||
331 | static acpi_status | 330 | static acpi_status |
332 | acpi_ns_repair_TSS(struct acpi_predefined_data *data, | 331 | acpi_ns_repair_TSS(struct acpi_predefined_data *data, |
333 | union acpi_operand_object **return_object_ptr) | 332 | union acpi_operand_object **return_object_ptr) |
334 | { | 333 | { |
335 | union acpi_operand_object *return_object = *return_object_ptr; | 334 | union acpi_operand_object *return_object = *return_object_ptr; |
336 | acpi_status status; | 335 | acpi_status status; |
337 | 336 | ||
338 | status = acpi_ns_check_sorted_list(data, return_object, 5, 1, | 337 | status = acpi_ns_check_sorted_list(data, return_object, 5, 1, |
339 | ACPI_SORT_DESCENDING, | 338 | ACPI_SORT_DESCENDING, |
340 | "PowerDissipation"); | 339 | "PowerDissipation"); |
341 | 340 | ||
342 | return (status); | 341 | return (status); |
343 | } | 342 | } |
344 | 343 | ||
345 | /****************************************************************************** | 344 | /****************************************************************************** |
346 | * | 345 | * |
347 | * FUNCTION: acpi_ns_repair_PSS | 346 | * FUNCTION: acpi_ns_repair_PSS |
348 | * | 347 | * |
349 | * PARAMETERS: Data - Pointer to validation data structure | 348 | * PARAMETERS: Data - Pointer to validation data structure |
350 | * return_object_ptr - Pointer to the object returned from the | 349 | * return_object_ptr - Pointer to the object returned from the |
351 | * evaluation of a method or object | 350 | * evaluation of a method or object |
352 | * | 351 | * |
353 | * RETURN: Status. AE_OK if object is OK or was repaired successfully | 352 | * RETURN: Status. AE_OK if object is OK or was repaired successfully |
354 | * | 353 | * |
355 | * DESCRIPTION: Repair for the _PSS object. If necessary, sort the object list | 354 | * DESCRIPTION: Repair for the _PSS object. If necessary, sort the object list |
356 | * by the CPU frequencies. Check that the power dissipation values | 355 | * by the CPU frequencies. Check that the power dissipation values |
357 | * are all proportional to CPU frequency (i.e., sorting by | 356 | * are all proportional to CPU frequency (i.e., sorting by |
358 | * frequency should be the same as sorting by power.) | 357 | * frequency should be the same as sorting by power.) |
359 | * | 358 | * |
360 | *****************************************************************************/ | 359 | *****************************************************************************/ |
361 | 360 | ||
362 | static acpi_status | 361 | static acpi_status |
363 | acpi_ns_repair_PSS(struct acpi_predefined_data *data, | 362 | acpi_ns_repair_PSS(struct acpi_predefined_data *data, |
364 | union acpi_operand_object **return_object_ptr) | 363 | union acpi_operand_object **return_object_ptr) |
365 | { | 364 | { |
366 | union acpi_operand_object *return_object = *return_object_ptr; | 365 | union acpi_operand_object *return_object = *return_object_ptr; |
367 | union acpi_operand_object **outer_elements; | 366 | union acpi_operand_object **outer_elements; |
368 | u32 outer_element_count; | 367 | u32 outer_element_count; |
369 | union acpi_operand_object **elements; | 368 | union acpi_operand_object **elements; |
370 | union acpi_operand_object *obj_desc; | 369 | union acpi_operand_object *obj_desc; |
371 | u32 previous_value; | 370 | u32 previous_value; |
372 | acpi_status status; | 371 | acpi_status status; |
373 | u32 i; | 372 | u32 i; |
374 | 373 | ||
375 | /* | 374 | /* |
376 | * Entries (sub-packages) in the _PSS Package must be sorted by power | 375 | * Entries (sub-packages) in the _PSS Package must be sorted by power |
377 | * dissipation, in descending order. If it appears that the list is | 376 | * dissipation, in descending order. If it appears that the list is |
378 | * incorrectly sorted, sort it. We sort by cpu_frequency, since this | 377 | * incorrectly sorted, sort it. We sort by cpu_frequency, since this |
379 | * should be proportional to the power. | 378 | * should be proportional to the power. |
380 | */ | 379 | */ |
381 | status = acpi_ns_check_sorted_list(data, return_object, 6, 0, | 380 | status = acpi_ns_check_sorted_list(data, return_object, 6, 0, |
382 | ACPI_SORT_DESCENDING, | 381 | ACPI_SORT_DESCENDING, |
383 | "CpuFrequency"); | 382 | "CpuFrequency"); |
384 | if (ACPI_FAILURE(status)) { | 383 | if (ACPI_FAILURE(status)) { |
385 | return (status); | 384 | return (status); |
386 | } | 385 | } |
387 | 386 | ||
388 | /* | 387 | /* |
389 | * We now know the list is correctly sorted by CPU frequency. Check if | 388 | * We now know the list is correctly sorted by CPU frequency. Check if |
390 | * the power dissipation values are proportional. | 389 | * the power dissipation values are proportional. |
391 | */ | 390 | */ |
392 | previous_value = ACPI_UINT32_MAX; | 391 | previous_value = ACPI_UINT32_MAX; |
393 | outer_elements = return_object->package.elements; | 392 | outer_elements = return_object->package.elements; |
394 | outer_element_count = return_object->package.count; | 393 | outer_element_count = return_object->package.count; |
395 | 394 | ||
396 | for (i = 0; i < outer_element_count; i++) { | 395 | for (i = 0; i < outer_element_count; i++) { |
397 | elements = (*outer_elements)->package.elements; | 396 | elements = (*outer_elements)->package.elements; |
398 | obj_desc = elements[1]; /* Index1 = power_dissipation */ | 397 | obj_desc = elements[1]; /* Index1 = power_dissipation */ |
399 | 398 | ||
400 | if ((u32) obj_desc->integer.value > previous_value) { | 399 | if ((u32) obj_desc->integer.value > previous_value) { |
401 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, | 400 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, |
402 | data->node_flags, | 401 | data->node_flags, |
403 | "SubPackage[%u,%u] - suspicious power dissipation values", | 402 | "SubPackage[%u,%u] - suspicious power dissipation values", |
404 | i - 1, i)); | 403 | i - 1, i)); |
405 | } | 404 | } |
406 | 405 | ||
407 | previous_value = (u32) obj_desc->integer.value; | 406 | previous_value = (u32) obj_desc->integer.value; |
408 | outer_elements++; | 407 | outer_elements++; |
409 | } | 408 | } |
410 | 409 | ||
411 | return (AE_OK); | 410 | return (AE_OK); |
412 | } | 411 | } |
413 | 412 | ||
414 | /****************************************************************************** | 413 | /****************************************************************************** |
415 | * | 414 | * |
416 | * FUNCTION: acpi_ns_check_sorted_list | 415 | * FUNCTION: acpi_ns_check_sorted_list |
417 | * | 416 | * |
418 | * PARAMETERS: Data - Pointer to validation data structure | 417 | * PARAMETERS: Data - Pointer to validation data structure |
419 | * return_object - Pointer to the top-level returned object | 418 | * return_object - Pointer to the top-level returned object |
420 | * expected_count - Minimum length of each sub-package | 419 | * expected_count - Minimum length of each sub-package |
421 | * sort_index - Sub-package entry to sort on | 420 | * sort_index - Sub-package entry to sort on |
422 | * sort_direction - Ascending or descending | 421 | * sort_direction - Ascending or descending |
423 | * sort_key_name - Name of the sort_index field | 422 | * sort_key_name - Name of the sort_index field |
424 | * | 423 | * |
425 | * RETURN: Status. AE_OK if the list is valid and is sorted correctly or | 424 | * RETURN: Status. AE_OK if the list is valid and is sorted correctly or |
426 | * has been repaired by sorting the list. | 425 | * has been repaired by sorting the list. |
427 | * | 426 | * |
428 | * DESCRIPTION: Check if the package list is valid and sorted correctly by the | 427 | * DESCRIPTION: Check if the package list is valid and sorted correctly by the |
429 | * sort_index. If not, then sort the list. | 428 | * sort_index. If not, then sort the list. |
430 | * | 429 | * |
431 | *****************************************************************************/ | 430 | *****************************************************************************/ |
432 | 431 | ||
433 | static acpi_status | 432 | static acpi_status |
434 | acpi_ns_check_sorted_list(struct acpi_predefined_data *data, | 433 | acpi_ns_check_sorted_list(struct acpi_predefined_data *data, |
435 | union acpi_operand_object *return_object, | 434 | union acpi_operand_object *return_object, |
436 | u32 expected_count, | 435 | u32 expected_count, |
437 | u32 sort_index, | 436 | u32 sort_index, |
438 | u8 sort_direction, char *sort_key_name) | 437 | u8 sort_direction, char *sort_key_name) |
439 | { | 438 | { |
440 | u32 outer_element_count; | 439 | u32 outer_element_count; |
441 | union acpi_operand_object **outer_elements; | 440 | union acpi_operand_object **outer_elements; |
442 | union acpi_operand_object **elements; | 441 | union acpi_operand_object **elements; |
443 | union acpi_operand_object *obj_desc; | 442 | union acpi_operand_object *obj_desc; |
444 | u32 i; | 443 | u32 i; |
445 | u32 previous_value; | 444 | u32 previous_value; |
446 | 445 | ||
447 | ACPI_FUNCTION_NAME(ns_check_sorted_list); | 446 | ACPI_FUNCTION_NAME(ns_check_sorted_list); |
448 | 447 | ||
449 | /* The top-level object must be a package */ | 448 | /* The top-level object must be a package */ |
450 | 449 | ||
451 | if (return_object->common.type != ACPI_TYPE_PACKAGE) { | 450 | if (return_object->common.type != ACPI_TYPE_PACKAGE) { |
452 | return (AE_AML_OPERAND_TYPE); | 451 | return (AE_AML_OPERAND_TYPE); |
453 | } | 452 | } |
454 | 453 | ||
455 | /* | 454 | /* |
456 | * NOTE: assumes list of sub-packages contains no NULL elements. | 455 | * NOTE: assumes list of sub-packages contains no NULL elements. |
457 | * Any NULL elements should have been removed by earlier call | 456 | * Any NULL elements should have been removed by earlier call |
458 | * to acpi_ns_remove_null_elements. | 457 | * to acpi_ns_remove_null_elements. |
459 | */ | 458 | */ |
460 | outer_elements = return_object->package.elements; | 459 | outer_elements = return_object->package.elements; |
461 | outer_element_count = return_object->package.count; | 460 | outer_element_count = return_object->package.count; |
462 | if (!outer_element_count) { | 461 | if (!outer_element_count) { |
463 | return (AE_AML_PACKAGE_LIMIT); | 462 | return (AE_AML_PACKAGE_LIMIT); |
464 | } | 463 | } |
465 | 464 | ||
466 | previous_value = 0; | 465 | previous_value = 0; |
467 | if (sort_direction == ACPI_SORT_DESCENDING) { | 466 | if (sort_direction == ACPI_SORT_DESCENDING) { |
468 | previous_value = ACPI_UINT32_MAX; | 467 | previous_value = ACPI_UINT32_MAX; |
469 | } | 468 | } |
470 | 469 | ||
471 | /* Examine each subpackage */ | 470 | /* Examine each subpackage */ |
472 | 471 | ||
473 | for (i = 0; i < outer_element_count; i++) { | 472 | for (i = 0; i < outer_element_count; i++) { |
474 | 473 | ||
475 | /* Each element of the top-level package must also be a package */ | 474 | /* Each element of the top-level package must also be a package */ |
476 | 475 | ||
477 | if ((*outer_elements)->common.type != ACPI_TYPE_PACKAGE) { | 476 | if ((*outer_elements)->common.type != ACPI_TYPE_PACKAGE) { |
478 | return (AE_AML_OPERAND_TYPE); | 477 | return (AE_AML_OPERAND_TYPE); |
479 | } | 478 | } |
480 | 479 | ||
481 | /* Each sub-package must have the minimum length */ | 480 | /* Each sub-package must have the minimum length */ |
482 | 481 | ||
483 | if ((*outer_elements)->package.count < expected_count) { | 482 | if ((*outer_elements)->package.count < expected_count) { |
484 | return (AE_AML_PACKAGE_LIMIT); | 483 | return (AE_AML_PACKAGE_LIMIT); |
485 | } | 484 | } |
486 | 485 | ||
487 | elements = (*outer_elements)->package.elements; | 486 | elements = (*outer_elements)->package.elements; |
488 | obj_desc = elements[sort_index]; | 487 | obj_desc = elements[sort_index]; |
489 | 488 | ||
490 | if (obj_desc->common.type != ACPI_TYPE_INTEGER) { | 489 | if (obj_desc->common.type != ACPI_TYPE_INTEGER) { |
491 | return (AE_AML_OPERAND_TYPE); | 490 | return (AE_AML_OPERAND_TYPE); |
492 | } | 491 | } |
493 | 492 | ||
494 | /* | 493 | /* |
495 | * The list must be sorted in the specified order. If we detect a | 494 | * The list must be sorted in the specified order. If we detect a |
496 | * discrepancy, sort the entire list. | 495 | * discrepancy, sort the entire list. |
497 | */ | 496 | */ |
498 | if (((sort_direction == ACPI_SORT_ASCENDING) && | 497 | if (((sort_direction == ACPI_SORT_ASCENDING) && |
499 | (obj_desc->integer.value < previous_value)) || | 498 | (obj_desc->integer.value < previous_value)) || |
500 | ((sort_direction == ACPI_SORT_DESCENDING) && | 499 | ((sort_direction == ACPI_SORT_DESCENDING) && |
501 | (obj_desc->integer.value > previous_value))) { | 500 | (obj_desc->integer.value > previous_value))) { |
502 | acpi_ns_sort_list(return_object->package.elements, | 501 | acpi_ns_sort_list(return_object->package.elements, |
503 | outer_element_count, sort_index, | 502 | outer_element_count, sort_index, |
504 | sort_direction); | 503 | sort_direction); |
505 | 504 | ||
506 | data->flags |= ACPI_OBJECT_REPAIRED; | 505 | data->flags |= ACPI_OBJECT_REPAIRED; |
507 | 506 | ||
508 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, | 507 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, |
509 | "%s: Repaired unsorted list - now sorted by %s\n", | 508 | "%s: Repaired unsorted list - now sorted by %s\n", |
510 | data->pathname, sort_key_name)); | 509 | data->pathname, sort_key_name)); |
511 | return (AE_OK); | 510 | return (AE_OK); |
512 | } | 511 | } |
513 | 512 | ||
514 | previous_value = (u32) obj_desc->integer.value; | 513 | previous_value = (u32) obj_desc->integer.value; |
515 | outer_elements++; | 514 | outer_elements++; |
516 | } | 515 | } |
517 | 516 | ||
518 | return (AE_OK); | 517 | return (AE_OK); |
519 | } | ||
520 | |||
521 | /****************************************************************************** | ||
522 | * | ||
523 | * FUNCTION: acpi_ns_remove_null_elements | ||
524 | * | ||
525 | * PARAMETERS: Data - Pointer to validation data structure | ||
526 | * package_type - An acpi_return_package_types value | ||
527 | * obj_desc - A Package object | ||
528 | * | ||
529 | * RETURN: None. | ||
530 | * | ||
531 | * DESCRIPTION: Remove all NULL package elements from packages that contain | ||
532 | * a variable number of sub-packages. | ||
533 | * | ||
534 | *****************************************************************************/ | ||
535 | |||
536 | void | ||
537 | acpi_ns_remove_null_elements(struct acpi_predefined_data *data, | ||
538 | u8 package_type, | ||
539 | union acpi_operand_object *obj_desc) | ||
540 | { | ||
541 | union acpi_operand_object **source; | ||
542 | union acpi_operand_object **dest; | ||
543 | u32 count; | ||
544 | u32 new_count; | ||
545 | u32 i; | ||
546 | |||
547 | ACPI_FUNCTION_NAME(ns_remove_null_elements); | ||
548 | |||
549 | /* | ||
550 | * PTYPE1 packages contain no subpackages. | ||
551 | * PTYPE2 packages contain a variable number of sub-packages. We can | ||
552 | * safely remove all NULL elements from the PTYPE2 packages. | ||
553 | */ | ||
554 | switch (package_type) { | ||
555 | case ACPI_PTYPE1_FIXED: | ||
556 | case ACPI_PTYPE1_VAR: | ||
557 | case ACPI_PTYPE1_OPTION: | ||
558 | return; | ||
559 | |||
560 | case ACPI_PTYPE2: | ||
561 | case ACPI_PTYPE2_COUNT: | ||
562 | case ACPI_PTYPE2_PKG_COUNT: | ||
563 | case ACPI_PTYPE2_FIXED: | ||
564 | case ACPI_PTYPE2_MIN: | ||
565 | case ACPI_PTYPE2_REV_FIXED: | ||
566 | break; | ||
567 | |||
568 | default: | ||
569 | return; | ||
570 | } | ||
571 | |||
572 | count = obj_desc->package.count; | ||
573 | new_count = count; | ||
574 | |||
575 | source = obj_desc->package.elements; | ||
576 | dest = source; | ||
577 | |||
578 | /* Examine all elements of the package object, remove nulls */ | ||
579 | |||
580 | for (i = 0; i < count; i++) { | ||
581 | if (!*source) { | ||
582 | new_count--; | ||
583 | } else { | ||
584 | *dest = *source; | ||
585 | dest++; | ||
586 | } | ||
587 | source++; | ||
588 | } | ||
589 | |||
590 | /* Update parent package if any null elements were removed */ | ||
591 | |||
592 | if (new_count < count) { | ||
593 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, | ||
594 | "%s: Found and removed %u NULL elements\n", | ||
595 | data->pathname, (count - new_count))); | ||
596 | |||
597 | /* NULL terminate list and update the package count */ | ||
598 | |||
599 | *dest = NULL; | ||
600 | obj_desc->package.count = new_count; | ||
601 | } | ||
602 | } | 518 | } |
603 | 519 | ||
604 | /****************************************************************************** | 520 | /****************************************************************************** |
605 | * | 521 | * |
606 | * FUNCTION: acpi_ns_sort_list | 522 | * FUNCTION: acpi_ns_sort_list |
607 | * | 523 | * |
608 | * PARAMETERS: Elements - Package object element list | 524 | * PARAMETERS: Elements - Package object element list |
609 | * Count - Element count for above | 525 | * Count - Element count for above |
610 | * Index - Sort by which package element | 526 | * Index - Sort by which package element |
611 | * sort_direction - Ascending or Descending sort | 527 | * sort_direction - Ascending or Descending sort |
612 | * | 528 | * |
613 | * RETURN: None | 529 | * RETURN: None |
614 | * | 530 | * |
615 | * DESCRIPTION: Sort the objects that are in a package element list. | 531 | * DESCRIPTION: Sort the objects that are in a package element list. |
616 | * | 532 | * |
617 | * NOTE: Assumes that all NULL elements have been removed from the package, | 533 | * NOTE: Assumes that all NULL elements have been removed from the package, |
618 | * and that all elements have been verified to be of type Integer. | 534 | * and that all elements have been verified to be of type Integer. |
619 | * | 535 | * |
620 | *****************************************************************************/ | 536 | *****************************************************************************/ |
621 | 537 | ||
622 | static void | 538 | static void |
623 | acpi_ns_sort_list(union acpi_operand_object **elements, | 539 | acpi_ns_sort_list(union acpi_operand_object **elements, |
624 | u32 count, u32 index, u8 sort_direction) | 540 | u32 count, u32 index, u8 sort_direction) |
625 | { | 541 | { |
626 | union acpi_operand_object *obj_desc1; | 542 | union acpi_operand_object *obj_desc1; |
627 | union acpi_operand_object *obj_desc2; | 543 | union acpi_operand_object *obj_desc2; |
628 | union acpi_operand_object *temp_obj; | 544 | union acpi_operand_object *temp_obj; |
629 | u32 i; | 545 | u32 i; |
630 | u32 j; | 546 | u32 j; |
631 | 547 | ||
632 | /* Simple bubble sort */ | 548 | /* Simple bubble sort */ |
633 | 549 | ||
634 | for (i = 1; i < count; i++) { | 550 | for (i = 1; i < count; i++) { |
635 | for (j = (count - 1); j >= i; j--) { | 551 | for (j = (count - 1); j >= i; j--) { |
636 | obj_desc1 = elements[j - 1]->package.elements[index]; | 552 | obj_desc1 = elements[j - 1]->package.elements[index]; |
637 | obj_desc2 = elements[j]->package.elements[index]; | 553 | obj_desc2 = elements[j]->package.elements[index]; |
638 | 554 | ||
639 | if (((sort_direction == ACPI_SORT_ASCENDING) && | 555 | if (((sort_direction == ACPI_SORT_ASCENDING) && |
640 | (obj_desc1->integer.value > | 556 | (obj_desc1->integer.value > |
641 | obj_desc2->integer.value)) | 557 | obj_desc2->integer.value)) |
642 | || ((sort_direction == ACPI_SORT_DESCENDING) | 558 | || ((sort_direction == ACPI_SORT_DESCENDING) |
643 | && (obj_desc1->integer.value < | 559 | && (obj_desc1->integer.value < |
644 | obj_desc2->integer.value))) { | 560 | obj_desc2->integer.value))) { |
645 | temp_obj = elements[j - 1]; | 561 | temp_obj = elements[j - 1]; |
646 | elements[j - 1] = elements[j]; | 562 | elements[j - 1] = elements[j]; |
647 | elements[j] = temp_obj; | 563 | elements[j] = temp_obj; |
648 | } | 564 | } |
649 | } | 565 | } |
650 | } | 566 | } |
651 | } | 567 | } |
652 | 568 |