drivers/tee/qcomtee/mem_obj.c
Source file repositories/reference/linux-study-clean/drivers/tee/qcomtee/mem_obj.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/tee/qcomtee/mem_obj.c- Extension
.c- Size
- 4978 bytes
- Lines
- 169
- 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.
- 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/firmware/qcom/qcom_scm.hlinux/mm.hqcomtee.h
Detected Declarations
struct qcomtee_mem_objectfunction is_qcomtee_memobj_objectfunction qcomtee_mem_object_dispatchfunction qcomtee_mem_object_releasefunction qcomtee_memobj_param_to_objectfunction qcomtee_memobj_param_from_objectfunction qcomtee_mem_object_map
Annotated Snippet
struct qcomtee_mem_object {
struct qcomtee_object object;
struct tee_shm *shm;
/* QTEE requires these felids to be page aligned. */
phys_addr_t paddr; /* Physical address of range. */
size_t size; /* Size of the range. */
};
#define to_qcomtee_mem_object(o) \
container_of((o), struct qcomtee_mem_object, object)
static struct qcomtee_object_operations qcomtee_mem_object_ops;
/* Is it a memory object using tee_shm? */
int is_qcomtee_memobj_object(struct qcomtee_object *object)
{
return object != NULL_QCOMTEE_OBJECT &&
typeof_qcomtee_object(object) == QCOMTEE_OBJECT_TYPE_CB &&
object->ops == &qcomtee_mem_object_ops;
}
static int qcomtee_mem_object_dispatch(struct qcomtee_object_invoke_ctx *oic,
struct qcomtee_object *object, u32 op,
struct qcomtee_arg *args)
{
return -EINVAL;
}
static void qcomtee_mem_object_release(struct qcomtee_object *object)
{
struct qcomtee_mem_object *mem_object = to_qcomtee_mem_object(object);
/* Matching get is in qcomtee_memobj_param_to_object(). */
tee_shm_put(mem_object->shm);
kfree(mem_object);
}
static struct qcomtee_object_operations qcomtee_mem_object_ops = {
.release = qcomtee_mem_object_release,
.dispatch = qcomtee_mem_object_dispatch,
};
/**
* qcomtee_memobj_param_to_object() - OBJREF parameter to &struct qcomtee_object.
* @object: object returned.
* @param: TEE parameter.
* @ctx: context in which the conversion should happen.
*
* @param is an OBJREF with %QCOMTEE_OBJREF_FLAG_MEM flags.
*
* Return: On success return 0 or <0 on failure.
*/
int qcomtee_memobj_param_to_object(struct qcomtee_object **object,
struct tee_param *param,
struct tee_context *ctx)
{
struct tee_shm *shm;
int err;
struct qcomtee_mem_object *mem_object __free(kfree) = kzalloc_obj(*mem_object);
if (!mem_object)
return -ENOMEM;
shm = tee_shm_get_from_id(ctx, param->u.objref.id);
if (IS_ERR(shm))
return PTR_ERR(shm);
/* mem-object wrapping the memref. */
err = qcomtee_object_user_init(&mem_object->object,
QCOMTEE_OBJECT_TYPE_CB,
&qcomtee_mem_object_ops, "tee-shm-%d",
shm->id);
if (err) {
tee_shm_put(shm);
return err;
}
mem_object->paddr = shm->paddr;
mem_object->size = shm->size;
mem_object->shm = shm;
*object = &no_free_ptr(mem_object)->object;
return 0;
}
/* Reverse what qcomtee_memobj_param_to_object() does. */
int qcomtee_memobj_param_from_object(struct tee_param *param,
struct qcomtee_object *object,
Annotation
- Immediate include surface: `linux/firmware/qcom/qcom_scm.h`, `linux/mm.h`, `qcomtee.h`.
- Detected declarations: `struct qcomtee_mem_object`, `function is_qcomtee_memobj_object`, `function qcomtee_mem_object_dispatch`, `function qcomtee_mem_object_release`, `function qcomtee_memobj_param_to_object`, `function qcomtee_memobj_param_from_object`, `function qcomtee_mem_object_map`.
- Atlas domain: Driver Families / drivers/tee.
- Implementation status: source implementation candidate.
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.