ReactOS  0.4.14-dev-1338-g0d187f7
utils.c File Reference
#include <precomp.h>
#include <ntstrsafe.h>
#include <debug.h>
Include dependency graph for utils.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define _COMPONENT   ACPI_BUS_COMPONENT
 

Functions

static void acpi_util_eval_error (ACPI_HANDLE h, ACPI_STRING p, ACPI_STATUS s)
 
ACPI_STATUS acpi_extract_package (ACPI_OBJECT *package, ACPI_BUFFER *format, ACPI_BUFFER *buffer)
 
ACPI_STATUS acpi_evaluate_integer (ACPI_HANDLE handle, ACPI_STRING pathname, ACPI_OBJECT_LIST *arguments, unsigned long long *data)
 
ACPI_STATUS acpi_evaluate_reference (ACPI_HANDLE handle, ACPI_STRING pathname, ACPI_OBJECT_LIST *arguments, struct acpi_handle_list *list)
 
NTSTATUS acpi_create_registry_table (HANDLE ParentKeyHandle, ACPI_TABLE_HEADER *OutTable, PCWSTR KeyName)
 
NTSTATUS acpi_create_volatile_registry_tables (void)
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_BUS_COMPONENT

Definition at line 36 of file utils.c.

◆ NDEBUG

#define NDEBUG

Definition at line 29 of file utils.c.

Function Documentation

◆ acpi_create_registry_table()

NTSTATUS acpi_create_registry_table ( HANDLE  ParentKeyHandle,
ACPI_TABLE_HEADER OutTable,
PCWSTR  KeyName 
)

Definition at line 374 of file utils.c.

