1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
#ifndef __CMDQ_SEC_H__
#define __CMDQ_SEC_H__
#include "cmdq_core.h"
#if defined(CMDQ_SECURE_PATH_SUPPORT)
#include "mobicore_driver_api.h"
#include "cmdq_sec_iwc_common.h"
#endif
/**
* error code for CMDQ
*/
#define CMDQ_ERR_NULL_SEC_CTX_HANDLE (6000)
#define CMDQ_ERR_SEC_CTX_SETUP (6001)
#define CMDQ_ERR_SEC_CTX_TEARDOWN (6002)
/**
* inter-world communication state
*/
typedef enum {
IWC_INIT = 0,
IWC_MOBICORE_OPENED = 1,
IWC_WSM_ALLOCATED = 2,
IWC_SES_OPENED = 3,
IWC_SES_MSG_PACKAGED = 4,
IWC_SES_TRANSACTED = 5,
IWC_SES_ON_TRANSACTED = 6,
IWC_END_OF_ENUM = 7,
} CMDQ_IWC_STATE_ENUM;
/**
* CMDQ secure context struct
* note it is not global data, each process has its own CMDQ sec context
*/
typedef struct cmdqSecContextStruct {
struct list_head listEntry;
/* basic info */
uint32_t tgid; /* tgid of process context */
uint32_t referCount; /* reference count for open cmdq device node */
/* iwc state */
CMDQ_IWC_STATE_ENUM state;
/* iwc information */
void *iwcMessage; /* message buffer */
#if defined(CMDQ_SECURE_PATH_SUPPORT)
struct mc_uuid_t uuid; /* Universally Unique Identifier of secure tl/dr */
struct mc_session_handle sessionHandle; /* session handle */
#endif
uint32_t openMobicoreByOther; /* true if someone has opened mobicore device in this prpocess context */
} cmdqSecContextStruct, *cmdqSecContextHandle;
int32_t cmdq_sec_init_allocate_resource_thread(void *data);
/**
* Create and destory non-cachable shared memory,
* used to share data for CMDQ driver between NWd and SWd
*
* Be careful that we should not disvlose any information about secure buffer address of
*/
int32_t cmdq_sec_create_shared_memory(cmdqSecSharedMemoryHandle *pHandle, const uint32_t size);
int32_t cmdq_sec_destroy_shared_memory(cmdqSecSharedMemoryHandle handle);
/**
* Callback to fill message buffer for secure task
*
* Params:
* init32_t command id
* void* pornter of TaskStruct
* int32_t CMDQ HW thread id
* void* the inter-world communication buffer
* Return:
* >=0 for success;
*/
typedef int32_t(*CmdqSecFillIwcCB) (int32_t, void *, int32_t, void *);
/**
* Entry secure world to handle secure path jobs
* .submit task
* .cancel error task
*/
int32_t cmdq_sec_exec_task_async_unlocked(TaskStruct *pTask, int32_t thread);
int32_t cmdq_sec_cancel_error_task_unlocked(TaskStruct *pTask, int32_t thread, cmdqSecCancelTaskResultStruct *pResult);
int32_t cmdq_sec_allocate_path_resource_unlocked(bool throwAEE);
/**
* secure path control
*/
void cmdq_sec_lock_secure_path(void);
void cmdq_sec_unlock_secure_path(void);
void cmdqSecInitialize(void);
void cmdqSecDeInitialize(void);
void cmdqSecEnableProfile(const bool enable);
#endif /* __DDP_CMDQ_SEC_H__ */
|