optee thread的初始化
来源:互联网 发布:网络侵权管辖地 编辑:程序博客网 时间:2024/06/14 12:02
optee os 是支持thread的,thread的初始化主要在下面两个函数中进行
init_runtime->thread_init_boot_thread
void thread_init_boot_thread(void)
{
//得到这个cpu id对应的thread_core_local
struct thread_core_local *l = thread_get_core_local();
size_t n;
//可见optee 支持的最多CFG_NUM_THREADS个thread。分别初始化thread的mutexes/sess_stack/pgt_cache
for (n = 0; n < CFG_NUM_THREADS; n++) {
TAILQ_INIT(&threads[n].mutexes);
TAILQ_INIT(&threads[n].tsd.sess_stack);
#ifdef CFG_SMALL_PAGE_USER_TA
SLIST_INIT(&threads[n].tsd.pgt_cache);
#endif
}
//将thread_core_local 数组对应curr_thread 赋值为-1
for (n = 0; n < CFG_TEE_CORE_NB_CORE; n++)
thread_core_local[n].curr_thread = -1;
//将当前cpu id 对应的curr_thread赋值为0
l->curr_thread = 0;
threads[0].state = THREAD_STATE_ACTIVE;
}
struct thread_core_local *thread_get_core_local(void)
{
uint32_t cpu_id = get_core_pos();
/*
* Foreign interrupts must be disabled before playing with core_local
* since we otherwise may be rescheduled to a different core in the
* middle of this function.
*/
assert(thread_get_exceptions() & THREAD_EXCP_FOREIGN_INTR);
assert(cpu_id < CFG_TEE_CORE_NB_CORE);
return &thread_core_local[cpu_id];
}
thread_get_core_local 主要是返回cpuid对应的thread_core_local
static struct thread_core_local thread_core_local[CFG_TEE_CORE_NB_CORE];
第二个函数是thread_init_per_cpu
void thread_init_per_cpu(void)
{
size_t pos = get_core_pos();
struct thread_core_local *l = thread_get_core_local();
init_sec_mon(pos);
//设置l->tmp_stack_va_end
set_tmp_stack(l, GET_STACK(stack_tmp[pos]) - STACK_TMP_OFFS);
set_abt_stack(l, GET_STACK(stack_abt[pos]));
// 用于将thread_vect_table 保持到vbar_el1 中
thread_init_vbar();
}
static void set_tmp_stack(struct thread_core_local *l, vaddr_t sp)
{
/*
* We're already using the tmp stack when this function is called
* so there's no need to assign it to any stack pointer. However,
* we'll need to restore it at different times so store it here.
*/
l->tmp_stack_va_end = sp;
}
FUNC thread_init_vbar , :
adr x0, thread_vect_table
msr vbar_el1, x0
ret
END_FUNC thread_init_vbar
init_runtime->thread_init_boot_thread
void thread_init_boot_thread(void)
{
//得到这个cpu id对应的thread_core_local
struct thread_core_local *l = thread_get_core_local();
size_t n;
//可见optee 支持的最多CFG_NUM_THREADS个thread。分别初始化thread的mutexes/sess_stack/pgt_cache
for (n = 0; n < CFG_NUM_THREADS; n++) {
TAILQ_INIT(&threads[n].mutexes);
TAILQ_INIT(&threads[n].tsd.sess_stack);
#ifdef CFG_SMALL_PAGE_USER_TA
SLIST_INIT(&threads[n].tsd.pgt_cache);
#endif
}
//将thread_core_local 数组对应curr_thread 赋值为-1
for (n = 0; n < CFG_TEE_CORE_NB_CORE; n++)
thread_core_local[n].curr_thread = -1;
//将当前cpu id 对应的curr_thread赋值为0
l->curr_thread = 0;
threads[0].state = THREAD_STATE_ACTIVE;
}
struct thread_core_local *thread_get_core_local(void)
{
uint32_t cpu_id = get_core_pos();
/*
* Foreign interrupts must be disabled before playing with core_local
* since we otherwise may be rescheduled to a different core in the
* middle of this function.
*/
assert(thread_get_exceptions() & THREAD_EXCP_FOREIGN_INTR);
assert(cpu_id < CFG_TEE_CORE_NB_CORE);
return &thread_core_local[cpu_id];
}
thread_get_core_local 主要是返回cpuid对应的thread_core_local
static struct thread_core_local thread_core_local[CFG_TEE_CORE_NB_CORE];
第二个函数是thread_init_per_cpu
void thread_init_per_cpu(void)
{
size_t pos = get_core_pos();
struct thread_core_local *l = thread_get_core_local();
init_sec_mon(pos);
//设置l->tmp_stack_va_end
set_tmp_stack(l, GET_STACK(stack_tmp[pos]) - STACK_TMP_OFFS);
set_abt_stack(l, GET_STACK(stack_abt[pos]));
// 用于将thread_vect_table 保持到vbar_el1 中
thread_init_vbar();
}
static void set_tmp_stack(struct thread_core_local *l, vaddr_t sp)
{
/*
* We're already using the tmp stack when this function is called
* so there's no need to assign it to any stack pointer. However,
* we'll need to restore it at different times so store it here.
*/
l->tmp_stack_va_end = sp;
}
FUNC thread_init_vbar , :
adr x0, thread_vect_table
msr vbar_el1, x0
ret
END_FUNC thread_init_vbar
阅读全文
0 0
- optee thread的初始化
- optee os 的启动和初始化
- optee的generic_boot_init_primary 分析
- optee 的helloworld ta
- optee的同步机制总结
- optee中的fiq的执行
- optee开源项目的学习
- optee 中静态memory的管理
- linaro optee os官网的几张架构图
- 初识optee 在QEMU平台上的编译、运行
- optee fvp
- Thread中ThreadLocal.ThreadLocalMap映射表的初始化
- java:基于volatile和Thread Local Storage的双重检查锁定实现延迟初始化
- <OPTEE>Trusted Application结构分析
- optee os中的console driver
- optee os 中的系统调用
- Class.forName() 初始化、Thread.currentThread().getContextClassLoader().getResourceAsStream
- RT-thread组件初始化代码分析
- Android studio查看应用的日志和内存
- git clone 单个分支和clone时遇到 filename too long的问题
- word2013 发布csdn博客
- Java四种线程池的使用
- 梦网云通讯获取状态报告API接口get_rpt说明POST请求示例
- optee thread的初始化
- 1039. Course List for Student (25)
- OpenCV学习笔记(19)关于CV_8UC1,CV_8UC2等参数
- R语言利用caret包比较ROC曲线
- sql server字段类型详解
- IOS 修改状态栏颜色
- Redis java调用API
- Ubuntu expect使用经验
- 百度地图申请密钥Android SDK