diff options
author | Lin Ming <ming.m.lin@intel.com> | 2010-08-05 21:35:51 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2010-10-01 01:47:43 -0400 |
commit | b0ed7a915abac309fcb5a51bccd3782e3daa7417 (patch) | |
tree | 0bffdd098549d61180e6959217c84a05dadb99fa /drivers/acpi/acpica/utosi.c | |
parent | 09387b43153953006471dbb06ece6bf779d10937 (diff) |
ACPICA/ACPI: Add new host interfaces for _OSI support
Adds install/remove interfaces so that the host can dynamically
alter the global _OSI table. Also adds support for _OSI handlers.
Additional support: new debugger command (osi), and test support in
the acpiexec utility. Adds new file, utilities/utosi.c.
ACPICA bugzilla 836.
The Linux OSL _OSI code is also changed.
acpi_osi_setup can't call acpi_install/remove_interface because ACPICA
is not initialized yet at this early time.
So we just save the osi string in acpi_osi_setup and will handle it
later in a new function acpi_osi_setup_late.
http://www.acpica.org/bugzilla/show_bug.cgi?id=836
Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/acpica/utosi.c')
-rw-r--r-- | drivers/acpi/acpica/utosi.c | 379 |
1 files changed, 379 insertions, 0 deletions
diff --git a/drivers/acpi/acpica/utosi.c b/drivers/acpi/acpica/utosi.c new file mode 100644 index 000000000000..0a37950c96aa --- /dev/null +++ b/drivers/acpi/acpica/utosi.c | |||
@@ -0,0 +1,379 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: utosi - Support for the _OSI predefined control method | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2010, 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 | ||
48 | ACPI_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 | */ | ||
62 | static 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 2009", NULL, 0, ACPI_OSI_WIN_7}, /* Windows 7 and Server 2008 R2 - Added 09/2009 */ | ||
75 | |||
76 | /* Feature Group Strings */ | ||
77 | |||
78 | {"Extended Address Space Descriptor", NULL, 0, 0} | ||
79 | |||
80 | /* | ||
81 | * All "optional" feature group strings (features that are implemented | ||
82 | * by the host) should be dynamically added by the host via | ||
83 | * acpi_install_interface and should not be manually added here. | ||
84 | * | ||
85 | * Examples of optional feature group strings: | ||
86 | * | ||
87 | * "Module Device" | ||
88 | * "Processor Device" | ||
89 | * "3.0 Thermal Model" | ||
90 | * "3.0 _SCP Extensions" | ||
91 | * "Processor Aggregator Device" | ||
92 | */ | ||
93 | }; | ||
94 | |||
95 | /******************************************************************************* | ||
96 | * | ||
97 | * FUNCTION: acpi_ut_initialize_interfaces | ||
98 | * | ||
99 | * PARAMETERS: None | ||
100 | * | ||
101 | * RETURN: Status | ||
102 | * | ||
103 | * DESCRIPTION: Initialize the global _OSI supported interfaces list | ||
104 | * | ||
105 | ******************************************************************************/ | ||
106 | |||
107 | acpi_status acpi_ut_initialize_interfaces(void) | ||
108 | { | ||
109 | u32 i; | ||
110 | |||
111 | (void)acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER); | ||
112 | acpi_gbl_supported_interfaces = acpi_default_supported_interfaces; | ||
113 | |||
114 | /* Link the static list of supported interfaces */ | ||
115 | |||
116 | for (i = 0; | ||
117 | i < (ACPI_ARRAY_LENGTH(acpi_default_supported_interfaces) - 1); | ||
118 | i++) { | ||
119 | acpi_default_supported_interfaces[i].next = | ||
120 | &acpi_default_supported_interfaces[(acpi_size) i + 1]; | ||
121 | } | ||
122 | |||
123 | acpi_os_release_mutex(acpi_gbl_osi_mutex); | ||
124 | return (AE_OK); | ||
125 | } | ||
126 | |||
127 | /******************************************************************************* | ||
128 | * | ||
129 | * FUNCTION: acpi_ut_interface_terminate | ||
130 | * | ||
131 | * PARAMETERS: None | ||
132 | * | ||
133 | * RETURN: None | ||
134 | * | ||
135 | * DESCRIPTION: Delete all interfaces in the global list. Sets | ||
136 | * acpi_gbl_supported_interfaces to NULL. | ||
137 | * | ||
138 | ******************************************************************************/ | ||
139 | |||
140 | void acpi_ut_interface_terminate(void) | ||
141 | { | ||
142 | struct acpi_interface_info *next_interface; | ||
143 | |||
144 | (void)acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER); | ||
145 | next_interface = acpi_gbl_supported_interfaces; | ||
146 | |||
147 | while (next_interface) { | ||
148 | acpi_gbl_supported_interfaces = next_interface->next; | ||
149 | |||
150 | /* Only interfaces added at runtime can be freed */ | ||
151 | |||
152 | if (next_interface->flags & ACPI_OSI_DYNAMIC) { | ||
153 | ACPI_FREE(next_interface->name); | ||
154 | ACPI_FREE(next_interface); | ||
155 | } | ||
156 | |||
157 | next_interface = acpi_gbl_supported_interfaces; | ||
158 | } | ||
159 | |||
160 | acpi_os_release_mutex(acpi_gbl_osi_mutex); | ||
161 | } | ||
162 | |||
163 | /******************************************************************************* | ||
164 | * | ||
165 | * FUNCTION: acpi_ut_install_interface | ||
166 | * | ||
167 | * PARAMETERS: interface_name - The interface to install | ||
168 | * | ||
169 | * RETURN: Status | ||
170 | * | ||
171 | * DESCRIPTION: Install the interface into the global interface list. | ||
172 | * Caller MUST hold acpi_gbl_osi_mutex | ||
173 | * | ||
174 | ******************************************************************************/ | ||
175 | |||
176 | acpi_status acpi_ut_install_interface(acpi_string interface_name) | ||
177 | { | ||
178 | struct acpi_interface_info *interface_info; | ||
179 | |||
180 | /* Allocate info block and space for the name string */ | ||
181 | |||
182 | interface_info = | ||
183 | ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_interface_info)); | ||
184 | if (!interface_info) { | ||
185 | return (AE_NO_MEMORY); | ||
186 | } | ||
187 | |||
188 | interface_info->name = | ||
189 | ACPI_ALLOCATE_ZEROED(ACPI_STRLEN(interface_name) + 1); | ||
190 | if (!interface_info->name) { | ||
191 | ACPI_FREE(interface_info); | ||
192 | return (AE_NO_MEMORY); | ||
193 | } | ||
194 | |||
195 | /* Initialize new info and insert at the head of the global list */ | ||
196 | |||
197 | ACPI_STRCPY(interface_info->name, interface_name); | ||
198 | interface_info->flags = ACPI_OSI_DYNAMIC; | ||
199 | interface_info->next = acpi_gbl_supported_interfaces; | ||
200 | |||
201 | acpi_gbl_supported_interfaces = interface_info; | ||
202 | return (AE_OK); | ||
203 | } | ||
204 | |||
205 | /******************************************************************************* | ||
206 | * | ||
207 | * FUNCTION: acpi_ut_remove_interface | ||
208 | * | ||
209 | * PARAMETERS: interface_name - The interface to remove | ||
210 | * | ||
211 | * RETURN: Status | ||
212 | * | ||
213 | * DESCRIPTION: Remove the interface from the global interface list. | ||
214 | * Caller MUST hold acpi_gbl_osi_mutex | ||
215 | * | ||
216 | ******************************************************************************/ | ||
217 | |||
218 | acpi_status acpi_ut_remove_interface(acpi_string interface_name) | ||
219 | { | ||
220 | struct acpi_interface_info *previous_interface; | ||
221 | struct acpi_interface_info *next_interface; | ||
222 | |||
223 | previous_interface = next_interface = acpi_gbl_supported_interfaces; | ||
224 | while (next_interface) { | ||
225 | if (!ACPI_STRCMP(interface_name, next_interface->name)) { | ||
226 | |||
227 | /* Found: name is in either the static list or was added at runtime */ | ||
228 | |||
229 | if (next_interface->flags & ACPI_OSI_DYNAMIC) { | ||
230 | |||
231 | /* Interface was added dynamically, remove and free it */ | ||
232 | |||
233 | if (previous_interface == next_interface) { | ||
234 | acpi_gbl_supported_interfaces = | ||
235 | next_interface->next; | ||
236 | } else { | ||
237 | previous_interface->next = | ||
238 | next_interface->next; | ||
239 | } | ||
240 | |||
241 | ACPI_FREE(next_interface->name); | ||
242 | ACPI_FREE(next_interface); | ||
243 | } else { | ||
244 | /* | ||
245 | * Interface is in static list. If marked invalid, then it | ||
246 | * does not actually exist. Else, mark it invalid. | ||
247 | */ | ||
248 | if (next_interface->flags & ACPI_OSI_INVALID) { | ||
249 | return (AE_NOT_EXIST); | ||
250 | } | ||
251 | |||
252 | next_interface->flags |= ACPI_OSI_INVALID; | ||
253 | } | ||
254 | |||
255 | return (AE_OK); | ||
256 | } | ||
257 | |||
258 | previous_interface = next_interface; | ||
259 | next_interface = next_interface->next; | ||
260 | } | ||
261 | |||
262 | /* Interface was not found */ | ||
263 | |||
264 | return (AE_NOT_EXIST); | ||
265 | } | ||
266 | |||
267 | /******************************************************************************* | ||
268 | * | ||
269 | * FUNCTION: acpi_ut_get_interface | ||
270 | * | ||
271 | * PARAMETERS: interface_name - The interface to find | ||
272 | * | ||
273 | * RETURN: struct acpi_interface_info if found. NULL if not found. | ||
274 | * | ||
275 | * DESCRIPTION: Search for the specified interface name in the global list. | ||
276 | * Caller MUST hold acpi_gbl_osi_mutex | ||
277 | * | ||
278 | ******************************************************************************/ | ||
279 | |||
280 | struct acpi_interface_info *acpi_ut_get_interface(acpi_string interface_name) | ||
281 | { | ||
282 | struct acpi_interface_info *next_interface; | ||
283 | |||
284 | next_interface = acpi_gbl_supported_interfaces; | ||
285 | while (next_interface) { | ||
286 | if (!ACPI_STRCMP(interface_name, next_interface->name)) { | ||
287 | return (next_interface); | ||
288 | } | ||
289 | |||
290 | next_interface = next_interface->next; | ||
291 | } | ||
292 | |||
293 | return (NULL); | ||
294 | } | ||
295 | |||
296 | /******************************************************************************* | ||
297 | * | ||
298 | * FUNCTION: acpi_ut_osi_implementation | ||
299 | * | ||
300 | * PARAMETERS: walk_state - Current walk state | ||
301 | * | ||
302 | * RETURN: Status | ||
303 | * | ||
304 | * DESCRIPTION: Implementation of the _OSI predefined control method. When | ||
305 | * an invocation of _OSI is encountered in the system AML, | ||
306 | * control is transferred to this function. | ||
307 | * | ||
308 | ******************************************************************************/ | ||
309 | |||
310 | acpi_status acpi_ut_osi_implementation(struct acpi_walk_state * walk_state) | ||
311 | { | ||
312 | union acpi_operand_object *string_desc; | ||
313 | union acpi_operand_object *return_desc; | ||
314 | struct acpi_interface_info *interface_info; | ||
315 | acpi_interface_handler interface_handler; | ||
316 | u32 return_value; | ||
317 | |||
318 | ACPI_FUNCTION_TRACE(ut_osi_implementation); | ||
319 | |||
320 | /* Validate the string input argument (from the AML caller) */ | ||
321 | |||
322 | string_desc = walk_state->arguments[0].object; | ||
323 | if (!string_desc || (string_desc->common.type != ACPI_TYPE_STRING)) { | ||
324 | return_ACPI_STATUS(AE_TYPE); | ||
325 | } | ||
326 | |||
327 | /* Create a return object */ | ||
328 | |||
329 | return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); | ||
330 | if (!return_desc) { | ||
331 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
332 | } | ||
333 | |||
334 | /* Default return value is 0, NOT SUPPORTED */ | ||
335 | |||
336 | return_value = 0; | ||
337 | (void)acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER); | ||
338 | |||
339 | /* Lookup the interface in the global _OSI list */ | ||
340 | |||
341 | interface_info = acpi_ut_get_interface(string_desc->string.pointer); | ||
342 | if (interface_info && !(interface_info->flags & ACPI_OSI_INVALID)) { | ||
343 | /* | ||
344 | * The interface is supported. | ||
345 | * Update the osi_data if necessary. We keep track of the latest | ||
346 | * version of Windows that has been requested by the BIOS. | ||
347 | */ | ||
348 | if (interface_info->value > acpi_gbl_osi_data) { | ||
349 | acpi_gbl_osi_data = interface_info->value; | ||
350 | } | ||
351 | |||
352 | return_value = ACPI_UINT32_MAX; | ||
353 | } | ||
354 | |||
355 | acpi_os_release_mutex(acpi_gbl_osi_mutex); | ||
356 | |||
357 | /* | ||
358 | * Invoke an optional _OSI interface handler. The host OS may wish | ||
359 | * to do some interface-specific handling. For example, warn about | ||
360 | * certain interfaces or override the true/false support value. | ||
361 | */ | ||
362 | interface_handler = acpi_gbl_interface_handler; | ||
363 | if (interface_handler) { | ||
364 | return_value = | ||
365 | interface_handler(string_desc->string.pointer, | ||
366 | return_value); | ||
367 | } | ||
368 | |||
369 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_INFO, | ||
370 | "ACPI: BIOS _OSI(\"%s\") is %ssupported\n", | ||
371 | string_desc->string.pointer, | ||
372 | return_value == 0 ? "not " : "")); | ||
373 | |||
374 | /* Complete the return object */ | ||
375 | |||
376 | return_desc->integer.value = return_value; | ||
377 | walk_state->return_desc = return_desc; | ||
378 | return_ACPI_STATUS(AE_OK); | ||
379 | } | ||