ReactOS  0.4.13-dev-464-g6b95727
halacpi.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _ACPI_CACHED_TABLE
 

Typedefs

typedef struct _ACPI_CACHED_TABLE ACPI_CACHED_TABLE
 
typedef struct _ACPI_CACHED_TABLEPACPI_CACHED_TABLE
 

Functions

NTSTATUS NTAPI HalpAcpiTableCacheInit (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
PVOID NTAPI HalpAcpiGetTable (IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG Signature)
 
INIT_FUNCTION NTSTATUS NTAPI HalpSetupAcpiPhase0 (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
PVOID NTAPI HalAcpiGetTable (IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG Signature)
 

Typedef Documentation

◆ ACPI_CACHED_TABLE

◆ PACPI_CACHED_TABLE

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().

◆ 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().

◆ 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:1060
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:2777
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().

◆ 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:1060
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:2777
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().