ReactOS  0.4.14-dev-599-g2d4d3f5
tbutils.c File Reference
#include "acpi.h"
#include "accommon.h"
#include "actables.h"
Include dependency graph for tbutils.c:

Go to the source code of this file.

Macros

#define _COMPONENT   ACPI_TABLES
 

Functions

static ACPI_PHYSICAL_ADDRESS AcpiTbGetRootTableEntry (UINT8 *TableEntry, UINT32 TableEntrySize)
 
ACPI_STATUS AcpiTbInitializeFacs (void)
 
void AcpiTbCheckDsdtHeader (void)
 
ACPI_TABLE_HEADERAcpiTbCopyDsdt (UINT32 TableIndex)
 
ACPI_STATUS ACPI_INIT_FUNCTION AcpiTbParseRootTable (ACPI_PHYSICAL_ADDRESS RsdpAddress)
 
ACPI_STATUS AcpiTbGetTable (ACPI_TABLE_DESC *TableDesc, ACPI_TABLE_HEADER **OutTable)
 
void AcpiTbPutTable (ACPI_TABLE_DESC *TableDesc)
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_TABLES

Definition at line 48 of file tbutils.c.

Function Documentation

◆ AcpiTbCheckDsdtHeader()

void AcpiTbCheckDsdtHeader ( void  )

Definition at line 124 of file tbutils.c.

126 {
127 
128  /* Compare original length and checksum to current values */
129 
130  if (AcpiGbl_OriginalDsdtHeader.Length != AcpiGbl_DSDT->Length ||
131  AcpiGbl_OriginalDsdtHeader.Checksum != AcpiGbl_DSDT->Checksum)
132  {
134  "The DSDT has been corrupted or replaced - "
135  "old, new headers below"));
136 
137  AcpiTbPrintTableHeader (0, &AcpiGbl_OriginalDsdtHeader);
138  AcpiTbPrintTableHeader (0, AcpiGbl_DSDT);
139 
140  /* Disable further error messages */
141 
142  AcpiGbl_OriginalDsdtHeader.Length = AcpiGbl_DSDT->Length;
143  AcpiGbl_OriginalDsdtHeader.Checksum = AcpiGbl_DSDT->Checksum;
144  }
145 }
#define AE_INFO
Definition: acoutput.h:230
#define ACPI_BIOS_ERROR(plist)
Definition: acoutput.h:243
void AcpiTbPrintTableHeader(ACPI_PHYSICAL_ADDRESS Address, ACPI_TABLE_HEADER *Header)
Definition: tbprint.c:141

Referenced by AcpiPsExecuteMethod().

◆ AcpiTbCopyDsdt()

ACPI_TABLE_HEADER* AcpiTbCopyDsdt ( UINT32  TableIndex)

Definition at line 163 of file tbutils.c.

165 {
166  ACPI_TABLE_HEADER *NewTable;
167  ACPI_TABLE_DESC *TableDesc;
168 
169 
170  TableDesc = &AcpiGbl_RootTableList.Tables[TableIndex];
171 
172  NewTable = ACPI_ALLOCATE (TableDesc->Length);
173  if (!NewTable)
174  {
175  ACPI_ERROR ((AE_INFO, "Could not copy DSDT of length 0x%X",
176  TableDesc->Length));
177  return (NULL);
178  }
179 
180  memcpy (NewTable, TableDesc->Pointer, TableDesc->Length);
181  AcpiTbUninstallTable (TableDesc);
182 
184  &AcpiGbl_RootTableList.Tables[AcpiGbl_DsdtIndex],
185  ACPI_PTR_TO_PHYSADDR (NewTable),
187 
188  ACPI_INFO ((
189  "Forced DSDT copy: length 0x%05X copied locally, original unmapped",
190  NewTable->Length));
191 
192  return (NewTable);
193 }
UINT32 Length
Definition: actbl.h:109
void AcpiTbUninstallTable(ACPI_TABLE_DESC *TableDesc)
Definition: tbinstal.c:333
#define ACPI_ALLOCATE(a)
Definition: actypes.h:384
smooth NULL
Definition: ftsmooth.c:416
#define AE_INFO
Definition: acoutput.h:230
ACPI_TABLE_HEADER * Pointer
Definition: actbl.h:404
#define ACPI_PTR_TO_PHYSADDR(i)
Definition: actypes.h:556
#define ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL
Definition: actbl.h:431
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ACPI_INFO(plist)
Definition: acoutput.h:237
void AcpiTbInitTableDescriptor(ACPI_TABLE_DESC *TableDesc, ACPI_PHYSICAL_ADDRESS Address, UINT8 Flags, ACPI_TABLE_HEADER *Table)
Definition: tbdata.c:130
UINT32 Length
Definition: actbl.h:405
#define ACPI_ERROR(plist)
Definition: acoutput.h:240

