Erik Schmauss | 9585763 | 2018-03-14 16:13:07 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 2 | /****************************************************************************** |
| 3 | * |
| 4 | * Module Name: utosi - Support for the _OSI predefined control method |
| 5 | * |
Bob Moore | 840c02c | 2019-01-14 09:55:25 -0800 | [diff] [blame] | 6 | * Copyright (C) 2000 - 2019, Intel Corp. |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 7 | * |
Erik Schmauss | 9585763 | 2018-03-14 16:13:07 -0700 | [diff] [blame] | 8 | *****************************************************************************/ |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 9 | |
| 10 | #include <acpi/acpi.h> |
| 11 | #include "accommon.h" |
| 12 | |
| 13 | #define _COMPONENT ACPI_UTILITIES |
| 14 | ACPI_MODULE_NAME("utosi") |
| 15 | |
Bob Moore | 73581c0 | 2014-02-26 10:33:18 +0800 | [diff] [blame] | 16 | /****************************************************************************** |
| 17 | * |
| 18 | * ACPICA policy for new _OSI strings: |
| 19 | * |
| 20 | * It is the stated policy of ACPICA that new _OSI strings will be integrated |
| 21 | * into this module as soon as possible after they are defined. It is strongly |
| 22 | * recommended that all ACPICA hosts mirror this policy and integrate any |
| 23 | * changes to this module as soon as possible. There are several historical |
| 24 | * reasons behind this policy: |
| 25 | * |
| 26 | * 1) New BIOSs tend to test only the case where the host responds TRUE to |
| 27 | * the latest version of Windows, which would respond to the latest/newest |
| 28 | * _OSI string. Not responding TRUE to the latest version of Windows will |
| 29 | * risk executing untested code paths throughout the DSDT and SSDTs. |
| 30 | * |
| 31 | * 2) If a new _OSI string is recognized only after a significant delay, this |
| 32 | * has the potential to cause problems on existing working machines because |
| 33 | * of the possibility that a new and different path through the ASL code |
| 34 | * will be executed. |
| 35 | * |
| 36 | * 3) New _OSI strings are tending to come out about once per year. A delay |
| 37 | * in recognizing a new string for a significant amount of time risks the |
| 38 | * release of another string which only compounds the initial problem. |
| 39 | * |
| 40 | *****************************************************************************/ |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 41 | /* |
| 42 | * Strings supported by the _OSI predefined control method (which is |
| 43 | * implemented internally within this module.) |
| 44 | * |
| 45 | * March 2009: Removed "Linux" as this host no longer wants to respond true |
| 46 | * for this string. Basically, the only safe OS strings are windows-related |
| 47 | * and in many or most cases represent the only test path within the |
| 48 | * BIOS-provided ASL code. |
| 49 | * |
| 50 | * The last element of each entry is used to track the newest version of |
| 51 | * Windows that the BIOS has requested. |
| 52 | */ |
| 53 | static struct acpi_interface_info acpi_default_supported_interfaces[] = { |
| 54 | /* Operating System Vendor Strings */ |
| 55 | |
| 56 | {"Windows 2000", NULL, 0, ACPI_OSI_WIN_2000}, /* Windows 2000 */ |
| 57 | {"Windows 2001", NULL, 0, ACPI_OSI_WIN_XP}, /* Windows XP */ |
| 58 | {"Windows 2001 SP1", NULL, 0, ACPI_OSI_WIN_XP_SP1}, /* Windows XP SP1 */ |
| 59 | {"Windows 2001.1", NULL, 0, ACPI_OSI_WINSRV_2003}, /* Windows Server 2003 */ |
| 60 | {"Windows 2001 SP2", NULL, 0, ACPI_OSI_WIN_XP_SP2}, /* Windows XP SP2 */ |
| 61 | {"Windows 2001.1 SP1", NULL, 0, ACPI_OSI_WINSRV_2003_SP1}, /* Windows Server 2003 SP1 - Added 03/2006 */ |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 62 | {"Windows 2006", NULL, 0, ACPI_OSI_WIN_VISTA}, /* Windows vista - Added 03/2006 */ |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 63 | {"Windows 2006.1", NULL, 0, ACPI_OSI_WINSRV_2008}, /* Windows Server 2008 - Added 09/2009 */ |
| 64 | {"Windows 2006 SP1", NULL, 0, ACPI_OSI_WIN_VISTA_SP1}, /* Windows Vista SP1 - Added 09/2009 */ |
Bob Moore | 23ebbf0 | 2010-10-18 08:50:47 +0800 | [diff] [blame] | 65 | {"Windows 2006 SP2", NULL, 0, ACPI_OSI_WIN_VISTA_SP2}, /* Windows Vista SP2 - Added 09/2010 */ |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 66 | {"Windows 2009", NULL, 0, ACPI_OSI_WIN_7}, /* Windows 7 and Server 2008 R2 - Added 09/2009 */ |
Bob Moore | a57f7f9 | 2012-08-17 10:55:02 +0800 | [diff] [blame] | 67 | {"Windows 2012", NULL, 0, ACPI_OSI_WIN_8}, /* Windows 8 and Server 2012 - Added 08/2012 */ |
Bob Moore | faae404 | 2014-02-11 10:25:27 +0800 | [diff] [blame] | 68 | {"Windows 2013", NULL, 0, ACPI_OSI_WIN_8}, /* Windows 8.1 and Server 2012 R2 - Added 01/2014 */ |
Bob Moore | 796888e | 2015-04-13 11:50:37 +0800 | [diff] [blame] | 69 | {"Windows 2015", NULL, 0, ACPI_OSI_WIN_10}, /* Windows 10 - Added 03/2015 */ |
Mario Limonciello | bc4d413 | 2018-01-03 15:06:28 -0800 | [diff] [blame] | 70 | {"Windows 2016", NULL, 0, ACPI_OSI_WIN_10_RS1}, /* Windows 10 version 1607 - Added 12/2017 */ |
| 71 | {"Windows 2017", NULL, 0, ACPI_OSI_WIN_10_RS2}, /* Windows 10 version 1703 - Added 12/2017 */ |
Mario Limonciello | ad584b4 | 2018-03-14 16:13:00 -0700 | [diff] [blame] | 72 | {"Windows 2017.2", NULL, 0, ACPI_OSI_WIN_10_RS3}, /* Windows 10 version 1709 - Added 02/2018 */ |
Bob Moore | 2db9087 | 2018-12-13 12:30:26 -0800 | [diff] [blame] | 73 | {"Windows 2018", NULL, 0, ACPI_OSI_WIN_10_RS4}, /* Windows 10 version 1803 - Added 11/2018 */ |
Jung-uk Kim | 0fcb9a3 | 2018-12-13 12:30:31 -0800 | [diff] [blame] | 74 | {"Windows 2018.2", NULL, 0, ACPI_OSI_WIN_10_RS5}, /* Windows 10 version 1809 - Added 11/2018 */ |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 75 | |
| 76 | /* Feature Group Strings */ |
| 77 | |
Lv Zheng | 2cf9f5b | 2013-07-22 16:08:16 +0800 | [diff] [blame] | 78 | {"Extended Address Space Descriptor", NULL, ACPI_OSI_FEATURE, 0}, |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 79 | |
| 80 | /* |
| 81 | * All "optional" feature group strings (features that are implemented |
Lv Zheng | 2cf9f5b | 2013-07-22 16:08:16 +0800 | [diff] [blame] | 82 | * by the host) should be dynamically modified to VALID by the host via |
| 83 | * acpi_install_interface or acpi_update_interfaces. Such optional feature |
| 84 | * group strings are set as INVALID by default here. |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 85 | */ |
Lv Zheng | 2cf9f5b | 2013-07-22 16:08:16 +0800 | [diff] [blame] | 86 | |
| 87 | {"Module Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0}, |
| 88 | {"Processor Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0}, |
| 89 | {"3.0 Thermal Model", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0}, |
| 90 | {"3.0 _SCP Extensions", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0}, |
| 91 | {"Processor Aggregator Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0} |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | /******************************************************************************* |
| 95 | * |
| 96 | * FUNCTION: acpi_ut_initialize_interfaces |
| 97 | * |
| 98 | * PARAMETERS: None |
| 99 | * |
| 100 | * RETURN: Status |
| 101 | * |
| 102 | * DESCRIPTION: Initialize the global _OSI supported interfaces list |
| 103 | * |
| 104 | ******************************************************************************/ |
| 105 | |
| 106 | acpi_status acpi_ut_initialize_interfaces(void) |
| 107 | { |
Jung-uk Kim | 388a990 | 2013-04-12 00:24:34 +0000 | [diff] [blame] | 108 | acpi_status status; |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 109 | u32 i; |
| 110 | |
Jung-uk Kim | 388a990 | 2013-04-12 00:24:34 +0000 | [diff] [blame] | 111 | status = acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER); |
| 112 | if (ACPI_FAILURE(status)) { |
| 113 | return (status); |
| 114 | } |
| 115 | |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 116 | acpi_gbl_supported_interfaces = acpi_default_supported_interfaces; |
| 117 | |
| 118 | /* Link the static list of supported interfaces */ |
| 119 | |
| 120 | for (i = 0; |
| 121 | i < (ACPI_ARRAY_LENGTH(acpi_default_supported_interfaces) - 1); |
| 122 | i++) { |
| 123 | acpi_default_supported_interfaces[i].next = |
Lv Zheng | f5c1e1c | 2016-05-05 12:57:53 +0800 | [diff] [blame] | 124 | &acpi_default_supported_interfaces[(acpi_size)i + 1]; |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | acpi_os_release_mutex(acpi_gbl_osi_mutex); |
| 128 | return (AE_OK); |
| 129 | } |
| 130 | |
| 131 | /******************************************************************************* |
| 132 | * |
| 133 | * FUNCTION: acpi_ut_interface_terminate |
| 134 | * |
| 135 | * PARAMETERS: None |
| 136 | * |
Jung-uk Kim | 388a990 | 2013-04-12 00:24:34 +0000 | [diff] [blame] | 137 | * RETURN: Status |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 138 | * |
| 139 | * DESCRIPTION: Delete all interfaces in the global list. Sets |
| 140 | * acpi_gbl_supported_interfaces to NULL. |
| 141 | * |
| 142 | ******************************************************************************/ |
| 143 | |
Jung-uk Kim | 388a990 | 2013-04-12 00:24:34 +0000 | [diff] [blame] | 144 | acpi_status acpi_ut_interface_terminate(void) |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 145 | { |
Jung-uk Kim | 388a990 | 2013-04-12 00:24:34 +0000 | [diff] [blame] | 146 | acpi_status status; |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 147 | struct acpi_interface_info *next_interface; |
| 148 | |
Jung-uk Kim | 388a990 | 2013-04-12 00:24:34 +0000 | [diff] [blame] | 149 | status = acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER); |
| 150 | if (ACPI_FAILURE(status)) { |
| 151 | return (status); |
| 152 | } |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 153 | |
Jung-uk Kim | 388a990 | 2013-04-12 00:24:34 +0000 | [diff] [blame] | 154 | next_interface = acpi_gbl_supported_interfaces; |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 155 | while (next_interface) { |
| 156 | acpi_gbl_supported_interfaces = next_interface->next; |
| 157 | |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 158 | if (next_interface->flags & ACPI_OSI_DYNAMIC) { |
Lv Zheng | 2cf9f5b | 2013-07-22 16:08:16 +0800 | [diff] [blame] | 159 | |
| 160 | /* Only interfaces added at runtime can be freed */ |
| 161 | |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 162 | ACPI_FREE(next_interface->name); |
| 163 | ACPI_FREE(next_interface); |
Lv Zheng | 2cf9f5b | 2013-07-22 16:08:16 +0800 | [diff] [blame] | 164 | } else { |
| 165 | /* Interface is in static list. Reset it to invalid or valid. */ |
| 166 | |
| 167 | if (next_interface->flags & ACPI_OSI_DEFAULT_INVALID) { |
| 168 | next_interface->flags |= ACPI_OSI_INVALID; |
| 169 | } else { |
| 170 | next_interface->flags &= ~ACPI_OSI_INVALID; |
| 171 | } |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | next_interface = acpi_gbl_supported_interfaces; |
| 175 | } |
| 176 | |
| 177 | acpi_os_release_mutex(acpi_gbl_osi_mutex); |
Jung-uk Kim | 388a990 | 2013-04-12 00:24:34 +0000 | [diff] [blame] | 178 | return (AE_OK); |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | /******************************************************************************* |
| 182 | * |
| 183 | * FUNCTION: acpi_ut_install_interface |
| 184 | * |
| 185 | * PARAMETERS: interface_name - The interface to install |
| 186 | * |
| 187 | * RETURN: Status |
| 188 | * |
| 189 | * DESCRIPTION: Install the interface into the global interface list. |
| 190 | * Caller MUST hold acpi_gbl_osi_mutex |
| 191 | * |
| 192 | ******************************************************************************/ |
| 193 | |
| 194 | acpi_status acpi_ut_install_interface(acpi_string interface_name) |
| 195 | { |
| 196 | struct acpi_interface_info *interface_info; |
| 197 | |
| 198 | /* Allocate info block and space for the name string */ |
| 199 | |
| 200 | interface_info = |
| 201 | ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_interface_info)); |
| 202 | if (!interface_info) { |
| 203 | return (AE_NO_MEMORY); |
| 204 | } |
| 205 | |
Bob Moore | 4fa4616 | 2015-07-01 14:45:11 +0800 | [diff] [blame] | 206 | interface_info->name = ACPI_ALLOCATE_ZEROED(strlen(interface_name) + 1); |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 207 | if (!interface_info->name) { |
| 208 | ACPI_FREE(interface_info); |
| 209 | return (AE_NO_MEMORY); |
| 210 | } |
| 211 | |
| 212 | /* Initialize new info and insert at the head of the global list */ |
| 213 | |
Bob Moore | 4fa4616 | 2015-07-01 14:45:11 +0800 | [diff] [blame] | 214 | strcpy(interface_info->name, interface_name); |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 215 | interface_info->flags = ACPI_OSI_DYNAMIC; |
| 216 | interface_info->next = acpi_gbl_supported_interfaces; |
| 217 | |
| 218 | acpi_gbl_supported_interfaces = interface_info; |
| 219 | return (AE_OK); |
| 220 | } |
| 221 | |
| 222 | /******************************************************************************* |
| 223 | * |
| 224 | * FUNCTION: acpi_ut_remove_interface |
| 225 | * |
| 226 | * PARAMETERS: interface_name - The interface to remove |
| 227 | * |
| 228 | * RETURN: Status |
| 229 | * |
| 230 | * DESCRIPTION: Remove the interface from the global interface list. |
| 231 | * Caller MUST hold acpi_gbl_osi_mutex |
| 232 | * |
| 233 | ******************************************************************************/ |
| 234 | |
| 235 | acpi_status acpi_ut_remove_interface(acpi_string interface_name) |
| 236 | { |
| 237 | struct acpi_interface_info *previous_interface; |
| 238 | struct acpi_interface_info *next_interface; |
| 239 | |
| 240 | previous_interface = next_interface = acpi_gbl_supported_interfaces; |
| 241 | while (next_interface) { |
Bob Moore | 4fa4616 | 2015-07-01 14:45:11 +0800 | [diff] [blame] | 242 | if (!strcmp(interface_name, next_interface->name)) { |
Bob Moore | 1fad873 | 2015-12-29 13:54:36 +0800 | [diff] [blame] | 243 | /* |
| 244 | * Found: name is in either the static list |
| 245 | * or was added at runtime |
| 246 | */ |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 247 | if (next_interface->flags & ACPI_OSI_DYNAMIC) { |
| 248 | |
| 249 | /* Interface was added dynamically, remove and free it */ |
| 250 | |
| 251 | if (previous_interface == next_interface) { |
| 252 | acpi_gbl_supported_interfaces = |
| 253 | next_interface->next; |
| 254 | } else { |
| 255 | previous_interface->next = |
| 256 | next_interface->next; |
| 257 | } |
| 258 | |
| 259 | ACPI_FREE(next_interface->name); |
| 260 | ACPI_FREE(next_interface); |
| 261 | } else { |
| 262 | /* |
Bob Moore | 1fad873 | 2015-12-29 13:54:36 +0800 | [diff] [blame] | 263 | * Interface is in static list. If marked invalid, then |
| 264 | * it does not actually exist. Else, mark it invalid. |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 265 | */ |
| 266 | if (next_interface->flags & ACPI_OSI_INVALID) { |
| 267 | return (AE_NOT_EXIST); |
| 268 | } |
| 269 | |
| 270 | next_interface->flags |= ACPI_OSI_INVALID; |
| 271 | } |
| 272 | |
| 273 | return (AE_OK); |
| 274 | } |
| 275 | |
| 276 | previous_interface = next_interface; |
| 277 | next_interface = next_interface->next; |
| 278 | } |
| 279 | |
| 280 | /* Interface was not found */ |
| 281 | |
| 282 | return (AE_NOT_EXIST); |
| 283 | } |
| 284 | |
| 285 | /******************************************************************************* |
| 286 | * |
Lv Zheng | 2cf9f5b | 2013-07-22 16:08:16 +0800 | [diff] [blame] | 287 | * FUNCTION: acpi_ut_update_interfaces |
| 288 | * |
| 289 | * PARAMETERS: action - Actions to be performed during the |
| 290 | * update |
| 291 | * |
| 292 | * RETURN: Status |
| 293 | * |
| 294 | * DESCRIPTION: Update _OSI interface strings, disabling or enabling OS vendor |
| 295 | * strings or/and feature group strings. |
| 296 | * Caller MUST hold acpi_gbl_osi_mutex |
| 297 | * |
| 298 | ******************************************************************************/ |
| 299 | |
| 300 | acpi_status acpi_ut_update_interfaces(u8 action) |
| 301 | { |
| 302 | struct acpi_interface_info *next_interface; |
| 303 | |
| 304 | next_interface = acpi_gbl_supported_interfaces; |
| 305 | while (next_interface) { |
| 306 | if (((next_interface->flags & ACPI_OSI_FEATURE) && |
| 307 | (action & ACPI_FEATURE_STRINGS)) || |
| 308 | (!(next_interface->flags & ACPI_OSI_FEATURE) && |
| 309 | (action & ACPI_VENDOR_STRINGS))) { |
| 310 | if (action & ACPI_DISABLE_INTERFACES) { |
| 311 | |
| 312 | /* Mark the interfaces as invalid */ |
| 313 | |
| 314 | next_interface->flags |= ACPI_OSI_INVALID; |
| 315 | } else { |
| 316 | /* Mark the interfaces as valid */ |
| 317 | |
| 318 | next_interface->flags &= ~ACPI_OSI_INVALID; |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | next_interface = next_interface->next; |
| 323 | } |
| 324 | |
| 325 | return (AE_OK); |
| 326 | } |
| 327 | |
| 328 | /******************************************************************************* |
| 329 | * |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 330 | * FUNCTION: acpi_ut_get_interface |
| 331 | * |
| 332 | * PARAMETERS: interface_name - The interface to find |
| 333 | * |
| 334 | * RETURN: struct acpi_interface_info if found. NULL if not found. |
| 335 | * |
| 336 | * DESCRIPTION: Search for the specified interface name in the global list. |
| 337 | * Caller MUST hold acpi_gbl_osi_mutex |
| 338 | * |
| 339 | ******************************************************************************/ |
| 340 | |
| 341 | struct acpi_interface_info *acpi_ut_get_interface(acpi_string interface_name) |
| 342 | { |
| 343 | struct acpi_interface_info *next_interface; |
| 344 | |
| 345 | next_interface = acpi_gbl_supported_interfaces; |
| 346 | while (next_interface) { |
Bob Moore | 4fa4616 | 2015-07-01 14:45:11 +0800 | [diff] [blame] | 347 | if (!strcmp(interface_name, next_interface->name)) { |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 348 | return (next_interface); |
| 349 | } |
| 350 | |
| 351 | next_interface = next_interface->next; |
| 352 | } |
| 353 | |
| 354 | return (NULL); |
| 355 | } |
| 356 | |
| 357 | /******************************************************************************* |
| 358 | * |
| 359 | * FUNCTION: acpi_ut_osi_implementation |
| 360 | * |
| 361 | * PARAMETERS: walk_state - Current walk state |
| 362 | * |
| 363 | * RETURN: Status |
Bob Moore | 955f485 | 2016-09-07 14:06:47 +0800 | [diff] [blame] | 364 | * Integer: TRUE (0) if input string is matched |
| 365 | * FALSE (-1) if string is not matched |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 366 | * |
| 367 | * DESCRIPTION: Implementation of the _OSI predefined control method. When |
| 368 | * an invocation of _OSI is encountered in the system AML, |
| 369 | * control is transferred to this function. |
| 370 | * |
Bob Moore | 955f485 | 2016-09-07 14:06:47 +0800 | [diff] [blame] | 371 | * (August 2016) |
| 372 | * Note: _OSI is now defined to return "Ones" to indicate a match, for |
| 373 | * compatibility with other ACPI implementations. On a 32-bit DSDT, Ones |
| 374 | * is 0xFFFFFFFF. On a 64-bit DSDT, Ones is 0xFFFFFFFFFFFFFFFF |
| 375 | * (ACPI_UINT64_MAX). |
| 376 | * |
| 377 | * This function always returns ACPI_UINT64_MAX for TRUE, and later code |
| 378 | * will truncate this to 32 bits if necessary. |
| 379 | * |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 380 | ******************************************************************************/ |
| 381 | |
Lv Zheng | f5c1e1c | 2016-05-05 12:57:53 +0800 | [diff] [blame] | 382 | acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state) |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 383 | { |
| 384 | union acpi_operand_object *string_desc; |
| 385 | union acpi_operand_object *return_desc; |
| 386 | struct acpi_interface_info *interface_info; |
| 387 | acpi_interface_handler interface_handler; |
Jung-uk Kim | 388a990 | 2013-04-12 00:24:34 +0000 | [diff] [blame] | 388 | acpi_status status; |
Bob Moore | 955f485 | 2016-09-07 14:06:47 +0800 | [diff] [blame] | 389 | u64 return_value; |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 390 | |
| 391 | ACPI_FUNCTION_TRACE(ut_osi_implementation); |
| 392 | |
| 393 | /* Validate the string input argument (from the AML caller) */ |
| 394 | |
| 395 | string_desc = walk_state->arguments[0].object; |
| 396 | if (!string_desc || (string_desc->common.type != ACPI_TYPE_STRING)) { |
| 397 | return_ACPI_STATUS(AE_TYPE); |
| 398 | } |
| 399 | |
| 400 | /* Create a return object */ |
| 401 | |
| 402 | return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); |
| 403 | if (!return_desc) { |
| 404 | return_ACPI_STATUS(AE_NO_MEMORY); |
| 405 | } |
| 406 | |
| 407 | /* Default return value is 0, NOT SUPPORTED */ |
| 408 | |
| 409 | return_value = 0; |
Jung-uk Kim | 388a990 | 2013-04-12 00:24:34 +0000 | [diff] [blame] | 410 | status = acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER); |
| 411 | if (ACPI_FAILURE(status)) { |
Jung-uk Kim | 3aa2eea | 2013-05-08 04:01:49 +0000 | [diff] [blame] | 412 | acpi_ut_remove_reference(return_desc); |
| 413 | return_ACPI_STATUS(status); |
Jung-uk Kim | 388a990 | 2013-04-12 00:24:34 +0000 | [diff] [blame] | 414 | } |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 415 | |
| 416 | /* Lookup the interface in the global _OSI list */ |
| 417 | |
| 418 | interface_info = acpi_ut_get_interface(string_desc->string.pointer); |
| 419 | if (interface_info && !(interface_info->flags & ACPI_OSI_INVALID)) { |
| 420 | /* |
| 421 | * The interface is supported. |
| 422 | * Update the osi_data if necessary. We keep track of the latest |
| 423 | * version of Windows that has been requested by the BIOS. |
| 424 | */ |
| 425 | if (interface_info->value > acpi_gbl_osi_data) { |
| 426 | acpi_gbl_osi_data = interface_info->value; |
| 427 | } |
| 428 | |
Bob Moore | 955f485 | 2016-09-07 14:06:47 +0800 | [diff] [blame] | 429 | return_value = ACPI_UINT64_MAX; |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 430 | } |
| 431 | |
| 432 | acpi_os_release_mutex(acpi_gbl_osi_mutex); |
| 433 | |
| 434 | /* |
| 435 | * Invoke an optional _OSI interface handler. The host OS may wish |
| 436 | * to do some interface-specific handling. For example, warn about |
| 437 | * certain interfaces or override the true/false support value. |
| 438 | */ |
| 439 | interface_handler = acpi_gbl_interface_handler; |
| 440 | if (interface_handler) { |
Bob Moore | 955f485 | 2016-09-07 14:06:47 +0800 | [diff] [blame] | 441 | if (interface_handler |
| 442 | (string_desc->string.pointer, (u32)return_value)) { |
| 443 | return_value = ACPI_UINT64_MAX; |
| 444 | } |
Lin Ming | b0ed7a9 | 2010-08-06 09:35:51 +0800 | [diff] [blame] | 445 | } |
| 446 | |
| 447 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_INFO, |
| 448 | "ACPI: BIOS _OSI(\"%s\") is %ssupported\n", |
| 449 | string_desc->string.pointer, |
| 450 | return_value == 0 ? "not " : "")); |
| 451 | |
| 452 | /* Complete the return object */ |
| 453 | |
| 454 | return_desc->integer.value = return_value; |
| 455 | walk_state->return_desc = return_desc; |
| 456 | return_ACPI_STATUS(AE_OK); |
| 457 | } |