Skip to content

Commit

Permalink
core: OCALL support
Browse files Browse the repository at this point in the history
Adds the ability for TAs to perform "Out Calls", or OCALLs. OCALLs allow
TAs to invoke commands on their corresponding CA in the same way that CAs
can invoke commands on TAs.

Signed-off-by: Hernan Gatta <[email protected]>
  • Loading branch information
HernanGatta committed Apr 11, 2020
1 parent 55efdb8 commit 9905099
Show file tree
Hide file tree
Showing 12 changed files with 544 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/arch/arm/include/kernel/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define THREAD_ID_0 0
#define THREAD_ID_INVALID -1

#define THREAD_RPC_MAX_NUM_PARAMS 4
#define THREAD_RPC_MAX_NUM_PARAMS 6

#ifndef __ASSEMBLER__

Expand Down Expand Up @@ -674,6 +674,10 @@ struct mobj *thread_rpc_alloc_global_payload(size_t size);
*/
void thread_rpc_free_global_payload(struct mobj *mobj);

struct mobj *thread_rpc_alloc_client_app_payload(size_t size);

void thread_rpc_free_client_app_payload(struct mobj *mobj);

#endif /*__ASSEMBLER__*/

#endif /*KERNEL_THREAD_H*/
11 changes: 11 additions & 0 deletions core/arch/arm/kernel/thread_optee_smc.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,3 +601,14 @@ void thread_rpc_free_global_payload(struct mobj *mobj)
thread_rpc_free(OPTEE_RPC_SHM_TYPE_GLOBAL, mobj_get_cookie(mobj),
mobj);
}

struct mobj *thread_rpc_alloc_client_app_payload(size_t size)
{
return thread_rpc_alloc(size, 8, OPTEE_RPC_SHM_TYPE_CLIENT_APP);
}

void thread_rpc_free_client_app_payload(struct mobj *mobj)
{
thread_rpc_free(OPTEE_RPC_SHM_TYPE_CLIENT_APP, mobj_get_cookie(mobj),
mobj);
}
16 changes: 16 additions & 0 deletions core/include/optee_rpc_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@
*/
#define OPTEE_RPC_SHM_TYPE_GLOBAL 2

#define OPTEE_RPC_SHM_TYPE_CLIENT_APP 3

/*
* Free shared memory previously allocated with OPTEE_RPC_CMD_SHM_ALLOC
*
Expand Down Expand Up @@ -148,6 +150,20 @@
*/
#define OPTEE_RPC_CMD_BENCH_REG 20

/*
* Send an OCALL to the Client Application.
*
* [in] value[0].a CA Command ID (i.e., OCALL# for the CA to execute)
* [out] value[0].b OCALL return value
* [out] value[0].c OCALL return value origin
* [in] value[1].a UUID of TA whence OCALL originated (HI bits)
* [out] value[1].b UUID of TA whence OCALL originated (LO bits)
* [-] value[1].c Unused
*
* [in/out] any[2..5].* OCALL parameters as specified by the TA, if any
*/
#define OPTEE_RPC_CMD_OCALL 21

/*
* Definition of protocol for command OPTEE_RPC_CMD_FS
*/
Expand Down
Loading

0 comments on commit 9905099

Please sign in to comment.