ReactOS 0.4.15-dev-5836-g942b022
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)
 
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}
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const WCHAR Signature[]
Definition: parser.c:141
VOID FASTCALL ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:23
VOID FASTCALL ExReleaseFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:31
PVOID NTAPI HalpAcpiGetTable(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG Signature)
Definition: halacpi.c:404
FAST_MUTEX HalpAcpiTableCacheLock
Definition: halacpi.c:18
NTSTATUS NTAPI HalpAcpiTableCacheInit(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halacpi.c:642

Referenced by HalpAddDevice(), HalpGetHotPlugMemoryInfo(), HalpInitBootTable(), HalpNumaInitializeStaticConfiguration(), HalpParseApicTables(), 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}
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
VOID NTAPI HalpUnmapVirtualAddress(IN PVOID VirtualAddress, IN PFN_COUNT PageCount)
Definition: memory.c:148
VOID NTAPI HalpAcpiCacheTable(IN PDESCRIPTION_HEADER TableHeader)
Definition: halacpi.c:77
PVOID NTAPI HalpAcpiCopyBiosTable(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN PDESCRIPTION_HEADER TableHeader)
Definition: halacpi.c:88
PDESCRIPTION_HEADER NTAPI HalpAcpiGetCachedTable(IN ULONG Signature)
Definition: halacpi.c:51
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
ULONG Length
Definition: acpi.h:97
#define BYTES_TO_PAGES(Size)
ULONG PFN_COUNT
Definition: mmtypes.h:102

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 */
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
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) &&
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,
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 */
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}
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
Status
Definition: gdiplustypes.h:25
PVOID NTAPI HalpMapPhysicalMemory64(IN PHYSICAL_ADDRESS PhysicalAddress, IN PFN_COUNT PageCount)
Definition: memory.c:140
LIST_ENTRY HalpAcpiTableCacheList
Definition: halacpi.c:17
NTSTATUS NTAPI HalpAcpiFindRsdtPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock, OUT PACPI_BIOS_MULTI_NODE *AcpiMultiNode)
Definition: halacpi.c:547
NTHALAPI VOID NTAPI HalDisplayString(PUCHAR String)
PVOID NTAPI MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, IN SIZE_T NumberOfBytes, IN MEMORY_CACHING_TYPE CacheType)
Definition: iosup.c:47
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:108
#define RSDT_SIGNATURE
Definition: acpi.h:32
#define XSDT_SIGNATURE
Definition: acpi.h:39
#define STATUS_SUCCESS
Definition: shellext.h:65
PHYSICAL_ADDRESS RsdtAddress
Definition: acpi.h:21
ULONG Signature
Definition: acpi.h:96
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
Definition: acpi.h:187
DESCRIPTION_HEADER Header
Definition: acpi.h:188
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
LONGLONG QuadPart
Definition: typedefs.h:114
ULONG LowPart
Definition: typedefs.h:106
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1098
#define ADDRESS_AND_SIZE_TO_SPAN_PAGES(_Va, _Size)
@ MmNonCached
Definition: mmtypes.h:129

Referenced by HalAcpiGetTable(), and HalpSetupAcpiPhase0().

◆ HalpSetupAcpiPhase0()

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 TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define DbgPrint
Definition: hal.h:12
ULONG64 NTAPI HalpAllocPhysicalMemory(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG64 MaxAddress, IN PFN_NUMBER PageCount, IN BOOLEAN Aligned)
Definition: memory.c:29
VOID NTAPI HalpDynamicSystemResourceConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halacpi.c:499
PHYSICAL_ADDRESS HalpMaxHotPlugMemoryAddress
Definition: halacpi.c:28
VOID NTAPI HalpAcpiDetectMachineSpecificActions(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN PFADT DescriptionTable)
Definition: halacpi.c:507
PACPI_SRAT HalpAcpiSrat
Definition: halacpi.c:25
VOID NTAPI HalpInitBootTable(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halacpi.c:520
PHARDWARE_PTE HalpPteForFlush
Definition: halacpi.c:30
BOOLEAN HalpPhysicalMemoryMayAppearAbove4GB
Definition: halacpi.c:21
PVOID HalpVirtAddrForFlush
Definition: halacpi.c:31
BOOLEAN HalpProcessedACPIPhase0
Definition: halacpi.c:20
PDEBUG_PORT_TABLE HalpDebugPortTable
Definition: halacpi.c:24
FADT HalpFixedAcpiDescTable
Definition: halacpi.c:23
VOID NTAPI HaliAcpiTimerInit(IN ULONG TimerPort, IN ULONG TimerValExt)
Definition: halacpi.c:771
VOID NTAPI HalpNumaInitializeStaticConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halacpi.c:475
PVOID NTAPI HalAcpiGetTable(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG Signature)
Definition: halacpi.c:446
PVOID HalpLowStub
Definition: halacpi.c:32
PHYSICAL_ADDRESS HalpLowStubPhysicalAddress
Definition: halacpi.c:29
#define HalAddressToPte(x)
Definition: halp.h:163
#define FADT_SIGNATURE
Definition: acpi.h:31
#define DBGP_SIGNATURE
Definition: acpi.h:38
struct _FADT FADT
#define STATUS_NOT_FOUND
Definition: shellext.h:72
DESCRIPTION_HEADER Header
Definition: halacpi.h:9
UCHAR Revision
Definition: acpi.h:98
Definition: acpi.h:123
DESCRIPTION_HEADER Header
Definition: acpi.h:124
Definition: typedefs.h:120
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by HalInitSystem().