/* Location of resource hob matching type and highest address below end */
STATIC EFI_HOB_RESOURCE_DESCRIPTOR* GetHighestResourceDescriptor(EFI_RESOURCE_TYPE Type, EFI_PHYSICAL_ADDRESS End)
/* Location of resource hob matching type and highest address below end */
STATIC EFI_HOB_RESOURCE_DESCRIPTOR* GetHighestResourceDescriptor(EFI_RESOURCE_TYPE Type, EFI_PHYSICAL_ADDRESS End)
{
  EFI_PEI_HOB_POINTERS         Hob;
  EFI_HOB_RESOURCE_DESCRIPTOR  *ResourceDescriptor = NULL;
  Hob.Raw = GetFirstHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR);
  while (Hob.Raw != NULL) {
    if ((Hob.ResourceDescriptor->ResourceType == Type) &&
        (Hob.ResourceDescriptor->PhysicalStart < End))
    {
      if (!ResourceDescriptor ||
          (ResourceDescriptor->PhysicalStart < Hob.ResourceDescriptor->PhysicalStart))
      {
        ResourceDescriptor = Hob.ResourceDescriptor;
      }
    }
    Hob.Raw = GET_NEXT_HOB (Hob);
    Hob.Raw = GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, Hob.Raw);
  }
  return ResourceDescriptor;
}