TianoCore EDK2 master
Loading...
Searching...
No Matches
BaseResetSystemAcpiGed.c
Go to the documentation of this file.
1
10#include <Library/DebugLib.h>
13#include "ResetSystemAcpiGed.h"
14
23VOID *
25 CONST CHAR8 *Name
26 )
27{
28 FIRMWARE_CONFIG_ITEM FwCfgItem;
29 EFI_STATUS Status;
30 UINTN FwCfgSize;
31 VOID *Data;
32
33 Status = QemuFwCfgFindFile (Name, &FwCfgItem, &FwCfgSize);
34 if (EFI_ERROR (Status)) {
35 DEBUG ((DEBUG_ERROR, "%a %d read %s error Status %d \n", __func__, __LINE__, Name, Status));
36 return NULL;
37 }
38
39 Data = AllocatePool (FwCfgSize);
40 if (Data == NULL) {
41 return NULL;
42 }
43
44 QemuFwCfgSelectItem (FwCfgItem);
45 QemuFwCfgReadBytes (FwCfgSize, Data);
46
47 return Data;
48}
49
59 VOID
60 )
61{
66 VOID *AcpiTables = NULL;
67 UINT32 *Entry32 = NULL;
68 UINTN Entry32Num;
69 UINT32 *Signature = NULL;
70 UINTN Idx;
71
72 Rsdp = GetFwCfgData ("etc/acpi/rsdp");
73 if (Rsdp == NULL) {
74 DEBUG ((DEBUG_ERROR, "%a %d read etc/acpi/rsdp error \n", __func__, __LINE__));
75 return EFI_NOT_FOUND;
76 }
77
78 AcpiTables = GetFwCfgData ("etc/acpi/tables");
79 if (AcpiTables == NULL) {
80 DEBUG ((DEBUG_ERROR, "%a %d read etc/acpi/tables error \n", __func__, __LINE__));
81 FreePool (Rsdp);
82 return EFI_NOT_FOUND;
83 }
84
85 Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *)((UINTN)AcpiTables + Rsdp->RsdtAddress);
86 Entry32 = (UINT32 *)(Rsdt + 1);
87 Entry32Num = (Rsdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) >> 2;
88 for (Idx = 0; Idx < Entry32Num; Idx++) {
89 Signature = (UINT32 *)((UINTN)Entry32[Idx] + (UINTN)AcpiTables);
92 DEBUG ((DEBUG_INFO, "Found Fadt in Rsdt\n"));
93 goto Done;
94 }
95 }
96
97 Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *)((UINTN)AcpiTables + Rsdp->XsdtAddress);
98 Entry32 = (UINT32 *)(Xsdt + 1);
99 Entry32Num = (Xsdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) >> 2;
100 for (Idx = 0; Idx < Entry32Num; Idx++) {
101 Signature = (UINT32 *)((UINTN)Entry32[Idx] + (UINTN)AcpiTables);
104 DEBUG ((DEBUG_INFO, "Found Fadt in Xsdt\n"));
105 goto Done;
106 }
107 }
108
109 FreePool (Rsdp);
110 FreePool (AcpiTables);
111 DEBUG ((DEBUG_ERROR, " Fadt Not Found\n"));
112 return EFI_NOT_FOUND;
113
114Done:
115 mPowerManager.ResetRegAddr = Fadt->ResetReg.Address;
116 mPowerManager.ResetValue = Fadt->ResetValue;
117 mPowerManager.SleepControlRegAddr = Fadt->SleepControlReg.Address;
118 mPowerManager.SleepStatusRegAddr = Fadt->SleepStatusReg.Address;
119
120 FreePool (Rsdp);
121 FreePool (AcpiTables);
122
123 return EFI_SUCCESS;
124}
125
133EFI_API
135 IN EFI_HANDLE ImageHandle,
136 IN EFI_SYSTEM_TABLE *SystemTable
137 )
138{
139 EFI_STATUS Status;
140
142 if (EFI_ERROR (Status)) {
143 DEBUG ((DEBUG_INFO, "%a:%d\n", __func__, __LINE__));
144 }
145
146 ASSERT (mPowerManager.SleepControlRegAddr);
147 ASSERT (mPowerManager.SleepStatusRegAddr);
148 ASSERT (mPowerManager.ResetRegAddr);
149
150 return Status;
151}
UINT64 UINTN
#define EFI_ACPI_5_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE
Definition: Acpi50.h:1930
STATIC EFI_STATUS GetPowerManagerByParseAcpiInfo(VOID)
STATIC VOID * GetFwCfgData(CONST CHAR8 *Name)
EFI_STATUS EFI_API ResetSystemLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define STATIC
Definition: Base.h:264
#define IN
Definition: Base.h:279
#define DEBUG(Expression)
Definition: DebugLib.h:434
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
RETURN_STATUS EFIAPI QemuFwCfgFindFile(IN CONST CHAR8 *Name, OUT FIRMWARE_CONFIG_ITEM *Item, OUT UINTN *Size)
Definition: QemuFwCfgLib.c:250
VOID EFIAPI QemuFwCfgReadBytes(IN UINTN Size, IN VOID *Buffer OPTIONAL)
Definition: QemuFwCfgNull.c:66
VOID EFIAPI QemuFwCfgSelectItem(IN FIRMWARE_CONFIG_ITEM QemuFwCfgItem)
Definition: QemuFwCfgLib.c:33
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112