diff --git a/uhdf2/README.md b/uhdf2/README.md old mode 100755 new mode 100644 diff --git a/uhdf2/README_zh.md b/uhdf2/README_zh.md old mode 100755 new mode 100644 diff --git a/uhdf2/config/BUILD.gn b/uhdf2/config/BUILD.gn old mode 100755 new mode 100644 diff --git a/uhdf2/hcs/BUILD.gn b/uhdf2/hcs/BUILD.gn old mode 100755 new mode 100644 diff --git a/uhdf2/hcs/large/device_info.hcs b/uhdf2/hcs/large/device_info.hcs old mode 100755 new mode 100644 diff --git a/uhdf2/hcs/standard/device_info.hcs b/uhdf2/hcs/standard/device_info.hcs index 718a2fd1c0524b4333c9e9d83d339e9781630d5b..57d036b819b9be8e4261b47f699b42d6a23ef2ce 100755 --- a/uhdf2/hcs/standard/device_info.hcs +++ b/uhdf2/hcs/standard/device_info.hcs @@ -28,19 +28,6 @@ } } } - 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; @@ -53,29 +40,5 @@ } } } - 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 index 01b37ac8c13bc6f4290c96176a32d45ea03a4dc6..bf8dc250cb2744b277f7ffeac187299008b04d44 100755 --- a/uhdf2/hcs/standard/hdf.hcs +++ b/uhdf2/hcs/standard/hdf.hcs @@ -1,6 +1,4 @@ #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 deleted file mode 100755 index 74009f398bb5318742645bc36ec1994296ea9e5c..0000000000000000000000000000000000000000 --- a/uhdf2/hcs/standard/usb_cdcacm.hcs +++ /dev/null @@ -1,242 +0,0 @@ -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 deleted file mode 100755 index 6e49a99a4789bc6568c82453b82d72174fb6de60..0000000000000000000000000000000000000000 --- a/uhdf2/hcs/standard/usb_pnp_device.hcs +++ /dev/null @@ -1,47 +0,0 @@ -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 old mode 100755 new mode 100644 diff --git a/uhdf2/hdi/src/iservmgr_hdi.cpp b/uhdf2/hdi/src/iservmgr_hdi.cpp old mode 100755 new mode 100644 diff --git a/uhdf2/hdi/test/BUILD.gn b/uhdf2/hdi/test/BUILD.gn old mode 100755 new mode 100644 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 old mode 100755 new mode 100644 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 old mode 100755 new mode 100644 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 old mode 100755 new mode 100644 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 old mode 100755 new mode 100644 diff --git a/uhdf2/hdi/test/hdi_sample/sample_client_cpp/unittest/BUILD.gn b/uhdf2/hdi/test/hdi_sample/sample_client_cpp/unittest/BUILD.gn old mode 100755 new mode 100644 diff --git a/uhdf2/hdi/test/hdi_sample/sample_client_cpp/unittest/sample_proxy.cpp b/uhdf2/hdi/test/hdi_sample/sample_client_cpp/unittest/sample_proxy.cpp old mode 100755 new mode 100644 diff --git a/uhdf2/hdi/test/hdi_sample/sample_service_c/BUILD.gn b/uhdf2/hdi/test/hdi_sample/sample_service_c/BUILD.gn old mode 100755 new mode 100644 diff --git a/uhdf2/hdi/test/hdi_sample/sample_service_cpp/BUILD.gn b/uhdf2/hdi/test/hdi_sample/sample_service_cpp/BUILD.gn old mode 100755 new mode 100644 diff --git a/uhdf2/hdi/test/hdi_sample/sample_service_cpp/sample_driver.cpp b/uhdf2/hdi/test/hdi_sample/sample_service_cpp/sample_driver.cpp old mode 100755 new mode 100644 diff --git a/uhdf2/hdi/test/hdi_sample/sample_service_cpp/sample_service.cpp b/uhdf2/hdi/test/hdi_sample/sample_service_cpp/sample_service.cpp old mode 100755 new mode 100644 diff --git a/uhdf2/hdi/test/hdi_sample/sample_service_cpp/sample_service_stub.cpp b/uhdf2/hdi/test/hdi_sample/sample_service_cpp/sample_service_stub.cpp old mode 100755 new mode 100644 diff --git a/uhdf2/hdi/test/servmgr/service_manager_hdi_c_test.cpp b/uhdf2/hdi/test/servmgr/service_manager_hdi_c_test.cpp old mode 100755 new mode 100644 diff --git a/uhdf2/hdi/test/servmgr/service_manager_hdi_test.cpp b/uhdf2/hdi/test/servmgr/service_manager_hdi_test.cpp old mode 100755 new mode 100644 diff --git a/uhdf2/host/include/devhost_service_full.h b/uhdf2/host/include/devhost_service_full.h old mode 100644 new mode 100755 diff --git a/uhdf2/host/include/devhost_service_stub.h b/uhdf2/host/include/devhost_service_stub.h old mode 100644 new mode 100755 diff --git a/uhdf2/host/src/devhost_service_full.c b/uhdf2/host/src/devhost_service_full.c old mode 100644 new mode 100755 diff --git a/uhdf2/host/src/device_token_stub.c b/uhdf2/host/src/device_token_stub.c old mode 100644 new mode 100755 diff --git a/uhdf2/host/src/devmgr_service_proxy.c b/uhdf2/host/src/devmgr_service_proxy.c old mode 100644 new mode 100755 diff --git a/uhdf2/host/src/hdf_device_full.c b/uhdf2/host/src/hdf_device_full.c old mode 100644 new mode 100755 diff --git a/uhdf2/host/test/unittest/devmgr_test.cpp b/uhdf2/host/test/unittest/devmgr_test.cpp old mode 100755 new mode 100644 diff --git a/uhdf2/host/test/unittest/sample_driver/BUILD.gn b/uhdf2/host/test/unittest/sample_driver/BUILD.gn old mode 100755 new mode 100644 diff --git a/uhdf2/include/hdf_devmgr.h b/uhdf2/include/hdf_devmgr.h old mode 100644 new mode 100755 diff --git a/uhdf2/ipc/BUILD.gn b/uhdf2/ipc/BUILD.gn old mode 100755 new mode 100644 diff --git a/uhdf2/ipc/src/hdf_sbuf_impl_hipc.cpp b/uhdf2/ipc/src/hdf_sbuf_impl_hipc.cpp old mode 100755 new mode 100644 diff --git a/uhdf2/manager/BUILD.gn b/uhdf2/manager/BUILD.gn old mode 100755 new mode 100644 diff --git a/uhdf2/manager/hdf_devmgr.rc b/uhdf2/manager/hdf_devmgr.rc old mode 100755 new mode 100644 diff --git a/uhdf2/manager/include/devhost_service_proxy.h b/uhdf2/manager/include/devhost_service_proxy.h old mode 100644 new mode 100755 diff --git a/uhdf2/manager/include/devmgr_pnp_service.h b/uhdf2/manager/include/devmgr_pnp_service.h old mode 100644 new mode 100755 index 0358e2669452929731bc5900085aa9feb28edb1c..6f92dc13b0a5af5711229283f6f5428ae5b592d9 --- a/uhdf2/manager/include/devmgr_pnp_service.h +++ b/uhdf2/manager/include/devmgr_pnp_service.h @@ -24,8 +24,7 @@ struct HdfSList *DevmgrServiceGetPnpDeviceInfo(); int32_t DevmgrServiceRegPnpDevice( - struct IDevmgrService *devmgrSvc, const char *moduleName, const char *serviceName, - const void *privateData); + struct IDevmgrService *devmgrSvc, const char *moduleName, const char *serviceName); int32_t DevmgrServiceUnRegPnpDevice( struct IDevmgrService *devmgrSvc, const char *moduleName, const char *serviceName); diff --git a/uhdf2/manager/include/devmgr_service_stub.h b/uhdf2/manager/include/devmgr_service_stub.h old mode 100644 new mode 100755 diff --git a/uhdf2/manager/src/devhost_service_proxy.c b/uhdf2/manager/src/devhost_service_proxy.c old mode 100644 new mode 100755 diff --git a/uhdf2/manager/src/device_token_proxy.c b/uhdf2/manager/src/device_token_proxy.c old mode 100644 new mode 100755 diff --git a/uhdf2/manager/src/devmgr_pnp_service.c b/uhdf2/manager/src/devmgr_pnp_service.c old mode 100644 new mode 100755 index 827b2b1a5149d3eda73536a282ac894126f7a3ab..63c289384912fe0065ad2cf6c893d7eb04cd99be --- a/uhdf2/manager/src/devmgr_pnp_service.c +++ b/uhdf2/manager/src/devmgr_pnp_service.c @@ -20,7 +20,6 @@ #include "hdf_log.h" #include "osal_mem.h" #include "osal_time.h" -#include "securec.h" #define PNP_SLEEP_TIME 50 // ms @@ -72,38 +71,11 @@ static bool DevmgrServiceAddPnpDeviceInfo(struct HdfDeviceInfoFull *deviceInfo) deviceInfo->super.hostId = g_hostId; deviceInfo->super.policy = SERVICE_POLICY_PUBLIC; deviceInfo->super.preload = DEVICE_PRELOAD_ENABLE; - deviceInfo->super.deviceMatchAttr = ""; HdfSListAdd(g_deviceInfos, &deviceInfo->super.node); return true; } -static bool DevmgrServiceAddPrivateData( - struct HdfDeviceInfoFull *deviceInfo, const void *privateData) -{ - if (privateData != NULL) { - deviceInfo->super.private = (const void *)OsalMemCalloc(sizeof(struct UsbPnpNotifyServiceInfo)); - if (deviceInfo->super.private != NULL) { - int32_t length = ((struct UsbPnpNotifyServiceInfo *)(privateData))->length; - HDF_LOGD("%{public}s: private length=%{public}d", __func__, length); - - memcpy_s((void *)(deviceInfo->super.private), sizeof(struct UsbPnpNotifyServiceInfo), privateData, length); - if (deviceInfo->super.private == NULL) { - HDF_LOGE("%{public}s: memcpy_s private error", __func__); - return false; - } - } else { - HDF_LOGE("%{public}s: OsalMemCalloc private error", __func__); - return false; - } - } else { - HDF_LOGW("%{public}s: privateData is NULL", __func__); - } - - return true; -} - -static bool DevmgrServiceAddPnpDevice( - const char *moduleName, const char *serviceName, const void *privateData) +static bool DevmgrServiceAddPnpDevice(const char *moduleName, const char *serviceName) { if (moduleName == NULL || serviceName == NULL) { return false; @@ -127,11 +99,6 @@ static bool DevmgrServiceAddPnpDevice( return false; } - if (!DevmgrServiceAddPrivateData(deviceInfo, privateData)) { - HdfDeviceInfoFullFreeInstance(deviceInfo); - return false; - } - if (!DevmgrServiceAddPnpDeviceInfo(deviceInfo)) { HdfDeviceInfoFullFreeInstance(deviceInfo); return false; @@ -229,8 +196,7 @@ static int DevmgrServiceInstallDevice(struct DevHostServiceClnt *hostClnt, const } int32_t DevmgrServiceRegPnpDevice( - struct IDevmgrService *devmgrSvc, const char *moduleName, const char *serviceName, - const void *privateData) + struct IDevmgrService *devmgrSvc, const char *moduleName, const char *serviceName) { int32_t ret = HDF_FAILURE; struct DevmgrService *inst = (struct DevmgrService *)devmgrSvc; @@ -251,7 +217,7 @@ int32_t DevmgrServiceRegPnpDevice( HDF_LOGE("%s host service is null!", __func__); return HDF_ERR_INVALID_OBJECT; } - if (!DevmgrServiceAddPnpDevice(moduleName, serviceName, privateData)) { + if (!DevmgrServiceAddPnpDevice(moduleName, serviceName)) { HDF_LOGE("%s add pnp device failed!", __func__); return ret; } diff --git a/uhdf2/manager/src/devmgr_service_stub.c b/uhdf2/manager/src/devmgr_service_stub.c old mode 100644 new mode 100755 index 1119651a6037b04bba32ee24909adaec5ac5df05..f69db5a8d8225cd66145f1d7b5b9ab52b701949e --- a/uhdf2/manager/src/devmgr_service_stub.c +++ b/uhdf2/manager/src/devmgr_service_stub.c @@ -21,70 +21,14 @@ #include "devmgr_pnp_service.h" #include "devmgr_virtual_service.h" #include "devsvc_manager.h" -#include "hdf_device_info_full.h" #include "hdf_base.h" #include "hdf_log.h" #include "hdf_sbuf.h" #include "osal_mem.h" #include "osal_sysevent.h" -#include "securec.h" -#include "hdf_attribute_manager.h" -#include "device_resource_if.h" -#include "hcs_tree_if.h" -#include #define HDF_LOG_TAG devmgr_service_stub -#define USB_PNP_NOTIFY_SERVICE_NAME "hdf_usb_pnp_notify_service" - -struct UsbPnpMatchIdTable { - const char *moduleName; - const char *serviceName; - - int32_t interfaceLength; - - uint8_t length; - - uint16_t matchFlag; - - uint16_t vendorId; - uint16_t productId; - - uint16_t bcdDeviceLow; - uint16_t bcdDeviceHigh; - - uint8_t deviceClass; - uint8_t deviceSubClass; - uint8_t deviceProtocol; - - uint8_t interfaceClass; - uint8_t interfaceSubClass; - uint8_t interfaceProtocol; - - uint8_t interfaceNumber[USB_PNP_INFO_MAX_INTERFACES]; -}; - -struct UsbPnpDeviceListTable { - struct DListHead list; - const char *moduleName; - const char *serviceName; - uint32_t usbDevAddr; - int32_t devNum; - int32_t busNum; - int32_t interfaceLength; - uint8_t interfaceNumber[USB_PNP_INFO_MAX_INTERFACES]; -}; - -struct UsbPnpRemoveInfo { - uint8_t removeType; - uint32_t usbDevAddr; - int32_t devNum; - int32_t busNum; - uint8_t interfaceNum; -}; - -struct UsbPnpDeviceListTable *g_usbPnpDeviceTableList = NULL; - static int32_t DevmgrServiceStubDispatchAttachDevice( struct IDevmgrService *devmgrSvc, struct HdfSBuf *data) { @@ -109,9 +53,7 @@ static int32_t DevmgrServiceStubDispatchPnpDevice( struct IDevmgrService *devmgrSvc, struct HdfSBuf *data, bool isReg) { int32_t ret = HDF_FAILURE; - uint32_t infoSize = 0; - struct UsbPnpNotifyServiceInfo *privateData = NULL; - + const char *moduleName = HdfSbufReadString(data); if (moduleName == NULL) { return ret; @@ -121,19 +63,8 @@ static int32_t DevmgrServiceStubDispatchPnpDevice( return ret; } - if (!HdfSbufReadBuffer(data, (const void **)(&privateData), &infoSize)) { - HDF_LOGW("%{public}s: HdfSbufReadBuffer privateData error!", __func__); - privateData = NULL; - } - if (privateData == NULL) { - HDF_LOGW("%{public}s: privateData is NULL!", __func__); - } else { - HDF_LOGD("%{public}s: length=%{public}d, infoSize=%{public}d, moduleName=%{public}s, serviceName=%{public}s", - __func__, privateData->length, infoSize, moduleName, serviceName); - } - if (isReg) { - ret = DevmgrServiceRegPnpDevice(devmgrSvc, moduleName, serviceName, (const void *)privateData); + ret = DevmgrServiceRegPnpDevice(devmgrSvc, moduleName, serviceName); } else { ret = DevmgrServiceUnRegPnpDevice(devmgrSvc, moduleName, serviceName); } @@ -201,718 +132,6 @@ static struct HdfRemoteDispatcher g_devmgrDispatcher = { .Dispatch = DevmgrServiceStubDispatch }; -static struct HdfSBuf *DevmgrServiceStubBufCreate(const char *moduleName, - const char *serviceName, struct UsbPnpNotifyServiceInfo serviceInfo) -{ - struct HdfSBuf *pnpData = NULL; - char modName[128] = {0}; - - pnpData = HdfSBufObtainDefaultSize(); - if (pnpData == NULL) { - HDF_LOGE("%{public}s: HdfSBufTypedObtain pnpData fail", __func__); - return NULL; - } - - if (sprintf_s(modName, sizeof(modName) - 1, "lib%s.z.so", moduleName) < 0) { - HDF_LOGE("%{public}s: sprintf_s modName fail", __func__); - goto out; - } - if (!HdfSbufWriteString(pnpData, modName)) { - HDF_LOGE("%{public}s: write modName name failed!", __func__); - goto out; - } - - if (!HdfSbufWriteString(pnpData, serviceName)) { - HDF_LOGE("%{public}s: write service name failed!", __func__); - goto out; - } - - if (!HdfSbufWriteBuffer(pnpData, (const void *)(&serviceInfo), sizeof(struct UsbPnpNotifyServiceInfo))) { - HDF_LOGE("%{public}s: write privateData failed!", __func__); - goto out; - } - - HDF_LOGD("%{public}s: create: devNum=%{public}d, busNum=%{public}d, moduleName=%{public}s, \ - serviceName=%{public}s", __func__, serviceInfo.devNum, serviceInfo.busNum, modName, serviceName); - - return pnpData; - -out: - HdfSBufRecycle(pnpData); - - return NULL; -} - -static bool DevmgrServiceStubUsbMatchDevice(struct UsbPnpNotifyMatchInfoTable *dev, - const struct UsbPnpMatchIdTable *id) -{ - if ((id->matchFlag & USB_PNP_NOTIFY_MATCH_VENDOR) && - (id->vendorId != dev->deviceInfo.vendorId)) { - return false; - } - - if ((id->matchFlag & USB_PNP_NOTIFY_MATCH_PRODUCT) && - (id->productId != dev->deviceInfo.productId)) { - return false; - } - - if ((id->matchFlag & USB_PNP_NOTIFY_MATCH_DEV_LOW) && - (id->bcdDeviceLow > dev->deviceInfo.bcdDeviceLow)) { - return false; - } - - if ((id->matchFlag & USB_PNP_NOTIFY_MATCH_DEV_HIGH) && - (id->bcdDeviceHigh < dev->deviceInfo.bcdDeviceHigh)) { - return false; - } - - if ((id->matchFlag & USB_PNP_NOTIFY_MATCH_DEV_CLASS) && - (id->deviceClass != dev->deviceInfo.deviceClass)) { - return false; - } - - if ((id->matchFlag & USB_PNP_NOTIFY_MATCH_DEV_SUBCLASS) && - (id->deviceSubClass != dev->deviceInfo.deviceSubClass)) { - return false; - } - - if ((id->matchFlag & USB_PNP_NOTIFY_MATCH_DEV_PROTOCOL) && - (id->deviceProtocol != dev->deviceInfo.deviceProtocol)) { - return false; - } - - return true; -} - -static bool DevmgrServiceStubUsbMatchOneIdIntf(struct UsbPnpNotifyMatchInfoTable *dev, - int8_t index, struct UsbPnpMatchIdTable *id) -{ - int32_t i; - uint8_t j; - - if (dev->deviceInfo.deviceClass == USB_CLASS_VENDOR_SPEC && - !(id->matchFlag & USB_PNP_NOTIFY_MATCH_VENDOR) && - (id->matchFlag & (USB_PNP_NOTIFY_MATCH_INT_CLASS | USB_PNP_NOTIFY_MATCH_INT_SUBCLASS | - USB_PNP_NOTIFY_MATCH_INT_PROTOCOL | USB_PNP_NOTIFY_MATCH_INT_NUMBER))) { - return false; - } - - if ((id->matchFlag & USB_PNP_NOTIFY_MATCH_INT_CLASS) && - (id->interfaceClass != dev->interfaceInfo[index].interfaceClass)) { - return false; - } - - if ((id->matchFlag & USB_PNP_NOTIFY_MATCH_INT_SUBCLASS) && - (id->interfaceSubClass != dev->interfaceInfo[index].interfaceSubClass)) { - return false; - } - - if ((id->matchFlag & USB_PNP_NOTIFY_MATCH_INT_PROTOCOL) && - (id->interfaceProtocol != dev->interfaceInfo[index].interfaceProtocol)) { - return false; - } - - if (id->interfaceLength == 1) { - if ((id->matchFlag & USB_PNP_NOTIFY_MATCH_INT_NUMBER) && - (id->interfaceNumber[0] != dev->interfaceInfo[index].interfaceNumber)) { - return false; - } - - id->interfaceNumber[0] = dev->interfaceInfo[index].interfaceNumber; - } else { - if (id->matchFlag & USB_PNP_NOTIFY_MATCH_INT_NUMBER) { - for (i = 0; i < id->interfaceLength; i++) { - for (j = 0; j < dev->numInfos; j++) { - if (id->interfaceNumber[i] == dev->interfaceInfo[j].interfaceNumber) { - break; - } - } - - if (j >= dev->numInfos) { - return false; - } - } - } else { - id->interfaceLength = 1; - id->interfaceNumber[0] = dev->interfaceInfo[index].interfaceNumber; - } - } - - return true; -} - -static int32_t DevmgrServiceStubParseIdTable(const struct DeviceResourceNode *node, - struct DeviceResourceIface *devResIface, struct UsbPnpMatchIdTable *table) -{ - if (node == NULL || table == NULL || devResIface == NULL) { - HDF_LOGE("%{public}s: node or table or devResIface is NULL!", __func__); - return HDF_FAILURE; - } - - if (devResIface->GetString(node, "moduleName", &table->moduleName, "") != HDF_SUCCESS) { - HDF_LOGE("%{public}s: read moduleName fail!", __func__); - return HDF_FAILURE; - } - - if (devResIface->GetString(node, "serviceName", &table->serviceName, "") != HDF_SUCCESS) { - HDF_LOGE("%{public}s: read serviceName fail!", __func__); - return HDF_FAILURE; - } - - if (devResIface->GetUint8(node, "length", &table->length, 0) != HDF_SUCCESS) { - HDF_LOGE("%{public}s: read length fail!", __func__); - return HDF_FAILURE; - } - - if (devResIface->GetUint16(node, "matchFlag", &table->matchFlag, 0) != HDF_SUCCESS) { - HDF_LOGE("%{public}s: read matchFlag fail!", __func__); - return HDF_FAILURE; - } - - if (devResIface->GetUint16(node, "vendorId", &table->vendorId, 0) != HDF_SUCCESS) { - HDF_LOGE("%{public}s: read vendorId fail!", __func__); - return HDF_FAILURE; - } - - if (devResIface->GetUint16(node, "productId", &table->productId, 0) != HDF_SUCCESS) { - HDF_LOGE("%{public}s: read productId fail!", __func__); - return HDF_FAILURE; - } - - if (devResIface->GetUint16(node, "bcdDeviceLow", &table->bcdDeviceLow, 0) != HDF_SUCCESS) { - HDF_LOGE("%{public}s: read bcdDeviceLow fail!", __func__); - return HDF_FAILURE; - } - - if (devResIface->GetUint16(node, "bcdDeviceHigh", &table->bcdDeviceHigh, 0) != HDF_SUCCESS) { - HDF_LOGE("%{public}s: read bcdDeviceHigh fail!", __func__); - return HDF_FAILURE; - } - - if (devResIface->GetUint8(node, "deviceClass", &table->deviceClass, 0) != HDF_SUCCESS) { - HDF_LOGE("%{public}s: read deviceClass fail!", __func__); - return HDF_FAILURE; - } - - if (devResIface->GetUint8(node, "deviceSubClass", &table->deviceSubClass, 0) != HDF_SUCCESS) { - HDF_LOGE("%{public}s: read deviceSubClass fail!", __func__); - return HDF_FAILURE; - } - - if (devResIface->GetUint8(node, "deviceProtocol", &table->deviceProtocol, 0) != HDF_SUCCESS) { - HDF_LOGE("%{public}s: read deviceProtocol fail!", __func__); - return HDF_FAILURE; - } - - if (devResIface->GetUint8(node, "interfaceClass", &table->interfaceClass, 0) != HDF_SUCCESS) { - HDF_LOGE("%{public}s: read interfaceClass fail!", __func__); - return HDF_FAILURE; - } - - if (devResIface->GetUint8(node, "interfaceSubClass", &table->interfaceSubClass, 0) != HDF_SUCCESS) { - HDF_LOGE("%{public}s: read interfaceSubClass fail!", __func__); - return HDF_FAILURE; - } - - if (devResIface->GetUint8(node, "interfaceProtocol", &table->interfaceProtocol, 0) != HDF_SUCCESS) { - HDF_LOGE("%{public}s: read interfaceProtocol fail!", __func__); - return HDF_FAILURE; - } - - table->interfaceLength = devResIface->GetElemNum(node, "interfaceNumber"); - if (table->interfaceLength <= 0) { - HDF_LOGE("%{public}s: read interfaceLength=%{public}d fail!", __func__, table->interfaceLength); - return HDF_FAILURE; - } - if (devResIface->GetUint8Array(node, "interfaceNumber", table->interfaceNumber, \ - table->interfaceLength, 0) != HDF_SUCCESS) { - HDF_LOGE("%{public}s: read interfaceNumber fail!", __func__); - return HDF_FAILURE; - } - - HDF_LOGD("%{public}s:%{public}s parseIdTable success, length=%{public}d", \ - __func__, USB_PNP_DEBUG_STRING, table->length); - - return HDF_SUCCESS; -} - -static struct UsbPnpMatchIdTable **DevmgrServiceStubParseTableList(const struct DeviceResourceNode *node) -{ - struct DeviceResourceIface *devResIface = NULL; - int32_t idTabCount; - int32_t count; - int32_t ret; - const char *idTableName = NULL; - const struct DeviceResourceNode *tableNode = NULL; - struct UsbPnpMatchIdTable **idTable = NULL; - - if (node == NULL) { - HDF_LOGE("%s: node is NULL!", __func__); - return NULL; - } - devResIface = DeviceResourceGetIfaceInstance(HDF_CONFIG_SOURCE); - if (devResIface == NULL) { - HDF_LOGE("%{public}s: devResIface is NULL!", __func__); - return NULL; - } - idTabCount = devResIface->GetElemNum(node, "idTableList"); - if (idTabCount <= 0) { - HDF_LOGE("%{public}s: idTableList not found!", __func__); - return NULL; - } - HDF_LOGD("%{public}s:%{public}s idTabCount=%{public}d!", \ - __func__, USB_PNP_DEBUG_STRING, idTabCount); - idTable = (struct UsbPnpMatchIdTable **)OsalMemCalloc((idTabCount + 1) * sizeof(struct UsbPnpMatchIdTable *)); - if (idTable == NULL) { - HDF_LOGE("%{public}s: OsalMemCalloc failure!", __func__); - return NULL; - } - idTable[idTabCount] = NULL; - for (count = 0; count < idTabCount; count++) { - idTable[count] = (struct UsbPnpMatchIdTable *)OsalMemCalloc(sizeof(struct UsbPnpMatchIdTable)); - if (idTable[count] == NULL) { - HDF_LOGE("%{public}s: OsalMemCalloc failure!", __func__); - goto out; - } - ret = devResIface->GetStringArrayElem(node, "idTableList", count, &idTableName, NULL); - if (ret != HDF_SUCCESS) { - goto out; - } - tableNode = devResIface->GetChildNode(node, idTableName); - if (tableNode == NULL) { - HDF_LOGE("%{public}s: tableNode is NULL!", __func__); - goto out; - } - if (DevmgrServiceStubParseIdTable(tableNode, devResIface, idTable[count]) != HDF_SUCCESS) { - HDF_LOGE("%{public}s: DevmgrServiceStubParseIdTable failure!", __func__); - goto out; - } - } - - HDF_LOGD("%{public}s: %{public}s parse usb pnp id table success, idTabCount=%{public}d!", \ - __func__, USB_PNP_DEBUG_STRING, idTabCount); - - return idTable; - -out: - while ((--count) >= 0) { - OsalMemFree(idTable[count]); - } - OsalMemFree(idTable); - - return NULL; -} - -static struct UsbPnpMatchIdTable **DevmgrServiceStubParseDeviceId(const struct DeviceResourceNode *node) -{ - const char *deviceIdName = NULL; - struct DeviceResourceIface *devResIface = NULL; - const struct DeviceResourceNode *deviceIdNode = NULL; - - if (node == NULL) { - HDF_LOGE("%{public}s: node is NULL!", __func__); - return NULL; - } - - devResIface = DeviceResourceGetIfaceInstance(HDF_CONFIG_SOURCE); - if (devResIface == NULL) { - HDF_LOGE("%{public}s: devResIface is NULL!", __func__); - return NULL; - } - - if (devResIface->GetString(node, "usb_pnp_device_id", &deviceIdName, NULL) != HDF_SUCCESS) { - HDF_LOGE("%{public}s: get usb_pnp_device_id name failure!", __func__); - return NULL; - } - - deviceIdNode = devResIface->GetChildNode(node, deviceIdName); - if (deviceIdNode == NULL) { - HDF_LOGE("%{public}s: deviceIdNode is NULL!", __func__); - return NULL; - } - - return DevmgrServiceStubParseTableList(deviceIdNode); -} - -static struct UsbPnpMatchIdTable **DevmgrServiceStubPnpMatch(void) -{ - struct DeviceResourceIface *devResInstance = NULL; - const struct DeviceResourceNode *rootNode = NULL; - const struct DeviceResourceNode *usbPnpNode = NULL; - - devResInstance = DeviceResourceGetIfaceInstance(HDF_CONFIG_SOURCE); - if (devResInstance == NULL) { - HDF_LOGE("%{public}s: devResInstance is NULL!", __func__); - return NULL; - } - - rootNode = devResInstance->GetRootNode(); - if (rootNode == NULL) { - HDF_LOGE("%{public}s: devResNode is NULL!", __func__); - return NULL; - } - - usbPnpNode = devResInstance->GetNodeByMatchAttr(rootNode, "usb_pnp_match"); - if (usbPnpNode == NULL) { - HDF_LOGE("%{public}s: usbPnpNode is NULL!", __func__); - return NULL; - } - - return DevmgrServiceStubParseDeviceId(usbPnpNode); -} - -static const struct UsbPnpMatchIdTable *DevmgrServiceStubPnpAddInterface(uint8_t index, - struct UsbPnpNotifyMatchInfoTable *infoTable, struct UsbPnpMatchIdTable **matchIdTable) -{ - struct UsbPnpMatchIdTable *idTable = NULL; - int32_t tableCount; - - for (tableCount = 0, idTable = matchIdTable[0]; idTable != NULL; idTable = matchIdTable[++tableCount]) { - HDF_LOGD("%{public}s:%{public}s matchDevice doing, idTable=%{public}p-%{public}d-0x%{public}x-0x%{public}x", \ - __func__, USB_PNP_DEBUG_STRING, idTable, idTable->matchFlag, idTable->vendorId, idTable->productId); - - if (!DevmgrServiceStubUsbMatchDevice(infoTable, idTable)) { - continue; - } - - if (!DevmgrServiceStubUsbMatchOneIdIntf(infoTable, index, idTable)) { - continue; - } - - HDF_LOGD("%{public}s: matchDevice end, index=%{public}d tableCount=%{public}d is match idTable=%{public}p, \ - moduleName=%{public}s, serviceName=%{public}s", __func__, index, tableCount, idTable, \ - idTable->moduleName, idTable->serviceName); - - return idTable; - } - - HDF_LOGD("%{public}s:%{public}s matchDevice end, idTable=%{public}p", \ - __func__, USB_PNP_DEBUG_STRING, idTable); - - return NULL; -} - -static int DevmgrServiceStubPnpRemoveInterface(struct IDevmgrService *devmgrSvc, - struct UsbPnpRemoveInfo removeInfo) -{ - int ret = HDF_SUCCESS; - struct HdfSBuf *pnpData = NULL; - struct UsbPnpDeviceListTable *deviceListTablePos = NULL; - struct UsbPnpDeviceListTable *deviceListTableTemp = NULL; - bool findFlag = false; - struct UsbPnpNotifyServiceInfo serviceInfo; - int32_t i; - - HDF_LOGD("%{public}s:%{public}s removeType=%{public}d Enter", \ - __func__, USB_PNP_DEBUG_STRING, removeInfo.removeType); - - if (DListIsEmpty(&g_usbPnpDeviceTableList->list)) { - HDF_LOGE("%{public}s:%{public}d g_usbPnpDeviceTableList is empty. ", __func__, __LINE__); - return HDF_ERR_INVALID_OBJECT; - } - - DLIST_FOR_EACH_ENTRY_SAFE(deviceListTablePos, deviceListTableTemp, &g_usbPnpDeviceTableList->list, \ - struct UsbPnpDeviceListTable, list) { - if ((deviceListTablePos->usbDevAddr == removeInfo.usbDevAddr) && \ - (deviceListTablePos->busNum == removeInfo.busNum)) { - if (removeInfo.removeType == USB_PNP_NOTIFY_REMOVE_INTERFACE_NUM) { - for (i = 0; i < deviceListTablePos->interfaceLength; i++) { - if (deviceListTablePos->interfaceNumber[i] == removeInfo.interfaceNum) { - break; - } - } - - if (i >= deviceListTablePos->interfaceLength) { - continue; - } - } - findFlag = true; - - serviceInfo.length = sizeof(struct UsbPnpNotifyServiceInfo) - (USB_PNP_INFO_MAX_INTERFACES \ - - deviceListTablePos->interfaceLength); - serviceInfo.devNum = deviceListTablePos->devNum; - serviceInfo.busNum = deviceListTablePos->busNum; - serviceInfo.interfaceLength = deviceListTablePos->interfaceLength; - memcpy_s(serviceInfo.interfaceNumber, USB_PNP_INFO_MAX_INTERFACES, \ - deviceListTablePos->interfaceNumber, USB_PNP_INFO_MAX_INTERFACES); - pnpData = DevmgrServiceStubBufCreate(deviceListTablePos->moduleName, deviceListTablePos->serviceName, \ - serviceInfo); - if (pnpData == NULL) { - ret = HDF_FAILURE; - HDF_LOGE("%{public}s: DevmgrServiceStubBufCreate faile", __func__); - break; - } - ret = DevmgrServiceStubDispatchPnpDevice(devmgrSvc, pnpData, false); - if (ret != HDF_SUCCESS) { - HDF_LOGE("%{public}s: DevmgrServiceStubDispatchPnpDevice faile", __func__); - break; - } - - DListRemove(&deviceListTablePos->list); - OsalMemFree(deviceListTablePos); - - HDF_LOGD("%{public}s:%{public}s usbDevAddr=0x%{public}x, device=%{public}d-%{public}d-%{public}d \ - to be remove success. ", __func__, USB_PNP_DEBUG_STRING, removeInfo.usbDevAddr, \ - removeInfo.devNum, removeInfo.busNum, removeInfo.interfaceNum); - } - } - - if (findFlag == false) { - HDF_LOGE("%{public}s:%{public}s removeType=%{public}d, usbDevAddr=0x%{public}x, \ - device=%{public}d-%{public}d-%{public}d to be remove but not exist. ", \ - __func__, USB_PNP_DEBUG_STRING, removeInfo.removeType, removeInfo.usbDevAddr, \ - removeInfo.devNum, removeInfo.busNum, removeInfo.interfaceNum); - ret = HDF_FAILURE; - } - - return ret; -} - -static int DevmgrServiceStubDeviceListAdd(struct UsbPnpNotifyMatchInfoTable *info, - const struct UsbPnpMatchIdTable *idTable) -{ - int ret; - unsigned char *ptr = NULL; - struct UsbPnpDeviceListTable *deviceTableListTemp = NULL; - - ptr = OsalMemAlloc(sizeof(struct UsbPnpDeviceListTable)); - if (ptr == NULL) { - ret = HDF_ERR_MALLOC_FAIL; - HDF_LOGE("%{public}s:%{public}d OsalMemAlloc faile, ret=%{public}d ", __func__, __LINE__, ret); - } else { - deviceTableListTemp = (struct UsbPnpDeviceListTable *)ptr; - - DListHeadInit(&deviceTableListTemp->list); - deviceTableListTemp->moduleName = idTable->moduleName; - deviceTableListTemp->serviceName = idTable->serviceName; - deviceTableListTemp->usbDevAddr = info->usbDevAddr; - deviceTableListTemp->devNum = info->devNum; - deviceTableListTemp->busNum = info->busNum; - deviceTableListTemp->interfaceLength = idTable->interfaceLength; - memcpy_s(deviceTableListTemp->interfaceNumber, USB_PNP_INFO_MAX_INTERFACES, \ - idTable->interfaceNumber, USB_PNP_INFO_MAX_INTERFACES); - - DListInsertTail(&deviceTableListTemp->list, &g_usbPnpDeviceTableList->list); - HDF_LOGD("%{public}s:%{public}s add %{public}s-%{public}s-0x%{public}x-%{public}d-%{public}d-\ - %{public}d-%{public}d device to g_usbPnpDeviceTableList", __func__, USB_PNP_DEBUG_STRING, \ - deviceTableListTemp->moduleName, deviceTableListTemp->serviceName, deviceTableListTemp->usbDevAddr, \ - deviceTableListTemp->devNum, deviceTableListTemp->busNum, deviceTableListTemp->interfaceLength, \ - deviceTableListTemp->interfaceNumber[0]); - - ret = HDF_SUCCESS; - } - - return ret; -} - -static int DevmgrServiceStubEventReceived(void *priv, uint32_t id, struct HdfSBuf *data) -{ - int ret; - bool flag; - uint32_t infoSize; - struct UsbPnpNotifyMatchInfoTable *infoTable = NULL; - struct HdfSBuf *pnpData = NULL; - struct IDevmgrService *super = (struct IDevmgrService *)priv; - struct UsbPnpMatchIdTable **matchIdTable = NULL; - const struct UsbPnpMatchIdTable *idTable = NULL; - int8_t i; - int32_t tableCount; - struct UsbPnpRemoveInfo removeInfo; - struct UsbPnpNotifyServiceInfo serviceInfo; - - HDF_LOGD("%{public}s:%{public}s enter", __func__, USB_PNP_DEBUG_STRING); - - flag = HdfSbufReadBuffer(data, (const void **)(&infoTable), &infoSize); - if ((flag == false) || (infoTable == NULL)) { - ret = HDF_ERR_INVALID_PARAM; - HDF_LOGE("%{public}s: fail to read infoTable in event data, flag=%{public}d, infoTable=%{public}p", \ - __func__, flag, infoTable); - return ret; - } - HDF_LOGD("%{public}s: %{public}s infoSize=%{public}d, usbDevAddr=0x%{public}x, devNum=%{public}d, \ - busNum=%{public}d, infoTable=0x%{public}x-0x%{public}x success", __func__, USB_PNP_DEBUG_STRING, \ - infoSize, infoTable->usbDevAddr, infoTable->devNum, infoTable->busNum, infoTable->deviceInfo.vendorId, \ - infoTable->deviceInfo.productId); - - HDF_LOGD("%{public}s: priv=%{public}p received:id=%{public}u", __func__, priv, id); - switch (id) { - case USB_PNP_NOTIFY_ADD_INTERFACE: - matchIdTable = DevmgrServiceStubPnpMatch(); - if ((matchIdTable == NULL) || (matchIdTable[0] == NULL)) { - ret = HDF_ERR_INVALID_PARAM; - HDF_LOGE("%{public}s: matchIdTable or matchIdTable[0] is NULL!", __func__); - return ret; - } - - for (i = 0; i < infoTable->numInfos; i++) { - idTable = DevmgrServiceStubPnpAddInterface(i, infoTable, matchIdTable); - if (idTable == NULL) { - HDF_LOGD("%{public}s: i=%{public}d is not match", __func__, i); - continue; - } - - serviceInfo.length = sizeof(struct UsbPnpNotifyServiceInfo) - (USB_PNP_INFO_MAX_INTERFACES \ - - idTable->interfaceLength); - serviceInfo.devNum = infoTable->devNum; - serviceInfo.busNum = infoTable->busNum; - serviceInfo.interfaceLength = idTable->interfaceLength; - memcpy_s(serviceInfo.interfaceNumber, USB_PNP_INFO_MAX_INTERFACES, \ - idTable->interfaceNumber, USB_PNP_INFO_MAX_INTERFACES); - pnpData = DevmgrServiceStubBufCreate(idTable->moduleName, idTable->serviceName, serviceInfo); - if (pnpData == NULL) { - ret = HDF_FAILURE; - HDF_LOGE("%{public}s: DevmgrServiceStubBufCreate faile", __func__); - break; - } - - ret = DevmgrServiceStubDispatchPnpDevice(super, pnpData, true); - if (ret != HDF_SUCCESS) { - HDF_LOGE("%{public}s:%{public}s handle failed, id is %{public}d, ret=%{public}d", \ - __func__, USB_PNP_DEBUG_STRING, id, ret); - } else { - ret = DevmgrServiceStubDeviceListAdd(infoTable, idTable); - if (ret != HDF_SUCCESS) { - HDF_LOGE("%{public}s:%{public}s DevmgrServiceStubDeviceListAdd faile", \ - __func__, USB_PNP_DEBUG_STRING); - break; - } - } - } - - HDF_LOGD("%{public}s:%{public}s OsalMemFree matchIdTable, ret=%{public}d", \ - __func__, USB_PNP_DEBUG_STRING, ret); - - tableCount = 0; - for (idTable = matchIdTable[0]; idTable != NULL;) { - tableCount++; - idTable = matchIdTable[tableCount]; - } - while ((--tableCount) >= 0) { - OsalMemFree(matchIdTable[tableCount]); - } - OsalMemFree(matchIdTable); - break; - case USB_PNP_NOTIFY_REMOVE_INTERFACE: - removeInfo.removeType = infoTable->removeType; - removeInfo.usbDevAddr = infoTable->usbDevAddr; - removeInfo.devNum = infoTable->devNum; - removeInfo.busNum = infoTable->busNum; - removeInfo.interfaceNum = infoTable->interfaceInfo[0].interfaceNumber; - ret = DevmgrServiceStubPnpRemoveInterface(super, removeInfo); - HDF_LOGD("%{public}s: %{public}s remove interface done", __func__, USB_PNP_DEBUG_STRING); - break; - case USB_PNP_NOTIFY_REPORT_INTERFACE: - ret = HDF_ERR_NOT_SUPPORT; - break; - default: - ret = HDF_ERR_INVALID_PARAM; - break; - } - - HDF_LOGD("%{public}s:%{public}s ret=%{public}d DONE", __func__, USB_PNP_DEBUG_STRING, ret); - - return ret; -} - -static int DevmgrServiceStubEventSend(struct HdfIoService *serv, char *eventData) -{ - int ret; - int replyData = 0; - struct HdfSBuf *data = NULL; - - data = HdfSBufObtainDefaultSize(); - if (data == NULL) { - ret = HDF_DEV_ERR_NO_MEMORY; - HDF_LOGE("%{public}s: fail to obtain sbuf data", __func__); - return ret; - } - - struct HdfSBuf *reply = HdfSBufObtainDefaultSize(); - if (reply == NULL) { - ret = HDF_DEV_ERR_NO_MEMORY; - HDF_LOGE("%{public}s: fail to obtain sbuf reply", __func__); - goto out; - } - - if (!HdfSbufWriteString(data, eventData)) { - ret = HDF_FAILURE; - HDF_LOGE("%{public}s: fail to write sbuf", __func__); - goto out; - } - - ret = serv->dispatcher->Dispatch(&serv->object, USB_PNP_NOTIFY_REPORT_INTERFACE, data, reply); - if (ret != HDF_SUCCESS) { - HDF_LOGE("%{public}s: fail to send serivice call, ret=%{public}d", __func__, ret); - goto out; - } - - if (!HdfSbufReadInt32(reply, &replyData)) { - ret = HDF_ERR_INVALID_OBJECT; - HDF_LOGE("%{public}s: fail to get service call reply", __func__); - goto out; - } - - HDF_LOGE("%{public}s: get reply is 0x%{public}x", __func__, replyData); - -out: - HdfSBufRecycle(data); - HdfSBufRecycle(reply); - - return ret; -} - -static int DevmgrServiceStubEventHandle(struct IDevmgrService *inst) -{ - int status; - struct HdfIoService *usbPnpServ = HdfIoServiceBind(USB_PNP_NOTIFY_SERVICE_NAME); - static struct HdfDevEventlistener usbPnpListener = { - .callBack = DevmgrServiceStubEventReceived, - }; - usbPnpListener.priv = (void *)(inst); - - if (g_usbPnpDeviceTableList == NULL) { - g_usbPnpDeviceTableList = (struct UsbPnpDeviceListTable *)OsalMemCalloc(sizeof(struct UsbPnpDeviceListTable)); - if (g_usbPnpDeviceTableList == NULL) { - status = HDF_ERR_MALLOC_FAIL; - HDF_LOGE("%{public}s: OsalMemCalloc g_usbPnpDeviceTableList faile status=%{public}d", \ - __func__, status); - return status; - } - DListHeadInit(&g_usbPnpDeviceTableList->list); - g_usbPnpDeviceTableList->moduleName = ""; - g_usbPnpDeviceTableList->serviceName = ""; - g_usbPnpDeviceTableList->usbDevAddr = 0; - g_usbPnpDeviceTableList->devNum = 0; - g_usbPnpDeviceTableList->busNum = 0; - g_usbPnpDeviceTableList->interfaceLength = 0; - memset_s(g_usbPnpDeviceTableList->interfaceNumber, USB_PNP_INFO_MAX_INTERFACES, 0, USB_PNP_INFO_MAX_INTERFACES); - HDF_LOGI("%{public}s OsalMemCalloc success,g_usbPnpDeviceTableList=%{public}p", \ - USB_PNP_DEBUG_STRING, g_usbPnpDeviceTableList); - } else { - HDF_LOGD("%{public}s g_usbPnpDeviceTableList=%{public}p is not NULL", \ - USB_PNP_DEBUG_STRING, g_usbPnpDeviceTableList); - } - - status = HdfDeviceRegisterEventListener(usbPnpServ, &usbPnpListener); - if (status != HDF_SUCCESS) { - HDF_LOGE("HdfDeviceRegisterEventListener faile status=%{public}d", status); - goto out; - } - HDF_LOGI("%{public}s HdfDeviceRegisterEventListener success,inst=%{public}p", USB_PNP_DEBUG_STRING, inst); - - status = DevmgrServiceStubEventSend(usbPnpServ, "USB PNP Handle Info"); - if (status != HDF_SUCCESS) { - HDF_LOGE("DevmgrServiceStubEventSend faile status=%{public}d", status); - goto out; - } - HDF_LOGI("DevmgrServiceStubEventSend success"); - -out: - OsalMemFree(g_usbPnpDeviceTableList); - - return status; -} - int DevmgrServiceStubStartService(struct IDevmgrService *inst) { int status = HDF_FAILURE; @@ -945,15 +164,7 @@ int DevmgrServiceStubStartService(struct IDevmgrService *inst) status = DevmgrServiceStartService((struct IDevmgrService *)&fullService->super); - HDF_LOGI("%{public}s:%{public}s Start service status is %{public}d", __func__, USB_PNP_DEBUG_STRING, status); - - HDF_LOGI("%{public}s:%{public}s", __func__, USB_PNP_DEBUG_STRING); - if (status == HDF_SUCCESS) { - if (DevmgrServiceStubEventHandle(inst) != HDF_SUCCESS) { - HDF_LOGE("%{public}s:%{public}s error", __func__, USB_PNP_DEBUG_STRING); - } - } - + HDF_LOGI("%s: Start service status is %d", __func__, status); return status; } diff --git a/uhdf2/manager/src/devmgr_virtual_service.c b/uhdf2/manager/src/devmgr_virtual_service.c old mode 100644 new mode 100755 index 76bf0808bad05860501a24f6a05939e4631779f2..183c2abc268f77c4cf788eb0e65ed7ea78feadc4 --- a/uhdf2/manager/src/devmgr_virtual_service.c +++ b/uhdf2/manager/src/devmgr_virtual_service.c @@ -62,7 +62,7 @@ int DevmgrServiceVirtualDevice( } if (flag) { - ret = DevmgrServiceRegPnpDevice(inst, moduleName, serviceName, NULL); + ret = DevmgrServiceRegPnpDevice(inst, moduleName, serviceName); if (ret == HDF_SUCCESS) { list = DevmgrServiceGetPnpDeviceInfo(); DevmgrUpdateDeviceType(list, moduleName, serviceName); diff --git a/uhdf2/ohos.build b/uhdf2/ohos.build old mode 100755 new mode 100644 index 896e39682a7567b73dfa516279e7a8d81bd7d9ef..bf06483a3580bd06e8b72a1f7649da6714cf2ef9 --- a/uhdf2/ohos.build +++ b/uhdf2/ohos.build @@ -17,27 +17,15 @@ "//drivers/peripheral/display/hal:hdi_display", "//drivers/peripheral/wlan/client:wifi_driver_client", "//drivers/peripheral/wlan/hal:wifi_hal", - "//drivers/peripheral/camera/hal:camera_hal", - "//drivers/peripheral/usb/core:libusb_core", - "//drivers/peripheral/usb/serial:hostsdk_test", - "//drivers/peripheral/usb/serial:libusbhost_acm", - "//drivers/peripheral/usb/serial:hostacm_test", - "//drivers/peripheral/usb/gadget:libusbfn_cdcacm", - "//drivers/peripheral/usb/gadget:acm_test", - "//drivers/peripheral/usb/gadget:acm_read", - "//drivers/peripheral/usb/gadget:acm_write", - "//drivers/peripheral/usb/gadget:prop_test", "//drivers/peripheral/base:hdf_peripheral.rc", "//drivers/peripheral/sensor/hal:hdi_sensor" ], "test_list": [ - "//drivers/peripheral/wlan/test:hdf_test_wifi", "//drivers/peripheral/sensor/test:hdf_test_sensor", "//drivers/adapter/uhdf2/test:hdf_test_uhdf", "//drivers/adapter/uhdf2/osal/test:unittest", "//drivers/adapter/uhdf2/host/test:unittest", - "//drivers/adapter/uhdf2/hdi/test:unittest", - "//drivers/peripheral/usb/moduletest:moduletest" + "//drivers/adapter/uhdf2/hdi/test:unittest" ] } } diff --git a/uhdf2/osal/BUILD.gn b/uhdf2/osal/BUILD.gn old mode 100755 new mode 100644 diff --git a/uhdf2/osal/test/BUILD.gn b/uhdf2/osal/test/BUILD.gn old mode 100755 new mode 100644 diff --git a/uhdf2/osal/test/unittest/common/osal_slist_test.cpp b/uhdf2/osal/test/unittest/common/osal_slist_test.cpp old mode 100755 new mode 100644 diff --git a/uhdf2/security/BUILD.gn b/uhdf2/security/BUILD.gn old mode 100755 new mode 100644 diff --git a/uhdf2/shared/include/hdf_device_info_full.h b/uhdf2/shared/include/hdf_device_info_full.h old mode 100644 new mode 100755 diff --git a/uhdf2/shared/src/dev_attribute_parcel.c b/uhdf2/shared/src/dev_attribute_parcel.c old mode 100644 new mode 100755 index b01c4e2c7d0ab69adeceedb8bd75353f66094175..967c95b3aac608aa10cdac8eb949e8aed5c151ab --- a/uhdf2/shared/src/dev_attribute_parcel.c +++ b/uhdf2/shared/src/dev_attribute_parcel.c @@ -20,114 +20,6 @@ #define HDF_LOG_TAG dev_attribute_parcel -#define ATTRIBUTE_PRIVATE_DATA_LENGTH_NULL 0 - -static bool DeviceAttributePrivateWrite(const struct HdfDeviceInfoFull *attribute, struct HdfSBuf *sbuf) -{ - bool flag; - uint8_t byteData; - int32_t wordData; - struct UsbPnpNotifyServiceInfo *info = (struct UsbPnpNotifyServiceInfo *)(attribute->super.private); - int32_t i; - - if (info == NULL) { - HDF_LOGE("Device attribute writePrivate private is NULL"); - return false; - } - - wordData = info->length; - flag = HdfSbufWriteInt32(sbuf, wordData); - if (flag == false) { - HDF_LOGE("Device attribute writePrivate length failed, flag=%{public}d", flag); - return false; - } - wordData = info->devNum; - flag = HdfSbufWriteInt32(sbuf, wordData); - if (flag == false) { - HDF_LOGE("Device attribute writePrivate devNum failed, flag=%{public}d", flag); - return false; - } - wordData = info->busNum; - flag = HdfSbufWriteInt32(sbuf, wordData); - if (flag == false) { - HDF_LOGE("Device attribute writePrivate busNum failed, flag=%{public}d", flag); - return false; - } - wordData = info->interfaceLength; - flag = HdfSbufWriteInt32(sbuf, wordData); - if (flag == false) { - HDF_LOGE("Device attribute writePrivate interfaceLength failed, flag=%{public}d", flag); - return false; - } - for (i = 0; i < info->interfaceLength; i++) { - byteData = info->interfaceNumber[i]; - flag = HdfSbufWriteUint8(sbuf, byteData); - if (flag == false) { - HDF_LOGE("Device attribute writePrivate interfaceNumber[%{public}d] failed, flag=%{public}d", flag, i); - return false; - } - } - - return true; -} - -static const void *DeviceAttributePrivateRead(struct HdfSBuf *sbuf) -{ - bool flag; - int32_t wordData; - uint8_t byteData; - int32_t i; - - struct UsbPnpNotifyServiceInfo *info = (struct UsbPnpNotifyServiceInfo *)OsalMemCalloc(sizeof(struct UsbPnpNotifyServiceInfo)); - if (info == NULL) { - HDF_LOGE("%{public}s: OsalMemCalloc failed, info is null", __func__); - return NULL; - } - - flag = HdfSbufReadInt32(sbuf, &wordData); - if (flag == false) { - HDF_LOGE("Device attribute readPrivate length failed, flag=%{public}d", flag); - return NULL; - } - info->length = wordData; - - if (info->length == ATTRIBUTE_PRIVATE_DATA_LENGTH_NULL) { - HDF_LOGW("%{public}s: readPrivate is NULL and info->length=%{public}d", __func__, info->length); - } else { - flag = HdfSbufReadInt32(sbuf, &wordData); - if (flag == false) { - HDF_LOGE("Device attribute readPrivate devNum failed, flag=%{public}d", flag); - return NULL; - } - info->devNum = wordData; - - flag = HdfSbufReadInt32(sbuf, &wordData); - if (flag == false) { - HDF_LOGE("Device attribute readPrivate busNum failed, flag=%{public}d", flag); - return NULL; - } - info->busNum = wordData; - - flag = HdfSbufReadInt32(sbuf, &wordData); - if (flag == false) { - HDF_LOGE("Device attribute readPrivate interfaceLength failed, flag=%{public}d", flag); - return NULL; - } - info->interfaceLength = wordData; - - for (i = 0; i < info->interfaceLength; i++) { - flag = HdfSbufReadUint8(sbuf, &byteData); - if (flag == false) { - HDF_LOGE("Device attribute readPrivate interfaceNumber[%{public}d] failed, flag=%{public}d", flag, i); - return NULL; - } - info->interfaceNumber[i] = byteData; - } - } - - return (const void *)info; -} - bool DeviceAttributeFullWrite(const struct HdfDeviceInfoFull *attribute, struct HdfSBuf *sbuf) { if (attribute == NULL || sbuf == NULL) { @@ -141,13 +33,6 @@ bool DeviceAttributeFullWrite(const struct HdfDeviceInfoFull *attribute, struct ret &= HdfSbufWriteString(sbuf, attribute->super.svcName); ret &= HdfSbufWriteString(sbuf, attribute->super.moduleName); ret &= HdfSbufWriteString(sbuf, attribute->super.deviceMatchAttr); - if (attribute->super.private != NULL) { - ret &= DeviceAttributePrivateWrite(attribute, sbuf); - } else { - HDF_LOGW("%{public}s: Device attribute write private is NULL", __func__); - uint8_t privateLength = ATTRIBUTE_PRIVATE_DATA_LENGTH_NULL; - ret &= HdfSbufWriteUint8(sbuf, privateLength); - } if (ret == 0) { HDF_LOGE("Device attribute write parcel failed"); @@ -192,23 +77,6 @@ struct HdfDeviceInfoFull *DeviceAttributeFullRead(struct HdfSBuf *sbuf) break; } - const char *deviceMatchAttr = HdfSbufReadString(sbuf); - if (deviceMatchAttr == NULL) { - HDF_LOGE("%{public}s: Read from parcel failed, deviceMatchAttr is null", __func__); - break; - } - attribute->super.deviceMatchAttr = strdup(deviceMatchAttr); - - attribute->super.private = DeviceAttributePrivateRead(sbuf); - if (attribute->super.private == NULL) { - HDF_LOGE("%{public}s: Read from parcel failed, private is null", __func__); - break; - } - - HDF_LOGD("%{public}s: AttributeRead moduleName=%{public}s, svcName=%{public}s, deviceMatchAttr=%{public}s, private=%{public}p, length=%{public}d", \ - __func__, moduleName, svcName, deviceMatchAttr, attribute->super.private, \ - ((struct UsbPnpNotifyServiceInfo *)(attribute->super.private))->length); - return attribute; } while (0); diff --git a/uhdf2/shared/src/hdf_device_info_full.c b/uhdf2/shared/src/hdf_device_info_full.c old mode 100644 new mode 100755 index 33bd37644e0f666f8460e068ef349a85ea9e4f23..ed96e6595b2c12531df8fa03a5613e985b08442a --- a/uhdf2/shared/src/hdf_device_info_full.c +++ b/uhdf2/shared/src/hdf_device_info_full.c @@ -47,12 +47,6 @@ void HdfDeviceInfoFullFreeInstance(struct HdfDeviceInfoFull *attribute) if (attribute->super.svcName != NULL) { OsalMemFree((void *)attribute->super.svcName); } - if (attribute->super.deviceMatchAttr != NULL) { - OsalMemFree((void *)attribute->super.deviceMatchAttr); - } - if (attribute->super.private != NULL) { - OsalMemFree((void *)attribute->super.private); - } if (attribute->deviceHandle != NULL) { dlclose(attribute->deviceHandle); } diff --git a/uhdf2/test/BUILD.gn b/uhdf2/test/BUILD.gn old mode 100755 new mode 100644 diff --git a/uhdf2/test/resource/config/ohos_test.xml b/uhdf2/test/resource/config/ohos_test.xml old mode 100755 new mode 100644 diff --git a/uhdf2/test/unittest/common/BUILD.gn b/uhdf2/test/unittest/common/BUILD.gn old mode 100755 new mode 100644 diff --git a/uhdf2/test/unittest/config/BUILD.gn b/uhdf2/test/unittest/config/BUILD.gn old mode 100755 new mode 100644 diff --git a/uhdf2/test/unittest/manager/BUILD.gn b/uhdf2/test/unittest/manager/BUILD.gn old mode 100755 new mode 100644 diff --git a/uhdf2/test/unittest/osal/BUILD.gn b/uhdf2/test/unittest/osal/BUILD.gn old mode 100755 new mode 100644 diff --git a/uhdf2/test/unittest/platform/BUILD.gn b/uhdf2/test/unittest/platform/BUILD.gn old mode 100755 new mode 100644 diff --git a/uhdf2/uhdf.gni b/uhdf2/uhdf.gni old mode 100755 new mode 100644