optee_os中静态共享内存的注册
生活随笔
收集整理的這篇文章主要介紹了
optee_os中静态共享内存的注册
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
快速鏈接:
.
👉👉👉 個人博客筆記導讀目錄(全部) 👈👈👈
說明: 在默認的情況下,本文講述的是armv8 aarch64體系,optee 3.12.0代碼
默認開啟了CFG_CORE_RESERVED_SHM
編譯的時候在section段中預留一塊內存做為共享內存
#ifdef CFG_CORE_RESERVED_SHM
register_phys_mem(MEM_AREA_NSEC_SHM, TEE_SHMEM_START, TEE_SHMEM_SIZE);
#endif
內存的類型為:MEM_AREA_NSEC_SHM
內存的大小在platform_config.h中定義
#define TEE_SHMEM_START (TZDRAM_BASE + TZDRAM_SIZE)
#define TEE_SHMEM_SIZE 0x100000
在optee early_init的時候,將共享內存地址和size保存到全局變量中
#ifdef CFG_CORE_RESERVED_SHM static TEE_Result teecore_init_pub_ram(void) {vaddr_t s = 0;vaddr_t e = 0;/* get virtual addr/size of NSec shared mem allocated from teecore */core_mmu_get_mem_by_type(MEM_AREA_NSEC_SHM, &s, &e);if (s >= e || s & SMALL_PAGE_MASK || e & SMALL_PAGE_MASK)panic("invalid PUB RAM");/* extra check: we could rely on core_mmu_get_mem_by_type() */if (!tee_vbuf_is_non_sec(s, e - s))panic("PUB RAM is not non-secure");#ifdef CFG_PL310/* Allocate statically the l2cc mutex */tee_l2cc_store_mutex_boot_pa(virt_to_phys((void *)s));s += sizeof(uint32_t); /* size of a pl310 mutex */s = ROUNDUP(s, SMALL_PAGE_SIZE); /* keep required alignment */ #endifdefault_nsec_shm_paddr = virt_to_phys((void *)s);default_nsec_shm_size = e - s;return TEE_SUCCESS; } early_init(teecore_init_pub_ram); #endif /*CFG_CORE_RESERVED_SHM*/在Linux Kernel tee-driver加載的時候,會請求TEE服務,獲取共享內存的地址和size,然后在Linux Kernel中進行remap
#ifdef CFG_CORE_RESERVED_SHM static void tee_entry_get_shm_config(struct thread_smc_args *args) {args->a0 = OPTEE_SMC_RETURN_OK;args->a1 = default_nsec_shm_paddr;args->a2 = default_nsec_shm_size;/* Should this be TEESMC cache attributes instead? */args->a3 = core_mmu_is_shm_cached(); } #endif總結
以上是生活随笔為你收集整理的optee_os中静态共享内存的注册的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: optee的fast call的介绍
- 下一篇: optee中spinlock的实现原理详