/* The function checks the "linux,pci-domain" property of the host-pci node. Either all host-pci nodes must have this property, or none of them. If the property is available, read it. Otherwise dynamically assign the Ids. */
STATIC EFI_STATUS EFIAPI GetPciSegGroup(IN CONST VOID *Fdt, IN INT32 HostPciNode, OUT INT32 *SegGroup)
/* The function checks the "linux,pci-domain" property of the host-pci node. Either all host-pci nodes must have this property, or none of them. If the property is available, read it. Otherwise dynamically assign the Ids. */
STATIC EFI_STATUS EFIAPI GetPciSegGroup(IN CONST VOID *Fdt, IN INT32 HostPciNode, OUT INT32 *SegGroup)
{
  CONST UINT8   *Data;
  INT32         DataSize;
  STATIC INT32  LocalSegGroup = 0;
  if ((Fdt == NULL) ||
      (SegGroup == NULL))
  {
    ASSERT (0);
    return EFI_INVALID_PARAMETER;
  }
  Data = fdt_getprop (Fdt, HostPciNode, "linux,pci-domain", &DataSize);
  if ((Data == NULL) || (DataSize < 0)) {
    if (LocalSegGroup < 0) {
      ASSERT (0);
      return EFI_ABORTED;
    }
    *SegGroup = LocalSegGroup++;
    return EFI_SUCCESS;
  }
  if ((DataSize > sizeof (UINT32))  ||
      (LocalSegGroup > 0))
  {
    ASSERT (0);
    return EFI_ABORTED;
  }
  LocalSegGroup = -1;
  *SegGroup = fdt32_to_cpu (*(UINT32 *)Data);
  return EFI_SUCCESS;
}