375 {
377  UNICODE_STRING HardwareKeyName, ValueName;
378  ANSI_STRING HardwareKeyNameA;
381  char OemId[7] = { 0 }; /* exactly one byte more than ACPI_TABLE_HEADER->OemId */
382  char OemTableId[9] = { 0 }; /* exactly one byte more than ACPI_TABLE_HEADER->OemTableId */
383  WCHAR OemRevision[9] = { 0 }; /* enough to accept hex DWORD */
384 
385  C_ASSERT(sizeof(OemId) == RTL_FIELD_SIZE(ACPI_TABLE_HEADER, OemId) + 1);
386  C_ASSERT(sizeof(OemTableId) == RTL_FIELD_SIZE(ACPI_TABLE_HEADER, OemTableId) + 1);
387  /* Copy OEM data from the table */
388  RtlCopyMemory(OemId, OutTable->OemId, sizeof(OutTable->OemId));
389  RtlCopyMemory(OemTableId, OutTable->OemTableId, sizeof(OutTable->OemTableId));
390  /* Create table subkey */
391  RtlInitUnicodeString(&HardwareKeyName, KeyName);
393  &HardwareKeyName,
395  ParentKeyHandle,
396  NULL);
397  Status = ZwCreateKey(&KeyHandle,
398  KEY_WRITE,
400  0,
401  NULL,
403  NULL);
404  if (!NT_SUCCESS(Status))
405  {
406  DPRINT1("ZwCreateKey() for %ws failed (Status 0x%08lx)\n", KeyName, Status);
407  return Status;
408  }
409 
410  if (OutTable->OemRevision != 0)
411  {
412  /* We have OEM info in table, so create other OEM subkeys */
413  RtlInitAnsiString(&HardwareKeyNameA, OemId);
414  Status = RtlAnsiStringToUnicodeString(&HardwareKeyName, &HardwareKeyNameA, TRUE);
415  if (!NT_SUCCESS(Status))
416  {
417  DPRINT1("RtlAnsiStringToUnicodeString() for %s failed (Status 0x%08lx)\n", HardwareKeyNameA, Status);
418  return Status;
419  }
420 
422  &HardwareKeyName,
424  KeyHandle,
425  NULL);
426  Status = ZwCreateKey(&SubKeyHandle,
427  KEY_WRITE,
429  0,
430  NULL,
432  NULL);
433  RtlFreeUnicodeString(&HardwareKeyName);
435  if (!NT_SUCCESS(Status))
436  {
437  DPRINT1("ZwCreateKey() for %s failed (Status 0x%08lx)\n", HardwareKeyNameA, Status);
438  return Status;
439  }
441 
442  RtlInitAnsiString(&HardwareKeyNameA, OemTableId);
443  Status = RtlAnsiStringToUnicodeString(&HardwareKeyName, &HardwareKeyNameA, TRUE);
444  if (!NT_SUCCESS(Status))
445  {
446  DPRINT1("RtlAnsiStringToUnicodeString() for %s failed (Status 0x%08lx)\n", HardwareKeyNameA, Status);
447  return Status;
448  }
449 
451  &HardwareKeyName,
453  KeyHandle,
454  NULL);
455  Status = ZwCreateKey(&SubKeyHandle,
456  KEY_WRITE,
458  0,
459  NULL,
461  NULL);
462  RtlFreeUnicodeString(&HardwareKeyName);
464  if (!NT_SUCCESS(Status))
465  {
466  DPRINT1("ZwCreateKey() for %s failed (Status 0x%08lx)\n", HardwareKeyNameA, Status);
467  return Status;
468  }
470 
471  Status = RtlStringCbPrintfW(OemRevision,
472  sizeof(OemRevision),
473  L"%08X",
474  OutTable->OemRevision);
475  if (!NT_SUCCESS(Status))
476  {
477  DPRINT1("RtlStringCbPrintfW() for 0x%08lx failed (Status 0x%08lx)\n", OutTable->OemRevision, Status);
478  return Status;
479  }
480  RtlInitUnicodeString(&HardwareKeyName, OemRevision);
481 
483  &HardwareKeyName,
485  KeyHandle,
486  NULL);
487  Status = ZwCreateKey(&SubKeyHandle,
488  KEY_WRITE,
490  0,
491  NULL,
493  NULL);
495  if (!NT_SUCCESS(Status))
496  {
497  DPRINT1("ZwCreateKey() for %ws failed (Status 0x%08lx)\n", KeyName, Status);
498  return Status;
499  }
501  }
502  /* Table reg value name is always '00000000' */
504  L"00000000");
505  Status = ZwSetValueKey(KeyHandle,
506  &ValueName,
507  0,
508  REG_BINARY,
509  OutTable,
510  OutTable->Length);
512  if (!NT_SUCCESS(Status))
513  {
514  DPRINT1("ZwSetValueKey() failed (Status 0x%08lx)\n", Status);
515  return Status;
516  }
517 
518  return STATUS_SUCCESS;
519 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define RTL_FIELD_SIZE(type, field)
Definition: kdb_expr.c:84
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4711
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
UINT32 OemRevision
Definition: actbl.h:114
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
#define REG_BINARY
Definition: nt_native.h:1496
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
UINT32 Length
Definition: actbl.h:109
LONG NTSTATUS
Definition: precomp.h:26
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
_In_ PUNICODE_STRING ValueName
Definition: cmfuncs.h:264
smooth NULL
Definition: ftsmooth.c:416
#define C_ASSERT(e)
Definition: intsafe.h:79
#define KEY_WRITE
Definition: nt_native.h:1031
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTRSAFEVAPI RtlStringCbPrintfW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1173
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ PNDIS_STRING _Out_ PNDIS_HANDLE SubKeyHandle
Definition: ndis.h:4723
static const WCHAR L[]
Definition: oid.c:1250
char OemTableId[ACPI_OEM_TABLE_ID_SIZE]
Definition: actbl.h:113
Status
Definition: gdiplustypes.h:24
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
#define DPRINT1
Definition: precomp.h:8
char OemId[ACPI_OEM_ID_SIZE]
Definition: actbl.h:112
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define REG_OPTION_VOLATILE
Definition: nt_native.h:1060
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by acpi_create_volatile_registry_tables().

◆ acpi_create_volatile_registry_tables()

NTSTATUS acpi_create_volatile_registry_tables ( void  )

Definition at line 522 of file utils.c.

