dsobject.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813
  1. /******************************************************************************
  2. *
  3. * Module Name: dsobject - Dispatcher object management routines
  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 "accommon.h"
  44. #include "acparser.h"
  45. #include "amlcode.h"
  46. #include "acdispat.h"
  47. #include "acnamesp.h"
  48. #include "acinterp.h"
  49. #define _COMPONENT ACPI_DISPATCHER
  50. ACPI_MODULE_NAME("dsobject")
  51. /* Local prototypes */
  52. static acpi_status
  53. acpi_ds_build_internal_object(struct acpi_walk_state *walk_state,
  54. union acpi_parse_object *op,
  55. union acpi_operand_object **obj_desc_ptr);
  56. #ifndef ACPI_NO_METHOD_EXECUTION
  57. /*******************************************************************************
  58. *
  59. * FUNCTION: acpi_ds_build_internal_object
  60. *
  61. * PARAMETERS: walk_state - Current walk state
  62. * Op - Parser object to be translated
  63. * obj_desc_ptr - Where the ACPI internal object is returned
  64. *
  65. * RETURN: Status
  66. *
  67. * DESCRIPTION: Translate a parser Op object to the equivalent namespace object
  68. * Simple objects are any objects other than a package object!
  69. *
  70. ******************************************************************************/
  71. static acpi_status
  72. acpi_ds_build_internal_object(struct acpi_walk_state *walk_state,
  73. union acpi_parse_object *op,
  74. union acpi_operand_object **obj_desc_ptr)
  75. {
  76. union acpi_operand_object *obj_desc;
  77. acpi_status status;
  78. ACPI_FUNCTION_TRACE(ds_build_internal_object);
  79. *obj_desc_ptr = NULL;
  80. if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) {
  81. /*
  82. * This is a named object reference. If this name was
  83. * previously looked up in the namespace, it was stored in this op.
  84. * Otherwise, go ahead and look it up now
  85. */
  86. if (!op->common.node) {
  87. status = acpi_ns_lookup(walk_state->scope_info,
  88. op->common.value.string,
  89. ACPI_TYPE_ANY,
  90. ACPI_IMODE_EXECUTE,
  91. ACPI_NS_SEARCH_PARENT |
  92. ACPI_NS_DONT_OPEN_SCOPE, NULL,
  93. ACPI_CAST_INDIRECT_PTR(struct
  94. acpi_namespace_node,
  95. &(op->
  96. common.
  97. node)));
  98. if (ACPI_FAILURE(status)) {
  99. /* Check if we are resolving a named reference within a package */
  100. if ((status == AE_NOT_FOUND)
  101. && (acpi_gbl_enable_interpreter_slack)
  102. &&
  103. ((op->common.parent->common.aml_opcode ==
  104. AML_PACKAGE_OP)
  105. || (op->common.parent->common.aml_opcode ==
  106. AML_VAR_PACKAGE_OP))) {
  107. /*
  108. * We didn't find the target and we are populating elements
  109. * of a package - ignore if slack enabled. Some ASL code
  110. * contains dangling invalid references in packages and
  111. * expects that no exception will be issued. Leave the
  112. * element as a null element. It cannot be used, but it
  113. * can be overwritten by subsequent ASL code - this is
  114. * typically the case.
  115. */
  116. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  117. "Ignoring unresolved reference in package [%4.4s]\n",
  118. walk_state->
  119. scope_info->scope.
  120. node->name.ascii));
  121. return_ACPI_STATUS(AE_OK);
  122. } else {
  123. ACPI_ERROR_NAMESPACE(op->common.value.
  124. string, status);
  125. }
  126. return_ACPI_STATUS(status);
  127. }
  128. }
  129. /* Special object resolution for elements of a package */
  130. if ((op->common.parent->common.aml_opcode == AML_PACKAGE_OP) ||
  131. (op->common.parent->common.aml_opcode ==
  132. AML_VAR_PACKAGE_OP)) {
  133. /*
  134. * Attempt to resolve the node to a value before we insert it into
  135. * the package. If this is a reference to a common data type,
  136. * resolve it immediately. According to the ACPI spec, package
  137. * elements can only be "data objects" or method references.
  138. * Attempt to resolve to an Integer, Buffer, String or Package.
  139. * If cannot, return the named reference (for things like Devices,
  140. * Methods, etc.) Buffer Fields and Fields will resolve to simple
  141. * objects (int/buf/str/pkg).
  142. *
  143. * NOTE: References to things like Devices, Methods, Mutexes, etc.
  144. * will remain as named references. This behavior is not described
  145. * in the ACPI spec, but it appears to be an oversight.
  146. */
  147. obj_desc =
  148. ACPI_CAST_PTR(union acpi_operand_object,
  149. op->common.node);
  150. status =
  151. acpi_ex_resolve_node_to_value(ACPI_CAST_INDIRECT_PTR
  152. (struct
  153. acpi_namespace_node,
  154. &obj_desc),
  155. walk_state);
  156. if (ACPI_FAILURE(status)) {
  157. return_ACPI_STATUS(status);
  158. }
  159. switch (op->common.node->type) {
  160. /*
  161. * For these types, we need the actual node, not the subobject.
  162. * However, the subobject did not get an extra reference count above.
  163. *
  164. * TBD: should ex_resolve_node_to_value be changed to fix this?
  165. */
  166. case ACPI_TYPE_DEVICE:
  167. case ACPI_TYPE_THERMAL:
  168. acpi_ut_add_reference(op->common.node->object);
  169. /*lint -fallthrough */
  170. /*
  171. * For these types, we need the actual node, not the subobject.
  172. * The subobject got an extra reference count in ex_resolve_node_to_value.
  173. */
  174. case ACPI_TYPE_MUTEX:
  175. case ACPI_TYPE_METHOD:
  176. case ACPI_TYPE_POWER:
  177. case ACPI_TYPE_PROCESSOR:
  178. case ACPI_TYPE_EVENT:
  179. case ACPI_TYPE_REGION:
  180. /* We will create a reference object for these types below */
  181. break;
  182. default:
  183. /*
  184. * All other types - the node was resolved to an actual
  185. * object, we are done.
  186. */
  187. goto exit;
  188. }
  189. }
  190. }
  191. /* Create and init a new internal ACPI object */
  192. obj_desc = acpi_ut_create_internal_object((acpi_ps_get_opcode_info
  193. (op->common.aml_opcode))->
  194. object_type);
  195. if (!obj_desc) {
  196. return_ACPI_STATUS(AE_NO_MEMORY);
  197. }
  198. status =
  199. acpi_ds_init_object_from_op(walk_state, op, op->common.aml_opcode,
  200. &obj_desc);
  201. if (ACPI_FAILURE(status)) {
  202. acpi_ut_remove_reference(obj_desc);
  203. return_ACPI_STATUS(status);
  204. }
  205. exit:
  206. *obj_desc_ptr = obj_desc;
  207. return_ACPI_STATUS(status);
  208. }
  209. /*******************************************************************************
  210. *
  211. * FUNCTION: acpi_ds_build_internal_buffer_obj
  212. *
  213. * PARAMETERS: walk_state - Current walk state
  214. * Op - Parser object to be translated
  215. * buffer_length - Length of the buffer
  216. * obj_desc_ptr - Where the ACPI internal object is returned
  217. *
  218. * RETURN: Status
  219. *
  220. * DESCRIPTION: Translate a parser Op package object to the equivalent
  221. * namespace object
  222. *
  223. ******************************************************************************/
  224. acpi_status
  225. acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state,
  226. union acpi_parse_object *op,
  227. u32 buffer_length,
  228. union acpi_operand_object **obj_desc_ptr)
  229. {
  230. union acpi_parse_object *arg;
  231. union acpi_operand_object *obj_desc;
  232. union acpi_parse_object *byte_list;
  233. u32 byte_list_length = 0;
  234. ACPI_FUNCTION_TRACE(ds_build_internal_buffer_obj);
  235. /*
  236. * If we are evaluating a Named buffer object "Name (xxxx, Buffer)".
  237. * The buffer object already exists (from the NS node), otherwise it must
  238. * be created.
  239. */
  240. obj_desc = *obj_desc_ptr;
  241. if (!obj_desc) {
  242. /* Create a new buffer object */
  243. obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER);
  244. *obj_desc_ptr = obj_desc;
  245. if (!obj_desc) {
  246. return_ACPI_STATUS(AE_NO_MEMORY);
  247. }
  248. }
  249. /*
  250. * Second arg is the buffer data (optional) byte_list can be either
  251. * individual bytes or a string initializer. In either case, a
  252. * byte_list appears in the AML.
  253. */
  254. arg = op->common.value.arg; /* skip first arg */
  255. byte_list = arg->named.next;
  256. if (byte_list) {
  257. if (byte_list->common.aml_opcode != AML_INT_BYTELIST_OP) {
  258. ACPI_ERROR((AE_INFO,
  259. "Expecting bytelist, got AML opcode %X in op %p",
  260. byte_list->common.aml_opcode, byte_list));
  261. acpi_ut_remove_reference(obj_desc);
  262. return (AE_TYPE);
  263. }
  264. byte_list_length = (u32) byte_list->common.value.integer;
  265. }
  266. /*
  267. * The buffer length (number of bytes) will be the larger of:
  268. * 1) The specified buffer length and
  269. * 2) The length of the initializer byte list
  270. */
  271. obj_desc->buffer.length = buffer_length;
  272. if (byte_list_length > buffer_length) {
  273. obj_desc->buffer.length = byte_list_length;
  274. }
  275. /* Allocate the buffer */
  276. if (obj_desc->buffer.length == 0) {
  277. obj_desc->buffer.pointer = NULL;
  278. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  279. "Buffer defined with zero length in AML, creating\n"));
  280. } else {
  281. obj_desc->buffer.pointer =
  282. ACPI_ALLOCATE_ZEROED(obj_desc->buffer.length);
  283. if (!obj_desc->buffer.pointer) {
  284. acpi_ut_delete_object_desc(obj_desc);
  285. return_ACPI_STATUS(AE_NO_MEMORY);
  286. }
  287. /* Initialize buffer from the byte_list (if present) */
  288. if (byte_list) {
  289. ACPI_MEMCPY(obj_desc->buffer.pointer,
  290. byte_list->named.data, byte_list_length);
  291. }
  292. }
  293. obj_desc->buffer.flags |= AOPOBJ_DATA_VALID;
  294. op->common.node = ACPI_CAST_PTR(struct acpi_namespace_node, obj_desc);
  295. return_ACPI_STATUS(AE_OK);
  296. }
  297. /*******************************************************************************
  298. *
  299. * FUNCTION: acpi_ds_build_internal_package_obj
  300. *
  301. * PARAMETERS: walk_state - Current walk state
  302. * Op - Parser object to be translated
  303. * element_count - Number of elements in the package - this is
  304. * the num_elements argument to Package()
  305. * obj_desc_ptr - Where the ACPI internal object is returned
  306. *
  307. * RETURN: Status
  308. *
  309. * DESCRIPTION: Translate a parser Op package object to the equivalent
  310. * namespace object
  311. *
  312. * NOTE: The number of elements in the package will be always be the num_elements
  313. * count, regardless of the number of elements in the package list. If
  314. * num_elements is smaller, only that many package list elements are used.
  315. * if num_elements is larger, the Package object is padded out with
  316. * objects of type Uninitialized (as per ACPI spec.)
  317. *
  318. * Even though the ASL compilers do not allow num_elements to be smaller
  319. * than the Package list length (for the fixed length package opcode), some
  320. * BIOS code modifies the AML on the fly to adjust the num_elements, and
  321. * this code compensates for that. This also provides compatibility with
  322. * other AML interpreters.
  323. *
  324. ******************************************************************************/
  325. acpi_status
  326. acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
  327. union acpi_parse_object *op,
  328. u32 element_count,
  329. union acpi_operand_object **obj_desc_ptr)
  330. {
  331. union acpi_parse_object *arg;
  332. union acpi_parse_object *parent;
  333. union acpi_operand_object *obj_desc = NULL;
  334. acpi_status status = AE_OK;
  335. unsigned i;
  336. u16 index;
  337. u16 reference_count;
  338. ACPI_FUNCTION_TRACE(ds_build_internal_package_obj);
  339. /* Find the parent of a possibly nested package */
  340. parent = op->common.parent;
  341. while ((parent->common.aml_opcode == AML_PACKAGE_OP) ||
  342. (parent->common.aml_opcode == AML_VAR_PACKAGE_OP)) {
  343. parent = parent->common.parent;
  344. }
  345. /*
  346. * If we are evaluating a Named package object "Name (xxxx, Package)",
  347. * the package object already exists, otherwise it must be created.
  348. */
  349. obj_desc = *obj_desc_ptr;
  350. if (!obj_desc) {
  351. obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_PACKAGE);
  352. *obj_desc_ptr = obj_desc;
  353. if (!obj_desc) {
  354. return_ACPI_STATUS(AE_NO_MEMORY);
  355. }
  356. obj_desc->package.node = parent->common.node;
  357. }
  358. /*
  359. * Allocate the element array (array of pointers to the individual
  360. * objects) based on the num_elements parameter. Add an extra pointer slot
  361. * so that the list is always null terminated.
  362. */
  363. obj_desc->package.elements = ACPI_ALLOCATE_ZEROED(((acpi_size)
  364. element_count +
  365. 1) * sizeof(void *));
  366. if (!obj_desc->package.elements) {
  367. acpi_ut_delete_object_desc(obj_desc);
  368. return_ACPI_STATUS(AE_NO_MEMORY);
  369. }
  370. obj_desc->package.count = element_count;
  371. /*
  372. * Initialize the elements of the package, up to the num_elements count.
  373. * Package is automatically padded with uninitialized (NULL) elements
  374. * if num_elements is greater than the package list length. Likewise,
  375. * Package is truncated if num_elements is less than the list length.
  376. */
  377. arg = op->common.value.arg;
  378. arg = arg->common.next;
  379. for (i = 0; arg && (i < element_count); i++) {
  380. if (arg->common.aml_opcode == AML_INT_RETURN_VALUE_OP) {
  381. if (arg->common.node->type == ACPI_TYPE_METHOD) {
  382. /*
  383. * A method reference "looks" to the parser to be a method
  384. * invocation, so we special case it here
  385. */
  386. arg->common.aml_opcode = AML_INT_NAMEPATH_OP;
  387. status =
  388. acpi_ds_build_internal_object(walk_state,
  389. arg,
  390. &obj_desc->
  391. package.
  392. elements[i]);
  393. } else {
  394. /* This package element is already built, just get it */
  395. obj_desc->package.elements[i] =
  396. ACPI_CAST_PTR(union acpi_operand_object,
  397. arg->common.node);
  398. }
  399. } else {
  400. status = acpi_ds_build_internal_object(walk_state, arg,
  401. &obj_desc->
  402. package.
  403. elements[i]);
  404. }
  405. if (*obj_desc_ptr) {
  406. /* Existing package, get existing reference count */
  407. reference_count =
  408. (*obj_desc_ptr)->common.reference_count;
  409. if (reference_count > 1) {
  410. /* Make new element ref count match original ref count */
  411. for (index = 0; index < (reference_count - 1);
  412. index++) {
  413. acpi_ut_add_reference((obj_desc->
  414. package.
  415. elements[i]));
  416. }
  417. }
  418. }
  419. arg = arg->common.next;
  420. }
  421. /* Check for match between num_elements and actual length of package_list */
  422. if (arg) {
  423. /*
  424. * num_elements was exhausted, but there are remaining elements in the
  425. * package_list.
  426. *
  427. * Note: technically, this is an error, from ACPI spec: "It is an error
  428. * for NumElements to be less than the number of elements in the
  429. * PackageList". However, for now, we just print an error message and
  430. * no exception is returned.
  431. */
  432. while (arg) {
  433. /* Find out how many elements there really are */
  434. i++;
  435. arg = arg->common.next;
  436. }
  437. ACPI_WARNING((AE_INFO,
  438. "Package List length (%X) larger than NumElements count (%X), truncated\n",
  439. i, element_count));
  440. } else if (i < element_count) {
  441. /*
  442. * Arg list (elements) was exhausted, but we did not reach num_elements count.
  443. * Note: this is not an error, the package is padded out with NULLs.
  444. */
  445. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  446. "Package List length (%X) smaller than NumElements count (%X), padded with null elements\n",
  447. i, element_count));
  448. }
  449. obj_desc->package.flags |= AOPOBJ_DATA_VALID;
  450. op->common.node = ACPI_CAST_PTR(struct acpi_namespace_node, obj_desc);
  451. return_ACPI_STATUS(status);
  452. }
  453. /*******************************************************************************
  454. *
  455. * FUNCTION: acpi_ds_create_node
  456. *
  457. * PARAMETERS: walk_state - Current walk state
  458. * Node - NS Node to be initialized
  459. * Op - Parser object to be translated
  460. *
  461. * RETURN: Status
  462. *
  463. * DESCRIPTION: Create the object to be associated with a namespace node
  464. *
  465. ******************************************************************************/
  466. acpi_status
  467. acpi_ds_create_node(struct acpi_walk_state *walk_state,
  468. struct acpi_namespace_node *node,
  469. union acpi_parse_object *op)
  470. {
  471. acpi_status status;
  472. union acpi_operand_object *obj_desc;
  473. ACPI_FUNCTION_TRACE_PTR(ds_create_node, op);
  474. /*
  475. * Because of the execution pass through the non-control-method
  476. * parts of the table, we can arrive here twice. Only init
  477. * the named object node the first time through
  478. */
  479. if (acpi_ns_get_attached_object(node)) {
  480. return_ACPI_STATUS(AE_OK);
  481. }
  482. if (!op->common.value.arg) {
  483. /* No arguments, there is nothing to do */
  484. return_ACPI_STATUS(AE_OK);
  485. }
  486. /* Build an internal object for the argument(s) */
  487. status = acpi_ds_build_internal_object(walk_state, op->common.value.arg,
  488. &obj_desc);
  489. if (ACPI_FAILURE(status)) {
  490. return_ACPI_STATUS(status);
  491. }
  492. /* Re-type the object according to its argument */
  493. node->type = obj_desc->common.type;
  494. /* Attach obj to node */
  495. status = acpi_ns_attach_object(node, obj_desc, node->type);
  496. /* Remove local reference to the object */
  497. acpi_ut_remove_reference(obj_desc);
  498. return_ACPI_STATUS(status);
  499. }
  500. #endif /* ACPI_NO_METHOD_EXECUTION */
  501. /*******************************************************************************
  502. *
  503. * FUNCTION: acpi_ds_init_object_from_op
  504. *
  505. * PARAMETERS: walk_state - Current walk state
  506. * Op - Parser op used to init the internal object
  507. * Opcode - AML opcode associated with the object
  508. * ret_obj_desc - Namespace object to be initialized
  509. *
  510. * RETURN: Status
  511. *
  512. * DESCRIPTION: Initialize a namespace object from a parser Op and its
  513. * associated arguments. The namespace object is a more compact
  514. * representation of the Op and its arguments.
  515. *
  516. ******************************************************************************/
  517. acpi_status
  518. acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
  519. union acpi_parse_object *op,
  520. u16 opcode,
  521. union acpi_operand_object **ret_obj_desc)
  522. {
  523. const struct acpi_opcode_info *op_info;
  524. union acpi_operand_object *obj_desc;
  525. acpi_status status = AE_OK;
  526. ACPI_FUNCTION_TRACE(ds_init_object_from_op);
  527. obj_desc = *ret_obj_desc;
  528. op_info = acpi_ps_get_opcode_info(opcode);
  529. if (op_info->class == AML_CLASS_UNKNOWN) {
  530. /* Unknown opcode */
  531. return_ACPI_STATUS(AE_TYPE);
  532. }
  533. /* Perform per-object initialization */
  534. switch (obj_desc->common.type) {
  535. case ACPI_TYPE_BUFFER:
  536. /*
  537. * Defer evaluation of Buffer term_arg operand
  538. */
  539. obj_desc->buffer.node =
  540. ACPI_CAST_PTR(struct acpi_namespace_node,
  541. walk_state->operands[0]);
  542. obj_desc->buffer.aml_start = op->named.data;
  543. obj_desc->buffer.aml_length = op->named.length;
  544. break;
  545. case ACPI_TYPE_PACKAGE:
  546. /*
  547. * Defer evaluation of Package term_arg operand
  548. */
  549. obj_desc->package.node =
  550. ACPI_CAST_PTR(struct acpi_namespace_node,
  551. walk_state->operands[0]);
  552. obj_desc->package.aml_start = op->named.data;
  553. obj_desc->package.aml_length = op->named.length;
  554. break;
  555. case ACPI_TYPE_INTEGER:
  556. switch (op_info->type) {
  557. case AML_TYPE_CONSTANT:
  558. /*
  559. * Resolve AML Constants here - AND ONLY HERE!
  560. * All constants are integers.
  561. * We mark the integer with a flag that indicates that it started
  562. * life as a constant -- so that stores to constants will perform
  563. * as expected (noop). zero_op is used as a placeholder for optional
  564. * target operands.
  565. */
  566. obj_desc->common.flags = AOPOBJ_AML_CONSTANT;
  567. switch (opcode) {
  568. case AML_ZERO_OP:
  569. obj_desc->integer.value = 0;
  570. break;
  571. case AML_ONE_OP:
  572. obj_desc->integer.value = 1;
  573. break;
  574. case AML_ONES_OP:
  575. obj_desc->integer.value = ACPI_INTEGER_MAX;
  576. /* Truncate value if we are executing from a 32-bit ACPI table */
  577. #ifndef ACPI_NO_METHOD_EXECUTION
  578. acpi_ex_truncate_for32bit_table(obj_desc);
  579. #endif
  580. break;
  581. case AML_REVISION_OP:
  582. obj_desc->integer.value = ACPI_CA_VERSION;
  583. break;
  584. default:
  585. ACPI_ERROR((AE_INFO,
  586. "Unknown constant opcode %X",
  587. opcode));
  588. status = AE_AML_OPERAND_TYPE;
  589. break;
  590. }
  591. break;
  592. case AML_TYPE_LITERAL:
  593. obj_desc->integer.value = op->common.value.integer;
  594. #ifndef ACPI_NO_METHOD_EXECUTION
  595. acpi_ex_truncate_for32bit_table(obj_desc);
  596. #endif
  597. break;
  598. default:
  599. ACPI_ERROR((AE_INFO, "Unknown Integer type %X",
  600. op_info->type));
  601. status = AE_AML_OPERAND_TYPE;
  602. break;
  603. }
  604. break;
  605. case ACPI_TYPE_STRING:
  606. obj_desc->string.pointer = op->common.value.string;
  607. obj_desc->string.length =
  608. (u32) ACPI_STRLEN(op->common.value.string);
  609. /*
  610. * The string is contained in the ACPI table, don't ever try
  611. * to delete it
  612. */
  613. obj_desc->common.flags |= AOPOBJ_STATIC_POINTER;
  614. break;
  615. case ACPI_TYPE_METHOD:
  616. break;
  617. case ACPI_TYPE_LOCAL_REFERENCE:
  618. switch (op_info->type) {
  619. case AML_TYPE_LOCAL_VARIABLE:
  620. /* Local ID (0-7) is (AML opcode - base AML_LOCAL_OP) */
  621. obj_desc->reference.value = opcode - AML_LOCAL_OP;
  622. obj_desc->reference.class = ACPI_REFCLASS_LOCAL;
  623. #ifndef ACPI_NO_METHOD_EXECUTION
  624. status =
  625. acpi_ds_method_data_get_node(ACPI_REFCLASS_LOCAL,
  626. obj_desc->reference.
  627. value, walk_state,
  628. ACPI_CAST_INDIRECT_PTR
  629. (struct
  630. acpi_namespace_node,
  631. &obj_desc->reference.
  632. object));
  633. #endif
  634. break;
  635. case AML_TYPE_METHOD_ARGUMENT:
  636. /* Arg ID (0-6) is (AML opcode - base AML_ARG_OP) */
  637. obj_desc->reference.value = opcode - AML_ARG_OP;
  638. obj_desc->reference.class = ACPI_REFCLASS_ARG;
  639. #ifndef ACPI_NO_METHOD_EXECUTION
  640. status = acpi_ds_method_data_get_node(ACPI_REFCLASS_ARG,
  641. obj_desc->
  642. reference.value,
  643. walk_state,
  644. ACPI_CAST_INDIRECT_PTR
  645. (struct
  646. acpi_namespace_node,
  647. &obj_desc->
  648. reference.
  649. object));
  650. #endif
  651. break;
  652. default: /* Object name or Debug object */
  653. switch (op->common.aml_opcode) {
  654. case AML_INT_NAMEPATH_OP:
  655. /* Node was saved in Op */
  656. obj_desc->reference.node = op->common.node;
  657. obj_desc->reference.object =
  658. op->common.node->object;
  659. obj_desc->reference.class = ACPI_REFCLASS_NAME;
  660. break;
  661. case AML_DEBUG_OP:
  662. obj_desc->reference.class = ACPI_REFCLASS_DEBUG;
  663. break;
  664. default:
  665. ACPI_ERROR((AE_INFO,
  666. "Unimplemented reference type for AML opcode: %4.4X",
  667. opcode));
  668. return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
  669. }
  670. break;
  671. }
  672. break;
  673. default:
  674. ACPI_ERROR((AE_INFO, "Unimplemented data type: %X",
  675. obj_desc->common.type));
  676. status = AE_AML_OPERAND_TYPE;
  677. break;
  678. }
  679. return_ACPI_STATUS(status);
  680. }