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_SYSCALL_ADAPTER_H 10 #define HDF_SYSCALL_ADAPTER_H 11 12 #include "hdf_dlist.h" 13 #include "hdf_io_service_if.h" 14 #include "osal_mutex.h" 15 #include "osal_thread.h" 16 17 struct HdfSyscallAdapter; 18 19 enum HdfDevListenerThreadStatus { 20 LISTENER_UNINITED = 0, 21 LISTENER_INITED, 22 LISTENER_EXITED, 23 LISTENER_STARTED, 24 LISTENER_RUNNING, 25 LISTENER_WAITING, 26 }; 27 28 struct HdfDevListenerThread { 29 struct OsalMutex mutex; 30 struct OsalThread thread; 31 struct DListHead *adapterListPtr; 32 struct HdfSyscallAdapter *adapter; 33 struct pollfd *pfds; 34 uint16_t pfdSize; 35 bool pollChanged; 36 bool shouldStop; 37 struct DListHead *listenerListPtr; 38 uint8_t status; 39 }; 40 41 struct HdfSyscallAdapter { 42 struct HdfIoService super; 43 struct OsalMutex mutex; 44 struct DListHead listenerList; 45 int fd; 46 struct DListHead listNode; 47 struct HdfDevListenerThread *thread; 48 struct HdfSyscallAdapterGroup *group; 49 }; 50 51 struct HdfSyscallAdapterGroup { 52 struct HdfIoServiceGroup serviceGroup; 53 struct OsalMutex mutex; 54 struct DListHead adapterList; 55 struct HdfDevListenerThread *thread; 56 struct DListHead listenerList; 57 }; 58 59 #endif /* HDF_SYSCALL_ADAPTER_H */ 60