1 /* 2 * Copyright (c) 2020-2022 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_IO_SERVICE_H 10 #define HDF_IO_SERVICE_H 11 12 #include "hdf_io_service_if.h" 13 14 #ifdef __cplusplus 15 extern "C" { 16 #endif /* __cplusplus */ 17 18 #define DEV_NODE_PATH "/dev/hdf/" 19 #define DEV_PATH "/dev/" 20 #define DEV_MGR_NODE "dev_mgr" 21 #define MAX_MODE_SIZE 0777 22 #define DEV_NODE_PATH_MODE 0750 23 #define HDF_WRITE_READ _IO('b', 1) 24 #define HDF_READ_DEV_EVENT _IO('b', 2) 25 #define HDF_LISTEN_EVENT_START _IO('b', 3) 26 #define HDF_LISTEN_EVENT_STOP _IO('b', 4) 27 #define HDF_LISTEN_EVENT_WAKEUP _IO('b', 5) 28 #define HDF_LISTEN_EVENT_EXIT _IO('b', 6) 29 30 typedef enum { 31 DEVMGR_LOAD_SERVICE = 0, 32 DEVMGR_UNLOAD_SERVICE, 33 DEVMGR_GET_SERVICE, 34 DEVMGR_LIST_ALL_SERVICE, 35 DEVMGR_LIST_ALL_DEVICE, 36 } DevMgrCmd; 37 38 struct HdfWriteReadBuf { 39 uint32_t writeSize; // bytes to write 40 uint32_t writeConsumed; // bytes consumed by driver (for ERESTARTSYS) 41 uint64_t writeBuffer; 42 uint32_t readSize; // bytes to read 43 uint32_t readConsumed; // bytes consumed by driver (for ERESTARTSYS) 44 uint64_t readBuffer; 45 int32_t cmdCode; 46 }; 47 48 struct HdfIoService *HdfIoServicePublish(const char *serviceName, uint32_t mode); 49 void HdfIoServiceRemove(struct HdfIoService *service); 50 51 struct HdfIoService *HdfIoServiceAdapterObtain(const char *serviceName); 52 void HdfIoServiceAdapterRecycle(struct HdfIoService *service); 53 struct HdfIoService *HdfIoServiceAdapterPublish(const char *serviceName, uint32_t mode) __attribute__((weak)); 54 void HdfIoServiceAdapterRemove(struct HdfIoService *service) __attribute__((weak)); 55 int32_t HdfLoadDriverByServiceName(const char *serviceName); 56 int32_t HdfListAllService(struct HdfSBuf *reply); 57 int32_t HdfListAllDevice(struct HdfSBuf *reply); 58 59 #ifdef __cplusplus 60 } 61 #endif /* __cplusplus */ 62 63 #endif /* HDF_IO_SERVICE_H */ 64 65