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