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