uteval.c 21 KB

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