blob: 0809d73193e1906dbc75583b8ba5be44615f461e [file] [log] [blame]
Lin Mingb0ed7a92010-08-06 09:35:51 +08001/******************************************************************************
2 *
3 * Module Name: utosi - Support for the _OSI predefined control method
4 *
5 *****************************************************************************/
6
7/*
David E. Box82a80942015-02-05 15:20:45 +08008 * Copyright (C) 2000 - 2015, Intel Corp.
Lin Mingb0ed7a92010-08-06 09:35:51 +08009 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include "accommon.h"
46
47#define _COMPONENT ACPI_UTILITIES
48ACPI_MODULE_NAME("utosi")
49
Bob Moore73581c02014-02-26 10:33:18 +080050/******************************************************************************
51 *
52 * ACPICA policy for new _OSI strings:
53 *
54 * It is the stated policy of ACPICA that new _OSI strings will be integrated
55 * into this module as soon as possible after they are defined. It is strongly
56 * recommended that all ACPICA hosts mirror this policy and integrate any
57 * changes to this module as soon as possible. There are several historical
58 * reasons behind this policy:
59 *
60 * 1) New BIOSs tend to test only the case where the host responds TRUE to
61 * the latest version of Windows, which would respond to the latest/newest
62 * _OSI string. Not responding TRUE to the latest version of Windows will
63 * risk executing untested code paths throughout the DSDT and SSDTs.
64 *
65 * 2) If a new _OSI string is recognized only after a significant delay, this
66 * has the potential to cause problems on existing working machines because
67 * of the possibility that a new and different path through the ASL code
68 * will be executed.
69 *
70 * 3) New _OSI strings are tending to come out about once per year. A delay
71 * in recognizing a new string for a significant amount of time risks the
72 * release of another string which only compounds the initial problem.
73 *
74 *****************************************************************************/
Lin Mingb0ed7a92010-08-06 09:35:51 +080075/*
76 * Strings supported by the _OSI predefined control method (which is
77 * implemented internally within this module.)
78 *
79 * March 2009: Removed "Linux" as this host no longer wants to respond true
80 * for this string. Basically, the only safe OS strings are windows-related
81 * and in many or most cases represent the only test path within the
82 * BIOS-provided ASL code.
83 *
84 * The last element of each entry is used to track the newest version of
85 * Windows that the BIOS has requested.
86 */
87static struct acpi_interface_info acpi_default_supported_interfaces[] = {
88 /* Operating System Vendor Strings */
89
90 {"Windows 2000", NULL, 0, ACPI_OSI_WIN_2000}, /* Windows 2000 */
91 {"Windows 2001", NULL, 0, ACPI_OSI_WIN_XP}, /* Windows XP */
92 {"Windows 2001 SP1", NULL, 0, ACPI_OSI_WIN_XP_SP1}, /* Windows XP SP1 */
93 {"Windows 2001.1", NULL, 0, ACPI_OSI_WINSRV_2003}, /* Windows Server 2003 */
94 {"Windows 2001 SP2", NULL, 0, ACPI_OSI_WIN_XP_SP2}, /* Windows XP SP2 */
95 {"Windows 2001.1 SP1", NULL, 0, ACPI_OSI_WINSRV_2003_SP1}, /* Windows Server 2003 SP1 - Added 03/2006 */
Bob Mooreba494be2012-07-12 09:40:10 +080096 {"Windows 2006", NULL, 0, ACPI_OSI_WIN_VISTA}, /* Windows vista - Added 03/2006 */
Lin Mingb0ed7a92010-08-06 09:35:51 +080097 {"Windows 2006.1", NULL, 0, ACPI_OSI_WINSRV_2008}, /* Windows Server 2008 - Added 09/2009 */
98 {"Windows 2006 SP1", NULL, 0, ACPI_OSI_WIN_VISTA_SP1}, /* Windows Vista SP1 - Added 09/2009 */
Bob Moore23ebbf02010-10-18 08:50:47 +080099 {"Windows 2006 SP2", NULL, 0, ACPI_OSI_WIN_VISTA_SP2}, /* Windows Vista SP2 - Added 09/2010 */
Lin Mingb0ed7a92010-08-06 09:35:51 +0800100 {"Windows 2009", NULL, 0, ACPI_OSI_WIN_7}, /* Windows 7 and Server 2008 R2 - Added 09/2009 */
Bob Moorea57f7f92012-08-17 10:55:02 +0800101 {"Windows 2012", NULL, 0, ACPI_OSI_WIN_8}, /* Windows 8 and Server 2012 - Added 08/2012 */
Bob Moorefaae4042014-02-11 10:25:27 +0800102 {"Windows 2013", NULL, 0, ACPI_OSI_WIN_8}, /* Windows 8.1 and Server 2012 R2 - Added 01/2014 */
Bob Moore796888e2015-04-13 11:50:37 +0800103 {"Windows 2015", NULL, 0, ACPI_OSI_WIN_10}, /* Windows 10 - Added 03/2015 */
Lin Mingb0ed7a92010-08-06 09:35:51 +0800104
105 /* Feature Group Strings */
106
Lv Zheng2cf9f5b2013-07-22 16:08:16 +0800107 {"Extended Address Space Descriptor", NULL, ACPI_OSI_FEATURE, 0},
Lin Mingb0ed7a92010-08-06 09:35:51 +0800108
109 /*
110 * All "optional" feature group strings (features that are implemented
Lv Zheng2cf9f5b2013-07-22 16:08:16 +0800111 * by the host) should be dynamically modified to VALID by the host via
112 * acpi_install_interface or acpi_update_interfaces. Such optional feature
113 * group strings are set as INVALID by default here.
Lin Mingb0ed7a92010-08-06 09:35:51 +0800114 */
Lv Zheng2cf9f5b2013-07-22 16:08:16 +0800115
116 {"Module Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
117 {"Processor Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
118 {"3.0 Thermal Model", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
119 {"3.0 _SCP Extensions", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
120 {"Processor Aggregator Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0}
Lin Mingb0ed7a92010-08-06 09:35:51 +0800121};
122
123/*******************************************************************************
124 *
125 * FUNCTION: acpi_ut_initialize_interfaces
126 *
127 * PARAMETERS: None
128 *
129 * RETURN: Status
130 *
131 * DESCRIPTION: Initialize the global _OSI supported interfaces list
132 *
133 ******************************************************************************/
134
135acpi_status acpi_ut_initialize_interfaces(void)
136{
Jung-uk Kim388a9902013-04-12 00:24:34 +0000137 acpi_status status;
Lin Mingb0ed7a92010-08-06 09:35:51 +0800138 u32 i;
139
Jung-uk Kim388a9902013-04-12 00:24:34 +0000140 status = acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER);
141 if (ACPI_FAILURE(status)) {
142 return (status);
143 }
144
Lin Mingb0ed7a92010-08-06 09:35:51 +0800145 acpi_gbl_supported_interfaces = acpi_default_supported_interfaces;
146
147 /* Link the static list of supported interfaces */
148
149 for (i = 0;
150 i < (ACPI_ARRAY_LENGTH(acpi_default_supported_interfaces) - 1);
151 i++) {
152 acpi_default_supported_interfaces[i].next =
153 &acpi_default_supported_interfaces[(acpi_size) i + 1];
154 }
155
156 acpi_os_release_mutex(acpi_gbl_osi_mutex);
157 return (AE_OK);
158}
159
160/*******************************************************************************
161 *
162 * FUNCTION: acpi_ut_interface_terminate
163 *
164 * PARAMETERS: None
165 *
Jung-uk Kim388a9902013-04-12 00:24:34 +0000166 * RETURN: Status
Lin Mingb0ed7a92010-08-06 09:35:51 +0800167 *
168 * DESCRIPTION: Delete all interfaces in the global list. Sets
169 * acpi_gbl_supported_interfaces to NULL.
170 *
171 ******************************************************************************/
172
Jung-uk Kim388a9902013-04-12 00:24:34 +0000173acpi_status acpi_ut_interface_terminate(void)
Lin Mingb0ed7a92010-08-06 09:35:51 +0800174{
Jung-uk Kim388a9902013-04-12 00:24:34 +0000175 acpi_status status;
Lin Mingb0ed7a92010-08-06 09:35:51 +0800176 struct acpi_interface_info *next_interface;
177
Jung-uk Kim388a9902013-04-12 00:24:34 +0000178 status = acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER);
179 if (ACPI_FAILURE(status)) {
180 return (status);
181 }
Lin Mingb0ed7a92010-08-06 09:35:51 +0800182
Jung-uk Kim388a9902013-04-12 00:24:34 +0000183 next_interface = acpi_gbl_supported_interfaces;
Lin Mingb0ed7a92010-08-06 09:35:51 +0800184 while (next_interface) {
185 acpi_gbl_supported_interfaces = next_interface->next;
186
Lin Mingb0ed7a92010-08-06 09:35:51 +0800187 if (next_interface->flags & ACPI_OSI_DYNAMIC) {
Lv Zheng2cf9f5b2013-07-22 16:08:16 +0800188
189 /* Only interfaces added at runtime can be freed */
190
Lin Mingb0ed7a92010-08-06 09:35:51 +0800191 ACPI_FREE(next_interface->name);
192 ACPI_FREE(next_interface);
Lv Zheng2cf9f5b2013-07-22 16:08:16 +0800193 } else {
194 /* Interface is in static list. Reset it to invalid or valid. */
195
196 if (next_interface->flags & ACPI_OSI_DEFAULT_INVALID) {
197 next_interface->flags |= ACPI_OSI_INVALID;
198 } else {
199 next_interface->flags &= ~ACPI_OSI_INVALID;
200 }
Lin Mingb0ed7a92010-08-06 09:35:51 +0800201 }
202
203 next_interface = acpi_gbl_supported_interfaces;
204 }
205
206 acpi_os_release_mutex(acpi_gbl_osi_mutex);
Jung-uk Kim388a9902013-04-12 00:24:34 +0000207 return (AE_OK);
Lin Mingb0ed7a92010-08-06 09:35:51 +0800208}
209
210/*******************************************************************************
211 *
212 * FUNCTION: acpi_ut_install_interface
213 *
214 * PARAMETERS: interface_name - The interface to install
215 *
216 * RETURN: Status
217 *
218 * DESCRIPTION: Install the interface into the global interface list.
219 * Caller MUST hold acpi_gbl_osi_mutex
220 *
221 ******************************************************************************/
222
223acpi_status acpi_ut_install_interface(acpi_string interface_name)
224{
225 struct acpi_interface_info *interface_info;
226
227 /* Allocate info block and space for the name string */
228
229 interface_info =
230 ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_interface_info));
231 if (!interface_info) {
232 return (AE_NO_MEMORY);
233 }
234
Bob Moore4fa46162015-07-01 14:45:11 +0800235 interface_info->name = ACPI_ALLOCATE_ZEROED(strlen(interface_name) + 1);
Lin Mingb0ed7a92010-08-06 09:35:51 +0800236 if (!interface_info->name) {
237 ACPI_FREE(interface_info);
238 return (AE_NO_MEMORY);
239 }
240
241 /* Initialize new info and insert at the head of the global list */
242
Bob Moore4fa46162015-07-01 14:45:11 +0800243 strcpy(interface_info->name, interface_name);
Lin Mingb0ed7a92010-08-06 09:35:51 +0800244 interface_info->flags = ACPI_OSI_DYNAMIC;
245 interface_info->next = acpi_gbl_supported_interfaces;
246
247 acpi_gbl_supported_interfaces = interface_info;
248 return (AE_OK);
249}
250
251/*******************************************************************************
252 *
253 * FUNCTION: acpi_ut_remove_interface
254 *
255 * PARAMETERS: interface_name - The interface to remove
256 *
257 * RETURN: Status
258 *
259 * DESCRIPTION: Remove the interface from the global interface list.
260 * Caller MUST hold acpi_gbl_osi_mutex
261 *
262 ******************************************************************************/
263
264acpi_status acpi_ut_remove_interface(acpi_string interface_name)
265{
266 struct acpi_interface_info *previous_interface;
267 struct acpi_interface_info *next_interface;
268
269 previous_interface = next_interface = acpi_gbl_supported_interfaces;
270 while (next_interface) {
Bob Moore4fa46162015-07-01 14:45:11 +0800271 if (!strcmp(interface_name, next_interface->name)) {
Bob Moore1fad8732015-12-29 13:54:36 +0800272 /*
273 * Found: name is in either the static list
274 * or was added at runtime
275 */
Lin Mingb0ed7a92010-08-06 09:35:51 +0800276 if (next_interface->flags & ACPI_OSI_DYNAMIC) {
277
278 /* Interface was added dynamically, remove and free it */
279
280 if (previous_interface == next_interface) {
281 acpi_gbl_supported_interfaces =
282 next_interface->next;
283 } else {
284 previous_interface->next =
285 next_interface->next;
286 }
287
288 ACPI_FREE(next_interface->name);
289 ACPI_FREE(next_interface);
290 } else {
291 /*
Bob Moore1fad8732015-12-29 13:54:36 +0800292 * Interface is in static list. If marked invalid, then
293 * it does not actually exist. Else, mark it invalid.
Lin Mingb0ed7a92010-08-06 09:35:51 +0800294 */
295 if (next_interface->flags & ACPI_OSI_INVALID) {
296 return (AE_NOT_EXIST);
297 }
298
299 next_interface->flags |= ACPI_OSI_INVALID;
300 }
301
302 return (AE_OK);
303 }
304
305 previous_interface = next_interface;
306 next_interface = next_interface->next;
307 }
308
309 /* Interface was not found */
310
311 return (AE_NOT_EXIST);
312}
313
314/*******************************************************************************
315 *
Lv Zheng2cf9f5b2013-07-22 16:08:16 +0800316 * FUNCTION: acpi_ut_update_interfaces
317 *
318 * PARAMETERS: action - Actions to be performed during the
319 * update
320 *
321 * RETURN: Status
322 *
323 * DESCRIPTION: Update _OSI interface strings, disabling or enabling OS vendor
324 * strings or/and feature group strings.
325 * Caller MUST hold acpi_gbl_osi_mutex
326 *
327 ******************************************************************************/
328
329acpi_status acpi_ut_update_interfaces(u8 action)
330{
331 struct acpi_interface_info *next_interface;
332
333 next_interface = acpi_gbl_supported_interfaces;
334 while (next_interface) {
335 if (((next_interface->flags & ACPI_OSI_FEATURE) &&
336 (action & ACPI_FEATURE_STRINGS)) ||
337 (!(next_interface->flags & ACPI_OSI_FEATURE) &&
338 (action & ACPI_VENDOR_STRINGS))) {
339 if (action & ACPI_DISABLE_INTERFACES) {
340
341 /* Mark the interfaces as invalid */
342
343 next_interface->flags |= ACPI_OSI_INVALID;
344 } else {
345 /* Mark the interfaces as valid */
346
347 next_interface->flags &= ~ACPI_OSI_INVALID;
348 }
349 }
350
351 next_interface = next_interface->next;
352 }
353
354 return (AE_OK);
355}
356
357/*******************************************************************************
358 *
Lin Mingb0ed7a92010-08-06 09:35:51 +0800359 * FUNCTION: acpi_ut_get_interface
360 *
361 * PARAMETERS: interface_name - The interface to find
362 *
363 * RETURN: struct acpi_interface_info if found. NULL if not found.
364 *
365 * DESCRIPTION: Search for the specified interface name in the global list.
366 * Caller MUST hold acpi_gbl_osi_mutex
367 *
368 ******************************************************************************/
369
370struct acpi_interface_info *acpi_ut_get_interface(acpi_string interface_name)
371{
372 struct acpi_interface_info *next_interface;
373
374 next_interface = acpi_gbl_supported_interfaces;
375 while (next_interface) {
Bob Moore4fa46162015-07-01 14:45:11 +0800376 if (!strcmp(interface_name, next_interface->name)) {
Lin Mingb0ed7a92010-08-06 09:35:51 +0800377 return (next_interface);
378 }
379
380 next_interface = next_interface->next;
381 }
382
383 return (NULL);
384}
385
386/*******************************************************************************
387 *
388 * FUNCTION: acpi_ut_osi_implementation
389 *
390 * PARAMETERS: walk_state - Current walk state
391 *
392 * RETURN: Status
393 *
394 * DESCRIPTION: Implementation of the _OSI predefined control method. When
395 * an invocation of _OSI is encountered in the system AML,
396 * control is transferred to this function.
397 *
398 ******************************************************************************/
399
400acpi_status acpi_ut_osi_implementation(struct acpi_walk_state * walk_state)
401{
402 union acpi_operand_object *string_desc;
403 union acpi_operand_object *return_desc;
404 struct acpi_interface_info *interface_info;
405 acpi_interface_handler interface_handler;
Jung-uk Kim388a9902013-04-12 00:24:34 +0000406 acpi_status status;
Lin Mingb0ed7a92010-08-06 09:35:51 +0800407 u32 return_value;
408
409 ACPI_FUNCTION_TRACE(ut_osi_implementation);
410
411 /* Validate the string input argument (from the AML caller) */
412
413 string_desc = walk_state->arguments[0].object;
414 if (!string_desc || (string_desc->common.type != ACPI_TYPE_STRING)) {
415 return_ACPI_STATUS(AE_TYPE);
416 }
417
418 /* Create a return object */
419
420 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
421 if (!return_desc) {
422 return_ACPI_STATUS(AE_NO_MEMORY);
423 }
424
425 /* Default return value is 0, NOT SUPPORTED */
426
427 return_value = 0;
Jung-uk Kim388a9902013-04-12 00:24:34 +0000428 status = acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER);
429 if (ACPI_FAILURE(status)) {
Jung-uk Kim3aa2eea2013-05-08 04:01:49 +0000430 acpi_ut_remove_reference(return_desc);
431 return_ACPI_STATUS(status);
Jung-uk Kim388a9902013-04-12 00:24:34 +0000432 }
Lin Mingb0ed7a92010-08-06 09:35:51 +0800433
434 /* Lookup the interface in the global _OSI list */
435
436 interface_info = acpi_ut_get_interface(string_desc->string.pointer);
437 if (interface_info && !(interface_info->flags & ACPI_OSI_INVALID)) {
438 /*
439 * The interface is supported.
440 * Update the osi_data if necessary. We keep track of the latest
441 * version of Windows that has been requested by the BIOS.
442 */
443 if (interface_info->value > acpi_gbl_osi_data) {
444 acpi_gbl_osi_data = interface_info->value;
445 }
446
447 return_value = ACPI_UINT32_MAX;
448 }
449
450 acpi_os_release_mutex(acpi_gbl_osi_mutex);
451
452 /*
453 * Invoke an optional _OSI interface handler. The host OS may wish
454 * to do some interface-specific handling. For example, warn about
455 * certain interfaces or override the true/false support value.
456 */
457 interface_handler = acpi_gbl_interface_handler;
458 if (interface_handler) {
459 return_value =
460 interface_handler(string_desc->string.pointer,
461 return_value);
462 }
463
464 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INFO,
465 "ACPI: BIOS _OSI(\"%s\") is %ssupported\n",
466 string_desc->string.pointer,
467 return_value == 0 ? "not " : ""));
468
469 /* Complete the return object */
470
471 return_desc->integer.value = return_value;
472 walk_state->return_desc = return_desc;
473 return_ACPI_STATUS(AE_OK);
474}