drivers/tee/qcomtee/qcomtee_msg.h

Source file repositories/reference/linux-study-clean/drivers/tee/qcomtee/qcomtee_msg.h

File Facts

System
Linux kernel
Corpus path
drivers/tee/qcomtee/qcomtee_msg.h
Extension
.h
Size
10539 bytes
Lines
305
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct qcomtee_msg_object_invoke {
	u32 cxt;
	u32 op;
	u32 counts;
	union qcomtee_msg_arg args[];
};

/* Bit masks for the four 4-bit nibbles holding the counts. */
#define QCOMTEE_MASK_IB GENMASK(3, 0)
#define QCOMTEE_MASK_OB GENMASK(7, 4)
#define QCOMTEE_MASK_IO GENMASK(11, 8)
#define QCOMTEE_MASK_OO GENMASK(15, 12)

/**
 * struct qcomtee_msg_callback - Callback request message.
 * @result: result of operation @op on the object referenced by @cxt.
 * @cxt: object ID hosted in the kernel.
 * @op: operation for the object.
 * @counts: number of different types of arguments in @args.
 * @args: array of arguments.
 *
 * For details of @counts, see &qcomtee_msg_object_invoke.counts.
 */
struct qcomtee_msg_callback {
	u32 result;
	u32 cxt;
	u32 op;
	u32 counts;
	union qcomtee_msg_arg args[];
};

/* Offset in the message for the beginning of the buffer argument's contents. */
#define qcomtee_msg_buffer_args(t, n) \
	qcomtee_msg_offset_align(struct_size_t(t, args, n))
/* Pointer to the beginning of a buffer argument's content at an offset. */
#define qcomtee_msg_offset_to_ptr(m, off) ((void *)&((char *)(m))[(off)])

/* Some helpers to manage msg.counts. */

static inline unsigned int qcomtee_msg_num_ib(u32 counts)
{
	return FIELD_GET(QCOMTEE_MASK_IB, counts);
}

static inline unsigned int qcomtee_msg_num_ob(u32 counts)
{
	return FIELD_GET(QCOMTEE_MASK_OB, counts);
}

static inline unsigned int qcomtee_msg_num_io(u32 counts)
{
	return FIELD_GET(QCOMTEE_MASK_IO, counts);
}

static inline unsigned int qcomtee_msg_num_oo(u32 counts)
{
	return FIELD_GET(QCOMTEE_MASK_OO, counts);
}

static inline unsigned int qcomtee_msg_idx_ib(u32 counts)
{
	return 0;
}

static inline unsigned int qcomtee_msg_idx_ob(u32 counts)
{
	return qcomtee_msg_num_ib(counts);
}

static inline unsigned int qcomtee_msg_idx_io(u32 counts)
{
	return qcomtee_msg_idx_ob(counts) + qcomtee_msg_num_ob(counts);
}

static inline unsigned int qcomtee_msg_idx_oo(u32 counts)
{
	return qcomtee_msg_idx_io(counts) + qcomtee_msg_num_io(counts);
}

#define qcomtee_msg_for_each(i, first, num) \
	for ((i) = (first); (i) < (first) + (num); (i)++)

#define qcomtee_msg_for_each_input_buffer(i, m)                  \
	qcomtee_msg_for_each(i, qcomtee_msg_idx_ib((m)->counts), \
			     qcomtee_msg_num_ib((m)->counts))

#define qcomtee_msg_for_each_output_buffer(i, m)                 \
	qcomtee_msg_for_each(i, qcomtee_msg_idx_ob((m)->counts), \
			     qcomtee_msg_num_ob((m)->counts))

Annotation

Implementation Notes