日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

[ATF]-ATF启动--BL31跳转到optee和uboot

發布時間:2025/3/21 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 [ATF]-ATF启动--BL31跳转到optee和uboot 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

ATF

        • 1、背景
        • 2、ATF編譯
        • 3、ATF的啟動
        • 4、獲取optee/uboot的跳轉地址
        • 4、總結一下ATF啟動流程


★★★ 鏈接 : 個人博客導讀首頁—點擊此處 ★★★

1、背景

在vendor某些廠商的設計中,ATF并不是BOOTROM加載后的第一個啟動鏡像,可能是這樣的:
BOOTROM—>PL—>ATF—>optee—>uboot…, 在PL階段就已經將ATF/optee/uboot鏡像的load到內存了.

2、ATF編譯

由上述背景的原因,我們的ATF就不需要走BL1/BL2階段load optee/uboot鏡像到內存了,直接走BL3即可.
所以bl1和bl2目錄也無需編譯.

我們的編譯方法是在make的時候傳入RESET_TO_BL31=1參數:

make -C $DIRPATH RESET_TO_BL31=1 PLAT=xxxx clean make -C $DIRPATH RESET_TO_BL31=1 PLAT=xxx xxxx_VDK=0 xxxxxx=0 xxxxxx=0 HIGHADDR_DEVICE=1 all

3、ATF的啟動

從bl31.ld.S文件可知,ATF是從bl31_entrypoint開始啟動的

func bl31_entrypointbl bl31_early_platform_setupbl bl31_plat_arch_setupbl bl31_main

在bl31_main()函數中:

  • runtime_svc_init()跳轉optee之前的準備,然后再調用bl32_init跳轉到optee,optee
    os初始化完成后再從此處回來。
  • bl31_prepare_next_image_entry()跳轉uboot之前的準備,返回到bl31_entrypoint后調用b
    el3_exit跳轉到uboot, PC就不會再回此處了。下次PC再回來就是在REE進行了smc調用,那時是直接跳轉到ATF的異常向量表.
void bl31_main(void) {NOTICE("BL31: %s\n", version_string);NOTICE("BL31: %s\n", build_message);/* Perform remaining generic architectural setup from EL3 */bl31_arch_setup();/* Perform platform setup in BL31 */bl31_platform_setup();/* Initialise helper libraries */bl31_lib_init();/* Initialize the runtime services e.g. psci */INFO("BL31: Initializing runtime services\n");runtime_svc_init();/** All the cold boot actions on the primary cpu are done. We now need to* decide which is the next image (BL32 or BL33) and how to execute it.* If the SPD runtime service is present, it would want to pass control* to BL32 first in S-EL1. In that case, SPD would have registered a* function to intialize bl32 where it takes responsibility of entering* S-EL1 and returning control back to bl31_main. Once this is done we* can prepare entry into BL33 as normal.*//** If SPD had registerd an init hook, invoke it.*/if (bl32_init) {INFO("BL31: Initializing BL32\n");(*bl32_init)();}/** We are ready to enter the next EL. Prepare entry into the image* corresponding to the desired security state after the next ERET.*/bl31_prepare_next_image_entry();/** Perform any platform specific runtime setup prior to cold boot exit* from BL31*/bl31_plat_runtime_setup(); }

4、獲取optee/uboot的跳轉地址

bl31_prepare_next_image_entry()可以獲取optee/uboot的跳轉地址,該地址最終來自于platform_def.h頭文件中寫死的地址

  • #define BL32_BASE (PLAT_S_DRAM_BASE + BL31_SIZE + PLAT_TRUSTED_MAILBOX_SIZE)
  • #define PLAT_NS_IMAGE_BASE 0x80000000
    #define PLAT_NS_IMAGE_OFFSET (PLAT_NS_IMAGE_BASE + 0x9000000)
void bl31_prepare_next_image_entry(void) {entry_point_info_t *next_image_info;uint32_t image_type;/* Determine which image to execute next */image_type = bl31_get_next_image_type();/* Program EL3 registers to enable entry into the next EL */next_image_info = bl31_plat_get_next_image_ep_info(image_type);assert(next_image_info);assert(image_type == GET_SECURITY_STATE(next_image_info->h.attr));INFO("BL31: Preparing for EL3 exit to %s world\n",(image_type == SECURE) ? "secure" : "normal");print_entry_point_info(next_image_info);cm_init_my_context(next_image_info);cm_prepare_el3_exit(image_type); } entry_point_info_t *bl31_plat_get_next_image_ep_info(uint32_t type) {assert(sec_state_is_valid(type));if (type == NON_SECURE)return &bl33_image_ep_info;if (type == SECURE)return &bl32_image_ep_info;return NULL; }void bl31_early_platform_setup(bl31_params_t *from_bl2,void *plat_params_from_bl2) {......bl32_image_ep_info.pc = BL32_BASE;............bl33_image_ep_info.pc = plat_get_ns_image_entrypoint();bl33_image_ep_info.spsr = plat_get_spsr_for_bl33_entry();...... }unsigned long plat_get_ns_image_entrypoint(void) {return PLAT_NS_IMAGE_OFFSET; }

4、總結一下ATF啟動流程

總結

以上是生活随笔為你收集整理的[ATF]-ATF启动--BL31跳转到optee和uboot的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。