28 for (Index = 0; Index < mSmmAccess.NumberRegions; Index++) {
30 mSmmAccess.SmramDesc[Index].RegionState |= Value;
32 mSmmAccess.SmramDesc[Index].RegionState &= Value;
56 if ((mSmmAccess.SmmRegionState & EFI_SMRAM_LOCKED) != 0) {
60 DEBUG ((DEBUG_INFO,
"Cannot open the locked SMRAM Region\n"));
61 return EFI_DEVICE_ERROR;
64 mSmmAccess.SmmRegionState &= ~(EFI_SMRAM_CLOSED | EFI_ALLOCATED);
67 mSmmAccess.SmmRegionState |= EFI_SMRAM_OPEN;
94 if ((mSmmAccess.SmmRegionState & EFI_SMRAM_LOCKED) != 0) {
98 DEBUG ((DEBUG_INFO,
"Cannot close the locked SMRAM Region\n"));
99 return EFI_DEVICE_ERROR;
102 if ((mSmmAccess.SmmRegionState & EFI_SMRAM_CLOSED) != 0) {
103 return EFI_DEVICE_ERROR;
106 mSmmAccess.SmmRegionState &= ~EFI_SMRAM_OPEN;
109 mSmmAccess.SmmRegionState |= (EFI_SMRAM_CLOSED | EFI_ALLOCATED);
138 DEBUG ((DEBUG_INFO,
"Cannot lock SMRAM when it is still open\n"));
139 return EFI_DEVICE_ERROR;
142 mSmmAccess.SmmRegionState |= EFI_SMRAM_LOCKED;
173 UINTN NecessaryBufferSize;
176 if (*SmramMapSize < NecessaryBufferSize) {
177 Status = EFI_BUFFER_TOO_SMALL;
179 CopyMem (SmramMap, mSmmAccess.SmramDesc, NecessaryBufferSize);
183 *SmramMapSize = NecessaryBufferSize;
214 if (GuidHob ==
NULL) {
215 DEBUG ((DEBUG_INFO,
"SMRAM HOB NOT found\n"));
216 return EFI_NOT_FOUND;
222 if (mSmmAccess.SmramDesc ==
NULL) {
223 return EFI_OUT_OF_RESOURCES;
228 DEBUG ((DEBUG_INFO,
"NumberOfSmmReservedRegions = 0x%x\n", SmmRegionNum));
229 for (Index = 0; Index < SmmRegionNum; Index++) {
232 "%d: base=0x%x, size = 0x%x, State=0x%x\n",
238 mSmmAccess.SmramDesc[Index].RegionState &= EFI_ALLOCATED;
239 mSmmAccess.SmramDesc[Index].RegionState |= EFI_SMRAM_CLOSED | EFI_CACHEABLE;
242 mSmmAccess.Signature = SMM_ACCESS_PRIVATE_DATA_SIGNATURE;
243 mSmmAccess.NumberRegions = SmmRegionNum;
244 mSmmAccess.SmmAccess.Open =
Open;
245 mSmmAccess.SmmAccess.Close =
Close;
246 mSmmAccess.SmmAccess.Lock =
Lock;
250 mSmmAccess.SmmRegionState = EFI_SMRAM_CLOSED;
252 Status =
gBS->InstallMultipleProtocolInterfaces (
254 &gEfiSmmAccess2ProtocolGuid,
255 &mSmmAccess.SmmAccess,
VOID *EFIAPI GetFirstGuidHob(IN CONST EFI_GUID *Guid)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
#define DEBUG(Expression)
EFI_STATUS EFIAPI GetCapabilities(IN CONST EFI_SMM_ACCESS2_PROTOCOL *This, IN OUT UINTN *SmramMapSize, IN OUT EFI_SMRAM_DESCRIPTOR *SmramMap)
EFI_STATUS EFIAPI Lock(IN EFI_SMM_ACCESS2_PROTOCOL *This)
EFI_STATUS EFIAPI Close(IN EFI_SMM_ACCESS2_PROTOCOL *This)
VOID SyncRegionState2SmramDesc(IN BOOLEAN OrLogic, IN UINT64 Value)
EFI_STATUS EFIAPI SmmAccessEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS EFIAPI Open(IN EFI_SMM_ACCESS2_PROTOCOL *This)
EFI_PHYSICAL_ADDRESS PhysicalStart
UINT32 NumberOfSmmReservedRegions
EFI_SMRAM_DESCRIPTOR Descriptor[1]