ReactOS  0.4.14-dev-999-g61c8d34
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 423 of file utosi.c.

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

Referenced by AcpiInstallInterface(), and AcpiUtOsiImplementation().

◆ AcpiUtInitializeInterfaces()

ACPI_STATUS AcpiUtInitializeInterfaces ( void  )

Definition at line 148 of file utosi.c.

150 {
152  UINT32 i;
153 
154 
155  Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
156  if (ACPI_FAILURE (Status))
157  {
158  return (Status);
159  }
160 
161  AcpiGbl_SupportedInterfaces = AcpiDefaultSupportedInterfaces;
162 
163  /* Link the static list of supported interfaces */
164 
165  for (i = 0;
167  i++)
168  {
170  &AcpiDefaultSupportedInterfaces[(ACPI_SIZE) i + 1];
171  }
172 
173  AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
174  return (AE_OK);
175 }
ACPI_STATUS AcpiOsAcquireMutex(ACPI_MUTEX Handle, UINT16 Timeout)
Definition: osl.c:306
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_ARRAY_LENGTH(x)
Definition: actypes.h:540
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
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
unsigned int UINT32
static ACPI_INTERFACE_INFO AcpiDefaultSupportedInterfaces[]
Definition: utosi.c:91
#define ACPI_WAIT_FOREVER
Definition: actypes.h:501
Status
Definition: gdiplustypes.h:24
struct acpi_interface_info * Next
Definition: aclocal.h:1264
void AcpiOsReleaseMutex(ACPI_MUTEX Handle)
Definition: osl.c:333
#define AE_OK
Definition: acexcep.h:97

Referenced by AcpiInitializeSubsystem().

◆ AcpiUtInstallInterface()

ACPI_STATUS AcpiUtInstallInterface ( ACPI_STRING  InterfaceName)

Definition at line 253 of file utosi.c.

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

Referenced by AcpiInstallInterface().

◆ AcpiUtInterfaceTerminate()

ACPI_STATUS AcpiUtInterfaceTerminate ( void  )

Definition at line 192 of file utosi.c.

194 {
196  ACPI_INTERFACE_INFO *NextInterface;
197 
198 
199  Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
200  if (ACPI_FAILURE (Status))
201  {
202  return (Status);
203  }
204 
205  NextInterface = AcpiGbl_SupportedInterfaces;
206  while (NextInterface)
207  {
208  AcpiGbl_SupportedInterfaces = NextInterface->Next;
209 
210  if (NextInterface->Flags & ACPI_OSI_DYNAMIC)
211  {
212  /* Only interfaces added at runtime can be freed */
213 
214  ACPI_FREE (NextInterface->Name);
215  ACPI_FREE (NextInterface);
216  }
217  else
218  {
219  /* Interface is in static list. Reset it to invalid or valid. */
220 
221  if (NextInterface->Flags & ACPI_OSI_DEFAULT_INVALID)
222  {
223  NextInterface->Flags |= ACPI_OSI_INVALID;
224  }
225  else
226  {
227  NextInterface->Flags &= ~ACPI_OSI_INVALID;
228  }
229  }
230 
231  NextInterface = AcpiGbl_SupportedInterfaces;
232  }
233 
234  AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
235  return (AE_OK);
236 }
#define ACPI_FREE(a)
Definition: actypes.h:386
ACPI_STATUS AcpiOsAcquireMutex(ACPI_MUTEX Handle, UINT16 Timeout)
Definition: osl.c:306
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define ACPI_OSI_INVALID
Definition: aclocal.h:1270
#define ACPI_OSI_DYNAMIC
Definition: aclocal.h:1271
#define ACPI_OSI_DEFAULT_INVALID
Definition: aclocal.h:1273
#define ACPI_WAIT_FOREVER
Definition: actypes.h:501
Status
Definition: gdiplustypes.h:24
struct acpi_interface_info * Next
Definition: aclocal.h:1264
void AcpiOsReleaseMutex(ACPI_MUTEX Handle)
Definition: osl.c:333
#define AE_OK
Definition: acexcep.h:97

Referenced by AcpiUtSubsystemShutdown().

◆ AcpiUtOsiImplementation()

ACPI_STATUS AcpiUtOsiImplementation ( ACPI_WALK_STATE WalkState)

Definition at line 470 of file utosi.c.

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

Referenced by AcpiNsRootInitialize().

◆ AcpiUtRemoveInterface()

ACPI_STATUS AcpiUtRemoveInterface ( ACPI_STRING  InterfaceName)

Definition at line 299 of file utosi.c.

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

Referenced by AcpiRemoveInterface().

◆ AcpiUtUpdateInterfaces()

ACPI_STATUS AcpiUtUpdateInterfaces ( UINT8  Action)

Definition at line 374 of file utosi.c.

376 {
377  ACPI_INTERFACE_INFO *NextInterface;
378 
379 
380  NextInterface = AcpiGbl_SupportedInterfaces;
381  while (NextInterface)
382  {
383  if (((NextInterface->Flags & ACPI_OSI_FEATURE) &&
385  (!(NextInterface->Flags & ACPI_OSI_FEATURE) &&
387  {
389  {
390  /* Mark the interfaces as invalid */
391 
392  NextInterface->Flags |= ACPI_OSI_INVALID;
393  }
394  else
395  {
396  /* Mark the interfaces as valid */
397 
398  NextInterface->Flags &= ~ACPI_OSI_INVALID;
399  }
400  }
401 
402  NextInterface = NextInterface->Next;
403  }
404 
405  return (AE_OK);
406 }
#define ACPI_OSI_FEATURE
Definition: aclocal.h:1272
#define ACPI_VENDOR_STRINGS
Definition: actypes.h:1385
#define ACPI_OSI_INVALID
Definition: aclocal.h:1270
_In_ PLIST_ENTRY _In_ PSTRING _In_ USHORT _In_opt_ PSTRING _In_opt_ PSTRING _In_ ULONG _In_ ULONG Action
Definition: fsrtlfuncs.h:738
#define ACPI_FEATURE_STRINGS
Definition: actypes.h:1386
struct acpi_interface_info * Next
Definition: aclocal.h:1264
#define ACPI_DISABLE_INTERFACES
Definition: actypes.h:1388
#define AE_OK
Definition: acexcep.h:97

Referenced by AcpiUpdateInterfaces().

Variable Documentation

◆ AcpiDefaultSupportedInterfaces

ACPI_INTERFACE_INFO AcpiDefaultSupportedInterfaces[]
static

Definition at line 91 of file utosi.c.

Referenced by AcpiUtInitializeInterfaces().