diff options
author | Igor Opaniuk <igor.opaniuk@linaro.org> | 2018-02-05 18:39:13 +0200 |
---|---|---|
committer | Jérôme Forissier <jerome.forissier@linaro.org> | 2018-06-19 13:23:32 +0200 |
commit | afefa2ccd2023d5bd4c7b5116f0f4358ca94bb4d (patch) | |
tree | c780fd0d0540b880f101577e6a4ded46d901ce0c | |
parent | afd1381f1b3f59835abae6e59120d1e0e3960121 (diff) |
core: support for global shared buffers
Add support of allocating SHM shared with non-secure kernel
and exported to a non-secure userspace application.
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Igor Opaniuk <igor.opaniuk@linaro.org>
-rw-r--r-- | core/arch/arm/include/kernel/thread.h | 20 | ||||
-rw-r--r-- | core/arch/arm/kernel/thread.c | 10 | ||||
-rw-r--r-- | core/include/optee_msg.h | 5 |
3 files changed, 35 insertions, 0 deletions
diff --git a/core/arch/arm/include/kernel/thread.h b/core/arch/arm/include/kernel/thread.h index cd6dd815..056fa340 100644 --- a/core/arch/arm/include/kernel/thread.h +++ b/core/arch/arm/include/kernel/thread.h @@ -628,6 +628,26 @@ uint32_t thread_rpc_cmd(uint32_t cmd, size_t num_params, unsigned long thread_smc(unsigned long func_id, unsigned long a1, unsigned long a2, unsigned long a3); +/** + * Allocate data for payload buffers. + * Buffer is exported to user mode applications. + * + * @size: size in bytes of payload buffer + * @cookie: returned cookie used when freeing the buffer + * + * @returns mobj that describes allocated buffer or NULL on error + */ +struct mobj *thread_rpc_alloc_global_payload(size_t size, uint64_t *cookie); + +/** + * Free physical memory previously allocated with + * thread_rpc_alloc_global_payload() + * + * @cookie: cookie received when allocating the buffer + * @mobj: mobj that describes the buffer + */ +void thread_rpc_free_global_payload(uint64_t cookie, struct mobj *mobj); + #endif /*ASM*/ #endif /*KERNEL_THREAD_H*/ diff --git a/core/arch/arm/kernel/thread.c b/core/arch/arm/kernel/thread.c index ed8cb13d..119cf408 100644 --- a/core/arch/arm/kernel/thread.c +++ b/core/arch/arm/kernel/thread.c @@ -1573,3 +1573,13 @@ void thread_rpc_free_payload(uint64_t cookie, struct mobj *mobj) { thread_rpc_free(OPTEE_MSG_RPC_SHM_TYPE_APPL, cookie, mobj); } + +struct mobj *thread_rpc_alloc_global_payload(size_t size, uint64_t *cookie) +{ + return thread_rpc_alloc(size, 8, OPTEE_MSG_RPC_SHM_TYPE_GLOBAL, cookie); +} + +void thread_rpc_free_global_payload(uint64_t cookie, struct mobj *mobj) +{ + thread_rpc_free(OPTEE_MSG_RPC_SHM_TYPE_GLOBAL, cookie, mobj); +} diff --git a/core/include/optee_msg.h b/core/include/optee_msg.h index bf59f82d..d5b858fa 100644 --- a/core/include/optee_msg.h +++ b/core/include/optee_msg.h @@ -397,6 +397,11 @@ struct optee_msg_arg { #define OPTEE_MSG_RPC_SHM_TYPE_APPL 0 /* Memory only shared with non-secure kernel */ #define OPTEE_MSG_RPC_SHM_TYPE_KERNEL 1 +/* + * Memory shared with non-secure kernel and exported to a non-secure user + * space application + */ +#define OPTEE_MSG_RPC_SHM_TYPE_GLOBAL 2 /* * Free shared memory previously allocated with OPTEE_MSG_RPC_CMD_SHM_ALLOC |