uteval.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775
  1. /******************************************************************************
  2. *
  3. * Module Name: uteval - Object evaluation
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2008, 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 "acinterp.h"
  46. #define _COMPONENT ACPI_UTILITIES
  47. ACPI_MODULE_NAME("uteval")
  48. /* Local prototypes */
  49. static void
  50. acpi_ut_copy_id_string(char *destination, char *source, acpi_size max_length);
  51. static acpi_status
  52. acpi_ut_translate_one_cid(union acpi_operand_object *obj_desc,
  53. struct acpi_compatible_id *one_cid);
  54. /*
  55. * Strings supported by the _OSI predefined (internal) method.
  56. *
  57. * March 2009: Removed "Linux" as this host no longer wants to respond true
  58. * for this string. Basically, the only safe OS strings are windows-related
  59. * and in many or most cases represent the only test path within the
  60. * BIOS-provided ASL code.
  61. *
  62. * The second element of each entry is used to track the newest version of
  63. * Windows that the BIOS has requested.
  64. */
  65. static struct acpi_interface_info acpi_interfaces_supported[] = {
  66. /* Operating System Vendor Strings */
  67. {"Windows 2000", ACPI_OSI_WIN_2000}, /* Windows 2000 */
  68. {"Windows 2001", ACPI_OSI_WIN_XP}, /* Windows XP */
  69. {"Windows 2001 SP1", ACPI_OSI_WIN_XP_SP1}, /* Windows XP SP1 */
  70. {"Windows 2001.1", ACPI_OSI_WINSRV_2003}, /* Windows Server 2003 */
  71. {"Windows 2001 SP2", ACPI_OSI_WIN_XP_SP2}, /* Windows XP SP2 */
  72. {"Windows 2001.1 SP1", ACPI_OSI_WINSRV_2003_SP1}, /* Windows Server 2003 SP1 - Added 03/2006 */
  73. {"Windows 2006", ACPI_OSI_WIN_VISTA}, /* Windows Vista - Added 03/2006 */
  74. /* Feature Group Strings */
  75. {"Extended Address Space Descriptor", 0}
  76. /*
  77. * All "optional" feature group strings (features that are implemented
  78. * by the host) should be implemented in the host version of
  79. * acpi_os_validate_interface and should not be added here.
  80. */
  81. };
  82. /*******************************************************************************
  83. *
  84. * FUNCTION: acpi_ut_osi_implementation
  85. *
  86. * PARAMETERS: walk_state - Current walk state
  87. *
  88. * RETURN: Status
  89. *
  90. * DESCRIPTION: Implementation of the _OSI predefined control method
  91. *
  92. ******************************************************************************/
  93. acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state)
  94. {
  95. acpi_status status;
  96. union acpi_operand_object *string_desc;
  97. union acpi_operand_object *return_desc;
  98. u32 return_value;
  99. u32 i;
  100. ACPI_FUNCTION_TRACE(ut_osi_implementation);
  101. /* Validate the string input argument */
  102. string_desc = walk_state->arguments[0].object;
  103. if (!string_desc || (string_desc->common.type != ACPI_TYPE_STRING)) {
  104. return_ACPI_STATUS(AE_TYPE);
  105. }
  106. /* Create a return object */
  107. return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
  108. if (!return_desc) {
  109. return_ACPI_STATUS(AE_NO_MEMORY);
  110. }
  111. /* Default return value is 0, NOT SUPPORTED */
  112. return_value = 0;
  113. /* Compare input string to static table of supported interfaces */
  114. for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_interfaces_supported); i++) {
  115. if (!ACPI_STRCMP(string_desc->string.pointer,
  116. acpi_interfaces_supported[i].name)) {
  117. /*
  118. * The interface is supported.
  119. * Update the osi_data if necessary. We keep track of the latest
  120. * version of Windows that has been requested by the BIOS.
  121. */
  122. if (acpi_interfaces_supported[i].value >
  123. acpi_gbl_osi_data) {
  124. acpi_gbl_osi_data =
  125. acpi_interfaces_supported[i].value;
  126. }
  127. return_value = ACPI_UINT32_MAX;
  128. goto exit;
  129. }
  130. }
  131. /*
  132. * Did not match the string in the static table, call the host OSL to
  133. * check for a match with one of the optional strings (such as
  134. * "Module Device", "3.0 Thermal Model", etc.)
  135. */
  136. status = acpi_os_validate_interface(string_desc->string.pointer);
  137. if (ACPI_SUCCESS(status)) {
  138. /* The interface is supported */
  139. return_value = ACPI_UINT32_MAX;
  140. }
  141. exit:
  142. ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO,
  143. "ACPI: BIOS _OSI(%s) is %ssupported\n",
  144. string_desc->string.pointer, return_value == 0 ? "not " : ""));
  145. /* Complete the return value */
  146. return_desc->integer.value = return_value;
  147. walk_state->return_desc = return_desc;
  148. return_ACPI_STATUS (AE_OK);
  149. }
  150. /*******************************************************************************
  151. *
  152. * FUNCTION: acpi_osi_invalidate
  153. *
  154. * PARAMETERS: interface_string
  155. *
  156. * RETURN: Status
  157. *
  158. * DESCRIPTION: invalidate string in pre-defiend _OSI string list
  159. *
  160. ******************************************************************************/
  161. acpi_status acpi_osi_invalidate(char *interface)
  162. {
  163. int i;
  164. for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_interfaces_supported); i++) {
  165. if (!ACPI_STRCMP(interface, acpi_interfaces_supported[i].name)) {
  166. *acpi_interfaces_supported[i].name = '\0';
  167. return AE_OK;
  168. }
  169. }
  170. return AE_NOT_FOUND;
  171. }
  172. /*******************************************************************************
  173. *
  174. * FUNCTION: acpi_ut_evaluate_object
  175. *
  176. * PARAMETERS: prefix_node - Starting node
  177. * Path - Path to object from starting node
  178. * expected_return_types - Bitmap of allowed return types
  179. * return_desc - Where a return value is stored
  180. *
  181. * RETURN: Status
  182. *
  183. * DESCRIPTION: Evaluates a namespace object and verifies the type of the
  184. * return object. Common code that simplifies accessing objects
  185. * that have required return objects of fixed types.
  186. *
  187. * NOTE: Internal function, no parameter validation
  188. *
  189. ******************************************************************************/
  190. acpi_status
  191. acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
  192. char *path,
  193. u32 expected_return_btypes,
  194. union acpi_operand_object **return_desc)
  195. {
  196. struct acpi_evaluate_info *info;
  197. acpi_status status;
  198. u32 return_btype;
  199. ACPI_FUNCTION_TRACE(ut_evaluate_object);
  200. /* Allocate the evaluation information block */
  201. info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
  202. if (!info) {
  203. return_ACPI_STATUS(AE_NO_MEMORY);
  204. }
  205. info->prefix_node = prefix_node;
  206. info->pathname = path;
  207. /* Evaluate the object/method */
  208. status = acpi_ns_evaluate(info);
  209. if (ACPI_FAILURE(status)) {
  210. if (status == AE_NOT_FOUND) {
  211. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  212. "[%4.4s.%s] was not found\n",
  213. acpi_ut_get_node_name(prefix_node),
  214. path));
  215. } else {
  216. ACPI_ERROR_METHOD("Method execution failed",
  217. prefix_node, path, status);
  218. }
  219. goto cleanup;
  220. }
  221. /* Did we get a return object? */
  222. if (!info->return_object) {
  223. if (expected_return_btypes) {
  224. ACPI_ERROR_METHOD("No object was returned from",
  225. prefix_node, path, AE_NOT_EXIST);
  226. status = AE_NOT_EXIST;
  227. }
  228. goto cleanup;
  229. }
  230. /* Map the return object type to the bitmapped type */
  231. switch ((info->return_object)->common.type) {
  232. case ACPI_TYPE_INTEGER:
  233. return_btype = ACPI_BTYPE_INTEGER;
  234. break;
  235. case ACPI_TYPE_BUFFER:
  236. return_btype = ACPI_BTYPE_BUFFER;
  237. break;
  238. case ACPI_TYPE_STRING:
  239. return_btype = ACPI_BTYPE_STRING;
  240. break;
  241. case ACPI_TYPE_PACKAGE:
  242. return_btype = ACPI_BTYPE_PACKAGE;
  243. break;
  244. default:
  245. return_btype = 0;
  246. break;
  247. }
  248. if ((acpi_gbl_enable_interpreter_slack) && (!expected_return_btypes)) {
  249. /*
  250. * We received a return object, but one was not expected. This can
  251. * happen frequently if the "implicit return" feature is enabled.
  252. * Just delete the return object and return AE_OK.
  253. */
  254. acpi_ut_remove_reference(info->return_object);
  255. goto cleanup;
  256. }
  257. /* Is the return object one of the expected types? */
  258. if (!(expected_return_btypes & return_btype)) {
  259. ACPI_ERROR_METHOD("Return object type is incorrect",
  260. prefix_node, path, AE_TYPE);
  261. ACPI_ERROR((AE_INFO,
  262. "Type returned from %s was incorrect: %s, expected Btypes: %X",
  263. path,
  264. acpi_ut_get_object_type_name(info->return_object),
  265. expected_return_btypes));
  266. /* On error exit, we must delete the return object */
  267. acpi_ut_remove_reference(info->return_object);
  268. status = AE_TYPE;
  269. goto cleanup;
  270. }
  271. /* Object type is OK, return it */
  272. *return_desc = info->return_object;
  273. cleanup:
  274. ACPI_FREE(info);
  275. return_ACPI_STATUS(status);
  276. }
  277. /*******************************************************************************
  278. *
  279. * FUNCTION: acpi_ut_evaluate_numeric_object
  280. *
  281. * PARAMETERS: object_name - Object name to be evaluated
  282. * device_node - Node for the device
  283. * Address - Where the value is returned
  284. *
  285. * RETURN: Status
  286. *
  287. * DESCRIPTION: Evaluates a numeric namespace object for a selected device
  288. * and stores result in *Address.
  289. *
  290. * NOTE: Internal function, no parameter validation
  291. *
  292. ******************************************************************************/
  293. acpi_status
  294. acpi_ut_evaluate_numeric_object(char *object_name,
  295. struct acpi_namespace_node *device_node,
  296. acpi_integer * address)
  297. {
  298. union acpi_operand_object *obj_desc;
  299. acpi_status status;
  300. ACPI_FUNCTION_TRACE(ut_evaluate_numeric_object);
  301. status = acpi_ut_evaluate_object(device_node, object_name,
  302. ACPI_BTYPE_INTEGER, &obj_desc);
  303. if (ACPI_FAILURE(status)) {
  304. return_ACPI_STATUS(status);
  305. }
  306. /* Get the returned Integer */
  307. *address = obj_desc->integer.value;
  308. /* On exit, we must delete the return object */
  309. acpi_ut_remove_reference(obj_desc);
  310. return_ACPI_STATUS(status);
  311. }
  312. /*******************************************************************************
  313. *
  314. * FUNCTION: acpi_ut_copy_id_string
  315. *
  316. * PARAMETERS: Destination - Where to copy the string
  317. * Source - Source string
  318. * max_length - Length of the destination buffer
  319. *
  320. * RETURN: None
  321. *
  322. * DESCRIPTION: Copies an ID string for the _HID, _CID, and _UID methods.
  323. * Performs removal of a leading asterisk if present -- workaround
  324. * for a known issue on a bunch of machines.
  325. *
  326. ******************************************************************************/
  327. static void
  328. acpi_ut_copy_id_string(char *destination, char *source, acpi_size max_length)
  329. {
  330. /*
  331. * Workaround for ID strings that have a leading asterisk. This construct
  332. * is not allowed by the ACPI specification (ID strings must be
  333. * alphanumeric), but enough existing machines have this embedded in their
  334. * ID strings that the following code is useful.
  335. */
  336. if (*source == '*') {
  337. source++;
  338. }
  339. /* Do the actual copy */
  340. ACPI_STRNCPY(destination, source, max_length);
  341. }
  342. /*******************************************************************************
  343. *
  344. * FUNCTION: acpi_ut_execute_HID
  345. *
  346. * PARAMETERS: device_node - Node for the device
  347. * Hid - Where the HID is returned
  348. *
  349. * RETURN: Status
  350. *
  351. * DESCRIPTION: Executes the _HID control method that returns the hardware
  352. * ID of the device.
  353. *
  354. * NOTE: Internal function, no parameter validation
  355. *
  356. ******************************************************************************/
  357. acpi_status
  358. acpi_ut_execute_HID(struct acpi_namespace_node *device_node,
  359. struct acpica_device_id *hid)
  360. {
  361. union acpi_operand_object *obj_desc;
  362. acpi_status status;
  363. ACPI_FUNCTION_TRACE(ut_execute_HID);
  364. status = acpi_ut_evaluate_object(device_node, METHOD_NAME__HID,
  365. ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING,
  366. &obj_desc);
  367. if (ACPI_FAILURE(status)) {
  368. return_ACPI_STATUS(status);
  369. }
  370. if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
  371. /* Convert the Numeric HID to string */
  372. acpi_ex_eisa_id_to_string((u32) obj_desc->integer.value,
  373. hid->value);
  374. } else {
  375. /* Copy the String HID from the returned object */
  376. acpi_ut_copy_id_string(hid->value, obj_desc->string.pointer,
  377. sizeof(hid->value));
  378. }
  379. /* On exit, we must delete the return object */
  380. acpi_ut_remove_reference(obj_desc);
  381. return_ACPI_STATUS(status);
  382. }
  383. /*******************************************************************************
  384. *
  385. * FUNCTION: acpi_ut_translate_one_cid
  386. *
  387. * PARAMETERS: obj_desc - _CID object, must be integer or string
  388. * one_cid - Where the CID string is returned
  389. *
  390. * RETURN: Status
  391. *
  392. * DESCRIPTION: Return a numeric or string _CID value as a string.
  393. * (Compatible ID)
  394. *
  395. * NOTE: Assumes a maximum _CID string length of
  396. * ACPI_MAX_CID_LENGTH.
  397. *
  398. ******************************************************************************/
  399. static acpi_status
  400. acpi_ut_translate_one_cid(union acpi_operand_object *obj_desc,
  401. struct acpi_compatible_id *one_cid)
  402. {
  403. switch (obj_desc->common.type) {
  404. case ACPI_TYPE_INTEGER:
  405. /* Convert the Numeric CID to string */
  406. acpi_ex_eisa_id_to_string((u32) obj_desc->integer.value,
  407. one_cid->value);
  408. return (AE_OK);
  409. case ACPI_TYPE_STRING:
  410. if (obj_desc->string.length > ACPI_MAX_CID_LENGTH) {
  411. return (AE_AML_STRING_LIMIT);
  412. }
  413. /* Copy the String CID from the returned object */
  414. acpi_ut_copy_id_string(one_cid->value, obj_desc->string.pointer,
  415. ACPI_MAX_CID_LENGTH);
  416. return (AE_OK);
  417. default:
  418. return (AE_TYPE);
  419. }
  420. }
  421. /*******************************************************************************
  422. *
  423. * FUNCTION: acpi_ut_execute_CID
  424. *
  425. * PARAMETERS: device_node - Node for the device
  426. * return_cid_list - Where the CID list is returned
  427. *
  428. * RETURN: Status
  429. *
  430. * DESCRIPTION: Executes the _CID control method that returns one or more
  431. * compatible hardware IDs for the device.
  432. *
  433. * NOTE: Internal function, no parameter validation
  434. *
  435. ******************************************************************************/
  436. acpi_status
  437. acpi_ut_execute_CID(struct acpi_namespace_node * device_node,
  438. struct acpi_compatible_id_list ** return_cid_list)
  439. {
  440. union acpi_operand_object *obj_desc;
  441. acpi_status status;
  442. u32 count;
  443. u32 size;
  444. struct acpi_compatible_id_list *cid_list;
  445. u32 i;
  446. ACPI_FUNCTION_TRACE(ut_execute_CID);
  447. /* Evaluate the _CID method for this device */
  448. status = acpi_ut_evaluate_object(device_node, METHOD_NAME__CID,
  449. ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING
  450. | ACPI_BTYPE_PACKAGE, &obj_desc);
  451. if (ACPI_FAILURE(status)) {
  452. return_ACPI_STATUS(status);
  453. }
  454. /* Get the number of _CIDs returned */
  455. count = 1;
  456. if (obj_desc->common.type == ACPI_TYPE_PACKAGE) {
  457. count = obj_desc->package.count;
  458. }
  459. /* Allocate a worst-case buffer for the _CIDs */
  460. size = (((count - 1) * sizeof(struct acpi_compatible_id)) +
  461. sizeof(struct acpi_compatible_id_list));
  462. cid_list = ACPI_ALLOCATE_ZEROED((acpi_size) size);
  463. if (!cid_list) {
  464. return_ACPI_STATUS(AE_NO_MEMORY);
  465. }
  466. /* Init CID list */
  467. cid_list->count = count;
  468. cid_list->size = size;
  469. /*
  470. * A _CID can return either a single compatible ID or a package of
  471. * compatible IDs. Each compatible ID can be one of the following:
  472. * 1) Integer (32 bit compressed EISA ID) or
  473. * 2) String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss")
  474. */
  475. /* The _CID object can be either a single CID or a package (list) of CIDs */
  476. if (obj_desc->common.type == ACPI_TYPE_PACKAGE) {
  477. /* Translate each package element */
  478. for (i = 0; i < count; i++) {
  479. status =
  480. acpi_ut_translate_one_cid(obj_desc->package.
  481. elements[i],
  482. &cid_list->id[i]);
  483. if (ACPI_FAILURE(status)) {
  484. break;
  485. }
  486. }
  487. } else {
  488. /* Only one CID, translate to a string */
  489. status = acpi_ut_translate_one_cid(obj_desc, cid_list->id);
  490. }
  491. /* Cleanup on error */
  492. if (ACPI_FAILURE(status)) {
  493. ACPI_FREE(cid_list);
  494. } else {
  495. *return_cid_list = cid_list;
  496. }
  497. /* On exit, we must delete the _CID return object */
  498. acpi_ut_remove_reference(obj_desc);
  499. return_ACPI_STATUS(status);
  500. }
  501. /*******************************************************************************
  502. *
  503. * FUNCTION: acpi_ut_execute_UID
  504. *
  505. * PARAMETERS: device_node - Node for the device
  506. * Uid - Where the UID is returned
  507. *
  508. * RETURN: Status
  509. *
  510. * DESCRIPTION: Executes the _UID control method that returns the hardware
  511. * ID of the device.
  512. *
  513. * NOTE: Internal function, no parameter validation
  514. *
  515. ******************************************************************************/
  516. acpi_status
  517. acpi_ut_execute_UID(struct acpi_namespace_node *device_node,
  518. struct acpica_device_id *uid)
  519. {
  520. union acpi_operand_object *obj_desc;
  521. acpi_status status;
  522. ACPI_FUNCTION_TRACE(ut_execute_UID);
  523. status = acpi_ut_evaluate_object(device_node, METHOD_NAME__UID,
  524. ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING,
  525. &obj_desc);
  526. if (ACPI_FAILURE(status)) {
  527. return_ACPI_STATUS(status);
  528. }
  529. if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
  530. /* Convert the Numeric UID to string */
  531. acpi_ex_unsigned_integer_to_string(obj_desc->integer.value,
  532. uid->value);
  533. } else {
  534. /* Copy the String UID from the returned object */
  535. acpi_ut_copy_id_string(uid->value, obj_desc->string.pointer,
  536. sizeof(uid->value));
  537. }
  538. /* On exit, we must delete the return object */
  539. acpi_ut_remove_reference(obj_desc);
  540. return_ACPI_STATUS(status);
  541. }
  542. /*******************************************************************************
  543. *
  544. * FUNCTION: acpi_ut_execute_STA
  545. *
  546. * PARAMETERS: device_node - Node for the device
  547. * Flags - Where the status flags are returned
  548. *
  549. * RETURN: Status
  550. *
  551. * DESCRIPTION: Executes _STA for selected device and stores results in
  552. * *Flags.
  553. *
  554. * NOTE: Internal function, no parameter validation
  555. *
  556. ******************************************************************************/
  557. acpi_status
  558. acpi_ut_execute_STA(struct acpi_namespace_node *device_node, u32 * flags)
  559. {
  560. union acpi_operand_object *obj_desc;
  561. acpi_status status;
  562. ACPI_FUNCTION_TRACE(ut_execute_STA);
  563. status = acpi_ut_evaluate_object(device_node, METHOD_NAME__STA,
  564. ACPI_BTYPE_INTEGER, &obj_desc);
  565. if (ACPI_FAILURE(status)) {
  566. if (AE_NOT_FOUND == status) {
  567. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  568. "_STA on %4.4s was not found, assuming device is present\n",
  569. acpi_ut_get_node_name(device_node)));
  570. *flags = ACPI_UINT32_MAX;
  571. status = AE_OK;
  572. }
  573. return_ACPI_STATUS(status);
  574. }
  575. /* Extract the status flags */
  576. *flags = (u32) obj_desc->integer.value;
  577. /* On exit, we must delete the return object */
  578. acpi_ut_remove_reference(obj_desc);
  579. return_ACPI_STATUS(status);
  580. }
  581. /*******************************************************************************
  582. *
  583. * FUNCTION: acpi_ut_execute_Sxds
  584. *
  585. * PARAMETERS: device_node - Node for the device
  586. * Flags - Where the status flags are returned
  587. *
  588. * RETURN: Status
  589. *
  590. * DESCRIPTION: Executes _STA for selected device and stores results in
  591. * *Flags.
  592. *
  593. * NOTE: Internal function, no parameter validation
  594. *
  595. ******************************************************************************/
  596. acpi_status
  597. acpi_ut_execute_sxds(struct acpi_namespace_node *device_node, u8 * highest)
  598. {
  599. union acpi_operand_object *obj_desc;
  600. acpi_status status;
  601. u32 i;
  602. ACPI_FUNCTION_TRACE(ut_execute_sxds);
  603. for (i = 0; i < 4; i++) {
  604. highest[i] = 0xFF;
  605. status = acpi_ut_evaluate_object(device_node,
  606. ACPI_CAST_PTR(char,
  607. acpi_gbl_highest_dstate_names
  608. [i]),
  609. ACPI_BTYPE_INTEGER, &obj_desc);
  610. if (ACPI_FAILURE(status)) {
  611. if (status != AE_NOT_FOUND) {
  612. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  613. "%s on Device %4.4s, %s\n",
  614. ACPI_CAST_PTR(char,
  615. acpi_gbl_highest_dstate_names
  616. [i]),
  617. acpi_ut_get_node_name
  618. (device_node),
  619. acpi_format_exception
  620. (status)));
  621. return_ACPI_STATUS(status);
  622. }
  623. } else {
  624. /* Extract the Dstate value */
  625. highest[i] = (u8) obj_desc->integer.value;
  626. /* Delete the return object */
  627. acpi_ut_remove_reference(obj_desc);
  628. }
  629. }
  630. return_ACPI_STATUS(AE_OK);
  631. }