psargs.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  1. /******************************************************************************
  2. *
  3. * Module Name: psargs - Parse AML opcode arguments
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2008, Intel Corp.
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions, and the following disclaimer,
  15. * without modification.
  16. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  17. * substantially similar to the "NO WARRANTY" disclaimer below
  18. * ("Disclaimer") and any redistribution must be conditioned upon
  19. * including a substantially similar Disclaimer requirement for further
  20. * binary redistribution.
  21. * 3. Neither the names of the above-listed copyright holders nor the names
  22. * of any contributors may be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * Alternatively, this software may be distributed under the terms of the
  26. * GNU General Public License ("GPL") version 2 as published by the Free
  27. * Software Foundation.
  28. *
  29. * NO WARRANTY
  30. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  31. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  32. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  33. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  34. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  35. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  36. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  38. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  39. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  40. * POSSIBILITY OF SUCH DAMAGES.
  41. */
  42. #include <acpi/acpi.h>
  43. #include <acpi/acparser.h>
  44. #include <acpi/amlcode.h>
  45. #include <acpi/acnamesp.h>
  46. #include <acpi/acdispat.h>
  47. #define _COMPONENT ACPI_PARSER
  48. ACPI_MODULE_NAME("psargs")
  49. /* Local prototypes */
  50. static u32
  51. acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state);
  52. static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state
  53. *parser_state);
  54. /*******************************************************************************
  55. *
  56. * FUNCTION: acpi_ps_get_next_package_length
  57. *
  58. * PARAMETERS: parser_state - Current parser state object
  59. *
  60. * RETURN: Decoded package length. On completion, the AML pointer points
  61. * past the length byte or bytes.
  62. *
  63. * DESCRIPTION: Decode and return a package length field.
  64. * Note: Largest package length is 28 bits, from ACPI specification
  65. *
  66. ******************************************************************************/
  67. static u32
  68. acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state)
  69. {
  70. u8 *aml = parser_state->aml;
  71. u32 package_length = 0;
  72. u32 byte_count;
  73. u8 byte_zero_mask = 0x3F; /* Default [0:5] */
  74. ACPI_FUNCTION_TRACE(ps_get_next_package_length);
  75. /*
  76. * Byte 0 bits [6:7] contain the number of additional bytes
  77. * used to encode the package length, either 0,1,2, or 3
  78. */
  79. byte_count = (aml[0] >> 6);
  80. parser_state->aml += ((acpi_size) byte_count + 1);
  81. /* Get bytes 3, 2, 1 as needed */
  82. while (byte_count) {
  83. /*
  84. * Final bit positions for the package length bytes:
  85. * Byte3->[20:27]
  86. * Byte2->[12:19]
  87. * Byte1->[04:11]
  88. * Byte0->[00:03]
  89. */
  90. package_length |= (aml[byte_count] << ((byte_count << 3) - 4));
  91. byte_zero_mask = 0x0F; /* Use bits [0:3] of byte 0 */
  92. byte_count--;
  93. }
  94. /* Byte 0 is a special case, either bits [0:3] or [0:5] are used */
  95. package_length |= (aml[0] & byte_zero_mask);
  96. return_UINT32(package_length);
  97. }
  98. /*******************************************************************************
  99. *
  100. * FUNCTION: acpi_ps_get_next_package_end
  101. *
  102. * PARAMETERS: parser_state - Current parser state object
  103. *
  104. * RETURN: Pointer to end-of-package +1
  105. *
  106. * DESCRIPTION: Get next package length and return a pointer past the end of
  107. * the package. Consumes the package length field
  108. *
  109. ******************************************************************************/
  110. u8 *acpi_ps_get_next_package_end(struct acpi_parse_state *parser_state)
  111. {
  112. u8 *start = parser_state->aml;
  113. u32 package_length;
  114. ACPI_FUNCTION_TRACE(ps_get_next_package_end);
  115. /* Function below updates parser_state->Aml */
  116. package_length = acpi_ps_get_next_package_length(parser_state);
  117. return_PTR(start + package_length); /* end of package */
  118. }
  119. /*******************************************************************************
  120. *
  121. * FUNCTION: acpi_ps_get_next_namestring
  122. *
  123. * PARAMETERS: parser_state - Current parser state object
  124. *
  125. * RETURN: Pointer to the start of the name string (pointer points into
  126. * the AML.
  127. *
  128. * DESCRIPTION: Get next raw namestring within the AML stream. Handles all name
  129. * prefix characters. Set parser state to point past the string.
  130. * (Name is consumed from the AML.)
  131. *
  132. ******************************************************************************/
  133. char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state)
  134. {
  135. u8 *start = parser_state->aml;
  136. u8 *end = parser_state->aml;
  137. ACPI_FUNCTION_TRACE(ps_get_next_namestring);
  138. /* Point past any namestring prefix characters (backslash or carat) */
  139. while (acpi_ps_is_prefix_char(*end)) {
  140. end++;
  141. }
  142. /* Decode the path prefix character */
  143. switch (*end) {
  144. case 0:
  145. /* null_name */
  146. if (end == start) {
  147. start = NULL;
  148. }
  149. end++;
  150. break;
  151. case AML_DUAL_NAME_PREFIX:
  152. /* Two name segments */
  153. end += 1 + (2 * ACPI_NAME_SIZE);
  154. break;
  155. case AML_MULTI_NAME_PREFIX_OP:
  156. /* Multiple name segments, 4 chars each, count in next byte */
  157. end += 2 + (*(end + 1) * ACPI_NAME_SIZE);
  158. break;
  159. default:
  160. /* Single name segment */
  161. end += ACPI_NAME_SIZE;
  162. break;
  163. }
  164. parser_state->aml = end;
  165. return_PTR((char *)start);
  166. }
  167. /*******************************************************************************
  168. *
  169. * FUNCTION: acpi_ps_get_next_namepath
  170. *
  171. * PARAMETERS: parser_state - Current parser state object
  172. * Arg - Where the namepath will be stored
  173. * arg_count - If the namepath points to a control method
  174. * the method's argument is returned here.
  175. * possible_method_call - Whether the namepath can possibly be the
  176. * start of a method call
  177. *
  178. * RETURN: Status
  179. *
  180. * DESCRIPTION: Get next name (if method call, return # of required args).
  181. * Names are looked up in the internal namespace to determine
  182. * if the name represents a control method. If a method
  183. * is found, the number of arguments to the method is returned.
  184. * This information is critical for parsing to continue correctly.
  185. *
  186. ******************************************************************************/
  187. acpi_status
  188. acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state,
  189. struct acpi_parse_state *parser_state,
  190. union acpi_parse_object *arg, u8 possible_method_call)
  191. {
  192. acpi_status status;
  193. char *path;
  194. union acpi_parse_object *name_op;
  195. union acpi_operand_object *method_desc;
  196. struct acpi_namespace_node *node;
  197. u8 *start = parser_state->aml;
  198. ACPI_FUNCTION_TRACE(ps_get_next_namepath);
  199. path = acpi_ps_get_next_namestring(parser_state);
  200. acpi_ps_init_op(arg, AML_INT_NAMEPATH_OP);
  201. /* Null path case is allowed, just exit */
  202. if (!path) {
  203. arg->common.value.name = path;
  204. return_ACPI_STATUS(AE_OK);
  205. }
  206. /*
  207. * Lookup the name in the internal namespace, starting with the current
  208. * scope. We don't want to add anything new to the namespace here,
  209. * however, so we use MODE_EXECUTE.
  210. * Allow searching of the parent tree, but don't open a new scope -
  211. * we just want to lookup the object (must be mode EXECUTE to perform
  212. * the upsearch)
  213. */
  214. status = acpi_ns_lookup(walk_state->scope_info, path,
  215. ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
  216. ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
  217. NULL, &node);
  218. /*
  219. * If this name is a control method invocation, we must
  220. * setup the method call
  221. */
  222. if (ACPI_SUCCESS(status) &&
  223. possible_method_call && (node->type == ACPI_TYPE_METHOD)) {
  224. if (walk_state->opcode == AML_UNLOAD_OP) {
  225. /*
  226. * acpi_ps_get_next_namestring has increased the AML pointer,
  227. * so we need to restore the saved AML pointer for method call.
  228. */
  229. walk_state->parser_state.aml = start;
  230. walk_state->arg_count = 1;
  231. acpi_ps_init_op(arg, AML_INT_METHODCALL_OP);
  232. return_ACPI_STATUS(AE_OK);
  233. }
  234. /* This name is actually a control method invocation */
  235. method_desc = acpi_ns_get_attached_object(node);
  236. ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
  237. "Control Method - %p Desc %p Path=%p\n", node,
  238. method_desc, path));
  239. name_op = acpi_ps_alloc_op(AML_INT_NAMEPATH_OP);
  240. if (!name_op) {
  241. return_ACPI_STATUS(AE_NO_MEMORY);
  242. }
  243. /* Change Arg into a METHOD CALL and attach name to it */
  244. acpi_ps_init_op(arg, AML_INT_METHODCALL_OP);
  245. name_op->common.value.name = path;
  246. /* Point METHODCALL/NAME to the METHOD Node */
  247. name_op->common.node = node;
  248. acpi_ps_append_arg(arg, name_op);
  249. if (!method_desc) {
  250. ACPI_ERROR((AE_INFO,
  251. "Control Method %p has no attached object",
  252. node));
  253. return_ACPI_STATUS(AE_AML_INTERNAL);
  254. }
  255. ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
  256. "Control Method - %p Args %X\n",
  257. node, method_desc->method.param_count));
  258. /* Get the number of arguments to expect */
  259. walk_state->arg_count = method_desc->method.param_count;
  260. return_ACPI_STATUS(AE_OK);
  261. }
  262. /*
  263. * Special handling if the name was not found during the lookup -
  264. * some not_found cases are allowed
  265. */
  266. if (status == AE_NOT_FOUND) {
  267. /* 1) not_found is ok during load pass 1/2 (allow forward references) */
  268. if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) !=
  269. ACPI_PARSE_EXECUTE) {
  270. status = AE_OK;
  271. }
  272. /* 2) not_found during a cond_ref_of(x) is ok by definition */
  273. else if (walk_state->op->common.aml_opcode ==
  274. AML_COND_REF_OF_OP) {
  275. status = AE_OK;
  276. }
  277. /*
  278. * 3) not_found while building a Package is ok at this point, we
  279. * may flag as an error later if slack mode is not enabled.
  280. * (Some ASL code depends on allowing this behavior)
  281. */
  282. else if ((arg->common.parent) &&
  283. ((arg->common.parent->common.aml_opcode ==
  284. AML_PACKAGE_OP)
  285. || (arg->common.parent->common.aml_opcode ==
  286. AML_VAR_PACKAGE_OP))) {
  287. status = AE_OK;
  288. }
  289. }
  290. /* Final exception check (may have been changed from code above) */
  291. if (ACPI_FAILURE(status)) {
  292. ACPI_ERROR_NAMESPACE(path, status);
  293. if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) ==
  294. ACPI_PARSE_EXECUTE) {
  295. /* Report a control method execution error */
  296. status = acpi_ds_method_error(status, walk_state);
  297. }
  298. }
  299. /* Save the namepath */
  300. arg->common.value.name = path;
  301. return_ACPI_STATUS(status);
  302. }
  303. /*******************************************************************************
  304. *
  305. * FUNCTION: acpi_ps_get_next_simple_arg
  306. *
  307. * PARAMETERS: parser_state - Current parser state object
  308. * arg_type - The argument type (AML_*_ARG)
  309. * Arg - Where the argument is returned
  310. *
  311. * RETURN: None
  312. *
  313. * DESCRIPTION: Get the next simple argument (constant, string, or namestring)
  314. *
  315. ******************************************************************************/
  316. void
  317. acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state,
  318. u32 arg_type, union acpi_parse_object *arg)
  319. {
  320. u32 length;
  321. u16 opcode;
  322. u8 *aml = parser_state->aml;
  323. ACPI_FUNCTION_TRACE_U32(ps_get_next_simple_arg, arg_type);
  324. switch (arg_type) {
  325. case ARGP_BYTEDATA:
  326. /* Get 1 byte from the AML stream */
  327. opcode = AML_BYTE_OP;
  328. arg->common.value.integer = (acpi_integer) * aml;
  329. length = 1;
  330. break;
  331. case ARGP_WORDDATA:
  332. /* Get 2 bytes from the AML stream */
  333. opcode = AML_WORD_OP;
  334. ACPI_MOVE_16_TO_64(&arg->common.value.integer, aml);
  335. length = 2;
  336. break;
  337. case ARGP_DWORDDATA:
  338. /* Get 4 bytes from the AML stream */
  339. opcode = AML_DWORD_OP;
  340. ACPI_MOVE_32_TO_64(&arg->common.value.integer, aml);
  341. length = 4;
  342. break;
  343. case ARGP_QWORDDATA:
  344. /* Get 8 bytes from the AML stream */
  345. opcode = AML_QWORD_OP;
  346. ACPI_MOVE_64_TO_64(&arg->common.value.integer, aml);
  347. length = 8;
  348. break;
  349. case ARGP_CHARLIST:
  350. /* Get a pointer to the string, point past the string */
  351. opcode = AML_STRING_OP;
  352. arg->common.value.string = ACPI_CAST_PTR(char, aml);
  353. /* Find the null terminator */
  354. length = 0;
  355. while (aml[length]) {
  356. length++;
  357. }
  358. length++;
  359. break;
  360. case ARGP_NAME:
  361. case ARGP_NAMESTRING:
  362. acpi_ps_init_op(arg, AML_INT_NAMEPATH_OP);
  363. arg->common.value.name =
  364. acpi_ps_get_next_namestring(parser_state);
  365. return_VOID;
  366. default:
  367. ACPI_ERROR((AE_INFO, "Invalid ArgType %X", arg_type));
  368. return_VOID;
  369. }
  370. acpi_ps_init_op(arg, opcode);
  371. parser_state->aml += length;
  372. return_VOID;
  373. }
  374. /*******************************************************************************
  375. *
  376. * FUNCTION: acpi_ps_get_next_field
  377. *
  378. * PARAMETERS: parser_state - Current parser state object
  379. *
  380. * RETURN: A newly allocated FIELD op
  381. *
  382. * DESCRIPTION: Get next field (named_field, reserved_field, or access_field)
  383. *
  384. ******************************************************************************/
  385. static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state
  386. *parser_state)
  387. {
  388. u32 aml_offset = (u32)
  389. ACPI_PTR_DIFF(parser_state->aml,
  390. parser_state->aml_start);
  391. union acpi_parse_object *field;
  392. u16 opcode;
  393. u32 name;
  394. ACPI_FUNCTION_TRACE(ps_get_next_field);
  395. /* Determine field type */
  396. switch (ACPI_GET8(parser_state->aml)) {
  397. default:
  398. opcode = AML_INT_NAMEDFIELD_OP;
  399. break;
  400. case 0x00:
  401. opcode = AML_INT_RESERVEDFIELD_OP;
  402. parser_state->aml++;
  403. break;
  404. case 0x01:
  405. opcode = AML_INT_ACCESSFIELD_OP;
  406. parser_state->aml++;
  407. break;
  408. }
  409. /* Allocate a new field op */
  410. field = acpi_ps_alloc_op(opcode);
  411. if (!field) {
  412. return_PTR(NULL);
  413. }
  414. field->common.aml_offset = aml_offset;
  415. /* Decode the field type */
  416. switch (opcode) {
  417. case AML_INT_NAMEDFIELD_OP:
  418. /* Get the 4-character name */
  419. ACPI_MOVE_32_TO_32(&name, parser_state->aml);
  420. acpi_ps_set_name(field, name);
  421. parser_state->aml += ACPI_NAME_SIZE;
  422. /* Get the length which is encoded as a package length */
  423. field->common.value.size =
  424. acpi_ps_get_next_package_length(parser_state);
  425. break;
  426. case AML_INT_RESERVEDFIELD_OP:
  427. /* Get the length which is encoded as a package length */
  428. field->common.value.size =
  429. acpi_ps_get_next_package_length(parser_state);
  430. break;
  431. case AML_INT_ACCESSFIELD_OP:
  432. /*
  433. * Get access_type and access_attrib and merge into the field Op
  434. * access_type is first operand, access_attribute is second
  435. */
  436. field->common.value.integer =
  437. (((u32) ACPI_GET8(parser_state->aml) << 8));
  438. parser_state->aml++;
  439. field->common.value.integer |= ACPI_GET8(parser_state->aml);
  440. parser_state->aml++;
  441. break;
  442. default:
  443. /* Opcode was set in previous switch */
  444. break;
  445. }
  446. return_PTR(field);
  447. }
  448. /*******************************************************************************
  449. *
  450. * FUNCTION: acpi_ps_get_next_arg
  451. *
  452. * PARAMETERS: walk_state - Current state
  453. * parser_state - Current parser state object
  454. * arg_type - The argument type (AML_*_ARG)
  455. * return_arg - Where the next arg is returned
  456. *
  457. * RETURN: Status, and an op object containing the next argument.
  458. *
  459. * DESCRIPTION: Get next argument (including complex list arguments that require
  460. * pushing the parser stack)
  461. *
  462. ******************************************************************************/
  463. acpi_status
  464. acpi_ps_get_next_arg(struct acpi_walk_state *walk_state,
  465. struct acpi_parse_state *parser_state,
  466. u32 arg_type, union acpi_parse_object **return_arg)
  467. {
  468. union acpi_parse_object *arg = NULL;
  469. union acpi_parse_object *prev = NULL;
  470. union acpi_parse_object *field;
  471. u32 subop;
  472. acpi_status status = AE_OK;
  473. ACPI_FUNCTION_TRACE_PTR(ps_get_next_arg, parser_state);
  474. switch (arg_type) {
  475. case ARGP_BYTEDATA:
  476. case ARGP_WORDDATA:
  477. case ARGP_DWORDDATA:
  478. case ARGP_CHARLIST:
  479. case ARGP_NAME:
  480. case ARGP_NAMESTRING:
  481. /* Constants, strings, and namestrings are all the same size */
  482. arg = acpi_ps_alloc_op(AML_BYTE_OP);
  483. if (!arg) {
  484. return_ACPI_STATUS(AE_NO_MEMORY);
  485. }
  486. acpi_ps_get_next_simple_arg(parser_state, arg_type, arg);
  487. break;
  488. case ARGP_PKGLENGTH:
  489. /* Package length, nothing returned */
  490. parser_state->pkg_end =
  491. acpi_ps_get_next_package_end(parser_state);
  492. break;
  493. case ARGP_FIELDLIST:
  494. if (parser_state->aml < parser_state->pkg_end) {
  495. /* Non-empty list */
  496. while (parser_state->aml < parser_state->pkg_end) {
  497. field = acpi_ps_get_next_field(parser_state);
  498. if (!field) {
  499. return_ACPI_STATUS(AE_NO_MEMORY);
  500. }
  501. if (prev) {
  502. prev->common.next = field;
  503. } else {
  504. arg = field;
  505. }
  506. prev = field;
  507. }
  508. /* Skip to End of byte data */
  509. parser_state->aml = parser_state->pkg_end;
  510. }
  511. break;
  512. case ARGP_BYTELIST:
  513. if (parser_state->aml < parser_state->pkg_end) {
  514. /* Non-empty list */
  515. arg = acpi_ps_alloc_op(AML_INT_BYTELIST_OP);
  516. if (!arg) {
  517. return_ACPI_STATUS(AE_NO_MEMORY);
  518. }
  519. /* Fill in bytelist data */
  520. arg->common.value.size = (u32)
  521. ACPI_PTR_DIFF(parser_state->pkg_end,
  522. parser_state->aml);
  523. arg->named.data = parser_state->aml;
  524. /* Skip to End of byte data */
  525. parser_state->aml = parser_state->pkg_end;
  526. }
  527. break;
  528. case ARGP_TARGET:
  529. case ARGP_SUPERNAME:
  530. case ARGP_SIMPLENAME:
  531. subop = acpi_ps_peek_opcode(parser_state);
  532. if (subop == 0 ||
  533. acpi_ps_is_leading_char(subop) ||
  534. acpi_ps_is_prefix_char(subop)) {
  535. /* null_name or name_string */
  536. arg = acpi_ps_alloc_op(AML_INT_NAMEPATH_OP);
  537. if (!arg) {
  538. return_ACPI_STATUS(AE_NO_MEMORY);
  539. }
  540. /* To support super_name arg of Unload */
  541. if (walk_state->opcode == AML_UNLOAD_OP) {
  542. status =
  543. acpi_ps_get_next_namepath(walk_state,
  544. parser_state, arg,
  545. 1);
  546. /*
  547. * If the super_name arg of Unload is a method call,
  548. * we have restored the AML pointer, just free this Arg
  549. */
  550. if (arg->common.aml_opcode ==
  551. AML_INT_METHODCALL_OP) {
  552. acpi_ps_free_op(arg);
  553. arg = NULL;
  554. }
  555. } else {
  556. status =
  557. acpi_ps_get_next_namepath(walk_state,
  558. parser_state, arg,
  559. 0);
  560. }
  561. } else {
  562. /* Single complex argument, nothing returned */
  563. walk_state->arg_count = 1;
  564. }
  565. break;
  566. case ARGP_DATAOBJ:
  567. case ARGP_TERMARG:
  568. /* Single complex argument, nothing returned */
  569. walk_state->arg_count = 1;
  570. break;
  571. case ARGP_DATAOBJLIST:
  572. case ARGP_TERMLIST:
  573. case ARGP_OBJLIST:
  574. if (parser_state->aml < parser_state->pkg_end) {
  575. /* Non-empty list of variable arguments, nothing returned */
  576. walk_state->arg_count = ACPI_VAR_ARGS;
  577. }
  578. break;
  579. default:
  580. ACPI_ERROR((AE_INFO, "Invalid ArgType: %X", arg_type));
  581. status = AE_AML_OPERAND_TYPE;
  582. break;
  583. }
  584. *return_arg = arg;
  585. return_ACPI_STATUS(status);
  586. }