uteval.c 21 KB

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