dsfield.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805
  1. // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
  2. /******************************************************************************
  3. *
  4. * Module Name: dsfield - Dispatcher field routines
  5. *
  6. * Copyright (C) 2000 - 2018, Intel Corp.
  7. *
  8. *****************************************************************************/
  9. #include <acpi/acpi.h>
  10. #include "accommon.h"
  11. #include "amlcode.h"
  12. #include "acdispat.h"
  13. #include "acinterp.h"
  14. #include "acnamesp.h"
  15. #include "acparser.h"
  16. #ifdef ACPI_EXEC_APP
  17. #include "aecommon.h"
  18. #endif
  19. #define _COMPONENT ACPI_DISPATCHER
  20. ACPI_MODULE_NAME("dsfield")
  21. /* Local prototypes */
  22. #ifdef ACPI_ASL_COMPILER
  23. #include "acdisasm.h"
  24. static acpi_status
  25. acpi_ds_create_external_region(acpi_status lookup_status,
  26. union acpi_parse_object *op,
  27. char *path,
  28. struct acpi_walk_state *walk_state,
  29. struct acpi_namespace_node **node);
  30. #endif
  31. static acpi_status
  32. acpi_ds_get_field_names(struct acpi_create_field_info *info,
  33. struct acpi_walk_state *walk_state,
  34. union acpi_parse_object *arg);
  35. #ifdef ACPI_ASL_COMPILER
  36. /*******************************************************************************
  37. *
  38. * FUNCTION: acpi_ds_create_external_region (iASL Disassembler only)
  39. *
  40. * PARAMETERS: lookup_status - Status from ns_lookup operation
  41. * op - Op containing the Field definition and args
  42. * path - Pathname of the region
  43. * ` walk_state - Current method state
  44. * node - Where the new region node is returned
  45. *
  46. * RETURN: Status
  47. *
  48. * DESCRIPTION: Add region to the external list if NOT_FOUND. Create a new
  49. * region node/object.
  50. *
  51. ******************************************************************************/
  52. static acpi_status
  53. acpi_ds_create_external_region(acpi_status lookup_status,
  54. union acpi_parse_object *op,
  55. char *path,
  56. struct acpi_walk_state *walk_state,
  57. struct acpi_namespace_node **node)
  58. {
  59. acpi_status status;
  60. union acpi_operand_object *obj_desc;
  61. if (lookup_status != AE_NOT_FOUND) {
  62. return (lookup_status);
  63. }
  64. /*
  65. * Table disassembly:
  66. * operation_region not found. Generate an External for it, and
  67. * insert the name into the namespace.
  68. */
  69. acpi_dm_add_op_to_external_list(op, path, ACPI_TYPE_REGION, 0, 0);
  70. status = acpi_ns_lookup(walk_state->scope_info, path, ACPI_TYPE_REGION,
  71. ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT,
  72. walk_state, node);
  73. if (ACPI_FAILURE(status)) {
  74. return (status);
  75. }
  76. /* Must create and install a region object for the new node */
  77. obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_REGION);
  78. if (!obj_desc) {
  79. return (AE_NO_MEMORY);
  80. }
  81. obj_desc->region.node = *node;
  82. status = acpi_ns_attach_object(*node, obj_desc, ACPI_TYPE_REGION);
  83. return (status);
  84. }
  85. #endif
  86. /*******************************************************************************
  87. *
  88. * FUNCTION: acpi_ds_create_buffer_field
  89. *
  90. * PARAMETERS: op - Current parse op (create_XXField)
  91. * walk_state - Current state
  92. *
  93. * RETURN: Status
  94. *
  95. * DESCRIPTION: Execute the create_field operators:
  96. * create_bit_field_op,
  97. * create_byte_field_op,
  98. * create_word_field_op,
  99. * create_dword_field_op,
  100. * create_qword_field_op,
  101. * create_field_op (all of which define a field in a buffer)
  102. *
  103. ******************************************************************************/
  104. acpi_status
  105. acpi_ds_create_buffer_field(union acpi_parse_object *op,
  106. struct acpi_walk_state *walk_state)
  107. {
  108. union acpi_parse_object *arg;
  109. struct acpi_namespace_node *node;
  110. acpi_status status;
  111. union acpi_operand_object *obj_desc;
  112. union acpi_operand_object *second_desc = NULL;
  113. u32 flags;
  114. ACPI_FUNCTION_TRACE(ds_create_buffer_field);
  115. /*
  116. * Get the name_string argument (name of the new buffer_field)
  117. */
  118. if (op->common.aml_opcode == AML_CREATE_FIELD_OP) {
  119. /* For create_field, name is the 4th argument */
  120. arg = acpi_ps_get_arg(op, 3);
  121. } else {
  122. /* For all other create_XXXField operators, name is the 3rd argument */
  123. arg = acpi_ps_get_arg(op, 2);
  124. }
  125. if (!arg) {
  126. return_ACPI_STATUS(AE_AML_NO_OPERAND);
  127. }
  128. if (walk_state->deferred_node) {
  129. node = walk_state->deferred_node;
  130. status = AE_OK;
  131. } else {
  132. /* Execute flag should always be set when this function is entered */
  133. if (!(walk_state->parse_flags & ACPI_PARSE_EXECUTE)) {
  134. ACPI_ERROR((AE_INFO, "Parse execute mode is not set"));
  135. return_ACPI_STATUS(AE_AML_INTERNAL);
  136. }
  137. /* Creating new namespace node, should not already exist */
  138. flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE |
  139. ACPI_NS_ERROR_IF_FOUND;
  140. /*
  141. * Mark node temporary if we are executing a normal control
  142. * method. (Don't mark if this is a module-level code method)
  143. */
  144. if (walk_state->method_node &&
  145. !(walk_state->parse_flags & ACPI_PARSE_MODULE_LEVEL)) {
  146. flags |= ACPI_NS_TEMPORARY;
  147. }
  148. /* Enter the name_string into the namespace */
  149. status = acpi_ns_lookup(walk_state->scope_info,
  150. arg->common.value.string, ACPI_TYPE_ANY,
  151. ACPI_IMODE_LOAD_PASS1, flags,
  152. walk_state, &node);
  153. if (ACPI_FAILURE(status)) {
  154. ACPI_ERROR_NAMESPACE(walk_state->scope_info,
  155. arg->common.value.string, status);
  156. return_ACPI_STATUS(status);
  157. }
  158. }
  159. /*
  160. * We could put the returned object (Node) on the object stack for later,
  161. * but for now, we will put it in the "op" object that the parser uses,
  162. * so we can get it again at the end of this scope.
  163. */
  164. op->common.node = node;
  165. /*
  166. * If there is no object attached to the node, this node was just created
  167. * and we need to create the field object. Otherwise, this was a lookup
  168. * of an existing node and we don't want to create the field object again.
  169. */
  170. obj_desc = acpi_ns_get_attached_object(node);
  171. if (obj_desc) {
  172. return_ACPI_STATUS(AE_OK);
  173. }
  174. /*
  175. * The Field definition is not fully parsed at this time.
  176. * (We must save the address of the AML for the buffer and index operands)
  177. */
  178. /* Create the buffer field object */
  179. obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER_FIELD);
  180. if (!obj_desc) {
  181. status = AE_NO_MEMORY;
  182. goto cleanup;
  183. }
  184. /*
  185. * Remember location in AML stream of the field unit opcode and operands
  186. * -- since the buffer and index operands must be evaluated.
  187. */
  188. second_desc = obj_desc->common.next_object;
  189. second_desc->extra.aml_start = op->named.data;
  190. second_desc->extra.aml_length = op->named.length;
  191. obj_desc->buffer_field.node = node;
  192. /* Attach constructed field descriptors to parent node */
  193. status = acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_BUFFER_FIELD);
  194. if (ACPI_FAILURE(status)) {
  195. goto cleanup;
  196. }
  197. cleanup:
  198. /* Remove local reference to the object */
  199. acpi_ut_remove_reference(obj_desc);
  200. return_ACPI_STATUS(status);
  201. }
  202. /*******************************************************************************
  203. *
  204. * FUNCTION: acpi_ds_get_field_names
  205. *
  206. * PARAMETERS: info - create_field info structure
  207. * ` walk_state - Current method state
  208. * arg - First parser arg for the field name list
  209. *
  210. * RETURN: Status
  211. *
  212. * DESCRIPTION: Process all named fields in a field declaration. Names are
  213. * entered into the namespace.
  214. *
  215. ******************************************************************************/
  216. static acpi_status
  217. acpi_ds_get_field_names(struct acpi_create_field_info *info,
  218. struct acpi_walk_state *walk_state,
  219. union acpi_parse_object *arg)
  220. {
  221. acpi_status status;
  222. u64 position;
  223. union acpi_parse_object *child;
  224. #ifdef ACPI_EXEC_APP
  225. u64 value = 0;
  226. union acpi_operand_object *result_desc;
  227. union acpi_operand_object *obj_desc;
  228. char *name_path;
  229. #endif
  230. ACPI_FUNCTION_TRACE_PTR(ds_get_field_names, info);
  231. /* First field starts at bit zero */
  232. info->field_bit_position = 0;
  233. /* Process all elements in the field list (of parse nodes) */
  234. while (arg) {
  235. /*
  236. * Four types of field elements are handled:
  237. * 1) name - Enters a new named field into the namespace
  238. * 2) offset - specifies a bit offset
  239. * 3) access_as - changes the access mode/attributes
  240. * 4) connection - Associate a resource template with the field
  241. */
  242. switch (arg->common.aml_opcode) {
  243. case AML_INT_RESERVEDFIELD_OP:
  244. position = (u64)info->field_bit_position +
  245. (u64)arg->common.value.size;
  246. if (position > ACPI_UINT32_MAX) {
  247. ACPI_ERROR((AE_INFO,
  248. "Bit offset within field too large (> 0xFFFFFFFF)"));
  249. return_ACPI_STATUS(AE_SUPPORT);
  250. }
  251. info->field_bit_position = (u32) position;
  252. break;
  253. case AML_INT_ACCESSFIELD_OP:
  254. case AML_INT_EXTACCESSFIELD_OP:
  255. /*
  256. * Get new access_type, access_attribute, and access_length fields
  257. * -- to be used for all field units that follow, until the
  258. * end-of-field or another access_as keyword is encountered.
  259. * NOTE. These three bytes are encoded in the integer value
  260. * of the parseop for convenience.
  261. *
  262. * In field_flags, preserve the flag bits other than the
  263. * ACCESS_TYPE bits.
  264. */
  265. /* access_type (byte_acc, word_acc, etc.) */
  266. info->field_flags = (u8)
  267. ((info->
  268. field_flags & ~(AML_FIELD_ACCESS_TYPE_MASK)) |
  269. ((u8)((u32)(arg->common.value.integer & 0x07))));
  270. /* access_attribute (attrib_quick, attrib_byte, etc.) */
  271. info->attribute = (u8)
  272. ((arg->common.value.integer >> 8) & 0xFF);
  273. /* access_length (for serial/buffer protocols) */
  274. info->access_length = (u8)
  275. ((arg->common.value.integer >> 16) & 0xFF);
  276. break;
  277. case AML_INT_CONNECTION_OP:
  278. /*
  279. * Clear any previous connection. New connection is used for all
  280. * fields that follow, similar to access_as
  281. */
  282. info->resource_buffer = NULL;
  283. info->connection_node = NULL;
  284. info->pin_number_index = 0;
  285. /*
  286. * A Connection() is either an actual resource descriptor (buffer)
  287. * or a named reference to a resource template
  288. */
  289. child = arg->common.value.arg;
  290. if (child->common.aml_opcode == AML_INT_BYTELIST_OP) {
  291. info->resource_buffer = child->named.data;
  292. info->resource_length =
  293. (u16)child->named.value.integer;
  294. } else {
  295. /* Lookup the Connection() namepath, it should already exist */
  296. status = acpi_ns_lookup(walk_state->scope_info,
  297. child->common.value.
  298. name, ACPI_TYPE_ANY,
  299. ACPI_IMODE_EXECUTE,
  300. ACPI_NS_DONT_OPEN_SCOPE,
  301. walk_state,
  302. &info->connection_node);
  303. if (ACPI_FAILURE(status)) {
  304. ACPI_ERROR_NAMESPACE(walk_state->
  305. scope_info,
  306. child->common.
  307. value.name,
  308. status);
  309. return_ACPI_STATUS(status);
  310. }
  311. }
  312. break;
  313. case AML_INT_NAMEDFIELD_OP:
  314. /* Lookup the name, it should already exist */
  315. status = acpi_ns_lookup(walk_state->scope_info,
  316. (char *)&arg->named.name,
  317. info->field_type,
  318. ACPI_IMODE_EXECUTE,
  319. ACPI_NS_DONT_OPEN_SCOPE,
  320. walk_state, &info->field_node);
  321. if (ACPI_FAILURE(status)) {
  322. ACPI_ERROR_NAMESPACE(walk_state->scope_info,
  323. (char *)&arg->named.name,
  324. status);
  325. return_ACPI_STATUS(status);
  326. } else {
  327. arg->common.node = info->field_node;
  328. info->field_bit_length = arg->common.value.size;
  329. /*
  330. * If there is no object attached to the node, this node was
  331. * just created and we need to create the field object.
  332. * Otherwise, this was a lookup of an existing node and we
  333. * don't want to create the field object again.
  334. */
  335. if (!acpi_ns_get_attached_object
  336. (info->field_node)) {
  337. status = acpi_ex_prep_field_value(info);
  338. if (ACPI_FAILURE(status)) {
  339. return_ACPI_STATUS(status);
  340. }
  341. #ifdef ACPI_EXEC_APP
  342. name_path =
  343. acpi_ns_get_external_pathname(info->
  344. field_node);
  345. obj_desc =
  346. acpi_ut_create_integer_object
  347. (value);
  348. if (ACPI_SUCCESS
  349. (ae_lookup_init_file_entry
  350. (name_path, &value))) {
  351. acpi_ex_write_data_to_field
  352. (obj_desc,
  353. acpi_ns_get_attached_object
  354. (info->field_node),
  355. &result_desc);
  356. }
  357. acpi_ut_remove_reference(obj_desc);
  358. ACPI_FREE(name_path);
  359. #endif
  360. }
  361. }
  362. /* Keep track of bit position for the next field */
  363. position = (u64)info->field_bit_position +
  364. (u64)arg->common.value.size;
  365. if (position > ACPI_UINT32_MAX) {
  366. ACPI_ERROR((AE_INFO,
  367. "Field [%4.4s] bit offset too large (> 0xFFFFFFFF)",
  368. ACPI_CAST_PTR(char,
  369. &info->field_node->
  370. name)));
  371. return_ACPI_STATUS(AE_SUPPORT);
  372. }
  373. info->field_bit_position += info->field_bit_length;
  374. info->pin_number_index++; /* Index relative to previous Connection() */
  375. break;
  376. default:
  377. ACPI_ERROR((AE_INFO,
  378. "Invalid opcode in field list: 0x%X",
  379. arg->common.aml_opcode));
  380. return_ACPI_STATUS(AE_AML_BAD_OPCODE);
  381. }
  382. arg = arg->common.next;
  383. }
  384. return_ACPI_STATUS(AE_OK);
  385. }
  386. /*******************************************************************************
  387. *
  388. * FUNCTION: acpi_ds_create_field
  389. *
  390. * PARAMETERS: op - Op containing the Field definition and args
  391. * region_node - Object for the containing Operation Region
  392. * ` walk_state - Current method state
  393. *
  394. * RETURN: Status
  395. *
  396. * DESCRIPTION: Create a new field in the specified operation region
  397. *
  398. ******************************************************************************/
  399. acpi_status
  400. acpi_ds_create_field(union acpi_parse_object *op,
  401. struct acpi_namespace_node *region_node,
  402. struct acpi_walk_state *walk_state)
  403. {
  404. acpi_status status;
  405. union acpi_parse_object *arg;
  406. struct acpi_create_field_info info;
  407. ACPI_FUNCTION_TRACE_PTR(ds_create_field, op);
  408. /* First arg is the name of the parent op_region (must already exist) */
  409. arg = op->common.value.arg;
  410. if (!region_node) {
  411. status =
  412. acpi_ns_lookup(walk_state->scope_info,
  413. arg->common.value.name, ACPI_TYPE_REGION,
  414. ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
  415. walk_state, &region_node);
  416. #ifdef ACPI_ASL_COMPILER
  417. status = acpi_ds_create_external_region(status, arg,
  418. arg->common.value.name,
  419. walk_state,
  420. &region_node);
  421. #endif
  422. if (ACPI_FAILURE(status)) {
  423. ACPI_ERROR_NAMESPACE(walk_state->scope_info,
  424. arg->common.value.name, status);
  425. return_ACPI_STATUS(status);
  426. }
  427. }
  428. memset(&info, 0, sizeof(struct acpi_create_field_info));
  429. /* Second arg is the field flags */
  430. arg = arg->common.next;
  431. info.field_flags = (u8) arg->common.value.integer;
  432. info.attribute = 0;
  433. /* Each remaining arg is a Named Field */
  434. info.field_type = ACPI_TYPE_LOCAL_REGION_FIELD;
  435. info.region_node = region_node;
  436. status = acpi_ds_get_field_names(&info, walk_state, arg->common.next);
  437. return_ACPI_STATUS(status);
  438. }
  439. /*******************************************************************************
  440. *
  441. * FUNCTION: acpi_ds_init_field_objects
  442. *
  443. * PARAMETERS: op - Op containing the Field definition and args
  444. * ` walk_state - Current method state
  445. *
  446. * RETURN: Status
  447. *
  448. * DESCRIPTION: For each "Field Unit" name in the argument list that is
  449. * part of the field declaration, enter the name into the
  450. * namespace.
  451. *
  452. ******************************************************************************/
  453. acpi_status
  454. acpi_ds_init_field_objects(union acpi_parse_object *op,
  455. struct acpi_walk_state *walk_state)
  456. {
  457. acpi_status status;
  458. union acpi_parse_object *arg = NULL;
  459. struct acpi_namespace_node *node;
  460. u8 type = 0;
  461. u32 flags;
  462. ACPI_FUNCTION_TRACE_PTR(ds_init_field_objects, op);
  463. /* Execute flag should always be set when this function is entered */
  464. if (!(walk_state->parse_flags & ACPI_PARSE_EXECUTE)) {
  465. if (walk_state->parse_flags & ACPI_PARSE_DEFERRED_OP) {
  466. /* bank_field Op is deferred, just return OK */
  467. return_ACPI_STATUS(AE_OK);
  468. }
  469. ACPI_ERROR((AE_INFO, "Parse deferred mode is not set"));
  470. return_ACPI_STATUS(AE_AML_INTERNAL);
  471. }
  472. /*
  473. * Get the field_list argument for this opcode. This is the start of the
  474. * list of field elements.
  475. */
  476. switch (walk_state->opcode) {
  477. case AML_FIELD_OP:
  478. arg = acpi_ps_get_arg(op, 2);
  479. type = ACPI_TYPE_LOCAL_REGION_FIELD;
  480. break;
  481. case AML_BANK_FIELD_OP:
  482. arg = acpi_ps_get_arg(op, 4);
  483. type = ACPI_TYPE_LOCAL_BANK_FIELD;
  484. break;
  485. case AML_INDEX_FIELD_OP:
  486. arg = acpi_ps_get_arg(op, 3);
  487. type = ACPI_TYPE_LOCAL_INDEX_FIELD;
  488. break;
  489. default:
  490. return_ACPI_STATUS(AE_BAD_PARAMETER);
  491. }
  492. /* Creating new namespace node(s), should not already exist */
  493. flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE |
  494. ACPI_NS_ERROR_IF_FOUND;
  495. /*
  496. * Mark node(s) temporary if we are executing a normal control
  497. * method. (Don't mark if this is a module-level code method)
  498. */
  499. if (walk_state->method_node &&
  500. !(walk_state->parse_flags & ACPI_PARSE_MODULE_LEVEL)) {
  501. flags |= ACPI_NS_TEMPORARY;
  502. }
  503. #ifdef ACPI_EXEC_APP
  504. flags |= ACPI_NS_OVERRIDE_IF_FOUND;
  505. #endif
  506. /*
  507. * Walk the list of entries in the field_list
  508. * Note: field_list can be of zero length. In this case, Arg will be NULL.
  509. */
  510. while (arg) {
  511. /*
  512. * Ignore OFFSET/ACCESSAS/CONNECTION terms here; we are only interested
  513. * in the field names in order to enter them into the namespace.
  514. */
  515. if (arg->common.aml_opcode == AML_INT_NAMEDFIELD_OP) {
  516. status = acpi_ns_lookup(walk_state->scope_info,
  517. (char *)&arg->named.name, type,
  518. ACPI_IMODE_LOAD_PASS1, flags,
  519. walk_state, &node);
  520. if (ACPI_FAILURE(status)) {
  521. ACPI_ERROR_NAMESPACE(walk_state->scope_info,
  522. (char *)&arg->named.name,
  523. status);
  524. if (status != AE_ALREADY_EXISTS) {
  525. return_ACPI_STATUS(status);
  526. }
  527. /* Name already exists, just ignore this error */
  528. status = AE_OK;
  529. }
  530. arg->common.node = node;
  531. }
  532. /* Get the next field element in the list */
  533. arg = arg->common.next;
  534. }
  535. return_ACPI_STATUS(AE_OK);
  536. }
  537. /*******************************************************************************
  538. *
  539. * FUNCTION: acpi_ds_create_bank_field
  540. *
  541. * PARAMETERS: op - Op containing the Field definition and args
  542. * region_node - Object for the containing Operation Region
  543. * walk_state - Current method state
  544. *
  545. * RETURN: Status
  546. *
  547. * DESCRIPTION: Create a new bank field in the specified operation region
  548. *
  549. ******************************************************************************/
  550. acpi_status
  551. acpi_ds_create_bank_field(union acpi_parse_object *op,
  552. struct acpi_namespace_node *region_node,
  553. struct acpi_walk_state *walk_state)
  554. {
  555. acpi_status status;
  556. union acpi_parse_object *arg;
  557. struct acpi_create_field_info info;
  558. ACPI_FUNCTION_TRACE_PTR(ds_create_bank_field, op);
  559. /* First arg is the name of the parent op_region (must already exist) */
  560. arg = op->common.value.arg;
  561. if (!region_node) {
  562. status =
  563. acpi_ns_lookup(walk_state->scope_info,
  564. arg->common.value.name, ACPI_TYPE_REGION,
  565. ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
  566. walk_state, &region_node);
  567. #ifdef ACPI_ASL_COMPILER
  568. status = acpi_ds_create_external_region(status, arg,
  569. arg->common.value.name,
  570. walk_state,
  571. &region_node);
  572. #endif
  573. if (ACPI_FAILURE(status)) {
  574. ACPI_ERROR_NAMESPACE(walk_state->scope_info,
  575. arg->common.value.name, status);
  576. return_ACPI_STATUS(status);
  577. }
  578. }
  579. /* Second arg is the Bank Register (Field) (must already exist) */
  580. arg = arg->common.next;
  581. status =
  582. acpi_ns_lookup(walk_state->scope_info, arg->common.value.string,
  583. ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
  584. ACPI_NS_SEARCH_PARENT, walk_state,
  585. &info.register_node);
  586. if (ACPI_FAILURE(status)) {
  587. ACPI_ERROR_NAMESPACE(walk_state->scope_info,
  588. arg->common.value.string, status);
  589. return_ACPI_STATUS(status);
  590. }
  591. /*
  592. * Third arg is the bank_value
  593. * This arg is a term_arg, not a constant
  594. * It will be evaluated later, by acpi_ds_eval_bank_field_operands
  595. */
  596. arg = arg->common.next;
  597. /* Fourth arg is the field flags */
  598. arg = arg->common.next;
  599. info.field_flags = (u8) arg->common.value.integer;
  600. /* Each remaining arg is a Named Field */
  601. info.field_type = ACPI_TYPE_LOCAL_BANK_FIELD;
  602. info.region_node = region_node;
  603. /*
  604. * Use Info.data_register_node to store bank_field Op
  605. * It's safe because data_register_node will never be used when create
  606. * bank field \we store aml_start and aml_length in the bank_field Op for
  607. * late evaluation. Used in acpi_ex_prep_field_value(Info)
  608. *
  609. * TBD: Or, should we add a field in struct acpi_create_field_info, like
  610. * "void *ParentOp"?
  611. */
  612. info.data_register_node = (struct acpi_namespace_node *)op;
  613. status = acpi_ds_get_field_names(&info, walk_state, arg->common.next);
  614. return_ACPI_STATUS(status);
  615. }
  616. /*******************************************************************************
  617. *
  618. * FUNCTION: acpi_ds_create_index_field
  619. *
  620. * PARAMETERS: op - Op containing the Field definition and args
  621. * region_node - Object for the containing Operation Region
  622. * ` walk_state - Current method state
  623. *
  624. * RETURN: Status
  625. *
  626. * DESCRIPTION: Create a new index field in the specified operation region
  627. *
  628. ******************************************************************************/
  629. acpi_status
  630. acpi_ds_create_index_field(union acpi_parse_object *op,
  631. struct acpi_namespace_node *region_node,
  632. struct acpi_walk_state *walk_state)
  633. {
  634. acpi_status status;
  635. union acpi_parse_object *arg;
  636. struct acpi_create_field_info info;
  637. ACPI_FUNCTION_TRACE_PTR(ds_create_index_field, op);
  638. /* First arg is the name of the Index register (must already exist) */
  639. arg = op->common.value.arg;
  640. status =
  641. acpi_ns_lookup(walk_state->scope_info, arg->common.value.string,
  642. ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
  643. ACPI_NS_SEARCH_PARENT, walk_state,
  644. &info.register_node);
  645. if (ACPI_FAILURE(status)) {
  646. ACPI_ERROR_NAMESPACE(walk_state->scope_info,
  647. arg->common.value.string, status);
  648. return_ACPI_STATUS(status);
  649. }
  650. /* Second arg is the data register (must already exist) */
  651. arg = arg->common.next;
  652. status =
  653. acpi_ns_lookup(walk_state->scope_info, arg->common.value.string,
  654. ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
  655. ACPI_NS_SEARCH_PARENT, walk_state,
  656. &info.data_register_node);
  657. if (ACPI_FAILURE(status)) {
  658. ACPI_ERROR_NAMESPACE(walk_state->scope_info,
  659. arg->common.value.string, status);
  660. return_ACPI_STATUS(status);
  661. }
  662. /* Next arg is the field flags */
  663. arg = arg->common.next;
  664. info.field_flags = (u8) arg->common.value.integer;
  665. /* Each remaining arg is a Named Field */
  666. info.field_type = ACPI_TYPE_LOCAL_INDEX_FIELD;
  667. info.region_node = region_node;
  668. status = acpi_ds_get_field_names(&info, walk_state, arg->common.next);
  669. return_ACPI_STATUS(status);
  670. }