523 {
525  UNICODE_STRING HardwareKeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\HARDWARE\\ACPI");
528  ACPI_STATUS AcpiStatus;
529  ACPI_TABLE_HEADER *OutTable;
530  ACPI_PHYSICAL_ADDRESS RsdpAddress;
531  ACPI_TABLE_RSDP *Rsdp;
532  ACPI_PHYSICAL_ADDRESS Address;
533  UINT32 TableEntrySize;
534 
535  /* Create Main Hardware ACPI key*/
537  &HardwareKeyName,
539  NULL,
540  NULL);
541  Status = ZwCreateKey(&KeyHandle,
542  KEY_WRITE,
544  0,
545  NULL,
547  NULL);
548  if (!NT_SUCCESS(Status))
549  {
550  DPRINT1("ZwCreateKey() for ACPI failed (Status 0x%08lx)\n", Status);
551  return Status;
552  }
553  /* Read DSDT table */
554  AcpiStatus = AcpiGetTable(ACPI_SIG_DSDT, 0, &OutTable);
555  if (ACPI_FAILURE(AcpiStatus))
556  {
557  DPRINT1("AcpiGetTable() for DSDT failed (Status 0x%08lx)\n", AcpiStatus);
559  goto done;
560  }
561  /* Dump DSDT table */
562  Status = acpi_create_registry_table(KeyHandle, OutTable, L"DSDT");
563  if (!NT_SUCCESS(Status))
564  {
565  DPRINT1("acpi_dump_table_to_registry() for DSDT failed (Status 0x%08lx)\n", Status);
566  goto done;
567  }
568  /* Read FACS table */
569  AcpiStatus = AcpiGetTable(ACPI_SIG_FACS, 0, &OutTable);
570  if (ACPI_FAILURE(AcpiStatus))
571  {
572  DPRINT1("AcpiGetTable() for FACS failed (Status 0x%08lx)\n", AcpiStatus);
574  goto done;
575  }
576  /* Dump FACS table */
577  Status = acpi_create_registry_table(KeyHandle, OutTable, L"FACS");
578  if (!NT_SUCCESS(Status))
579  {
580  DPRINT1("acpi_dump_table_to_registry() for FACS failed (Status 0x%08lx)\n", Status);
581  goto done;
582  }
583  /* Read FACS table */
584  AcpiStatus = AcpiGetTable(ACPI_SIG_FADT, 0, &OutTable);
585  if (ACPI_FAILURE(AcpiStatus))
586  {
587  DPRINT1("AcpiGetTable() for FADT failed (Status 0x%08lx)\n", AcpiStatus);
589  goto done;
590  }
591  /* Dump FADT table */
592  Status = acpi_create_registry_table(KeyHandle, OutTable, L"FADT");
593  if (!NT_SUCCESS(Status))
594  {
595  DPRINT1("acpi_dump_table_to_registry() for FADT failed (Status 0x%08lx)\n", Status);
596  goto done;
597  }
598  /* This is a rough copy from ACPICA reading of RSDT/XSDT and added to avoid patching acpica */
599  RsdpAddress = AcpiOsGetRootPointer();
600  /* Map the entire RSDP and extract the address of the RSDT or XSDT */
601  Rsdp = AcpiOsMapMemory(RsdpAddress, sizeof(ACPI_TABLE_RSDP));
602  if (!Rsdp)
603  {
604  DPRINT1("AcpiOsMapMemory() failed\n");
606  goto done;
607  }
608  /* Use XSDT if present and not overridden. Otherwise, use RSDT */
609  if ((Rsdp->Revision > 1) &&
610  Rsdp->XsdtPhysicalAddress &&
611  !AcpiGbl_DoNotUseXsdt)
612  {
613  /*
614  * RSDP contains an XSDT (64-bit physical addresses). We must use
615  * the XSDT if the revision is > 1 and the XSDT pointer is present,
616  * as per the ACPI specification.
617  */
618  Address = (ACPI_PHYSICAL_ADDRESS)Rsdp->XsdtPhysicalAddress;
619  TableEntrySize = ACPI_XSDT_ENTRY_SIZE;
620  }
621  else
622  {
623  /* Root table is an RSDT (32-bit physical addresses) */
624  Address = (ACPI_PHYSICAL_ADDRESS)Rsdp->RsdtPhysicalAddress;
625  TableEntrySize = ACPI_RSDT_ENTRY_SIZE;
626  }
627  /*
628  * It is not possible to map more than one entry in some environments,
629  * so unmap the RSDP here before mapping other tables
630  */
631  AcpiOsUnmapMemory(Rsdp, sizeof(ACPI_TABLE_RSDP));
632  OutTable = AcpiOsMapMemory(Address, TableEntrySize);
633  if (!OutTable)
634  {
635  DPRINT1("AcpiOsMapMemory() failed\n");
637  goto done;
638  }
639  /* Dump RSDT table */
640  Status = acpi_create_registry_table(KeyHandle, OutTable, L"RSDT");
641  AcpiOsUnmapMemory(OutTable, TableEntrySize);
642  if (!NT_SUCCESS(Status))
643  {
644  DPRINT1("acpi_dump_table_to_registry() for RSDT failed (Status 0x%08lx)\n", Status);
645  }
646 
647 done:
649  return Status;
650 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
void * AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS Where, ACPI_SIZE Length)
Definition: osl.c:108
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
#define ACPI_XSDT_ENTRY_SIZE
Definition: actbl.h:209
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define ACPI_RSDT_ENTRY_SIZE
Definition: actbl.h:208
ACPI_STATUS AcpiGetTable(char *Signature, UINT32 Instance, ACPI_TABLE_HEADER **OutTable)
Definition: tbxface.c:366
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
unsigned int UINT32
#define ACPI_SIG_FACS
Definition: actbl.h:69
smooth NULL
Definition: ftsmooth.c:416
static WCHAR Address[46]
Definition: ping.c:68
UINT64 XsdtPhysicalAddress
Definition: actbl.h:157
#define ACPI_SIG_DSDT
Definition: actbl.h:67
#define KEY_WRITE
Definition: nt_native.h:1031
NTSTATUS acpi_create_registry_table(HANDLE ParentKeyHandle, ACPI_TABLE_HEADER *OutTable, PCWSTR KeyName)
Definition: utils.c:374
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
UINT8 Revision
Definition: actbl.h:154
UINT32 RsdtPhysicalAddress
Definition: actbl.h:155
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
static const WCHAR L[]
Definition: oid.c:1250
#define ACPI_SIG_FADT
Definition: actbl.h:68
Status
Definition: gdiplustypes.h:24
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define DPRINT1
Definition: precomp.h:8
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define REG_OPTION_VOLATILE
Definition: nt_native.h:1060
ACPI_PHYSICAL_ADDRESS AcpiOsGetRootPointer(void)
Definition: osl.c:43
void AcpiOsUnmapMemory(void *LogicalAddress, ACPI_SIZE Size)
Definition: osl.c:128
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by Bus_StartFdo().

