ReactOS  0.4.14-dev-52-g6116262
halacpi.c File Reference
#include <hal.h>
#include <debug.h>
Include dependency graph for halacpi.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

PDESCRIPTION_HEADER NTAPI HalpAcpiGetCachedTable (IN ULONG Signature)
 
VOID NTAPI HalpAcpiCacheTable (IN PDESCRIPTION_HEADER TableHeader)
 
PVOID NTAPI HalpAcpiCopyBiosTable (IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN PDESCRIPTION_HEADER TableHeader)
 
PVOID NTAPI HalpAcpiGetTableFromBios (IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG Signature)
 
PVOID NTAPI HalpAcpiGetTable (IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG Signature)
 
PVOID NTAPI HalAcpiGetTable (IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG Signature)
 
VOID NTAPI HalpNumaInitializeStaticConfiguration (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
VOID NTAPI HalpGetHotPlugMemoryInfo (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
VOID NTAPI HalpDynamicSystemResourceConfiguration (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
VOID NTAPI HalpAcpiDetectMachineSpecificActions (IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN PFADT DescriptionTable)
 
VOID NTAPI HalpInitBootTable (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
NTSTATUS NTAPI HalpAcpiFindRsdtPhase0 (IN PLOADER_PARAMETER_BLOCK LoaderBlock, OUT PACPI_BIOS_MULTI_NODE *AcpiMultiNode)
 
NTSTATUS NTAPI HalpAcpiTableCacheInit (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
VOID NTAPI HaliAcpiTimerInit (IN ULONG TimerPort, IN ULONG TimerValExt)
 
INIT_FUNCTION NTSTATUS NTAPI HalpSetupAcpiPhase0 (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
INIT_FUNCTION VOID NTAPI HalpInitializePciBus (VOID)
 
VOID NTAPI HalpInitNonBusHandler (VOID)
 
INIT_FUNCTION VOID NTAPI HalpInitBusHandlers (VOID)
 
INIT_FUNCTION VOID NTAPI HalpBuildAddressMap (VOID)
 
INIT_FUNCTION BOOLEAN NTAPI HalpGetDebugPortTable (VOID)
 
INIT_FUNCTION ULONG NTAPI HalpIs16BitPortDecodeSupported (VOID)
 
VOID NTAPI HalpAcpiDetectResourceListSize (OUT PULONG ListSize)
 
NTSTATUS NTAPI HalpBuildAcpiResourceList (IN PIO_RESOURCE_REQUIREMENTS_LIST ResourceList)
 
NTSTATUS NTAPI HalpQueryAcpiResourceRequirements (OUT PIO_RESOURCE_REQUIREMENTS_LIST *Requirements)
 
INIT_FUNCTION VOID NTAPI HalReportResourceUsage (VOID)
 

Variables

LIST_ENTRY HalpAcpiTableCacheList
 
FAST_MUTEX HalpAcpiTableCacheLock
 
BOOLEAN HalpProcessedACPIPhase0
 
BOOLEAN HalpPhysicalMemoryMayAppearAbove4GB
 
FADT HalpFixedAcpiDescTable
 
PDEBUG_PORT_TABLE HalpDebugPortTable
 
PACPI_SRAT HalpAcpiSrat
 
PBOOT_TABLE HalpSimpleBootFlagTable
 
PHYSICAL_ADDRESS HalpMaxHotPlugMemoryAddress
 
PHYSICAL_ADDRESS HalpLowStubPhysicalAddress
 
PHARDWARE_PTE HalpPteForFlush
 
PVOID HalpVirtAddrForFlush
 
PVOID HalpLowStub
 
PACPI_BIOS_MULTI_NODE HalpAcpiMultiNode
 
LIST_ENTRY HalpAcpiTableMatchList
 
ULONG HalpInvalidAcpiTable
 
ULONG HalpPicVectorRedirect [] = {0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15}
 
BOOLEAN HalDisableFirmwareMapper = TRUE
 
PWCHAR HalHardwareIdString = L"acpipic_up"
 
PWCHAR HalName = L"ACPI Compatible Eisa/Isa HAL"
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file halacpi.c.

Function Documentation

◆ HalAcpiGetTable()

PVOID NTAPI HalAcpiGetTable ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock,
IN ULONG  Signature 
)

Definition at line 446 of file halacpi.c.

448 {
449  PDESCRIPTION_HEADER TableHeader;
450 
451  /* Is this phase0 */
452  if (LoaderBlock)
453  {
454  /* Initialize the cache first */
455  if (!NT_SUCCESS(HalpAcpiTableCacheInit(LoaderBlock))) return NULL;
456  }
457  else
458  {
459  /* Lock the cache */
461  }
462 
463  /* Get the table */
464  TableHeader = HalpAcpiGetTable(LoaderBlock, Signature);
465 
466  /* Release the lock in phase 1 */
467  if (!LoaderBlock) ExReleaseFastMutex(&HalpAcpiTableCacheLock);
468 
469  /* Return the table */
470  return TableHeader;
471 }
FAST_MUTEX HalpAcpiTableCacheLock
Definition: halacpi.c:18
VOID FASTCALL ExReleaseFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:31
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PVOID NTAPI HalpAcpiGetTable(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG Signature)
Definition: halacpi.c:404
NTSTATUS NTAPI HalpAcpiTableCacheInit(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halacpi.c:642
VOID FASTCALL ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:23
static const WCHAR Signature[]
Definition: parser.c:141

Referenced by HalpGetHotPlugMemoryInfo(), HalpInitBootTable(), HalpNumaInitializeStaticConfiguration(), HalpReportDetectedDevices(), and HalpSetupAcpiPhase0().

◆ HaliAcpiTimerInit()

VOID NTAPI HaliAcpiTimerInit ( IN ULONG  TimerPort,
IN ULONG  TimerValExt 
)

Definition at line 771 of file halacpi.c.

773 {
774  PAGED_CODE();
775 
776  /* Is this in the init phase? */
777  if (!TimerPort)
778  {
779  /* Get the data from the FADT */
782  DPRINT1("ACPI Timer at: %Xh (EXT: %d)\n", TimerPort, TimerValExt);
783  }
784 
785  /* FIXME: Now proceed to the timer initialization */
786  //HalaAcpiTimerInit(TimerPort, TimerValExt);
787 }
ULONG flags
Definition: acpi.h:162
#define PAGED_CODE()
Definition: video.h:57
#define ACPI_TMR_VAL_EXT
Definition: acpi.h:48
ULONG pm_tmr_blk_io_port
Definition: acpi.h:140
#define DPRINT1
Definition: precomp.h:8
FADT HalpFixedAcpiDescTable
Definition: halacpi.c:23

Referenced by HalpSetupAcpiPhase0().

◆ HalpAcpiCacheTable()

VOID NTAPI HalpAcpiCacheTable ( IN PDESCRIPTION_HEADER  TableHeader)

Definition at line 77 of file halacpi.c.

78 {
79  PACPI_CACHED_TABLE CachedTable;
80 
81  /* Get the cached table and link it */
82  CachedTable = CONTAINING_RECORD(TableHeader, ACPI_CACHED_TABLE, Header);
84 }
#define InsertTailList(ListHead, Entry)
Definition: Header.h:8
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
LIST_ENTRY HalpAcpiTableCacheList
Definition: halacpi.c:17
LIST_ENTRY Links
Definition: halacpi.h:8

Referenced by HalpAcpiGetTable(), and HalpAcpiTableCacheInit().

◆ HalpAcpiCopyBiosTable()

PVOID NTAPI HalpAcpiCopyBiosTable ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock,
IN PDESCRIPTION_HEADER  TableHeader 
)

Definition at line 88 of file halacpi.c.

90 {
91  ULONG Size;
92  PFN_COUNT PageCount;
93  PHYSICAL_ADDRESS PhysAddress;
94  PACPI_CACHED_TABLE CachedTable;
95  PDESCRIPTION_HEADER CopiedTable;
96 
97  /* Size we'll need for the cached table */
98  Size = TableHeader->Length + FIELD_OFFSET(ACPI_CACHED_TABLE, Header);
99  if (LoaderBlock)
100  {
101  /* Phase 0: Convert to pages and use the HAL heap */
102  PageCount = BYTES_TO_PAGES(Size);
103  PhysAddress.QuadPart = HalpAllocPhysicalMemory(LoaderBlock,
104  0x1000000,
105  PageCount,
106  FALSE);
107  if (PhysAddress.QuadPart)
108  {
109  /* Map it */
110  CachedTable = HalpMapPhysicalMemory64(PhysAddress, PageCount);
111  }
112  else
113  {
114  /* No memory, so nothing to map */
115  CachedTable = NULL;
116  }
117  }
118  else
119  {
120  /* Use Mm pool */
122  }
123 
124  /* Do we have the cached table? */
125  if (CachedTable)
126  {
127  /* Copy the data */
128  CopiedTable = &CachedTable->Header;
129  RtlCopyMemory(CopiedTable, TableHeader, TableHeader->Length);
130  }
131  else
132  {
133  /* Nothing to return */
134  CopiedTable = NULL;
135  }
136 
137  /* Return the table */
138  return CopiedTable;
139 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
DESCRIPTION_HEADER Header
Definition: halacpi.h:9
ULONG PFN_COUNT
Definition: mmtypes.h:102
Definition: Header.h:8
PVOID NTAPI HalpMapPhysicalMemory64(IN PHYSICAL_ADDRESS PhysicalAddress, IN ULONG NumberPage)
Definition: misc.c:28
smooth NULL
Definition: ftsmooth.c:416
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define BYTES_TO_PAGES(Size)
#define TAG_HAL
Definition: hal.h:55
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
ULONG Length
Definition: acpi.h:97
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
unsigned int ULONG
Definition: retypes.h:1
ULONG64 NTAPI HalpAllocPhysicalMemory(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG64 MaxAddress, IN PFN_NUMBER PageCount, IN BOOLEAN Aligned)
Definition: memory.c:29
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by HalpAcpiGetTable(), and HalpAcpiTableCacheInit().

◆ HalpAcpiDetectMachineSpecificActions()

VOID NTAPI HalpAcpiDetectMachineSpecificActions ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock,
IN PFADT  DescriptionTable 
)

Definition at line 507 of file halacpi.c.

509 {
510  /* Does this HAL specify something? */
512  {
513  /* Great, but we don't support it */
514  DPRINT1("WARNING: Your HAL has specific ACPI hacks to apply!\n");
515  }
516 }
LIST_ENTRY HalpAcpiTableMatchList
Definition: halacpi.c:36
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define DPRINT1
Definition: precomp.h:8

Referenced by HalpSetupAcpiPhase0().

◆ HalpAcpiDetectResourceListSize()

VOID NTAPI HalpAcpiDetectResourceListSize ( OUT PULONG  ListSize)

Definition at line 969 of file halacpi.c.

970 {
971  PAGED_CODE();
972 
973  /* One element if there is a SCI */
974  *ListSize = HalpFixedAcpiDescTable.sci_int_vector ? 1: 0;
975 }
USHORT sci_int_vector
Definition: acpi.h:129
#define PAGED_CODE()
Definition: video.h:57
FADT HalpFixedAcpiDescTable
Definition: halacpi.c:23

Referenced by HalpQueryAcpiResourceRequirements().

◆ HalpAcpiFindRsdtPhase0()

NTSTATUS NTAPI HalpAcpiFindRsdtPhase0 ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock,
OUT PACPI_BIOS_MULTI_NODE AcpiMultiNode 
)

Definition at line 547 of file halacpi.c.

549 {
550  PCONFIGURATION_COMPONENT_DATA ComponentEntry;
553  PACPI_BIOS_MULTI_NODE NodeData;
554  SIZE_T NodeLength;
555  PFN_COUNT PageCount;
556  PVOID MappedAddress;
558 
559  /* Did we already do this once? */
560  if (HalpAcpiMultiNode)
561  {
562  /* Return what we know */
563  *AcpiMultiNode = HalpAcpiMultiNode;
564  return STATUS_SUCCESS;
565  }
566 
567  /* Assume failure */
568  *AcpiMultiNode = NULL;
569 
570  /* Find the multi function adapter key */
571  ComponentEntry = KeFindConfigurationNextEntry(LoaderBlock->ConfigurationRoot,
572  AdapterClass,
573  MultiFunctionAdapter,
574  0,
575  &Next);
576  while (ComponentEntry)
577  {
578  /* Find the ACPI BIOS key */
579  if (!_stricmp(ComponentEntry->ComponentEntry.Identifier, "ACPI BIOS"))
580  {
581  /* Found it */
582  break;
583  }
584 
585  /* Keep searching */
586  Next = ComponentEntry;
587  ComponentEntry = KeFindConfigurationNextEntry(LoaderBlock->ConfigurationRoot,
588  AdapterClass,
589  MultiFunctionAdapter,
590  NULL,
591  &Next);
592  }
593 
594  /* Make sure we found it */
595  if (!ComponentEntry)
596  {
597  DPRINT1("**** HalpAcpiFindRsdtPhase0: did NOT find RSDT\n");
598  return STATUS_NOT_FOUND;
599  }
600 
601  /* The configuration data is a resource list, and the BIOS node follows */
602  ResourceList = ComponentEntry->ConfigurationData;
603  NodeData = (PACPI_BIOS_MULTI_NODE)(ResourceList + 1);
604 
605  /* How many E820 memory entries are there? */
606  NodeLength = sizeof(ACPI_BIOS_MULTI_NODE) +
607  (NodeData->Count - 1) * sizeof(ACPI_E820_ENTRY);
608 
609  /* Convert to pages */
610  PageCount = (PFN_COUNT)BYTES_TO_PAGES(NodeLength);
611 
612  /* Allocate the memory */
614  0x1000000,
615  PageCount,
616  FALSE);
618  {
619  /* Map it if the allocation worked */
620  MappedAddress = HalpMapPhysicalMemory64(PhysicalAddress, PageCount);
621  }
622  else
623  {
624  /* Otherwise we'll have to fail */
625  MappedAddress = NULL;
626  }
627 
628  /* Save the multi node, bail out if we didn't find it */
629  HalpAcpiMultiNode = MappedAddress;
630  if (!MappedAddress) return STATUS_INSUFFICIENT_RESOURCES;
631 
632  /* Copy the multi-node data */
633  RtlCopyMemory(MappedAddress, NodeData, NodeLength);
634 
635  /* Return the data */
636  *AcpiMultiNode = HalpAcpiMultiNode;
637  return STATUS_SUCCESS;
638 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
ULONG PFN_COUNT
Definition: mmtypes.h:102
PACPI_BIOS_MULTI_NODE HalpAcpiMultiNode
Definition: halacpi.c:34
struct _ACPI_BIOS_MULTI_NODE * PACPI_BIOS_MULTI_NODE
struct _ACPI_BIOS_MULTI_NODE ACPI_BIOS_MULTI_NODE
const MUI_LANGUAGE_RESOURCE ResourceList[]
Definition: muilanguages.h:414
#define _stricmp
Definition: cat.c:22
struct _ACPI_E820_ENTRY ACPI_E820_ENTRY
PVOID NTAPI HalpMapPhysicalMemory64(IN PHYSICAL_ADDRESS PhysicalAddress, IN ULONG NumberPage)
Definition: misc.c:28
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_NOT_FOUND
Definition: shellext.h:67
#define BYTES_TO_PAGES(Size)
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1061
CONFIGURATION_COMPONENT ComponentEntry
Definition: arc.h:121
ULONGLONG Count
Definition: acpi.h:22
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define DPRINT1
Definition: precomp.h:8
ULONG64 NTAPI HalpAllocPhysicalMemory(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG64 MaxAddress, IN PFN_NUMBER PageCount, IN BOOLEAN Aligned)
Definition: memory.c:29
INIT_FUNCTION PCONFIGURATION_COMPONENT_DATA NTAPI KeFindConfigurationNextEntry(IN PCONFIGURATION_COMPONENT_DATA Child, IN CONFIGURATION_CLASS Class, IN CONFIGURATION_TYPE Type, IN PULONG ComponentKey OPTIONAL, IN PCONFIGURATION_COMPONENT_DATA *NextLink)
Definition: config.c:44
return STATUS_SUCCESS
Definition: btrfs.c:2966
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by HalpAcpiTableCacheInit().

◆ HalpAcpiGetCachedTable()

PDESCRIPTION_HEADER NTAPI HalpAcpiGetCachedTable ( IN ULONG  Signature)

Definition at line 51 of file halacpi.c.

52 {
53  PLIST_ENTRY ListHead, NextEntry;
54  PACPI_CACHED_TABLE CachedTable;
55 
56  /* Loop cached tables */
57  ListHead = &HalpAcpiTableCacheList;
58  NextEntry = ListHead->Flink;
59  while (NextEntry != ListHead)
60  {
61  /* Get the table */
62  CachedTable = CONTAINING_RECORD(NextEntry, ACPI_CACHED_TABLE, Links);
63 
64  /* Compare signatures */
65  if (CachedTable->Header.Signature == Signature) return &CachedTable->Header;
66 
67  /* Keep going */
68  NextEntry = NextEntry->Flink;
69  }
70 
71  /* Nothing found */
72  return NULL;
73 }
DESCRIPTION_HEADER Header
Definition: halacpi.h:9
ULONG Signature
Definition: acpi.h:96
smooth NULL
Definition: ftsmooth.c:416
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
Definition: typedefs.h:117
LIST_ENTRY HalpAcpiTableCacheList
Definition: halacpi.c:17
static const WCHAR Signature[]
Definition: parser.c:141

Referenced by HalpAcpiGetTable().

◆ HalpAcpiGetTable()

PVOID NTAPI HalpAcpiGetTable ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock,
IN ULONG  Signature 
)

Definition at line 404 of file halacpi.c.

406 {
407  PFN_COUNT PageCount;
408  PDESCRIPTION_HEADER TableAddress, BiosCopy;
409 
410  /* See if we have a cached table? */
411  TableAddress = HalpAcpiGetCachedTable(Signature);
412  if (!TableAddress)
413  {
414  /* No cache, search the BIOS */
415  TableAddress = HalpAcpiGetTableFromBios(LoaderBlock, Signature);
416  if (TableAddress)
417  {
418  /* Found it, copy it into our own memory */
419  BiosCopy = HalpAcpiCopyBiosTable(LoaderBlock, TableAddress);
420 
421  /* Get the pages, and unmap the BIOS copy */
422  PageCount = BYTES_TO_PAGES(TableAddress->Length);
423  if (LoaderBlock)
424  {
425  /* Phase 0, use the HAL heap */
426  HalpUnmapVirtualAddress(TableAddress, PageCount);
427  }
428  else
429  {
430  /* Phase 1, use Mm */
431  MmUnmapIoSpace(TableAddress, PageCount << PAGE_SHIFT);
432  }
433 
434  /* Cache the bios copy */
435  TableAddress = BiosCopy;
436  if (BiosCopy) HalpAcpiCacheTable(BiosCopy);
437  }
438  }
439 
440  /* Return the table */
441  return TableAddress;
442 }
VOID NTAPI HalpAcpiCacheTable(IN PDESCRIPTION_HEADER TableHeader)
Definition: halacpi.c:77
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
ULONG PFN_COUNT
Definition: mmtypes.h:102
PVOID NTAPI HalpAcpiCopyBiosTable(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN PDESCRIPTION_HEADER TableHeader)
Definition: halacpi.c:88
#define BYTES_TO_PAGES(Size)
VOID NTAPI HalpUnmapVirtualAddress(IN PVOID VirtualAddress, IN ULONG NumberPages)
Definition: misc.c:39
ULONG Length
Definition: acpi.h:97
PVOID NTAPI HalpAcpiGetTableFromBios(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG Signature)
Definition: halacpi.c:143
VOID NTAPI MmUnmapIoSpace(IN PVOID BaseAddress, IN SIZE_T NumberOfBytes)
Definition: iosup.c:193
static const WCHAR Signature[]
Definition: parser.c:141
PDESCRIPTION_HEADER NTAPI HalpAcpiGetCachedTable(IN ULONG Signature)
Definition: halacpi.c:51

Referenced by HalAcpiGetTable(), and HalpAcpiGetTableFromBios().

◆ HalpAcpiGetTableFromBios()

PVOID NTAPI HalpAcpiGetTableFromBios ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock,
IN ULONG  Signature 
)

Definition at line 143 of file halacpi.c.

145 {
147  PXSDT Xsdt;
148  PRSDT Rsdt;
149  PFADT Fadt;
151  ULONG TableLength;
152  CHAR CheckSum = 0;
153  ULONG Offset;
154  ULONG EntryCount, CurrentEntry;
155  PCHAR CurrentByte;
156  PFN_COUNT PageCount;
157 
158  /* Should not query the RSDT/XSDT by itself */
159  if ((Signature == RSDT_SIGNATURE) || (Signature == XSDT_SIGNATURE)) return NULL;
160 
161  /* Special case request for DSDT, because the FADT points to it */
162  if (Signature == DSDT_SIGNATURE)
163  {
164  /* Grab the FADT */
165  Fadt = HalpAcpiGetTable(LoaderBlock, FADT_SIGNATURE);
166  if (Fadt)
167  {
168  /* Grab the DSDT address and assume 2 pages */
170  PhysicalAddress.LowPart = Fadt->dsdt;
171  TableLength = 2 * PAGE_SIZE;
172 
173  /* Map it */
174  if (LoaderBlock)
175  {
176  /* Phase 0, use HAL heap */
178  }
179  else
180  {
181  /* Phase 1, use Mm */
183  }
184 
185  /* Fail if we couldn't map it */
186  if (!Header)
187  {
188  DPRINT1("HAL: Failed to map ACPI table.\n");
189  return NULL;
190  }
191 
192  /* Validate the signature */
193  if (Header->Signature != DSDT_SIGNATURE)
194  {
195  /* Fail and unmap */
196  if (LoaderBlock)
197  {
198  /* Using HAL heap */
200  }
201  else
202  {
203  /* Using Mm */
205  }
206 
207  /* Didn't find anything */
208  return NULL;
209  }
210  }
211  else
212  {
213  /* Couldn't find it */
214  return NULL;
215  }
216  }
217  else
218  {
219  /* To find tables, we need the RSDT */
220  Rsdt = HalpAcpiGetTable(LoaderBlock, RSDT_SIGNATURE);
221  if (Rsdt)
222  {
223  /* Won't be using the XSDT */
224  Xsdt = NULL;
225  }
226  else
227  {
228  /* Only other choice is to use the XSDT */
229  Xsdt = HalpAcpiGetTable(LoaderBlock, XSDT_SIGNATURE);
230  if (!Xsdt) return NULL;
231 
232  /* Won't be using the RSDT */
233  Rsdt = NULL;
234  }
235 
236  /* Smallest RSDT/XSDT is one without table entries */
237  Offset = FIELD_OFFSET(RSDT, Tables);
238  if (Xsdt)
239  {
240  /* Figure out total size of table and the offset */
241  TableLength = Xsdt->Header.Length;
242  if (TableLength < Offset) Offset = Xsdt->Header.Length;
243 
244  /* The entries are each 64-bits, so count them */
245  EntryCount = (TableLength - Offset) / sizeof(PHYSICAL_ADDRESS);
246  }
247  else
248  {
249  /* Figure out total size of table and the offset */
250  TableLength = Rsdt->Header.Length;
251  if (TableLength < Offset) Offset = Rsdt->Header.Length;
252 
253  /* The entries are each 32-bits, so count them */
254  EntryCount = (TableLength - Offset) / sizeof(ULONG);
255  }
256 
257  /* Start at the beginning of the array and loop it */
258  for (CurrentEntry = 0; CurrentEntry < EntryCount; CurrentEntry++)
259  {
260  /* Are we using the XSDT? */
261  if (!Xsdt)
262  {
263  /* Read the 32-bit physical address */
264  PhysicalAddress.LowPart = Rsdt->Tables[CurrentEntry];
266  }
267  else
268  {
269  /* Read the 64-bit physical address */
270  PhysicalAddress = Xsdt->Tables[CurrentEntry];
271  }
272 
273  /* Had we already mapped a table? */
274  if (Header)
275  {
276  /* Yes, unmap it */
277  if (LoaderBlock)
278  {
279  /* Using HAL heap */
281  }
282  else
283  {
284  /* Using Mm */
286  }
287  }
288 
289  /* Now map this table */
290  if (!LoaderBlock)
291  {
292  /* Phase 1: Use HAL heap */
294  }
295  else
296  {
297  /* Phase 0: Use Mm */
299  }
300 
301  /* Check if we mapped it */
302  if (!Header)
303  {
304  /* Game over */
305  DPRINT1("HAL: Failed to map ACPI table.\n");
306  return NULL;
307  }
308 
309  /* We found it, break out */
310  DPRINT("Found ACPI table %c%c%c%c at 0x%p\n",
311  Header->Signature & 0xFF,
312  (Header->Signature & 0xFF00) >> 8,
313  (Header->Signature & 0xFF0000) >> 16,
314  (Header->Signature & 0xFF000000) >> 24,
315  Header);
316  if (Header->Signature == Signature) break;
317  }
318 
319  /* Did we end up here back at the last entry? */
320  if (CurrentEntry == EntryCount)
321  {
322  /* Yes, unmap the last table we processed */
323  if (LoaderBlock)
324  {
325  /* Using HAL heap */
327  }
328  else
329  {
330  /* Using Mm */
332  }
333 
334  /* Didn't find anything */
335  return NULL;
336  }
337  }
338 
339  /* Past this point, we assume something was found */
340  ASSERT(Header);
341 
342  /* How many pages do we need? */
343  PageCount = BYTES_TO_PAGES(Header->Length);
344  if (PageCount != 2)
345  {
346  /* We assumed two, but this is not the case, free the current mapping */
347  if (LoaderBlock)
348  {
349  /* Using HAL heap */
351  }
352  else
353  {
354  /* Using Mm */
356  }
357 
358  /* Now map this table using its correct size */
359  if (!LoaderBlock)
360  {
361  /* Phase 1: Use HAL heap */
363  }
364  else
365  {
366  /* Phase 0: Use Mm */
368  }
369  }
370 
371  /* Fail if the remapped failed */
372  if (!Header) return NULL;
373 
374  /* All tables in ACPI 3.0 other than the FACP should have correct checksum */
375  if ((Header->Signature != FADT_SIGNATURE) || (Header->Revision > 2))
376  {
377  /* Go to the end of the table */
378  CheckSum = 0;
379  CurrentByte = (PCHAR)Header + Header->Length;
380  while (CurrentByte-- != (PCHAR)Header)
381  {
382  /* Add this byte */
383  CheckSum += *CurrentByte;
384  }
385 
386  /* The correct checksum is always 0, anything else is illegal */
387  if (CheckSum)
388  {
389  HalpInvalidAcpiTable = Header->Signature;
390  DPRINT1("Checksum failed on ACPI table %c%c%c%c\n",
391  (Signature & 0xFF),
392  (Signature & 0xFF00) >> 8,
393  (Signature & 0xFF0000) >> 16,
394  (Signature & 0xFF000000) >> 24);
395  }
396  }
397 
398  /* Return the table */
399  return Header;
400 }
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 * u
Definition: glfuncs.h:240
signed char * PCHAR
Definition: retypes.h:7
#define XSDT_SIGNATURE
Definition: acpi.h:39
Definition: acpi.h:193
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
ULONG HalpInvalidAcpiTable
Definition: halacpi.c:38
#define RSDT_SIGNATURE
Definition: acpi.h:32
ULONG PFN_COUNT
Definition: mmtypes.h:102
ULONG Tables[ANYSIZE_ARRAY]
Definition: acpi.h:189
char CHAR
Definition: xmlstorage.h:175
PVOID NTAPI MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, IN SIZE_T NumberOfBytes, IN MEMORY_CACHING_TYPE CacheType)
Definition: iosup.c:47
while(1)
Definition: macro.lex.yy.c:740
PHYSICAL_ADDRESS Tables[ANYSIZE_ARRAY]
Definition: acpi.h:196
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
Definition: Header.h:8
PVOID NTAPI HalpMapPhysicalMemory64(IN PHYSICAL_ADDRESS PhysicalAddress, IN ULONG NumberPage)
Definition: misc.c:28
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
DESCRIPTION_HEADER Header
Definition: acpi.h:195
#define PCHAR
Definition: match.c:90
ULONG dsdt
Definition: acpi.h:126
UCHAR CheckSum(LPSTR p, ULONG Len)
Definition: serial.c:197
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define BYTES_TO_PAGES(Size)
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1061
ULONG LowPart
Definition: typedefs.h:104
#define PAGE_SIZE
Definition: env_spec_w32.h:49
VOID NTAPI HalpUnmapVirtualAddress(IN PVOID VirtualAddress, IN ULONG NumberPages)
Definition: misc.c:39
PVOID NTAPI HalpAcpiGetTable(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG Signature)
Definition: halacpi.c:404
ULONG Length
Definition: acpi.h:97
Definition: acpi.h:122
VOID NTAPI MmUnmapIoSpace(IN PVOID BaseAddress, IN SIZE_T NumberOfBytes)
Definition: iosup.c:193
Definition: acpi.h:186
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define DSDT_SIGNATURE
Definition: acpi.h:34
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define FADT_SIGNATURE
Definition: acpi.h:31
static const WCHAR Signature[]
Definition: parser.c:141
DESCRIPTION_HEADER Header
Definition: acpi.h:188

Referenced by HalpAcpiGetTable().

◆ HalpAcpiTableCacheInit()

NTSTATUS NTAPI HalpAcpiTableCacheInit ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 642 of file halacpi.c.

643 {
644  PACPI_BIOS_MULTI_NODE AcpiMultiNode;
647  PVOID MappedAddress;
648  ULONG TableLength;
649  PRSDT Rsdt;
650  PLOADER_PARAMETER_EXTENSION LoaderExtension;
651 
652  /* Only initialize once */
653  if (HalpAcpiTableCacheList.Flink) return Status;
654 
655  /* Setup the lock and table */
658 
659  /* Find the RSDT */
660  Status = HalpAcpiFindRsdtPhase0(LoaderBlock, &AcpiMultiNode);
661  if (!NT_SUCCESS(Status)) return Status;
662 
663  PhysicalAddress.QuadPart = AcpiMultiNode->RsdtAddress.QuadPart;
664 
665  /* Map the RSDT */
666  if (LoaderBlock)
667  {
668  /* Phase0: Use HAL Heap to map the RSDT, we assume it's about 2 pages */
669  MappedAddress = HalpMapPhysicalMemory64(PhysicalAddress, 2);
670  }
671  else
672  {
673  /* Use an I/O map */
674  MappedAddress = MmMapIoSpace(PhysicalAddress, PAGE_SIZE * 2, MmNonCached);
675  }
676 
677  /* Get the RSDT */
678  Rsdt = MappedAddress;
679  if (!MappedAddress)
680  {
681  /* Fail, no memory */
682  DPRINT1("HAL: Failed to map RSDT\n");
684  }
685 
686  /* Validate it */
687  if ((Rsdt->Header.Signature != RSDT_SIGNATURE) &&
688  (Rsdt->Header.Signature != XSDT_SIGNATURE))
689  {
690  /* Very bad: crash */
691  HalDisplayString("Bad RSDT pointer\r\n");
692  KeBugCheckEx(MISMATCHED_HAL, 4, __LINE__, 0, 0);
693  }
694 
695  /* We assumed two pages -- do we need less or more? */
697  Rsdt->Header.Length);
698  if (TableLength != 2)
699  {
700  /* Are we in phase 0 or 1? */
701  if (!LoaderBlock)
702  {
703  /* Unmap the old table, remap the new one, using Mm I/O space */
704  MmUnmapIoSpace(MappedAddress, 2 * PAGE_SIZE);
705  MappedAddress = MmMapIoSpace(PhysicalAddress,
706  TableLength << PAGE_SHIFT,
707  MmNonCached);
708  }
709  else
710  {
711  /* Unmap the old table, remap the new one, using HAL heap */
712  HalpUnmapVirtualAddress(MappedAddress, 2);
713  MappedAddress = HalpMapPhysicalMemory64(PhysicalAddress, TableLength);
714  }
715 
716  /* Get the remapped table */
717  Rsdt = MappedAddress;
718  if (!MappedAddress)
719  {
720  /* Fail, no memory */
721  DPRINT1("HAL: Couldn't remap RSDT\n");
723  }
724  }
725 
726  /* Now take the BIOS copy and make our own local copy */
727  Rsdt = HalpAcpiCopyBiosTable(LoaderBlock, &Rsdt->Header);
728  if (!Rsdt)
729  {
730  /* Fail, no memory */
731  DPRINT1("HAL: Couldn't remap RSDT\n");
733  }
734 
735  /* Get rid of the BIOS mapping */
736  if (LoaderBlock)
737  {
738  /* Use HAL heap */
739  HalpUnmapVirtualAddress(MappedAddress, TableLength);
740 
741  LoaderExtension = LoaderBlock->Extension;
742  }
743  else
744  {
745  /* Use Mm */
746  MmUnmapIoSpace(MappedAddress, TableLength << PAGE_SHIFT);
747 
748  LoaderExtension = NULL;
749  }
750 
751  /* Cache the RSDT */
752  HalpAcpiCacheTable(&Rsdt->Header);
753 
754  /* Check for compatible loader block extension */
755  if (LoaderExtension && (LoaderExtension->Size >= 0x58))
756  {
757  /* Compatible loader: did it provide an ACPI table override? */
758  if ((LoaderExtension->AcpiTable) && (LoaderExtension->AcpiTableSize))
759  {
760  /* Great, because we don't support it! */
761  DPRINT1("ACPI Table Overrides Not Supported!\n");
762  }
763  }
764 
765  /* Done */
766  return Status;
767 }
VOID NTAPI HalpAcpiCacheTable(IN PDESCRIPTION_HEADER TableHeader)
Definition: halacpi.c:77
#define XSDT_SIGNATURE
Definition: acpi.h:39
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define RSDT_SIGNATURE
Definition: acpi.h:32
FAST_MUTEX HalpAcpiTableCacheLock
Definition: halacpi.c:18
LONG NTSTATUS
Definition: precomp.h:26
PVOID NTAPI MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, IN SIZE_T NumberOfBytes, IN MEMORY_CACHING_TYPE CacheType)
Definition: iosup.c:47
PVOID NTAPI HalpAcpiCopyBiosTable(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN PDESCRIPTION_HEADER TableHeader)
Definition: halacpi.c:88
PVOID NTAPI HalpMapPhysicalMemory64(IN PHYSICAL_ADDRESS PhysicalAddress, IN ULONG NumberPage)
Definition: misc.c:28
PHYSICAL_ADDRESS RsdtAddress
Definition: acpi.h:21
ULONG Signature
Definition: acpi.h:96
smooth NULL
Definition: ftsmooth.c:416
#define ADDRESS_AND_SIZE_TO_SPAN_PAGES(_Va, _Size)
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
NTSTATUS NTAPI HalpAcpiFindRsdtPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock, OUT PACPI_BIOS_MULTI_NODE *AcpiMultiNode)
Definition: halacpi.c:547
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1061
ULONG LowPart
Definition: typedefs.h:104
#define PAGE_SIZE
Definition: env_spec_w32.h:49
VOID NTAPI HalpUnmapVirtualAddress(IN PVOID VirtualAddress, IN ULONG NumberPages)
Definition: misc.c:39
Status
Definition: gdiplustypes.h:24
ULONG Length
Definition: acpi.h:97
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
VOID NTAPI MmUnmapIoSpace(IN PVOID BaseAddress, IN SIZE_T NumberOfBytes)
Definition: iosup.c:193
Definition: acpi.h:186
NTHALAPI VOID NTAPI HalDisplayString(PUCHAR String)
LIST_ENTRY HalpAcpiTableCacheList
Definition: halacpi.c:17
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2966
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:107
DESCRIPTION_HEADER Header
Definition: acpi.h:188
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by HalAcpiGetTable(), and HalpSetupAcpiPhase0().

