/* Calculate the maximum value which is a power of 2, but less the MemoryLength. */
UINT64 Power2MaxMemory(IN UINT64 MemoryAddress, IN UINT64 MemoryLength)
/* Calculate the maximum value which is a power of 2, but less the MemoryLength. */
UINT64 Power2MaxMemory(IN UINT64 MemoryAddress, IN UINT64 MemoryLength)
{
  UINT64  Result;
  if (MemoryLength == 0) {
    return EFI_INVALID_PARAMETER;
  }
  Result = GetPowerOfTwo64 (MemoryLength);
  if (MemoryAddress == 0) {
    return Result;
  }
  while (CheckMtrrAlignment (MemoryAddress, Result) != 0) {
    Result = RShiftU64 (Result, 1);
  }
  return Result;
}