Referenced by AcpiTbLoadNamespace().

◆ AcpiTbGetRootTableEntry()

static ACPI_PHYSICAL_ADDRESS AcpiTbGetRootTableEntry ( UINT8 TableEntry,
UINT32  TableEntrySize 
)
static

Definition at line 214 of file tbutils.c.

217 {
218  UINT64 Address64;
219 
220 
221  /*
222  * Get the table physical address (32-bit for RSDT, 64-bit for XSDT):
223  * Note: Addresses are 32-bit aligned (not 64) in both RSDT and XSDT
224  */
225  if (TableEntrySize == ACPI_RSDT_ENTRY_SIZE)
226  {
227  /*
228  * 32-bit platform, RSDT: Return 32-bit table entry
229  * 64-bit platform, RSDT: Expand 32-bit to 64-bit and return
230  */
231  return ((ACPI_PHYSICAL_ADDRESS) (*ACPI_CAST_PTR (
232  UINT32, TableEntry)));
233  }
234  else
235  {
236  /*
237  * 32-bit platform, XSDT: Truncate 64-bit to 32-bit and return
238  * 64-bit platform, XSDT: Move (unaligned) 64-bit to local,
239  * return 64-bit
240  */
241  ACPI_MOVE_64_TO_64 (&Address64, TableEntry);
242 
243 #if ACPI_MACHINE_WIDTH == 32
244  if (Address64 > ACPI_UINT32_MAX)
245  {
246  /* Will truncate 64-bit address to 32 bits, issue warning */
247 
249  "64-bit Physical Address in XSDT is too large (0x%8.8X%8.8X),"
250  " truncating",
251  ACPI_FORMAT_UINT64 (Address64)));
252  }
253 #endif
254  return ((ACPI_PHYSICAL_ADDRESS) (Address64));
255  }
256 }
#define ACPI_RSDT_ENTRY_SIZE
Definition: actbl.h:208
unsigned int UINT32
#define AE_INFO
Definition: acoutput.h:230
#define ACPI_UINT32_MAX
Definition: actypes.h:66
#define ACPI_FORMAT_UINT64(i)
Definition: acmacros.h:71
_Must_inspect_result_ typedef _In_ ULONG TableEntry
Definition: iotypes.h:3947
#define ACPI_MOVE_64_TO_64(d, s)
Definition: acmacros.h:155
unsigned long long UINT64
#define ACPI_CAST_PTR(t, p)
Definition: actypes.h:544
#define ACPI_BIOS_WARNING(plist)
Definition: acoutput.h:241

Referenced by AcpiTbParseRootTable().

◆ AcpiTbGetTable()

ACPI_STATUS AcpiTbGetTable ( ACPI_TABLE_DESC TableDesc,
ACPI_TABLE_HEADER **  OutTable 
)

Definition at line 433 of file tbutils.c.

436 {
438 
439 
441 
442 
443  if (TableDesc->ValidationCount == 0)
444  {
445  /* Table need to be "VALIDATED" */
446 
447  Status = AcpiTbValidateTable (TableDesc);
448  if (ACPI_FAILURE (Status))
449  {
451  }
452  }
453 
455  {
456  TableDesc->ValidationCount++;
457 
458  /*
459  * Detect ValidationCount overflows to ensure that the warning
460  * message will only be printed once.
461  */
463  {
465  "Table %p, Validation count overflows\n", TableDesc));
466  }
467  }
468 
469  *OutTable = TableDesc->Pointer;
471 }
#define ACPI_WARNING(plist)
Definition: acoutput.h:238
ACPI_STATUS AcpiTbGetTable(ACPI_TABLE_DESC *TableDesc, ACPI_TABLE_HEADER **OutTable)
Definition: tbutils.c:433
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
UINT16 ValidationCount
Definition: actbl.h:409
#define AE_INFO
Definition: acoutput.h:230
ACPI_TABLE_HEADER * Pointer
Definition: actbl.h:404
Status
Definition: gdiplustypes.h:24
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_MAX_TABLE_VALIDATIONS
Definition: actbl.h:425
ACPI_STATUS AcpiTbValidateTable(ACPI_TABLE_DESC *TableDesc)
Definition: tbdata.c:353
#define AE_OK
Definition: acexcep.h:97

Referenced by AcpiGetTable(), AcpiGetTableByIndex(), and AcpiTbParseFadt().

◆ AcpiTbInitializeFacs()

ACPI_STATUS AcpiTbInitializeFacs ( void  )

Definition at line 75 of file tbutils.c.

