Lines Matching refs:arg

246 static inline bool check_param_input(struct optee_msg_arg *arg)  in check_param_input()  argument
248 return arg->num_params == 1 && in check_param_input()
249 arg->params[0].attr == OPTEE_MSG_ATTR_TYPE_VALUE_INPUT; in check_param_input()
328 static void handle_cmd_alloc(const struct device *dev, struct optee_msg_arg *arg, in handle_cmd_alloc() argument
336 arg->ret_origin = TEEC_ORIGIN_COMMS; in handle_cmd_alloc()
338 if (!check_param_input(arg)) { in handle_cmd_alloc()
339 arg->ret = TEEC_ERROR_BAD_PARAMETERS; in handle_cmd_alloc()
343 switch (arg->params[0].u.value.a) { in handle_cmd_alloc()
346 rc = tee_add_shm(dev, NULL, 0, arg->params[0].u.value.b, TEE_SHM_ALLOC, &shm); in handle_cmd_alloc()
349 rc = cmd_alloc_suppl(dev, arg->params[0].u.value.b, &shm); in handle_cmd_alloc()
352 arg->ret = TEEC_ERROR_BAD_PARAMETERS; in handle_cmd_alloc()
358 arg->ret = TEEC_ERROR_OUT_OF_MEMORY; in handle_cmd_alloc()
360 arg->ret = TEEC_ERROR_GENERIC; in handle_cmd_alloc()
367 arg->ret = TEEC_ERROR_OUT_OF_MEMORY; in handle_cmd_alloc()
372 arg->params[0].attr = OPTEE_MSG_ATTR_TYPE_TMEM_OUTPUT | OPTEE_MSG_ATTR_NONCONTIG; in handle_cmd_alloc()
373 arg->params[0].u.tmem.buf_ptr = pl_phys_and_offset; in handle_cmd_alloc()
374 arg->params[0].u.tmem.size = shm->size; in handle_cmd_alloc()
375 arg->params[0].u.tmem.shm_ref = (uint64_t)shm; in handle_cmd_alloc()
376 arg->ret = TEEC_SUCCESS; in handle_cmd_alloc()
382 static void handle_cmd_free(const struct device *dev, struct optee_msg_arg *arg) in handle_cmd_free() argument
386 if (!check_param_input(arg)) { in handle_cmd_free()
387 arg->ret = TEEC_ERROR_BAD_PARAMETERS; in handle_cmd_free()
391 switch (arg->params[0].u.value.a) { in handle_cmd_free()
393 rc = tee_rm_shm(dev, (struct tee_shm *)arg->params[0].u.value.b); in handle_cmd_free()
396 cmd_free_suppl(dev, (struct tee_shm *)arg->params[0].u.value.b); in handle_cmd_free()
399 arg->ret = TEEC_ERROR_BAD_PARAMETERS; in handle_cmd_free()
404 arg->ret = TEEC_ERROR_OUT_OF_MEMORY; in handle_cmd_free()
408 arg->ret = TEEC_SUCCESS; in handle_cmd_free()
411 static void handle_cmd_get_time(const struct device *dev, struct optee_msg_arg *arg) in handle_cmd_get_time() argument
417 if (arg->num_params != 1 || in handle_cmd_get_time()
418 (arg->params[0].attr & OPTEE_MSG_ATTR_TYPE_MASK) in handle_cmd_get_time()
420 arg->ret = TEEC_ERROR_BAD_PARAMETERS; in handle_cmd_get_time()
428 arg->params[0].u.value.a = up_secs; in handle_cmd_get_time()
429 arg->params[0].u.value.b = up_nsecs; in handle_cmd_get_time()
431 arg->ret = TEEC_SUCCESS; in handle_cmd_get_time()
522 static void handle_cmd_notify(const struct device *dev, struct optee_msg_arg *arg) in handle_cmd_notify() argument
524 if (!check_param_input(arg)) { in handle_cmd_notify()
525 arg->ret = TEEC_ERROR_BAD_PARAMETERS; in handle_cmd_notify()
529 switch (arg->params[0].u.value.a) { in handle_cmd_notify()
531 if (optee_notif_send(dev, arg->params[0].u.value.b)) { in handle_cmd_notify()
536 if (optee_notif_wait(dev, arg->params[0].u.value.b)) { in handle_cmd_notify()
544 arg->ret = TEEC_SUCCESS; in handle_cmd_notify()
548 arg->ret = TEEC_ERROR_BAD_PARAMETERS; in handle_cmd_notify()
551 static void handle_cmd_wait(const struct device *dev, struct optee_msg_arg *arg) in handle_cmd_wait() argument
553 if (!check_param_input(arg)) { in handle_cmd_wait()
554 arg->ret = TEEC_ERROR_BAD_PARAMETERS; in handle_cmd_wait()
558 k_sleep(K_MSEC(arg->params[0].u.value.a)); in handle_cmd_wait()
560 arg->ret = TEEC_SUCCESS; in handle_cmd_wait()
577 static void handle_rpc_supp_cmd(const struct device *dev, struct optee_msg_arg *arg) in handle_rpc_supp_cmd() argument
582 arg->ret_origin = TEEC_ORIGIN_COMMS; in handle_rpc_supp_cmd()
584 params = k_malloc(sizeof(*params) * arg->num_params); in handle_rpc_supp_cmd()
586 arg->ret = TEEC_ERROR_OUT_OF_MEMORY; in handle_rpc_supp_cmd()
590 ret = msg_param_to_param(params, arg->num_params, arg->params); in handle_rpc_supp_cmd()
592 arg->ret = TEEC_ERROR_BAD_PARAMETERS; in handle_rpc_supp_cmd()
593 arg->ret_origin = TEEC_ORIGIN_COMMS; in handle_rpc_supp_cmd()
597 arg->ret = optee_call_supp(dev, arg->cmd, arg->num_params, params); in handle_rpc_supp_cmd()
599 ret = param_to_msg_param(params, arg->num_params, arg->params); in handle_rpc_supp_cmd()
601 arg->ret = TEEC_ERROR_GENERIC; in handle_rpc_supp_cmd()
602 arg->ret_origin = TEEC_ORIGIN_COMMS; in handle_rpc_supp_cmd()
611 struct optee_msg_arg *arg = shm->addr; in handle_func_rpc_call() local
613 switch (arg->cmd) { in handle_func_rpc_call()
616 handle_cmd_alloc(dev, arg, pages); in handle_func_rpc_call()
619 handle_cmd_free(dev, arg); in handle_func_rpc_call()
622 handle_cmd_get_time(dev, arg); in handle_func_rpc_call()
625 handle_cmd_notify(dev, arg); in handle_func_rpc_call()
628 handle_cmd_wait(dev, arg); in handle_func_rpc_call()
634 handle_rpc_supp_cmd(dev, arg); in handle_func_rpc_call()
679 static int optee_call(const struct device *dev, struct optee_msg_arg *arg) in optee_call() argument
687 u64_to_regs((uint64_t)k_mem_phys_addr(arg), &param.a1, &param.a2); in optee_call()
757 static int optee_open_session(const struct device *dev, struct tee_open_session_arg *arg, in optee_open_session() argument
765 if (!arg || !session_id) { in optee_open_session()
785 memcpy(&marg->params[0].u.value, arg->uuid, sizeof(arg->uuid)); in optee_open_session()
786 memcpy(&marg->params[1].u.value, arg->uuid, sizeof(arg->clnt_uuid)); in optee_open_session()
788 marg->params[1].u.value.c = arg->clnt_login; in optee_open_session()
795 arg->ret = optee_call(dev, marg); in optee_open_session()
796 if (arg->ret) { in optee_open_session()
797 arg->ret_origin = TEEC_ORIGIN_COMMS; in optee_open_session()
803 arg->ret = TEEC_ERROR_COMMUNICATION; in optee_open_session()
804 arg->ret_origin = TEEC_ORIGIN_COMMS; in optee_open_session()
818 arg->ret = marg->ret; in optee_open_session()
819 arg->ret_origin = marg->ret_origin; in optee_open_session()
858 static int optee_invoke_func(const struct device *dev, struct tee_invoke_func_arg *arg, in optee_invoke_func() argument
865 if (!arg) { in optee_invoke_func()
882 marg->func = arg->func; in optee_invoke_func()
883 marg->session = arg->session; in optee_invoke_func()
890 arg->ret = optee_call(dev, marg); in optee_invoke_func()
891 if (arg->ret) { in optee_invoke_func()
892 arg->ret_origin = TEEC_ORIGIN_COMMS; in optee_invoke_func()
898 arg->ret = TEEC_ERROR_COMMUNICATION; in optee_invoke_func()
899 arg->ret_origin = TEEC_ORIGIN_COMMS; in optee_invoke_func()
903 arg->ret = marg->ret; in optee_invoke_func()
904 arg->ret_origin = marg->ret_origin; in optee_invoke_func()