rsutils.c 23 KB

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