/* Return the memory type bit mask that's compatible to first type in the Ranges. */
UINT8 MtrrLibGetCompatibleTypes(IN CONST MTRR_MEMORY_RANGE *Ranges, IN UINTN RangeCount)
/* Return the memory type bit mask that's compatible to first type in the Ranges. */
UINT8 MtrrLibGetCompatibleTypes(IN CONST MTRR_MEMORY_RANGE *Ranges, IN UINTN RangeCount)
{
  ASSERT (RangeCount != 0);
  switch (Ranges[0].Type) {
    case CacheWriteBack:
    case CacheWriteThrough:
      return (1 << CacheWriteBack) | (1 << CacheWriteThrough) | (1 << CacheUncacheable);
      break;
    case CacheWriteCombining:
    case CacheWriteProtected:
      return (1 << Ranges[0].Type) | (1 << CacheUncacheable);
      break;
    case CacheUncacheable:
      if (RangeCount == 1) {
        return (1 << CacheUncacheable);
      }
      return MtrrLibGetCompatibleTypes (&Ranges[1], RangeCount - 1);
      break;
    case CacheInvalid:
    default:
      ASSERT (FALSE);
      break;
  }
  return 0;
}