diff options
author | Jens Wiklander <jens.wiklander@linaro.org> | 2018-10-24 08:30:35 +0200 |
---|---|---|
committer | Jérôme Forissier <jerome.forissier@linaro.org> | 2018-11-15 11:42:52 +0100 |
commit | 6009538c64db84891f98e0a0f31a25578706994f (patch) | |
tree | f805f8bd0561c21ed1bb949d7968bc005f020bde /core/tee | |
parent | 19c8abe1a29461f58c91996785207266c86c22c5 (diff) |
core: introduce generic optee_rpc_cmd.h
Replaces the OPTEE_MSG RPC command protocol descriptions in optee_msg.h
and optee_msg_supplicant with a generic optee_rpc_cmd.h. Defined names
are also refactored to mirror the new structure.
Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Diffstat (limited to 'core/tee')
-rw-r--r-- | core/tee/fs_htree.c | 1 | ||||
-rw-r--r-- | core/tee/tadb.c | 25 | ||||
-rw-r--r-- | core/tee/tee_fs_rpc.c | 31 | ||||
-rw-r--r-- | core/tee/tee_ree_fs.c | 26 | ||||
-rw-r--r-- | core/tee/tee_rpmb_fs.c | 4 |
5 files changed, 44 insertions, 43 deletions
diff --git a/core/tee/fs_htree.c b/core/tee/fs_htree.c index 7ea5fc3c..30f01ba8 100644 --- a/core/tee/fs_htree.c +++ b/core/tee/fs_htree.c @@ -7,7 +7,6 @@ #include <crypto/crypto.h> #include <initcall.h> #include <kernel/tee_common_otp.h> -#include <optee_msg_supplicant.h> #include <stdlib.h> #include <string_ext.h> #include <string.h> diff --git a/core/tee/tadb.c b/core/tee/tadb.c index af47de3b..97d2c558 100644 --- a/core/tee/tadb.c +++ b/core/tee/tadb.c @@ -10,7 +10,7 @@ #include <kernel/refcount.h> #include <kernel/thread.h> #include <mm/mobj.h> -#include <optee_msg_supplicant.h> +#include <optee_rpc_cmd.h> #include <stdio.h> #include <string.h> #include <tee_api_defines_extensions.h> @@ -102,7 +102,7 @@ static TEE_Result ta_operation_open(unsigned int cmd, uint32_t file_number, [2] = THREAD_PARAM_VALUE(OUT, 0, 0, 0), }; - res = thread_rpc_cmd(OPTEE_MSG_RPC_CMD_FS, ARRAY_SIZE(params), params); + res = thread_rpc_cmd(OPTEE_RPC_CMD_FS, ARRAY_SIZE(params), params); if (!res) *fd = params[2].u.value.a; @@ -121,11 +121,11 @@ static TEE_Result ta_operation_remove(uint32_t file_number) file_num_to_str(va, TEE_FS_NAME_MAX, file_number); struct thread_param params[] = { - [0] = THREAD_PARAM_VALUE(IN, OPTEE_MRF_REMOVE, 0, 0), + [0] = THREAD_PARAM_VALUE(IN, OPTEE_RPC_FS_REMOVE, 0, 0), [1] = THREAD_PARAM_MEMREF(IN, mobj, 0, TEE_FS_NAME_MAX), }; - return thread_rpc_cmd(OPTEE_MSG_RPC_CMD_FS, ARRAY_SIZE(params), params); + return thread_rpc_cmd(OPTEE_RPC_CMD_FS, ARRAY_SIZE(params), params); } static TEE_Result maybe_grow_files(struct tee_tadb_dir *db, int idx) @@ -419,7 +419,7 @@ TEE_Result tee_tadb_ta_create(const struct tee_tadb_property *property, if (res) goto err_put; - res = ta_operation_open(OPTEE_MRF_CREATE, ta->entry.file_number, + res = ta_operation_open(OPTEE_RPC_FS_CREATE, ta->entry.file_number, &ta->fd); if (res) goto err_put; @@ -454,7 +454,7 @@ TEE_Result tee_tadb_ta_write(struct tee_tadb_ta_write *ta, const void *buf, size_t wl = MIN(rl, TADB_MAX_BUFFER_SIZE); void *wb; - res = tee_fs_rpc_write_init(&op, OPTEE_MSG_RPC_CMD_FS, ta->fd, + res = tee_fs_rpc_write_init(&op, OPTEE_RPC_CMD_FS, ta->fd, ta->pos, wl, &wb); if (res) return res; @@ -480,7 +480,7 @@ void tee_tadb_ta_close_and_delete(struct tee_tadb_ta_write *ta) { crypto_authenc_final(ta->ctx, TADB_AUTH_ENC_ALG); crypto_authenc_free_ctx(ta->ctx, TADB_AUTH_ENC_ALG); - tee_fs_rpc_close(OPTEE_MSG_RPC_CMD_FS, ta->fd); + tee_fs_rpc_close(OPTEE_RPC_CMD_FS, ta->fd); ta_operation_remove(ta->entry.file_number); mutex_lock(&tadb_mutex); @@ -554,7 +554,7 @@ TEE_Result tee_tadb_ta_close_and_commit(struct tee_tadb_ta_write *ta) if (res) goto err; - tee_fs_rpc_close(OPTEE_MSG_RPC_CMD_FS, ta->fd); + tee_fs_rpc_close(OPTEE_RPC_CMD_FS, ta->fd); mutex_lock(&tadb_mutex); /* @@ -658,7 +658,8 @@ TEE_Result tee_tadb_ta_open(const TEE_UUID *uuid, goto err; } - res = ta_operation_open(OPTEE_MRF_OPEN, ta->entry.file_number, &ta->fd); + res = ta_operation_open(OPTEE_RPC_FS_OPEN, ta->entry.file_number, + &ta->fd); if (res) goto err; @@ -698,11 +699,11 @@ static TEE_Result ta_load(struct tee_tadb_ta_read *ta) assert(ta->ta_buf); struct thread_param params[] = { - [0] = THREAD_PARAM_VALUE(IN, OPTEE_MRF_READ, ta->fd, 0), + [0] = THREAD_PARAM_VALUE(IN, OPTEE_RPC_FS_READ, ta->fd, 0), [1] = THREAD_PARAM_MEMREF(OUT, ta->ta_mobj, 0, sz), }; - res = thread_rpc_cmd(OPTEE_MSG_RPC_CMD_FS, ARRAY_SIZE(params), params); + res = thread_rpc_cmd(OPTEE_RPC_CMD_FS, ARRAY_SIZE(params), params); if (res) { thread_rpc_free_payload(ta->ta_mobj); ta->ta_mobj = NULL; @@ -769,7 +770,7 @@ void tee_tadb_ta_close(struct tee_tadb_ta_read *ta) crypto_authenc_free_ctx(ta->ctx, TADB_AUTH_ENC_ALG); if (ta->ta_mobj) thread_rpc_free_payload(ta->ta_mobj); - tee_fs_rpc_close(OPTEE_MSG_RPC_CMD_FS, ta->fd); + tee_fs_rpc_close(OPTEE_RPC_CMD_FS, ta->fd); tadb_put(ta->db); free(ta); } diff --git a/core/tee/tee_fs_rpc.c b/core/tee/tee_fs_rpc.c index 6e13eabe..3af52f65 100644 --- a/core/tee/tee_fs_rpc.c +++ b/core/tee/tee_fs_rpc.c @@ -7,7 +7,7 @@ #include <kernel/tee_misc.h> #include <kernel/thread.h> #include <mm/core_memprot.h> -#include <optee_msg_supplicant.h> +#include <optee_rpc_cmd.h> #include <stdlib.h> #include <string_ext.h> #include <string.h> @@ -60,12 +60,12 @@ static TEE_Result operation_open(uint32_t id, unsigned int cmd, TEE_Result tee_fs_rpc_open(uint32_t id, struct tee_pobj *po, int *fd) { - return operation_open(id, OPTEE_MRF_OPEN, po, fd); + return operation_open(id, OPTEE_RPC_FS_OPEN, po, fd); } TEE_Result tee_fs_rpc_create(uint32_t id, struct tee_pobj *po, int *fd) { - return operation_open(id, OPTEE_MRF_CREATE, po, fd); + return operation_open(id, OPTEE_RPC_FS_CREATE, po, fd); } static TEE_Result operation_open_dfh(uint32_t id, unsigned int cmd, @@ -103,21 +103,21 @@ static TEE_Result operation_open_dfh(uint32_t id, unsigned int cmd, TEE_Result tee_fs_rpc_open_dfh(uint32_t id, const struct tee_fs_dirfile_fileh *dfh, int *fd) { - return operation_open_dfh(id, OPTEE_MRF_OPEN, dfh, fd); + return operation_open_dfh(id, OPTEE_RPC_FS_OPEN, dfh, fd); } TEE_Result tee_fs_rpc_create_dfh(uint32_t id, const struct tee_fs_dirfile_fileh *dfh, int *fd) { - return operation_open_dfh(id, OPTEE_MRF_CREATE, dfh, fd); + return operation_open_dfh(id, OPTEE_RPC_FS_CREATE, dfh, fd); } TEE_Result tee_fs_rpc_close(uint32_t id, int fd) { struct tee_fs_rpc_operation op = { .id = id, .num_params = 1, .params = { - [0] = THREAD_PARAM_VALUE(IN, OPTEE_MRF_CLOSE, fd, 0), + [0] = THREAD_PARAM_VALUE(IN, OPTEE_RPC_FS_CLOSE, fd, 0), }, }; @@ -140,7 +140,7 @@ TEE_Result tee_fs_rpc_read_init(struct tee_fs_rpc_operation *op, *op = (struct tee_fs_rpc_operation){ .id = id, .num_params = 2, .params = { - [0] = THREAD_PARAM_VALUE(IN, OPTEE_MRF_READ, fd, + [0] = THREAD_PARAM_VALUE(IN, OPTEE_RPC_FS_READ, fd, offset), [1] = THREAD_PARAM_MEMREF(OUT, mobj, 0, data_len), }, @@ -177,7 +177,7 @@ TEE_Result tee_fs_rpc_write_init(struct tee_fs_rpc_operation *op, *op = (struct tee_fs_rpc_operation){ .id = id, .num_params = 2, .params = { - [0] = THREAD_PARAM_VALUE(IN, OPTEE_MRF_WRITE, fd, + [0] = THREAD_PARAM_VALUE(IN, OPTEE_RPC_FS_WRITE, fd, offset), [1] = THREAD_PARAM_MEMREF(IN, mobj, 0, data_len), }, @@ -197,7 +197,7 @@ TEE_Result tee_fs_rpc_truncate(uint32_t id, int fd, size_t len) { struct tee_fs_rpc_operation op = { .id = id, .num_params = 1, .params = { - [0] = THREAD_PARAM_VALUE(IN, OPTEE_MRF_TRUNCATE, fd, + [0] = THREAD_PARAM_VALUE(IN, OPTEE_RPC_FS_TRUNCATE, fd, len), } }; @@ -222,7 +222,7 @@ TEE_Result tee_fs_rpc_remove(uint32_t id, struct tee_pobj *po) struct tee_fs_rpc_operation op = { .id = id, .num_params = 2, .params = { - [0] = THREAD_PARAM_VALUE(IN, OPTEE_MRF_REMOVE, 0, 0), + [0] = THREAD_PARAM_VALUE(IN, OPTEE_RPC_FS_REMOVE, 0, 0), [1] = THREAD_PARAM_MEMREF(IN, mobj, 0, TEE_FS_NAME_MAX), }, }; @@ -248,7 +248,7 @@ TEE_Result tee_fs_rpc_remove_dfh(uint32_t id, struct tee_fs_rpc_operation op = { .id = id, .num_params = 2, .params = { - [0] = THREAD_PARAM_VALUE(IN, OPTEE_MRF_REMOVE, 0, 0), + [0] = THREAD_PARAM_VALUE(IN, OPTEE_RPC_FS_REMOVE, 0, 0), [1] = THREAD_PARAM_MEMREF(IN, mobj, 0, TEE_FS_NAME_MAX), } }; @@ -292,7 +292,7 @@ TEE_Result tee_fs_rpc_rename(uint32_t id, struct tee_pobj *old, struct tee_fs_rpc_operation op = { .id = id, .num_params = 3, .params = { - [0] = THREAD_PARAM_VALUE(IN, OPTEE_MRF_RENAME, + [0] = THREAD_PARAM_VALUE(IN, OPTEE_RPC_FS_RENAME, overwrite, 0), [1] = THREAD_PARAM_MEMREF(IN, mobj, 0, TEE_FS_NAME_MAX), [2] = THREAD_PARAM_MEMREF(IN, mobj, TEE_FS_NAME_MAX, @@ -327,7 +327,8 @@ TEE_Result tee_fs_rpc_opendir(uint32_t id, const TEE_UUID *uuid, struct tee_fs_rpc_operation op = { .id = id, .num_params = 3, .params = { - [0] = THREAD_PARAM_VALUE(IN, OPTEE_MRF_OPENDIR, 0, 0), + [0] = THREAD_PARAM_VALUE(IN, OPTEE_RPC_FS_OPENDIR, + 0, 0), [1] = THREAD_PARAM_MEMREF(IN, mobj, 0, TEE_FS_NAME_MAX), [2] = THREAD_PARAM_VALUE(OUT, 0, 0, 0), } @@ -352,7 +353,7 @@ TEE_Result tee_fs_rpc_closedir(uint32_t id, struct tee_fs_dir *d) { struct tee_fs_rpc_operation op = { .id = id, .num_params = 1, .params = { - [0] = THREAD_PARAM_VALUE(IN, OPTEE_MRF_CLOSEDIR, + [0] = THREAD_PARAM_VALUE(IN, OPTEE_RPC_FS_CLOSEDIR, d->nw_dir, 0), } }; @@ -378,7 +379,7 @@ TEE_Result tee_fs_rpc_readdir(uint32_t id, struct tee_fs_dir *d, struct tee_fs_rpc_operation op = { .id = id, .num_params = 2, .params = { - [0] = THREAD_PARAM_VALUE(IN, OPTEE_MRF_READDIR, + [0] = THREAD_PARAM_VALUE(IN, OPTEE_RPC_FS_READDIR, d->nw_dir, 0), [1] = THREAD_PARAM_MEMREF(IN, mobj, 0, max_name_len), } diff --git a/core/tee/tee_ree_fs.c b/core/tee/tee_ree_fs.c index 0ad686c3..e55234d1 100644 --- a/core/tee/tee_ree_fs.c +++ b/core/tee/tee_ree_fs.c @@ -9,7 +9,7 @@ #include <kernel/thread.h> #include <mm/core_memprot.h> #include <mm/tee_pager.h> -#include <optee_msg_supplicant.h> +#include <optee_rpc_cmd.h> #include <stdio.h> #include <stdlib.h> #include <string_ext.h> @@ -242,7 +242,7 @@ static TEE_Result ree_fs_rpc_read_init(void *aux, if (res != TEE_SUCCESS) return res; - return tee_fs_rpc_read_init(op, OPTEE_MSG_RPC_CMD_FS, fdp->fd, + return tee_fs_rpc_read_init(op, OPTEE_RPC_CMD_FS, fdp->fd, offs, size, data); } @@ -260,7 +260,7 @@ static TEE_Result ree_fs_rpc_write_init(void *aux, if (res != TEE_SUCCESS) return res; - return tee_fs_rpc_write_init(op, OPTEE_MSG_RPC_CMD_FS, fdp->fd, + return tee_fs_rpc_write_init(op, OPTEE_RPC_CMD_FS, fdp->fd, offs, size, data); } @@ -299,7 +299,7 @@ static TEE_Result ree_fs_ftruncate_internal(struct tee_fs_fd *fdp, if (res != TEE_SUCCESS) return res; - res = tee_fs_rpc_truncate(OPTEE_MSG_RPC_CMD_FS, fdp->fd, + res = tee_fs_rpc_truncate(OPTEE_RPC_CMD_FS, fdp->fd, offs + sz); if (res != TEE_SUCCESS) return res; @@ -422,10 +422,10 @@ static TEE_Result ree_fs_open_primitive(bool create, uint8_t *hash, fdp->uuid = uuid; if (create) - res = tee_fs_rpc_create_dfh(OPTEE_MSG_RPC_CMD_FS, + res = tee_fs_rpc_create_dfh(OPTEE_RPC_CMD_FS, dfh, &fdp->fd); else - res = tee_fs_rpc_open_dfh(OPTEE_MSG_RPC_CMD_FS, dfh, &fdp->fd); + res = tee_fs_rpc_open_dfh(OPTEE_RPC_CMD_FS, dfh, &fdp->fd); if (res != TEE_SUCCESS) goto out; @@ -441,9 +441,9 @@ out: *fh = (struct tee_file_handle *)fdp; } else { if (fdp->fd != -1) - tee_fs_rpc_close(OPTEE_MSG_RPC_CMD_FS, fdp->fd); + tee_fs_rpc_close(OPTEE_RPC_CMD_FS, fdp->fd); if (create) - tee_fs_rpc_remove_dfh(OPTEE_MSG_RPC_CMD_FS, dfh); + tee_fs_rpc_remove_dfh(OPTEE_RPC_CMD_FS, dfh); free(fdp); } @@ -456,7 +456,7 @@ static void ree_fs_close_primitive(struct tee_file_handle *fh) if (fdp) { tee_fs_htree_close(&fdp->ht); - tee_fs_rpc_close(OPTEE_MSG_RPC_CMD_FS, fdp->fd); + tee_fs_rpc_close(OPTEE_RPC_CMD_FS, fdp->fd); free(fdp); } } @@ -675,7 +675,7 @@ static TEE_Result set_name(struct tee_fs_dirfile_dirh *dirh, return res; if (have_old_dfh) - tee_fs_rpc_remove_dfh(OPTEE_MSG_RPC_CMD_FS, &old_dfh); + tee_fs_rpc_remove_dfh(OPTEE_RPC_CMD_FS, &old_dfh); return TEE_SUCCESS; } @@ -751,7 +751,7 @@ out: if (*fh) { ree_fs_close_primitive(*fh); *fh = NULL; - tee_fs_rpc_remove_dfh(OPTEE_MSG_RPC_CMD_FS, &dfh); + tee_fs_rpc_remove_dfh(OPTEE_RPC_CMD_FS, &dfh); } } mutex_unlock(&ree_fs_mutex); @@ -835,7 +835,7 @@ static TEE_Result ree_fs_rename(struct tee_pobj *old, struct tee_pobj *new, goto out; if (remove_dfh.idx != -1) - tee_fs_rpc_remove_dfh(OPTEE_MSG_RPC_CMD_FS, &remove_dfh); + tee_fs_rpc_remove_dfh(OPTEE_RPC_CMD_FS, &remove_dfh); out: put_dirh(dirh, res); @@ -869,7 +869,7 @@ static TEE_Result ree_fs_remove(struct tee_pobj *po) if (res) goto out; - tee_fs_rpc_remove_dfh(OPTEE_MSG_RPC_CMD_FS, &dfh); + tee_fs_rpc_remove_dfh(OPTEE_RPC_CMD_FS, &dfh); assert(tee_fs_dirfile_find(dirh, &po->uuid, po->obj_id, po->obj_id_len, &dfh)); diff --git a/core/tee/tee_rpmb_fs.c b/core/tee/tee_rpmb_fs.c index 43a25b4d..d9577c47 100644 --- a/core/tee/tee_rpmb_fs.c +++ b/core/tee/tee_rpmb_fs.c @@ -16,7 +16,7 @@ #include <mm/core_memprot.h> #include <mm/mobj.h> #include <mm/tee_mm.h> -#include <optee_msg_supplicant.h> +#include <optee_rpc_cmd.h> #include <stdlib.h> #include <string_ext.h> #include <string.h> @@ -476,7 +476,7 @@ static TEE_Result tee_rpmb_invoke(struct tee_rpmb_mem *mem) mem->resp_size), }; - return thread_rpc_cmd(OPTEE_MSG_RPC_CMD_RPMB, 2, params); + return thread_rpc_cmd(OPTEE_RPC_CMD_RPMB, 2, params); } static bool is_zero(const uint8_t *buf, size_t size) |