dsopcode.c 38 KB

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