rsutils.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787
  1. /*******************************************************************************
  2. *
  3. * Module Name: rsutils - Utilities for the resource manager
  4. *
  5. ******************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2015, 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 "acnamesp.h"
  45. #include "acresrc.h"
  46. #define _COMPONENT ACPI_RESOURCES
  47. ACPI_MODULE_NAME("rsutils")
  48. /*******************************************************************************
  49. *
  50. * FUNCTION: acpi_rs_decode_bitmask
  51. *
  52. * PARAMETERS: mask - Bitmask to decode
  53. * list - Where the converted list is returned
  54. *
  55. * RETURN: Count of bits set (length of list)
  56. *
  57. * DESCRIPTION: Convert a bit mask into a list of values
  58. *
  59. ******************************************************************************/
  60. u8 acpi_rs_decode_bitmask(u16 mask, u8 * list)
  61. {
  62. u8 i;
  63. u8 bit_count;
  64. ACPI_FUNCTION_ENTRY();
  65. /* Decode the mask bits */
  66. for (i = 0, bit_count = 0; mask; i++) {
  67. if (mask & 0x0001) {
  68. list[bit_count] = i;
  69. bit_count++;
  70. }
  71. mask >>= 1;
  72. }
  73. return (bit_count);
  74. }
  75. /*******************************************************************************
  76. *
  77. * FUNCTION: acpi_rs_encode_bitmask
  78. *
  79. * PARAMETERS: list - List of values to encode
  80. * count - Length of list
  81. *
  82. * RETURN: Encoded bitmask
  83. *
  84. * DESCRIPTION: Convert a list of values to an encoded bitmask
  85. *
  86. ******************************************************************************/
  87. u16 acpi_rs_encode_bitmask(u8 * list, u8 count)
  88. {
  89. u32 i;
  90. u16 mask;
  91. ACPI_FUNCTION_ENTRY();
  92. /* Encode the list into a single bitmask */
  93. for (i = 0, mask = 0; i < count; i++) {
  94. mask |= (0x1 << list[i]);
  95. }
  96. return (mask);
  97. }
  98. /*******************************************************************************
  99. *
  100. * FUNCTION: acpi_rs_move_data
  101. *
  102. * PARAMETERS: destination - Pointer to the destination descriptor
  103. * source - Pointer to the source descriptor
  104. * item_count - How many items to move
  105. * move_type - Byte width
  106. *
  107. * RETURN: None
  108. *
  109. * DESCRIPTION: Move multiple data items from one descriptor to another. Handles
  110. * alignment issues and endian issues if necessary, as configured
  111. * via the ACPI_MOVE_* macros. (This is why a memcpy is not used)
  112. *
  113. ******************************************************************************/
  114. void
  115. acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type)
  116. {
  117. u32 i;
  118. ACPI_FUNCTION_ENTRY();
  119. /* One move per item */
  120. for (i = 0; i < item_count; i++) {
  121. switch (move_type) {
  122. /*
  123. * For the 8-bit case, we can perform the move all at once
  124. * since there are no alignment or endian issues
  125. */
  126. case ACPI_RSC_MOVE8:
  127. case ACPI_RSC_MOVE_GPIO_RES:
  128. case ACPI_RSC_MOVE_SERIAL_VEN:
  129. case ACPI_RSC_MOVE_SERIAL_RES:
  130. memcpy(destination, source, item_count);
  131. return;
  132. /*
  133. * 16-, 32-, and 64-bit cases must use the move macros that perform
  134. * endian conversion and/or accommodate hardware that cannot perform
  135. * misaligned memory transfers
  136. */
  137. case ACPI_RSC_MOVE16:
  138. case ACPI_RSC_MOVE_GPIO_PIN:
  139. ACPI_MOVE_16_TO_16(&ACPI_CAST_PTR(u16, destination)[i],
  140. &ACPI_CAST_PTR(u16, source)[i]);
  141. break;
  142. case ACPI_RSC_MOVE32:
  143. ACPI_MOVE_32_TO_32(&ACPI_CAST_PTR(u32, destination)[i],
  144. &ACPI_CAST_PTR(u32, source)[i]);
  145. break;
  146. case ACPI_RSC_MOVE64:
  147. ACPI_MOVE_64_TO_64(&ACPI_CAST_PTR(u64, destination)[i],
  148. &ACPI_CAST_PTR(u64, source)[i]);
  149. break;
  150. default:
  151. return;
  152. }
  153. }
  154. }
  155. /*******************************************************************************
  156. *
  157. * FUNCTION: acpi_rs_set_resource_length
  158. *
  159. * PARAMETERS: total_length - Length of the AML descriptor, including
  160. * the header and length fields.
  161. * aml - Pointer to the raw AML descriptor
  162. *
  163. * RETURN: None
  164. *
  165. * DESCRIPTION: Set the resource_length field of an AML
  166. * resource descriptor, both Large and Small descriptors are
  167. * supported automatically. Note: Descriptor Type field must
  168. * be valid.
  169. *
  170. ******************************************************************************/
  171. void
  172. acpi_rs_set_resource_length(acpi_rsdesc_size total_length,
  173. union aml_resource *aml)
  174. {
  175. acpi_rs_length resource_length;
  176. ACPI_FUNCTION_ENTRY();
  177. /* Length is the total descriptor length minus the header length */
  178. resource_length = (acpi_rs_length)
  179. (total_length - acpi_ut_get_resource_header_length(aml));
  180. /* Length is stored differently for large and small descriptors */
  181. if (aml->small_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) {
  182. /* Large descriptor -- bytes 1-2 contain the 16-bit length */
  183. ACPI_MOVE_16_TO_16(&aml->large_header.resource_length,
  184. &resource_length);
  185. } else {
  186. /* Small descriptor -- bits 2:0 of byte 0 contain the length */
  187. aml->small_header.descriptor_type = (u8)
  188. /* Clear any existing length, preserving descriptor type bits */
  189. ((aml->small_header.
  190. descriptor_type & ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK)
  191. | resource_length);
  192. }
  193. }
  194. /*******************************************************************************
  195. *
  196. * FUNCTION: acpi_rs_set_resource_header
  197. *
  198. * PARAMETERS: descriptor_type - Byte to be inserted as the type
  199. * total_length - Length of the AML descriptor, including
  200. * the header and length fields.
  201. * aml - Pointer to the raw AML descriptor
  202. *
  203. * RETURN: None
  204. *
  205. * DESCRIPTION: Set the descriptor_type and resource_length fields of an AML
  206. * resource descriptor, both Large and Small descriptors are
  207. * supported automatically
  208. *
  209. ******************************************************************************/
  210. void
  211. acpi_rs_set_resource_header(u8 descriptor_type,
  212. acpi_rsdesc_size total_length,
  213. union aml_resource *aml)
  214. {
  215. ACPI_FUNCTION_ENTRY();
  216. /* Set the Resource Type */
  217. aml->small_header.descriptor_type = descriptor_type;
  218. /* Set the Resource Length */
  219. acpi_rs_set_resource_length(total_length, aml);
  220. }
  221. /*******************************************************************************
  222. *
  223. * FUNCTION: acpi_rs_strcpy
  224. *
  225. * PARAMETERS: destination - Pointer to the destination string
  226. * source - Pointer to the source string
  227. *
  228. * RETURN: String length, including NULL terminator
  229. *
  230. * DESCRIPTION: Local string copy that returns the string length, saving a
  231. * strcpy followed by a strlen.
  232. *
  233. ******************************************************************************/
  234. static u16 acpi_rs_strcpy(char *destination, char *source)
  235. {
  236. u16 i;
  237. ACPI_FUNCTION_ENTRY();
  238. for (i = 0; source[i]; i++) {
  239. destination[i] = source[i];
  240. }
  241. destination[i] = 0;
  242. /* Return string length including the NULL terminator */
  243. return ((u16) (i + 1));
  244. }
  245. /*******************************************************************************
  246. *
  247. * FUNCTION: acpi_rs_get_resource_source
  248. *
  249. * PARAMETERS: resource_length - Length field of the descriptor
  250. * minimum_length - Minimum length of the descriptor (minus
  251. * any optional fields)
  252. * resource_source - Where the resource_source is returned
  253. * aml - Pointer to the raw AML descriptor
  254. * string_ptr - (optional) where to store the actual
  255. * resource_source string
  256. *
  257. * RETURN: Length of the string plus NULL terminator, rounded up to native
  258. * word boundary
  259. *
  260. * DESCRIPTION: Copy the optional resource_source data from a raw AML descriptor
  261. * to an internal resource descriptor
  262. *
  263. ******************************************************************************/
  264. acpi_rs_length
  265. acpi_rs_get_resource_source(acpi_rs_length resource_length,
  266. acpi_rs_length minimum_length,
  267. struct acpi_resource_source * resource_source,
  268. union aml_resource * aml, char *string_ptr)
  269. {
  270. acpi_rsdesc_size total_length;
  271. u8 *aml_resource_source;
  272. ACPI_FUNCTION_ENTRY();
  273. total_length =
  274. resource_length + sizeof(struct aml_resource_large_header);
  275. aml_resource_source = ACPI_ADD_PTR(u8, aml, minimum_length);
  276. /*
  277. * resource_source is present if the length of the descriptor is longer than
  278. * the minimum length.
  279. *
  280. * Note: Some resource descriptors will have an additional null, so
  281. * we add 1 to the minimum length.
  282. */
  283. if (total_length > (acpi_rsdesc_size) (minimum_length + 1)) {
  284. /* Get the resource_source_index */
  285. resource_source->index = aml_resource_source[0];
  286. resource_source->string_ptr = string_ptr;
  287. if (!string_ptr) {
  288. /*
  289. * String destination pointer is not specified; Set the String
  290. * pointer to the end of the current resource_source structure.
  291. */
  292. resource_source->string_ptr =
  293. ACPI_ADD_PTR(char, resource_source,
  294. sizeof(struct acpi_resource_source));
  295. }
  296. /*
  297. * In order for the Resource length to be a multiple of the native
  298. * word, calculate the length of the string (+1 for NULL terminator)
  299. * and expand to the next word multiple.
  300. *
  301. * Zero the entire area of the buffer.
  302. */
  303. total_length =
  304. (u32)strlen(ACPI_CAST_PTR(char, &aml_resource_source[1])) +
  305. 1;
  306. total_length = (u32)ACPI_ROUND_UP_TO_NATIVE_WORD(total_length);
  307. memset(resource_source->string_ptr, 0, total_length);
  308. /* Copy the resource_source string to the destination */
  309. resource_source->string_length =
  310. acpi_rs_strcpy(resource_source->string_ptr,
  311. ACPI_CAST_PTR(char,
  312. &aml_resource_source[1]));
  313. return ((acpi_rs_length) total_length);
  314. }
  315. /* resource_source is not present */
  316. resource_source->index = 0;
  317. resource_source->string_length = 0;
  318. resource_source->string_ptr = NULL;
  319. return (0);
  320. }
  321. /*******************************************************************************
  322. *
  323. * FUNCTION: acpi_rs_set_resource_source
  324. *
  325. * PARAMETERS: aml - Pointer to the raw AML descriptor
  326. * minimum_length - Minimum length of the descriptor (minus
  327. * any optional fields)
  328. * resource_source - Internal resource_source
  329. *
  330. * RETURN: Total length of the AML descriptor
  331. *
  332. * DESCRIPTION: Convert an optional resource_source from internal format to a
  333. * raw AML resource descriptor
  334. *
  335. ******************************************************************************/
  336. acpi_rsdesc_size
  337. acpi_rs_set_resource_source(union aml_resource * aml,
  338. acpi_rs_length minimum_length,
  339. struct acpi_resource_source * resource_source)
  340. {
  341. u8 *aml_resource_source;
  342. acpi_rsdesc_size descriptor_length;
  343. ACPI_FUNCTION_ENTRY();
  344. descriptor_length = minimum_length;
  345. /* Non-zero string length indicates presence of a resource_source */
  346. if (resource_source->string_length) {
  347. /* Point to the end of the AML descriptor */
  348. aml_resource_source = ACPI_ADD_PTR(u8, aml, minimum_length);
  349. /* Copy the resource_source_index */
  350. aml_resource_source[0] = (u8) resource_source->index;
  351. /* Copy the resource_source string */
  352. strcpy(ACPI_CAST_PTR(char, &aml_resource_source[1]),
  353. resource_source->string_ptr);
  354. /*
  355. * Add the length of the string (+ 1 for null terminator) to the
  356. * final descriptor length
  357. */
  358. descriptor_length +=
  359. ((acpi_rsdesc_size) resource_source->string_length + 1);
  360. }
  361. /* Return the new total length of the AML descriptor */
  362. return (descriptor_length);
  363. }
  364. /*******************************************************************************
  365. *
  366. * FUNCTION: acpi_rs_get_prt_method_data
  367. *
  368. * PARAMETERS: node - Device node
  369. * ret_buffer - Pointer to a buffer structure for the
  370. * results
  371. *
  372. * RETURN: Status
  373. *
  374. * DESCRIPTION: This function is called to get the _PRT value of an object
  375. * contained in an object specified by the handle passed in
  376. *
  377. * If the function fails an appropriate status will be returned
  378. * and the contents of the callers buffer is undefined.
  379. *
  380. ******************************************************************************/
  381. acpi_status
  382. acpi_rs_get_prt_method_data(struct acpi_namespace_node * node,
  383. struct acpi_buffer * ret_buffer)
  384. {
  385. union acpi_operand_object *obj_desc;
  386. acpi_status status;
  387. ACPI_FUNCTION_TRACE(rs_get_prt_method_data);
  388. /* Parameters guaranteed valid by caller */
  389. /* Execute the method, no parameters */
  390. status = acpi_ut_evaluate_object(node, METHOD_NAME__PRT,
  391. ACPI_BTYPE_PACKAGE, &obj_desc);
  392. if (ACPI_FAILURE(status)) {
  393. return_ACPI_STATUS(status);
  394. }
  395. /*
  396. * Create a resource linked list from the byte stream buffer that comes
  397. * back from the _CRS method execution.
  398. */
  399. status = acpi_rs_create_pci_routing_table(obj_desc, ret_buffer);
  400. /* On exit, we must delete the object returned by evaluate_object */
  401. acpi_ut_remove_reference(obj_desc);
  402. return_ACPI_STATUS(status);
  403. }
  404. /*******************************************************************************
  405. *
  406. * FUNCTION: acpi_rs_get_crs_method_data
  407. *
  408. * PARAMETERS: node - Device node
  409. * ret_buffer - Pointer to a buffer structure for the
  410. * results
  411. *
  412. * RETURN: Status
  413. *
  414. * DESCRIPTION: This function is called to get the _CRS value of an object
  415. * contained in an object specified by the handle passed in
  416. *
  417. * If the function fails an appropriate status will be returned
  418. * and the contents of the callers buffer is undefined.
  419. *
  420. ******************************************************************************/
  421. acpi_status
  422. acpi_rs_get_crs_method_data(struct acpi_namespace_node *node,
  423. struct acpi_buffer *ret_buffer)
  424. {
  425. union acpi_operand_object *obj_desc;
  426. acpi_status status;
  427. ACPI_FUNCTION_TRACE(rs_get_crs_method_data);
  428. /* Parameters guaranteed valid by caller */
  429. /* Execute the method, no parameters */
  430. status = acpi_ut_evaluate_object(node, METHOD_NAME__CRS,
  431. ACPI_BTYPE_BUFFER, &obj_desc);
  432. if (ACPI_FAILURE(status)) {
  433. return_ACPI_STATUS(status);
  434. }
  435. /*
  436. * Make the call to create a resource linked list from the
  437. * byte stream buffer that comes back from the _CRS method
  438. * execution.
  439. */
  440. status = acpi_rs_create_resource_list(obj_desc, ret_buffer);
  441. /* On exit, we must delete the object returned by evaluateObject */
  442. acpi_ut_remove_reference(obj_desc);
  443. return_ACPI_STATUS(status);
  444. }
  445. /*******************************************************************************
  446. *
  447. * FUNCTION: acpi_rs_get_prs_method_data
  448. *
  449. * PARAMETERS: node - Device node
  450. * ret_buffer - Pointer to a buffer structure for the
  451. * results
  452. *
  453. * RETURN: Status
  454. *
  455. * DESCRIPTION: This function is called to get the _PRS value of an object
  456. * contained in an object specified by the handle passed in
  457. *
  458. * If the function fails an appropriate status will be returned
  459. * and the contents of the callers buffer is undefined.
  460. *
  461. ******************************************************************************/
  462. acpi_status
  463. acpi_rs_get_prs_method_data(struct acpi_namespace_node *node,
  464. struct acpi_buffer *ret_buffer)
  465. {
  466. union acpi_operand_object *obj_desc;
  467. acpi_status status;
  468. ACPI_FUNCTION_TRACE(rs_get_prs_method_data);
  469. /* Parameters guaranteed valid by caller */
  470. /* Execute the method, no parameters */
  471. status = acpi_ut_evaluate_object(node, METHOD_NAME__PRS,
  472. ACPI_BTYPE_BUFFER, &obj_desc);
  473. if (ACPI_FAILURE(status)) {
  474. return_ACPI_STATUS(status);
  475. }
  476. /*
  477. * Make the call to create a resource linked list from the
  478. * byte stream buffer that comes back from the _CRS method
  479. * execution.
  480. */
  481. status = acpi_rs_create_resource_list(obj_desc, ret_buffer);
  482. /* On exit, we must delete the object returned by evaluateObject */
  483. acpi_ut_remove_reference(obj_desc);
  484. return_ACPI_STATUS(status);
  485. }
  486. /*******************************************************************************
  487. *
  488. * FUNCTION: acpi_rs_get_aei_method_data
  489. *
  490. * PARAMETERS: node - Device node
  491. * ret_buffer - Pointer to a buffer structure for the
  492. * results
  493. *
  494. * RETURN: Status
  495. *
  496. * DESCRIPTION: This function is called to get the _AEI value of an object
  497. * contained in an object specified by the handle passed in
  498. *
  499. * If the function fails an appropriate status will be returned
  500. * and the contents of the callers buffer is undefined.
  501. *
  502. ******************************************************************************/
  503. acpi_status
  504. acpi_rs_get_aei_method_data(struct acpi_namespace_node *node,
  505. struct acpi_buffer *ret_buffer)
  506. {
  507. union acpi_operand_object *obj_desc;
  508. acpi_status status;
  509. ACPI_FUNCTION_TRACE(rs_get_aei_method_data);
  510. /* Parameters guaranteed valid by caller */
  511. /* Execute the method, no parameters */
  512. status = acpi_ut_evaluate_object(node, METHOD_NAME__AEI,
  513. ACPI_BTYPE_BUFFER, &obj_desc);
  514. if (ACPI_FAILURE(status)) {
  515. return_ACPI_STATUS(status);
  516. }
  517. /*
  518. * Make the call to create a resource linked list from the
  519. * byte stream buffer that comes back from the _CRS method
  520. * execution.
  521. */
  522. status = acpi_rs_create_resource_list(obj_desc, ret_buffer);
  523. /* On exit, we must delete the object returned by evaluateObject */
  524. acpi_ut_remove_reference(obj_desc);
  525. return_ACPI_STATUS(status);
  526. }
  527. /*******************************************************************************
  528. *
  529. * FUNCTION: acpi_rs_get_method_data
  530. *
  531. * PARAMETERS: handle - Handle to the containing object
  532. * path - Path to method, relative to Handle
  533. * ret_buffer - Pointer to a buffer structure for the
  534. * results
  535. *
  536. * RETURN: Status
  537. *
  538. * DESCRIPTION: This function is called to get the _CRS or _PRS value of an
  539. * object contained in an object specified by the handle passed in
  540. *
  541. * If the function fails an appropriate status will be returned
  542. * and the contents of the callers buffer is undefined.
  543. *
  544. ******************************************************************************/
  545. acpi_status
  546. acpi_rs_get_method_data(acpi_handle handle,
  547. char *path, struct acpi_buffer *ret_buffer)
  548. {
  549. union acpi_operand_object *obj_desc;
  550. acpi_status status;
  551. ACPI_FUNCTION_TRACE(rs_get_method_data);
  552. /* Parameters guaranteed valid by caller */
  553. /* Execute the method, no parameters */
  554. status =
  555. acpi_ut_evaluate_object(ACPI_CAST_PTR
  556. (struct acpi_namespace_node, handle), path,
  557. ACPI_BTYPE_BUFFER, &obj_desc);
  558. if (ACPI_FAILURE(status)) {
  559. return_ACPI_STATUS(status);
  560. }
  561. /*
  562. * Make the call to create a resource linked list from the
  563. * byte stream buffer that comes back from the method
  564. * execution.
  565. */
  566. status = acpi_rs_create_resource_list(obj_desc, ret_buffer);
  567. /* On exit, we must delete the object returned by evaluate_object */
  568. acpi_ut_remove_reference(obj_desc);
  569. return_ACPI_STATUS(status);
  570. }
  571. /*******************************************************************************
  572. *
  573. * FUNCTION: acpi_rs_set_srs_method_data
  574. *
  575. * PARAMETERS: node - Device node
  576. * in_buffer - Pointer to a buffer structure of the
  577. * parameter
  578. *
  579. * RETURN: Status
  580. *
  581. * DESCRIPTION: This function is called to set the _SRS of an object contained
  582. * in an object specified by the handle passed in
  583. *
  584. * If the function fails an appropriate status will be returned
  585. * and the contents of the callers buffer is undefined.
  586. *
  587. * Note: Parameters guaranteed valid by caller
  588. *
  589. ******************************************************************************/
  590. acpi_status
  591. acpi_rs_set_srs_method_data(struct acpi_namespace_node *node,
  592. struct acpi_buffer *in_buffer)
  593. {
  594. struct acpi_evaluate_info *info;
  595. union acpi_operand_object *args[2];
  596. acpi_status status;
  597. struct acpi_buffer buffer;
  598. ACPI_FUNCTION_TRACE(rs_set_srs_method_data);
  599. /* Allocate and initialize the evaluation information block */
  600. info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
  601. if (!info) {
  602. return_ACPI_STATUS(AE_NO_MEMORY);
  603. }
  604. info->prefix_node = node;
  605. info->relative_pathname = METHOD_NAME__SRS;
  606. info->parameters = args;
  607. info->flags = ACPI_IGNORE_RETURN_VALUE;
  608. /*
  609. * The in_buffer parameter will point to a linked list of
  610. * resource parameters. It needs to be formatted into a
  611. * byte stream to be sent in as an input parameter to _SRS
  612. *
  613. * Convert the linked list into a byte stream
  614. */
  615. buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
  616. status = acpi_rs_create_aml_resources(in_buffer, &buffer);
  617. if (ACPI_FAILURE(status)) {
  618. goto cleanup;
  619. }
  620. /* Create and initialize the method parameter object */
  621. args[0] = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER);
  622. if (!args[0]) {
  623. /*
  624. * Must free the buffer allocated above (otherwise it is freed
  625. * later)
  626. */
  627. ACPI_FREE(buffer.pointer);
  628. status = AE_NO_MEMORY;
  629. goto cleanup;
  630. }
  631. args[0]->buffer.length = (u32) buffer.length;
  632. args[0]->buffer.pointer = buffer.pointer;
  633. args[0]->common.flags = AOPOBJ_DATA_VALID;
  634. args[1] = NULL;
  635. /* Execute the method, no return value is expected */
  636. status = acpi_ns_evaluate(info);
  637. /* Clean up and return the status from acpi_ns_evaluate */
  638. acpi_ut_remove_reference(args[0]);
  639. cleanup:
  640. ACPI_FREE(info);
  641. return_ACPI_STATUS(status);
  642. }