utosi.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. /******************************************************************************
  2. *
  3. * Module Name: utosi - Support for the _OSI predefined control method
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2014, 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. #define _COMPONENT ACPI_UTILITIES
  45. ACPI_MODULE_NAME("utosi")
  46. /******************************************************************************
  47. *
  48. * ACPICA policy for new _OSI strings:
  49. *
  50. * It is the stated policy of ACPICA that new _OSI strings will be integrated
  51. * into this module as soon as possible after they are defined. It is strongly
  52. * recommended that all ACPICA hosts mirror this policy and integrate any
  53. * changes to this module as soon as possible. There are several historical
  54. * reasons behind this policy:
  55. *
  56. * 1) New BIOSs tend to test only the case where the host responds TRUE to
  57. * the latest version of Windows, which would respond to the latest/newest
  58. * _OSI string. Not responding TRUE to the latest version of Windows will
  59. * risk executing untested code paths throughout the DSDT and SSDTs.
  60. *
  61. * 2) If a new _OSI string is recognized only after a significant delay, this
  62. * has the potential to cause problems on existing working machines because
  63. * of the possibility that a new and different path through the ASL code
  64. * will be executed.
  65. *
  66. * 3) New _OSI strings are tending to come out about once per year. A delay
  67. * in recognizing a new string for a significant amount of time risks the
  68. * release of another string which only compounds the initial problem.
  69. *
  70. *****************************************************************************/
  71. /*
  72. * Strings supported by the _OSI predefined control method (which is
  73. * implemented internally within this module.)
  74. *
  75. * March 2009: Removed "Linux" as this host no longer wants to respond true
  76. * for this string. Basically, the only safe OS strings are windows-related
  77. * and in many or most cases represent the only test path within the
  78. * BIOS-provided ASL code.
  79. *
  80. * The last element of each entry is used to track the newest version of
  81. * Windows that the BIOS has requested.
  82. */
  83. static struct acpi_interface_info acpi_default_supported_interfaces[] = {
  84. /* Operating System Vendor Strings */
  85. {"Windows 2000", NULL, 0, ACPI_OSI_WIN_2000}, /* Windows 2000 */
  86. {"Windows 2001", NULL, 0, ACPI_OSI_WIN_XP}, /* Windows XP */
  87. {"Windows 2001 SP1", NULL, 0, ACPI_OSI_WIN_XP_SP1}, /* Windows XP SP1 */
  88. {"Windows 2001.1", NULL, 0, ACPI_OSI_WINSRV_2003}, /* Windows Server 2003 */
  89. {"Windows 2001 SP2", NULL, 0, ACPI_OSI_WIN_XP_SP2}, /* Windows XP SP2 */
  90. {"Windows 2001.1 SP1", NULL, 0, ACPI_OSI_WINSRV_2003_SP1}, /* Windows Server 2003 SP1 - Added 03/2006 */
  91. {"Windows 2006", NULL, 0, ACPI_OSI_WIN_VISTA}, /* Windows vista - Added 03/2006 */
  92. {"Windows 2006.1", NULL, 0, ACPI_OSI_WINSRV_2008}, /* Windows Server 2008 - Added 09/2009 */
  93. {"Windows 2006 SP1", NULL, 0, ACPI_OSI_WIN_VISTA_SP1}, /* Windows Vista SP1 - Added 09/2009 */
  94. {"Windows 2006 SP2", NULL, 0, ACPI_OSI_WIN_VISTA_SP2}, /* Windows Vista SP2 - Added 09/2010 */
  95. {"Windows 2009", NULL, 0, ACPI_OSI_WIN_7}, /* Windows 7 and Server 2008 R2 - Added 09/2009 */
  96. {"Windows 2012", NULL, 0, ACPI_OSI_WIN_8}, /* Windows 8 and Server 2012 - Added 08/2012 */
  97. {"Windows 2013", NULL, 0, ACPI_OSI_WIN_8}, /* Windows 8.1 and Server 2012 R2 - Added 01/2014 */
  98. /* Feature Group Strings */
  99. {"Extended Address Space Descriptor", NULL, ACPI_OSI_FEATURE, 0},
  100. /*
  101. * All "optional" feature group strings (features that are implemented
  102. * by the host) should be dynamically modified to VALID by the host via
  103. * acpi_install_interface or acpi_update_interfaces. Such optional feature
  104. * group strings are set as INVALID by default here.
  105. */
  106. {"Module Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
  107. {"Processor Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
  108. {"3.0 Thermal Model", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
  109. {"3.0 _SCP Extensions", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
  110. {"Processor Aggregator Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0}
  111. };
  112. /*******************************************************************************
  113. *
  114. * FUNCTION: acpi_ut_initialize_interfaces
  115. *
  116. * PARAMETERS: None
  117. *
  118. * RETURN: Status
  119. *
  120. * DESCRIPTION: Initialize the global _OSI supported interfaces list
  121. *
  122. ******************************************************************************/
  123. acpi_status acpi_ut_initialize_interfaces(void)
  124. {
  125. acpi_status status;
  126. u32 i;
  127. status = acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER);
  128. if (ACPI_FAILURE(status)) {
  129. return (status);
  130. }
  131. acpi_gbl_supported_interfaces = acpi_default_supported_interfaces;
  132. /* Link the static list of supported interfaces */
  133. for (i = 0;
  134. i < (ACPI_ARRAY_LENGTH(acpi_default_supported_interfaces) - 1);
  135. i++) {
  136. acpi_default_supported_interfaces[i].next =
  137. &acpi_default_supported_interfaces[(acpi_size) i + 1];
  138. }
  139. acpi_os_release_mutex(acpi_gbl_osi_mutex);
  140. return (AE_OK);
  141. }
  142. /*******************************************************************************
  143. *
  144. * FUNCTION: acpi_ut_interface_terminate
  145. *
  146. * PARAMETERS: None
  147. *
  148. * RETURN: Status
  149. *
  150. * DESCRIPTION: Delete all interfaces in the global list. Sets
  151. * acpi_gbl_supported_interfaces to NULL.
  152. *
  153. ******************************************************************************/
  154. acpi_status acpi_ut_interface_terminate(void)
  155. {
  156. acpi_status status;
  157. struct acpi_interface_info *next_interface;
  158. status = acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER);
  159. if (ACPI_FAILURE(status)) {
  160. return (status);
  161. }
  162. next_interface = acpi_gbl_supported_interfaces;
  163. while (next_interface) {
  164. acpi_gbl_supported_interfaces = next_interface->next;
  165. if (next_interface->flags & ACPI_OSI_DYNAMIC) {
  166. /* Only interfaces added at runtime can be freed */
  167. ACPI_FREE(next_interface->name);
  168. ACPI_FREE(next_interface);
  169. } else {
  170. /* Interface is in static list. Reset it to invalid or valid. */
  171. if (next_interface->flags & ACPI_OSI_DEFAULT_INVALID) {
  172. next_interface->flags |= ACPI_OSI_INVALID;
  173. } else {
  174. next_interface->flags &= ~ACPI_OSI_INVALID;
  175. }
  176. }
  177. next_interface = acpi_gbl_supported_interfaces;
  178. }
  179. acpi_os_release_mutex(acpi_gbl_osi_mutex);
  180. return (AE_OK);
  181. }
  182. /*******************************************************************************
  183. *
  184. * FUNCTION: acpi_ut_install_interface
  185. *
  186. * PARAMETERS: interface_name - The interface to install
  187. *
  188. * RETURN: Status
  189. *
  190. * DESCRIPTION: Install the interface into the global interface list.
  191. * Caller MUST hold acpi_gbl_osi_mutex
  192. *
  193. ******************************************************************************/
  194. acpi_status acpi_ut_install_interface(acpi_string interface_name)
  195. {
  196. struct acpi_interface_info *interface_info;
  197. /* Allocate info block and space for the name string */
  198. interface_info =
  199. ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_interface_info));
  200. if (!interface_info) {
  201. return (AE_NO_MEMORY);
  202. }
  203. interface_info->name =
  204. ACPI_ALLOCATE_ZEROED(ACPI_STRLEN(interface_name) + 1);
  205. if (!interface_info->name) {
  206. ACPI_FREE(interface_info);
  207. return (AE_NO_MEMORY);
  208. }
  209. /* Initialize new info and insert at the head of the global list */
  210. ACPI_STRCPY(interface_info->name, interface_name);
  211. interface_info->flags = ACPI_OSI_DYNAMIC;
  212. interface_info->next = acpi_gbl_supported_interfaces;
  213. acpi_gbl_supported_interfaces = interface_info;
  214. return (AE_OK);
  215. }
  216. /*******************************************************************************
  217. *
  218. * FUNCTION: acpi_ut_remove_interface
  219. *
  220. * PARAMETERS: interface_name - The interface to remove
  221. *
  222. * RETURN: Status
  223. *
  224. * DESCRIPTION: Remove the interface from the global interface list.
  225. * Caller MUST hold acpi_gbl_osi_mutex
  226. *
  227. ******************************************************************************/
  228. acpi_status acpi_ut_remove_interface(acpi_string interface_name)
  229. {
  230. struct acpi_interface_info *previous_interface;
  231. struct acpi_interface_info *next_interface;
  232. previous_interface = next_interface = acpi_gbl_supported_interfaces;
  233. while (next_interface) {
  234. if (!ACPI_STRCMP(interface_name, next_interface->name)) {
  235. /* Found: name is in either the static list or was added at runtime */
  236. if (next_interface->flags & ACPI_OSI_DYNAMIC) {
  237. /* Interface was added dynamically, remove and free it */
  238. if (previous_interface == next_interface) {
  239. acpi_gbl_supported_interfaces =
  240. next_interface->next;
  241. } else {
  242. previous_interface->next =
  243. next_interface->next;
  244. }
  245. ACPI_FREE(next_interface->name);
  246. ACPI_FREE(next_interface);
  247. } else {
  248. /*
  249. * Interface is in static list. If marked invalid, then it
  250. * does not actually exist. Else, mark it invalid.
  251. */
  252. if (next_interface->flags & ACPI_OSI_INVALID) {
  253. return (AE_NOT_EXIST);
  254. }
  255. next_interface->flags |= ACPI_OSI_INVALID;
  256. }
  257. return (AE_OK);
  258. }
  259. previous_interface = next_interface;
  260. next_interface = next_interface->next;
  261. }
  262. /* Interface was not found */
  263. return (AE_NOT_EXIST);
  264. }
  265. /*******************************************************************************
  266. *
  267. * FUNCTION: acpi_ut_update_interfaces
  268. *
  269. * PARAMETERS: action - Actions to be performed during the
  270. * update
  271. *
  272. * RETURN: Status
  273. *
  274. * DESCRIPTION: Update _OSI interface strings, disabling or enabling OS vendor
  275. * strings or/and feature group strings.
  276. * Caller MUST hold acpi_gbl_osi_mutex
  277. *
  278. ******************************************************************************/
  279. acpi_status acpi_ut_update_interfaces(u8 action)
  280. {
  281. struct acpi_interface_info *next_interface;
  282. next_interface = acpi_gbl_supported_interfaces;
  283. while (next_interface) {
  284. if (((next_interface->flags & ACPI_OSI_FEATURE) &&
  285. (action & ACPI_FEATURE_STRINGS)) ||
  286. (!(next_interface->flags & ACPI_OSI_FEATURE) &&
  287. (action & ACPI_VENDOR_STRINGS))) {
  288. if (action & ACPI_DISABLE_INTERFACES) {
  289. /* Mark the interfaces as invalid */
  290. next_interface->flags |= ACPI_OSI_INVALID;
  291. } else {
  292. /* Mark the interfaces as valid */
  293. next_interface->flags &= ~ACPI_OSI_INVALID;
  294. }
  295. }
  296. next_interface = next_interface->next;
  297. }
  298. return (AE_OK);
  299. }
  300. /*******************************************************************************
  301. *
  302. * FUNCTION: acpi_ut_get_interface
  303. *
  304. * PARAMETERS: interface_name - The interface to find
  305. *
  306. * RETURN: struct acpi_interface_info if found. NULL if not found.
  307. *
  308. * DESCRIPTION: Search for the specified interface name in the global list.
  309. * Caller MUST hold acpi_gbl_osi_mutex
  310. *
  311. ******************************************************************************/
  312. struct acpi_interface_info *acpi_ut_get_interface(acpi_string interface_name)
  313. {
  314. struct acpi_interface_info *next_interface;
  315. next_interface = acpi_gbl_supported_interfaces;
  316. while (next_interface) {
  317. if (!ACPI_STRCMP(interface_name, next_interface->name)) {
  318. return (next_interface);
  319. }
  320. next_interface = next_interface->next;
  321. }
  322. return (NULL);
  323. }
  324. /*******************************************************************************
  325. *
  326. * FUNCTION: acpi_ut_osi_implementation
  327. *
  328. * PARAMETERS: walk_state - Current walk state
  329. *
  330. * RETURN: Status
  331. *
  332. * DESCRIPTION: Implementation of the _OSI predefined control method. When
  333. * an invocation of _OSI is encountered in the system AML,
  334. * control is transferred to this function.
  335. *
  336. ******************************************************************************/
  337. acpi_status acpi_ut_osi_implementation(struct acpi_walk_state * walk_state)
  338. {
  339. union acpi_operand_object *string_desc;
  340. union acpi_operand_object *return_desc;
  341. struct acpi_interface_info *interface_info;
  342. acpi_interface_handler interface_handler;
  343. acpi_status status;
  344. u32 return_value;
  345. ACPI_FUNCTION_TRACE(ut_osi_implementation);
  346. /* Validate the string input argument (from the AML caller) */
  347. string_desc = walk_state->arguments[0].object;
  348. if (!string_desc || (string_desc->common.type != ACPI_TYPE_STRING)) {
  349. return_ACPI_STATUS(AE_TYPE);
  350. }
  351. /* Create a return object */
  352. return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
  353. if (!return_desc) {
  354. return_ACPI_STATUS(AE_NO_MEMORY);
  355. }
  356. /* Default return value is 0, NOT SUPPORTED */
  357. return_value = 0;
  358. status = acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER);
  359. if (ACPI_FAILURE(status)) {
  360. acpi_ut_remove_reference(return_desc);
  361. return_ACPI_STATUS(status);
  362. }
  363. /* Lookup the interface in the global _OSI list */
  364. interface_info = acpi_ut_get_interface(string_desc->string.pointer);
  365. if (interface_info && !(interface_info->flags & ACPI_OSI_INVALID)) {
  366. /*
  367. * The interface is supported.
  368. * Update the osi_data if necessary. We keep track of the latest
  369. * version of Windows that has been requested by the BIOS.
  370. */
  371. if (interface_info->value > acpi_gbl_osi_data) {
  372. acpi_gbl_osi_data = interface_info->value;
  373. }
  374. return_value = ACPI_UINT32_MAX;
  375. }
  376. acpi_os_release_mutex(acpi_gbl_osi_mutex);
  377. /*
  378. * Invoke an optional _OSI interface handler. The host OS may wish
  379. * to do some interface-specific handling. For example, warn about
  380. * certain interfaces or override the true/false support value.
  381. */
  382. interface_handler = acpi_gbl_interface_handler;
  383. if (interface_handler) {
  384. return_value =
  385. interface_handler(string_desc->string.pointer,
  386. return_value);
  387. }
  388. ACPI_DEBUG_PRINT_RAW((ACPI_DB_INFO,
  389. "ACPI: BIOS _OSI(\"%s\") is %ssupported\n",
  390. string_desc->string.pointer,
  391. return_value == 0 ? "not " : ""));
  392. /* Complete the return object */
  393. return_desc->integer.value = return_value;
  394. walk_state->return_desc = return_desc;
  395. return_ACPI_STATUS(AE_OK);
  396. }