77 {
78  ACPI_TABLE_FACS *Facs;
79 
80 
81  /* If Hardware Reduced flag is set, there is no FACS */
82 
83  if (AcpiGbl_ReducedHardware)
84  {
85  AcpiGbl_FACS = NULL;
86  return (AE_OK);
87  }
88  else if (AcpiGbl_FADT.XFacs &&
89  (!AcpiGbl_FADT.Facs || !AcpiGbl_Use32BitFacsAddresses))
90  {
91  (void) AcpiGetTableByIndex (AcpiGbl_XFacsIndex,
93  AcpiGbl_FACS = Facs;
94  }
95  else if (AcpiGbl_FADT.Facs)
96  {
97  (void) AcpiGetTableByIndex (AcpiGbl_FacsIndex,
99  AcpiGbl_FACS = Facs;
100  }
101 
102  /* If there is no FACS, just continue. There was already an error msg */
103 
104  return (AE_OK);
105 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
ACPI_STATUS AcpiGetTableByIndex(UINT32 TableIndex, ACPI_TABLE_HEADER **OutTable)
Definition: tbxface.c:491
smooth NULL
Definition: ftsmooth.c:416
#define ACPI_CAST_INDIRECT_PTR(t, p)
Definition: actypes.h:545
#define AE_OK
Definition: acexcep.h:97

Referenced by AcpiEnableSubsystem().

◆ AcpiTbParseRootTable()

ACPI_STATUS ACPI_INIT_FUNCTION AcpiTbParseRootTable ( ACPI_PHYSICAL_ADDRESS  RsdpAddress)

Definition at line 277 of file tbutils.c.

279 {
280  ACPI_TABLE_RSDP *Rsdp;
281  UINT32 TableEntrySize;
282  UINT32 i;
283  UINT32 TableCount;
285  ACPI_PHYSICAL_ADDRESS Address;
286  UINT32 Length;
287  UINT8 *TableEntry;
289  UINT32 TableIndex;
290 
291 
292  ACPI_FUNCTION_TRACE (TbParseRootTable);
293 
294 
295  /* Map the entire RSDP and extract the address of the RSDT or XSDT */
296 
297  Rsdp = AcpiOsMapMemory (RsdpAddress, sizeof (ACPI_TABLE_RSDP));
298  if (!Rsdp)
299  {
301  }
302 
303  AcpiTbPrintTableHeader (RsdpAddress,
305 
306  /* Use XSDT if present and not overridden. Otherwise, use RSDT */
307 
308  if ((Rsdp->Revision > 1) &&
309  Rsdp->XsdtPhysicalAddress &&
310  !AcpiGbl_DoNotUseXsdt)
311  {
312  /*
313  * RSDP contains an XSDT (64-bit physical addresses). We must use
314  * the XSDT if the revision is > 1 and the XSDT pointer is present,
315  * as per the ACPI specification.
316  */
317  Address = (ACPI_PHYSICAL_ADDRESS) Rsdp->XsdtPhysicalAddress;
318  TableEntrySize = ACPI_XSDT_ENTRY_SIZE;
319  }
320  else
321  {
322  /* Root table is an RSDT (32-bit physical addresses) */
323 
324  Address = (ACPI_PHYSICAL_ADDRESS) Rsdp->RsdtPhysicalAddress;
325  TableEntrySize = ACPI_RSDT_ENTRY_SIZE;
326  }
327 
328  /*
329  * It is not possible to map more than one entry in some environments,
330  * so unmap the RSDP here before mapping other tables
331  */
332  AcpiOsUnmapMemory (Rsdp, sizeof (ACPI_TABLE_RSDP));
333 
334  /* Map the RSDT/XSDT table header to get the full table length */
335 
337  if (!Table)
338  {
340  }
341 
343 
344  /*
345  * Validate length of the table, and map entire table.
346  * Minimum length table must contain at least one entry.
347  */
348  Length = Table->Length;
350 
351  if (Length < (sizeof (ACPI_TABLE_HEADER) + TableEntrySize))
352  {
354  "Invalid table length 0x%X in RSDT/XSDT", Length));
356  }
357 
359  if (!Table)
360  {
362  }
363 
364  /* Validate the root table checksum */
365 
367  if (ACPI_FAILURE (Status))
368  {
371  }
372 
373  /* Get the number of entries and pointer to first entry */
374 
375  TableCount = (UINT32) ((Table->Length - sizeof (ACPI_TABLE_HEADER)) /
376  TableEntrySize);
378 
379  /* Initialize the root table array from the RSDT/XSDT */
380 
381  for (i = 0; i < TableCount; i++)
382  {
383  /* Get the table physical address (32-bit for RSDT, 64-bit for XSDT) */
384 
385  Address = AcpiTbGetRootTableEntry (TableEntry, TableEntrySize);
386 
387  /* Skip NULL entries in RSDT/XSDT */
388 
389  if (!Address)
390  {
391  goto NextTable;
392  }
393 
396 
397  if (ACPI_SUCCESS (Status) &&
399  &AcpiGbl_RootTableList.Tables[TableIndex].Signature,
400  ACPI_SIG_FADT))
401  {
402  AcpiGbl_FadtIndex = TableIndex;
403  AcpiTbParseFadt ();
404  }
405 
406 NextTable:
407 
408  TableEntry += TableEntrySize;
409  }
410 
413 }
ASMGENDATA Table[]
Definition: genincdata.c:61
#define TRUE
Definition: types.h:120
#define ACPI_SUCCESS(a)
Definition: acexcep.h:94
#define AE_NO_MEMORY
Definition: acexcep.h:112
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
void * AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS Where, ACPI_SIZE Length)
Definition: osl.c:108
#define ACPI_XSDT_ENTRY_SIZE
Definition: actbl.h:209
UINT32 ACPI_STATUS
Definition: actypes.h:460
ACPI_STATUS AcpiTbInstallStandardTable(ACPI_PHYSICAL_ADDRESS Address, UINT8 Flags, BOOLEAN Reload, BOOLEAN Override, UINT32 *TableIndex)
Definition: tbinstal.c:137
#define ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL
Definition: actbl.h:430
#define ACPI_RSDT_ENTRY_SIZE
Definition: actbl.h:208
#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
#define AE_INFO
Definition: acoutput.h:230
static WCHAR Address[46]
Definition: ping.c:68
#define ACPI_BIOS_ERROR(plist)
Definition: acoutput.h:243
UINT64 XsdtPhysicalAddress
Definition: actbl.h:157
UINT8 Revision
Definition: actbl.h:154
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define ACPI_COMPARE_NAMESEG(a, b)
Definition: actypes.h:561
void AcpiTbParseFadt(void)
Definition: tbfadt.c:339
UINT32 RsdtPhysicalAddress
Definition: actbl.h:155
#define ACPI_SIG_FADT
Definition: actbl.h:68
Status
Definition: gdiplustypes.h:24
void AcpiTbPrintTableHeader(ACPI_PHYSICAL_ADDRESS Address, ACPI_TABLE_HEADER *Header)
Definition: tbprint.c:141
ACPI_STATUS AcpiTbVerifyChecksum(ACPI_TABLE_HEADER *Table, UINT32 Length)
Definition: tbprint.c:203
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
_Must_inspect_result_ typedef _In_ ULONG TableEntry
Definition: iotypes.h:3947
static ACPI_PHYSICAL_ADDRESS AcpiTbGetRootTableEntry(UINT8 *TableEntry, UINT32 TableEntrySize)
Definition: tbutils.c:214
#define AE_INVALID_TABLE_LENGTH
Definition: acexcep.h:171
#define ACPI_ADD_PTR(t, a, b)
Definition: actypes.h:546
#define ACPI_CAST_PTR(t, p)
Definition: actypes.h:544
unsigned char UINT8
#define AE_OK
Definition: acexcep.h:97
void AcpiOsUnmapMemory(void *LogicalAddress, ACPI_SIZE Size)
Definition: osl.c:128

