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