dsobject.c 23 KB

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