Lines Matching +full:op +full:- +full:tee

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2015-2021, Linaro Limited
20 if (arg->num_params != 1) in handle_rpc_func_cmd_get_time()
22 if ((arg->params[0].attr & OPTEE_MSG_ATTR_TYPE_MASK) != in handle_rpc_func_cmd_get_time()
27 arg->params[0].u.value.a = ts.tv_sec; in handle_rpc_func_cmd_get_time()
28 arg->params[0].u.value.b = ts.tv_nsec; in handle_rpc_func_cmd_get_time()
30 arg->ret = TEEC_SUCCESS; in handle_rpc_func_cmd_get_time()
33 arg->ret = TEEC_ERROR_BAD_PARAMETERS; in handle_rpc_func_cmd_get_time()
40 struct optee *optee = tee_get_drvdata(ctx->teedev); in handle_rpc_func_cmd_i2c_transfer()
45 int ret = -EOPNOTSUPP; in handle_rpc_func_cmd_i2c_transfer()
53 if (arg->num_params != ARRAY_SIZE(attr)) { in handle_rpc_func_cmd_i2c_transfer()
54 arg->ret = TEEC_ERROR_BAD_PARAMETERS; in handle_rpc_func_cmd_i2c_transfer()
58 params = kmalloc_array(arg->num_params, sizeof(struct tee_param), in handle_rpc_func_cmd_i2c_transfer()
61 arg->ret = TEEC_ERROR_OUT_OF_MEMORY; in handle_rpc_func_cmd_i2c_transfer()
65 if (optee->ops->from_msg_param(optee, params, arg->num_params, in handle_rpc_func_cmd_i2c_transfer()
66 arg->params)) in handle_rpc_func_cmd_i2c_transfer()
69 for (i = 0; i < arg->num_params; i++) { in handle_rpc_func_cmd_i2c_transfer()
89 msg.buf = params[2].u.memref.shm->kaddr; in handle_rpc_func_cmd_i2c_transfer()
106 arg->ret = TEEC_ERROR_COMMUNICATION; in handle_rpc_func_cmd_i2c_transfer()
109 if (optee->ops->to_msg_param(optee, arg->params, in handle_rpc_func_cmd_i2c_transfer()
110 arg->num_params, params)) in handle_rpc_func_cmd_i2c_transfer()
111 arg->ret = TEEC_ERROR_BAD_PARAMETERS; in handle_rpc_func_cmd_i2c_transfer()
113 arg->ret = TEEC_SUCCESS; in handle_rpc_func_cmd_i2c_transfer()
121 arg->ret = TEEC_ERROR_BAD_PARAMETERS; in handle_rpc_func_cmd_i2c_transfer()
127 arg->ret = TEEC_ERROR_NOT_SUPPORTED; in handle_rpc_func_cmd_i2c_transfer()
136 if (arg->num_params != 1) in handle_rpc_func_cmd_wq()
139 if ((arg->params[0].attr & OPTEE_MSG_ATTR_TYPE_MASK) != in handle_rpc_func_cmd_wq()
143 switch (arg->params[0].u.value.a) { in handle_rpc_func_cmd_wq()
145 rc = optee_notif_wait(optee, arg->params[0].u.value.b, arg->params[0].u.value.c); in handle_rpc_func_cmd_wq()
150 if (optee_notif_send(optee, arg->params[0].u.value.b)) in handle_rpc_func_cmd_wq()
157 arg->ret = TEEC_SUCCESS; in handle_rpc_func_cmd_wq()
160 if (rc == -ETIMEDOUT) in handle_rpc_func_cmd_wq()
161 arg->ret = TEE_ERROR_TIMEOUT; in handle_rpc_func_cmd_wq()
163 arg->ret = TEEC_ERROR_BAD_PARAMETERS; in handle_rpc_func_cmd_wq()
170 if (arg->num_params != 1) in handle_rpc_func_cmd_wait()
173 if ((arg->params[0].attr & OPTEE_MSG_ATTR_TYPE_MASK) != in handle_rpc_func_cmd_wait()
177 msec_to_wait = arg->params[0].u.value.a; in handle_rpc_func_cmd_wait()
182 arg->ret = TEEC_SUCCESS; in handle_rpc_func_cmd_wait()
185 arg->ret = TEEC_ERROR_BAD_PARAMETERS; in handle_rpc_func_cmd_wait()
193 arg->ret_origin = TEEC_ORIGIN_COMMS; in handle_rpc_supp_cmd()
195 params = kmalloc_array(arg->num_params, sizeof(struct tee_param), in handle_rpc_supp_cmd()
198 arg->ret = TEEC_ERROR_OUT_OF_MEMORY; in handle_rpc_supp_cmd()
202 if (optee->ops->from_msg_param(optee, params, arg->num_params, in handle_rpc_supp_cmd()
203 arg->params)) { in handle_rpc_supp_cmd()
204 arg->ret = TEEC_ERROR_BAD_PARAMETERS; in handle_rpc_supp_cmd()
208 arg->ret = optee_supp_thrd_req(ctx, arg->cmd, arg->num_params, params); in handle_rpc_supp_cmd()
210 if (optee->ops->to_msg_param(optee, arg->params, arg->num_params, in handle_rpc_supp_cmd()
212 arg->ret = TEEC_ERROR_BAD_PARAMETERS; in handle_rpc_supp_cmd()
221 struct optee *optee = tee_get_drvdata(ctx->teedev); in optee_rpc_cmd_alloc_suppl()
231 return ERR_PTR(-ENOMEM); in optee_rpc_cmd_alloc_suppl()
233 mutex_lock(&optee->supp.mutex); in optee_rpc_cmd_alloc_suppl()
235 shm = tee_shm_get_from_id(optee->supp.ctx, param.u.value.c); in optee_rpc_cmd_alloc_suppl()
236 mutex_unlock(&optee->supp.mutex); in optee_rpc_cmd_alloc_suppl()
271 if (arg->num_params != ARRAY_SIZE(params) || in handle_rpc_func_rpmb_probe_reset()
272 optee->ops->from_msg_param(optee, params, arg->num_params, in handle_rpc_func_rpmb_probe_reset()
273 arg->params) || in handle_rpc_func_rpmb_probe_reset()
275 arg->ret = TEEC_ERROR_BAD_PARAMETERS; in handle_rpc_func_rpmb_probe_reset()
282 if (optee->ops->to_msg_param(optee, arg->params, in handle_rpc_func_rpmb_probe_reset()
283 arg->num_params, params)) { in handle_rpc_func_rpmb_probe_reset()
284 arg->ret = TEEC_ERROR_BAD_PARAMETERS; in handle_rpc_func_rpmb_probe_reset()
288 mutex_lock(&optee->rpmb_dev_mutex); in handle_rpc_func_rpmb_probe_reset()
289 rpmb_dev_put(optee->rpmb_dev); in handle_rpc_func_rpmb_probe_reset()
290 optee->rpmb_dev = NULL; in handle_rpc_func_rpmb_probe_reset()
291 mutex_unlock(&optee->rpmb_dev_mutex); in handle_rpc_func_rpmb_probe_reset()
293 arg->ret = TEEC_SUCCESS; in handle_rpc_func_rpmb_probe_reset()
306 return -1; in rpmb_type_to_rpc_type()
314 return rpmb_type_to_rpc_type(rdev->descr.type) >= 0; in rpc_rpmb_match()
325 if (arg->num_params != ARRAY_SIZE(params) || in handle_rpc_func_rpmb_probe_next()
326 optee->ops->from_msg_param(optee, params, arg->num_params, in handle_rpc_func_rpmb_probe_next()
327 arg->params) || in handle_rpc_func_rpmb_probe_next()
330 arg->ret = TEEC_ERROR_BAD_PARAMETERS; in handle_rpc_func_rpmb_probe_next()
336 arg->ret = TEEC_ERROR_BAD_PARAMETERS; in handle_rpc_func_rpmb_probe_next()
340 mutex_lock(&optee->rpmb_dev_mutex); in handle_rpc_func_rpmb_probe_next()
341 rdev = rpmb_dev_find_device(NULL, optee->rpmb_dev, rpc_rpmb_match); in handle_rpc_func_rpmb_probe_next()
342 rpmb_dev_put(optee->rpmb_dev); in handle_rpc_func_rpmb_probe_next()
343 optee->rpmb_dev = rdev; in handle_rpc_func_rpmb_probe_next()
344 mutex_unlock(&optee->rpmb_dev_mutex); in handle_rpc_func_rpmb_probe_next()
347 arg->ret = TEEC_ERROR_ITEM_NOT_FOUND; in handle_rpc_func_rpmb_probe_next()
351 if (params[1].u.memref.size < rdev->descr.dev_id_len) { in handle_rpc_func_rpmb_probe_next()
352 arg->ret = TEEC_ERROR_SHORT_BUFFER; in handle_rpc_func_rpmb_probe_next()
355 memcpy(buf, rdev->descr.dev_id, rdev->descr.dev_id_len); in handle_rpc_func_rpmb_probe_next()
356 params[1].u.memref.size = rdev->descr.dev_id_len; in handle_rpc_func_rpmb_probe_next()
357 params[0].u.value.a = rpmb_type_to_rpc_type(rdev->descr.type); in handle_rpc_func_rpmb_probe_next()
358 params[0].u.value.b = rdev->descr.capacity; in handle_rpc_func_rpmb_probe_next()
359 params[0].u.value.c = rdev->descr.reliable_wr_count; in handle_rpc_func_rpmb_probe_next()
360 if (optee->ops->to_msg_param(optee, arg->params, in handle_rpc_func_rpmb_probe_next()
361 arg->num_params, params)) { in handle_rpc_func_rpmb_probe_next()
362 arg->ret = TEEC_ERROR_BAD_PARAMETERS; in handle_rpc_func_rpmb_probe_next()
366 arg->ret = TEEC_SUCCESS; in handle_rpc_func_rpmb_probe_next()
377 mutex_lock(&optee->rpmb_dev_mutex); in handle_rpc_func_rpmb_frames()
378 rdev = rpmb_dev_get(optee->rpmb_dev); in handle_rpc_func_rpmb_frames()
379 mutex_unlock(&optee->rpmb_dev_mutex); in handle_rpc_func_rpmb_frames()
381 arg->ret = TEEC_ERROR_ITEM_NOT_FOUND; in handle_rpc_func_rpmb_frames()
385 if (arg->num_params != ARRAY_SIZE(params) || in handle_rpc_func_rpmb_frames()
386 optee->ops->from_msg_param(optee, params, arg->num_params, in handle_rpc_func_rpmb_frames()
387 arg->params) || in handle_rpc_func_rpmb_frames()
390 arg->ret = TEEC_ERROR_BAD_PARAMETERS; in handle_rpc_func_rpmb_frames()
400 arg->ret = TEEC_ERROR_BAD_PARAMETERS; in handle_rpc_func_rpmb_frames()
403 if (optee->ops->to_msg_param(optee, arg->params, in handle_rpc_func_rpmb_frames()
404 arg->num_params, params)) { in handle_rpc_func_rpmb_frames()
405 arg->ret = TEEC_ERROR_BAD_PARAMETERS; in handle_rpc_func_rpmb_frames()
408 arg->ret = TEEC_SUCCESS; in handle_rpc_func_rpmb_frames()
416 switch (arg->cmd) { in optee_rpc_cmd()
430 * optee->in_kernel_rpmb_routing true means that OP-TEE supports in optee_rpc_cmd()
431 * in-kernel RPMB routing _and_ that the RPMB subsystem is in optee_rpc_cmd()
440 if (optee->in_kernel_rpmb_routing) in optee_rpc_cmd()
446 if (optee->in_kernel_rpmb_routing) in optee_rpc_cmd()
452 if (optee->in_kernel_rpmb_routing) in optee_rpc_cmd()