TA 系统调用

当在TA中通过system call陷入到secure的el1的时候会调用到core/arch/arm/kernel/thread_a64.S中的el0_sync_a64
el0_sync_a64:
     store_xregs sp, THREAD_CORE_LOCAL_X0, 0, 3
     mrs x2, esr_el1
     mrs x3, sp_el0
     lsr x2, x2, #ESR_EC_SHIFT
     cmp x2, #ESR_EC_AARCH64_SVC
     b.eq    el0_svc
     b   el0_sync_abort
     check_vector_size el0_sync_a64
 
     .align  7
 
在el0_sync_a64 中又会call el0_svc
LOCAL_FUNC el0_svc , :
     /* get pointer to current thread context in x0 */
     get_thread_ctx sp, 0, 1, 2
     /* load saved kernel sp */
     ldr x0, [x0, #THREAD_CTX_KERN_SP]
     /* Keep pointer to initial recod in x1 */
     mov x1, sp
     /* Switch to SP_EL0 and restore kernel sp */
     msr spsel, #0
     mov x2, sp  /* Save SP_EL0 */
     mov sp, x0
 
     /*
      * Unmask native interrupts, Serror, and debug exceptions since we have
      * nothing left in sp_el1. Note that the SVC handler is excepted to
      * re-enable foreign interrupts by itself.
      */
     msr daifclr, #(DAIFBIT_FIQ | DAIFBIT_ABT | DAIFBIT_DBG)
 
     /* Call the handler */
     bl  tee_svc_handler
 
跳转到tee_svc_handler
void tee_svc_handler(struct thread_svc_regs *regs)
{
    size_t scn;
    size_t max_args;
    syscall_t scf;
//所有的系统调用都定义在tee_svc_syscall_table 这个数组中
    COMPILE_TIME_ASSERT(ARRAY_SIZE(tee_svc_syscall_table) ==
                (TEE_SCN_MAX + 1));

    thread_user_save_vfp();

    /* TA has just entered kernel mode */
    tee_ta_update_session_utime_suspend();

    /* Restore foreign interrupts which are disabled on exception entry */
    thread_restore_foreign_intr();
//得到具体调用的systemcall的id,即scn
    get_scn_max_args(regs, &scn, &max_args);

    trace_syscall(scn);

    if (max_args > TEE_SVC_MAX_ARGS) {
        DMSG("Too many arguments for SCN %zu (%zu)", scn, max_args);
        set_svc_retval(regs, TEE_ERROR_GENERIC);
        return;
    }

    if (scn > TEE_SCN_MAX)
        scf = syscall_not_supported;
    else // 指向这个systemcall
        scf = tee_svc_syscall_table[scn].fn;
//通过tee_svc_do_call 来调用这个system call,tee_svc_do_call 定义在/core/arch/arm/tee/arch_svc_a64.S 中会通过tee_svc_copy_from_user 从user space copy数据
    set_svc_retval(regs, tee_svc_do_call(regs, scf));

    if (scn != TEE_SCN_RETURN) {
        /* We're about to switch back to user mode */
        tee_ta_update_session_utime_resume();
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在C++中调用talib需要进行以下步骤: 1. 首先,你需要安装talib。你可以从talib的官方网站(https://github.com/mrjbq7/ta-lib)下载源代码并进行编译安装。 2. 在你的C++项目中,包含talib的头文件。你可以使用下面的代码来引入talib的函数声明: ```cpp #include <ta-lib/ta_func.h> ``` 3. 为了正确链接talib,你需要在编译时将talib的文件链接到你的项目中。具体的方法取决于你所使用的编译器和操作系统。 4. 调用talib中的函数。talib提供了各种技术分析指标的计算函数,比如移动平均线、相对强弱指标等等。你可以根据自己的需求选择相应的函数进行调用。 下面是一个简单的示例代码,展示了如何使用talib计算简单移动平均线(SMA): ```cpp #include <iostream> #include <ta-lib/ta_func.h> int main() { // 定义输入数据 double input[] = {1.0, 2.0, 3.0, 4.0, 5.0}; // 定义输出数组 double output[5]; // 计算SMA TA_RetCode retCode = TA_MA(0, 4, input, 3, TA_MAType_SMA, &output[2], nullptr, nullptr); if (retCode == TA_SUCCESS) { // 打印结果 for (int i = 2; i < 5; i++) { std::cout << "SMA[" << i << "]: " << output[i] << std::endl; } } else { std::cerr << "计算SMA失败" << std::endl; } return 0; } ``` 在上面的示例代码中,我们首先定义了一个输入数组`input`,然后定义了一个输出数组`output`。接下来,我们调用了`TA_MA`函数来计算简单移动平均线。最后,我们打印了计算结果。 请注意,以上代码仅为示例,实际使用时你可能需要根据具体的需求进行修改。另外,记得根据你的操作系统和编译器对文件进行正确的链接。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值