drivers/tee/qcomtee/core.c
Source file repositories/reference/linux-study-clean/drivers/tee/qcomtee/core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/tee/qcomtee/core.c- Extension
.c- Size
- 24172 bytes
- Lines
- 918
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/init.hlinux/module.hlinux/slab.hlinux/uaccess.hlinux/xarray.hqcomtee.h
Detected Declarations
function qcomtee_next_arg_typefunction qcomtee_qtee_object_allocfunction qcomtee_qtee_object_freefunction qcomtee_do_release_qtee_objectfunction qcomtee_release_qtee_objectfunction qcomtee_object_releasefunction qcomtee_object_getfunction qcomtee_object_putfunction qcomtee_idx_allocfunction qcomtee_object_id_getfunction qcomtee_object_id_putfunction qcomtee_local_object_getfunction qcomtee_object_user_initfunction qcomtee_object_typefunction qcomtee_object_qtee_initfunction qcomtee_prepare_msgfunction qcomtee_update_argsfunction qcomtee_prepare_argsfunction qcomtee_msg_for_each_input_bufferfunction qcomtee_msg_for_each_output_bufferfunction qcomtee_msg_for_each_input_objectfunction qcomtee_update_msgfunction qcomtee_cb_object_invokefunction qcomtee_object_typefunction qcomtee_object_invoke_ctx_invokefunction qcomtee_qtee_objects_putfunction qcomtee_arg_for_each_input_objectfunction qcomtee_object_do_invoke_internalfunction qcomtee_object_do_invokefunction qcomtee_object_get_client_envfunction qcomtee_object_get_service
Annotated Snippet
if (!object->ops->dispatch) {
ret = -EINVAL;
break;
}
/* If failed, "no-name". */
object->name = kvasprintf_const(GFP_KERNEL, fmt, ap);
QCOMTEE_OBJECT_SET(object, QCOMTEE_OBJECT_TYPE_CB);
ret = 0;
break;
case QCOMTEE_OBJECT_TYPE_ROOT:
case QCOMTEE_OBJECT_TYPE_TEE:
default:
ret = -EINVAL;
}
va_end(ap);
return ret;
}
/**
* qcomtee_object_type() - Returns the type of object represented by an ID.
* @object_id: object ID for the object.
*
* Similar to typeof_qcomtee_object(), but instead of receiving an object as
* an argument, it receives an object ID. It is used internally on the return
* path from QTEE.
*
* Return: Returns the type of object referenced by @object_id.
*/
static enum qcomtee_object_type qcomtee_object_type(unsigned int object_id)
{
if (object_id == QCOMTEE_MSG_OBJECT_NULL)
return QCOMTEE_OBJECT_TYPE_NULL;
if (object_id & QCOMTEE_MSG_OBJECT_NS_BIT)
return QCOMTEE_OBJECT_TYPE_CB;
return QCOMTEE_OBJECT_TYPE_TEE;
}
/**
* qcomtee_object_qtee_init() - Initialize an object for QTEE.
* @oic: context to use for the invocation.
* @object: object returned.
* @object_id: object ID received from QTEE.
*
* Return: On failure, returns < 0 and sets @object to %NULL_QCOMTEE_OBJECT.
* On success, returns 0
*/
static int qcomtee_object_qtee_init(struct qcomtee_object_invoke_ctx *oic,
struct qcomtee_object **object,
unsigned int object_id)
{
int ret = 0;
switch (qcomtee_object_type(object_id)) {
case QCOMTEE_OBJECT_TYPE_NULL:
*object = NULL_QCOMTEE_OBJECT;
break;
case QCOMTEE_OBJECT_TYPE_CB:
*object = qcomtee_local_object_get(oic, object_id);
if (*object == NULL_QCOMTEE_OBJECT)
ret = -EINVAL;
break;
default: /* QCOMTEE_OBJECT_TYPE_TEE */
*object = qcomtee_qtee_object_alloc(oic, object_id);
if (*object == NULL_QCOMTEE_OBJECT)
ret = -ENOMEM;
break;
}
return ret;
}
/*
* ''Marshaling API''
* qcomtee_prepare_msg - Prepare the inbound buffer for sending to QTEE
* qcomtee_update_args - Parse the QTEE response in the inbound buffer
* qcomtee_prepare_args - Parse the QTEE request from the outbound buffer
* qcomtee_update_msg - Update the outbound buffer with the response for QTEE
*/
static int qcomtee_prepare_msg(struct qcomtee_object_invoke_ctx *oic,
struct qcomtee_object *object, u32 op,
Annotation
- Immediate include surface: `linux/firmware/qcom/qcom_scm.h`, `linux/init.h`, `linux/module.h`, `linux/slab.h`, `linux/uaccess.h`, `linux/xarray.h`, `qcomtee.h`.
- Detected declarations: `function qcomtee_next_arg_type`, `function qcomtee_qtee_object_alloc`, `function qcomtee_qtee_object_free`, `function qcomtee_do_release_qtee_object`, `function qcomtee_release_qtee_object`, `function qcomtee_object_release`, `function qcomtee_object_get`, `function qcomtee_object_put`, `function qcomtee_idx_alloc`, `function qcomtee_object_id_get`.
- Atlas domain: Driver Families / drivers/tee.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.