◆ HalpBuildAcpiResourceList()

NTSTATUS NTAPI HalpBuildAcpiResourceList ( IN PIO_RESOURCE_REQUIREMENTS_LIST  ResourceList)

Definition at line 979 of file halacpi.c.

980 {
981  ULONG Interrupt;
982  PAGED_CODE();
984 
985  /* Initialize the list */
986  ResourceList->BusNumber = -1;
987  ResourceList->AlternativeLists = 1;
988  ResourceList->InterfaceType = PNPBus;
989  ResourceList->List[0].Version = 1;
990  ResourceList->List[0].Revision = 1;
991  ResourceList->List[0].Count = 0;
992 
993  /* Is there a SCI? */
995  {
996  /* Fill out the entry for it */
997  ResourceList->List[0].Descriptors[0].Flags = CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE;
998  ResourceList->List[0].Descriptors[0].Type = CmResourceTypeInterrupt;
999  ResourceList->List[0].Descriptors[0].ShareDisposition = CmResourceShareShared;
1000 
1001  /* Get the interrupt number */
1003  ResourceList->List[0].Descriptors[0].u.Interrupt.MinimumVector = Interrupt;
1004  ResourceList->List[0].Descriptors[0].u.Interrupt.MaximumVector = Interrupt;
1005 
1006  /* One more */
1007  ++ResourceList->List[0].Count;
1008  }
1009 
1010  /* All good */
1011  return STATUS_SUCCESS;
1012 }
USHORT sci_int_vector
Definition: acpi.h:129
const MUI_LANGUAGE_RESOURCE ResourceList[]
Definition: muilanguages.h:414
#define PAGED_CODE()
Definition: video.h:57
smooth NULL
Definition: ftsmooth.c:416
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ULONG HalpPicVectorRedirect[]
Definition: halacpi.c:40
#define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE
Definition: cmtypes.h:143
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
FADT HalpFixedAcpiDescTable
Definition: halacpi.c:23
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by HalpQueryAcpiResourceRequirements().

