⚠️ The code is based on: https://gitlab.com/riseproject/riscv-optee/optee_os/-/tree/dev-optee-mpxy

Commit ID: 75df9ba41a404aec897399ead0ff0aebcbff48ca

  • tee_ta_init_pseudo_ta_session()
    • Look up the pseudo TA based on UUID.

    • Create pseudo TA context for the UUID, assign ctx->ts_ctx.ops to pseudo_ta_ops. pseudo_ta_ops will be the global callbacks for the pseudo TAs:

       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      15
      16
      
      // core/kernel/pseudo_ta.c
      TEE_Result tee_ta_init_pseudo_ta_session(const TEE_UUID *uuid,
      			struct tee_ta_session *s)
      {
      
      	.....
      
        ctx->ref_count = 1;
      	ctx->flags = ta->flags;
      	stc->pseudo_ta = ta;
      	ctx->ts_ctx.uuid = ta->uuid;
      	ctx->ts_ctx.ops = &pseudo_ta_ops;
      
      	.....
      
      }
      
      1
      2
      3
      4
      5
      6
      7
      8
      
      // core/kernel/pseudo_ta.c
      
      static const struct ts_ops pseudo_ta_ops = {
      	.enter_open_session = pseudo_ta_enter_open_session,
      	.enter_invoke_cmd = pseudo_ta_enter_invoke_cmd,
      	.enter_close_session = pseudo_ta_enter_close_session,
      	.destroy = pseudo_ta_destroy,
      };
      

  • pseudo_ta_enter_open_session()
    • Call stc->pseudo_ta->open_session_entry_point() callback, if defined.
      • E.g. If the opened session is for pseudo TA: rtc.pta, open_session_entry_point() callback is: open_session():

        1
        2
        3
        4
        5
        6
        7
        
        // core/pta/rtc.c
        
        pseudo_ta_register(.uuid = PTA_RTC_UUID, .name = PTA_NAME,
        		   .flags = PTA_DEFAULT_FLAGS | TA_FLAG_CONCURRENT |
        			    TA_FLAG_DEVICE_ENUM,
        		   .open_session_entry_point = open_session,
        		   .invoke_command_entry_point = invoke_command);
        

  • pseudo_ta_enter_invoke_cmd()
    • Call stc->pseudo_ta->invoke_command_entry_point() callback.
      • E.g. If the opened session is for pseudo TA: device.pta, invoke_command_entry_point() callback is: invoke_command(), which will call get_devices() to retrieve the UUIDs of the pseudo TAs:

        1
        2
        3
        4
        5
        
        // core/pta/device.c
        
        pseudo_ta_register(.uuid = PTA_DEVICE_UUID, .name = PTA_NAME,
        		   .flags = PTA_DEFAULT_FLAGS,
        		   .invoke_command_entry_point = invoke_command);