in amdtee/call.c [72:122]
static int amd_params_to_tee_params(struct tee_param *tee, u32 count,
struct tee_operation *amd)
{
int i, ret = 0;
u32 type;
if (!count)
return 0;
if (!tee || !amd || count > TEE_MAX_PARAMS)
return -EINVAL;
/* Assumes amd->param_types is valid */
for (i = 0; i < count; i++) {
type = TEE_PARAM_TYPE_GET(amd->param_types, i);
pr_debug("%s: type[%d] = 0x%x\n", __func__, i, type);
if (type == TEE_OP_PARAM_TYPE_INVALID ||
type > TEE_OP_PARAM_TYPE_MEMREF_INOUT)
return -EINVAL;
if (type == TEE_OP_PARAM_TYPE_NONE ||
type == TEE_OP_PARAM_TYPE_VALUE_INPUT ||
type == TEE_OP_PARAM_TYPE_MEMREF_INPUT)
continue;
/*
* It is assumed that buf_id remains unchanged for
* both open_session and invoke_cmd call
*/
if (type > TEE_OP_PARAM_TYPE_MEMREF_INPUT) {
tee[i].u.memref.shm_offs = amd->params[i].mref.offset;
tee[i].u.memref.size = amd->params[i].mref.size;
pr_debug("%s: bufid[%d] = 0x%x, offset[%d] = 0x%x, size[%d] = 0x%x\n",
__func__,
i, amd->params[i].mref.buf_id,
i, amd->params[i].mref.offset,
i, amd->params[i].mref.size);
} else {
/* field 'c' not supported by AMD TEE */
tee[i].u.value.a = amd->params[i].val.a;
tee[i].u.value.b = amd->params[i].val.b;
tee[i].u.value.c = 0;
pr_debug("%s: a[%d] = 0x%x, b[%d] = 0x%x\n",
__func__,
i, amd->params[i].val.a,
i, amd->params[i].val.b);
}
}
return ret;
}