/* Caller should ensure that it is the only one to call this function. This function cannot be called concurrently. */
XENSTORE_STATUS XenBusEnumerateBus(XENBUS_DEVICE *Dev)
/* Caller should ensure that it is the only one to call this function. This function cannot be called concurrently. */
XENSTORE_STATUS XenBusEnumerateBus(XENBUS_DEVICE *Dev)
{
  CONST CHAR8      **Types;
  UINTN            Index;
  UINT32           Count;
  XENSTORE_STATUS  Status;
  Status = XenStoreListDirectory (
             XST_NIL,
             "device",
             "",
             &Count,
             &Types
             );
  if (Status != XENSTORE_STATUS_SUCCESS) {
    return Status;
  }
  for (Index = 0; Index < Count; Index++) {
    XenBusEnumerateDeviceType (Dev, Types[Index]);
  }
  FreePool ((VOID *)Types);
  return XENSTORE_STATUS_SUCCESS;
}