◆ acpi_evaluate_integer()

ACPI_STATUS acpi_evaluate_integer ( ACPI_HANDLE  handle,
ACPI_STRING  pathname,
ACPI_OBJECT_LIST arguments,
unsigned long long data 
)

Definition at line 242 of file utils.c.

247 {
250  ACPI_BUFFER buffer = {sizeof(ACPI_OBJECT), &element};
251 
252  ACPI_FUNCTION_TRACE("acpi_evaluate_integer");
253 
254  if (!data)
256 
258  if (ACPI_FAILURE(status)) {
261  }
262 
263  if (element.Type != ACPI_TYPE_INTEGER) {
266  }
267 
268  *data = element.Integer.Value;
269 
270  ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%lu]\n", *data));
271 
273 }
union acpi_object ACPI_OBJECT
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
#define ACPI_TYPE_INTEGER
Definition: actypes.h:680
char pathname[512]
Definition: util.h:13
GLuint buffer
Definition: glext.h:5915
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
static void acpi_util_eval_error(ACPI_HANDLE h, ACPI_STRING p, ACPI_STATUS s)
Definition: utils.c:40
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define AE_BAD_DATA
Definition: acexcep.h:154
#define ACPI_DB_INFO
Definition: acoutput.h:153
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
ACPI_STATUS AcpiEvaluateObject(ACPI_HANDLE Handle, ACPI_STRING Pathname, ACPI_OBJECT_LIST *ExternalParams, ACPI_BUFFER *ReturnBuffer)
Definition: nsxfeval.c:217
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define AE_OK
Definition: acexcep.h:97
Definition: ps.c:97

