drivers/tee/optee/rpc.c
Source file repositories/reference/linux-study-clean/drivers/tee/optee/rpc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/tee/optee/rpc.c- Extension
.c- Size
- 11548 bytes
- Lines
- 461
- Domain
- Driver Families
- Bucket
- drivers/tee
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/i2c.hlinux/rpmb.hlinux/slab.hlinux/tee_core.hoptee_private.hoptee_rpc_cmd.h
Detected Declarations
function Copyrightfunction handle_rpc_func_cmd_i2c_transferfunction handle_rpc_func_cmd_i2c_transferfunction handle_rpc_func_cmd_wqfunction handle_rpc_func_cmd_waitfunction handle_rpc_supp_cmdfunction optee_rpc_cmd_free_supplfunction handle_rpc_func_rpmb_probe_resetfunction rpmb_type_to_rpc_typefunction rpc_rpmb_matchfunction handle_rpc_func_rpmb_probe_nextfunction handle_rpc_func_rpmb_framesfunction optee_rpc_cmd
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2015-2021, Linaro Limited
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/rpmb.h>
#include <linux/slab.h>
#include <linux/tee_core.h>
#include "optee_private.h"
#include "optee_rpc_cmd.h"
static void handle_rpc_func_cmd_get_time(struct optee_msg_arg *arg)
{
struct timespec64 ts;
if (arg->num_params != 1)
goto bad;
if ((arg->params[0].attr & OPTEE_MSG_ATTR_TYPE_MASK) !=
OPTEE_MSG_ATTR_TYPE_VALUE_OUTPUT)
goto bad;
ktime_get_real_ts64(&ts);
arg->params[0].u.value.a = ts.tv_sec;
arg->params[0].u.value.b = ts.tv_nsec;
arg->ret = TEEC_SUCCESS;
return;
bad:
arg->ret = TEEC_ERROR_BAD_PARAMETERS;
}
#if IS_REACHABLE(CONFIG_I2C)
static void handle_rpc_func_cmd_i2c_transfer(struct tee_context *ctx,
struct optee_msg_arg *arg)
{
struct optee *optee = tee_get_drvdata(ctx->teedev);
struct tee_param *params;
struct i2c_adapter *adapter;
struct i2c_msg msg = { };
size_t i;
int ret = -EOPNOTSUPP;
static const u8 attr[] = {
TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT,
TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT,
TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT,
TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_OUTPUT,
};
if (arg->num_params != ARRAY_SIZE(attr)) {
arg->ret = TEEC_ERROR_BAD_PARAMETERS;
return;
}
params = kmalloc_objs(struct tee_param, arg->num_params);
if (!params) {
arg->ret = TEEC_ERROR_OUT_OF_MEMORY;
return;
}
if (optee->ops->from_msg_param(optee, params, arg->num_params,
arg->params))
goto bad;
for (i = 0; i < arg->num_params; i++) {
if (params[i].attr != attr[i])
goto bad;
}
adapter = i2c_get_adapter(params[0].u.value.b);
if (!adapter)
goto bad;
if (params[1].u.value.a & OPTEE_RPC_I2C_FLAGS_TEN_BIT) {
if (!i2c_check_functionality(adapter,
I2C_FUNC_10BIT_ADDR)) {
i2c_put_adapter(adapter);
goto bad;
}
msg.flags = I2C_M_TEN;
}
msg.addr = params[0].u.value.c;
msg.buf = params[2].u.memref.shm->kaddr;
msg.len = params[2].u.memref.size;
Annotation
- Immediate include surface: `linux/delay.h`, `linux/i2c.h`, `linux/rpmb.h`, `linux/slab.h`, `linux/tee_core.h`, `optee_private.h`, `optee_rpc_cmd.h`.
- Detected declarations: `function Copyright`, `function handle_rpc_func_cmd_i2c_transfer`, `function handle_rpc_func_cmd_i2c_transfer`, `function handle_rpc_func_cmd_wq`, `function handle_rpc_func_cmd_wait`, `function handle_rpc_supp_cmd`, `function optee_rpc_cmd_free_suppl`, `function handle_rpc_func_rpmb_probe_reset`, `function rpmb_type_to_rpc_type`, `function rpc_rpmb_match`.
- Atlas domain: Driver Families / drivers/tee.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.