ReactOS 0.4.15-dev-7934-g1dc8d80
utosi.c File Reference
#include "acpi.h"
#include "accommon.h"
Include dependency graph for utosi.c:

Go to the source code of this file.

Macros

#define _COMPONENT   ACPI_UTILITIES
 

Functions

ACPI_STATUS AcpiUtInitializeInterfaces (void)
 
ACPI_STATUS AcpiUtInterfaceTerminate (void)
 
ACPI_STATUS AcpiUtInstallInterface (ACPI_STRING InterfaceName)
 
ACPI_STATUS AcpiUtRemoveInterface (ACPI_STRING InterfaceName)
 
ACPI_STATUS AcpiUtUpdateInterfaces (UINT8 Action)
 
ACPI_INTERFACE_INFOAcpiUtGetInterface (ACPI_STRING InterfaceName)
 
ACPI_STATUS AcpiUtOsiImplementation (ACPI_WALK_STATE *WalkState)
 

Variables

static ACPI_INTERFACE_INFO AcpiDefaultSupportedInterfaces []
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_UTILITIES

Definition at line 48 of file utosi.c.

Function Documentation

◆ AcpiUtGetInterface()

ACPI_INTERFACE_INFO * AcpiUtGetInterface ( ACPI_STRING  InterfaceName)

Definition at line 425 of file utosi.c.

427{
428 ACPI_INTERFACE_INFO *NextInterface;
429
430
431 NextInterface = AcpiGbl_SupportedInterfaces;
432 while (NextInterface)
433 {
434 if (!strcmp (InterfaceName, NextInterface->Name))
435 {
436 return (NextInterface);
437 }
438
439 NextInterface = NextInterface->Next;
440 }
441
442 return (NULL);
443}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define NULL
Definition: types.h:112
struct acpi_interface_info * Next
Definition: aclocal.h:1264

Referenced by AcpiInstallInterface(), and AcpiUtOsiImplementation().

◆ AcpiUtInitializeInterfaces()

ACPI_STATUS AcpiUtInitializeInterfaces ( void  )

Definition at line 150 of file utosi.c.

152{
154 UINT32 i;
155
156
157 Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
158 if (ACPI_FAILURE (Status))
159 {
160 return (Status);
161 }
162
163 AcpiGbl_SupportedInterfaces = AcpiDefaultSupportedInterfaces;
164
165 /* Link the static list of supported interfaces */
166
167 for (i = 0;
169 i++)
170 {
172 &AcpiDefaultSupportedInterfaces[(ACPI_SIZE) i + 1];
173 }
174
175 AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
176 return (AE_OK);
177}
unsigned int UINT32
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define AE_OK
Definition: acexcep.h:97
#define ACPI_ARRAY_LENGTH(x)
Definition: actypes.h:540
#define AcpiOsAcquireMutex(Handle, Time)
Definition: actypes.h:276
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define AcpiOsReleaseMutex(Handle)
Definition: actypes.h:277
#define ACPI_WAIT_FOREVER
Definition: actypes.h:501
Status
Definition: gdiplustypes.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static ACPI_INTERFACE_INFO AcpiDefaultSupportedInterfaces[]
Definition: utosi.c:91

Referenced by AcpiInitializeSubsystem().

◆ AcpiUtInstallInterface()

ACPI_STATUS AcpiUtInstallInterface ( ACPI_STRING  InterfaceName)

Definition at line 255 of file utosi.c.

257{
258 ACPI_INTERFACE_INFO *InterfaceInfo;
259
260
261 /* Allocate info block and space for the name string */
262
263 InterfaceInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_INTERFACE_INFO));
264 if (!InterfaceInfo)
265 {
266 return (AE_NO_MEMORY);
267 }
268
269 InterfaceInfo->Name = ACPI_ALLOCATE_ZEROED (strlen (InterfaceName) + 1);
270 if (!InterfaceInfo->Name)
271 {
272 ACPI_FREE (InterfaceInfo);
273 return (AE_NO_MEMORY);
274 }
275
276 /* Initialize new info and insert at the head of the global list */
277
278 strcpy (InterfaceInfo->Name, InterfaceName);
279 InterfaceInfo->Flags = ACPI_OSI_DYNAMIC;
280 InterfaceInfo->Next = AcpiGbl_SupportedInterfaces;
281
282 AcpiGbl_SupportedInterfaces = InterfaceInfo;
283 return (AE_OK);
284}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define AE_NO_MEMORY
Definition: acexcep.h:112
#define ACPI_OSI_DYNAMIC
Definition: aclocal.h:1271
#define ACPI_FREE(a)
Definition: actypes.h:386
#define ACPI_ALLOCATE_ZEROED(a)
Definition: actypes.h:385

