Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Module Name: psargs - Parse AML opcode arguments |
| 4 | * |
| 5 | *****************************************************************************/ |
| 6 | |
| 7 | /* |
| 8 | * Copyright (C) 2000 - 2005, R. Byron Moore |
| 9 | * All rights reserved. |
| 10 | * |
| 11 | * Redistribution and use in source and binary forms, with or without |
| 12 | * modification, are permitted provided that the following conditions |
| 13 | * are met: |
| 14 | * 1. Redistributions of source code must retain the above copyright |
| 15 | * notice, this list of conditions, and the following disclaimer, |
| 16 | * without modification. |
| 17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
| 18 | * substantially similar to the "NO WARRANTY" disclaimer below |
| 19 | * ("Disclaimer") and any redistribution must be conditioned upon |
| 20 | * including a substantially similar Disclaimer requirement for further |
| 21 | * binary redistribution. |
| 22 | * 3. Neither the names of the above-listed copyright holders nor the names |
| 23 | * of any contributors may be used to endorse or promote products derived |
| 24 | * from this software without specific prior written permission. |
| 25 | * |
| 26 | * Alternatively, this software may be distributed under the terms of the |
| 27 | * GNU General Public License ("GPL") version 2 as published by the Free |
| 28 | * Software Foundation. |
| 29 | * |
| 30 | * NO WARRANTY |
| 31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR |
| 34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 41 | * POSSIBILITY OF SUCH DAMAGES. |
| 42 | */ |
| 43 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #include <acpi/acpi.h> |
| 45 | #include <acpi/acparser.h> |
| 46 | #include <acpi/amlcode.h> |
| 47 | #include <acpi/acnamesp.h> |
| 48 | |
| 49 | #define _COMPONENT ACPI_PARSER |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 50 | ACPI_MODULE_NAME("psargs") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 52 | /* Local prototypes */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 53 | static u32 |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 54 | acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 55 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 56 | static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state |
| 57 | *parser_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | |
| 59 | /******************************************************************************* |
| 60 | * |
| 61 | * FUNCTION: acpi_ps_get_next_package_length |
| 62 | * |
| 63 | * PARAMETERS: parser_state - Current parser state object |
| 64 | * |
| 65 | * RETURN: Decoded package length. On completion, the AML pointer points |
| 66 | * past the length byte or bytes. |
| 67 | * |
| 68 | * DESCRIPTION: Decode and return a package length field |
| 69 | * |
| 70 | ******************************************************************************/ |
| 71 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 72 | static u32 |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 73 | acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 75 | u32 encoded_length; |
| 76 | u32 length = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 78 | ACPI_FUNCTION_TRACE("ps_get_next_package_length"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 80 | encoded_length = (u32) ACPI_GET8(parser_state->aml); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | parser_state->aml++; |
| 82 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 83 | switch (encoded_length >> 6) { /* bits 6-7 contain encoding scheme */ |
| 84 | case 0: /* 1-byte encoding (bits 0-5) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | |
| 86 | length = (encoded_length & 0x3F); |
| 87 | break; |
| 88 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 89 | case 1: /* 2-byte encoding (next byte + bits 0-3) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 91 | length = ((ACPI_GET8(parser_state->aml) << 04) | |
| 92 | (encoded_length & 0x0F)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | parser_state->aml++; |
| 94 | break; |
| 95 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 96 | case 2: /* 3-byte encoding (next 2 bytes + bits 0-3) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 98 | length = ((ACPI_GET8(parser_state->aml + 1) << 12) | |
| 99 | (ACPI_GET8(parser_state->aml) << 04) | |
| 100 | (encoded_length & 0x0F)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | parser_state->aml += 2; |
| 102 | break; |
| 103 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 104 | case 3: /* 4-byte encoding (next 3 bytes + bits 0-3) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 106 | length = ((ACPI_GET8(parser_state->aml + 2) << 20) | |
| 107 | (ACPI_GET8(parser_state->aml + 1) << 12) | |
| 108 | (ACPI_GET8(parser_state->aml) << 04) | |
| 109 | (encoded_length & 0x0F)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | parser_state->aml += 3; |
| 111 | break; |
| 112 | |
| 113 | default: |
| 114 | |
| 115 | /* Can't get here, only 2 bits / 4 cases */ |
| 116 | break; |
| 117 | } |
| 118 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 119 | return_VALUE(length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | } |
| 121 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | /******************************************************************************* |
| 123 | * |
| 124 | * FUNCTION: acpi_ps_get_next_package_end |
| 125 | * |
| 126 | * PARAMETERS: parser_state - Current parser state object |
| 127 | * |
| 128 | * RETURN: Pointer to end-of-package +1 |
| 129 | * |
| 130 | * DESCRIPTION: Get next package length and return a pointer past the end of |
| 131 | * the package. Consumes the package length field |
| 132 | * |
| 133 | ******************************************************************************/ |
| 134 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 135 | u8 *acpi_ps_get_next_package_end(struct acpi_parse_state *parser_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 137 | u8 *start = parser_state->aml; |
| 138 | acpi_native_uint length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 140 | ACPI_FUNCTION_TRACE("ps_get_next_package_end"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | |
| 142 | /* Function below changes parser_state->Aml */ |
| 143 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 144 | length = |
| 145 | (acpi_native_uint) acpi_ps_get_next_package_length(parser_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 147 | return_PTR(start + length); /* end of package */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | } |
| 149 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | /******************************************************************************* |
| 151 | * |
| 152 | * FUNCTION: acpi_ps_get_next_namestring |
| 153 | * |
| 154 | * PARAMETERS: parser_state - Current parser state object |
| 155 | * |
| 156 | * RETURN: Pointer to the start of the name string (pointer points into |
| 157 | * the AML. |
| 158 | * |
| 159 | * DESCRIPTION: Get next raw namestring within the AML stream. Handles all name |
| 160 | * prefix characters. Set parser state to point past the string. |
| 161 | * (Name is consumed from the AML.) |
| 162 | * |
| 163 | ******************************************************************************/ |
| 164 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 165 | char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 167 | u8 *start = parser_state->aml; |
| 168 | u8 *end = parser_state->aml; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 170 | ACPI_FUNCTION_TRACE("ps_get_next_namestring"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | |
| 172 | /* Handle multiple prefix characters */ |
| 173 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 174 | while (acpi_ps_is_prefix_char(ACPI_GET8(end))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | /* Include prefix '\\' or '^' */ |
| 176 | |
| 177 | end++; |
| 178 | } |
| 179 | |
| 180 | /* Decode the path */ |
| 181 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 182 | switch (ACPI_GET8(end)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | case 0: |
| 184 | |
| 185 | /* null_name */ |
| 186 | |
| 187 | if (end == start) { |
| 188 | start = NULL; |
| 189 | } |
| 190 | end++; |
| 191 | break; |
| 192 | |
| 193 | case AML_DUAL_NAME_PREFIX: |
| 194 | |
| 195 | /* Two name segments */ |
| 196 | |
| 197 | end += 1 + (2 * ACPI_NAME_SIZE); |
| 198 | break; |
| 199 | |
| 200 | case AML_MULTI_NAME_PREFIX_OP: |
| 201 | |
| 202 | /* Multiple name segments, 4 chars each */ |
| 203 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 204 | end += 2 + ((acpi_size) ACPI_GET8(end + 1) * ACPI_NAME_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | break; |
| 206 | |
| 207 | default: |
| 208 | |
| 209 | /* Single name segment */ |
| 210 | |
| 211 | end += ACPI_NAME_SIZE; |
| 212 | break; |
| 213 | } |
| 214 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 215 | parser_state->aml = (u8 *) end; |
| 216 | return_PTR((char *)start); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | } |
| 218 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | /******************************************************************************* |
| 220 | * |
| 221 | * FUNCTION: acpi_ps_get_next_namepath |
| 222 | * |
| 223 | * PARAMETERS: parser_state - Current parser state object |
| 224 | * Arg - Where the namepath will be stored |
| 225 | * arg_count - If the namepath points to a control method |
| 226 | * the method's argument is returned here. |
| 227 | * method_call - Whether the namepath can possibly be the |
| 228 | * start of a method call |
| 229 | * |
| 230 | * RETURN: Status |
| 231 | * |
| 232 | * DESCRIPTION: Get next name (if method call, return # of required args). |
| 233 | * Names are looked up in the internal namespace to determine |
| 234 | * if the name represents a control method. If a method |
| 235 | * is found, the number of arguments to the method is returned. |
| 236 | * This information is critical for parsing to continue correctly. |
| 237 | * |
| 238 | ******************************************************************************/ |
| 239 | |
| 240 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 241 | acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state, |
| 242 | struct acpi_parse_state *parser_state, |
| 243 | union acpi_parse_object *arg, u8 method_call) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 245 | char *path; |
| 246 | union acpi_parse_object *name_op; |
| 247 | acpi_status status = AE_OK; |
| 248 | union acpi_operand_object *method_desc; |
| 249 | struct acpi_namespace_node *node; |
| 250 | union acpi_generic_state scope_info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 252 | ACPI_FUNCTION_TRACE("ps_get_next_namepath"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 254 | path = acpi_ps_get_next_namestring(parser_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | |
| 256 | /* Null path case is allowed */ |
| 257 | |
| 258 | if (path) { |
| 259 | /* |
| 260 | * Lookup the name in the internal namespace |
| 261 | */ |
| 262 | scope_info.scope.node = NULL; |
| 263 | node = parser_state->start_node; |
| 264 | if (node) { |
| 265 | scope_info.scope.node = node; |
| 266 | } |
| 267 | |
| 268 | /* |
| 269 | * Lookup object. We don't want to add anything new to the namespace |
| 270 | * here, however. So we use MODE_EXECUTE. Allow searching of the |
| 271 | * parent tree, but don't open a new scope -- we just want to lookup the |
| 272 | * object (MUST BE mode EXECUTE to perform upsearch) |
| 273 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 274 | status = acpi_ns_lookup(&scope_info, path, ACPI_TYPE_ANY, |
| 275 | ACPI_IMODE_EXECUTE, |
| 276 | ACPI_NS_SEARCH_PARENT | |
| 277 | ACPI_NS_DONT_OPEN_SCOPE, NULL, &node); |
| 278 | if (ACPI_SUCCESS(status) && method_call) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | if (node->type == ACPI_TYPE_METHOD) { |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 280 | /* This name is actually a control method invocation */ |
| 281 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 282 | method_desc = acpi_ns_get_attached_object(node); |
| 283 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, |
| 284 | "Control Method - %p Desc %p Path=%p\n", |
| 285 | node, method_desc, path)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 287 | name_op = acpi_ps_alloc_op(AML_INT_NAMEPATH_OP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | if (!name_op) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 289 | return_ACPI_STATUS(AE_NO_MEMORY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | /* Change arg into a METHOD CALL and attach name to it */ |
| 293 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 294 | acpi_ps_init_op(arg, AML_INT_METHODCALL_OP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | name_op->common.value.name = path; |
| 296 | |
| 297 | /* Point METHODCALL/NAME to the METHOD Node */ |
| 298 | |
| 299 | name_op->common.node = node; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 300 | acpi_ps_append_arg(arg, name_op); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | |
| 302 | if (!method_desc) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 303 | ACPI_REPORT_ERROR(("ps_get_next_namepath: Control Method %p has no attached object\n", node)); |
| 304 | return_ACPI_STATUS(AE_AML_INTERNAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | } |
| 306 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 307 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, |
| 308 | "Control Method - %p Args %X\n", |
| 309 | node, |
| 310 | method_desc->method. |
| 311 | param_count)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | |
| 313 | /* Get the number of arguments to expect */ |
| 314 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 315 | walk_state->arg_count = |
| 316 | method_desc->method.param_count; |
| 317 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | /* |
| 321 | * Else this is normal named object reference. |
| 322 | * Just init the NAMEPATH object with the pathname. |
| 323 | * (See code below) |
| 324 | */ |
| 325 | } |
| 326 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 327 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | /* |
| 329 | * 1) Any error other than NOT_FOUND is always severe |
| 330 | * 2) NOT_FOUND is only important if we are executing a method. |
| 331 | * 3) If executing a cond_ref_of opcode, NOT_FOUND is ok. |
| 332 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 333 | if ((((walk_state-> |
| 334 | parse_flags & ACPI_PARSE_MODE_MASK) == |
| 335 | ACPI_PARSE_EXECUTE) && (status == AE_NOT_FOUND) |
| 336 | && (walk_state->op->common.aml_opcode != |
| 337 | AML_COND_REF_OF_OP)) |
| 338 | || (status != AE_NOT_FOUND)) { |
| 339 | ACPI_REPORT_NSERROR(path, status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 341 | acpi_os_printf |
| 342 | ("search_node %p start_node %p return_node %p\n", |
| 343 | scope_info.scope.node, |
| 344 | parser_state->start_node, node); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 346 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | /* |
| 348 | * We got a NOT_FOUND during table load or we encountered |
| 349 | * a cond_ref_of(x) where the target does not exist. |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 350 | * Either case is ok |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | */ |
| 352 | status = AE_OK; |
| 353 | } |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | /* |
| 358 | * Regardless of success/failure above, |
| 359 | * Just initialize the Op with the pathname. |
| 360 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 361 | acpi_ps_init_op(arg, AML_INT_NAMEPATH_OP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | arg->common.value.name = path; |
| 363 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 364 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | } |
| 366 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | /******************************************************************************* |
| 368 | * |
| 369 | * FUNCTION: acpi_ps_get_next_simple_arg |
| 370 | * |
| 371 | * PARAMETERS: parser_state - Current parser state object |
| 372 | * arg_type - The argument type (AML_*_ARG) |
| 373 | * Arg - Where the argument is returned |
| 374 | * |
| 375 | * RETURN: None |
| 376 | * |
| 377 | * DESCRIPTION: Get the next simple argument (constant, string, or namestring) |
| 378 | * |
| 379 | ******************************************************************************/ |
| 380 | |
| 381 | void |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 382 | acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state, |
| 383 | u32 arg_type, union acpi_parse_object *arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | { |
| 385 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 386 | ACPI_FUNCTION_TRACE_U32("ps_get_next_simple_arg", arg_type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | |
| 388 | switch (arg_type) { |
| 389 | case ARGP_BYTEDATA: |
| 390 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 391 | acpi_ps_init_op(arg, AML_BYTE_OP); |
| 392 | arg->common.value.integer = (u32) ACPI_GET8(parser_state->aml); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | parser_state->aml++; |
| 394 | break; |
| 395 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | case ARGP_WORDDATA: |
| 397 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 398 | acpi_ps_init_op(arg, AML_WORD_OP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | |
| 400 | /* Get 2 bytes from the AML stream */ |
| 401 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 402 | ACPI_MOVE_16_TO_32(&arg->common.value.integer, |
| 403 | parser_state->aml); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | parser_state->aml += 2; |
| 405 | break; |
| 406 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | case ARGP_DWORDDATA: |
| 408 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 409 | acpi_ps_init_op(arg, AML_DWORD_OP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | |
| 411 | /* Get 4 bytes from the AML stream */ |
| 412 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 413 | ACPI_MOVE_32_TO_32(&arg->common.value.integer, |
| 414 | parser_state->aml); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | parser_state->aml += 4; |
| 416 | break; |
| 417 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | case ARGP_QWORDDATA: |
| 419 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 420 | acpi_ps_init_op(arg, AML_QWORD_OP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | |
| 422 | /* Get 8 bytes from the AML stream */ |
| 423 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 424 | ACPI_MOVE_64_TO_64(&arg->common.value.integer, |
| 425 | parser_state->aml); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | parser_state->aml += 8; |
| 427 | break; |
| 428 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | case ARGP_CHARLIST: |
| 430 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 431 | acpi_ps_init_op(arg, AML_STRING_OP); |
| 432 | arg->common.value.string = (char *)parser_state->aml; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 434 | while (ACPI_GET8(parser_state->aml) != '\0') { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | parser_state->aml++; |
| 436 | } |
| 437 | parser_state->aml++; |
| 438 | break; |
| 439 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | case ARGP_NAME: |
| 441 | case ARGP_NAMESTRING: |
| 442 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 443 | acpi_ps_init_op(arg, AML_INT_NAMEPATH_OP); |
| 444 | arg->common.value.name = |
| 445 | acpi_ps_get_next_namestring(parser_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | break; |
| 447 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | default: |
| 449 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 450 | ACPI_REPORT_ERROR(("Invalid arg_type %X\n", arg_type)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | break; |
| 452 | } |
| 453 | |
| 454 | return_VOID; |
| 455 | } |
| 456 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | /******************************************************************************* |
| 458 | * |
| 459 | * FUNCTION: acpi_ps_get_next_field |
| 460 | * |
| 461 | * PARAMETERS: parser_state - Current parser state object |
| 462 | * |
| 463 | * RETURN: A newly allocated FIELD op |
| 464 | * |
| 465 | * DESCRIPTION: Get next field (named_field, reserved_field, or access_field) |
| 466 | * |
| 467 | ******************************************************************************/ |
| 468 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 469 | static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state |
| 470 | *parser_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 472 | u32 aml_offset = (u32) |
| 473 | ACPI_PTR_DIFF(parser_state->aml, |
| 474 | parser_state->aml_start); |
| 475 | union acpi_parse_object *field; |
| 476 | u16 opcode; |
| 477 | u32 name; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 479 | ACPI_FUNCTION_TRACE("ps_get_next_field"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 480 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 481 | /* Determine field type */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 483 | switch (ACPI_GET8(parser_state->aml)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | default: |
| 485 | |
| 486 | opcode = AML_INT_NAMEDFIELD_OP; |
| 487 | break; |
| 488 | |
| 489 | case 0x00: |
| 490 | |
| 491 | opcode = AML_INT_RESERVEDFIELD_OP; |
| 492 | parser_state->aml++; |
| 493 | break; |
| 494 | |
| 495 | case 0x01: |
| 496 | |
| 497 | opcode = AML_INT_ACCESSFIELD_OP; |
| 498 | parser_state->aml++; |
| 499 | break; |
| 500 | } |
| 501 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 502 | /* Allocate a new field op */ |
| 503 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 504 | field = acpi_ps_alloc_op(opcode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | if (!field) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 506 | return_PTR(NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 507 | } |
| 508 | |
| 509 | field->common.aml_offset = aml_offset; |
| 510 | |
| 511 | /* Decode the field type */ |
| 512 | |
| 513 | switch (opcode) { |
| 514 | case AML_INT_NAMEDFIELD_OP: |
| 515 | |
| 516 | /* Get the 4-character name */ |
| 517 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 518 | ACPI_MOVE_32_TO_32(&name, parser_state->aml); |
| 519 | acpi_ps_set_name(field, name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 520 | parser_state->aml += ACPI_NAME_SIZE; |
| 521 | |
| 522 | /* Get the length which is encoded as a package length */ |
| 523 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 524 | field->common.value.size = |
| 525 | acpi_ps_get_next_package_length(parser_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | break; |
| 527 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | case AML_INT_RESERVEDFIELD_OP: |
| 529 | |
| 530 | /* Get the length which is encoded as a package length */ |
| 531 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 532 | field->common.value.size = |
| 533 | acpi_ps_get_next_package_length(parser_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | break; |
| 535 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | case AML_INT_ACCESSFIELD_OP: |
| 537 | |
| 538 | /* |
| 539 | * Get access_type and access_attrib and merge into the field Op |
| 540 | * access_type is first operand, access_attribute is second |
| 541 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 542 | field->common.value.integer = |
| 543 | (ACPI_GET8(parser_state->aml) << 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 544 | parser_state->aml++; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 545 | field->common.value.integer |= ACPI_GET8(parser_state->aml); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 546 | parser_state->aml++; |
| 547 | break; |
| 548 | |
| 549 | default: |
| 550 | |
| 551 | /* Opcode was set in previous switch */ |
| 552 | break; |
| 553 | } |
| 554 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 555 | return_PTR(field); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 | } |
| 557 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | /******************************************************************************* |
| 559 | * |
| 560 | * FUNCTION: acpi_ps_get_next_arg |
| 561 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 562 | * PARAMETERS: walk_state - Current state |
| 563 | * parser_state - Current parser state object |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 564 | * arg_type - The argument type (AML_*_ARG) |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 565 | * return_arg - Where the next arg is returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 566 | * |
| 567 | * RETURN: Status, and an op object containing the next argument. |
| 568 | * |
| 569 | * DESCRIPTION: Get next argument (including complex list arguments that require |
| 570 | * pushing the parser stack) |
| 571 | * |
| 572 | ******************************************************************************/ |
| 573 | |
| 574 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 575 | acpi_ps_get_next_arg(struct acpi_walk_state *walk_state, |
| 576 | struct acpi_parse_state *parser_state, |
| 577 | u32 arg_type, union acpi_parse_object **return_arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 578 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 579 | union acpi_parse_object *arg = NULL; |
| 580 | union acpi_parse_object *prev = NULL; |
| 581 | union acpi_parse_object *field; |
| 582 | u32 subop; |
| 583 | acpi_status status = AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 585 | ACPI_FUNCTION_TRACE_PTR("ps_get_next_arg", parser_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 586 | |
| 587 | switch (arg_type) { |
| 588 | case ARGP_BYTEDATA: |
| 589 | case ARGP_WORDDATA: |
| 590 | case ARGP_DWORDDATA: |
| 591 | case ARGP_CHARLIST: |
| 592 | case ARGP_NAME: |
| 593 | case ARGP_NAMESTRING: |
| 594 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 595 | /* Constants, strings, and namestrings are all the same size */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 597 | arg = acpi_ps_alloc_op(AML_BYTE_OP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 598 | if (!arg) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 599 | return_ACPI_STATUS(AE_NO_MEMORY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 601 | acpi_ps_get_next_simple_arg(parser_state, arg_type, arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | break; |
| 603 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 604 | case ARGP_PKGLENGTH: |
| 605 | |
| 606 | /* Package length, nothing returned */ |
| 607 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 608 | parser_state->pkg_end = |
| 609 | acpi_ps_get_next_package_end(parser_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | break; |
| 611 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 612 | case ARGP_FIELDLIST: |
| 613 | |
| 614 | if (parser_state->aml < parser_state->pkg_end) { |
| 615 | /* Non-empty list */ |
| 616 | |
| 617 | while (parser_state->aml < parser_state->pkg_end) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 618 | field = acpi_ps_get_next_field(parser_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | if (!field) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 620 | return_ACPI_STATUS(AE_NO_MEMORY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 621 | } |
| 622 | |
| 623 | if (prev) { |
| 624 | prev->common.next = field; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 625 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 626 | arg = field; |
| 627 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | prev = field; |
| 629 | } |
| 630 | |
| 631 | /* Skip to End of byte data */ |
| 632 | |
| 633 | parser_state->aml = parser_state->pkg_end; |
| 634 | } |
| 635 | break; |
| 636 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | case ARGP_BYTELIST: |
| 638 | |
| 639 | if (parser_state->aml < parser_state->pkg_end) { |
| 640 | /* Non-empty list */ |
| 641 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 642 | arg = acpi_ps_alloc_op(AML_INT_BYTELIST_OP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 643 | if (!arg) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 644 | return_ACPI_STATUS(AE_NO_MEMORY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | } |
| 646 | |
| 647 | /* Fill in bytelist data */ |
| 648 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 649 | arg->common.value.size = (u32) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 650 | ACPI_PTR_DIFF(parser_state->pkg_end, |
| 651 | parser_state->aml); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 652 | arg->named.data = parser_state->aml; |
| 653 | |
| 654 | /* Skip to End of byte data */ |
| 655 | |
| 656 | parser_state->aml = parser_state->pkg_end; |
| 657 | } |
| 658 | break; |
| 659 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | case ARGP_TARGET: |
| 661 | case ARGP_SUPERNAME: |
| 662 | case ARGP_SIMPLENAME: |
| 663 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 664 | subop = acpi_ps_peek_opcode(parser_state); |
| 665 | if (subop == 0 || |
| 666 | acpi_ps_is_leading_char(subop) || |
| 667 | acpi_ps_is_prefix_char(subop)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 668 | /* null_name or name_string */ |
| 669 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 670 | arg = acpi_ps_alloc_op(AML_INT_NAMEPATH_OP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 671 | if (!arg) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 672 | return_ACPI_STATUS(AE_NO_MEMORY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | } |
| 674 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 675 | status = |
| 676 | acpi_ps_get_next_namepath(walk_state, parser_state, |
| 677 | arg, 0); |
| 678 | } else { |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 679 | /* Single complex argument, nothing returned */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 680 | |
| 681 | walk_state->arg_count = 1; |
| 682 | } |
| 683 | break; |
| 684 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | case ARGP_DATAOBJ: |
| 686 | case ARGP_TERMARG: |
| 687 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 688 | /* Single complex argument, nothing returned */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | |
| 690 | walk_state->arg_count = 1; |
| 691 | break; |
| 692 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | case ARGP_DATAOBJLIST: |
| 694 | case ARGP_TERMLIST: |
| 695 | case ARGP_OBJLIST: |
| 696 | |
| 697 | if (parser_state->aml < parser_state->pkg_end) { |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 698 | /* Non-empty list of variable arguments, nothing returned */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | |
| 700 | walk_state->arg_count = ACPI_VAR_ARGS; |
| 701 | } |
| 702 | break; |
| 703 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 704 | default: |
| 705 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 706 | ACPI_REPORT_ERROR(("Invalid arg_type: %X\n", arg_type)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | status = AE_AML_OPERAND_TYPE; |
| 708 | break; |
| 709 | } |
| 710 | |
| 711 | *return_arg = arg; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 712 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 713 | } |