rsutils.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  1. /*******************************************************************************
  2. *
  3. * Module Name: rsutils - Utilities for the resource manager
  4. *
  5. ******************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2011, 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. ACPI_MEMCPY(destination, source, item_count);
  128. return;
  129. /*
  130. * 16-, 32-, and 64-bit cases must use the move macros that perform
  131. * endian conversion and/or accommodate hardware that cannot perform
  132. * misaligned memory transfers
  133. */
  134. case ACPI_RSC_MOVE16:
  135. ACPI_MOVE_16_TO_16(&ACPI_CAST_PTR(u16, destination)[i],
  136. &ACPI_CAST_PTR(u16, source)[i]);
  137. break;
  138. case ACPI_RSC_MOVE32:
  139. ACPI_MOVE_32_TO_32(&ACPI_CAST_PTR(u32, destination)[i],
  140. &ACPI_CAST_PTR(u32, source)[i]);
  141. break;
  142. case ACPI_RSC_MOVE64:
  143. ACPI_MOVE_64_TO_64(&ACPI_CAST_PTR(u64, destination)[i],
  144. &ACPI_CAST_PTR(u64, source)[i]);
  145. break;
  146. default:
  147. return;
  148. }
  149. }
  150. }
  151. /*******************************************************************************
  152. *
  153. * FUNCTION: acpi_rs_set_resource_length
  154. *
  155. * PARAMETERS: total_length - Length of the AML descriptor, including
  156. * the header and length fields.
  157. * Aml - Pointer to the raw AML descriptor
  158. *
  159. * RETURN: None
  160. *
  161. * DESCRIPTION: Set the resource_length field of an AML
  162. * resource descriptor, both Large and Small descriptors are
  163. * supported automatically. Note: Descriptor Type field must
  164. * be valid.
  165. *
  166. ******************************************************************************/
  167. void
  168. acpi_rs_set_resource_length(acpi_rsdesc_size total_length,
  169. union aml_resource *aml)
  170. {
  171. acpi_rs_length resource_length;
  172. ACPI_FUNCTION_ENTRY();
  173. /* Length is the total descriptor length minus the header length */
  174. resource_length = (acpi_rs_length)
  175. (total_length - acpi_ut_get_resource_header_length(aml));
  176. /* Length is stored differently for large and small descriptors */
  177. if (aml->small_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) {
  178. /* Large descriptor -- bytes 1-2 contain the 16-bit length */
  179. ACPI_MOVE_16_TO_16(&aml->large_header.resource_length,
  180. &resource_length);
  181. } else {
  182. /* Small descriptor -- bits 2:0 of byte 0 contain the length */
  183. aml->small_header.descriptor_type = (u8)
  184. /* Clear any existing length, preserving descriptor type bits */
  185. ((aml->small_header.
  186. descriptor_type & ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK)
  187. | resource_length);
  188. }
  189. }
  190. /*******************************************************************************
  191. *
  192. * FUNCTION: acpi_rs_set_resource_header
  193. *
  194. * PARAMETERS: descriptor_type - Byte to be inserted as the type
  195. * total_length - Length of the AML descriptor, including
  196. * the header and length fields.
  197. * Aml - Pointer to the raw AML descriptor
  198. *
  199. * RETURN: None
  200. *
  201. * DESCRIPTION: Set the descriptor_type and resource_length fields of an AML
  202. * resource descriptor, both Large and Small descriptors are
  203. * supported automatically
  204. *
  205. ******************************************************************************/
  206. void
  207. acpi_rs_set_resource_header(u8 descriptor_type,
  208. acpi_rsdesc_size total_length,
  209. union aml_resource *aml)
  210. {
  211. ACPI_FUNCTION_ENTRY();
  212. /* Set the Resource Type */
  213. aml->small_header.descriptor_type = descriptor_type;
  214. /* Set the Resource Length */
  215. acpi_rs_set_resource_length(total_length, aml);
  216. }
  217. /*******************************************************************************
  218. *
  219. * FUNCTION: acpi_rs_strcpy
  220. *
  221. * PARAMETERS: Destination - Pointer to the destination string
  222. * Source - Pointer to the source string
  223. *
  224. * RETURN: String length, including NULL terminator
  225. *
  226. * DESCRIPTION: Local string copy that returns the string length, saving a
  227. * strcpy followed by a strlen.
  228. *
  229. ******************************************************************************/
  230. static u16 acpi_rs_strcpy(char *destination, char *source)
  231. {
  232. u16 i;
  233. ACPI_FUNCTION_ENTRY();
  234. for (i = 0; source[i]; i++) {
  235. destination[i] = source[i];
  236. }
  237. destination[i] = 0;
  238. /* Return string length including the NULL terminator */
  239. return ((u16) (i + 1));
  240. }
  241. /*******************************************************************************
  242. *
  243. * FUNCTION: acpi_rs_get_resource_source
  244. *
  245. * PARAMETERS: resource_length - Length field of the descriptor
  246. * minimum_length - Minimum length of the descriptor (minus
  247. * any optional fields)
  248. * resource_source - Where the resource_source is returned
  249. * Aml - Pointer to the raw AML descriptor
  250. * string_ptr - (optional) where to store the actual
  251. * resource_source string
  252. *
  253. * RETURN: Length of the string plus NULL terminator, rounded up to native
  254. * word boundary
  255. *
  256. * DESCRIPTION: Copy the optional resource_source data from a raw AML descriptor
  257. * to an internal resource descriptor
  258. *
  259. ******************************************************************************/
  260. acpi_rs_length
  261. acpi_rs_get_resource_source(acpi_rs_length resource_length,
  262. acpi_rs_length minimum_length,
  263. struct acpi_resource_source * resource_source,
  264. union aml_resource * aml, char *string_ptr)
  265. {
  266. acpi_rsdesc_size total_length;
  267. u8 *aml_resource_source;
  268. ACPI_FUNCTION_ENTRY();
  269. total_length =
  270. resource_length + sizeof(struct aml_resource_large_header);
  271. aml_resource_source = ACPI_ADD_PTR(u8, aml, minimum_length);
  272. /*
  273. * resource_source is present if the length of the descriptor is longer than
  274. * the minimum length.
  275. *
  276. * Note: Some resource descriptors will have an additional null, so
  277. * we add 1 to the minimum length.
  278. */
  279. if (total_length > (acpi_rsdesc_size) (minimum_length + 1)) {
  280. /* Get the resource_source_index */
  281. resource_source->index = aml_resource_source[0];
  282. resource_source->string_ptr = string_ptr;
  283. if (!string_ptr) {
  284. /*
  285. * String destination pointer is not specified; Set the String
  286. * pointer to the end of the current resource_source structure.
  287. */
  288. resource_source->string_ptr =
  289. ACPI_ADD_PTR(char, resource_source,
  290. sizeof(struct acpi_resource_source));
  291. }
  292. /*
  293. * In order for the Resource length to be a multiple of the native
  294. * word, calculate the length of the string (+1 for NULL terminator)
  295. * and expand to the next word multiple.
  296. *
  297. * Zero the entire area of the buffer.
  298. */
  299. total_length = (u32)
  300. ACPI_STRLEN(ACPI_CAST_PTR(char, &aml_resource_source[1])) + 1;
  301. total_length = (u32) ACPI_ROUND_UP_TO_NATIVE_WORD(total_length);
  302. ACPI_MEMSET(resource_source->string_ptr, 0, total_length);
  303. /* Copy the resource_source string to the destination */
  304. resource_source->string_length =
  305. acpi_rs_strcpy(resource_source->string_ptr,
  306. ACPI_CAST_PTR(char,
  307. &aml_resource_source[1]));
  308. return ((acpi_rs_length) total_length);
  309. }
  310. /* resource_source is not present */
  311. resource_source->index = 0;
  312. resource_source->string_length = 0;
  313. resource_source->string_ptr = NULL;
  314. return (0);
  315. }
  316. /*******************************************************************************
  317. *
  318. * FUNCTION: acpi_rs_set_resource_source
  319. *
  320. * PARAMETERS: Aml - Pointer to the raw AML descriptor
  321. * minimum_length - Minimum length of the descriptor (minus
  322. * any optional fields)
  323. * resource_source - Internal resource_source
  324. *
  325. * RETURN: Total length of the AML descriptor
  326. *
  327. * DESCRIPTION: Convert an optional resource_source from internal format to a
  328. * raw AML resource descriptor
  329. *
  330. ******************************************************************************/
  331. acpi_rsdesc_size
  332. acpi_rs_set_resource_source(union aml_resource * aml,
  333. acpi_rs_length minimum_length,
  334. struct acpi_resource_source * resource_source)
  335. {
  336. u8 *aml_resource_source;
  337. acpi_rsdesc_size descriptor_length;
  338. ACPI_FUNCTION_ENTRY();
  339. descriptor_length = minimum_length;
  340. /* Non-zero string length indicates presence of a resource_source */
  341. if (resource_source->string_length) {
  342. /* Point to the end of the AML descriptor */
  343. aml_resource_source = ACPI_ADD_PTR(u8, aml, minimum_length);
  344. /* Copy the resource_source_index */
  345. aml_resource_source[0] = (u8) resource_source->index;
  346. /* Copy the resource_source string */
  347. ACPI_STRCPY(ACPI_CAST_PTR(char, &aml_resource_source[1]),
  348. resource_source->string_ptr);
  349. /*
  350. * Add the length of the string (+ 1 for null terminator) to the
  351. * final descriptor length
  352. */
  353. descriptor_length +=
  354. ((acpi_rsdesc_size) resource_source->string_length + 1);
  355. }
  356. /* Return the new total length of the AML descriptor */
  357. return (descriptor_length);
  358. }
  359. /*******************************************************************************
  360. *
  361. * FUNCTION: acpi_rs_get_prt_method_data
  362. *
  363. * PARAMETERS: Node - Device node
  364. * ret_buffer - Pointer to a buffer structure for the
  365. * results
  366. *
  367. * RETURN: Status
  368. *
  369. * DESCRIPTION: This function is called to get the _PRT value of an object
  370. * contained in an object specified by the handle passed in
  371. *
  372. * If the function fails an appropriate status will be returned
  373. * and the contents of the callers buffer is undefined.
  374. *
  375. ******************************************************************************/
  376. acpi_status
  377. acpi_rs_get_prt_method_data(struct acpi_namespace_node * node,
  378. struct acpi_buffer * ret_buffer)
  379. {
  380. union acpi_operand_object *obj_desc;
  381. acpi_status status;
  382. ACPI_FUNCTION_TRACE(rs_get_prt_method_data);
  383. /* Parameters guaranteed valid by caller */
  384. /* Execute the method, no parameters */
  385. status = acpi_ut_evaluate_object(node, METHOD_NAME__PRT,
  386. ACPI_BTYPE_PACKAGE, &obj_desc);
  387. if (ACPI_FAILURE(status)) {
  388. return_ACPI_STATUS(status);
  389. }
  390. /*
  391. * Create a resource linked list from the byte stream buffer that comes
  392. * back from the _CRS method execution.
  393. */
  394. status = acpi_rs_create_pci_routing_table(obj_desc, ret_buffer);
  395. /* On exit, we must delete the object returned by evaluate_object */
  396. acpi_ut_remove_reference(obj_desc);
  397. return_ACPI_STATUS(status);
  398. }
  399. /*******************************************************************************
  400. *
  401. * FUNCTION: acpi_rs_get_crs_method_data
  402. *
  403. * PARAMETERS: Node - Device node
  404. * ret_buffer - Pointer to a buffer structure for the
  405. * results
  406. *
  407. * RETURN: Status
  408. *
  409. * DESCRIPTION: This function is called to get the _CRS value of an object
  410. * contained in an object specified by the handle passed in
  411. *
  412. * If the function fails an appropriate status will be returned
  413. * and the contents of the callers buffer is undefined.
  414. *
  415. ******************************************************************************/
  416. acpi_status
  417. acpi_rs_get_crs_method_data(struct acpi_namespace_node *node,
  418. struct acpi_buffer *ret_buffer)
  419. {
  420. union acpi_operand_object *obj_desc;
  421. acpi_status status;
  422. ACPI_FUNCTION_TRACE(rs_get_crs_method_data);
  423. /* Parameters guaranteed valid by caller */
  424. /* Execute the method, no parameters */
  425. status = acpi_ut_evaluate_object(node, METHOD_NAME__CRS,
  426. ACPI_BTYPE_BUFFER, &obj_desc);
  427. if (ACPI_FAILURE(status)) {
  428. return_ACPI_STATUS(status);
  429. }
  430. /*
  431. * Make the call to create a resource linked list from the
  432. * byte stream buffer that comes back from the _CRS method
  433. * execution.
  434. */
  435. status = acpi_rs_create_resource_list(obj_desc, ret_buffer);
  436. /* On exit, we must delete the object returned by evaluate_object */
  437. acpi_ut_remove_reference(obj_desc);
  438. return_ACPI_STATUS(status);
  439. }
  440. /*******************************************************************************
  441. *
  442. * FUNCTION: acpi_rs_get_prs_method_data
  443. *
  444. * PARAMETERS: Node - Device node
  445. * ret_buffer - Pointer to a buffer structure for the
  446. * results
  447. *
  448. * RETURN: Status
  449. *
  450. * DESCRIPTION: This function is called to get the _PRS value of an object
  451. * contained in an object specified by the handle passed in
  452. *
  453. * If the function fails an appropriate status will be returned
  454. * and the contents of the callers buffer is undefined.
  455. *
  456. ******************************************************************************/
  457. #ifdef ACPI_FUTURE_USAGE
  458. acpi_status
  459. acpi_rs_get_prs_method_data(struct acpi_namespace_node *node,
  460. struct acpi_buffer *ret_buffer)
  461. {
  462. union acpi_operand_object *obj_desc;
  463. acpi_status status;
  464. ACPI_FUNCTION_TRACE(rs_get_prs_method_data);
  465. /* Parameters guaranteed valid by caller */
  466. /* Execute the method, no parameters */
  467. status = acpi_ut_evaluate_object(node, METHOD_NAME__PRS,
  468. ACPI_BTYPE_BUFFER, &obj_desc);
  469. if (ACPI_FAILURE(status)) {
  470. return_ACPI_STATUS(status);
  471. }
  472. /*
  473. * Make the call to create a resource linked list from the
  474. * byte stream buffer that comes back from the _CRS method
  475. * execution.
  476. */
  477. status = acpi_rs_create_resource_list(obj_desc, ret_buffer);
  478. /* On exit, we must delete the object returned by evaluate_object */
  479. acpi_ut_remove_reference(obj_desc);
  480. return_ACPI_STATUS(status);
  481. }
  482. #endif /* ACPI_FUTURE_USAGE */
  483. /*******************************************************************************
  484. *
  485. * FUNCTION: acpi_rs_get_method_data
  486. *
  487. * PARAMETERS: Handle - Handle to the containing object
  488. * Path - Path to method, relative to Handle
  489. * ret_buffer - Pointer to a buffer structure for the
  490. * results
  491. *
  492. * RETURN: Status
  493. *
  494. * DESCRIPTION: This function is called to get the _CRS or _PRS value of an
  495. * object contained in an object specified by the handle passed in
  496. *
  497. * If the function fails an appropriate status will be returned
  498. * and the contents of the callers buffer is undefined.
  499. *
  500. ******************************************************************************/
  501. acpi_status
  502. acpi_rs_get_method_data(acpi_handle handle,
  503. char *path, struct acpi_buffer *ret_buffer)
  504. {
  505. union acpi_operand_object *obj_desc;
  506. acpi_status status;
  507. ACPI_FUNCTION_TRACE(rs_get_method_data);
  508. /* Parameters guaranteed valid by caller */
  509. /* Execute the method, no parameters */
  510. status =
  511. acpi_ut_evaluate_object(handle, path, ACPI_BTYPE_BUFFER, &obj_desc);
  512. if (ACPI_FAILURE(status)) {
  513. return_ACPI_STATUS(status);
  514. }
  515. /*
  516. * Make the call to create a resource linked list from the
  517. * byte stream buffer that comes back from the method
  518. * execution.
  519. */
  520. status = acpi_rs_create_resource_list(obj_desc, ret_buffer);
  521. /* On exit, we must delete the object returned by evaluate_object */
  522. acpi_ut_remove_reference(obj_desc);
  523. return_ACPI_STATUS(status);
  524. }
  525. /*******************************************************************************
  526. *
  527. * FUNCTION: acpi_rs_set_srs_method_data
  528. *
  529. * PARAMETERS: Node - Device node
  530. * in_buffer - Pointer to a buffer structure of the
  531. * parameter
  532. *
  533. * RETURN: Status
  534. *
  535. * DESCRIPTION: This function is called to set the _SRS of an object contained
  536. * in an object specified by the handle passed in
  537. *
  538. * If the function fails an appropriate status will be returned
  539. * and the contents of the callers buffer is undefined.
  540. *
  541. * Note: Parameters guaranteed valid by caller
  542. *
  543. ******************************************************************************/
  544. acpi_status
  545. acpi_rs_set_srs_method_data(struct acpi_namespace_node *node,
  546. struct acpi_buffer *in_buffer)
  547. {
  548. struct acpi_evaluate_info *info;
  549. union acpi_operand_object *args[2];
  550. acpi_status status;
  551. struct acpi_buffer buffer;
  552. ACPI_FUNCTION_TRACE(rs_set_srs_method_data);
  553. /* Allocate and initialize the evaluation information block */
  554. info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
  555. if (!info) {
  556. return_ACPI_STATUS(AE_NO_MEMORY);
  557. }
  558. info->prefix_node = node;
  559. info->pathname = METHOD_NAME__SRS;
  560. info->parameters = args;
  561. info->flags = ACPI_IGNORE_RETURN_VALUE;
  562. /*
  563. * The in_buffer parameter will point to a linked list of
  564. * resource parameters. It needs to be formatted into a
  565. * byte stream to be sent in as an input parameter to _SRS
  566. *
  567. * Convert the linked list into a byte stream
  568. */
  569. buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
  570. status = acpi_rs_create_aml_resources(in_buffer->pointer, &buffer);
  571. if (ACPI_FAILURE(status)) {
  572. goto cleanup;
  573. }
  574. /* Create and initialize the method parameter object */
  575. args[0] = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER);
  576. if (!args[0]) {
  577. /*
  578. * Must free the buffer allocated above (otherwise it is freed
  579. * later)
  580. */
  581. ACPI_FREE(buffer.pointer);
  582. status = AE_NO_MEMORY;
  583. goto cleanup;
  584. }
  585. args[0]->buffer.length = (u32) buffer.length;
  586. args[0]->buffer.pointer = buffer.pointer;
  587. args[0]->common.flags = AOPOBJ_DATA_VALID;
  588. args[1] = NULL;
  589. /* Execute the method, no return value is expected */
  590. status = acpi_ns_evaluate(info);
  591. /* Clean up and return the status from acpi_ns_evaluate */
  592. acpi_ut_remove_reference(args[0]);
  593. cleanup:
  594. ACPI_FREE(info);
  595. return_ACPI_STATUS(status);
  596. }