Referenced by AcpiInstallInterface().

◆ AcpiUtInterfaceTerminate()

ACPI_STATUS AcpiUtInterfaceTerminate ( void  )

Definition at line 194 of file utosi.c.

196{
198 ACPI_INTERFACE_INFO *NextInterface;
199
200
201 Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
202 if (ACPI_FAILURE (Status))
203 {
204 return (Status);
205 }
206
207 NextInterface = AcpiGbl_SupportedInterfaces;
208 while (NextInterface)
209 {
210 AcpiGbl_SupportedInterfaces = NextInterface->Next;
211
212 if (NextInterface->Flags & ACPI_OSI_DYNAMIC)
213 {
214 /* Only interfaces added at runtime can be freed */
215
216 ACPI_FREE (NextInterface->Name);
217 ACPI_FREE (NextInterface);
218 }
219 else
220 {
221 /* Interface is in static list. Reset it to invalid or valid. */
222
223 if (NextInterface->Flags & ACPI_OSI_DEFAULT_INVALID)
224 {
225 NextInterface->Flags |= ACPI_OSI_INVALID;
226 }
227 else
228 {
229 NextInterface->Flags &= ~ACPI_OSI_INVALID;
230 }
231 }
232
233 NextInterface = AcpiGbl_SupportedInterfaces;
234 }
235
236 AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
237 return (AE_OK);
238}
#define ACPI_OSI_DEFAULT_INVALID
Definition: aclocal.h:1273
#define ACPI_OSI_INVALID
Definition: aclocal.h:1270

Referenced by AcpiUtSubsystemShutdown().

◆ AcpiUtOsiImplementation()

ACPI_STATUS AcpiUtOsiImplementation ( ACPI_WALK_STATE WalkState)

Definition at line 472 of file utosi.c.

474{
475 ACPI_OPERAND_OBJECT *StringDesc;
476 ACPI_OPERAND_OBJECT *ReturnDesc;
477 ACPI_INTERFACE_INFO *InterfaceInfo;
478 ACPI_INTERFACE_HANDLER InterfaceHandler;
481
482
483 ACPI_FUNCTION_TRACE (UtOsiImplementation);
484
485
486 /* Validate the string input argument (from the AML caller) */
487
488 StringDesc = WalkState->Arguments[0].Object;
489 if (!StringDesc ||
490 (StringDesc->Common.Type != ACPI_TYPE_STRING))
491 {
493 }
494
495 /* Create a return object */
496
498 if (!ReturnDesc)
499 {
501 }
502
503 /* Default return value is 0, NOT SUPPORTED */
504
505 ReturnValue = 0;
506 Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
507 if (ACPI_FAILURE (Status))
508 {
509 AcpiUtRemoveReference (ReturnDesc);
511 }
512
513 /* Lookup the interface in the global _OSI list */
514
515 InterfaceInfo = AcpiUtGetInterface (StringDesc->String.Pointer);
516 if (InterfaceInfo &&
517 !(InterfaceInfo->Flags & ACPI_OSI_INVALID))
518 {
519 /*
520 * The interface is supported.
521 * Update the OsiData if necessary. We keep track of the latest
522 * version of Windows that has been requested by the BIOS.
523 */
524 if (InterfaceInfo->Value > AcpiGbl_OsiData)
525 {
526 AcpiGbl_OsiData = InterfaceInfo->Value;
527 }
528
530 }
531
532 AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
533
534 /*
535 * Invoke an optional _OSI interface handler. The host OS may wish
536 * to do some interface-specific handling. For example, warn about
537 * certain interfaces or override the true/false support value.
538 */
539 InterfaceHandler = AcpiGbl_InterfaceHandler;
540 if (InterfaceHandler)
541 {
542 if (InterfaceHandler (
543 StringDesc->String.Pointer, (UINT32) ReturnValue))
544 {
546 }
547 }
548
550 "ACPI: BIOS _OSI(\"%s\") is %ssupported\n",
551 StringDesc->String.Pointer, ReturnValue == 0 ? "not " : ""));
552
553 /* Complete the return object */
554
555 ReturnDesc->Integer.Value = ReturnValue;
556 WalkState->ReturnDesc = ReturnDesc;
558}
unsigned long long UINT64
UINT32 void void ** ReturnValue
Definition: acevents.h:216
#define AE_TYPE
Definition: acexcep.h:116
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_DEBUG_PRINT_RAW(pl)
Definition: acoutput.h:476
#define ACPI_DB_INFO
Definition: acoutput.h:153
#define ACPI_UINT64_MAX
Definition: actypes.h:67
#define ACPI_TYPE_STRING
Definition: actypes.h:689
#define ACPI_TYPE_INTEGER
Definition: actypes.h:688
UINT32(* ACPI_INTERFACE_HANDLER)(ACPI_STRING InterfaceName, UINT32 Supported)
Definition: actypes.h:1256
#define AcpiUtCreateInternalObject(t)
Definition: acutils.h:681
void AcpiUtRemoveReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:790
union acpi_operand_object * ReturnDesc
Definition: acstruct.h:123
struct acpi_namespace_node Arguments[ACPI_METHOD_NUM_ARGS]
Definition: acstruct.h:103
ACPI_OBJECT_INTEGER Integer
Definition: acobject.h:520
ACPI_OBJECT_COMMON Common
Definition: acobject.h:519
ACPI_OBJECT_STRING String
Definition: acobject.h:521
ACPI_INTERFACE_INFO * AcpiUtGetInterface(ACPI_STRING InterfaceName)
Definition: utosi.c:425

