hdfManagerNode = GetHdfManagerNode(HdfGetHcsRootNode());
if (hdfManagerNode == NULL) {
HDF_LOGE("%s: get hdf manager node is null", __func__);
return false;
}
hostNode = hdfManagerNode->child;
for (; hostNode != NULL; hostNode = hostNode->sibling) {
struct HdfHostInfo *hostInfo = HdfHostInfoNewInstance();
if (hostInfo == NULL) {
HdfSListFlush(hostList, HdfHostInfoDelete);
HDF_LOGE("%s: new hostInfo is null", __func__);
return false;
}
if (!GetHostInfo(hostNode, hostInfo)) {
HdfHostInfoFreeInstance(hostInfo);
continue;
}
hostInfo->hostId = hostId;
if (!HdfSListAddOrder(hostList, &hostInfo->node, HdfHostListCompare)) {
HdfHostInfoFreeInstance(hostInfo);
continue;
}
hostId++;
}
return true;
}
static int DevmgrServiceStartDeviceHost(struct DevmgrService *devmgr, struct HdfHostInfo *hostAttr)
{
struct DevHostServiceClnt *hostClnt = DevHostServiceClntNewInstance(hostAttr->hostId, hostAttr->hostName);
if (hostClnt == NULL) {
HDF_LOGW("failed to create new device host client");
return HDF_FAILURE;
}
if (HdfAttributeManagerGetDeviceList(hostClnt) != HDF_SUCCESS) {
HDF_LOGW("failed to get device list for host %{public}s", hostClnt->hostName);
return HDF_FAILURE;
}
DListInsertTail(&hostClnt->node, &devmgr->hosts);
// not start the host which only have dynamic devices
if (HdfSListIsEmpty(&hostClnt->unloadDevInfos)) {
return HDF_SUCCESS;
}
if (DevmgrServiceStartHostProcess(hostClnt, false, false) != HDF_SUCCESS) {
HDF_LOGW("failed to start device host, host id is %{public}u", hostAttr->hostId);
DListRemove(&hostClnt->node);
DevHostServiceClntFreeInstance(hostClnt);
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int HdfAttributeManagerGetDeviceList(struct DevHostServiceClnt *hostClnt)
{
uint16_t deviceIdx = 1;
const struct DeviceResourceNode *hostNode = NULL;
const struct DeviceResourceNode *device = NULL;
int ret = HDF_DEV_ERR_NO_DEVICE;
if (hostClnt == NULL) {
return HDF_ERR_INVALID_PARAM;
}
```
int HdfDeviceLaunchNode(struct HdfDeviceNode *devNode)
{
const struct HdfDriverEntry *driverEntry = NULL;
int ret;
if (devNode == NULL) {
HDF_LOGE("failed to launch service, device or service is null");
return HDF_ERR_INVALID_PARAM;
}