2 * Copyright (c) 2015, Linaro Limited
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
27 #ifndef KERNEL_PSEUDO_TA_H
28 #define KERNEL_PSEUDO_TA_H
32 #include <kernel/tee_ta_manager.h>
33 #include <tee_api_types.h>
34 #include <user_ta_header.h>
37 #define PTA_MANDATORY_FLAGS (TA_FLAG_SINGLE_INSTANCE | \
38 TA_FLAG_MULTI_SESSION | \
39 TA_FLAG_INSTANCE_KEEP_ALIVE)
41 #define PTA_ALLOWED_FLAGS PTA_MANDATORY_FLAGS
42 #define PTA_DEFAULT_FLAGS PTA_MANDATORY_FLAGS
44 struct pseudo_ta_head {
49 TEE_Result (*create_entry_point)(void);
50 void (*destroy_entry_point)(void);
51 TEE_Result (*open_session_entry_point)(uint32_t nParamTypes,
52 TEE_Param pParams[TEE_NUM_PARAMS],
53 void **ppSessionContext);
54 void (*close_session_entry_point)(void *pSessionContext);
55 TEE_Result (*invoke_command_entry_point)(void *pSessionContext,
56 uint32_t nCommandID, uint32_t nParamTypes,
57 TEE_Param pParams[TEE_NUM_PARAMS]);
60 #define pseudo_ta_register(...) static const struct pseudo_ta_head __head \
61 __used __section("ta_head_section") = { __VA_ARGS__ }
64 struct pseudo_ta_ctx {
65 const struct pseudo_ta_head *pseudo_ta;
66 struct tee_ta_ctx ctx;
69 static inline bool is_pseudo_ta_ctx(struct tee_ta_ctx *ctx)
71 return !(ctx->flags & TA_FLAG_USER_MODE);
74 static inline struct pseudo_ta_ctx *to_pseudo_ta_ctx(struct tee_ta_ctx *ctx)
76 assert(is_pseudo_ta_ctx(ctx));
77 return container_of(ctx, struct pseudo_ta_ctx, ctx);
80 TEE_Result tee_ta_init_pseudo_ta_session(const TEE_UUID *uuid,
81 struct tee_ta_session *s);
83 #endif /* KERNEL_PSEUDO_TA_H */