728x90
tee_shm: 리눅스 커널에서 쓸 수 있는 nw<->sw 공유 메모리 구조체
/**
* struct tee_shm - shared memory object
* @ctx: context using the object
* @paddr: physical address of the shared memory
* @kaddr: virtual address of the shared memory
* @size: size of shared memory
* @offset: offset of buffer in user space
* @pages: locked pages from userspace
* @num_pages: number of locked pages
* @refcount: reference counter
* @flags: defined by TEE_SHM_* in tee_core.h
* @id: unique id of a shared memory object on this device, shared
* with user space
* @sec_world_id:
* secure world assigned id of this shared memory object, not
* used by all drivers
*/
struct tee_shm {
struct tee_context *ctx;
phys_addr_t paddr;
void *kaddr;
size_t size;
unsigned int offset;
struct page **pages;
size_t num_pages;
refcount_t refcount;
u32 flags;
int id;
u64 sec_world_id;
};
어디를 공유 메모리로 설정할지 등등을 정할 수 있음
struct tee_shm* shm1=tee_shm_register_kernel_buf(pvt_data->ctx,rbuf[0],rbuf_size[0]);
shm1->flags=TEE_SHM_DYNAMIC;
이런식으로 가능!
위 코드는 rbuf[0]을 rbuf_size[0]만큼 공유메모리로 지정하겠다는 의미
tee_param
struct tee_param {
u64 attr;
union {
struct tee_param_memref memref;
struct tee_param_value value;
} u;
};
리눅스 커널에서 쓸 수 있는 tee한테 보낼 수 있는 파라미터
저 안의 구조체는 아래처럼 되어있다
struct tee_param_memref {
size_t shm_offs;
size_t size;
struct tee_shm *shm;
};
struct tee_param_value {
u64 a;
u64 b;
u64 c;
};
아래는 tee 내에서 받는 파라미터다
typedef union {
struct
{
void* buffer;
size_t size;
} memref;
struct
{
uint32_t a;
uint32_t b;
} value;
} TEE_Param;
이거는 코어쪽 TEE_Param 구조체! 이게 파라미터 하나당!!
이 형식에 맞춰서 client에서 보내면됨