Referenced by acpi_bus_get_power(), acpi_bus_get_status_handle(), acpi_power_get_state(), and Bus_PDO_QueryResources().

◆ acpi_evaluate_reference()

ACPI_STATUS acpi_evaluate_reference ( ACPI_HANDLE  handle,
ACPI_STRING  pathname,
ACPI_OBJECT_LIST arguments,
struct acpi_handle_list list 
)

Definition at line 277 of file utils.c.

282 {
284  ACPI_OBJECT *package = NULL;
287  UINT32 i = 0;
288 
289  ACPI_FUNCTION_TRACE("acpi_evaluate_reference");
290 
291  if (!list) {
293  }
294 
295  /* Evaluate object. */
296 
298  if (ACPI_FAILURE(status))
299  goto end;
300 
301  package = (ACPI_OBJECT *) buffer.Pointer;
302 
303  if ((buffer.Length == 0) || !package) {
304  ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
305  "No return object (len %X ptr %p)\n",
306  buffer.Length, package));
309  goto end;
310  }
311  if (package->Type != ACPI_TYPE_PACKAGE) {
312  ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
313  "Expecting a [Package], found type %X\n",
314  package->Type));
317  goto end;
318  }
319  if (!package->Package.Count) {
320  ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
321  "[Package] has zero elements (%p)\n",
322  package));
325  goto end;
326  }
327 
328  if (package->Package.Count > ACPI_MAX_HANDLES) {
329  return AE_NO_MEMORY;
330  }
331  list->count = package->Package.Count;
332 
333  /* Extract package data. */
334 
335  for (i = 0; i < list->count; i++) {
336 
337  element = &(package->Package.Elements[i]);
338 
339  if (element->Type != ACPI_TYPE_LOCAL_REFERENCE) {
341  ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
342  "Expecting a [Reference] package element, found type %X\n",
343  element->type));
345  break;
346  }
347 
348  if (!element->Reference.Handle) {
349  ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid reference in"
350  " package %s\n", pathname));
352  break;
353  }
354  /* Get the ACPI_HANDLE. */
355 
356  list->handles[i] = element->Reference.Handle;
357  ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found reference [%p]\n",
358  list->handles[i]));
359  }
360 
361 end:
362  if (ACPI_FAILURE(status)) {
363  list->count = 0;
364  //ExFreePool(list->handles);
365  }
366 
367  if (buffer.Pointer)
368  AcpiOsFree(buffer.Pointer);
369 
371 }
#define AE_NO_MEMORY
Definition: acexcep.h:112
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
char pathname[512]
Definition: util.h:13
#define ACPI_TYPE_LOCAL_REFERENCE
Definition: actypes.h:711
GLuint buffer
Definition: glext.h:5915
GLuint GLuint end
Definition: gl.h:1545
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_TYPE_PACKAGE
Definition: actypes.h:683
#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
smooth NULL
Definition: ftsmooth.c:416
static void acpi_util_eval_error(ACPI_HANDLE h, ACPI_STRING p, ACPI_STATUS s)
Definition: utils.c:40
#define ACPI_ALLOCATE_BUFFER
Definition: actypes.h:1036
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
Definition: _list.h:228
#define AE_BAD_DATA
Definition: acexcep.h:154
#define ACPI_DB_INFO
Definition: acoutput.h:153
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_MAX_HANDLES
Definition: acpi_bus.h:35
ACPI_STATUS AcpiEvaluateObject(ACPI_HANDLE Handle, ACPI_STRING Pathname, ACPI_OBJECT_LIST *ExternalParams, ACPI_BUFFER *ReturnBuffer)
Definition: nsxfeval.c:217
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define AE_NULL_ENTRY
Definition: acexcep.h:118
void AcpiOsFree(void *Memory)
Definition: osl.c:167
#define AE_OK
Definition: acexcep.h:97
Definition: ps.c:97

