optee_probe()c
| 2024-11-8
本文字數 698閱讀時長 2 分鐘
  • optee_probe()
    • sbi_mpxy_tee_probe()
    • Get invoke function.
    • optee_msg_api_uid_is_optee_api()
      • Check UUID:
        • Call the invoke function, e.g. optee_smccc_smc() with function ID: OPTEE_SMC_CALLS_UID to retrieve the UUID.
          • OP-TEE will return UUID. Return true if the returned UUID is OPTEE_MSG_UID (384fb3e0-e7f8-11e3-af63-0002a5d5c51b), false otherwise.
    • optee_msg_get_os_revision()
      • Get OS revision
        • Call the invoke function, e.g. optee_smccc_smc() with function ID: OPTEE_SMC_CALL_GET_OS_REVISION to get OS version.
          • OP-TEE will return the OS revision.
    • optee_msg_api_revision_is_compatible()
      • Check whether the API revision is compatible:
        • Call the invoke function, e.g. optee_smccc_smc() with function ID: OPTEE_SMC_CALLS_REVISION to retrieve the API revision.
          • OP-TEE will return the API revision. Return true if the returned API revision is OPTEE_MSG_REVISION (2.0), false otherwise.
    • optee_msg_get_thread_count()
      • Get OP-TEE thread count:
        • Call the invoke function, e.g. optee_smccc_smc() with function ID: OPTEE_SMC_GET_THREAD_COUNT to get the OP-TEE thread count.
    • optee_msg_exchange_capabilities()
      • Exchange capabilities between Linux and OP-TEE:
        • Linux sets:
          • If UP, OPTEE_SMC_NSEC_CAP_UNIPROCESSOR.
        • Call the invoke function, e.g. optee_smccc_smc() with function ID: OPTEE_SMC_EXCHANGE_CAPABILITIES to exchange the capabilities between Linux and OP-TEE.
        • OP-TEE sets:
          • If reserved shared memory is enabled in secure world: OPTEE_ABI_SEC_CAP_HAVE_RESERVED_SHM.
          • If dynamic shared memory is enabled in secure world: OPTEE_ABI_SEC_CAP_DYNAMIC_SHM.
          • If virtualization is enabled in secure world: OPTEE_ABI_SEC_CAP_VIRTUALIZATION.
          • Shared memory with a NULL reference is supported in secure world: OPTEE_ABI_SEC_CAP_MEMREF_NULL.
          • If asynchronous notification of normal world is supported in secure world: OPTEE_ABI_SEC_CAP_ASYNC_NOTIF.
          • Pre-allocating RPC arg struct is supported in secure world: OPTEE_ABI_SEC_CAP_RPC_ARG.
    • If the capabilities has OPTEE_ABI_SEC_CAP_DYNAMIC_SHM, create page-based allocator pool based on alloc_pages().
    • If the capabilities has OPTEE_ABI_SEC_CAP_HAVE_RESERVED_SHM, use the static memory pool.
      • Call the invoke function, e.g. optee_smccc_smc() with function ID: OPTEE_SMC_GET_SHM_CONFIG to get the base address and the size of the static memory pool allocated by OP-TEE.
        • OP-TEE returns default_nsec_shm_paddr and default_nsec_shm_size indicating the physical base address and the size of the non-secure shared memory initialized in teecore_init_pub_ram().
          • Non-secured shared memory is declared statically in OP-TEE:
            • teecore_init_pub_ram() is declared with early_init() when CFG_CORE_RESERVED_SHM is defined.
      • Allocate struct optee:
        • optee->ops = &optee_ops
      • Call tee_device_alloc() to allocate a new struct tee_device instance for TEE client device: optee-clnt with optee_clnt_desc. struct optee is passed as driver_data.
        • The allocated TEE client device is assigned to optee->teedev.
      • Call tee_device_alloc() to allocate a new struct tee_device instance for TEE supplicant device: optee-supp with optee_supp_desc. struct optee is passed as driver_data.
        • The allocated TEE supplicant device is assigned to optee->supp_teedev.
      • Call tee_device_register() to register optee-clnt device.
      • Call tee_device_register() to register optee-supp device.
      • Call platform_set_drvdata() to set optee device driver data to: struct optee.
      • Open OP-TEE client device (optee->teedev):
      • If OPTEE_SMC_SEC_CAP_ASYNC_NOTIF capability is supported:
        • Call platform_get_irq() to get (non-secure) IRQ 0.
        • Call optee_smc_notif_init_irq() to request IRQ.
          • If irq_is_percpu_devid():
            • init_pcpu_irq()
              • request_percpu_irq()
                • IRQ handler: notif_pcpu_irq_handler()
                  • irq_handler()
              • Init work: optee->smc.notif_pcpu_work:
              • Create work queue: optee->smc.notif_pcpu_wq
                • optee->smc.notif_pcpu_work is queued into optee->scm.notif_pcpu_wq in notif_pcpu_irq_handler()
          • Otherwise:
            • init_irq()
              • request_threaded_irq()
        • Call optee_enumerate_devices() to enumerate PTA devices (PTA_CMD_GET_DEVICES).
    Loading...
    目錄