diff --git a/uhdf2/README.md b/uhdf2/README.md
new file mode 100755
index 0000000000000000000000000000000000000000..c8efe7f483dff0ddaf8115d947a69407fc20f466
--- /dev/null
+++ b/uhdf2/README.md
@@ -0,0 +1,35 @@
+# full\_uhdf
+
+- [Introduction](#section11660541593)
+- [Directory Structure](#section161941989596)
+- [Repositories Involved](#section1371113476307)
+
+## Introduction
+
+This repository stores the code and compilation scripts for the user-mode Hardware Driver Foundation \(HDF\) of the OpenHarmony driver subsystem and provides basic capabilities for the HDF.
+
+## Directory Structure
+
+```
+/drivers/adapter/uhdf2
+├── config # Configuration parsing module
+├── hdi # Driver HDIs
+├── host # Host environment module
+├── include # Header files
+├── ipc # IPC module
+├── manager # Management module
+├── osal # Compilation scripts for adapting to the POSIX APIs
+├── security # Security module
+└── shared # Code shared by the host and manager modules
+```
+
+## Repositories Involved
+
+[Driver subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/driver-subsystem.md)
+
+[drivers\_framework](https://gitee.com/openharmony/drivers_framework/blob/master/README.md)
+
+drivers\_adapter
+
+[drivers\_adapter\_khdf\_linux](https://gitee.com/openharmony/drivers_adapter_khdf_linux/blob/master/README.md)
+
diff --git a/uhdf2/README_zh.md b/uhdf2/README_zh.md
new file mode 100755
index 0000000000000000000000000000000000000000..67a3d90763ec9d1e8cfc32e3a9544eafc19aceb5
--- /dev/null
+++ b/uhdf2/README_zh.md
@@ -0,0 +1,35 @@
+# full\_uhdf
+
+- [简介](#section11660541593)
+- [目录](#section161941989596)
+- [相关仓](#section1371113476307)
+
+## 简介
+
+该仓主要存放OpenHarmony驱动子系统用户态驱动框架的代码和编译脚本,在用户态中提供驱动框架的能力。
+
+## 目录
+
+```
+/drivers/adapter/uhdf2
+├── config #用户态驱动配置解析模块
+├── hdi #用户态驱动的hdi接口
+├── host #用户态驱动宿主环境模块
+├── include #用户态驱动框架提供能力头文件
+├── ipc #用户态驱动进程间通信模块
+├── manager #用户态驱动框架管理模块
+├── osal #适配posix接口代码的编译脚本适配
+├── security #用户态驱动安全模块
+└── shared #manager和host共享代码模块
+```
+
+## 相关仓
+
+[驱动子系统](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/%E9%A9%B1%E5%8A%A8%E5%AD%90%E7%B3%BB%E7%BB%9F.md)
+
+[drivers\_framework](https://gitee.com/openharmony/drivers_framework/blob/master/README_zh.md)
+
+drivers\_adapter
+
+[drivers\_adapter\_khdf\_linux](https://gitee.com/openharmony/drivers_adapter_khdf_linux/blob/master/README_zh.md)
+
diff --git a/uhdf2/config/BUILD.gn b/uhdf2/config/BUILD.gn
new file mode 100755
index 0000000000000000000000000000000000000000..76920c259a987da8164c2f75d69ce246f308f20d
--- /dev/null
+++ b/uhdf2/config/BUILD.gn
@@ -0,0 +1,58 @@
+# Copyright (c) 2021 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import("//build/ohos.gni")
+import("//drivers/adapter/uhdf2/uhdf.gni")
+
+group("uhdf_hcs_pkg") {
+ deps = [ ":libhdf_hcs" ]
+}
+
+ohos_shared_library("libhdf_hcs") {
+ include_dirs = [
+ "$hdf_uhdf_path/config/include",
+ "$hdf_uhdf_path/include/config",
+ "$hdf_framework_path/include/config",
+ "$hdf_framework_path/ability/config/hcs_parser/include",
+ ]
+ sources = [
+ "$hdf_framework_path/ability/config/device_resource_if.c",
+ "$hdf_framework_path/ability/config/hcs_parser/src/hcs_blob_if.c",
+ "$hdf_framework_path/ability/config/hcs_parser/src/hcs_generate_tree.c",
+ "$hdf_framework_path/ability/config/hcs_parser/src/hcs_parser.c",
+ "$hdf_framework_path/ability/config/hcs_parser/src/hcs_tree_if.c",
+ "$hdf_uhdf_path/config/src/hcs_blob_load.c",
+ "$hdf_uhdf_path/config/src/hcs_dm_parser.c",
+ ]
+
+ deps = [
+ "$hdf_uhdf_path/osal:libhdf_utils",
+ "//utils/native/base:utils",
+ ]
+
+ if (is_standard_system) {
+ external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
+ } else {
+ external_deps = [ "hilog:libhilog" ]
+ }
+
+ cflags = [
+ "-Wall",
+ "-Wextra",
+ "-Werror",
+ ]
+
+ # install_images = [ "vendor" ]
+ subsystem_name = "hdf"
+ part_name = "hdf"
+}
diff --git a/uhdf2/config/include/hcs_blob_load.h b/uhdf2/config/include/hcs_blob_load.h
new file mode 100644
index 0000000000000000000000000000000000000000..922e5dfa91d9d44d21266b1562c20d3719bc1144
--- /dev/null
+++ b/uhdf2/config/include/hcs_blob_load.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef HCS_BLOB_LOAD_H
+#define HCS_BLOB_LOAD_H
+
+#include "hdf_base.h"
+
+uint32_t OpenHcsBlobFile(const char *hcsBlobPath, char **hcsBlob);
+
+#endif // HCS_BLOB_LOAD_H
diff --git a/uhdf2/config/src/hcs_blob_load.c b/uhdf2/config/src/hcs_blob_load.c
new file mode 100644
index 0000000000000000000000000000000000000000..2d05d6528d9063a85bc60d1f9ed3c2339ca3813d
--- /dev/null
+++ b/uhdf2/config/src/hcs_blob_load.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "hcs_blob_load.h"
+#include
+#include
+#include "hcs_blob_if.h"
+#include "hdf_log.h"
+#include "osal_mem.h"
+
+#define HDF_LOG_TAG hcs_blob_load
+#define HBC_FILE_EXT ".hcb"
+
+static bool IsHcbFile(const char *fname)
+{
+ char *hcbExt = strstr(fname, HBC_FILE_EXT);
+ if (hcbExt == NULL) {
+ return false;
+ }
+ return true;
+}
+
+uint32_t OpenHcsBlobFile(const char *hcsBlobPath, char **hcsBlob)
+{
+ // the 0 is error.
+ int32_t length = 0;
+ if ((hcsBlobPath == NULL) || (hcsBlob == NULL) || !IsHcbFile(hcsBlobPath)) {
+ HDF_LOGE("%s failed, pls check the param", __func__);
+ return length;
+ }
+
+ char path[PATH_MAX] = { 0 };
+ if (realpath(hcsBlobPath, path) == NULL) {
+ HDF_LOGE("file %s is invalid", hcsBlobPath);
+ return length;
+ }
+ FILE *fp = fopen(path, "rb");
+ do {
+ if (fp == NULL) {
+ HDF_LOGE("%s failed, pls check the path of %s", __func__, hcsBlobPath);
+ break;
+ }
+ fseek(fp, 0, SEEK_END);
+ length = ftell(fp);
+ if ((length <= 0) || (length >= HBC_BLOB_MAX_LENGTH)) {
+ length = 0;
+ HDF_LOGE("%s failed, the HcsBlob file length is %d", __func__, length);
+ break;
+ }
+ *hcsBlob = (char *)OsalMemCalloc(length + 1);
+ if ((*hcsBlob) == NULL) {
+ length = 0;
+ HDF_LOGE("%s failed, OsalMemCalloc hcsBlob memory failed", __func__);
+ break;
+ }
+ fseek(fp, 0, SEEK_SET);
+ fread((void *)(*hcsBlob), length, 1, fp);
+ } while (0);
+ if (fp != NULL) {
+ fclose(fp);
+ }
+ return (length > 0) ? length : 0;
+}
diff --git a/uhdf2/config/src/hcs_dm_parser.c b/uhdf2/config/src/hcs_dm_parser.c
new file mode 100644
index 0000000000000000000000000000000000000000..011ef1a7251441eb36b27622bda185ed651b733b
--- /dev/null
+++ b/uhdf2/config/src/hcs_dm_parser.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "hcs_dm_parser.h"
+#include
+#include "hcs_blob_if.h"
+#include "hcs_blob_load.h"
+#include "hcs_parser.h"
+#include "hdf_log.h"
+#include "osal_mem.h"
+
+#define HDF_LOG_TAG hcs_dm_parser
+static char *g_hcsBlob = NULL;
+static struct DeviceResourceNode *g_hcsTreeRoot = NULL;
+static const char *g_hcsBlobPath = NULL;
+static pthread_mutex_t g_getDmRootMutex = PTHREAD_MUTEX_INITIALIZER;
+
+void ReleaseHcsTree(void)
+{
+ OsalMemFree(g_hcsTreeRoot);
+ g_hcsTreeRoot = NULL;
+ OsalMemFree(g_hcsBlob);
+ g_hcsBlob = NULL;
+}
+
+void SetHcsBlobPath(const char *path)
+{
+ if (g_hcsBlobPath != NULL) {
+ OsalMemFree((void *)g_hcsBlobPath);
+ }
+ g_hcsBlobPath = strdup(path);
+}
+
+static bool CreateHcsToTree(void)
+{
+ bool ret = true;
+ do {
+ uint32_t length = OpenHcsBlobFile(g_hcsBlobPath, &g_hcsBlob);
+ if (length == 0) {
+ ret = false;
+ break;
+ }
+ if (!HcsCheckBlobFormat(g_hcsBlob, length)) {
+ ret = false;
+ break;
+ }
+ if (!HcsDecompile((const char *)g_hcsBlob, HBC_HEADER_LENGTH, &g_hcsTreeRoot)) {
+ ret = false;
+ break;
+ }
+ } while (0);
+
+ if (!ret) {
+ ReleaseHcsTree();
+ }
+ return ret;
+}
+
+const struct DeviceResourceNode *HcsGetRootNode(void)
+{
+ if (g_hcsTreeRoot == NULL) {
+ pthread_mutex_lock(&g_getDmRootMutex);
+ if ((g_hcsTreeRoot == NULL) && !CreateHcsToTree()) {
+ pthread_mutex_unlock(&g_getDmRootMutex);
+ HDF_LOGE("%s is failed", __func__);
+ return NULL;
+ }
+ pthread_mutex_unlock(&g_getDmRootMutex);
+ }
+ return g_hcsTreeRoot;
+}
\ No newline at end of file
diff --git a/uhdf2/hcs/BUILD.gn b/uhdf2/hcs/BUILD.gn
new file mode 100755
index 0000000000000000000000000000000000000000..e77bfc4e6adfcf4441a0950fd64b7972e9aef9f5
--- /dev/null
+++ b/uhdf2/hcs/BUILD.gn
@@ -0,0 +1,36 @@
+# Copyright (c) 2021 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import("//build/ohos.gni")
+import("//drivers/adapter/uhdf2/uhdf.gni")
+
+ohos_prebuilt_etc("hdf_default.hcb") {
+ source = "hdf_default.hcb"
+ relative_install_dir = "hdfconfig"
+ subsystem_name = "hdf"
+ hcs_config_path = "default"
+ if (is_standard_system) {
+ hcs_config_path = "standard"
+ } else if (is_large_system) {
+ hcs_config_path = "large"
+ }
+ exec_script(
+ "$hdf_framework_path/tools/hc-gen/bin/hc-gen",
+ [
+ "-o",
+ rebase_path("hdf_default.hcb"),
+ rebase_path(hcs_config_path + "/hdf.hcs")
+ ],
+ "")
+ part_name = "hdf"
+}
\ No newline at end of file
diff --git a/uhdf2/hcs/default/device_info.hcs b/uhdf2/hcs/default/device_info.hcs
new file mode 100755
index 0000000000000000000000000000000000000000..de00b8bf74f716a9d676bb1893da7b3cae35fcb8
--- /dev/null
+++ b/uhdf2/hcs/default/device_info.hcs
@@ -0,0 +1,20 @@
+ root {
+ device_info {
+ match_attr = "hdf_manager";
+ template host {
+ hostName = "";
+ priority = 100;
+ template device {
+ template deviceNode {
+ policy = 0;
+ priority = 100;
+ preload = 0;
+ permission = 0664;
+ moduleName = "";
+ serviceName = "";
+ deviceMatchAttr = "";
+ }
+ }
+ }
+ }
+}
diff --git a/uhdf2/hcs/default/hdf.hcs b/uhdf2/hcs/default/hdf.hcs
new file mode 100755
index 0000000000000000000000000000000000000000..bf8dc250cb2744b277f7ffeac187299008b04d44
--- /dev/null
+++ b/uhdf2/hcs/default/hdf.hcs
@@ -0,0 +1,5 @@
+#include "device_info.hcs"
+
+root {
+ module = "default";
+}
diff --git a/uhdf2/hcs/large/device_info.hcs b/uhdf2/hcs/large/device_info.hcs
new file mode 100755
index 0000000000000000000000000000000000000000..de00b8bf74f716a9d676bb1893da7b3cae35fcb8
--- /dev/null
+++ b/uhdf2/hcs/large/device_info.hcs
@@ -0,0 +1,20 @@
+ root {
+ device_info {
+ match_attr = "hdf_manager";
+ template host {
+ hostName = "";
+ priority = 100;
+ template device {
+ template deviceNode {
+ policy = 0;
+ priority = 100;
+ preload = 0;
+ permission = 0664;
+ moduleName = "";
+ serviceName = "";
+ deviceMatchAttr = "";
+ }
+ }
+ }
+ }
+}
diff --git a/uhdf2/hcs/large/hdf.hcs b/uhdf2/hcs/large/hdf.hcs
new file mode 100755
index 0000000000000000000000000000000000000000..2dba784beba130cea086c95bd7ef994be6b75de5
--- /dev/null
+++ b/uhdf2/hcs/large/hdf.hcs
@@ -0,0 +1,5 @@
+#include "device_info.hcs"
+
+root {
+ module = "full";
+}
diff --git a/uhdf2/hcs/standard/device_info.hcs b/uhdf2/hcs/standard/device_info.hcs
new file mode 100755
index 0000000000000000000000000000000000000000..718a2fd1c0524b4333c9e9d83d339e9781630d5b
--- /dev/null
+++ b/uhdf2/hcs/standard/device_info.hcs
@@ -0,0 +1,81 @@
+ root {
+ device_info {
+ match_attr = "hdf_manager";
+ template host {
+ hostName = "";
+ priority = 100;
+ template device {
+ template deviceNode {
+ policy = 0;
+ priority = 100;
+ preload = 0;
+ permission = 0664;
+ moduleName = "";
+ serviceName = "";
+ deviceMatchAttr = "";
+ }
+ }
+ }
+ platform :: host {
+ hostName = "sample_host";
+ priority = 50;
+ sample_device :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ moduleName = "libsample_driver.z.so";
+ serviceName = "sample_driver_service";
+ }
+ }
+ }
+ acm :: host {
+ hostName = "acm_host";
+ priority = 50;
+ acm_device :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ moduleName = "libusbfn_cdcacm.z.so";
+ serviceName = "usbfn_cdcacm";
+ deviceMatchAttr = "usbfn_cdcacm_driver";
+ }
+ }
+ }
+ power :: host {
+ hostName = "power_host";
+ priority = 50;
+ battery_device :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ moduleName = "libbatteryd.z.so";
+ serviceName = "batteryd";
+ }
+ }
+ }
+ platform_camera :: host {
+ hostName = "camera_host";
+ priority = 50;
+ camera_device :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ moduleName = "libhdi_impl.z.so";
+ serviceName = "camera_service";
+ }
+ }
+ }
+ riladapter :: host {
+ hostName = "riladapter_host";
+ priority = 50;
+ riladapter_device :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ moduleName = "libril_init.z.so";
+ serviceName = "cellular_radio1";
+ }
+ }
+ }
+ }
+}
diff --git a/uhdf2/hcs/standard/hdf.hcs b/uhdf2/hcs/standard/hdf.hcs
new file mode 100755
index 0000000000000000000000000000000000000000..01b37ac8c13bc6f4290c96176a32d45ea03a4dc6
--- /dev/null
+++ b/uhdf2/hcs/standard/hdf.hcs
@@ -0,0 +1,7 @@
+#include "device_info.hcs"
+#include "usb_pnp_device.hcs"
+#include "usb_cdcacm.hcs"
+
+root {
+ module = "default";
+}
diff --git a/uhdf2/hcs/standard/usb_cdcacm.hcs b/uhdf2/hcs/standard/usb_cdcacm.hcs
new file mode 100755
index 0000000000000000000000000000000000000000..74009f398bb5318742645bc36ec1994296ea9e5c
--- /dev/null
+++ b/uhdf2/hcs/standard/usb_cdcacm.hcs
@@ -0,0 +1,242 @@
+root {
+ module = "cdcacm";
+ sampl_config {
+ match_attr = "usbfn_cdcacm_driver";
+ use_hcs = 0;
+ udc_name = "100e0000.hidwc3_1";
+ usb_dev_desc = "UsbDeviceDescriptor";
+ usb_dev_string = "UsbDeviceStrings";
+ usb_configuration = "UsbConfigs";
+ UsbDeviceDescriptor {
+ bLength = 18;
+ bDescriptorType = 0x01;
+ bcdUSB = 0x0200;
+ bDeviceClass = 2;
+ bDeviceSubClass = 0;
+ bDeviceProtocol = 0;
+ bMaxPacketSize0 = 0x40;
+ idVendor = 0x0525;
+ idProduct = 0xA4A7;
+ bcdDevice = 0x0100;
+ manufacturer = 0;
+ product = 1;
+ serialnumber = 2;
+ numConfigurations = 1;
+ }
+ UsbDeviceStrings {
+ stringTabList = ["string_1"];
+ string_1 {
+ language = 0x0409;
+ stringList = ["str_1", "str_2","str_3", "str_4"];
+ str_1 {
+ id = 0;
+ str = "";
+ }
+ str_2 {
+ id = 1;
+ str = "CDC ACM Sample for USB Device SDK";
+ }
+ str_3 {
+ id = 2;
+ str = "";
+ }
+ str_4 {
+ id = 3;
+ str = "CDC ACM";
+ }
+ }
+ }
+ UsbConfigs {
+ configList = ["config_1"];
+ config_1 {
+ configurationValue = 1;
+ iConfiguration = 3;
+ attributes = 0xC0;
+ maxPower = 500;
+ functionList = ["func_1"];
+ func_1 {
+ funcName = "f1";
+ stringTabList = ["fnString_1"];
+ fnString_1 {
+ language = 0x0409;
+ stringList = ["str_1", "str_2", "str_3"];
+ str_1 {
+ id = 0;
+ str = "CDC Serial";
+ }
+ str_2 {
+ id = 1;
+ str = "CDC Abstract Control Model (ACM)";
+ }
+ str_3 {
+ id = 2;
+ str = "CDC ACM Data";
+ }
+ }
+ fsDescList = ["assoc_interface", "ControlInterface", "cdc_header",
+ "cdc_call_mgmt", "cdc_acm", "cdc_union", "FsNotify_endpoint",
+ "DataInterface", "FsIn_endpoint", "FsOut_endpoint"];
+ assoc_interface {
+ bLength = 0x08;
+ bDescriptorType = 0x0B;
+ bFirstInterface = 0x00;
+ bInterfaceCount = 0x02;
+ bFunctionClass = 0x02;
+ bFunctionSubClass = 0x02;
+ bFunctionProtocol = 0x01;
+ iFunction = 0x00;
+ }
+ ControlInterface {
+ bLength = 0x09;
+ bDescriptorType = 0x04;
+ bInterfaceNumber = 0x00;
+ bAlternateSetting = 0x00;
+ bNumEndpoints = 0x01;
+ bInterfaceClass = 0x02;
+ bInterfaceSubClass = 0x02;
+ bInterfaceProtocol = 0x01;
+ iInterface = 0x01;
+ }
+ cdc_header {
+ bLength = 0x05;
+ bDescriptorType = 0x24;
+ desc_data = [0x05, 0x24, 0x00, 0x10, 0x01];
+ }
+ cdc_call_mgmt {
+ bLength = 0x05;
+ bDescriptorType = 0x24;
+ desc_data = [0x05, 0x24, 0x01, 0x00, 0x01];
+ }
+ cdc_acm {
+ bLength = 0x04;
+ bDescriptorType = 0x24;
+ desc_data = [0x04, 0x24, 0x02, 0x02];
+ }
+ cdc_union {
+ bLength = 0x05;
+ bDescriptorType = 0x24;
+ desc_data = [0x05, 0x24, 0x06, 0x00, 0x01];
+ }
+ FsNotify_endpoint {
+ bLength = 0x07;
+ bDescriptorType = 0x05;
+ bEndpointAddress = 0x81;
+ bmAttributes = 0x03;
+ wMaxPacketSize = 10;
+ bInterval = 32;
+ }
+ DataInterface {
+ bLength = 0x09;
+ bDescriptorType = 0x04;
+ bInterfaceNumber = 0x01;
+ bAlternateSetting = 0x00;
+ bNumEndpoints = 0x02;
+ bInterfaceClass = 0x0A;
+ bInterfaceSubClass = 0x00;
+ bInterfaceProtocol = 0x00;
+ iInterface = 0x02;
+ }
+ FsIn_endpoint {
+ bLength = 0x07;
+ bDescriptorType = 0x05;
+ bEndpointAddress = 0x82;
+ bmAttributes = 0x02;
+ wMaxPacketSize = 0;
+ bInterval = 0;
+ }
+ FsOut_endpoint {
+ bLength = 0x07;
+ bDescriptorType = 0x05;
+ bEndpointAddress = 0x3;
+ bmAttributes = 0x02;
+ wMaxPacketSize = 0;
+ bInterval = 0;
+ }
+ hsDescList = ["assoc_interface", "ControlInterface", "cdc_header",
+ "cdc_call_mgmt", "cdc_acm", "cdc_union", "HsNotify_endpoint",
+ "DataInterface", "HsIn_endpoint", "HsOut_endpoint"];
+ HsNotify_endpoint {
+ bLength = 0x07;
+ bDescriptorType = 0x05;
+ bEndpointAddress = 0x81;
+ bmAttributes = 0x03;
+ wMaxPacketSize = 10;
+ bInterval = 9;
+ }
+ HsIn_endpoint {
+ bLength = 0x07;
+ bDescriptorType = 0x05;
+ bEndpointAddress = 0x82;
+ bmAttributes = 0x02;
+ wMaxPacketSize = 512;
+ bInterval = 0;
+ }
+ HsOut_endpoint {
+ bLength = 0x07;
+ bDescriptorType = 0x05;
+ bEndpointAddress = 0x3;
+ bmAttributes = 0x02;
+ wMaxPacketSize = 512;
+ bInterval = 0;
+ }
+ ssDescList = ["assoc_interface", "ControlInterface", "cdc_header",
+ "cdc_call_mgmt", "cdc_acm", "cdc_union", "HsNotify_endpoint",
+ "ss_ep_comp", "DataInterface", "SsIn_endpoint",
+ "ss_ep_comp","SsOut_endpoint","ss_ep_comp"];
+ ss_ep_comp {
+ bLength = 0x06;
+ bDescriptorType = 0x30;
+ bMaxBurst = 0x00;
+ bmAttributes = 0x00;
+ wBytesPerInterval = 0x00;
+ }
+ SsIn_endpoint {
+ bLength = 0x07;
+ bDescriptorType = 0x05;
+ bEndpointAddress = 0x82;
+ bmAttributes = 0x02;
+ wMaxPacketSize = 1024;
+ bInterval = 0;
+ }
+ SsOut_endpoint {
+ bLength = 0x07;
+ bDescriptorType = 0x05;
+ bEndpointAddress = 0x3;
+ bmAttributes = 0x02;
+ wMaxPacketSize = 1024;
+ bInterval = 0;
+ }
+ }
+ }
+ }
+ custom_prop {
+ propTable = ["propList_1", "propList_2"];
+ propList_1 {
+ configNum = 1;
+ interfaceNum = 0;
+ propList = ["prop_1", "prop_2"];
+ prop_1 {
+ name = "testx";
+ value = "xxxxxx";
+ }
+ prop_2 {
+ name = "testy";
+ value = "yyyyyy";
+ }
+ }
+ propList_2 {
+ configNum = 1;
+ interfaceNum = 1;
+ propList = ["prop_1", "prop_2"];
+ prop_1 {
+ name = "testm";
+ value = "mmmmm";
+ }
+ prop_2 {
+ name = "testn";
+ value = "nnnnn";
+ }
+ }
+ }
+ }
+}
diff --git a/uhdf2/hcs/standard/usb_pnp_device.hcs b/uhdf2/hcs/standard/usb_pnp_device.hcs
new file mode 100755
index 0000000000000000000000000000000000000000..6e49a99a4789bc6568c82453b82d72174fb6de60
--- /dev/null
+++ b/uhdf2/hcs/standard/usb_pnp_device.hcs
@@ -0,0 +1,47 @@
+root {
+ module = "usb_pnp_device";
+ usb_pnp_config {
+ match_attr = "usb_pnp_match";
+ usb_pnp_device_id = "UsbPnpDeviceId";
+ UsbPnpDeviceId {
+ idTableList = [
+ "sample_table",
+ "host_acm_table"
+ ];
+ sample_table {
+ moduleName = "usb_pnp_sample_driver";
+ serviceName = "usb_pnp_sample_service";
+ length = 19;
+ matchFlag = 0x0003;
+ vendorId = 0xFFF0;
+ productId = 0xFFF0;
+ bcdDeviceLow = 0x0000;
+ bcdDeviceHigh = 0x0000;
+ deviceClass = 0;
+ deviceSubClass = 0;
+ deviceProtocol = 0;
+ interfaceClass = 0;
+ interfaceSubClass = 0;
+ interfaceProtocol = 0;
+ interfaceNumber = [0, 1];
+ }
+ host_acm_table {
+ moduleName = "usbhost_acm";
+ serviceName = "usbhost_acm_pnp_service";
+ length = 19;
+ matchFlag = 0x0403;
+ vendorId = 0x0526;
+ productId = 0xA4A7;
+ bcdDeviceLow = 0x0000;
+ bcdDeviceHigh = 0x0000;
+ deviceClass = 0;
+ deviceSubClass = 0;
+ deviceProtocol = 0;
+ interfaceClass = 0;
+ interfaceSubClass = 0;
+ interfaceProtocol = 0;
+ interfaceNumber = [0, 1];
+ }
+ }
+ }
+}
diff --git a/uhdf2/hdi/BUILD.gn b/uhdf2/hdi/BUILD.gn
new file mode 100755
index 0000000000000000000000000000000000000000..bb7c148a6af8dbffa342be0379bae806cc962c3c
--- /dev/null
+++ b/uhdf2/hdi/BUILD.gn
@@ -0,0 +1,88 @@
+# Copyright (c) 2021 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import("//build/ohos.gni")
+import("//drivers/adapter/uhdf2/uhdf.gni")
+group("uhdf_hidl_pkg") {
+ deps = [ ":libhdi" ]
+}
+
+config("libhdi_pub_config") {
+ visibility = [ ":*" ]
+
+ include_dirs = [
+ "//utils/native/base/include",
+ "$hdf_framework_path/ability/sbuf/include",
+ "$hdf_uhdf_path/ipc/include",
+ "$hdf_uhdf_path/hdi/include",
+ "$hdf_uhdf_path/include/hdi",
+ "$hdf_uhdf_path/shared/include",
+ ]
+}
+
+ohos_shared_library("libhdi") {
+ include_dirs = [
+ "$hdf_framework_path/include",
+ "$hdf_framework_path/include/core",
+ "$hdf_framework_path/include/osal",
+ "$hdf_framework_path/include/utils",
+ "$hdf_framework_path/core/sec/include",
+ "$hdf_framework_path/utils/include",
+ "$hdf_framework_path/core/shared/include",
+ "$hdf_framework_path/core/host/include",
+ "$hdf_framework_path/core/manager/include",
+ "$hdf_uhdf_path/include/devhost",
+ "$hdf_uhdf_path/devhost/include",
+ "$hdf_uhdf_path/devmgr/include",
+ "$hdf_uhdf_path/host/include",
+ "$hdf_uhdf_path/manager/include",
+ "$hdf_uhdf_path/include/host",
+ ]
+ public_configs = [ ":libhdi_pub_config" ]
+ sources = [
+ "src/devmgr_hdi.c",
+ "src/hdf_load_hdi.c",
+ "src/iservmgr_hdi.cpp",
+ "src/servmgr_hdi.c",
+ ]
+
+ deps = [
+ "$hdf_uhdf_path/ipc:libhdf_ipc_adapter",
+ "$hdf_uhdf_path/osal:libhdf_utils",
+ "//utils/native/base:utils",
+ ]
+
+ if (is_standard_system) {
+ external_deps = [
+ "communication_L2:ipc_core",
+ "hiviewdfx_hilog_native:libhilog",
+ "samgr_L2:samgr_proxy",
+ ]
+ } else {
+ external_deps = [
+ "hilog:libhilog",
+ "ipc:ipc_core",
+ "samgr:samgr_proxy",
+ ]
+ }
+
+ cflags = [
+ "-Wall",
+ "-Wextra",
+ "-Werror",
+ ]
+
+ # install_images = [ "vendor" ]
+ subsystem_name = "hdf"
+ part_name = "hdf"
+}
diff --git a/uhdf2/hdi/src/devmgr_hdi.c b/uhdf2/hdi/src/devmgr_hdi.c
new file mode 100644
index 0000000000000000000000000000000000000000..4c41a8e8591f8cd85a851f0bf8a81176daa69094
--- /dev/null
+++ b/uhdf2/hdi/src/devmgr_hdi.c
@@ -0,0 +1,251 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "devmgr_hdi.h"
+#include
+/*
+ * The "devmgr_service_stub.h" header file should be used. Actually, only the interface ID definition and service name
+ * are required here. This dependency can be removed when interface proxy impl is automatically generated from IDL.
+ */
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define HDF_LOG_TAG devmgr_interface
+
+static void DevmgrFreeQueryDeviceListImpl(struct DeviceInfoList *list);
+
+static int32_t DeviceManagerHdiCall(struct HDIDeviceManager *iDevMgr, int32_t id,
+ struct HdfSBuf *data, struct HdfSBuf *reply)
+{
+ if (iDevMgr->remote == NULL || iDevMgr->remote->dispatcher == NULL ||
+ iDevMgr->remote->dispatcher->Dispatch == NULL) {
+ return HDF_ERR_INVALID_OBJECT;
+ }
+
+ return iDevMgr->remote->dispatcher->Dispatch(iDevMgr->remote, id, data, reply);
+}
+
+static int32_t HdfObtainDeviceInfo(struct DeviceInfoList *list, struct HdfSBuf *reply)
+{
+ struct DeviceInfoNode *node = NULL;
+ const char *svrName = NULL;
+ int32_t svrNameLen;
+ char *base = NULL;
+ int32_t deviceType;
+
+ while ((svrName = HdfSbufReadString(reply))) {
+ svrNameLen = strlen(svrName) + 1;
+ base = (char *)OsalMemCalloc(sizeof(*node) + svrNameLen);
+ if (base == NULL) {
+ DevmgrFreeQueryDeviceListImpl(list);
+ return HDF_FAILURE;
+ }
+ node = (struct DeviceInfoNode *)base;
+ node->svcName = base + sizeof(*node);
+ if (strcpy_s(node->svcName, svrNameLen, svrName) != EOK) {
+ HDF_LOGE("strcpy service name %s failed", svrName);
+ OsalMemFree(base);
+ continue;
+ }
+ HDF_LOGD("%s %s", __func__, svrName);
+ HdfSbufReadInt32(reply, &deviceType);
+ if (deviceType != HDF_LOCAL_SERVICE && deviceType != HDF_REMOTE_SERVICE) {
+ HDF_LOGE("device type error %d ", deviceType);
+ OsalMemFree(base);
+ continue;
+ }
+ node->deviceType = deviceType;
+ DListInsertTail(&node->node, &list->list);
+ list->deviceCnt++;
+ }
+
+ return HDF_SUCCESS;
+}
+static int32_t DevmgrQueryDeviceInfo(struct HDIDeviceManager *iDevMgr, struct DeviceInfoList *list, int32_t type)
+{
+ struct HdfSBuf *reply = NULL;
+ struct HdfSBuf *data = NULL;
+ int32_t ret;
+
+ reply = HdfSBufTypedObtain(SBUF_IPC);
+ if (reply == NULL) {
+ return HDF_ERR_MALLOC_FAIL;
+ }
+
+ data = HdfSBufTypedObtain(SBUF_IPC);
+ if (data == NULL) {
+ HdfSBufRecycle(reply);
+ return HDF_ERR_MALLOC_FAIL;
+ }
+
+ list->deviceCnt = 0;
+ DListHeadInit(&list->list);
+
+ HdfSbufWriteInt32(data, type);
+ ret = DeviceManagerHdiCall(iDevMgr, DEVMGR_SERVICE_QUERY_DEVICE, data, reply);
+ if (ret != HDF_SUCCESS) {
+ HDF_LOGE("DevmgrProxyQueryDevice failed");
+ goto finished;
+ }
+
+ ret = HdfObtainDeviceInfo(list, reply);
+
+finished:
+ HdfSBufRecycle(reply);
+ HdfSBufRecycle(data);
+
+ return ret;
+}
+
+static int32_t DevmgrQueryUsableDeviceInfo(struct HDIDeviceManager *self, struct DeviceInfoList *list)
+{
+ if (self == NULL || list == NULL) {
+ return HDF_ERR_INVALID_PARAM;
+ }
+ return DevmgrQueryDeviceInfo(self, list, HDF_SERVICE_USABLE);
+}
+
+static int32_t DevmgrQueryUnusableDeviceInfo(struct HDIDeviceManager *self, struct DeviceInfoList *list)
+{
+ if (self == NULL || list == NULL) {
+ return HDF_ERR_INVALID_PARAM;
+ }
+
+ return DevmgrQueryDeviceInfo(self, list, HDF_SERVICE_UNUSABLE);
+}
+
+static void DevmgrFreeQueryDeviceListImpl(struct DeviceInfoList *list)
+{
+ if (list == NULL) {
+ return;
+ }
+
+ struct DeviceInfoNode *devNode = NULL;
+ struct DeviceInfoNode *tmp = NULL;
+ DLIST_FOR_EACH_ENTRY_SAFE(devNode, tmp, &list->list, struct DeviceInfoNode, node) {
+ DListRemove(&devNode->node);
+ OsalMemFree(devNode);
+ }
+ list->deviceCnt = 0;
+}
+
+static void DevmgrFreeQueryDeviceList(struct HDIDeviceManager *self, struct DeviceInfoList *list)
+{
+ (void)self;
+ DevmgrFreeQueryDeviceListImpl(list);
+}
+
+static int32_t HdfOpsDevice(struct HDIDeviceManager *iDevMgr,
+ const char *moduleName, const char *serviceName, int opsId)
+{
+ int32_t status = HDF_FAILURE;
+ if (iDevMgr == NULL || moduleName == NULL || serviceName == NULL) {
+ return HDF_ERR_INVALID_PARAM;
+ }
+
+ struct HdfSBuf *data = HdfSBufTypedObtain(SBUF_IPC);
+ struct HdfSBuf *reply = HdfSBufTypedObtain(SBUF_IPC);
+ if (data == NULL || reply == NULL) {
+ status = HDF_ERR_MALLOC_FAIL;
+ goto out;
+ }
+
+ if (!HdfSbufWriteString(data, moduleName)) {
+ HDF_LOGE("%s: writing module name failed!", __func__);
+ goto out;
+ }
+ if (!HdfSbufWriteString(data, serviceName)) {
+ HDF_LOGE("%s: writing service name failed!", __func__);
+ goto out;
+ }
+ status = DeviceManagerHdiCall(iDevMgr, opsId, data, reply);
+ if (status == HDF_SUCCESS) {
+ HdfSbufReadInt32(reply, &status);
+ }
+out:
+ HdfSBufRecycle(data);
+ HdfSBufRecycle(reply);
+ return status;
+}
+
+static int32_t DevmgrRegPnpDevice(struct HDIDeviceManager *self, const char *moduleName, const char *serviceName)
+{
+ return HdfOpsDevice(self, moduleName, serviceName, DEVMGR_SERVICE_REGIST_PNP_DEVICE);
+}
+
+static int32_t DevmgrUnRegPnpDevice(struct HDIDeviceManager *self, const char *moduleName, const char *serviceName)
+{
+ return HdfOpsDevice(self, moduleName, serviceName, DEVMGR_SERVICE_UNREGIST_PNP_DEVICE);
+}
+
+static int32_t DevmgrRegVirtualDevice(struct HDIDeviceManager *self, const char *moduleName, const char *serviceName)
+{
+ return HdfOpsDevice(self, moduleName, serviceName, DEVMGR_SERVICE_REGISTER_VIRTUAL_DEVICE);
+}
+
+static int32_t DevmgrUnRegVirtualDevice(struct HDIDeviceManager *self, const char *moduleName, const char *serviceName)
+{
+ return HdfOpsDevice(self, moduleName, serviceName, DEVMGR_SERVICE_UNREGISTER_VIRTUAL_DEVICE);
+}
+
+static void HDIDeviceManagerConstruct(struct HDIDeviceManager *inst)
+{
+ inst->FreeQueryDeviceList = DevmgrFreeQueryDeviceList;
+ inst->QueryUsableDeviceInfo = DevmgrQueryUsableDeviceInfo;
+ inst->QueryUnusableDeviceInfo = DevmgrQueryUnusableDeviceInfo;
+ inst->RegPnpDevice = DevmgrRegPnpDevice;
+ inst->UnRegPnpDevice = DevmgrUnRegPnpDevice;
+ inst->RegVirtualDevice = DevmgrRegVirtualDevice;
+ inst->UnRegVirtualDevice = DevmgrUnRegVirtualDevice;
+}
+
+struct HDIDeviceManager *HDIDeviceManagerGet(void)
+{
+ struct HDIServiceManager *serviceMgr = HDIServiceManagerGet();
+ if (serviceMgr == NULL) {
+ return NULL;
+ }
+ struct HdfRemoteService *remote = serviceMgr->GetService(serviceMgr, DEVICE_MANAGER_SERVICE);
+ HDIServiceManagerRelease(serviceMgr);
+ if (remote == NULL) {
+ HDF_LOGE("%s: hdi service %s not found", __func__, DEVICE_MANAGER_SERVICE);
+ return NULL;
+ }
+
+ struct HDIDeviceManager *iDevMgr = OsalMemAlloc(sizeof(struct HDIDeviceManager));
+ if (iDevMgr == NULL) {
+ HDF_LOGE("%s: OOM", __func__);
+ HdfRemoteServiceRecycle(remote);
+ return NULL;
+ }
+
+ iDevMgr->remote = remote;
+ HDIDeviceManagerConstruct(iDevMgr);
+ return iDevMgr;
+}
+
+void HDIDeviceManagerRelease(struct HDIDeviceManager *devmgr)
+{
+ if (devmgr == NULL) {
+ return;
+ }
+
+ HdfRemoteServiceRecycle(devmgr->remote);
+ OsalMemFree(devmgr);
+}
\ No newline at end of file
diff --git a/uhdf2/hdi/src/hdf_load_hdi.c b/uhdf2/hdi/src/hdf_load_hdi.c
new file mode 100644
index 0000000000000000000000000000000000000000..07c0dd0ca46e36c5845869dfa3b52d89d14c16d7
--- /dev/null
+++ b/uhdf2/hdi/src/hdf_load_hdi.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include
+#include
+#include "hdf_base.h"
+#include "hdf_load_hdi.h"
+#include "hdf_log.h"
+#include "osal_mem.h"
+#include "securec.h"
+
+#define HDF_LOG_TAG dev_load_hdi
+
+#ifdef __OHOS_STANDARD_SYS__
+#define HDI_SO_PATH "/system/lib"
+#else
+#define HDI_SO_PATH "/vendor/lib64"
+#endif
+struct HdiObject *LoadHdi(const char *name, uint32_t version)
+{
+ char path[PATH_MAX + 1] = {0};
+ char resolvedPath[PATH_MAX + 1] = {0};
+
+ if (name == NULL) {
+ HDF_LOGE("name is NULL");
+ return NULL;
+ }
+
+ if (snprintf_s(path, sizeof(path), sizeof(path) - 1, "%s/%s", HDI_SO_PATH, name) < 0) {
+ HDF_LOGE("%s snprintf_s failed", __func__);
+ return NULL;
+ }
+ if (realpath(path, resolvedPath) == NULL) {
+ HDF_LOGE("%s file name invalid", __func__);
+ return NULL;
+ }
+
+ struct HdiObject *hdi = (struct HdiObject *)OsalMemCalloc(sizeof(*hdi));
+ if (hdi == NULL) {
+ HDF_LOGE("%s malloc failed", __func__);
+ return NULL;
+ }
+ void *handler = dlopen(resolvedPath, RTLD_LAZY);
+ if (handler == NULL) {
+ HDF_LOGE("%s dlopen failed %s", __func__, dlerror());
+ OsalMemFree(hdi);
+ return NULL;
+ }
+ struct HdiBase *base = *(struct HdiBase **)dlsym(handler, "hdfHdiDesc");
+ if (base == NULL) {
+ HDF_LOGE("%s dlsym failed %s", __func__, dlerror());
+ dlclose(handler);
+ OsalMemFree(hdi);
+ return NULL;
+ }
+ if (version != base->moduleVersion) {
+ dlclose(handler);
+ OsalMemFree(hdi);
+ return NULL;
+ }
+ if (base->OpenHdi) {
+ base->OpenHdi();
+ }
+ hdi->dlHandler = (uintptr_t)handler;
+ hdi->hdiBase = base;
+ return hdi;
+}
+
+void CloseHdi(struct HdiObject *hdi)
+{
+ if (hdi == NULL || hdi->dlHandler == 0 || hdi->hdiBase == NULL) {
+ HDF_LOGE("%s para invalid", __func__);
+ return;
+ }
+
+ struct HdiBase *base = hdi->hdiBase;
+
+ if (base->CloseHdi) {
+ base->CloseHdi();
+ }
+
+ dlclose((void *)hdi->dlHandler);
+ hdi->dlHandler = 0;
+ hdi->hdiBase = NULL;
+ OsalMemFree(hdi);
+}
+
diff --git a/uhdf2/hdi/src/iservmgr_hdi.cpp b/uhdf2/hdi/src/iservmgr_hdi.cpp
new file mode 100755
index 0000000000000000000000000000000000000000..0e5b5d5106aade12a852f39f13d4fbf78dc3eadf
--- /dev/null
+++ b/uhdf2/hdi/src/iservmgr_hdi.cpp
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include
+#include
+#include "iservmgr_hdi.h"
+#include "hdf_log.h"
+
+namespace OHOS {
+namespace HDI {
+namespace ServiceManager {
+namespace V1_0 {
+constexpr int DEVICE_SERVICE_MANAGER_SA_ID = 5001;
+constexpr int DEVSVC_MANAGER_GET_SERVICE = 2;
+
+class ServiceManagerProxy : public IRemoteProxy {
+public:
+ explicit ServiceManagerProxy(const sptr& impl) : IRemoteProxy(impl) {}
+ ~ServiceManagerProxy() {}
+ virtual sptr GetService(const char* serviceName) override;
+private:
+ static inline BrokerDelegator delegator_;
+};
+
+sptr IServiceManager::Get()
+{
+ auto saManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
+ if (saManager == nullptr) {
+ HDF_LOGE("failed to get sa manager");
+ return nullptr;
+ }
+ sptr remote = saManager->GetSystemAbility(DEVICE_SERVICE_MANAGER_SA_ID);
+ if (remote != nullptr) {
+ return iface_cast(remote);
+ }
+
+ HDF_LOGE("failed to get sa hdf service manager");
+ return nullptr;
+}
+
+sptr ServiceManagerProxy::GetService(const char* serviceName)
+{
+ MessageParcel data;
+ MessageParcel reply;
+ if (!data.WriteCString(serviceName)) {
+ return nullptr;
+ }
+
+ MessageOption option;
+ int status = Remote()->SendRequest(DEVSVC_MANAGER_GET_SERVICE, data, reply, option);
+ if (status) {
+ HDF_LOGE("get hdi service call failed, %d", status);
+ return nullptr;
+ }
+ HDF_LOGE("get hdi service call success, %d", status);
+ return reply.ReadRemoteObject();
+}
+} // namespace V1_0
+} // namespace ServiceManager
+} // namespace HDI
+} // namespace OHOS
\ No newline at end of file
diff --git a/uhdf2/hdi/src/servmgr_hdi.c b/uhdf2/hdi/src/servmgr_hdi.c
new file mode 100644
index 0000000000000000000000000000000000000000..82312fab79ea1396809f7300b01ff020c59b30b4
--- /dev/null
+++ b/uhdf2/hdi/src/servmgr_hdi.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "servmgr_hdi.h"
+#include
+#include
+#include
+#include
+#include
+
+static int32_t ServiceManagerHdiCall(struct HDIServiceManager *iServMgr, int32_t id,
+ struct HdfSBuf *data, struct HdfSBuf *reply)
+{
+ if (iServMgr->remote == NULL || iServMgr->remote->dispatcher == NULL ||
+ iServMgr->remote->dispatcher->Dispatch == NULL) {
+ return HDF_ERR_INVALID_OBJECT;
+ }
+
+ return iServMgr->remote->dispatcher->Dispatch(iServMgr->remote, id, data, reply);
+}
+
+
+struct HdfRemoteService *HDIServiceManagerGetService(struct HDIServiceManager *iServMgr, const char* serviceName)
+{
+ if (iServMgr == NULL || serviceName == NULL) {
+ return NULL;
+ }
+
+ struct HdfSBuf *data = NULL;
+ struct HdfSBuf *reply = NULL;
+ struct HdfRemoteService *service = NULL;
+
+ do {
+ data = HdfSBufTypedObtain(SBUF_IPC);
+ reply = HdfSBufTypedObtain(SBUF_IPC);
+ if (data == NULL || reply == NULL) {
+ break;
+ }
+
+ if (!HdfSbufWriteString(data, serviceName)) {
+ break;
+ }
+ int status = ServiceManagerHdiCall(iServMgr, DEVSVC_MANAGER_GET_SERVICE, data, reply);
+ if (status == HDF_SUCCESS) {
+ service = HdfSBufReadRemoteService(reply);
+ } else {
+ HDF_LOGI("%s: %s not found", __func__, serviceName);
+ }
+ } while (0);
+
+ if (reply != NULL) {
+ HdfSBufRecycle(reply);
+ }
+ if (data != NULL) {
+ HdfSBufRecycle(data);
+ }
+ return service;
+}
+
+void HDIServiceManagerConstruct(struct HDIServiceManager *inst)
+{
+ inst->GetService = HDIServiceManagerGetService;
+}
+
+struct HDIServiceManager *HDIServiceManagerGet(void)
+{
+ struct HdfRemoteService *remote = HdfRemoteServiceGet(DEVICE_SERVICE_MANAGER_SA_ID);
+ if (remote == NULL) {
+ HDF_LOGE("%s: hdi service %s not found", __func__, DEVICE_SERVICE_MANAGER);
+ return NULL;
+ }
+
+ struct HDIServiceManager *iServMgr = OsalMemAlloc(sizeof(struct HDIServiceManager));
+ if (iServMgr == NULL) {
+ HDF_LOGE("%s: OOM", __func__);
+ HdfRemoteServiceRecycle(remote);
+ return NULL;
+ }
+
+ iServMgr->remote = remote;
+ HDIServiceManagerConstruct(iServMgr);
+ return iServMgr;
+}
+
+void HDIServiceManagerRelease(struct HDIServiceManager *servmgr)
+{
+ if (servmgr == NULL) {
+ return;
+ }
+
+ HdfRemoteServiceRecycle(servmgr->remote);
+ OsalMemFree(servmgr);
+}
\ No newline at end of file
diff --git a/uhdf2/hdi/test/BUILD.gn b/uhdf2/hdi/test/BUILD.gn
new file mode 100755
index 0000000000000000000000000000000000000000..8e24ab1600e35ca7d395a75477a3ba5fd6ca31ff
--- /dev/null
+++ b/uhdf2/hdi/test/BUILD.gn
@@ -0,0 +1,78 @@
+# Copyright (c) 2021 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import("//build/test.gni")
+import("//drivers/adapter/uhdf2/uhdf.gni")
+
+module_output_path = "hdf/hdi"
+
+###########################palTest###########################
+
+ohos_unittest("HdiServiceManagerTest") {
+ module_out_path = module_output_path
+ sources = [ "servmgr/service_manager_hdi_c_test.cpp" ]
+
+ deps = [
+ "$hdf_uhdf_path/hdi:libhdi",
+ "$hdf_uhdf_path/ipc:libhdf_ipc_adapter",
+ "$hdf_uhdf_path/osal:libhdf_utils",
+ "//third_party/googletest:gmock_main",
+ "//third_party/googletest:gtest_main",
+ "//utils/native/base:utils",
+ ]
+
+ include_dirs = [ "$hdf_uhdf_path/host/test/unittest/sample_driver" ]
+
+ if (is_standard_system) {
+ external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
+ } else {
+ external_deps = [ "hilog:libhilog" ]
+ }
+}
+
+ohos_unittest("HdiServiceManagerTestCC") {
+ module_out_path = module_output_path
+ sources = [ "servmgr/service_manager_hdi_test.cpp" ]
+
+ deps = [
+ "$hdf_uhdf_path/hdi:libhdi",
+ "$hdf_uhdf_path/osal:libhdf_utils",
+ "//third_party/googletest:gmock_main",
+ "//third_party/googletest:gtest_main",
+ "//utils/native/base:utils",
+ ]
+
+ include_dirs = [ "$hdf_uhdf_path/host/test/unittest/sample_driver" ]
+ if (is_standard_system) {
+ external_deps = [
+ "communication_L2:ipc_core",
+ "hiviewdfx_hilog_native:libhilog",
+ "samgr_L2:samgr_proxy",
+ ]
+ } else {
+ external_deps = [
+ "hilog:libhilog",
+ "ipc:ipc_core",
+ "samgr:samgr_proxy",
+ ]
+ }
+}
+
+###########################end###########################
+group("unittest") {
+ testonly = true
+ deps = [
+ ":HdiServiceManagerTest",
+ ":HdiServiceManagerTestCC",
+ ]
+}
diff --git a/uhdf2/hdi/test/dev_query/hdf_dev_query_test.c b/uhdf2/hdi/test/dev_query/hdf_dev_query_test.c
new file mode 100644
index 0000000000000000000000000000000000000000..4afe0f4cb44e6037fc7a4385bdc36f10de9b1daf
--- /dev/null
+++ b/uhdf2/hdi/test/dev_query/hdf_dev_query_test.c
@@ -0,0 +1,222 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "hdf_log.h"
+#include "devmgr_hdi.h"
+#include "osal_time.h"
+
+static int32_t g_testItemCnt = 0;
+static int32_t g_testItemFailCnt = 0;
+
+#define HDF_USABLE_DEVICE_CNT 100
+#define HDF_UNUSABLE_DEVICE_CNT 10
+#define HDF_QUERY_TIME_RANGE 10
+#define HDF_QUERY_DEVICE_ONE 0xffff
+#define HDF_QUERY_DEVICE_MORE 1000
+#define HDF_MICRO_UNIT 1000000
+#define TEST_ITEM_CNT 3
+#define USABLE 0
+#define UNUSABLE 1
+#define FREE 2
+
+static int g_index[TEST_ITEM_CNT];
+static uint64_t g_totalUsec[TEST_ITEM_CNT];
+
+#define GET_TIME_BEGIN(time) OsalGetTime(time)
+#define GET_TIME_END(index, time1, time2, diff) do { \
+ OsalGetTime(time2); \
+ OsalDiffTime(time1, time2, diff); \
+ CalcAverageTime(index, diff); \
+} while (0)
+
+#define UT_TEST_CHECK_RET(val, flag) do { \
+ if (!(val)) { \
+ HDF_LOGE("[HDF_TEST] %s line:%d HDF_TEST_FAIL", __func__, __LINE__); \
+ printf("[HDF_TEST] %s line:%d HDF_TEST_FAIL\r\n", __func__, __LINE__); \
+ g_testItemFailCnt++; \
+ } else if ((flag)) { \
+ HDF_LOGD("[HDF_TEST] %s line:%d HDF_TEST_PASS", __func__, __LINE__); \
+ printf("[HDF_TEST] %s line:%d HDF_TEST_PASS\r\n", __func__, __LINE__); \
+ } \
+ g_testItemCnt++; \
+} while (0)
+
+#define HDF_LOG_TAG hdf_query_device_test
+
+void PrintTestResult()
+{
+ HDF_LOGE("[HDF_TEST] %s test items: %d", __func__, g_testItemCnt);
+ HDF_LOGE("[HDF_TEST] %s test PASS: %d", __func__, g_testItemCnt - g_testItemFailCnt);
+ HDF_LOGE("[HDF_TEST] %s test FAIL: %d", __func__, g_testItemFailCnt);
+ printf("[HDF_TEST] %s test items: %d\r\n", __func__, g_testItemCnt);
+ printf("[HDF_TEST] %s test PASS: %d\r\n", __func__, g_testItemCnt - g_testItemFailCnt);
+ printf("[HDF_TEST] %s test FAIL: %d\r\n", __func__, g_testItemFailCnt);
+}
+
+static void CalcAverageTime(int index, const OsalTimespec *diff)
+{
+ g_totalUsec[index] += diff->sec * HDF_MICRO_UNIT + diff->usec;
+ g_index[index]++;
+}
+
+static void CheckAverageTime()
+{
+ HDF_LOGD("[HDF_TEST] %s line:%d test query usable %d time use time:%lu us",
+ __func__, __LINE__, g_index[USABLE], g_totalUsec[USABLE]);
+ printf("[HDF_TEST] %s line:%d test query usable %d time use time: %lu us\r\n",
+ __func__, __LINE__, g_index[USABLE], g_totalUsec[USABLE]);
+
+ HDF_LOGD("[HDF_TEST] %s line:%d test query unusable %d time use time:%lu us",
+ __func__, __LINE__, g_index[UNUSABLE], g_totalUsec[UNUSABLE]);
+ printf("[HDF_TEST] %s line:%d test query nusable %d time use time: %lu us\r\n",
+ __func__, __LINE__, g_index[UNUSABLE], g_totalUsec[UNUSABLE]);
+
+ HDF_LOGD("[HDF_TEST] %s line:%d test query free %d time use time:%lu us",
+ __func__, __LINE__, g_index[FREE], g_totalUsec[FREE]);
+ printf("[HDF_TEST] %s line:%d test query free %d time use time: %lu us\r\n",
+ __func__, __LINE__, g_index[FREE], g_totalUsec[FREE]);
+
+ UT_TEST_CHECK_RET((g_totalUsec[USABLE] / HDF_KILO_UNIT / g_index[USABLE]) <= HDF_QUERY_TIME_RANGE, true);
+ UT_TEST_CHECK_RET((g_totalUsec[UNUSABLE] / HDF_KILO_UNIT / g_index[UNUSABLE]) <= HDF_QUERY_TIME_RANGE, true);
+ UT_TEST_CHECK_RET((g_totalUsec[FREE] / HDF_KILO_UNIT / g_index[FREE]) <= HDF_QUERY_TIME_RANGE, true);
+}
+
+
+void HdfFreeQueryDeviceList(struct DeviceInfoList *list)
+{
+ struct HDIDeviceManager *iDevmgr = HDIDeviceManagerGet();
+ if (iDevmgr == NULL) {
+ return;
+ }
+
+ iDevmgr->FreeQueryDeviceList(iDevmgr, list);
+
+ HDIDeviceManagerRelease(iDevmgr);
+}
+
+int32_t HdfQueryUsableDeviceInfo(struct DeviceInfoList *list)
+{
+ struct HDIDeviceManager *iDevmgr = HDIDeviceManagerGet();
+ if (iDevmgr == NULL) {
+ return HDF_DEV_ERR_NO_DEVICE_SERVICE;
+ }
+
+ int32_t ret = iDevmgr->QueryUsableDeviceInfo(iDevmgr, list);
+
+ HDIDeviceManagerRelease(iDevmgr);
+ return ret;
+}
+
+int32_t HdfQueryUnusableDeviceInfo(struct DeviceInfoList *list)
+{
+ struct HDIDeviceManager *iDevmgr = HDIDeviceManagerGet();
+ if (iDevmgr == NULL) {
+ return HDF_DEV_ERR_NO_DEVICE_SERVICE;
+ }
+
+ int32_t ret = iDevmgr->QueryUnusableDeviceInfo(iDevmgr, list);
+
+ HDIDeviceManagerRelease(iDevmgr);
+ return ret;
+}
+
+/*
+ * HDF_QUERY_DEVICE_BaseFunction_AR_001 HDF_QUERY_DEVICE_BaseFunction_AR_002
+ * HDF_QUERY_DEVICE_BaseFunction_AR_005 HDF_QUERY_DEVICE_BaseFunction_AR_006
+ */
+static void QueryDeviceUsableTest(int index)
+{
+ int32_t ret;
+ OsalTimespec time1 = { 0, 0 };
+ OsalTimespec time2 = { 0, 0 };
+ OsalTimespec diff = { 0, 0 };
+ bool flag = (index == HDF_QUERY_DEVICE_ONE) ? true : false;
+
+ struct DeviceInfoList list;
+ struct DeviceInfoNode *devNode = NULL;
+ GET_TIME_BEGIN(&time1);
+
+ ret = HdfQueryUsableDeviceInfo(&list);
+ GET_TIME_END(USABLE, &time1, &time2, &diff);
+ UT_TEST_CHECK_RET(ret == HDF_SUCCESS, flag);
+ if (ret == HDF_SUCCESS) {
+ UT_TEST_CHECK_RET(list.deviceCnt == HDF_USABLE_DEVICE_CNT, flag);
+ HDF_LOGD("[HDF_TEST] %s usable:%d line:%d", __func__, list.deviceCnt, __LINE__);
+ if (flag) {
+ printf("[HDF_TEST] %s usable:%d line:%d\r\n", __func__, list.deviceCnt, __LINE__);
+ }
+ DLIST_FOR_EACH_ENTRY(devNode, &list.list, struct DeviceInfoNode, node) {
+ HDF_LOGD("usable: %s %d", devNode->svcName, devNode->deviceType);
+ }
+ } else {
+ HDF_LOGE("[HDF_TEST] %s line:%d", __func__, __LINE__);
+ }
+
+ GET_TIME_BEGIN(&time1);
+ HdfFreeQueryDeviceList(&list);
+ GET_TIME_END(FREE, &time1, &time2, &diff);
+}
+
+/* HDF_QUERY_DEVICE_BaseFunction_AR_003 HDF_QUERY_DEVICE_BaseFunction_AR_004 HDF_QUERY_DEVICE_BaseFunction_AR_007 */
+static void QueryDeviceUnusableTest(int index)
+{
+ int32_t ret;
+ OsalTimespec time1 = {0, 0};
+ OsalTimespec time2 = {0, 0};
+ OsalTimespec diff = {0, 0};
+ bool flag = (index == HDF_QUERY_DEVICE_ONE) ? true : false;
+
+ struct DeviceInfoList list;
+ struct DeviceInfoNode *devNode = NULL;
+ GET_TIME_BEGIN(&time1);
+ ret = HdfQueryUnusableDeviceInfo(&list);
+ GET_TIME_END(UNUSABLE, &time1, &time2, &diff);
+ UT_TEST_CHECK_RET(ret == HDF_SUCCESS, flag);
+ if (ret == HDF_SUCCESS) {
+ UT_TEST_CHECK_RET(list.deviceCnt == HDF_UNUSABLE_DEVICE_CNT, flag);
+ HDF_LOGD("[HDF_TEST] %s unusable:%d line:%d", __func__, list.deviceCnt, __LINE__);
+ if (flag) {
+ printf("[HDF_TEST] %s unusable:%d line:%d\r\n", __func__, list.deviceCnt, __LINE__);
+ }
+ DLIST_FOR_EACH_ENTRY(devNode, &list.list, struct DeviceInfoNode, node) {
+ HDF_LOGD("[HDF_TEST] usable: %s %d", devNode->svcName, devNode->deviceType);
+ }
+ } else {
+ HDF_LOGE("%s %d", __func__, __LINE__);
+ }
+
+ HdfFreeQueryDeviceList(&list);
+ GET_TIME_END(FREE, &time1, &time2, &diff);
+}
+
+/* HDF_QUERY_DEVICE_BaseFunction_AR_008 */
+int main(int argc, char **argv)
+{
+ (void)argv;
+ if (argc == 1) {
+ QueryDeviceUsableTest(HDF_QUERY_DEVICE_ONE);
+ QueryDeviceUnusableTest(HDF_QUERY_DEVICE_ONE);
+ } else {
+ int testCnt = HDF_QUERY_DEVICE_MORE;
+ for (int i = 0; i < testCnt; i++) {
+ QueryDeviceUsableTest(i);
+ QueryDeviceUnusableTest(i);
+ }
+ }
+ CheckAverageTime();
+ PrintTestResult();
+ return 0;
+}
+
diff --git a/uhdf2/hdi/test/dev_query/unittest/hcs/tas/device_info.hcs b/uhdf2/hdi/test/dev_query/unittest/hcs/tas/device_info.hcs
new file mode 100755
index 0000000000000000000000000000000000000000..6a917fdb271ef90b14522384fec047cf242ab157
--- /dev/null
+++ b/uhdf2/hdi/test/dev_query/unittest/hcs/tas/device_info.hcs
@@ -0,0 +1,1050 @@
+ root {
+ device_info {
+ match_attr = "hdf_manager";
+ template host {
+ hostName = "";
+ priority = 100;
+ template device {
+ template deviceNode {
+ policy = 0;
+ priority = 100;
+ preload = 0;
+ permission = 0664;
+ moduleName = "";
+ serviceName = "";
+ deviceMatchAttr = "";
+ }
+ }
+ }
+ platform :: host {
+ hostName = "platform_host";
+ priority = 50;
+ driver_io_ability :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "sample_driver";
+ }
+ }
+ driver_io_ability1 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "sample_driver1";
+ }
+ }
+ driver_io_ability2 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "sample_driver2";
+ }
+ }
+ driver_io_ability3 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "sample_driver3";
+ }
+ }
+ driver_io_ability4 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "sample_driver4";
+ }
+ }
+ driver_io_ability5 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "sample_driver5";
+ }
+ }
+ driver_io_ability6 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver1.so";
+ serviceName = "sample_driver_no_SO";
+ }
+ }
+ driver_io_ability7 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "sample_driver7";
+ }
+ }
+ driver_io_ability8 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "sample_driver8";
+ }
+ }
+ driver_io_ability9 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "sample_driver9";
+ }
+ }
+ driver_io_ability10 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "sample_driver10";
+ }
+ }
+ }
+ serviceA :: host {
+ hostName = "serviceA_host";
+ priority = 50;
+ serviceA :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceA_driver";
+ }
+ }
+ serviceA1 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceA_driver1";
+ }
+ }
+ serviceA2 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceA_driver2";
+ }
+ }
+ serviceA3 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceA_driver3";
+ }
+ }
+ serviceA4 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceA_driver4";
+ }
+ }
+ serviceA5 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceA_driver5";
+ }
+ }
+ serviceA6 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver1.so";
+ serviceName = "serviceA_driver_no_SO";
+ }
+ }
+ serviceA7 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceA_driver7";
+ }
+ }
+ serviceA8 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceA_driver8";
+ }
+ }
+ serviceA9 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceA_driver9";
+ }
+ }
+ serviceA10 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceA_driver10";
+ }
+ }
+ }
+ serviceB :: host {
+ hostName = "serviceB_host";
+ priority = 50;
+ serviceB :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceB_driver";
+ }
+ }
+ serviceB1 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceB_driver1";
+ }
+ }
+ serviceB2 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceB_driver2";
+ }
+ }
+ serviceB3 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceB_driver3";
+ }
+ }
+ serviceB4 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceB_driver4";
+ }
+ }
+ serviceB5 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceB_driver5";
+ }
+ }
+ serviceB6 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver1.so";
+ serviceName = "serviceB_driver_no_SO";
+ }
+ }
+ serviceB7 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceB_driver7";
+ }
+ }
+ serviceB8 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceB_driver8";
+ }
+ }
+ serviceB9 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceB_driver9";
+ }
+ }
+ serviceB10 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceB_driver10";
+ }
+ }
+ }
+ serviceC :: host {
+ hostName = "serviceC_host";
+ priority = 50;
+ serviceC :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceC_driver";
+ }
+ }
+ serviceC1 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceC_driver1";
+ }
+ }
+ serviceC2 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceC_driver2";
+ }
+ }
+ serviceC3 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceC_driver3";
+ }
+ }
+ serviceC4 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceC_driver4";
+ }
+ }
+ serviceC5 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceC_driver5";
+ }
+ }
+ serviceC6 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver1.so";
+ serviceName = "serviceC_driver_no_SO";
+ }
+ }
+ serviceC7 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceC_driver7";
+ }
+ }
+ serviceC8 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceC_driver8";
+ }
+ }
+ serviceC9 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceC_driver9";
+ }
+ }
+ serviceC10 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceC_driver10";
+ }
+ }
+ }
+ serviceD :: host {
+ hostName = "serviceD_host";
+ priority = 50;
+ serviceD :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceD_driver";
+ }
+ }
+ serviceD1 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceD_driver1";
+ }
+ }
+ serviceD2 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceD_driver2";
+ }
+ }
+ serviceD3 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceD_driver3";
+ }
+ }
+ serviceD4 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceD_driver4";
+ }
+ }
+ serviceD5 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceD_driver5";
+ }
+ }
+ serviceD6 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver1.so";
+ serviceName = "serviceD_driver_no_SO";
+ }
+ }
+ serviceD7 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceD_driver7";
+ }
+ }
+ serviceD8 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceD_driver8";
+ }
+ }
+ serviceD9 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceD_driver9";
+ }
+ }
+ serviceD10 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceD_driver10";
+ }
+ }
+ }
+ serviceE :: host {
+ hostName = "serviceE_host";
+ priority = 50;
+ serviceE :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceE_driver";
+ }
+ }
+ serviceE1 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceE_driver1";
+ }
+ }
+ serviceE2 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceE_driver2";
+ }
+ }
+ serviceE3 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceE_driver3";
+ }
+ }
+ serviceE4 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceE_driver4";
+ }
+ }
+ serviceE5 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceE_driver5";
+ }
+ }
+ serviceE6 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver1.so";
+ serviceName = "serviceE_driver_no_SO";
+ }
+ }
+ serviceE7 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceE_driver7";
+ }
+ }
+ serviceE8 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceE_driver8";
+ }
+ }
+ serviceE9 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceE_driver9";
+ }
+ }
+ serviceE10 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceE_driver10";
+ }
+ }
+ }
+ serviceF :: host {
+ hostName = "serviceF_host";
+ priority = 50;
+ serviceF :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceF_driver";
+ }
+ }
+ serviceF1 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceF_driver1";
+ }
+ }
+ serviceF2 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceF_driver2";
+ }
+ }
+ serviceF3 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceF_driver3";
+ }
+ }
+ serviceF4 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceF_driver4";
+ }
+ }
+ serviceF5 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceF_driver5";
+ }
+ }
+ serviceF6 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver1.so";
+ serviceName = "serviceF_driver_no_SO";
+ }
+ }
+ serviceF7 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceF_driver7";
+ }
+ }
+ serviceF8 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceF_driver8";
+ }
+ }
+ serviceF9 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceF_driver9";
+ }
+ }
+ serviceF10 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceF_driver10";
+ }
+ }
+ }
+ serviceH :: host {
+ hostName = "serviceH_host";
+ priority = 50;
+ serviceH :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceH_driver";
+ }
+ }
+ serviceH1 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceH_driver1";
+ }
+ }
+ serviceH2 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceH_driver2";
+ }
+ }
+ serviceH3 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceH_driver3";
+ }
+ }
+ serviceH4 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceH_driver4";
+ }
+ }
+ serviceH5 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceH_driver5";
+ }
+ }
+ serviceH6 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver1.so";
+ serviceName = "serviceH_driver_no_SO";
+ }
+ }
+ serviceH7 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceH_driver7";
+ }
+ }
+ serviceH8 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceH_driver8";
+ }
+ }
+ serviceH9 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceH_driver9";
+ }
+ }
+ serviceH10 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceH_driver10";
+ }
+ }
+ }
+ serviceG :: host {
+ hostName = "serviceG_host";
+ priority = 50;
+ serviceG :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceG_driver";
+ }
+ }
+ serviceG1 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceG_driver1";
+ }
+ }
+ serviceG2 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceG_driver2";
+ }
+ }
+ serviceG3 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceG_driver3";
+ }
+ }
+ serviceG4 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceG_driver4";
+ }
+ }
+ serviceG5 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceG_driver5";
+ }
+ }
+ serviceG6 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver1.so";
+ serviceName = "serviceG_driver_no_SO";
+ }
+ }
+ serviceG7 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceG_driver7";
+ }
+ }
+ serviceG8 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceG_driver8";
+ }
+ }
+ serviceG9 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceG_driver9";
+ }
+ }
+ serviceG10 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceG_driver10";
+ }
+ }
+ }
+ serviceI :: host {
+ hostName = "serviceI_host";
+ priority = 50;
+ serviceI :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceI_driver";
+ }
+ }
+ serviceI1 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceI_driver1";
+ }
+ }
+ serviceI2 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceI_driver2";
+ }
+ }
+ serviceI3 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceI_driver3";
+ }
+ }
+ serviceI4 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceI_driver4";
+ }
+ }
+ serviceI5 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceI_driver5";
+ }
+ }
+ serviceI6 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver1.so";
+ serviceName = "serviceI_driver_no_SO";
+ }
+ }
+ serviceI7 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceI_driver7";
+ }
+ }
+ serviceI8 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceI_driver8";
+ }
+ }
+ serviceI9 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceI_driver9";
+ }
+ }
+ serviceI10 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0644;
+ moduleName = "hdf_test_query_device_driver.so";
+ serviceName = "serviceI_driver10";
+ }
+ }
+ }
+ }
+}
diff --git a/uhdf2/hdi/test/dev_query/unittest/sample_driver/hdf_sample_driver.c b/uhdf2/hdi/test/dev_query/unittest/sample_driver/hdf_sample_driver.c
new file mode 100644
index 0000000000000000000000000000000000000000..df2e8ff87a87ae84350680716be72bbec5c03c90
--- /dev/null
+++ b/uhdf2/hdi/test/dev_query/unittest/sample_driver/hdf_sample_driver.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "hdf_log.h"
+#include "hdf_base.h"
+#include "hdf_device_desc.h"
+
+#define HDF_LOG_TAG hdf_sample_driver
+
+int32_t HdfSampleDriverBind(struct HdfDeviceObject *para)
+{
+ (void)para;
+
+ HDF_LOGE("%s", __func__);
+ return 0;
+}
+
+int32_t HdfSampleDriverInit(struct HdfDeviceObject *para)
+{
+ (void)para;
+
+ HDF_LOGE("%s", __func__);
+ return 0;
+}
+
+void HdfSampleDriverRelease(struct HdfDeviceObject *para)
+{
+ (void)para;
+
+ HDF_LOGE("%s", __func__);
+}
+
+struct HdfDriverEntry g_sampleDriverEntry = {
+ .moduleVersion = 1,
+ .Bind = HdfSampleDriverBind,
+ .Init = HdfSampleDriverInit,
+ .Release = HdfSampleDriverRelease,
+ .moduleName = "sample_driver",
+};
+HDF_INIT(g_sampleDriverEntry);
+
diff --git a/uhdf2/hdi/test/hdi_sample/sample_client_c/sample_client_c_test.cpp b/uhdf2/hdi/test/hdi_sample/sample_client_c/sample_client_c_test.cpp
new file mode 100755
index 0000000000000000000000000000000000000000..7580b3b6b1a9d877f4790c9418b788d71851b00b
--- /dev/null
+++ b/uhdf2/hdi/test/hdi_sample/sample_client_c/sample_client_c_test.cpp
@@ -0,0 +1,335 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include "securec.h"
+#include "isample.h"
+
+using namespace OHOS;
+using namespace testing::ext;
+
+#define HDF_LOG_TAG sample_client_c_test
+
+constexpr const char *TEST_SERVICE_NAME = "sample_service_c";
+
+class SampleObjCTest : public testing::Test {
+public:
+ static void SetUpTestCase(){}
+ static void TearDownTestCase(){}
+ void SetUp(){}
+ void TearDown(){}
+};
+
+HWTEST_F(SampleObjCTest, SampleObjCTest_001, TestSize.Level0)
+{
+ struct ISample *sampleObj = HdiSampleGet(TEST_SERVICE_NAME);
+ ASSERT_TRUE(sampleObj != nullptr);
+
+ bool input = true;
+ bool output = false;
+
+ int32_t ec = sampleObj->BooleanTypeTest(sampleObj, input, &output);
+
+ ASSERT_EQ(ec, HDF_SUCCESS);
+ ASSERT_TRUE(output);
+
+ HdiSampleRelease(sampleObj);
+}
+
+HWTEST_F(SampleObjCTest, SampleObjCTest_002, TestSize.Level0)
+{
+ struct ISample *sampleObj = HdiSampleGet(TEST_SERVICE_NAME);
+ ASSERT_TRUE(sampleObj != nullptr);
+
+ int8_t input = 10;
+ int8_t output;
+
+ int32_t ec = sampleObj->ByteTypeTest(sampleObj, input, &output);
+
+ ASSERT_EQ(ec, HDF_SUCCESS);
+ ASSERT_EQ(input, output);
+
+ HdiSampleRelease(sampleObj);
+}
+
+HWTEST_F(SampleObjCTest, SampleObjCTest_003, TestSize.Level0)
+{
+ struct ISample *sampleObj = HdiSampleGet(TEST_SERVICE_NAME);
+ ASSERT_TRUE(sampleObj != nullptr);
+
+ int16_t input = 10;
+ int16_t output;
+
+ int32_t ec = sampleObj->ShortTypeTest(sampleObj, input, &output);
+
+ ASSERT_EQ(ec, HDF_SUCCESS);
+ ASSERT_EQ(input, output);
+
+ HdiSampleRelease(sampleObj);
+}
+
+HWTEST_F(SampleObjCTest, SampleObjCTest_004, TestSize.Level0)
+{
+ struct ISample *sampleObj = HdiSampleGet(TEST_SERVICE_NAME);
+ ASSERT_TRUE(sampleObj != nullptr);
+
+ int32_t input = 10;
+ int32_t output;
+
+ int32_t ec = sampleObj->IntTypeTest(sampleObj, input, &output);
+
+ ASSERT_EQ(ec, HDF_SUCCESS);
+ ASSERT_EQ(input, output);
+
+ HdiSampleRelease(sampleObj);
+}
+
+HWTEST_F(SampleObjCTest, SampleObjCTest_005, TestSize.Level0)
+{
+ struct ISample *sampleObj = HdiSampleGet(TEST_SERVICE_NAME);
+ ASSERT_TRUE(sampleObj != nullptr);
+
+ int64_t input = 10;
+ int64_t output;
+
+ int32_t ec = sampleObj->LongTypeTest(sampleObj, input, &output);
+
+ ASSERT_EQ(ec, HDF_SUCCESS);
+ ASSERT_EQ(input, output);
+
+ HdiSampleRelease(sampleObj);
+}
+
+HWTEST_F(SampleObjCTest, SampleObjCTest_006, TestSize.Level0)
+{
+ struct ISample *sampleObj = HdiSampleGet(TEST_SERVICE_NAME);
+ ASSERT_TRUE(sampleObj != nullptr);
+
+ float input = 10;
+ float output;
+
+ int32_t ec = sampleObj->FloatTypeTest(sampleObj, input, &output);
+
+ ASSERT_EQ(ec, HDF_SUCCESS);
+ ASSERT_EQ(input, output);
+
+ HdiSampleRelease(sampleObj);
+}
+
+HWTEST_F(SampleObjCTest, SampleObjCTest_007, TestSize.Level0)
+{
+ struct ISample *sampleObj = HdiSampleGet(TEST_SERVICE_NAME);
+ ASSERT_TRUE(sampleObj != nullptr);
+
+ double input = 10;
+ double output;
+
+ int32_t ec = sampleObj->DoubleTypeTest(sampleObj, input, &output);
+
+ ASSERT_EQ(ec, HDF_SUCCESS);
+ ASSERT_EQ(input, output);
+
+ HdiSampleRelease(sampleObj);
+}
+
+HWTEST_F(SampleObjCTest, SampleObjCTest_008, TestSize.Level0)
+{
+ struct ISample *sampleObj = HdiSampleGet(TEST_SERVICE_NAME);
+ ASSERT_TRUE(sampleObj != nullptr);
+
+ const char *input = "c sample client test";
+ char *output = nullptr;
+
+ int32_t ec = sampleObj->StringTypeTest(sampleObj, input, &output);
+
+ ASSERT_EQ(ec, HDF_SUCCESS);
+ EXPECT_STREQ(input, output);
+
+ HdiSampleRelease(sampleObj);
+}
+
+HWTEST_F(SampleObjCTest, SampleObjCTest_009, TestSize.Level0)
+{
+ struct ISample *sampleObj = HdiSampleGet(TEST_SERVICE_NAME);
+ ASSERT_TRUE(sampleObj != nullptr);
+
+ uint8_t input = 10;
+ uint8_t output;
+
+ int32_t ec = sampleObj->UcharTypeTest(sampleObj, input, &output);
+
+ ASSERT_EQ(ec, HDF_SUCCESS);
+ ASSERT_EQ(input, output);
+
+ HdiSampleRelease(sampleObj);
+}
+
+HWTEST_F(SampleObjCTest, SampleObjCTest_010, TestSize.Level0)
+{
+ struct ISample *sampleObj = HdiSampleGet(TEST_SERVICE_NAME);
+ ASSERT_TRUE(sampleObj != nullptr);
+
+ uint16_t input = 10;
+ uint16_t output;
+
+ int32_t ec = sampleObj->UshortTypeTest(sampleObj, input, &output);
+
+ ASSERT_EQ(ec, HDF_SUCCESS);
+ ASSERT_EQ(input, output);
+
+ HdiSampleRelease(sampleObj);
+}
+
+HWTEST_F(SampleObjCTest, SampleObjCTest_011, TestSize.Level0)
+{
+ struct ISample *sampleObj = HdiSampleGet(TEST_SERVICE_NAME);
+ ASSERT_TRUE(sampleObj != nullptr);
+
+ uint32_t input = 10;
+ uint32_t output;
+
+ int32_t ec = sampleObj->UintTypeTest(sampleObj, input, &output);
+
+ ASSERT_EQ(ec, HDF_SUCCESS);
+ ASSERT_EQ(input, output);
+
+ HdiSampleRelease(sampleObj);
+}
+
+HWTEST_F(SampleObjCTest, SampleObjCTest_012, TestSize.Level0)
+{
+ struct ISample *sampleObj = HdiSampleGet(TEST_SERVICE_NAME);
+ ASSERT_TRUE(sampleObj != nullptr);
+
+ uint64_t input = 10;
+ uint64_t output;
+
+ int32_t ec = sampleObj->UlongTypeTest(sampleObj, input, &output);
+
+ ASSERT_EQ(ec, HDF_SUCCESS);
+ ASSERT_EQ(input, output);
+
+ HdiSampleRelease(sampleObj);
+}
+
+HWTEST_F(SampleObjCTest, SampleObjCTest_013, TestSize.Level0)
+{
+ struct ISample *sampleObj = HdiSampleGet(TEST_SERVICE_NAME);
+ ASSERT_TRUE(sampleObj != nullptr);
+
+ uint32_t inSize = 5;
+ int8_t *input = (int8_t *)OsalMemAlloc(sizeof(int8_t) * inSize);
+ ASSERT_TRUE(input != nullptr);
+
+ for (uint32_t i = 0; i < inSize; i++) {
+ input[i] = static_cast(i);
+ }
+
+ uint32_t outSize = 0;
+ int8_t *output = nullptr;
+
+ int32_t ec = sampleObj->ListTypeTest(sampleObj, input, inSize, &output, &outSize);
+
+ ASSERT_EQ(ec, HDF_SUCCESS);
+ ASSERT_TRUE(output != nullptr);
+ ASSERT_EQ(outSize, inSize);
+
+ for (uint32_t i = 0; i < outSize; i++) {
+ ASSERT_EQ(output[i], input[i]);
+ }
+
+ if (input != nullptr) {
+ OsalMemFree(input);
+ }
+ if (output != nullptr) {
+ OsalMemFree(output);
+ }
+}
+
+HWTEST_F(SampleObjCTest, SampleObjCTest_014, TestSize.Level0)
+{
+ struct ISample *sampleObj = HdiSampleGet(TEST_SERVICE_NAME);
+ ASSERT_TRUE(sampleObj != nullptr);
+
+ uint32_t inSize = 5;
+ int8_t *input = (int8_t *)OsalMemAlloc(sizeof(int8_t) * inSize);
+ ASSERT_TRUE(input != nullptr);
+
+ for (uint32_t i = 0; i < inSize; i++) {
+ input[i] = static_cast(i);
+ }
+
+ uint32_t outSize = 0;
+ int8_t *output = nullptr;
+
+ int32_t ec = sampleObj->ArrayTypeTest(sampleObj, input, inSize, &output, &outSize);
+
+ ASSERT_EQ(ec, HDF_SUCCESS);
+ ASSERT_TRUE(output != nullptr);
+ ASSERT_EQ(outSize, inSize);
+
+ for (uint32_t i = 0; i < outSize; i++) {
+ ASSERT_EQ(output[i], input[i]);
+ }
+
+ if (input != nullptr) {
+ OsalMemFree(input);
+ }
+ if (output != nullptr) {
+ OsalMemFree(output);
+ }
+}
+
+HWTEST_F(SampleObjCTest, SampleObjCTest_015, TestSize.Level0)
+{
+ struct ISample *sampleObj = HdiSampleGet(TEST_SERVICE_NAME);
+ ASSERT_TRUE(sampleObj != nullptr);
+
+ struct StructSample input = {
+ .first = 1,
+ .second = 2,
+ };
+
+ struct StructSample output;
+ int32_t ec = sampleObj->StructTypeTest(sampleObj, &input, &output);
+
+ ASSERT_EQ(ec, HDF_SUCCESS);
+ ASSERT_EQ(output.first, input.first);
+ ASSERT_EQ(output.second, input.second);
+
+ HdiSampleRelease(sampleObj);
+}
+
+HWTEST_F(SampleObjCTest, SampleObjCTest_016, TestSize.Level0)
+{
+ struct ISample *sampleObj = HdiSampleGet(TEST_SERVICE_NAME);
+ ASSERT_TRUE(sampleObj != nullptr);
+
+ enum EnumSample input = MEM_SECOND;
+ enum EnumSample output;
+
+ int32_t ec = sampleObj->EnumTypeTest(sampleObj, input, &output);
+
+ ASSERT_EQ(ec, HDF_SUCCESS);
+ ASSERT_EQ(input, output);
+
+ HdiSampleRelease(sampleObj);
+}
+
diff --git a/uhdf2/hdi/test/hdi_sample/sample_client_c/unittest/BUILD.gn b/uhdf2/hdi/test/hdi_sample/sample_client_c/unittest/BUILD.gn
new file mode 100755
index 0000000000000000000000000000000000000000..43755d139be5835faec7fd15af3f02293792b5f8
--- /dev/null
+++ b/uhdf2/hdi/test/hdi_sample/sample_client_c/unittest/BUILD.gn
@@ -0,0 +1,52 @@
+# Copyright (c) 2021 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import("//build/ohos.gni")
+import("//drivers/adapter/uhdf2/uhdf.gni")
+group("sample_client_c") {
+ deps = [ ":libsample_client_c" ]
+}
+
+ohos_shared_library("libsample_client_c") {
+
+ include_dirs = [
+ "$hdf_framework_path/ability/sbuf/include",
+ "$hdf_uhdf_path/manager/include",
+ "$hdf_uhdf_path/include/hdi",
+ ]
+
+ sources = [
+ "sample_proxy.c"
+ ]
+
+ deps = [
+ "//drivers/adapter/uhdf2/ipc:libhdf_ipc_adapter",
+ "//drivers/adapter/uhdf2/osal:libhdf_utils",
+ "//drivers/adapter/uhdf2/host:libhdf_host",
+ "$hdf_uhdf_path/hdi:libhdi"
+ ]
+
+ if (is_standard_system) {
+ external_deps = [
+ "hiviewdfx_hilog_native:libhilog",
+ ]
+ } else {
+ external_deps = [
+ "hilog:libhilog",
+ ]
+ }
+
+ # install_images = [ "vendor" ]
+ subsystem_name = "hdf"
+ part_name = "hdf"
+}
\ No newline at end of file
diff --git a/uhdf2/hdi/test/hdi_sample/sample_client_c/unittest/isample.h b/uhdf2/hdi/test/hdi_sample/sample_client_c/unittest/isample.h
new file mode 100644
index 0000000000000000000000000000000000000000..6aef4c06cb737046d196267316d81e2fce208378
--- /dev/null
+++ b/uhdf2/hdi/test/hdi_sample/sample_client_c/unittest/isample.h
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef HDI_SAMPLE_CLIENT_C_INF_H
+#define HDI_SAMPLE_CLIENT_C_INF_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+struct HdfRemoteService;
+
+struct StructSample {
+ int8_t first;
+ int16_t second;
+};
+
+enum EnumSample {
+ MEM_FIRST,
+ MEM_SECOND,
+ MEM_THIRD,
+};
+
+enum {
+ CMD_BOOLEAN_TYPE_TEST,
+ CMD_BYTE_TYPE_TEST,
+ CMD_SHORT_TYPE_TEST,
+ CMD_INT_TYPE_TEST,
+ CMD_LONG_TYPE_TEST,
+ CMD_FLOAT_TYPE_TEST,
+ CMD_DOUBLE_TYPE_TEST,
+ CMD_STRING_TYPE_TEST,
+ CMD_UCHAR_TYPE_TEST,
+ CMD_USHORT_TYPE_TEST,
+ CMD_UINT_TYPE_TEST,
+ CMD_ULONG_TYPE_TEST,
+ CMD_LIST_TYPE_TEST,
+ CMD_ARRAY_TYPE_TEST,
+ CMD_STRUCT_TYPE_TEST,
+ CMD_ENUM_TYPE_TEST,
+};
+
+struct ISample {
+ struct HdfRemoteService *remote;
+
+ int32_t (*BooleanTypeTest)(struct ISample *self, const bool input, bool *output);
+
+ int32_t (*ByteTypeTest)(struct ISample *self, const int8_t input, int8_t *output);
+
+ int32_t (*ShortTypeTest)(struct ISample *self, const int16_t input, int16_t *output);
+
+ int32_t (*IntTypeTest)(struct ISample *self, const int32_t input, int32_t *output);
+
+ int32_t (*LongTypeTest)(struct ISample *self, const int64_t input, int64_t *output);
+
+ int32_t (*FloatTypeTest)(struct ISample *self, const float input, float *output);
+
+ int32_t (*DoubleTypeTest)(struct ISample *self, const double input, double *output);
+
+ int32_t (*StringTypeTest)(struct ISample *self, const char* input, char **output);
+
+ int32_t (*UcharTypeTest)(struct ISample *self, const uint8_t input, uint8_t *output);
+
+ int32_t (*UshortTypeTest)(struct ISample *self, const uint16_t input, uint16_t *output);
+
+ int32_t (*UintTypeTest)(struct ISample *self, const uint32_t input, uint32_t *output);
+
+ int32_t (*UlongTypeTest)(struct ISample *self, const uint64_t input, uint64_t *output);
+
+ int32_t (*ListTypeTest)(struct ISample *self, const int8_t *input, const uint32_t inSize,
+ int8_t **output, uint32_t *outSize);
+
+ int32_t (*ArrayTypeTest)(struct ISample *self, const int8_t *input, const uint32_t inSize,
+ int8_t **output, uint32_t *outSize);
+
+ int32_t (*StructTypeTest)(struct ISample *self, const struct StructSample *input, struct StructSample *output);
+
+ int32_t (*EnumTypeTest)(struct ISample *self, const enum EnumSample input, enum EnumSample *output);
+};
+
+struct ISample *HdiSampleGet(const char *serviceName);
+
+void HdiSampleRelease(struct ISample *instance);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif // HDI_SAMPLE_CLIENT_C_INF_H
\ No newline at end of file
diff --git a/uhdf2/hdi/test/hdi_sample/sample_client_c/unittest/sample_proxy.c b/uhdf2/hdi/test/hdi_sample/sample_client_c/unittest/sample_proxy.c
new file mode 100644
index 0000000000000000000000000000000000000000..222b3b30b760445d103b1b208b1ce48c32832bcd
--- /dev/null
+++ b/uhdf2/hdi/test/hdi_sample/sample_client_c/unittest/sample_proxy.c
@@ -0,0 +1,844 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#include "isample.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+static int32_t SampleProxyCall(struct ISample *self,
+ int32_t id, struct HdfSBuf *data, struct HdfSBuf *reply)
+{
+ if (self->remote == NULL || self->remote->dispatcher == NULL ||
+ self->remote->dispatcher->Dispatch == NULL) {
+ HDF_LOGE("%{public}s: obj is null", __func__);
+ return HDF_ERR_INVALID_OBJECT;
+ }
+ return self->remote->dispatcher->Dispatch(self->remote, id, data, reply);
+}
+
+static int32_t SampleProxyBooleanTypeTest(struct ISample *self, const bool input, bool *output)
+{
+ int32_t ec = HDF_FAILURE;
+ if (self == NULL) {
+ return HDF_ERR_INVALID_PARAM;
+ }
+
+ struct HdfSBuf *data = HdfSBufTypedObtain(SBUF_IPC);
+ struct HdfSBuf *reply = HdfSBufTypedObtain(SBUF_IPC);
+
+ if (data == NULL || reply == NULL) {
+ HDF_LOGE("%{public}s: HdfSubf malloc failed!", __func__);
+ ec = HDF_ERR_MALLOC_FAIL;
+ goto finished;
+ }
+
+ if (!HdfSbufWriteUint32(data, (uint32_t)input)) {
+ HDF_LOGE("%{public}s: write bool input failed!", __func__);
+ ec = HDF_ERR_INVALID_PARAM;
+ goto finished;
+ }
+
+ ec = SampleProxyCall(self, CMD_BOOLEAN_TYPE_TEST, data, reply);
+ if (ec != HDF_SUCCESS) {
+ HDF_LOGE("%{public}s: call failed! error code is %{public}d", __func__, ec);
+ goto finished;
+ }
+
+ if (!HdfSbufReadUint32(reply, (uint32_t *)output)) {
+ HDF_LOGE("%{public}s: read result failed!", __func__);
+ goto finished;
+ }
+
+finished:
+ if (data != NULL) {
+ HdfSBufRecycle(data);
+ }
+ if (reply != NULL) {
+ HdfSBufRecycle(reply);
+ }
+ return ec;
+}
+
+static int32_t SampleProxyByteTypeTest(struct ISample *self, const int8_t input, int8_t *output)
+{
+ int32_t ec = HDF_FAILURE;
+ if (self == NULL) {
+ return HDF_ERR_INVALID_PARAM;
+ }
+
+ struct HdfSBuf *data = HdfSBufTypedObtain(SBUF_IPC);
+ struct HdfSBuf *reply = HdfSBufTypedObtain(SBUF_IPC);
+
+ if (data == NULL || reply == NULL) {
+ ec = HDF_ERR_MALLOC_FAIL;
+ goto finished;
+ }
+
+ if (!HdfSbufWriteInt8(data, input)) {
+ HDF_LOGE("%{public}s: write input failed!", __func__);
+ ec = HDF_ERR_INVALID_PARAM;
+ goto finished;
+ }
+
+ ec = SampleProxyCall(self, CMD_BYTE_TYPE_TEST, data, reply);
+ if (ec != HDF_SUCCESS) {
+ HDF_LOGE("%{public}s: call failed! error code is %{public}d", __func__, ec);
+ goto finished;
+ }
+
+ if (!HdfSbufReadInt8(reply, output)) {
+ HDF_LOGE("%{public}s: read result failed!", __func__);
+ goto finished;
+ }
+
+finished:
+ if (data != NULL) {
+ HdfSBufRecycle(data);
+ }
+ if (reply != NULL) {
+ HdfSBufRecycle(reply);
+ }
+ return ec;
+}
+
+static int32_t SampleProxyShortTypeTest(struct ISample *self, const int16_t input, int16_t *output)
+{
+ int32_t ec = HDF_FAILURE;
+ if (self == NULL) {
+ return HDF_ERR_INVALID_PARAM;
+ }
+
+ struct HdfSBuf *data = HdfSBufTypedObtain(SBUF_IPC);
+ struct HdfSBuf *reply = HdfSBufTypedObtain(SBUF_IPC);
+
+ if (data == NULL || reply == NULL) {
+ ec = HDF_ERR_MALLOC_FAIL;
+ goto finished;
+ }
+
+ if (!HdfSbufWriteInt16(data, input)) {
+ HDF_LOGE("%{public}s: write input failed!", __func__);
+ ec = HDF_ERR_INVALID_PARAM;
+ goto finished;
+ }
+
+ ec = SampleProxyCall(self, CMD_SHORT_TYPE_TEST, data, reply);
+ if (ec != HDF_SUCCESS) {
+ HDF_LOGE("%{public}s: call failed! error code is %{public}d", __func__, ec);
+ goto finished;
+ }
+
+ if (!HdfSbufReadInt16(reply, output)) {
+ HDF_LOGE("%{public}s: read result failed!", __func__);
+ goto finished;
+ }
+
+finished:
+ if (data != NULL) {
+ HdfSBufRecycle(data);
+ }
+ if (reply != NULL) {
+ HdfSBufRecycle(reply);
+ }
+ return ec;
+}
+
+static int32_t SampleProxyIntTypeTest(struct ISample *self, const int32_t input, int32_t *output)
+{
+ int32_t ec = HDF_FAILURE;
+ if (self == NULL) {
+ return HDF_ERR_INVALID_PARAM;
+ }
+
+ struct HdfSBuf *data = HdfSBufTypedObtain(SBUF_IPC);
+ struct HdfSBuf *reply = HdfSBufTypedObtain(SBUF_IPC);
+
+ if (data == NULL || reply == NULL) {
+ ec = HDF_ERR_MALLOC_FAIL;
+ goto finished;
+ }
+
+ if (!HdfSbufWriteInt32(data, input)) {
+ HDF_LOGE("%{public}s: write input failed!", __func__);
+ ec = HDF_ERR_INVALID_PARAM;
+ goto finished;
+ }
+
+ ec = SampleProxyCall(self, CMD_INT_TYPE_TEST, data, reply);
+ if (ec != HDF_SUCCESS) {
+ HDF_LOGE("%{public}s: call failed! error code is %{public}d", __func__, ec);
+ goto finished;
+ }
+
+ if (!HdfSbufReadInt32(reply, output)) {
+ HDF_LOGE("%{public}s: read result failed!", __func__);
+ goto finished;
+ }
+
+finished:
+ if (data != NULL) {
+ HdfSBufRecycle(data);
+ }
+ if (reply != NULL) {
+ HdfSBufRecycle(reply);
+ }
+ return ec;
+}
+
+static int32_t SampleProxyLongTypeTest(struct ISample *self, const int64_t input, int64_t *output)
+{
+ int32_t ec = HDF_FAILURE;
+ if (self == NULL) {
+ return HDF_ERR_INVALID_PARAM;
+ }
+
+ struct HdfSBuf *data = HdfSBufTypedObtain(SBUF_IPC);
+ struct HdfSBuf *reply = HdfSBufTypedObtain(SBUF_IPC);
+
+ if (data == NULL || reply == NULL) {
+ ec = HDF_ERR_MALLOC_FAIL;
+ goto finished;
+ }
+
+ if (!HdfSbufWriteInt64(data, input)) {
+ HDF_LOGE("%{public}s: write input failed!", __func__);
+ ec = HDF_ERR_INVALID_PARAM;
+ goto finished;
+ }
+
+ ec = SampleProxyCall(self, CMD_LONG_TYPE_TEST, data, reply);
+ if (ec != HDF_SUCCESS) {
+ HDF_LOGE("%{public}s: call failed! error code is %{public}d", __func__, ec);
+ goto finished;
+ }
+
+ if (!HdfSbufReadInt64(reply, output)) {
+ HDF_LOGE("%{public}s: read result failed!", __func__);
+ goto finished;
+ }
+
+finished:
+ if (data != NULL) {
+ HdfSBufRecycle(data);
+ }
+ if (reply != NULL) {
+ HdfSBufRecycle(reply);
+ }
+ return ec;
+}
+
+static int32_t SampleProxyFloatTypeTest(struct ISample *self, const float input, float *output)
+{
+ int32_t ec = HDF_FAILURE;
+ if (self == NULL) {
+ return HDF_ERR_INVALID_PARAM;
+ }
+
+ struct HdfSBuf *data = HdfSBufTypedObtain(SBUF_IPC);
+ struct HdfSBuf *reply = HdfSBufTypedObtain(SBUF_IPC);
+
+ if (data == NULL || reply == NULL) {
+ ec = HDF_ERR_MALLOC_FAIL;
+ goto finished;
+ }
+
+ if (!HdfSbufWriteFloat(data, input)) {
+ HDF_LOGE("%{public}s: write input failed!", __func__);
+ ec = HDF_ERR_INVALID_PARAM;
+ goto finished;
+ }
+
+ ec = SampleProxyCall(self, CMD_FLOAT_TYPE_TEST, data, reply);
+ if (ec != HDF_SUCCESS) {
+ HDF_LOGE("%{public}s: call failed! error code is %{public}d", __func__, ec);
+ goto finished;
+ }
+
+ if (!HdfSbufReadFloat(reply, output)) {
+ HDF_LOGE("%{public}s: read result failed!", __func__);
+ goto finished;
+ }
+
+finished:
+ if (data != NULL) {
+ HdfSBufRecycle(data);
+ }
+ if (reply != NULL) {
+ HdfSBufRecycle(reply);
+ }
+
+ return ec;
+}
+
+static int32_t SampleProxyDoubleTypeTest(struct ISample *self, const double input, double *output)
+{
+ int32_t ec = HDF_FAILURE;
+ if (self == NULL) {
+ return HDF_ERR_INVALID_PARAM;
+ }
+
+ struct HdfSBuf *data = HdfSBufTypedObtain(SBUF_IPC);
+ struct HdfSBuf *reply = HdfSBufTypedObtain(SBUF_IPC);
+
+ if (data == NULL || reply == NULL) {
+ ec = HDF_ERR_MALLOC_FAIL;
+ goto finished;
+ }
+
+ if (!HdfSbufWriteDouble(data, input)) {
+ HDF_LOGE("%{public}s: write input failed!", __func__);
+ ec = HDF_ERR_INVALID_PARAM;
+ goto finished;
+ }
+
+ ec = SampleProxyCall(self, CMD_DOUBLE_TYPE_TEST, data, reply);
+ if (ec != HDF_SUCCESS) {
+ HDF_LOGE("%{public}s: call failed! error code is %{public}d", __func__, ec);
+ goto finished;
+ }
+
+ if (!HdfSbufReadDouble(reply, output)) {
+ HDF_LOGE("%{public}s: read result failed!", __func__);
+ goto finished;
+ }
+
+finished:
+ if (data != NULL) {
+ HdfSBufRecycle(data);
+ }
+ if (reply != NULL) {
+ HdfSBufRecycle(reply);
+ }
+
+ return ec;
+}
+
+static int32_t SampleProxyStringTypeTest(struct ISample *self, const char* input, char **output)
+{
+ int32_t ec = HDF_FAILURE;
+ if (self == NULL || input == NULL) {
+ return HDF_ERR_INVALID_PARAM;
+ }
+
+ struct HdfSBuf *data = HdfSBufTypedObtain(SBUF_IPC);
+ struct HdfSBuf *reply = HdfSBufTypedObtain(SBUF_IPC);
+
+ if (data == NULL || reply == NULL) {
+ ec = HDF_ERR_MALLOC_FAIL;
+ goto finished;
+ }
+
+ if (!HdfSbufWriteString(data, input)) {
+ HDF_LOGE("%{public}s: write input failed!", __func__);
+ ec = HDF_ERR_INVALID_PARAM;
+ goto finished;
+ }
+
+ ec = SampleProxyCall(self, CMD_STRING_TYPE_TEST, data, reply);
+ if (ec != HDF_SUCCESS) {
+ HDF_LOGE("%{public}s: call failed! error code is %{public}d", __func__, ec);
+ goto finished;
+ }
+
+ const char *result = HdfSbufReadString(reply);
+ if (result == NULL) {
+ HDF_LOGE("%{public}s: read result failed!", __func__);
+ goto finished;
+ }
+ *output = strdup(result);
+
+finished:
+ if (data != NULL) {
+ HdfSBufRecycle(data);
+ }
+ if (reply != NULL) {
+ HdfSBufRecycle(reply);
+ }
+ return ec;
+}
+
+static int32_t SampleProxyUcharTypeTest(struct ISample *self, const uint8_t input, uint8_t *output)
+{
+ int32_t ec = HDF_FAILURE;
+ if (self == NULL) {
+ return HDF_ERR_INVALID_PARAM;
+ }
+
+ struct HdfSBuf *data = HdfSBufTypedObtain(SBUF_IPC);
+ struct HdfSBuf *reply = HdfSBufTypedObtain(SBUF_IPC);
+
+ if (data == NULL || reply == NULL) {
+ ec = HDF_ERR_MALLOC_FAIL;
+ goto finished;
+ }
+
+ if (!HdfSbufWriteUint8(data, input)) {
+ HDF_LOGE("%{public}s: write input failed!", __func__);
+ ec = HDF_ERR_INVALID_PARAM;
+ goto finished;
+ }
+
+ ec = SampleProxyCall(self, CMD_UCHAR_TYPE_TEST, data, reply);
+ if (ec != HDF_SUCCESS) {
+ HDF_LOGE("%{public}s: call failed! error code is %{public}d", __func__, ec);
+ goto finished;
+ }
+
+ if (!HdfSbufReadUint8(reply, output)) {
+ HDF_LOGE("%{public}s: read result failed!", __func__);
+ goto finished;
+ }
+
+finished:
+ if (data != NULL) {
+ HdfSBufRecycle(data);
+ }
+ if (reply != NULL) {
+ HdfSBufRecycle(reply);
+ }
+ return ec;
+}
+
+static int32_t SampleProxyUshortTypeTest(struct ISample *self, const uint16_t input, uint16_t *output)
+{
+ int32_t ec = HDF_FAILURE;
+ if (self == NULL) {
+ return HDF_ERR_INVALID_PARAM;
+ }
+
+ struct HdfSBuf *data = HdfSBufTypedObtain(SBUF_IPC);
+ struct HdfSBuf *reply = HdfSBufTypedObtain(SBUF_IPC);
+
+ if (data == NULL || reply == NULL) {
+ ec = HDF_ERR_MALLOC_FAIL;
+ goto finished;
+ }
+
+ if (!HdfSbufWriteUint16(data, input)) {
+ HDF_LOGE("%{public}s: write input failed!", __func__);
+ ec = HDF_ERR_INVALID_PARAM;
+ goto finished;
+ }
+
+ ec = SampleProxyCall(self, CMD_USHORT_TYPE_TEST, data, reply);
+ if (ec != HDF_SUCCESS) {
+ HDF_LOGE("%{public}s: call failed! error code is %{public}d", __func__, ec);
+ goto finished;
+ }
+
+ if (!HdfSbufReadUint16(reply, output)) {
+ HDF_LOGE("%{public}s: read result failed!", __func__);
+ goto finished;
+ }
+
+finished:
+ if (data != NULL) {
+ HdfSBufRecycle(data);
+ }
+ if (reply != NULL) {
+ HdfSBufRecycle(reply);
+ }
+ return ec;
+}
+
+static int32_t SampleProxyUintTypeTest(struct ISample *self, const uint32_t input, uint32_t *output)
+{
+ int32_t ec = HDF_FAILURE;
+ if (self == NULL) {
+ return HDF_ERR_INVALID_PARAM;
+ }
+
+ struct HdfSBuf *data = HdfSBufTypedObtain(SBUF_IPC);
+ struct HdfSBuf *reply = HdfSBufTypedObtain(SBUF_IPC);
+
+ if (data == NULL || reply == NULL) {
+ ec = HDF_ERR_MALLOC_FAIL;
+ goto finished;
+ }
+
+ if (!HdfSbufWriteUint32(data, input)) {
+ HDF_LOGE("%{public}s: write input failed!", __func__);
+ ec = HDF_ERR_INVALID_PARAM;
+ goto finished;
+ }
+
+ ec = SampleProxyCall(self, CMD_UINT_TYPE_TEST, data, reply);
+ if (ec != HDF_SUCCESS) {
+ HDF_LOGE("%{public}s: call failed! error code is %{public}d", __func__, ec);
+ goto finished;
+ }
+
+ if (!HdfSbufReadUint32(reply, output)) {
+ HDF_LOGE("%{public}s: read result failed!", __func__);
+ goto finished;
+ }
+
+finished:
+ if (data != NULL) {
+ HdfSBufRecycle(data);
+ }
+ if (reply != NULL) {
+ HdfSBufRecycle(reply);
+ }
+ return ec;
+}
+
+static int32_t SampleProxyUlongTypeTest(struct ISample *self, const uint64_t input, uint64_t *output)
+{
+ int32_t ec = HDF_FAILURE;
+ if (self == NULL) {
+ return HDF_ERR_INVALID_PARAM;
+ }
+
+ struct HdfSBuf *data = HdfSBufTypedObtain(SBUF_IPC);
+ struct HdfSBuf *reply = HdfSBufTypedObtain(SBUF_IPC);
+
+ if (data == NULL || reply == NULL) {
+ ec = HDF_ERR_MALLOC_FAIL;
+ goto finished;
+ }
+
+ if (!HdfSbufWriteUint64(data, input)) {
+ HDF_LOGE("%{public}s: write input failed!", __func__);
+ ec = HDF_ERR_INVALID_PARAM;
+ goto finished;
+ }
+
+ ec = SampleProxyCall(self, CMD_ULONG_TYPE_TEST, data, reply);
+ if (ec != HDF_SUCCESS) {
+ HDF_LOGE("%{public}s: call failed! error code is %{public}d", __func__, ec);
+ goto finished;
+ }
+
+ if (!HdfSbufReadUint64(reply, output)) {
+ HDF_LOGE("%{public}s: read result failed!", __func__);
+ goto finished;
+ }
+
+finished:
+ if (data != NULL) {
+ HdfSBufRecycle(data);
+ }
+ if (reply != NULL) {
+ HdfSBufRecycle(reply);
+ }
+ return ec;
+}
+
+static int32_t SampleProxyListTypeTest(struct ISample *self, const int8_t *input, const uint32_t inSize,
+ int8_t **output, uint32_t *outSize)
+{
+ int32_t ec = HDF_FAILURE;
+ if (self == NULL || input == NULL) {
+ return HDF_ERR_INVALID_PARAM;
+ }
+
+ struct HdfSBuf *data = HdfSBufTypedObtain(SBUF_IPC);
+ struct HdfSBuf *reply = HdfSBufTypedObtain(SBUF_IPC);
+
+ if (data == NULL || reply == NULL) {
+ ec = HDF_ERR_MALLOC_FAIL;
+ goto finished;
+ }
+
+ if (!HdfSbufWriteUint32(data, inSize)) {
+ HDF_LOGE("%{public}s: write input size failed!", __func__);
+ ec = HDF_ERR_INVALID_PARAM;
+ goto finished;
+ }
+
+ for (uint32_t i = 0; i < inSize; i++) {
+ if (!HdfSbufWriteInt8(data, input[i])) {
+ HDF_LOGE("%{public}s: write input[%d] failed!", __func__, i);
+ ec = HDF_ERR_INVALID_PARAM;
+ goto finished;
+ }
+ }
+
+ ec = SampleProxyCall(self, CMD_LIST_TYPE_TEST, data, reply);
+ if (ec != HDF_SUCCESS) {
+ HDF_LOGE("%{public}s: call failed! error code is %{public}d", __func__, ec);
+ goto finished;
+ }
+
+ if (!HdfSbufReadUint32(reply, outSize)) {
+ HDF_LOGE("%{public}s: read output size failed!", __func__);
+ goto finished;
+ }
+
+ if (*outSize == 0) {
+ HDF_LOGE("%{public}s: read outSize = %{public}d", __func__, *outSize);
+ goto finished;
+ }
+
+ int8_t *result = (int8_t *)OsalMemAlloc(sizeof(int8_t) * (*outSize));
+ if (result == NULL) {
+ HDF_LOGE("%{public}s: malloc output failed!", __func__);
+ goto finished;
+ }
+
+ for (uint32_t i = 0; i < *outSize; i++) {
+ if (!HdfSbufReadInt8(reply, &(result[i]))) {
+ HDF_LOGE("%{public}s: read output[%{public}d] failed!", __func__, i);
+ OsalMemFree(result);
+ goto finished;
+ }
+ }
+ *output = result;
+
+finished:
+ if (data != NULL) {
+ HdfSBufRecycle(data);
+ }
+ if (reply != NULL) {
+ HdfSBufRecycle(reply);
+ }
+ return ec;
+}
+
+static int32_t SampleProxyArrayTypeTest(struct ISample *self, const int8_t *input, const uint32_t inSize,
+ int8_t **output, uint32_t *outSize)
+{
+ int32_t ec = HDF_FAILURE;
+ if (self == NULL || input == NULL) {
+ return HDF_ERR_INVALID_PARAM;
+ }
+
+ struct HdfSBuf *data = HdfSBufTypedObtain(SBUF_IPC);
+ struct HdfSBuf *reply = HdfSBufTypedObtain(SBUF_IPC);
+
+ if (data == NULL || reply == NULL) {
+ ec = HDF_ERR_MALLOC_FAIL;
+ goto finished;
+ }
+
+ if (!HdfSbufWriteUint32(data, inSize)) {
+ HDF_LOGE("%{public}s: write input size failed!", __func__);
+ ec = HDF_ERR_INVALID_PARAM;
+ goto finished;
+ }
+
+ for (uint32_t i = 0; i < inSize; i++) {
+ if (!HdfSbufWriteInt8(data, input[i])) {
+ HDF_LOGE("%{public}s: write input[%d] failed!", __func__, i);
+ ec = HDF_ERR_INVALID_PARAM;
+ goto finished;
+ }
+ }
+
+ ec = SampleProxyCall(self, CMD_ARRAY_TYPE_TEST, data, reply);
+ if (ec != HDF_SUCCESS) {
+ HDF_LOGE("%{public}s: call failed! error code is %{public}d", __func__, ec);
+ goto finished;
+ }
+
+ if (!HdfSbufReadUint32(reply, outSize)) {
+ HDF_LOGE("%{public}s: read output size failed!", __func__);
+ goto finished;
+ }
+
+ if (*outSize == 0) {
+ HDF_LOGE("%{public}s: read outSize = %{public}d", __func__, *outSize);
+ goto finished;
+ }
+
+ int8_t *result = (int8_t *)OsalMemAlloc(sizeof(int8_t) * (*outSize));
+ if (result == NULL) {
+ HDF_LOGE("%{public}s: malloc output failed!", __func__);
+ goto finished;
+ }
+
+ for (uint32_t i = 0; i < *outSize; i++) {
+ if (!HdfSbufReadInt8(reply, &(result[i]))) {
+ HDF_LOGE("%{public}s: read output[%{public}d] failed!", __func__, i);
+ OsalMemFree(result);
+ goto finished;
+ }
+ }
+ *output = result;
+
+finished:
+ if (data != NULL) {
+ HdfSBufRecycle(data);
+ }
+ if (reply != NULL) {
+ HdfSBufRecycle(reply);
+ }
+ return ec;
+}
+
+static int32_t SampleProxyStructTypeTest(struct ISample *self, const struct StructSample *input,
+ struct StructSample *output)
+{
+ int32_t ec = HDF_FAILURE;
+ if (self == NULL) {
+ return HDF_ERR_INVALID_PARAM;
+ }
+
+ struct HdfSBuf *data = HdfSBufTypedObtain(SBUF_IPC);
+ struct HdfSBuf *reply = HdfSBufTypedObtain(SBUF_IPC);
+ if (data == NULL || reply == NULL) {
+ ec = HDF_ERR_MALLOC_FAIL;
+ goto finished;
+ }
+
+ if (!HdfSbufWriteBuffer(data, (const void *)input, sizeof(struct StructSample))) {
+ HDF_LOGE("%{public}s: write struct StructSample input failed!", __func__);
+ ec = HDF_ERR_INVALID_PARAM;
+ goto finished;
+ }
+
+ ec = SampleProxyCall(self, CMD_STRUCT_TYPE_TEST, data, reply);
+ if (ec != HDF_SUCCESS) {
+ HDF_LOGE("%{public}s: call failed! error code is %{public}d", __func__, ec);
+ goto finished;
+ }
+
+ struct StructSample *result = NULL;
+ uint32_t outSize = 0;
+ if (!HdfSbufReadBuffer(reply, (const void **)&result, &outSize)) {
+ HDF_LOGE("%{public}s: read struct StructSample result failed!", __func__);
+ ec = HDF_ERR_INVALID_PARAM;
+ goto finished;
+ }
+
+ if (result == NULL || outSize != sizeof(struct StructSample)) {
+ HDF_LOGE("%{public}s: result is error", __func__);
+ ec = HDF_ERR_INVALID_PARAM;
+ }
+ output->first = result->first;
+ output->second = result->second;
+
+finished:
+ if (data != NULL) {
+ HdfSBufRecycle(data);
+ }
+ if (reply != NULL) {
+ HdfSBufRecycle(reply);
+ }
+ return ec;
+}
+
+static int32_t SampleProxyEnumTypeTest(struct ISample *self, const enum EnumSample input, enum EnumSample *output)
+{
+ int32_t ec = HDF_FAILURE;
+ if (self == NULL) {
+ return HDF_ERR_INVALID_PARAM;
+ }
+
+ struct HdfSBuf *data = HdfSBufTypedObtain(SBUF_IPC);
+ struct HdfSBuf *reply = HdfSBufTypedObtain(SBUF_IPC);
+
+ if (data == NULL || reply == NULL) {
+ ec = HDF_ERR_MALLOC_FAIL;
+ goto finished;
+ }
+
+ if (!HdfSbufWriteUint32(data, (uint32_t)input)) {
+ HDF_LOGE("%{public}s: write input failed!", __func__);
+ ec = HDF_ERR_INVALID_PARAM;
+ goto finished;
+ }
+
+ ec = SampleProxyCall(self, CMD_ENUM_TYPE_TEST, data, reply);
+ if (ec != HDF_SUCCESS) {
+ HDF_LOGE("%{public}s: call failed! error code is %{public}d", __func__, ec);
+ goto finished;
+ }
+
+ if (!HdfSbufReadUint32(reply, (uint32_t *)output)) {
+ HDF_LOGE("%{public}s: read result failed!", __func__);
+ goto finished;
+ }
+
+finished:
+ if (data != NULL) {
+ HdfSBufRecycle(data);
+ }
+ if (reply != NULL) {
+ HdfSBufRecycle(reply);
+ }
+ return ec;
+}
+
+static void SampleConstruct(struct ISample *inst)
+{
+ inst->BooleanTypeTest = SampleProxyBooleanTypeTest;
+ inst->ByteTypeTest = SampleProxyByteTypeTest;
+ inst->ShortTypeTest = SampleProxyShortTypeTest;
+ inst->IntTypeTest = SampleProxyIntTypeTest;
+ inst->LongTypeTest = SampleProxyLongTypeTest;
+ inst->FloatTypeTest = SampleProxyFloatTypeTest;
+ inst->DoubleTypeTest = SampleProxyDoubleTypeTest;
+ inst->StringTypeTest = SampleProxyStringTypeTest;
+ inst->UcharTypeTest = SampleProxyUcharTypeTest;
+ inst->UshortTypeTest = SampleProxyUshortTypeTest;
+ inst->UintTypeTest = SampleProxyUintTypeTest;
+ inst->UlongTypeTest = SampleProxyUlongTypeTest;
+ inst->ListTypeTest = SampleProxyListTypeTest;
+ inst->ArrayTypeTest = SampleProxyArrayTypeTest;
+ inst->StructTypeTest = SampleProxyStructTypeTest;
+ inst->EnumTypeTest = SampleProxyEnumTypeTest;
+}
+
+struct ISample *HdiSampleGet(const char *serviceName)
+{
+ struct HDIServiceManager *serviceMgr = HDIServiceManagerGet();
+ if (serviceMgr == NULL) {
+ HDF_LOGE("%{public}s: HDIServiceManager not found!", __func__);
+ return NULL;
+ }
+
+ struct HdfRemoteService *remote = serviceMgr->GetService(serviceMgr, serviceName);
+ if (remote == NULL) {
+ HDF_LOGE("%{public}s: HdfRemoteService not found!", __func__);
+ return NULL;
+ }
+
+ struct ISample *sampleClient = (struct ISample *)OsalMemAlloc(sizeof(struct ISample));
+ if (sampleClient == NULL) {
+ HDF_LOGE("%{public}s: malloc sample instance failed!", __func__);
+ HdfRemoteServiceRecycle(remote);
+ return NULL;
+ }
+
+ sampleClient->remote = remote;
+ SampleConstruct(sampleClient);
+ return sampleClient;
+}
+
+void HdiSampleRelease(struct ISample *instance)
+{
+ if (instance == NULL) {
+ return;
+ }
+
+ HdfRemoteServiceRecycle(instance->remote);
+ OsalMemFree(instance);
+}
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
\ No newline at end of file
diff --git a/uhdf2/hdi/test/hdi_sample/sample_client_cpp/sample_client_cpp_test.cpp b/uhdf2/hdi/test/hdi_sample/sample_client_cpp/sample_client_cpp_test.cpp
new file mode 100755
index 0000000000000000000000000000000000000000..7977183372e44b77e06ad8d4ed5777133ef15550
--- /dev/null
+++ b/uhdf2/hdi/test/hdi_sample/sample_client_cpp/sample_client_cpp_test.cpp
@@ -0,0 +1,300 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include