Referenced by acpi_bus_get_power_flags().

◆ acpi_extract_package()

ACPI_STATUS acpi_extract_package ( ACPI_OBJECT package,
ACPI_BUFFER format,
ACPI_BUFFER buffer 
)

Definition at line 60 of file utils.c.

64 {
65  UINT32 size_required = 0;
66  UINT32 tail_offset = 0;
67  char *format_string = NULL;
68  UINT32 format_count = 0;
69  UINT32 i = 0;
70  UINT8 *head = NULL;
71  UINT8 *tail = NULL;
72 
73  if (!package || (package->Type != ACPI_TYPE_PACKAGE) || (package->Package.Count < 1)) {
74  ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'package' argument\n"));
76  }
77 
78  if (!format || !format->Pointer || (format->Length < 1)) {
79  ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'format' argument\n"));
81  }
82 
83  if (!buffer) {
84  ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'buffer' argument\n"));
86  }
87 
88  format_count = (format->Length/sizeof(char)) - 1;
89  if (format_count > package->Package.Count) {
90  ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Format specifies more objects [%d] than exist in package [%d].", format_count, package->package.count));
92  }
93 
94  format_string = format->Pointer;
95 
96  /*
97  * Calculate size_required.
98  */
99  for (i=0; i<format_count; i++) {
100 
101  ACPI_OBJECT *element = &(package->Package.Elements[i]);
102 
103  if (!element) {
105  }
106 
107  switch (element->Type) {
108 
109  case ACPI_TYPE_INTEGER:
110  switch (format_string[i]) {
111  case 'N':
112  size_required += sizeof(ACPI_INTEGER);
113  tail_offset += sizeof(ACPI_INTEGER);
114  break;
115  case 'S':
116  size_required += sizeof(char*) + sizeof(ACPI_INTEGER) + sizeof(char);
117  tail_offset += sizeof(char*);
118  break;
119  default:
120  ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid package element [%d]: got number, expecting [%c].\n", i, format_string[i]));
122  break;
123  }
124  break;
125 
126  case ACPI_TYPE_STRING:
127  case ACPI_TYPE_BUFFER:
128  switch (format_string[i]) {
129  case 'S':
130  size_required += sizeof(char*) + (element->String.Length * sizeof(char)) + sizeof(char);
131  tail_offset += sizeof(char*);
132  break;
133  case 'B':
134  size_required += sizeof(UINT8*) + (element->Buffer.Length * sizeof(UINT8));
135  tail_offset += sizeof(UINT8*);
136  break;
137  default:
138  ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid package element [%d] got string/buffer, expecting [%c].\n", i, format_string[i]));
140  break;
141  }
142  break;
143 
144  case ACPI_TYPE_PACKAGE:
145  default:
146  ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found unsupported element at index=%d\n", i));
147  /* TBD: handle nested packages... */
149  break;
150  }
151  }
152 
153  /*
154  * Validate output buffer.
155  */
156  if (buffer->Length < size_required) {
157  buffer->Length = size_required;
159  }
160  else if (buffer->Length != size_required || !buffer->Pointer) {
162  }
163 
164  head = buffer->Pointer;
165  tail = ((PUCHAR)buffer->Pointer) + tail_offset;
166 
167  /*
168  * Extract package data.
169  */
170  for (i=0; i<format_count; i++) {
171 
172  UINT8 **pointer = NULL;
173  ACPI_OBJECT *element = &(package->Package.Elements[i]);
174 
175  if (!element) {
177  }
178 
179  switch (element->Type) {
180 
181  case ACPI_TYPE_INTEGER:
182  switch (format_string[i]) {
183  case 'N':
184  *((ACPI_INTEGER*)head) = element->Integer.Value;
185  head += sizeof(ACPI_INTEGER);
186  break;
187  case 'S':
188  pointer = (UINT8**)head;
189  *pointer = tail;
190  *((ACPI_INTEGER*)tail) = element->Integer.Value;
191  head += sizeof(ACPI_INTEGER*);
192  tail += sizeof(ACPI_INTEGER);
193  /* NULL terminate string */
194  *tail = (char)0;
195  tail += sizeof(char);
196  break;
197  default:
198  /* Should never get here */
199  break;
200  }
201  break;
202 
203  case ACPI_TYPE_STRING:
204  case ACPI_TYPE_BUFFER:
205  switch (format_string[i]) {
206  case 'S':
207  pointer = (UINT8**)head;
208  *pointer = tail;
209  memcpy(tail, element->String.Pointer, element->String.Length);
210  head += sizeof(char*);
211  tail += element->String.Length * sizeof(char);
212  /* NULL terminate string */
213  *tail = (char)0;
214  tail += sizeof(char);
215  break;
216  case 'B':
217  pointer = (UINT8**)head;
218  *pointer = tail;
219  memcpy(tail, element->Buffer.Pointer, element->Buffer.Length);
220  head += sizeof(UINT8*);
221  tail += element->Buffer.Length * sizeof(UINT8);
222  break;
223  default:
224  /* Should never get here */
225  break;
226  }
227  break;
228 
229  case ACPI_TYPE_PACKAGE:
230  /* TBD: handle nested packages... */
231  default:
232  /* Should never get here */
233  break;
234  }
235  }
236 
238 }
struct outqueuenode * tail
Definition: adnsresfilter.c:66
UINT64 ACPI_INTEGER
Definition: actypes.h:514
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
struct acpi_object::@604 Package
struct outqueuenode * head
Definition: adnsresfilter.c:66
GLsizei const GLvoid * pointer
Definition: glext.h:5848
#define ACPI_TYPE_BUFFER
Definition: actypes.h:682
#define ACPI_TYPE_INTEGER
Definition: actypes.h:680
unsigned char * PUCHAR
Definition: retypes.h:3
GLuint buffer
Definition: glext.h:5915
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define ACPI_TYPE_PACKAGE
Definition: actypes.h:683
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
#define AE_BUFFER_OVERFLOW
Definition: acexcep.h:119
unsigned int UINT32
smooth NULL
Definition: ftsmooth.c:416
unsigned char
Definition: typeof.h:29
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define AE_SUPPORT
Definition: acexcep.h:123
const char * format_string(const WAVEFORMATEX *wfx)
Definition: capture.c:84
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define AE_BAD_DATA
Definition: acexcep.h:154
#define ACPI_DB_INFO
Definition: acoutput.h:153
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_TYPE_STRING
Definition: actypes.h:681
ACPI_OBJECT_TYPE Type
Definition: actypes.h:960
unsigned char UINT8
#define AE_OK
Definition: acexcep.h:97

◆ acpi_util_eval_error()

static void acpi_util_eval_error ( ACPI_HANDLE  h,
ACPI_STRING  p,
ACPI_STATUS  s 
)
static

Definition at line 40 of file utils.c.

41 {
42 #ifdef ACPI_DEBUG_OUTPUT
43  char prefix[80] = {'\0'};
44  ACPI_BUFFER buffer = {sizeof(prefix), prefix};
46  ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluate [%s.%s]: %s\n",
47  (char *) prefix, p, AcpiFormatException(s)));
48 #else
49  return;
50 #endif
51 }
GLuint buffer
Definition: glext.h:5915
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
const char * AcpiFormatException(ACPI_STATUS Status)
Definition: utexcep.c:70
ACPI_STATUS AcpiGetName(ACPI_HANDLE Handle, UINT32 NameType, ACPI_BUFFER *Buffer)
Definition: nsxfname.c:173
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
GLdouble s
Definition: gl.h:2039
#define ACPI_FULL_PATHNAME
Definition: actypes.h:1052
#define ACPI_DB_INFO
Definition: acoutput.h:153
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by acpi_evaluate_integer(), and acpi_evaluate_reference().