rsutils.c 23 KB

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