dsfield.c 22 KB

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