Print this page
acpica-unix2-20130823
PANKOVs restructure
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/io/acpica/utilities/utosi.c
+++ new/usr/src/common/acpica/components/utilities/utosi.c
1 1 /******************************************************************************
2 2 *
3 3 * Module Name: utosi - Support for the _OSI predefined control method
4 4 *
5 5 *****************************************************************************/
6 6
7 7 /*
8 - * Copyright (C) 2000 - 2011, Intel Corp.
8 + * Copyright (C) 2000 - 2013, Intel Corp.
9 9 * All rights reserved.
10 10 *
11 11 * Redistribution and use in source and binary forms, with or without
12 12 * modification, are permitted provided that the following conditions
13 13 * are met:
14 14 * 1. Redistributions of source code must retain the above copyright
15 15 * notice, this list of conditions, and the following disclaimer,
16 16 * without modification.
17 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 18 * substantially similar to the "NO WARRANTY" disclaimer below
19 19 * ("Disclaimer") and any redistribution must be conditioned upon
20 20 * including a substantially similar Disclaimer requirement for further
21 21 * binary redistribution.
22 22 * 3. Neither the names of the above-listed copyright holders nor the names
23 23 * of any contributors may be used to endorse or promote products derived
24 24 * from this software without specific prior written permission.
25 25 *
26 26 * Alternatively, this software may be distributed under the terms of the
27 27 * GNU General Public License ("GPL") version 2 as published by the Free
28 28 * Software Foundation.
29 29 *
30 30 * NO WARRANTY
31 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 41 * POSSIBILITY OF SUCH DAMAGES.
42 42 */
43 43
44 44 #define __UTOSI_C__
45 45
46 46 #include "acpi.h"
47 47 #include "accommon.h"
48 48
49 49
50 50 #define _COMPONENT ACPI_UTILITIES
51 51 ACPI_MODULE_NAME ("utosi")
52 52
53 53 /*
54 54 * Strings supported by the _OSI predefined control method (which is
55 55 * implemented internally within this module.)
56 56 *
57 57 * March 2009: Removed "Linux" as this host no longer wants to respond true
58 58 * for this string. Basically, the only safe OS strings are windows-related
59 59 * and in many or most cases represent the only test path within the
60 60 * BIOS-provided ASL code.
61 61 *
62 62 * The last element of each entry is used to track the newest version of
63 63 * Windows that the BIOS has requested.
64 64 */
65 65 static ACPI_INTERFACE_INFO AcpiDefaultSupportedInterfaces[] =
66 66 {
67 67 /* Operating System Vendor Strings */
68 68
69 69 {"Windows 2000", NULL, 0, ACPI_OSI_WIN_2000}, /* Windows 2000 */
↓ open down ↓ |
51 lines elided |
↑ open up ↑ |
70 70 {"Windows 2001", NULL, 0, ACPI_OSI_WIN_XP}, /* Windows XP */
71 71 {"Windows 2001 SP1", NULL, 0, ACPI_OSI_WIN_XP_SP1}, /* Windows XP SP1 */
72 72 {"Windows 2001.1", NULL, 0, ACPI_OSI_WINSRV_2003}, /* Windows Server 2003 */
73 73 {"Windows 2001 SP2", NULL, 0, ACPI_OSI_WIN_XP_SP2}, /* Windows XP SP2 */
74 74 {"Windows 2001.1 SP1", NULL, 0, ACPI_OSI_WINSRV_2003_SP1}, /* Windows Server 2003 SP1 - Added 03/2006 */
75 75 {"Windows 2006", NULL, 0, ACPI_OSI_WIN_VISTA}, /* Windows Vista - Added 03/2006 */
76 76 {"Windows 2006.1", NULL, 0, ACPI_OSI_WINSRV_2008}, /* Windows Server 2008 - Added 09/2009 */
77 77 {"Windows 2006 SP1", NULL, 0, ACPI_OSI_WIN_VISTA_SP1}, /* Windows Vista SP1 - Added 09/2009 */
78 78 {"Windows 2006 SP2", NULL, 0, ACPI_OSI_WIN_VISTA_SP2}, /* Windows Vista SP2 - Added 09/2010 */
79 79 {"Windows 2009", NULL, 0, ACPI_OSI_WIN_7}, /* Windows 7 and Server 2008 R2 - Added 09/2009 */
80 + {"Windows 2012", NULL, 0, ACPI_OSI_WIN_8}, /* Windows 8 and Server 2012 - Added 08/2012 */
80 81
81 82 /* Feature Group Strings */
82 83
83 - {"Extended Address Space Descriptor", NULL, 0, 0}
84 + {"Extended Address Space Descriptor", NULL, ACPI_OSI_FEATURE, 0},
84 85
85 86 /*
86 87 * All "optional" feature group strings (features that are implemented
87 - * by the host) should be dynamically added by the host via
88 - * AcpiInstallInterface and should not be manually added here.
89 - *
90 - * Examples of optional feature group strings:
91 - *
92 - * "Module Device"
93 - * "Processor Device"
94 - * "3.0 Thermal Model"
95 - * "3.0 _SCP Extensions"
96 - * "Processor Aggregator Device"
88 + * by the host) should be dynamically modified to VALID by the host via
89 + * AcpiInstallInterface or AcpiUpdateInterfaces. Such optional feature
90 + * group strings are set as INVALID by default here.
97 91 */
92 +
93 + {"Module Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
94 + {"Processor Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
95 + {"3.0 Thermal Model", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
96 + {"3.0 _SCP Extensions", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
97 + {"Processor Aggregator Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0}
98 98 };
99 99
100 100
101 101 /*******************************************************************************
102 102 *
103 103 * FUNCTION: AcpiUtInitializeInterfaces
104 104 *
105 105 * PARAMETERS: None
106 106 *
107 107 * RETURN: Status
108 108 *
109 109 * DESCRIPTION: Initialize the global _OSI supported interfaces list
110 110 *
111 111 ******************************************************************************/
112 112
113 113 ACPI_STATUS
114 114 AcpiUtInitializeInterfaces (
115 115 void)
116 116 {
117 + ACPI_STATUS Status;
117 118 UINT32 i;
118 119
119 120
120 - (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
121 + Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
122 + if (ACPI_FAILURE (Status))
123 + {
124 + return (Status);
125 + }
126 +
121 127 AcpiGbl_SupportedInterfaces = AcpiDefaultSupportedInterfaces;
122 128
123 129 /* Link the static list of supported interfaces */
124 130
125 131 for (i = 0; i < (ACPI_ARRAY_LENGTH (AcpiDefaultSupportedInterfaces) - 1); i++)
126 132 {
127 133 AcpiDefaultSupportedInterfaces[i].Next =
128 134 &AcpiDefaultSupportedInterfaces[(ACPI_SIZE) i + 1];
129 135 }
130 136
131 137 AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
↓ open down ↓ |
1 lines elided |
↑ open up ↑ |
132 138 return (AE_OK);
133 139 }
134 140
135 141
136 142 /*******************************************************************************
137 143 *
138 144 * FUNCTION: AcpiUtInterfaceTerminate
139 145 *
140 146 * PARAMETERS: None
141 147 *
142 - * RETURN: None
148 + * RETURN: Status
143 149 *
144 150 * DESCRIPTION: Delete all interfaces in the global list. Sets
145 151 * AcpiGbl_SupportedInterfaces to NULL.
146 152 *
147 153 ******************************************************************************/
148 154
149 -void
155 +ACPI_STATUS
150 156 AcpiUtInterfaceTerminate (
151 157 void)
152 158 {
159 + ACPI_STATUS Status;
153 160 ACPI_INTERFACE_INFO *NextInterface;
154 161
155 162
156 - (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
157 - NextInterface = AcpiGbl_SupportedInterfaces;
163 + Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
164 + if (ACPI_FAILURE (Status))
165 + {
166 + return (Status);
167 + }
158 168
169 + NextInterface = AcpiGbl_SupportedInterfaces;
159 170 while (NextInterface)
160 171 {
161 172 AcpiGbl_SupportedInterfaces = NextInterface->Next;
162 173
163 - /* Only interfaces added at runtime can be freed */
164 -
165 174 if (NextInterface->Flags & ACPI_OSI_DYNAMIC)
166 175 {
176 + /* Only interfaces added at runtime can be freed */
177 +
167 178 ACPI_FREE (NextInterface->Name);
168 179 ACPI_FREE (NextInterface);
169 180 }
181 + else
182 + {
183 + /* Interface is in static list. Reset it to invalid or valid. */
170 184
185 + if (NextInterface->Flags & ACPI_OSI_DEFAULT_INVALID)
186 + {
187 + NextInterface->Flags |= ACPI_OSI_INVALID;
188 + }
189 + else
190 + {
191 + NextInterface->Flags &= ~ACPI_OSI_INVALID;
192 + }
193 + }
194 +
171 195 NextInterface = AcpiGbl_SupportedInterfaces;
172 196 }
173 197
174 198 AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
199 + return (AE_OK);
175 200 }
176 201
177 202
178 203 /*******************************************************************************
179 204 *
180 205 * FUNCTION: AcpiUtInstallInterface
181 206 *
182 207 * PARAMETERS: InterfaceName - The interface to install
183 208 *
184 209 * RETURN: Status
185 210 *
186 211 * DESCRIPTION: Install the interface into the global interface list.
187 212 * Caller MUST hold AcpiGbl_OsiMutex
188 213 *
189 214 ******************************************************************************/
190 215
191 216 ACPI_STATUS
192 217 AcpiUtInstallInterface (
193 218 ACPI_STRING InterfaceName)
194 219 {
195 220 ACPI_INTERFACE_INFO *InterfaceInfo;
196 221
197 222
198 223 /* Allocate info block and space for the name string */
199 224
200 225 InterfaceInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_INTERFACE_INFO));
201 226 if (!InterfaceInfo)
202 227 {
203 228 return (AE_NO_MEMORY);
204 229 }
205 230
206 231 InterfaceInfo->Name = ACPI_ALLOCATE_ZEROED (ACPI_STRLEN (InterfaceName) + 1);
207 232 if (!InterfaceInfo->Name)
208 233 {
209 234 ACPI_FREE (InterfaceInfo);
210 235 return (AE_NO_MEMORY);
211 236 }
212 237
213 238 /* Initialize new info and insert at the head of the global list */
214 239
215 240 ACPI_STRCPY (InterfaceInfo->Name, InterfaceName);
216 241 InterfaceInfo->Flags = ACPI_OSI_DYNAMIC;
217 242 InterfaceInfo->Next = AcpiGbl_SupportedInterfaces;
218 243
219 244 AcpiGbl_SupportedInterfaces = InterfaceInfo;
220 245 return (AE_OK);
221 246 }
222 247
223 248
224 249 /*******************************************************************************
225 250 *
226 251 * FUNCTION: AcpiUtRemoveInterface
227 252 *
228 253 * PARAMETERS: InterfaceName - The interface to remove
229 254 *
230 255 * RETURN: Status
231 256 *
232 257 * DESCRIPTION: Remove the interface from the global interface list.
233 258 * Caller MUST hold AcpiGbl_OsiMutex
234 259 *
235 260 ******************************************************************************/
236 261
237 262 ACPI_STATUS
238 263 AcpiUtRemoveInterface (
239 264 ACPI_STRING InterfaceName)
240 265 {
241 266 ACPI_INTERFACE_INFO *PreviousInterface;
242 267 ACPI_INTERFACE_INFO *NextInterface;
243 268
244 269
245 270 PreviousInterface = NextInterface = AcpiGbl_SupportedInterfaces;
246 271 while (NextInterface)
247 272 {
248 273 if (!ACPI_STRCMP (InterfaceName, NextInterface->Name))
249 274 {
250 275 /* Found: name is in either the static list or was added at runtime */
251 276
252 277 if (NextInterface->Flags & ACPI_OSI_DYNAMIC)
253 278 {
254 279 /* Interface was added dynamically, remove and free it */
255 280
256 281 if (PreviousInterface == NextInterface)
257 282 {
258 283 AcpiGbl_SupportedInterfaces = NextInterface->Next;
259 284 }
260 285 else
261 286 {
262 287 PreviousInterface->Next = NextInterface->Next;
263 288 }
264 289
265 290 ACPI_FREE (NextInterface->Name);
266 291 ACPI_FREE (NextInterface);
267 292 }
268 293 else
269 294 {
270 295 /*
271 296 * Interface is in static list. If marked invalid, then it
272 297 * does not actually exist. Else, mark it invalid.
273 298 */
274 299 if (NextInterface->Flags & ACPI_OSI_INVALID)
275 300 {
276 301 return (AE_NOT_EXIST);
277 302 }
278 303
279 304 NextInterface->Flags |= ACPI_OSI_INVALID;
280 305 }
281 306
282 307 return (AE_OK);
283 308 }
284 309
285 310 PreviousInterface = NextInterface;
286 311 NextInterface = NextInterface->Next;
↓ open down ↓ |
102 lines elided |
↑ open up ↑ |
287 312 }
288 313
289 314 /* Interface was not found */
290 315
291 316 return (AE_NOT_EXIST);
292 317 }
293 318
294 319
295 320 /*******************************************************************************
296 321 *
322 + * FUNCTION: AcpiUtUpdateInterfaces
323 + *
324 + * PARAMETERS: Action - Actions to be performed during the
325 + * update
326 + *
327 + * RETURN: Status
328 + *
329 + * DESCRIPTION: Update _OSI interface strings, disabling or enabling OS vendor
330 + * strings or/and feature group strings.
331 + * Caller MUST hold AcpiGbl_OsiMutex
332 + *
333 + ******************************************************************************/
334 +
335 +ACPI_STATUS
336 +AcpiUtUpdateInterfaces (
337 + UINT8 Action)
338 +{
339 + ACPI_INTERFACE_INFO *NextInterface;
340 +
341 +
342 + NextInterface = AcpiGbl_SupportedInterfaces;
343 + while (NextInterface)
344 + {
345 + if (((NextInterface->Flags & ACPI_OSI_FEATURE) &&
346 + (Action & ACPI_FEATURE_STRINGS)) ||
347 + (!(NextInterface->Flags & ACPI_OSI_FEATURE) &&
348 + (Action & ACPI_VENDOR_STRINGS)))
349 + {
350 + if (Action & ACPI_DISABLE_INTERFACES)
351 + {
352 + /* Mark the interfaces as invalid */
353 +
354 + NextInterface->Flags |= ACPI_OSI_INVALID;
355 + }
356 + else
357 + {
358 + /* Mark the interfaces as valid */
359 +
360 + NextInterface->Flags &= ~ACPI_OSI_INVALID;
361 + }
362 + }
363 +
364 + NextInterface = NextInterface->Next;
365 + }
366 +
367 + return (AE_OK);
368 +}
369 +
370 +
371 +/*******************************************************************************
372 + *
297 373 * FUNCTION: AcpiUtGetInterface
298 374 *
299 375 * PARAMETERS: InterfaceName - The interface to find
300 376 *
301 377 * RETURN: ACPI_INTERFACE_INFO if found. NULL if not found.
302 378 *
303 379 * DESCRIPTION: Search for the specified interface name in the global list.
304 380 * Caller MUST hold AcpiGbl_OsiMutex
305 381 *
306 382 ******************************************************************************/
307 383
308 384 ACPI_INTERFACE_INFO *
309 385 AcpiUtGetInterface (
310 386 ACPI_STRING InterfaceName)
311 387 {
312 388 ACPI_INTERFACE_INFO *NextInterface;
313 389
314 390
315 391 NextInterface = AcpiGbl_SupportedInterfaces;
316 392 while (NextInterface)
317 393 {
318 394 if (!ACPI_STRCMP (InterfaceName, NextInterface->Name))
319 395 {
320 396 return (NextInterface);
321 397 }
322 398
323 399 NextInterface = NextInterface->Next;
324 400 }
325 401
326 402 return (NULL);
327 403 }
328 404
329 405
330 406 /*******************************************************************************
331 407 *
332 408 * FUNCTION: AcpiUtOsiImplementation
333 409 *
334 410 * PARAMETERS: WalkState - Current walk state
335 411 *
336 412 * RETURN: Status
337 413 *
338 414 * DESCRIPTION: Implementation of the _OSI predefined control method. When
339 415 * an invocation of _OSI is encountered in the system AML,
340 416 * control is transferred to this function.
341 417 *
↓ open down ↓ |
35 lines elided |
↑ open up ↑ |
342 418 ******************************************************************************/
343 419
344 420 ACPI_STATUS
345 421 AcpiUtOsiImplementation (
346 422 ACPI_WALK_STATE *WalkState)
347 423 {
348 424 ACPI_OPERAND_OBJECT *StringDesc;
349 425 ACPI_OPERAND_OBJECT *ReturnDesc;
350 426 ACPI_INTERFACE_INFO *InterfaceInfo;
351 427 ACPI_INTERFACE_HANDLER InterfaceHandler;
428 + ACPI_STATUS Status;
352 429 UINT32 ReturnValue;
353 430
354 431
355 432 ACPI_FUNCTION_TRACE (UtOsiImplementation);
356 433
357 434
358 435 /* Validate the string input argument (from the AML caller) */
359 436
360 437 StringDesc = WalkState->Arguments[0].Object;
361 438 if (!StringDesc ||
362 439 (StringDesc->Common.Type != ACPI_TYPE_STRING))
363 440 {
364 441 return_ACPI_STATUS (AE_TYPE);
365 442 }
366 443
367 444 /* Create a return object */
↓ open down ↓ |
6 lines elided |
↑ open up ↑ |
368 445
369 446 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
370 447 if (!ReturnDesc)
371 448 {
372 449 return_ACPI_STATUS (AE_NO_MEMORY);
373 450 }
374 451
375 452 /* Default return value is 0, NOT SUPPORTED */
376 453
377 454 ReturnValue = 0;
378 - (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
455 + Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
456 + if (ACPI_FAILURE (Status))
457 + {
458 + AcpiUtRemoveReference (ReturnDesc);
459 + return_ACPI_STATUS (Status);
460 + }
379 461
380 462 /* Lookup the interface in the global _OSI list */
381 463
382 464 InterfaceInfo = AcpiUtGetInterface (StringDesc->String.Pointer);
383 465 if (InterfaceInfo &&
384 466 !(InterfaceInfo->Flags & ACPI_OSI_INVALID))
385 467 {
386 468 /*
387 469 * The interface is supported.
388 470 * Update the OsiData if necessary. We keep track of the latest
389 471 * version of Windows that has been requested by the BIOS.
390 472 */
391 473 if (InterfaceInfo->Value > AcpiGbl_OsiData)
392 474 {
393 475 AcpiGbl_OsiData = InterfaceInfo->Value;
394 476 }
395 477
396 478 ReturnValue = ACPI_UINT32_MAX;
397 479 }
398 480
399 481 AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
400 482
401 483 /*
402 484 * Invoke an optional _OSI interface handler. The host OS may wish
403 485 * to do some interface-specific handling. For example, warn about
404 486 * certain interfaces or override the true/false support value.
405 487 */
406 488 InterfaceHandler = AcpiGbl_InterfaceHandler;
407 489 if (InterfaceHandler)
408 490 {
409 491 ReturnValue = InterfaceHandler (
410 492 StringDesc->String.Pointer, ReturnValue);
411 493 }
412 494
413 495 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO,
414 496 "ACPI: BIOS _OSI(\"%s\") is %ssupported\n",
415 497 StringDesc->String.Pointer, ReturnValue == 0 ? "not " : ""));
416 498
417 499 /* Complete the return object */
418 500
419 501 ReturnDesc->Integer.Value = ReturnValue;
420 502 WalkState->ReturnDesc = ReturnDesc;
421 503 return_ACPI_STATUS (AE_OK);
422 504 }
↓ open down ↓ |
34 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX