• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 Huawei Technologies Co., Ltd.
3  * Licensed under the Mulan PSL v2.
4  * You can use this software according to the terms and conditions of the Mulan PSL v2.
5  * You may obtain a copy of Mulan PSL v2 at:
6  *     http://license.coscl.org.cn/MulanPSL2
7  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
8  * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
9  * PURPOSE.
10  * See the Mulan PSL v2 for more details.
11  */
12 #ifndef PLATDRV_DRV_THREAD_H
13 #define PLATDRV_DRV_THREAD_H
14 #include <bits/alltypes.h>
15 #include <drv.h>
16 #include <spawn_ext.h>
17 
18 #define DRV_CALL_OK      0
19 #define DRV_CALL_ERROR  (-1)
20 intptr_t driver_dispatch(void *msg, cref_t *p_msg_hdl, struct src_msginfo *info);
21 
22 #ifdef CONFIG_DISABLE_MULTI_DRV
23 #define DRV_THREAD_MAX 0
24 #else /* CONFIG_DISABLE_MULTI_DRV */
25 #define DRV_THREAD_MAX 8
26 #endif /* CONFIG_DISABLE_MULTI_DRV */
27 #define INVALID_CALLER_PID (-1)
28 #define TASK_MAX 20
29 #define REPLY_BUF_LEN 2048U
30 #define ULL_PERMISSIONS 0x0
31 
32 struct syscaller_info {
33     tid_t current_thread;
34     pid_t caller_pid;
35     uint64_t job_handler;
36 };
37 
38 int32_t drv_thread_init(const char *name, uint32_t stack_size, uint32_t thread_limit);
39 int32_t multi_drv_framwork_init(uint32_t thread_limit, uint32_t stack_size, cref_t channel);
40 void update_callerpid_by_tid(tid_t tid, pid_t caller_pid);
41 int32_t get_callerpid_by_tid(tid_t tid, pid_t *caller_pid);
42 void update_caller_info_by_tid(tid_t tid, pid_t caller_pid, uint64_t job_handler);
43 int32_t get_callerpid_and_job_handler_by_tid(tid_t tid, pid_t *caller_pid, uint64_t *job_handler);
44 #endif
45