◆ HalpBuildAddressMap()

INIT_FUNCTION VOID NTAPI HalpBuildAddressMap ( VOID  )

Definition at line 944 of file halacpi.c.

945 {
946  /* ACPI is magic baby */
947 }

Referenced by HalpReportResourceUsage().

◆ HalpDynamicSystemResourceConfiguration()

VOID NTAPI HalpDynamicSystemResourceConfiguration ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 499 of file halacpi.c.

500 {
501  /* For this HAL, it means to get hot plug memory information */
502  HalpGetHotPlugMemoryInfo(LoaderBlock);
503 }
VOID NTAPI HalpGetHotPlugMemoryInfo(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halacpi.c:487

Referenced by HalpSetupAcpiPhase0().

◆ HalpGetDebugPortTable()

INIT_FUNCTION BOOLEAN NTAPI HalpGetDebugPortTable ( VOID  )

Definition at line 952 of file halacpi.c.

953 {
954  return ((HalpDebugPortTable) &&
956 }
PDEBUG_PORT_TABLE HalpDebugPortTable
Definition: halacpi.c:24
UCHAR AddressSpaceID
Definition: acpi.h:69
GEN_ADDR BaseAddress
Definition: acpi.h:209

Referenced by HalpReportResourceUsage().

◆ HalpGetHotPlugMemoryInfo()

VOID NTAPI HalpGetHotPlugMemoryInfo ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 487 of file halacpi.c.

488 {
489  PACPI_SRAT SratTable;
490 
491  /* Get the SRAT, bail out if it doesn't exist */
492  SratTable = HalAcpiGetTable(LoaderBlock, SRAT_SIGNATURE);
493  HalpAcpiSrat = SratTable;
494  if (!SratTable) return;
495 }
PVOID NTAPI HalAcpiGetTable(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG Signature)
Definition: halacpi.c:446
#define SRAT_SIGNATURE
Definition: acpi.h:41
PACPI_SRAT HalpAcpiSrat
Definition: halacpi.c:25

Referenced by HalpDynamicSystemResourceConfiguration().

◆ HalpInitBootTable()

VOID NTAPI HalpInitBootTable ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 520 of file halacpi.c.

521 {
522  PBOOT_TABLE BootTable;
523 
524  /* Get the boot table */
525  BootTable = HalAcpiGetTable(LoaderBlock, BOOT_SIGNATURE);
526  HalpSimpleBootFlagTable = BootTable;
527 
528  /* Validate it */
529  if ((BootTable) &&
530  (BootTable->Header.Length >= sizeof(BOOT_TABLE)) &&
531  (BootTable->CMOSIndex >= 9))
532  {
533  DPRINT1("ACPI Boot table found, but not supported!\n");
534  }
535  else
536  {
537  /* Invalid or doesn't exist, ignore it */
539  }
540 
541  /* Install the end of boot handler */
542 // HalEndOfBoot = HalpEndOfBoot;
543 }
#define BOOT_SIGNATURE
Definition: acpi.h:40
PVOID NTAPI HalAcpiGetTable(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG Signature)
Definition: halacpi.c:446
DESCRIPTION_HEADER Header
Definition: acpi.h:229
PBOOT_TABLE HalpSimpleBootFlagTable
Definition: halacpi.c:26
ULONG Length
Definition: acpi.h:97
#define DPRINT1
Definition: precomp.h:8
UCHAR CMOSIndex
Definition: acpi.h:230

Referenced by HalpSetupAcpiPhase0().

◆ HalpInitBusHandlers()

INIT_FUNCTION VOID NTAPI HalpInitBusHandlers ( VOID  )

Definition at line 935 of file halacpi.c.

936 {
937  /* On ACPI, we only have a fake PCI bus to worry about */
939 }
VOID NTAPI HalpInitNonBusHandler(VOID)
Definition: halacpi.c:924

Referenced by HalInitSystem().

◆ HalpInitializePciBus()

INIT_FUNCTION VOID NTAPI HalpInitializePciBus ( VOID  )

Definition at line 913 of file halacpi.c.

914 {
915  /* Setup the PCI stub support */
917 
918  /* Set the NMI crash flag */
920 }
VOID NTAPI HalpInitializePciStubs(VOID)
Definition: pci.c:674
INIT_FUNCTION VOID NTAPI HalpGetNMICrashFlag(VOID)
Definition: usage.c:571

Referenced by HalReportResourceUsage().

◆ HalpInitNonBusHandler()

VOID NTAPI HalpInitNonBusHandler ( VOID  )

Definition at line 924 of file halacpi.c.

925 {
926  /* These should be written by the PCI driver later, but we give defaults */
930 }
#define HalPciTranslateBusAddress
Definition: halfuncs.h:41
BOOLEAN NTAPI HalpFindBusAddressTranslation(IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress, IN OUT PULONG_PTR Context, IN BOOLEAN NextBus)
Definition: bus.c:98
NTSTATUS NTAPI HalpAssignSlotResources(IN PUNICODE_STRING RegistryPath, IN PUNICODE_STRING DriverClassName, IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT DeviceObject, IN INTERFACE_TYPE BusType, IN ULONG BusNumber, IN ULONG SlotNumber, IN OUT PCM_RESOURCE_LIST *AllocatedResources)
Definition: bus.c:39
BOOLEAN NTAPI HalpTranslateBusAddress(IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
Definition: bus.c:71
#define HalFindBusAddressTranslation
Definition: halfuncs.h:44
#define HalPciAssignSlotResources
Definition: halfuncs.h:42

Referenced by HalpInitBusHandlers().

◆ HalpIs16BitPortDecodeSupported()

INIT_FUNCTION ULONG NTAPI HalpIs16BitPortDecodeSupported ( VOID  )

Definition at line 961 of file halacpi.c.

962 {
963  /* All ACPI systems are at least "EISA" so they support this */
965 }
#define CM_RESOURCE_PORT_16_BIT_DECODE
Definition: cmtypes.h:112

Referenced by HalpBuildPartialFromAddress().

◆ HalpNumaInitializeStaticConfiguration()

VOID NTAPI HalpNumaInitializeStaticConfiguration ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 475 of file halacpi.c.

476 {
477  PACPI_SRAT SratTable;
478 
479  /* Get the SRAT, bail out if it doesn't exist */
480  SratTable = HalAcpiGetTable(LoaderBlock, SRAT_SIGNATURE);
481  HalpAcpiSrat = SratTable;
482  if (!SratTable) return;
483 }
PVOID NTAPI HalAcpiGetTable(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG Signature)
Definition: halacpi.c:446
#define SRAT_SIGNATURE
Definition: acpi.h:41
PACPI_SRAT HalpAcpiSrat
Definition: halacpi.c:25

Referenced by HalpSetupAcpiPhase0().

◆ HalpQueryAcpiResourceRequirements()

NTSTATUS NTAPI HalpQueryAcpiResourceRequirements ( OUT PIO_RESOURCE_REQUIREMENTS_LIST Requirements)

Definition at line 1016 of file halacpi.c.

1017 {
1018  PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList;
1019  ULONG Count = 0, ListSize;
1020  NTSTATUS Status;
1021  PAGED_CODE();
1022 
1023  /* Get ACPI resources */
1025  DPRINT("Resource count: %d\n", Count);
1026 
1027  /* Compute size of the list and allocate it */
1028  ListSize = FIELD_OFFSET(IO_RESOURCE_REQUIREMENTS_LIST, List[0].Descriptors) +
1029  (Count * sizeof(IO_RESOURCE_DESCRIPTOR));
1030  DPRINT("Resource list size: %d\n", ListSize);
1031  RequirementsList = ExAllocatePoolWithTag(PagedPool, ListSize, TAG_HAL);
1032  if (RequirementsList)
1033  {
1034  /* Initialize it */
1035  RtlZeroMemory(RequirementsList, ListSize);
1036  RequirementsList->ListSize = ListSize;
1037 
1038  /* Build it */
1039  Status = HalpBuildAcpiResourceList(RequirementsList);
1040  if (NT_SUCCESS(Status))
1041  {
1042  /* It worked, return it */
1043  *Requirements = RequirementsList;
1044 
1045  /* Validate the list */
1046  ASSERT(RequirementsList->List[0].Count == Count);
1047  }
1048  else
1049  {
1050  /* Fail */
1051  ExFreePoolWithTag(RequirementsList, TAG_HAL);
1053  }
1054  }
1055  else
1056  {
1057  /* Not enough memory */
1059  }
1060 
1061  /* Return the status */
1062  return Status;
1063 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
VOID NTAPI HalpAcpiDetectResourceListSize(OUT PULONG ListSize)
Definition: halacpi.c:969
NTSTATUS NTAPI HalpBuildAcpiResourceList(IN PIO_RESOURCE_REQUIREMENTS_LIST ResourceList)
Definition: halacpi.c:979
LONG NTSTATUS
Definition: precomp.h:26
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define PAGED_CODE()
Definition: video.h:57
void DPRINT(...)
Definition: polytest.cpp:61
LIST_ENTRY List
Definition: psmgr.c:57
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
IO_RESOURCE_LIST List[1]
Definition: iotypes.h:2393
#define TAG_HAL
Definition: hal.h:55
Status
Definition: gdiplustypes.h:24
struct _IO_RESOURCE_DESCRIPTOR IO_RESOURCE_DESCRIPTOR
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

Referenced by HalpQueryResourceRequirements(), and HalpQueryResources().

◆ HalpSetupAcpiPhase0()

INIT_FUNCTION NTSTATUS NTAPI HalpSetupAcpiPhase0 ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 792 of file halacpi.c.

793 {
795  PFADT Fadt;
796  ULONG TableLength;
798 
799  /* Only do this once */
801 
802  /* Setup the ACPI table cache */
803  Status = HalpAcpiTableCacheInit(LoaderBlock);
804  if (!NT_SUCCESS(Status)) return Status;
805 
806  /* Grab the FADT */
807  Fadt = HalAcpiGetTable(LoaderBlock, FADT_SIGNATURE);
808  if (!Fadt)
809  {
810  /* Fail */
811  DPRINT1("HAL: Didn't find the FACP\n");
812  return STATUS_NOT_FOUND;
813  }
814 
815  /* Assume typical size, otherwise whatever the descriptor table says */
816  TableLength = sizeof(FADT);
817  if (Fadt->Header.Length < sizeof(FADT)) TableLength = Fadt->Header.Length;
818 
819  /* Copy it in the HAL static buffer */
820  RtlCopyMemory(&HalpFixedAcpiDescTable, Fadt, TableLength);
821 
822  /* Anything special this HAL needs to do? */
824 
825  /* Get the debug table for KD */
827 
828  /* Initialize NUMA through the SRAT */
830 
831  /* Initialize hotplug through the SRAT */
833  if (HalpAcpiSrat)
834  {
835  DPRINT1("Your machine has a SRAT, but NUMA/HotPlug are not supported!\n");
836  }
837 
838  /* Can there be memory higher than 4GB? */
840  {
841  /* We'll need this for DMA later */
843  }
844 
845  /* Setup the ACPI timer */
846  HaliAcpiTimerInit(0, 0);
847 
848  /* Do we have a low stub address yet? */
850  {
851  /* Allocate it */
853  0x100000,
854  1,
855  FALSE);
857  {
858  /* Map it */
860  }
861  }
862 
863  /* Grab a page for flushes */
864  PhysicalAddress.QuadPart = 0x100000;
867 
868  /* Don't do this again */
870 
871  /* Setup the boot table */
872  HalpInitBootTable(LoaderBlock);
873 
874  /* Debugging code */
875  {
876  PLIST_ENTRY ListHead, NextEntry;
877  PACPI_CACHED_TABLE CachedTable;
878 
879  /* Loop cached tables */
880  ListHead = &HalpAcpiTableCacheList;
881  NextEntry = ListHead->Flink;
882  while (NextEntry != ListHead)
883  {
884  /* Get the table */
885  CachedTable = CONTAINING_RECORD(NextEntry, ACPI_CACHED_TABLE, Links);
886 
887  /* Compare signatures */
888  if ((CachedTable->Header.Signature == RSDT_SIGNATURE) ||
889  (CachedTable->Header.Signature == XSDT_SIGNATURE))
890  {
891  DPRINT1("ACPI %d.0 Detected. Tables: ", (CachedTable->Header.Revision + 1));
892  }
893 
894  DbgPrint("[%c%c%c%c] ",
895  (CachedTable->Header.Signature & 0xFF),
896  (CachedTable->Header.Signature & 0xFF00) >> 8,
897  (CachedTable->Header.Signature & 0xFF0000) >> 16,
898  (CachedTable->Header.Signature & 0xFF000000) >> 24);
899 
900  /* Keep going */
901  NextEntry = NextEntry->Flink;
902  }
903  DbgPrint("\n");
904  }
905 
906  /* Return success */
907  return STATUS_SUCCESS;
908 }
#define XSDT_SIGNATURE
Definition: acpi.h:39
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
DESCRIPTION_HEADER Header
Definition: acpi.h:124
#define RSDT_SIGNATURE
Definition: acpi.h:32
#define DbgPrint
Definition: loader.c:25
DESCRIPTION_HEADER Header
Definition: halacpi.h:9
PDEBUG_PORT_TABLE HalpDebugPortTable
Definition: halacpi.c:24
LONG NTSTATUS
Definition: precomp.h:26
PVOID NTAPI HalAcpiGetTable(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG Signature)
Definition: halacpi.c:446
#define HalAddressToPte(x)
Definition: halp.h:523
VOID NTAPI HalpDynamicSystemResourceConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halacpi.c:499
PHARDWARE_PTE HalpPteForFlush
Definition: halacpi.c:30
VOID NTAPI HalpAcpiDetectMachineSpecificActions(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN PFADT DescriptionTable)
Definition: halacpi.c:507
PVOID NTAPI HalpMapPhysicalMemory64(IN PHYSICAL_ADDRESS PhysicalAddress, IN ULONG NumberPage)
Definition: misc.c:28
ULONG Signature
Definition: acpi.h:96
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define STATUS_NOT_FOUND
Definition: shellext.h:67
PHYSICAL_ADDRESS HalpLowStubPhysicalAddress
Definition: halacpi.c:29
PHYSICAL_ADDRESS HalpMaxHotPlugMemoryAddress
Definition: halacpi.c:28
VOID NTAPI HalpInitBootTable(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halacpi.c:520
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
UCHAR Revision
Definition: acpi.h:98
PVOID HalpLowStub
Definition: halacpi.c:32
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1061
VOID NTAPI HaliAcpiTimerInit(IN ULONG TimerPort, IN ULONG TimerValExt)
Definition: halacpi.c:771
Definition: typedefs.h:117
Status
Definition: gdiplustypes.h:24
ULONG Length
Definition: acpi.h:97
NTSTATUS NTAPI HalpAcpiTableCacheInit(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halacpi.c:642
BOOLEAN HalpProcessedACPIPhase0
Definition: halacpi.c:20
struct _FADT FADT
Definition: acpi.h:122
LIST_ENTRY HalpAcpiTableCacheList
Definition: halacpi.c:17
#define DPRINT1
Definition: precomp.h:8
FADT HalpFixedAcpiDescTable
Definition: halacpi.c:23
unsigned int ULONG
Definition: retypes.h:1
BOOLEAN HalpPhysicalMemoryMayAppearAbove4GB
Definition: halacpi.c:21
#define DBGP_SIGNATURE
Definition: acpi.h:38
ULONG64 NTAPI HalpAllocPhysicalMemory(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG64 MaxAddress, IN PFN_NUMBER PageCount, IN BOOLEAN Aligned)
Definition: memory.c:29
#define FADT_SIGNATURE
Definition: acpi.h:31
return STATUS_SUCCESS
Definition: btrfs.c:2966
PACPI_SRAT HalpAcpiSrat
Definition: halacpi.c:25
VOID NTAPI HalpNumaInitializeStaticConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halacpi.c:475
LONGLONG QuadPart
Definition: typedefs.h:112
PVOID HalpVirtAddrForFlush
Definition: halacpi.c:31

Referenced by HalInitSystem().

◆ HalReportResourceUsage()

INIT_FUNCTION VOID NTAPI HalReportResourceUsage ( VOID  )

Definition at line 1071 of file halacpi.c.

1072 {
1073  INTERFACE_TYPE InterfaceType;
1074  UNICODE_STRING HalString;
1075 
1076  /* FIXME: Initialize DMA 64-bit support */
1077 
1078  /* FIXME: Initialize MCA bus */
1079 
1080  /* Initialize PCI bus. */
1082 
1083  /* What kind of bus is this? */
1084  switch (HalpBusType)
1085  {
1086  /* ISA Machine */
1087  case MACHINE_TYPE_ISA:
1088  InterfaceType = Isa;
1089  break;
1090 
1091  /* EISA Machine */
1092  case MACHINE_TYPE_EISA:
1093  InterfaceType = Eisa;
1094  break;
1095 
1096  /* MCA Machine */
1097  case MACHINE_TYPE_MCA:
1098  InterfaceType = MicroChannel;
1099  break;
1100 
1101  /* Unknown */
1102  default:
1103  InterfaceType = Internal;
1104  break;
1105  }
1106 
1107  /* Build HAL usage */
1108  RtlInitUnicodeString(&HalString, HalName);
1109  HalpReportResourceUsage(&HalString, InterfaceType);
1110 
1111  /* Setup PCI debugging and Hibernation */
1113 }
enum _INTERFACE_TYPE INTERFACE_TYPE
INIT_FUNCTION VOID NTAPI HalpInitializePciBus(VOID)
Definition: halacpi.c:913
PWCHAR HalName
Definition: halacpi.c:45
ULONG HalpBusType
Definition: bus.c:17
#define MACHINE_TYPE_ISA
Definition: ketypes.h:52
#define MACHINE_TYPE_MCA
Definition: ketypes.h:54
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
VOID NTAPI HalpReportResourceUsage(IN PUNICODE_STRING HalName, IN INTERFACE_TYPE InterfaceType)
Definition: usage.c:26
#define MACHINE_TYPE_EISA
Definition: ketypes.h:53
INIT_FUNCTION VOID NTAPI HalpRegisterPciDebuggingDeviceInfo(VOID)
Definition: pcibus.c:648

Variable Documentation

◆ HalDisableFirmwareMapper

BOOLEAN HalDisableFirmwareMapper = TRUE

Definition at line 43 of file halacpi.c.

Referenced by HalpMarkAcpiHal().

◆ HalHardwareIdString

PWCHAR HalHardwareIdString = L"acpipic_up"

Definition at line 44 of file halacpi.c.

Referenced by HalpQueryIdFdo().

◆ HalName

◆ HalpAcpiMultiNode

PACPI_BIOS_MULTI_NODE HalpAcpiMultiNode

Definition at line 34 of file halacpi.c.

Referenced by HalpAcpiFindRsdtPhase0().

◆ HalpAcpiSrat

◆ HalpAcpiTableCacheList

LIST_ENTRY HalpAcpiTableCacheList

◆ HalpAcpiTableCacheLock

FAST_MUTEX HalpAcpiTableCacheLock

Definition at line 18 of file halacpi.c.

Referenced by HalAcpiGetTable(), and HalpAcpiTableCacheInit().

◆ HalpAcpiTableMatchList

LIST_ENTRY HalpAcpiTableMatchList

Definition at line 36 of file halacpi.c.

Referenced by HalpAcpiDetectMachineSpecificActions().

◆ HalpDebugPortTable

PDEBUG_PORT_TABLE HalpDebugPortTable

Definition at line 24 of file halacpi.c.

Referenced by HalpGetDebugPortTable(), and HalpSetupAcpiPhase0().

◆ HalpFixedAcpiDescTable

FADT HalpFixedAcpiDescTable

◆ HalpInvalidAcpiTable

ULONG HalpInvalidAcpiTable

Definition at line 38 of file halacpi.c.

Referenced by HalpAcpiGetTableFromBios().

◆ HalpLowStub

PVOID HalpLowStub

Definition at line 32 of file halacpi.c.

Referenced by HalpSetupAcpiPhase0().

◆ HalpLowStubPhysicalAddress

PHYSICAL_ADDRESS HalpLowStubPhysicalAddress

Definition at line 29 of file halacpi.c.

Referenced by HalpSetupAcpiPhase0().

◆ HalpMaxHotPlugMemoryAddress

PHYSICAL_ADDRESS HalpMaxHotPlugMemoryAddress

Definition at line 28 of file halacpi.c.

Referenced by HalpSetupAcpiPhase0().

◆ HalpPhysicalMemoryMayAppearAbove4GB

BOOLEAN HalpPhysicalMemoryMayAppearAbove4GB

Definition at line 21 of file halacpi.c.

Referenced by HalpSetupAcpiPhase0().

◆ HalpPicVectorRedirect

ULONG HalpPicVectorRedirect[] = {0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15}

Definition at line 40 of file halacpi.c.

Referenced by HalpBuildAcpiResourceList().

◆ HalpProcessedACPIPhase0

BOOLEAN HalpProcessedACPIPhase0

Definition at line 20 of file halacpi.c.

Referenced by HalpSetupAcpiPhase0().

◆ HalpPteForFlush

PHARDWARE_PTE HalpPteForFlush

Definition at line 30 of file halacpi.c.

Referenced by HalpSetupAcpiPhase0().

◆ HalpSimpleBootFlagTable

PBOOT_TABLE HalpSimpleBootFlagTable

Definition at line 26 of file halacpi.c.

Referenced by HalpInitBootTable().

◆ HalpVirtAddrForFlush

PVOID HalpVirtAddrForFlush

Definition at line 31 of file halacpi.c.

Referenced by HalpSetupAcpiPhase0().