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