mTower
pseudo_ta.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2015, Linaro Limited
4  */
5 #ifndef KERNEL_PSEUDO_TA_H
6 #define KERNEL_PSEUDO_TA_H
7 
8 #include <assert.h>
9 #include <compiler.h>
10 #include <tee_ta_manager.h>
11 #include <tee_api_types.h>
12 #include <user_ta_header.h>
13 //#include <util.h>
14 
15 #define PTA_MANDATORY_FLAGS (TA_FLAG_SINGLE_INSTANCE | \
16  TA_FLAG_MULTI_SESSION | \
17  TA_FLAG_INSTANCE_KEEP_ALIVE)
18 //
19 //#define PTA_ALLOWED_FLAGS (PTA_MANDATORY_FLAGS | \
20 // TA_FLAG_SECURE_DATA_PATH | \
21 // TA_FLAG_CONCURRENT)
22 
23 #define PTA_DEFAULT_FLAGS PTA_MANDATORY_FLAGS
24 
26  TEE_UUID uuid;
27  const char *name;
28  uint32_t flags;
29 
30  TEE_Result (*create_entry_point)(void);
31  void (*destroy_entry_point)(void);
32  TEE_Result (*open_session_entry_point)(uint32_t nParamTypes,
33  TEE_Param pParams[TEE_NUM_PARAMS],
34  void **ppSessionContext);
35  void (*close_session_entry_point)(void *pSessionContext);
36  TEE_Result (*invoke_command_entry_point)(void *pSessionContext,
37  uint32_t nCommandID, uint32_t nParamTypes,
38  TEE_Param pParams[TEE_NUM_PARAMS]);
39 };
40 
41 #define pseudo_ta_register(...) static const struct pseudo_ta_head __head \
42  __used __section("ta_head_section") = { __VA_ARGS__ }
43 
44 
45 struct pseudo_ta_ctx {
46  const struct pseudo_ta_head *pseudo_ta;
47  struct tee_ta_ctx ctx;
48 };
49 
50 static inline bool is_pseudo_ta_ctx(struct tee_ta_ctx *ctx)
51 {
52  return !(ctx->flags & TA_FLAG_USER_MODE);
53 }
54 
55 #define container_of(ptr, type, member) \
56  (__extension__({ \
57  const typeof(((type *)0)->member) *__ptr = (ptr); \
58  (type *)((unsigned long)(__ptr) - offsetof(type, member)); \
59  }))
60 
61 static inline struct pseudo_ta_ctx *to_pseudo_ta_ctx(struct tee_ta_ctx *ctx)
62 {
63 // assert(is_pseudo_ta_ctx(ctx));
64  return container_of(ctx, struct pseudo_ta_ctx, ctx);
65 }
66 
67 TEE_Result tee_ta_init_pseudo_ta_session(const TEE_UUID *uuid,
68  struct tee_ta_session *s);
69 
70 #endif /* KERNEL_PSEUDO_TA_H */
71 
Definition: tee_api_types.h:72
Definition: pseudo_ta.h:25
Definition: pseudo_ta.h:45
Definition: tee_ta_manager.h:117
Definition: tee_api_types.h:45
Definition: tee_ta_manager.h:105