万事开头难,本以为所有的HelloWorld都是很简单的。下载了TZ的HelloWorld才知道。比想象的要困难很多。
DS-5的下载地址,需要注册ARM官网。注册个ARM账号,没有XX版本。
TrustZone的HelloWorld的下载地址
需要背景知识:
1.arm汇编(中级)
2.了解如何制作linux的boot,kernel
3.了解文件在flash布局与开发
4.了解TrustZone相关硬件设置方法
5.软件开发以及混合编程(中级)
6.Makefile使用方法
7.基于eclipse的DS-5的使用
假定你拥有了上面的知识,了解这个程序应该简单一些。不过ARM官方的东西,注释还是比较多的。如果你只是想编译通过,了解其中几项也是没问题的。
这个程序告诉我们什么?或者说通过这个程序我们学到了什么?
1.安全区先启动
2.Monitor必须在安全区启动
3.如何实现SMC(TZ的切换)跳转
4.需要硬件TZPC支持
这是个基础,稍后我们会慢慢研究这个东西的。
Program execution flow
The flow of program execution is shown below:
secureStart startup_secure.s: Initialization of Secure world
|
__main ARM library initialization
|
main main_secure.c: Enable caches and configure TZPC
|
monitorInit monitor.s: initialize Monitor
|
main main_secure.c: Print message and execute SMC
|
S -> NS
|
normalStart startup_normal.s: Initialization of Normal world
|
__main ARM library initialization
|
main main_normal.c: Enable caches, print message and execute SMC
|
NS -> S
|
SMC_Handler monitor.s: Perform context switch from NS to S
|
main main_secure.c: Print message and execute SMC
|
SMC_Handler monitor.s: Perform context switch from S to NS
|
S -> NS
|
main main_normal.c: Print message and execute SMC
|
NS -> S
|
SMC_Handler monitor.s: Perform context switch from NS to S
|
main main_secure.c: Print message and execute SMC
本文详细解析TrustZone HelloWorld程序的执行流程,包括安全区启动、Monitor启动、SMC切换等关键步骤,以及硬件TZPC的支持需求。通过理解此程序,读者能掌握TrustZone环境下程序的启动与上下文切换原理。
1527





