dsfield.c 21 KB

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