dsopcode.c 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443
  1. /******************************************************************************
  2. *
  3. * Module Name: dsopcode - Dispatcher Op Region support and handling of
  4. * "control" opcodes
  5. *
  6. *****************************************************************************/
  7. /*
  8. * Copyright (C) 2000 - 2008, Intel Corp.
  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. #include <acpi/acpi.h>
  44. #include "accommon.h"
  45. #include "acparser.h"
  46. #include "amlcode.h"
  47. #include "acdispat.h"
  48. #include "acinterp.h"
  49. #include "acnamesp.h"
  50. #include "acevents.h"
  51. #include "actables.h"
  52. #define _COMPONENT ACPI_DISPATCHER
  53. ACPI_MODULE_NAME("dsopcode")
  54. /* Local prototypes */
  55. static acpi_status
  56. acpi_ds_execute_arguments(struct acpi_namespace_node *node,
  57. struct acpi_namespace_node *scope_node,
  58. u32 aml_length, u8 * aml_start);
  59. static acpi_status
  60. acpi_ds_init_buffer_field(u16 aml_opcode,
  61. union acpi_operand_object *obj_desc,
  62. union acpi_operand_object *buffer_desc,
  63. union acpi_operand_object *offset_desc,
  64. union acpi_operand_object *length_desc,
  65. union acpi_operand_object *result_desc);
  66. /*******************************************************************************
  67. *
  68. * FUNCTION: acpi_ds_execute_arguments
  69. *
  70. * PARAMETERS: Node - Object NS node
  71. * scope_node - Parent NS node
  72. * aml_length - Length of executable AML
  73. * aml_start - Pointer to the AML
  74. *
  75. * RETURN: Status.
  76. *
  77. * DESCRIPTION: Late (deferred) execution of region or field arguments
  78. *
  79. ******************************************************************************/
  80. static acpi_status
  81. acpi_ds_execute_arguments(struct acpi_namespace_node *node,
  82. struct acpi_namespace_node *scope_node,
  83. u32 aml_length, u8 * aml_start)
  84. {
  85. acpi_status status;
  86. union acpi_parse_object *op;
  87. struct acpi_walk_state *walk_state;
  88. ACPI_FUNCTION_TRACE(ds_execute_arguments);
  89. /*
  90. * Allocate a new parser op to be the root of the parsed tree
  91. */
  92. op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP);
  93. if (!op) {
  94. return_ACPI_STATUS(AE_NO_MEMORY);
  95. }
  96. /* Save the Node for use in acpi_ps_parse_aml */
  97. op->common.node = scope_node;
  98. /* Create and initialize a new parser state */
  99. walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL);
  100. if (!walk_state) {
  101. status = AE_NO_MEMORY;
  102. goto cleanup;
  103. }
  104. status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start,
  105. aml_length, NULL, ACPI_IMODE_LOAD_PASS1);
  106. if (ACPI_FAILURE(status)) {
  107. acpi_ds_delete_walk_state(walk_state);
  108. goto cleanup;
  109. }
  110. /* Mark this parse as a deferred opcode */
  111. walk_state->parse_flags = ACPI_PARSE_DEFERRED_OP;
  112. walk_state->deferred_node = node;
  113. /* Pass1: Parse the entire declaration */
  114. status = acpi_ps_parse_aml(walk_state);
  115. if (ACPI_FAILURE(status)) {
  116. goto cleanup;
  117. }
  118. /* Get and init the Op created above */
  119. op->common.node = node;
  120. acpi_ps_delete_parse_tree(op);
  121. /* Evaluate the deferred arguments */
  122. op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP);
  123. if (!op) {
  124. return_ACPI_STATUS(AE_NO_MEMORY);
  125. }
  126. op->common.node = scope_node;
  127. /* Create and initialize a new parser state */
  128. walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL);
  129. if (!walk_state) {
  130. status = AE_NO_MEMORY;
  131. goto cleanup;
  132. }
  133. /* Execute the opcode and arguments */
  134. status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start,
  135. aml_length, NULL, ACPI_IMODE_EXECUTE);
  136. if (ACPI_FAILURE(status)) {
  137. acpi_ds_delete_walk_state(walk_state);
  138. goto cleanup;
  139. }
  140. /* Mark this execution as a deferred opcode */
  141. walk_state->deferred_node = node;
  142. status = acpi_ps_parse_aml(walk_state);
  143. cleanup:
  144. acpi_ps_delete_parse_tree(op);
  145. return_ACPI_STATUS(status);
  146. }
  147. /*******************************************************************************
  148. *
  149. * FUNCTION: acpi_ds_get_buffer_field_arguments
  150. *
  151. * PARAMETERS: obj_desc - A valid buffer_field object
  152. *
  153. * RETURN: Status.
  154. *
  155. * DESCRIPTION: Get buffer_field Buffer and Index. This implements the late
  156. * evaluation of these field attributes.
  157. *
  158. ******************************************************************************/
  159. acpi_status
  160. acpi_ds_get_buffer_field_arguments(union acpi_operand_object *obj_desc)
  161. {
  162. union acpi_operand_object *extra_desc;
  163. struct acpi_namespace_node *node;
  164. acpi_status status;
  165. ACPI_FUNCTION_TRACE_PTR(ds_get_buffer_field_arguments, obj_desc);
  166. if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
  167. return_ACPI_STATUS(AE_OK);
  168. }
  169. /* Get the AML pointer (method object) and buffer_field node */
  170. extra_desc = acpi_ns_get_secondary_object(obj_desc);
  171. node = obj_desc->buffer_field.node;
  172. ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
  173. (ACPI_TYPE_BUFFER_FIELD, node, NULL));
  174. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] BufferField Arg Init\n",
  175. acpi_ut_get_node_name(node)));
  176. /* Execute the AML code for the term_arg arguments */
  177. status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node),
  178. extra_desc->extra.aml_length,
  179. extra_desc->extra.aml_start);
  180. return_ACPI_STATUS(status);
  181. }
  182. /*******************************************************************************
  183. *
  184. * FUNCTION: acpi_ds_get_bank_field_arguments
  185. *
  186. * PARAMETERS: obj_desc - A valid bank_field object
  187. *
  188. * RETURN: Status.
  189. *
  190. * DESCRIPTION: Get bank_field bank_value. This implements the late
  191. * evaluation of these field attributes.
  192. *
  193. ******************************************************************************/
  194. acpi_status
  195. acpi_ds_get_bank_field_arguments(union acpi_operand_object *obj_desc)
  196. {
  197. union acpi_operand_object *extra_desc;
  198. struct acpi_namespace_node *node;
  199. acpi_status status;
  200. ACPI_FUNCTION_TRACE_PTR(ds_get_bank_field_arguments, obj_desc);
  201. if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
  202. return_ACPI_STATUS(AE_OK);
  203. }
  204. /* Get the AML pointer (method object) and bank_field node */
  205. extra_desc = acpi_ns_get_secondary_object(obj_desc);
  206. node = obj_desc->bank_field.node;
  207. ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
  208. (ACPI_TYPE_LOCAL_BANK_FIELD, node, NULL));
  209. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] BankField Arg Init\n",
  210. acpi_ut_get_node_name(node)));
  211. /* Execute the AML code for the term_arg arguments */
  212. status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node),
  213. extra_desc->extra.aml_length,
  214. extra_desc->extra.aml_start);
  215. return_ACPI_STATUS(status);
  216. }
  217. /*******************************************************************************
  218. *
  219. * FUNCTION: acpi_ds_get_buffer_arguments
  220. *
  221. * PARAMETERS: obj_desc - A valid Buffer object
  222. *
  223. * RETURN: Status.
  224. *
  225. * DESCRIPTION: Get Buffer length and initializer byte list. This implements
  226. * the late evaluation of these attributes.
  227. *
  228. ******************************************************************************/
  229. acpi_status acpi_ds_get_buffer_arguments(union acpi_operand_object *obj_desc)
  230. {
  231. struct acpi_namespace_node *node;
  232. acpi_status status;
  233. ACPI_FUNCTION_TRACE_PTR(ds_get_buffer_arguments, obj_desc);
  234. if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
  235. return_ACPI_STATUS(AE_OK);
  236. }
  237. /* Get the Buffer node */
  238. node = obj_desc->buffer.node;
  239. if (!node) {
  240. ACPI_ERROR((AE_INFO,
  241. "No pointer back to NS node in buffer obj %p",
  242. obj_desc));
  243. return_ACPI_STATUS(AE_AML_INTERNAL);
  244. }
  245. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Buffer Arg Init\n"));
  246. /* Execute the AML code for the term_arg arguments */
  247. status = acpi_ds_execute_arguments(node, node,
  248. obj_desc->buffer.aml_length,
  249. obj_desc->buffer.aml_start);
  250. return_ACPI_STATUS(status);
  251. }
  252. /*******************************************************************************
  253. *
  254. * FUNCTION: acpi_ds_get_package_arguments
  255. *
  256. * PARAMETERS: obj_desc - A valid Package object
  257. *
  258. * RETURN: Status.
  259. *
  260. * DESCRIPTION: Get Package length and initializer byte list. This implements
  261. * the late evaluation of these attributes.
  262. *
  263. ******************************************************************************/
  264. acpi_status acpi_ds_get_package_arguments(union acpi_operand_object *obj_desc)
  265. {
  266. struct acpi_namespace_node *node;
  267. acpi_status status;
  268. ACPI_FUNCTION_TRACE_PTR(ds_get_package_arguments, obj_desc);
  269. if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
  270. return_ACPI_STATUS(AE_OK);
  271. }
  272. /* Get the Package node */
  273. node = obj_desc->package.node;
  274. if (!node) {
  275. ACPI_ERROR((AE_INFO,
  276. "No pointer back to NS node in package %p",
  277. obj_desc));
  278. return_ACPI_STATUS(AE_AML_INTERNAL);
  279. }
  280. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Package Arg Init\n"));
  281. /* Execute the AML code for the term_arg arguments */
  282. status = acpi_ds_execute_arguments(node, node,
  283. obj_desc->package.aml_length,
  284. obj_desc->package.aml_start);
  285. return_ACPI_STATUS(status);
  286. }
  287. /*****************************************************************************
  288. *
  289. * FUNCTION: acpi_ds_get_region_arguments
  290. *
  291. * PARAMETERS: obj_desc - A valid region object
  292. *
  293. * RETURN: Status.
  294. *
  295. * DESCRIPTION: Get region address and length. This implements the late
  296. * evaluation of these region attributes.
  297. *
  298. ****************************************************************************/
  299. acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *obj_desc)
  300. {
  301. struct acpi_namespace_node *node;
  302. acpi_status status;
  303. union acpi_operand_object *extra_desc;
  304. ACPI_FUNCTION_TRACE_PTR(ds_get_region_arguments, obj_desc);
  305. if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
  306. return_ACPI_STATUS(AE_OK);
  307. }
  308. extra_desc = acpi_ns_get_secondary_object(obj_desc);
  309. if (!extra_desc) {
  310. return_ACPI_STATUS(AE_NOT_EXIST);
  311. }
  312. /* Get the Region node */
  313. node = obj_desc->region.node;
  314. ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
  315. (ACPI_TYPE_REGION, node, NULL));
  316. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] OpRegion Arg Init at AML %p\n",
  317. acpi_ut_get_node_name(node),
  318. extra_desc->extra.aml_start));
  319. /* Execute the argument AML */
  320. status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node),
  321. extra_desc->extra.aml_length,
  322. extra_desc->extra.aml_start);
  323. return_ACPI_STATUS(status);
  324. }
  325. /*******************************************************************************
  326. *
  327. * FUNCTION: acpi_ds_initialize_region
  328. *
  329. * PARAMETERS: obj_handle - Region namespace node
  330. *
  331. * RETURN: Status
  332. *
  333. * DESCRIPTION: Front end to ev_initialize_region
  334. *
  335. ******************************************************************************/
  336. acpi_status acpi_ds_initialize_region(acpi_handle obj_handle)
  337. {
  338. union acpi_operand_object *obj_desc;
  339. acpi_status status;
  340. obj_desc = acpi_ns_get_attached_object(obj_handle);
  341. /* Namespace is NOT locked */
  342. status = acpi_ev_initialize_region(obj_desc, FALSE);
  343. return (status);
  344. }
  345. /*******************************************************************************
  346. *
  347. * FUNCTION: acpi_ds_init_buffer_field
  348. *
  349. * PARAMETERS: aml_opcode - create_xxx_field
  350. * obj_desc - buffer_field object
  351. * buffer_desc - Host Buffer
  352. * offset_desc - Offset into buffer
  353. * length_desc - Length of field (CREATE_FIELD_OP only)
  354. * result_desc - Where to store the result
  355. *
  356. * RETURN: Status
  357. *
  358. * DESCRIPTION: Perform actual initialization of a buffer field
  359. *
  360. ******************************************************************************/
  361. static acpi_status
  362. acpi_ds_init_buffer_field(u16 aml_opcode,
  363. union acpi_operand_object *obj_desc,
  364. union acpi_operand_object *buffer_desc,
  365. union acpi_operand_object *offset_desc,
  366. union acpi_operand_object *length_desc,
  367. union acpi_operand_object *result_desc)
  368. {
  369. u32 offset;
  370. u32 bit_offset;
  371. u32 bit_count;
  372. u8 field_flags;
  373. acpi_status status;
  374. ACPI_FUNCTION_TRACE_PTR(ds_init_buffer_field, obj_desc);
  375. /* Host object must be a Buffer */
  376. if (buffer_desc->common.type != ACPI_TYPE_BUFFER) {
  377. ACPI_ERROR((AE_INFO,
  378. "Target of Create Field is not a Buffer object - %s",
  379. acpi_ut_get_object_type_name(buffer_desc)));
  380. status = AE_AML_OPERAND_TYPE;
  381. goto cleanup;
  382. }
  383. /*
  384. * The last parameter to all of these opcodes (result_desc) started
  385. * out as a name_string, and should therefore now be a NS node
  386. * after resolution in acpi_ex_resolve_operands().
  387. */
  388. if (ACPI_GET_DESCRIPTOR_TYPE(result_desc) != ACPI_DESC_TYPE_NAMED) {
  389. ACPI_ERROR((AE_INFO,
  390. "(%s) destination not a NS Node [%s]",
  391. acpi_ps_get_opcode_name(aml_opcode),
  392. acpi_ut_get_descriptor_name(result_desc)));
  393. status = AE_AML_OPERAND_TYPE;
  394. goto cleanup;
  395. }
  396. offset = (u32) offset_desc->integer.value;
  397. /*
  398. * Setup the Bit offsets and counts, according to the opcode
  399. */
  400. switch (aml_opcode) {
  401. case AML_CREATE_FIELD_OP:
  402. /* Offset is in bits, count is in bits */
  403. field_flags = AML_FIELD_ACCESS_BYTE;
  404. bit_offset = offset;
  405. bit_count = (u32) length_desc->integer.value;
  406. /* Must have a valid (>0) bit count */
  407. if (bit_count == 0) {
  408. ACPI_ERROR((AE_INFO,
  409. "Attempt to CreateField of length zero"));
  410. status = AE_AML_OPERAND_VALUE;
  411. goto cleanup;
  412. }
  413. break;
  414. case AML_CREATE_BIT_FIELD_OP:
  415. /* Offset is in bits, Field is one bit */
  416. bit_offset = offset;
  417. bit_count = 1;
  418. field_flags = AML_FIELD_ACCESS_BYTE;
  419. break;
  420. case AML_CREATE_BYTE_FIELD_OP:
  421. /* Offset is in bytes, field is one byte */
  422. bit_offset = 8 * offset;
  423. bit_count = 8;
  424. field_flags = AML_FIELD_ACCESS_BYTE;
  425. break;
  426. case AML_CREATE_WORD_FIELD_OP:
  427. /* Offset is in bytes, field is one word */
  428. bit_offset = 8 * offset;
  429. bit_count = 16;
  430. field_flags = AML_FIELD_ACCESS_WORD;
  431. break;
  432. case AML_CREATE_DWORD_FIELD_OP:
  433. /* Offset is in bytes, field is one dword */
  434. bit_offset = 8 * offset;
  435. bit_count = 32;
  436. field_flags = AML_FIELD_ACCESS_DWORD;
  437. break;
  438. case AML_CREATE_QWORD_FIELD_OP:
  439. /* Offset is in bytes, field is one qword */
  440. bit_offset = 8 * offset;
  441. bit_count = 64;
  442. field_flags = AML_FIELD_ACCESS_QWORD;
  443. break;
  444. default:
  445. ACPI_ERROR((AE_INFO,
  446. "Unknown field creation opcode %02x", aml_opcode));
  447. status = AE_AML_BAD_OPCODE;
  448. goto cleanup;
  449. }
  450. /* Entire field must fit within the current length of the buffer */
  451. if ((bit_offset + bit_count) > (8 * (u32) buffer_desc->buffer.length)) {
  452. ACPI_ERROR((AE_INFO,
  453. "Field [%4.4s] at %d exceeds Buffer [%4.4s] size %d (bits)",
  454. acpi_ut_get_node_name(result_desc),
  455. bit_offset + bit_count,
  456. acpi_ut_get_node_name(buffer_desc->buffer.node),
  457. 8 * (u32) buffer_desc->buffer.length));
  458. status = AE_AML_BUFFER_LIMIT;
  459. goto cleanup;
  460. }
  461. /*
  462. * Initialize areas of the field object that are common to all fields
  463. * For field_flags, use LOCK_RULE = 0 (NO_LOCK),
  464. * UPDATE_RULE = 0 (UPDATE_PRESERVE)
  465. */
  466. status = acpi_ex_prep_common_field_object(obj_desc, field_flags, 0,
  467. bit_offset, bit_count);
  468. if (ACPI_FAILURE(status)) {
  469. goto cleanup;
  470. }
  471. obj_desc->buffer_field.buffer_obj = buffer_desc;
  472. /* Reference count for buffer_desc inherits obj_desc count */
  473. buffer_desc->common.reference_count = (u16)
  474. (buffer_desc->common.reference_count +
  475. obj_desc->common.reference_count);
  476. cleanup:
  477. /* Always delete the operands */
  478. acpi_ut_remove_reference(offset_desc);
  479. acpi_ut_remove_reference(buffer_desc);
  480. if (aml_opcode == AML_CREATE_FIELD_OP) {
  481. acpi_ut_remove_reference(length_desc);
  482. }
  483. /* On failure, delete the result descriptor */
  484. if (ACPI_FAILURE(status)) {
  485. acpi_ut_remove_reference(result_desc); /* Result descriptor */
  486. } else {
  487. /* Now the address and length are valid for this buffer_field */
  488. obj_desc->buffer_field.flags |= AOPOBJ_DATA_VALID;
  489. }
  490. return_ACPI_STATUS(status);
  491. }
  492. /*******************************************************************************
  493. *
  494. * FUNCTION: acpi_ds_eval_buffer_field_operands
  495. *
  496. * PARAMETERS: walk_state - Current walk
  497. * Op - A valid buffer_field Op object
  498. *
  499. * RETURN: Status
  500. *
  501. * DESCRIPTION: Get buffer_field Buffer and Index
  502. * Called from acpi_ds_exec_end_op during buffer_field parse tree walk
  503. *
  504. ******************************************************************************/
  505. acpi_status
  506. acpi_ds_eval_buffer_field_operands(struct acpi_walk_state *walk_state,
  507. union acpi_parse_object *op)
  508. {
  509. acpi_status status;
  510. union acpi_operand_object *obj_desc;
  511. struct acpi_namespace_node *node;
  512. union acpi_parse_object *next_op;
  513. ACPI_FUNCTION_TRACE_PTR(ds_eval_buffer_field_operands, op);
  514. /*
  515. * This is where we evaluate the address and length fields of the
  516. * create_xxx_field declaration
  517. */
  518. node = op->common.node;
  519. /* next_op points to the op that holds the Buffer */
  520. next_op = op->common.value.arg;
  521. /* Evaluate/create the address and length operands */
  522. status = acpi_ds_create_operands(walk_state, next_op);
  523. if (ACPI_FAILURE(status)) {
  524. return_ACPI_STATUS(status);
  525. }
  526. obj_desc = acpi_ns_get_attached_object(node);
  527. if (!obj_desc) {
  528. return_ACPI_STATUS(AE_NOT_EXIST);
  529. }
  530. /* Resolve the operands */
  531. status = acpi_ex_resolve_operands(op->common.aml_opcode,
  532. ACPI_WALK_OPERANDS, walk_state);
  533. if (ACPI_FAILURE(status)) {
  534. ACPI_ERROR((AE_INFO, "(%s) bad operand(s) (%X)",
  535. acpi_ps_get_opcode_name(op->common.aml_opcode),
  536. status));
  537. return_ACPI_STATUS(status);
  538. }
  539. /* Initialize the Buffer Field */
  540. if (op->common.aml_opcode == AML_CREATE_FIELD_OP) {
  541. /* NOTE: Slightly different operands for this opcode */
  542. status =
  543. acpi_ds_init_buffer_field(op->common.aml_opcode, obj_desc,
  544. walk_state->operands[0],
  545. walk_state->operands[1],
  546. walk_state->operands[2],
  547. walk_state->operands[3]);
  548. } else {
  549. /* All other, create_xxx_field opcodes */
  550. status =
  551. acpi_ds_init_buffer_field(op->common.aml_opcode, obj_desc,
  552. walk_state->operands[0],
  553. walk_state->operands[1], NULL,
  554. walk_state->operands[2]);
  555. }
  556. return_ACPI_STATUS(status);
  557. }
  558. /*******************************************************************************
  559. *
  560. * FUNCTION: acpi_ds_eval_region_operands
  561. *
  562. * PARAMETERS: walk_state - Current walk
  563. * Op - A valid region Op object
  564. *
  565. * RETURN: Status
  566. *
  567. * DESCRIPTION: Get region address and length
  568. * Called from acpi_ds_exec_end_op during op_region parse tree walk
  569. *
  570. ******************************************************************************/
  571. acpi_status
  572. acpi_ds_eval_region_operands(struct acpi_walk_state *walk_state,
  573. union acpi_parse_object *op)
  574. {
  575. acpi_status status;
  576. union acpi_operand_object *obj_desc;
  577. union acpi_operand_object *operand_desc;
  578. struct acpi_namespace_node *node;
  579. union acpi_parse_object *next_op;
  580. ACPI_FUNCTION_TRACE_PTR(ds_eval_region_operands, op);
  581. /*
  582. * This is where we evaluate the address and length fields of the
  583. * op_region declaration
  584. */
  585. node = op->common.node;
  586. /* next_op points to the op that holds the space_iD */
  587. next_op = op->common.value.arg;
  588. /* next_op points to address op */
  589. next_op = next_op->common.next;
  590. /* Evaluate/create the address and length operands */
  591. status = acpi_ds_create_operands(walk_state, next_op);
  592. if (ACPI_FAILURE(status)) {
  593. return_ACPI_STATUS(status);
  594. }
  595. /* Resolve the length and address operands to numbers */
  596. status = acpi_ex_resolve_operands(op->common.aml_opcode,
  597. ACPI_WALK_OPERANDS, walk_state);
  598. if (ACPI_FAILURE(status)) {
  599. return_ACPI_STATUS(status);
  600. }
  601. obj_desc = acpi_ns_get_attached_object(node);
  602. if (!obj_desc) {
  603. return_ACPI_STATUS(AE_NOT_EXIST);
  604. }
  605. /*
  606. * Get the length operand and save it
  607. * (at Top of stack)
  608. */
  609. operand_desc = walk_state->operands[walk_state->num_operands - 1];
  610. obj_desc->region.length = (u32) operand_desc->integer.value;
  611. acpi_ut_remove_reference(operand_desc);
  612. /*
  613. * Get the address and save it
  614. * (at top of stack - 1)
  615. */
  616. operand_desc = walk_state->operands[walk_state->num_operands - 2];
  617. obj_desc->region.address = (acpi_physical_address)
  618. operand_desc->integer.value;
  619. acpi_ut_remove_reference(operand_desc);
  620. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n",
  621. obj_desc,
  622. ACPI_FORMAT_NATIVE_UINT(obj_desc->region.address),
  623. obj_desc->region.length));
  624. /* Now the address and length are valid for this opregion */
  625. obj_desc->region.flags |= AOPOBJ_DATA_VALID;
  626. return_ACPI_STATUS(status);
  627. }
  628. /*******************************************************************************
  629. *
  630. * FUNCTION: acpi_ds_eval_table_region_operands
  631. *
  632. * PARAMETERS: walk_state - Current walk
  633. * Op - A valid region Op object
  634. *
  635. * RETURN: Status
  636. *
  637. * DESCRIPTION: Get region address and length
  638. * Called from acpi_ds_exec_end_op during data_table_region parse tree walk
  639. *
  640. ******************************************************************************/
  641. acpi_status
  642. acpi_ds_eval_table_region_operands(struct acpi_walk_state *walk_state,
  643. union acpi_parse_object *op)
  644. {
  645. acpi_status status;
  646. union acpi_operand_object *obj_desc;
  647. union acpi_operand_object **operand;
  648. struct acpi_namespace_node *node;
  649. union acpi_parse_object *next_op;
  650. u32 table_index;
  651. struct acpi_table_header *table;
  652. ACPI_FUNCTION_TRACE_PTR(ds_eval_table_region_operands, op);
  653. /*
  654. * This is where we evaluate the signature_string and oem_iDString
  655. * and oem_table_iDString of the data_table_region declaration
  656. */
  657. node = op->common.node;
  658. /* next_op points to signature_string op */
  659. next_op = op->common.value.arg;
  660. /*
  661. * Evaluate/create the signature_string and oem_iDString
  662. * and oem_table_iDString operands
  663. */
  664. status = acpi_ds_create_operands(walk_state, next_op);
  665. if (ACPI_FAILURE(status)) {
  666. return_ACPI_STATUS(status);
  667. }
  668. /*
  669. * Resolve the signature_string and oem_iDString
  670. * and oem_table_iDString operands
  671. */
  672. status = acpi_ex_resolve_operands(op->common.aml_opcode,
  673. ACPI_WALK_OPERANDS, walk_state);
  674. if (ACPI_FAILURE(status)) {
  675. return_ACPI_STATUS(status);
  676. }
  677. operand = &walk_state->operands[0];
  678. /* Find the ACPI table */
  679. status = acpi_tb_find_table(operand[0]->string.pointer,
  680. operand[1]->string.pointer,
  681. operand[2]->string.pointer, &table_index);
  682. if (ACPI_FAILURE(status)) {
  683. return_ACPI_STATUS(status);
  684. }
  685. acpi_ut_remove_reference(operand[0]);
  686. acpi_ut_remove_reference(operand[1]);
  687. acpi_ut_remove_reference(operand[2]);
  688. status = acpi_get_table_by_index(table_index, &table);
  689. if (ACPI_FAILURE(status)) {
  690. return_ACPI_STATUS(status);
  691. }
  692. obj_desc = acpi_ns_get_attached_object(node);
  693. if (!obj_desc) {
  694. return_ACPI_STATUS(AE_NOT_EXIST);
  695. }
  696. obj_desc->region.address =
  697. (acpi_physical_address) ACPI_TO_INTEGER(table);
  698. obj_desc->region.length = table->length;
  699. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n",
  700. obj_desc,
  701. ACPI_FORMAT_NATIVE_UINT(obj_desc->region.address),
  702. obj_desc->region.length));
  703. /* Now the address and length are valid for this opregion */
  704. obj_desc->region.flags |= AOPOBJ_DATA_VALID;
  705. return_ACPI_STATUS(status);
  706. }
  707. /*******************************************************************************
  708. *
  709. * FUNCTION: acpi_ds_eval_data_object_operands
  710. *
  711. * PARAMETERS: walk_state - Current walk
  712. * Op - A valid data_object Op object
  713. * obj_desc - data_object
  714. *
  715. * RETURN: Status
  716. *
  717. * DESCRIPTION: Get the operands and complete the following data object types:
  718. * Buffer, Package.
  719. *
  720. ******************************************************************************/
  721. acpi_status
  722. acpi_ds_eval_data_object_operands(struct acpi_walk_state *walk_state,
  723. union acpi_parse_object *op,
  724. union acpi_operand_object *obj_desc)
  725. {
  726. acpi_status status;
  727. union acpi_operand_object *arg_desc;
  728. u32 length;
  729. ACPI_FUNCTION_TRACE(ds_eval_data_object_operands);
  730. /* The first operand (for all of these data objects) is the length */
  731. /*
  732. * Set proper index into operand stack for acpi_ds_obj_stack_push
  733. * invoked inside acpi_ds_create_operand.
  734. */
  735. walk_state->operand_index = walk_state->num_operands;
  736. status = acpi_ds_create_operand(walk_state, op->common.value.arg, 1);
  737. if (ACPI_FAILURE(status)) {
  738. return_ACPI_STATUS(status);
  739. }
  740. status = acpi_ex_resolve_operands(walk_state->opcode,
  741. &(walk_state->
  742. operands[walk_state->num_operands -
  743. 1]), walk_state);
  744. if (ACPI_FAILURE(status)) {
  745. return_ACPI_STATUS(status);
  746. }
  747. /* Extract length operand */
  748. arg_desc = walk_state->operands[walk_state->num_operands - 1];
  749. length = (u32) arg_desc->integer.value;
  750. /* Cleanup for length operand */
  751. status = acpi_ds_obj_stack_pop(1, walk_state);
  752. if (ACPI_FAILURE(status)) {
  753. return_ACPI_STATUS(status);
  754. }
  755. acpi_ut_remove_reference(arg_desc);
  756. /*
  757. * Create the actual data object
  758. */
  759. switch (op->common.aml_opcode) {
  760. case AML_BUFFER_OP:
  761. status =
  762. acpi_ds_build_internal_buffer_obj(walk_state, op, length,
  763. &obj_desc);
  764. break;
  765. case AML_PACKAGE_OP:
  766. case AML_VAR_PACKAGE_OP:
  767. status =
  768. acpi_ds_build_internal_package_obj(walk_state, op, length,
  769. &obj_desc);
  770. break;
  771. default:
  772. return_ACPI_STATUS(AE_AML_BAD_OPCODE);
  773. }
  774. if (ACPI_SUCCESS(status)) {
  775. /*
  776. * Return the object in the walk_state, unless the parent is a package -
  777. * in this case, the return object will be stored in the parse tree
  778. * for the package.
  779. */
  780. if ((!op->common.parent) ||
  781. ((op->common.parent->common.aml_opcode != AML_PACKAGE_OP) &&
  782. (op->common.parent->common.aml_opcode !=
  783. AML_VAR_PACKAGE_OP)
  784. && (op->common.parent->common.aml_opcode != AML_NAME_OP))) {
  785. walk_state->result_obj = obj_desc;
  786. }
  787. }
  788. return_ACPI_STATUS(status);
  789. }
  790. /*******************************************************************************
  791. *
  792. * FUNCTION: acpi_ds_eval_bank_field_operands
  793. *
  794. * PARAMETERS: walk_state - Current walk
  795. * Op - A valid bank_field Op object
  796. *
  797. * RETURN: Status
  798. *
  799. * DESCRIPTION: Get bank_field bank_value
  800. * Called from acpi_ds_exec_end_op during bank_field parse tree walk
  801. *
  802. ******************************************************************************/
  803. acpi_status
  804. acpi_ds_eval_bank_field_operands(struct acpi_walk_state *walk_state,
  805. union acpi_parse_object *op)
  806. {
  807. acpi_status status;
  808. union acpi_operand_object *obj_desc;
  809. union acpi_operand_object *operand_desc;
  810. struct acpi_namespace_node *node;
  811. union acpi_parse_object *next_op;
  812. union acpi_parse_object *arg;
  813. ACPI_FUNCTION_TRACE_PTR(ds_eval_bank_field_operands, op);
  814. /*
  815. * This is where we evaluate the bank_value field of the
  816. * bank_field declaration
  817. */
  818. /* next_op points to the op that holds the Region */
  819. next_op = op->common.value.arg;
  820. /* next_op points to the op that holds the Bank Register */
  821. next_op = next_op->common.next;
  822. /* next_op points to the op that holds the Bank Value */
  823. next_op = next_op->common.next;
  824. /*
  825. * Set proper index into operand stack for acpi_ds_obj_stack_push
  826. * invoked inside acpi_ds_create_operand.
  827. *
  828. * We use walk_state->Operands[0] to store the evaluated bank_value
  829. */
  830. walk_state->operand_index = 0;
  831. status = acpi_ds_create_operand(walk_state, next_op, 0);
  832. if (ACPI_FAILURE(status)) {
  833. return_ACPI_STATUS(status);
  834. }
  835. status = acpi_ex_resolve_to_value(&walk_state->operands[0], walk_state);
  836. if (ACPI_FAILURE(status)) {
  837. return_ACPI_STATUS(status);
  838. }
  839. ACPI_DUMP_OPERANDS(ACPI_WALK_OPERANDS,
  840. acpi_ps_get_opcode_name(op->common.aml_opcode), 1);
  841. /*
  842. * Get the bank_value operand and save it
  843. * (at Top of stack)
  844. */
  845. operand_desc = walk_state->operands[0];
  846. /* Arg points to the start Bank Field */
  847. arg = acpi_ps_get_arg(op, 4);
  848. while (arg) {
  849. /* Ignore OFFSET and ACCESSAS terms here */
  850. if (arg->common.aml_opcode == AML_INT_NAMEDFIELD_OP) {
  851. node = arg->common.node;
  852. obj_desc = acpi_ns_get_attached_object(node);
  853. if (!obj_desc) {
  854. return_ACPI_STATUS(AE_NOT_EXIST);
  855. }
  856. obj_desc->bank_field.value =
  857. (u32) operand_desc->integer.value;
  858. }
  859. /* Move to next field in the list */
  860. arg = arg->common.next;
  861. }
  862. acpi_ut_remove_reference(operand_desc);
  863. return_ACPI_STATUS(status);
  864. }
  865. /*******************************************************************************
  866. *
  867. * FUNCTION: acpi_ds_exec_begin_control_op
  868. *
  869. * PARAMETERS: walk_list - The list that owns the walk stack
  870. * Op - The control Op
  871. *
  872. * RETURN: Status
  873. *
  874. * DESCRIPTION: Handles all control ops encountered during control method
  875. * execution.
  876. *
  877. ******************************************************************************/
  878. acpi_status
  879. acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state,
  880. union acpi_parse_object *op)
  881. {
  882. acpi_status status = AE_OK;
  883. union acpi_generic_state *control_state;
  884. ACPI_FUNCTION_NAME(ds_exec_begin_control_op);
  885. ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", op,
  886. op->common.aml_opcode, walk_state));
  887. switch (op->common.aml_opcode) {
  888. case AML_WHILE_OP:
  889. /*
  890. * If this is an additional iteration of a while loop, continue.
  891. * There is no need to allocate a new control state.
  892. */
  893. if (walk_state->control_state) {
  894. if (walk_state->control_state->control.aml_predicate_start
  895. == (walk_state->parser_state.aml - 1)) {
  896. /* Reset the state to start-of-loop */
  897. walk_state->control_state->common.state =
  898. ACPI_CONTROL_CONDITIONAL_EXECUTING;
  899. break;
  900. }
  901. }
  902. /*lint -fallthrough */
  903. case AML_IF_OP:
  904. /*
  905. * IF/WHILE: Create a new control state to manage these
  906. * constructs. We need to manage these as a stack, in order
  907. * to handle nesting.
  908. */
  909. control_state = acpi_ut_create_control_state();
  910. if (!control_state) {
  911. status = AE_NO_MEMORY;
  912. break;
  913. }
  914. /*
  915. * Save a pointer to the predicate for multiple executions
  916. * of a loop
  917. */
  918. control_state->control.aml_predicate_start =
  919. walk_state->parser_state.aml - 1;
  920. control_state->control.package_end =
  921. walk_state->parser_state.pkg_end;
  922. control_state->control.opcode = op->common.aml_opcode;
  923. /* Push the control state on this walk's control stack */
  924. acpi_ut_push_generic_state(&walk_state->control_state,
  925. control_state);
  926. break;
  927. case AML_ELSE_OP:
  928. /* Predicate is in the state object */
  929. /* If predicate is true, the IF was executed, ignore ELSE part */
  930. if (walk_state->last_predicate) {
  931. status = AE_CTRL_TRUE;
  932. }
  933. break;
  934. case AML_RETURN_OP:
  935. break;
  936. default:
  937. break;
  938. }
  939. return (status);
  940. }
  941. /*******************************************************************************
  942. *
  943. * FUNCTION: acpi_ds_exec_end_control_op
  944. *
  945. * PARAMETERS: walk_list - The list that owns the walk stack
  946. * Op - The control Op
  947. *
  948. * RETURN: Status
  949. *
  950. * DESCRIPTION: Handles all control ops encountered during control method
  951. * execution.
  952. *
  953. ******************************************************************************/
  954. acpi_status
  955. acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state,
  956. union acpi_parse_object * op)
  957. {
  958. acpi_status status = AE_OK;
  959. union acpi_generic_state *control_state;
  960. ACPI_FUNCTION_NAME(ds_exec_end_control_op);
  961. switch (op->common.aml_opcode) {
  962. case AML_IF_OP:
  963. ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", op));
  964. /*
  965. * Save the result of the predicate in case there is an
  966. * ELSE to come
  967. */
  968. walk_state->last_predicate =
  969. (u8) walk_state->control_state->common.value;
  970. /*
  971. * Pop the control state that was created at the start
  972. * of the IF and free it
  973. */
  974. control_state =
  975. acpi_ut_pop_generic_state(&walk_state->control_state);
  976. acpi_ut_delete_generic_state(control_state);
  977. break;
  978. case AML_ELSE_OP:
  979. break;
  980. case AML_WHILE_OP:
  981. ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", op));
  982. control_state = walk_state->control_state;
  983. if (control_state->common.value) {
  984. /* Predicate was true, the body of the loop was just executed */
  985. /*
  986. * This loop counter mechanism allows the interpreter to escape
  987. * possibly infinite loops. This can occur in poorly written AML
  988. * when the hardware does not respond within a while loop and the
  989. * loop does not implement a timeout.
  990. */
  991. control_state->control.loop_count++;
  992. if (control_state->control.loop_count >
  993. ACPI_MAX_LOOP_ITERATIONS) {
  994. status = AE_AML_INFINITE_LOOP;
  995. break;
  996. }
  997. /*
  998. * Go back and evaluate the predicate and maybe execute the loop
  999. * another time
  1000. */
  1001. status = AE_CTRL_PENDING;
  1002. walk_state->aml_last_while =
  1003. control_state->control.aml_predicate_start;
  1004. break;
  1005. }
  1006. /* Predicate was false, terminate this while loop */
  1007. ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
  1008. "[WHILE_OP] termination! Op=%p\n", op));
  1009. /* Pop this control state and free it */
  1010. control_state =
  1011. acpi_ut_pop_generic_state(&walk_state->control_state);
  1012. acpi_ut_delete_generic_state(control_state);
  1013. break;
  1014. case AML_RETURN_OP:
  1015. ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
  1016. "[RETURN_OP] Op=%p Arg=%p\n", op,
  1017. op->common.value.arg));
  1018. /*
  1019. * One optional operand -- the return value
  1020. * It can be either an immediate operand or a result that
  1021. * has been bubbled up the tree
  1022. */
  1023. if (op->common.value.arg) {
  1024. /* Since we have a real Return(), delete any implicit return */
  1025. acpi_ds_clear_implicit_return(walk_state);
  1026. /* Return statement has an immediate operand */
  1027. status =
  1028. acpi_ds_create_operands(walk_state,
  1029. op->common.value.arg);
  1030. if (ACPI_FAILURE(status)) {
  1031. return (status);
  1032. }
  1033. /*
  1034. * If value being returned is a Reference (such as
  1035. * an arg or local), resolve it now because it may
  1036. * cease to exist at the end of the method.
  1037. */
  1038. status =
  1039. acpi_ex_resolve_to_value(&walk_state->operands[0],
  1040. walk_state);
  1041. if (ACPI_FAILURE(status)) {
  1042. return (status);
  1043. }
  1044. /*
  1045. * Get the return value and save as the last result
  1046. * value. This is the only place where walk_state->return_desc
  1047. * is set to anything other than zero!
  1048. */
  1049. walk_state->return_desc = walk_state->operands[0];
  1050. } else if (walk_state->result_count) {
  1051. /* Since we have a real Return(), delete any implicit return */
  1052. acpi_ds_clear_implicit_return(walk_state);
  1053. /*
  1054. * The return value has come from a previous calculation.
  1055. *
  1056. * If value being returned is a Reference (such as
  1057. * an arg or local), resolve it now because it may
  1058. * cease to exist at the end of the method.
  1059. *
  1060. * Allow references created by the Index operator to return unchanged.
  1061. */
  1062. if ((ACPI_GET_DESCRIPTOR_TYPE
  1063. (walk_state->results->results.obj_desc[0]) ==
  1064. ACPI_DESC_TYPE_OPERAND)
  1065. && ((walk_state->results->results.obj_desc[0])->
  1066. common.type == ACPI_TYPE_LOCAL_REFERENCE)
  1067. && ((walk_state->results->results.obj_desc[0])->
  1068. reference.class != ACPI_REFCLASS_INDEX)) {
  1069. status =
  1070. acpi_ex_resolve_to_value(&walk_state->
  1071. results->results.
  1072. obj_desc[0],
  1073. walk_state);
  1074. if (ACPI_FAILURE(status)) {
  1075. return (status);
  1076. }
  1077. }
  1078. walk_state->return_desc =
  1079. walk_state->results->results.obj_desc[0];
  1080. } else {
  1081. /* No return operand */
  1082. if (walk_state->num_operands) {
  1083. acpi_ut_remove_reference(walk_state->
  1084. operands[0]);
  1085. }
  1086. walk_state->operands[0] = NULL;
  1087. walk_state->num_operands = 0;
  1088. walk_state->return_desc = NULL;
  1089. }
  1090. ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
  1091. "Completed RETURN_OP State=%p, RetVal=%p\n",
  1092. walk_state, walk_state->return_desc));
  1093. /* End the control method execution right now */
  1094. status = AE_CTRL_TERMINATE;
  1095. break;
  1096. case AML_NOOP_OP:
  1097. /* Just do nothing! */
  1098. break;
  1099. case AML_BREAK_POINT_OP:
  1100. /* Call up to the OS service layer to handle this */
  1101. status =
  1102. acpi_os_signal(ACPI_SIGNAL_BREAKPOINT,
  1103. "Executed AML Breakpoint opcode");
  1104. /* If and when it returns, all done. */
  1105. break;
  1106. case AML_BREAK_OP:
  1107. case AML_CONTINUE_OP: /* ACPI 2.0 */
  1108. /* Pop and delete control states until we find a while */
  1109. while (walk_state->control_state &&
  1110. (walk_state->control_state->control.opcode !=
  1111. AML_WHILE_OP)) {
  1112. control_state =
  1113. acpi_ut_pop_generic_state(&walk_state->
  1114. control_state);
  1115. acpi_ut_delete_generic_state(control_state);
  1116. }
  1117. /* No while found? */
  1118. if (!walk_state->control_state) {
  1119. return (AE_AML_NO_WHILE);
  1120. }
  1121. /* Was: walk_state->aml_last_while = walk_state->control_state->Control.aml_predicate_start; */
  1122. walk_state->aml_last_while =
  1123. walk_state->control_state->control.package_end;
  1124. /* Return status depending on opcode */
  1125. if (op->common.aml_opcode == AML_BREAK_OP) {
  1126. status = AE_CTRL_BREAK;
  1127. } else {
  1128. status = AE_CTRL_CONTINUE;
  1129. }
  1130. break;
  1131. default:
  1132. ACPI_ERROR((AE_INFO, "Unknown control opcode=%X Op=%p",
  1133. op->common.aml_opcode, op));
  1134. status = AE_AML_BAD_OPCODE;
  1135. break;
  1136. }
  1137. return (status);
  1138. }