Referenced by AcpiNsRootInitialize().

◆ AcpiUtRemoveInterface()

ACPI_STATUS AcpiUtRemoveInterface ( ACPI_STRING  InterfaceName)

Definition at line 301 of file utosi.c.

303{
304 ACPI_INTERFACE_INFO *PreviousInterface;
305 ACPI_INTERFACE_INFO *NextInterface;
306
307
308 PreviousInterface = NextInterface = AcpiGbl_SupportedInterfaces;
309 while (NextInterface)
310 {
311 if (!strcmp (InterfaceName, NextInterface->Name))
312 {
313 /*
314 * Found: name is in either the static list
315 * or was added at runtime
316 */
317 if (NextInterface->Flags & ACPI_OSI_DYNAMIC)
318 {
319 /* Interface was added dynamically, remove and free it */
320
321 if (PreviousInterface == NextInterface)
322 {
323 AcpiGbl_SupportedInterfaces = NextInterface->Next;
324 }
325 else
326 {
327 PreviousInterface->Next = NextInterface->Next;
328 }
329
330 ACPI_FREE (NextInterface->Name);
331 ACPI_FREE (NextInterface);
332 }
333 else
334 {
335 /*
336 * Interface is in static list. If marked invalid, then
337 * it does not actually exist. Else, mark it invalid.
338 */
339 if (NextInterface->Flags & ACPI_OSI_INVALID)
340 {
341 return (AE_NOT_EXIST);
342 }
343
344 NextInterface->Flags |= ACPI_OSI_INVALID;
345 }
346
347 return (AE_OK);
348 }
349
350 PreviousInterface = NextInterface;
351 NextInterface = NextInterface->Next;
352 }
353
354 /* Interface was not found */
355
356 return (AE_NOT_EXIST);
357}
#define AE_NOT_EXIST
Definition: acexcep.h:114

Referenced by AcpiRemoveInterface().

◆ AcpiUtUpdateInterfaces()

ACPI_STATUS AcpiUtUpdateInterfaces ( UINT8  Action)

Definition at line 376 of file utosi.c.

378{
379 ACPI_INTERFACE_INFO *NextInterface;
380
381
382 NextInterface = AcpiGbl_SupportedInterfaces;
383 while (NextInterface)
384 {
385 if (((NextInterface->Flags & ACPI_OSI_FEATURE) &&
387 (!(NextInterface->Flags & ACPI_OSI_FEATURE) &&
389 {
391 {
392 /* Mark the interfaces as invalid */
393
394 NextInterface->Flags |= ACPI_OSI_INVALID;
395 }
396 else
397 {
398 /* Mark the interfaces as valid */
399
400 NextInterface->Flags &= ~ACPI_OSI_INVALID;
401 }
402 }
403
404 NextInterface = NextInterface->Next;
405 }
406
407 return (AE_OK);
408}
#define ACPI_OSI_FEATURE
Definition: aclocal.h:1272
#define ACPI_VENDOR_STRINGS
Definition: actypes.h:1423
#define ACPI_FEATURE_STRINGS
Definition: actypes.h:1424
#define ACPI_DISABLE_INTERFACES
Definition: actypes.h:1426
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:510

Referenced by AcpiUpdateInterfaces().

Variable Documentation

◆ AcpiDefaultSupportedInterfaces

ACPI_INTERFACE_INFO AcpiDefaultSupportedInterfaces[]
static

Definition at line 91 of file utosi.c.

Referenced by AcpiUtInitializeInterfaces().