/* It will ASSERT() if SMM Access2 Protocol doesn't exist. It will ASSERT() if SMRAM ranges can't be got. It will ASSERT() if Resource can't be allocated for cache SMRAM range. It will always return EFI_SUCCESS. */
EFI_STATUS EFIAPI SmmMemoryAllocationLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
/* It will ASSERT() if SMM Access2 Protocol doesn't exist. It will ASSERT() if SMRAM ranges can't be got. It will ASSERT() if Resource can't be allocated for cache SMRAM range. It will always return EFI_SUCCESS. */
EFI_STATUS EFIAPI SmmMemoryAllocationLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{
  EFI_STATUS                Status;
  EFI_SMM_ACCESS2_PROTOCOL  *SmmAccess;
  UINTN                     Size;
  Status = gBS->LocateProtocol (
                  &gEfiSmmAccess2ProtocolGuid,
                  NULL,
                  (VOID **)&SmmAccess
                  );
  ASSERT_EFI_ERROR (Status);
  Size   = 0;
  Status = SmmAccess->GetCapabilities (SmmAccess, &Size, NULL);
  ASSERT (Status == EFI_BUFFER_TOO_SMALL);
  mSmramRanges = (EFI_SMRAM_DESCRIPTOR *)AllocatePool (Size);
  ASSERT (mSmramRanges != NULL);
  Status = SmmAccess->GetCapabilities (SmmAccess, &Size, mSmramRanges);
  ASSERT_EFI_ERROR (Status);
  mSmramRangeCount = Size / sizeof (EFI_SMRAM_DESCRIPTOR);
  return EFI_SUCCESS;
}