27UINTN mSmmIoLibGcdMemNumberOfDesc = 0;
31VOID *mSmmIoLibRegistrationEndOfDxe;
32VOID *mSmmIoLibRegistrationReadyToLock;
34BOOLEAN mSmmIoLibReadyToLock =
FALSE;
47 UINT8 MemPhysicalAddressBits;
54 MemPhysicalAddressBits = ((
EFI_HOB_CPU *)Hob)->SizeOfMemorySpace;
57 if (RegEax >= 0x80000008) {
59 MemPhysicalAddressBits = (UINT8)RegEax;
61 MemPhysicalAddressBits = 36;
68 ASSERT (MemPhysicalAddressBits <= 52);
69 if (MemPhysicalAddressBits > 48) {
70 MemPhysicalAddressBits = 48;
77 DEBUG ((DEBUG_INFO,
"mSmmIoLibInternalMaximumSupportMemAddress = 0x%lx\n", mSmmIoLibInternalMaximumSupportMemAddress));
103 BOOLEAN InValidRegion;
109 if ((Length > mSmmIoLibInternalMaximumSupportMemAddress) ||
110 (BaseAddress > mSmmIoLibInternalMaximumSupportMemAddress) ||
111 ((Length != 0) && (BaseAddress > (mSmmIoLibInternalMaximumSupportMemAddress - (Length - 1)))))
118 "SmmIsMmioValid: Overflow: BaseAddress (0x%lx) - Length (0x%lx), MaximumSupportMemAddress (0x%lx)\n",
121 mSmmIoLibInternalMaximumSupportMemAddress
129 if (mSmmIoLibReadyToLock) {
130 InValidRegion =
FALSE;
131 for (Index = 0; Index < mSmmIoLibGcdMemNumberOfDesc; Index++) {
132 Desc = &mSmmIoLibGcdMemSpace[Index];
134 (BaseAddress >= Desc->BaseAddress) &&
135 ((BaseAddress + Length) <= (Desc->BaseAddress + Desc->Length)))
137 InValidRegion =
TRUE;
141 if (!InValidRegion) {
144 "SmmIsMmioValid: Not in valid MMIO region: BaseAddress (0x%lx) - Length (0x%lx)\n",
177 GcdMemoryMapEntry = GcdMemoryMap;
178 NewGcdMemoryMapEntry = GcdMemoryMap;
180 while ((
UINTN)GcdMemoryMapEntry < (
UINTN)GcdMemoryMapEnd) {
182 NextGcdMemoryMapEntry = GcdMemoryMapEntry + 1;
185 if (((
UINTN)NextGcdMemoryMapEntry < (
UINTN)GcdMemoryMapEnd) &&
189 GcdMemoryMapEntry->
Length += NextGcdMemoryMapEntry->
Length;
190 if (NewGcdMemoryMapEntry != GcdMemoryMapEntry) {
191 NewGcdMemoryMapEntry->
Length += NextGcdMemoryMapEntry->
Length;
194 NextGcdMemoryMapEntry = NextGcdMemoryMapEntry + 1;
197 GcdMemoryMapEntry = NextGcdMemoryMapEntry - 1;
202 GcdMemoryMapEntry = GcdMemoryMapEntry + 1;
203 NewGcdMemoryMapEntry = NewGcdMemoryMapEntry + 1;
229 UINTN NumberOfDescriptors;
233 Status =
gDS->GetMemorySpaceMap (&NumberOfDescriptors, &MemSpaceMap);
234 if (!EFI_ERROR (Status)) {
238 ASSERT (mSmmIoLibGcdMemSpace !=
NULL);
239 if (mSmmIoLibGcdMemSpace ==
NULL) {
240 gBS->FreePool (MemSpaceMap);
241 return EFI_OUT_OF_RESOURCES;
244 mSmmIoLibGcdMemNumberOfDesc = NumberOfDescriptors;
245 gBS->FreePool (MemSpaceMap);
268 mSmmIoLibReadyToLock =
TRUE;
325 gSmst->SmmRegisterProtocolNotify (&gEfiSmmEndOfDxeProtocolGuid,
NULL, &mSmmIoLibRegistrationEndOfDxe);
326 gSmst->SmmRegisterProtocolNotify (&gEfiSmmReadyToLockProtocolGuid,
NULL, &mSmmIoLibRegistrationReadyToLock);
VOID *EFIAPI GetFirstHob(IN UINT16 Type)
UINT64 EFIAPI LShiftU64(IN UINT64 Operand, IN UINTN Count)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
UINT32 EFIAPI AsmCpuid(IN UINT32 Index, OUT UINT32 *RegisterEax OPTIONAL, OUT UINT32 *RegisterEbx OPTIONAL, OUT UINT32 *RegisterEcx OPTIONAL, OUT UINT32 *RegisterEdx OPTIONAL)
@ EfiGcdMemoryTypeMemoryMappedIo
EFI_SMM_SYSTEM_TABLE2 * gSmst
EFI_STATUS EFIAPI SmmIoLibInternalEndOfDxeNotify(IN CONST EFI_GUID *Protocol, IN VOID *Interface, IN EFI_HANDLE Handle)
VOID SmmIoLibInternalCalculateMaximumSupportAddress(VOID)
EFI_STATUS EFIAPI SmmIoLibDestructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS EFIAPI SmmIoLibInternalReadyToLockNotify(IN CONST EFI_GUID *Protocol, IN VOID *Interface, IN EFI_HANDLE Handle)
EFI_STATUS EFIAPI SmmIoLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
STATIC VOID MergeGcdMmioEntry(IN OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR *GcdMemoryMap, IN OUT UINTN *NumberOfDescriptors)
BOOLEAN EFIAPI SmmIsMmioValid(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN EFI_GUID *Owner OPTIONAL)
UINT64 EFI_PHYSICAL_ADDRESS
EFI_GCD_MEMORY_TYPE GcdMemoryType
EFI_PHYSICAL_ADDRESS BaseAddress