boot_init_primary_late()c
| 2025-1-4
本文字數 323閱讀時長 1 分鐘
  • boot_init_primary_late()
    • init_external_dt()
      • Initialize the external DTB located at the given address:
          1. Add MMU mapping of the external DTB.
          1. Initialize device tree overlay.
    • discover_nsec_memory()
      • Call get_nsec_memory() to find all non-secure memories from DT.
        • Lookup for the DT nodes with device_type = “memory”.
      • Call core_mmu_set_discovered_nsec_ddr() to set:
        • discovered_nsec_ddr_start to the first non-secure memory.
          • Non-secure memories are sorted by the physical address in ascending order.
        • discovered_nsec_ddr_nelems to the number of the non-secure memories.
    • update_external_dt()
      • Call add_optee_dt_node() to add /firmware/optee DT node.
        • compatible = "linaro,optee-tz";
      • Call mark_tddram_as_reserved() to add /reserved-memory/optee_core DT node.
        • Reserve the secure memory regions in DRAM used by OP-TEE (CFG_TDDRAM_START ~ (CFG_TDDRAM_START + CFG_TDDRAM_SIZE - 1)) to prevent Linux from using it.
          • If CFG_WITH_PAGER is set and CFG_TDSRAM_START is defined, TEE core secure RAM (TEE_RAM) is allocated in SRAM, instead of DRAM. We don’t need to reserve the memory region for it.
            • However, we still need to reserve other secure memory regions in DRAM (TA_RAM) used by OP-TEE.
    • #ifdef CFG_RISCV_S_MODE
        • mpxy_opteed_channel_init()
          • Check if MPXY extension is supported by OpenSBI.
          • Extract MPXY channel ID from DT:
            • compatible = “riscv,sbi-mpxy-opteed";
            • riscv,sbi-mpxy-channel-id ← Defines MPXY channel ID.
              • Save MPXY channel ID to mpxy_opteed_ctx.channel_id.
            • opensbi-domain-instance ← Defines the OpenSBI domain used by OP-TEE (not used by OP-TEE).
          • sbi_mpxy_setup_shmem()
            • Allocates 4KB MPXY shared memory (4KB aligned).
            • Call sbi_mpxy_set_shmem SBI call to set up the allocated MPXY shared memory for the current core. This will invoke OpenSBI’s sbi_mpxy_set_shmem() to save the shared memory address and size into current hart tdomain’s mpxy_state.
      • boot_primary_init_intc()
        • plic_init()
          • Initialize interrupt controller, e.g. PLIC.
      • init_tee_runtime()
        • core_mmu_init_ta_ram()
          • Initialize the memory region for static TAs.
            • MEM_AREA_TA_RAM: Secure RAM where teecore loads/exec TA instances.
        • call_preinitcalls()
          • Call the preinitcalls defined in .scattered_array_preinitcall section.
          • e.g.
            • mobj_mapped_shm_init()
            • … etc
        • call_initcalls()
          • Call the initcalls defined in .scattered_array_initcall section.
          • e.g.
            • probe_dt_drivers_early()
            • check_ta_store()
            • early_ta_init()
            • verify_pseudo_tas_conformance()
            • tee_cryp_init()
            • … etc
      • call_finalcalls()
        • Call the finalcalls defined in scattered_array_call_finalcall section.
        • e.g.
          • release_external_dt()
          • … etc
      • #ifdef CFG_RISCV_S_MODE
        • start_secondary_cores()
          • Call sbi_hsm_hart_start() to start the secondary cores.
            • Start address = start_addr = _start
    Loading...
    目錄