45 Address &= ~EFI_PAGE_MASK;
47 Status =
gDS->GetMemorySpaceDescriptor (Address, &Descriptor);
48 if (EFI_ERROR (Status)) {
49 DEBUG ((DEBUG_INFO,
"%a: GetMemorySpaceDescriptor failed\n", __func__));
54 Status =
gDS->AddMemorySpace (
58 EFI_MEMORY_UC | EFI_MEMORY_RUNTIME
60 if (EFI_ERROR (Status)) {
61 DEBUG ((DEBUG_INFO,
"%a: AddMemorySpace failed\n", __func__));
65 Status =
gDS->SetMemorySpaceAttributes (
70 if (EFI_ERROR (Status)) {
71 DEBUG ((DEBUG_INFO,
"%a:%d SetMemorySpaceAttributes failed\n", __func__, __LINE__));
74 }
else if (!(Descriptor.
Attributes & EFI_MEMORY_RUNTIME)) {
75 Status =
gDS->SetMemorySpaceAttributes (
81 if (EFI_ERROR (Status)) {
82 DEBUG ((DEBUG_INFO,
"%a:%d SetMemorySpaceAttributes failed\n", __func__, __LINE__));
106 UINT32 *Entry32 =
NULL;
108 UINT32 *Signature =
NULL;
113 if (EFI_ERROR (Status)) {
117 if (EFI_ERROR (Status) || (Rsdp ==
NULL)) {
118 DEBUG ((DEBUG_ERROR,
"EFI_ERROR or Rsdp == NULL\n"));
123 Entry32 = (UINT32 *)(
UINTN)(Rsdt + 1);
125 for (Idx = 0; Idx < Entry32Num; Idx++) {
126 Signature = (UINT32 *)(
UINTN)Entry32[Idx];
129 DEBUG ((DEBUG_INFO,
"Found Fadt in Rsdt\n"));
135 Entry32 = (UINT32 *)(Xsdt + 1);
137 for (Idx = 0; Idx < Entry32Num; Idx++) {
138 Signature = (UINT32 *)(
UINTN)Entry32[Idx];
141 DEBUG ((DEBUG_INFO,
"Found Fadt in Xsdt\n"));
146 DEBUG ((DEBUG_ERROR,
" Fadt Not Found\n"));
150 mPowerManager.ResetRegAddr = Fadt->ResetReg.Address;
151 mPowerManager.ResetValue = Fadt->ResetValue;
152 mPowerManager.SleepControlRegAddr = Fadt->SleepControlReg.Address;
153 mPowerManager.SleepStatusRegAddr = Fadt->SleepStatusReg.Address;
195 if (EFI_ERROR (Status)) {
199 DEBUG ((DEBUG_INFO,
"%a: sleepControl %llx\n", __func__, mPowerManager.SleepControlRegAddr));
200 ASSERT (mPowerManager.SleepControlRegAddr);
202 if (EFI_ERROR (Status)) {
203 DEBUG ((DEBUG_INFO,
"%a:%d\n", __func__, __LINE__));
207 DEBUG ((DEBUG_INFO,
"%a: sleepStatus %llx\n", __func__, mPowerManager.SleepStatusRegAddr));
208 ASSERT (mPowerManager.SleepStatusRegAddr);
210 if (EFI_ERROR (Status)) {
211 DEBUG ((DEBUG_INFO,
"%a:%d\n", __func__, __LINE__));
215 DEBUG ((DEBUG_INFO,
"%a: ResetReg %llx\n", __func__, mPowerManager.ResetRegAddr));
216 ASSERT (mPowerManager.ResetRegAddr);
218 if (EFI_ERROR (Status)) {
219 DEBUG ((DEBUG_INFO,
"%a:%d\n", __func__, __LINE__));
241 Status =
gBS->CreateEventEx (
253 Status =
gBS->CreateEvent (
254 EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,
258 &ResetSystemVirtualNotifyEvent
#define EFI_ACPI_5_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE
STATIC EFI_STATUS GetPowerManagerByParseAcpiInfo(VOID)
STATIC VOID ResetSystemLibAddressChangeEvent(IN EFI_EVENT Event, IN VOID *Context)
STATIC EFI_STATUS SetMemoryAttributesRunTime(UINTN Address)
EFI_STATUS EFIAPI ResetSystemLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
STATIC VOID AcpiNotificationEvent(IN EFI_EVENT Event, IN VOID *Context)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
@ EfiGcdMemoryTypeNonExistent
@ EfiGcdMemoryTypeMemoryMappedIo
EFI_STATUS EFIAPI EfiGetSystemConfigurationTable(IN EFI_GUID *TableGuid, OUT VOID **Table)
EFI_STATUS EFIAPI EfiConvertPointer(IN UINTN DebugDisposition, IN OUT VOID **Address)
EFI_GCD_MEMORY_TYPE GcdMemoryType