1 /* 2 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 3 * 4 * HDF is dual licensed: you can use it either under the terms of 5 * the GPL, or the BSD license, at your option. 6 * See the LICENSE file in the root of this repository for complete details. 7 */ 8 9 #ifndef HDF_DEVICE_NODE_H 10 #define HDF_DEVICE_NODE_H 11 12 #include "hdf_device.h" 13 #include "hdf_device_info.h" 14 #include "hdf_device_desc.h" 15 #include "hdf_dlist.h" 16 #include "hdf_driver.h" 17 #include "hdf_pm.h" 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif /* __cplusplus */ 22 23 struct HdfDeviceNode; 24 struct DevHostService; 25 26 struct IDeviceNode { 27 struct HdfObject object; 28 int (*PublishService)(struct HdfDeviceNode *devNode); 29 int (*RemoveService)(struct HdfDeviceNode *devNode); 30 int (*LaunchNode)(struct HdfDeviceNode *devNode); 31 void (*UnlaunchNode)(struct HdfDeviceNode *devNode); 32 }; 33 34 struct HdfDeviceNode { 35 struct IDeviceNode super; 36 struct DListHead entry; 37 struct PowerStateToken *powerToken; 38 struct DevHostService *hostService; 39 struct HdfDeviceObject deviceObject; 40 struct IHdfDeviceToken *token; 41 struct HdfDriver *driver; 42 struct HdfDevice *device; 43 char *servName; 44 const char *servInfo; 45 char *driverName; 46 devid_t devId; 47 uint16_t policy; 48 uint16_t permission; 49 uint8_t devStatus; 50 bool servStatus; 51 char *interfaceDesc; 52 }; 53 54 enum DevNodeStaus { 55 DEVNODE_NONE = 0, 56 DEVNODE_INITED, 57 DEVNODE_LAUNCHED, 58 }; 59 60 int HdfDeviceNodeAddPowerStateListener( 61 struct HdfDeviceNode *devNode, const struct IPowerEventListener *listener); 62 void HdfDeviceNodeRemovePowerStateListener( 63 struct HdfDeviceNode *devNode, const struct IPowerEventListener *listener); 64 void HdfDeviceNodeConstruct(struct HdfDeviceNode *devNode); 65 void HdfDeviceNodeDestruct(struct HdfDeviceNode *devNode); 66 struct HdfDeviceNode *HdfDeviceNodeNewInstance(const struct HdfDeviceInfo *deviceInfo, struct HdfDriver *driver); 67 void HdfDeviceNodeFreeInstance(struct HdfDeviceNode *devNode); 68 void HdfDeviceNodeDelete(struct HdfDeviceNode *devNode); 69 int HdfDeviceNodePublishPublicService(struct HdfDeviceNode *devNode); 70 int HdfDeviceNodeRemoveService(struct HdfDeviceNode *devNode); 71 int DeviceDriverBind(struct HdfDeviceNode *devNode); 72 73 #ifdef __cplusplus 74 } 75 #endif /* __cplusplus */ 76 77 #endif /* HDF_DEVICE_NODE_H */ 78