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

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

[ATF]-ATF的异常向量表介绍-(irq,fiq,smc,hyc...)

發(fā)布時(shí)間:2025/3/21 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 [ATF]-ATF的异常向量表介绍-(irq,fiq,smc,hyc...) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

文章目錄

        • 1、同步異常向量表-(smc)
          • 1.1、handle_sync_exception調(diào)用smc_handler64處理同步異常
        • 2、異類步異常向量表-(irq,fiq...)
          • 2.1、get_interrupt_type_handler獲取ATF注冊(cè)的中斷處理函數(shù)
          • 2.2、handle_interrupt_exception調(diào)用ATF中注冊(cè)的handler函數(shù)


★★★ 友情鏈接 : 個(gè)人博客導(dǎo)讀首頁(yè)—點(diǎn)擊此處 ★★★

思考
(1)、smc是如何調(diào)用到ATF中的smc_handler64()函數(shù)的?
(2)、進(jìn)入EL3(ATF)的方式有幾種?

在ree或tee中執(zhí)行smc指令后,cpu將觸發(fā)同步異常,此時(shí)cpu進(jìn)入ATF的sync_exception_aarch64,在干函數(shù)中調(diào)用了handle_sync_exception()—>smc_handler64()

也就是說,進(jìn)入EL3(ATF)的方式有兩種:
(1)、同步異常:smc指令
(2)、異步異常:產(chǎn)生了routing到EL3的FIQ或IRQ

armv8異常:

  • asynchronous exception 異步異常,例如IRQ、FIQ、Serror
  • synchronous exception 同步異常,例如hyc、smc

1、同步異常向量表-(smc)

smc同步異常調(diào)用的都是handle_sync_exception

sync_exception_aarch64:/* -----------------------------------------------------* This exception vector will be the entry point for* SMCs and traps that are unhandled at lower ELs most* commonly. SP_EL3 should point to a valid cpu context* where the general purpose and system register state* can be saved.* -----------------------------------------------------*/handle_sync_exceptioncheck_vector_size sync_exception_aarch64 sync_exception_aarch32:/* -----------------------------------------------------* This exception vector will be the entry point for* SMCs and traps that are unhandled at lower ELs most* commonly. SP_EL3 should point to a valid cpu context* where the general purpose and system register state* can be saved.* -----------------------------------------------------*/handle_sync_exceptioncheck_vector_size sync_exception_aarch32
1.1、handle_sync_exception調(diào)用smc_handler64處理同步異常
.macro handle_sync_exception /* Enable the SError interrupt */ msr daifclr, #DAIF_ABT_BITstr x30, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_LR] mrs x30, esr_el3 ubfx x30, x30, #ESR_EC_SHIFT, #ESR_EC_LENGTHcmp x30, #EC_AARCH32_SMC b.eq smc_handler32cmp x30, #EC_AARCH64_SMC b.eq smc_handler64/* -----------------------------------------------------* The following code handles any synchronous exception* that is not an SMC.* -----------------------------------------------------*/bl report_unhandled_exception .endm

2、異類步異常向量表-(irq,fiq…)

irq/fiq異步異常調(diào)用的是handle_interrupt_exception

irq_aarch64:handle_interrupt_exception irq_aarch64check_vector_size irq_aarch64.align 7 fiq_aarch64:handle_interrupt_exception fiq_aarch64check_vector_size fiq_aarch64
2.1、get_interrupt_type_handler獲取ATF注冊(cè)的中斷處理函數(shù)
interrupt_type_handler_t get_interrupt_type_handler(uint32_t type) {if (validate_interrupt_type(type))return NULL;return intr_type_descs[type].handler; }
2.2、handle_interrupt_exception調(diào)用ATF中注冊(cè)的handler函數(shù)
.macro handle_interrupt_exception label/* Enable the SError interrupt */msr daifclr, #DAIF_ABT_BITstr x30, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_LR]bl save_gp_registers/** Save the EL3 system registers needed to return from* this exception.*/mrs x0, spsr_el3mrs x1, elr_el3stp x0, x1, [sp, #CTX_EL3STATE_OFFSET + CTX_SPSR_EL3]/* Switch to the runtime stack i.e. SP_EL0 */ldr x2, [sp, #CTX_EL3STATE_OFFSET + CTX_RUNTIME_SP]mov x20, spmsr spsel, #0mov sp, x2/** Find out whether this is a valid interrupt type. If the* interrupt controller reports a spurious interrupt then* return to where we came from.*/bl plat_ic_get_pending_interrupt_typecmp x0, #INTR_TYPE_INVALb.eq interrupt_exit_\label/** Get the registered handler for this interrupt type. A* NULL return value could be 'cause of the following* conditions:** a. An interrupt of a type was routed correctly but a* handler for its type was not registered.** b. An interrupt of a type was not routed correctly so* a handler for its type was not registered.** c. An interrupt of a type was routed correctly to EL3,* but was deasserted before its pending state could* be read. Another interrupt of a different type pended* at the same time and its type was reported as pending* instead. However, a handler for this type was not* registered.** a. and b. can only happen due to a programming error.* The occurrence of c. could be beyond the control of* Trusted Firmware. It makes sense to return from this* exception instead of reporting an error.*/bl get_interrupt_type_handlercbz x0, interrupt_exit_\labelmov x21, x0mov x0, #INTR_ID_UNAVAILABLE/* Set the current security state in the 'flags' parameter */mrs x2, scr_el3ubfx x1, x2, #0, #1/* Restore the reference to the 'handle' i.e. SP_EL3 */mov x2, x20/* x3 will point to a cookie (not used now) */mov x3, xzr/* Call the interrupt type handler */blr x21interrupt_exit_\label:/* Return from exception, possibly in a different security state */b el3_exit.endm

剖析該段匯編的關(guān)鍵代碼:

bl get_interrupt_type_handler //獲取注冊(cè)的中斷處理函數(shù), 返回函數(shù)地址,保存在X0中 cbz x0, interrupt_exit_\label mov x21, x0 //X0保存到了X21中 ..... blr x21 //跳轉(zhuǎn)到X21,就是跳轉(zhuǎn)到ATF中的中斷處理函數(shù)

總結(jié)

以上是生活随笔為你收集整理的[ATF]-ATF的异常向量表介绍-(irq,fiq,smc,hyc...)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。