Referenced by AcpiInitializeTables().

◆ AcpiTbPutTable()

void AcpiTbPutTable ( ACPI_TABLE_DESC TableDesc)

Definition at line 490 of file tbutils.c.

492 {
493 
495 
496 
498  {
499  TableDesc->ValidationCount--;
500 
501  /*
502  * Detect ValidationCount underflows to ensure that the warning
503  * message will only be printed once.
504  */
506  {
508  "Table %p, Validation count underflows\n", TableDesc));
509  return_VOID;
510  }
511  }
512 
513  if (TableDesc->ValidationCount == 0)
514  {
515  /* Table need to be "INVALIDATED" */
516 
517  AcpiTbInvalidateTable (TableDesc);
518  }
519 
520  return_VOID;
521 }
#define ACPI_WARNING(plist)
Definition: acoutput.h:238
UINT16 ValidationCount
Definition: actbl.h:409
#define AE_INFO
Definition: acoutput.h:230
void AcpiTbPutTable(ACPI_TABLE_DESC *TableDesc)
Definition: tbutils.c:490
#define return_VOID
Definition: acoutput.h:495
void AcpiTbInvalidateTable(ACPI_TABLE_DESC *TableDesc)
Definition: tbdata.c:392
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_MAX_TABLE_VALIDATIONS
Definition: actbl.h:425

Referenced by AcpiPutTable(), and AcpiTbParseFadt().