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