1b4315306SDan Handley /* 286e4859aSRohit Mathew * Copyright (c) 2015-2024, Arm Limited and Contributors. All rights reserved. 3b4315306SDan Handley * 482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause 5b4315306SDan Handley */ 615b94cc1SAntonio Nino Diaz #ifndef PLAT_ARM_H 715b94cc1SAntonio Nino Diaz #define PLAT_ARM_H 8b4315306SDan Handley 9d6dcbcadSLouis Mayencourt #include <stdbool.h> 10b4315306SDan Handley #include <stdint.h> 1109d40e0eSAntonio Nino Diaz 12a5566f65SHarrison Mutai #include <common/desc_image_load.h> 1309d40e0eSAntonio Nino Diaz #include <drivers/arm/tzc_common.h> 1409d40e0eSAntonio Nino Diaz #include <lib/bakery_lock.h> 1509d40e0eSAntonio Nino Diaz #include <lib/cassert.h> 1609d40e0eSAntonio Nino Diaz #include <lib/el3_runtime/cpu_data.h> 1786e4859aSRohit Mathew #include <lib/gpt_rme/gpt_rme.h> 1809d40e0eSAntonio Nino Diaz #include <lib/spinlock.h> 19a5566f65SHarrison Mutai #include <lib/transfer_list.h> 2009d40e0eSAntonio Nino Diaz #include <lib/utils_def.h> 2109d40e0eSAntonio Nino Diaz #include <lib/xlat_tables/xlat_tables_compat.h> 22b4315306SDan Handley 23afc931f5SSandrine Bailleux /******************************************************************************* 24afc931f5SSandrine Bailleux * Forward declarations 25afc931f5SSandrine Bailleux ******************************************************************************/ 26afc931f5SSandrine Bailleux struct meminfo; 27a8aa7fecSYatharth Kochar struct image_info; 28cab0b5b0SSoby Mathew struct bl_params; 29afc931f5SSandrine Bailleux 3023411d2cSSummer Qin typedef struct arm_tzc_regions_info { 3123411d2cSSummer Qin unsigned long long base; 3223411d2cSSummer Qin unsigned long long end; 33af6491f8SAntonio Nino Diaz unsigned int sec_attr; 3423411d2cSSummer Qin unsigned int nsaid_permissions; 3523411d2cSSummer Qin } arm_tzc_regions_info_t; 3623411d2cSSummer Qin 3786e4859aSRohit Mathew typedef struct arm_gpt_info { 3886e4859aSRohit Mathew pas_region_t *pas_region_base; 3986e4859aSRohit Mathew unsigned int pas_region_count; 4086e4859aSRohit Mathew uintptr_t l0_base; 4186e4859aSRohit Mathew uintptr_t l1_base; 4286e4859aSRohit Mathew size_t l0_size; 4386e4859aSRohit Mathew size_t l1_size; 4486e4859aSRohit Mathew gpccr_pps_e pps; 4586e4859aSRohit Mathew gpccr_pgs_e pgs; 4686e4859aSRohit Mathew } arm_gpt_info_t; 4786e4859aSRohit Mathew 4823411d2cSSummer Qin /******************************************************************************* 4923411d2cSSummer Qin * Default mapping definition of the TrustZone Controller for ARM standard 5023411d2cSSummer Qin * platforms. 5123411d2cSSummer Qin * Configure: 5223411d2cSSummer Qin * - Region 0 with no access; 5323411d2cSSummer Qin * - Region 1 with secure access only; 5423411d2cSSummer Qin * - the remaining DRAM regions access from the given Non-Secure masters. 5523411d2cSSummer Qin ******************************************************************************/ 56d836df71SManish V Badarkhe 57d836df71SManish V Badarkhe #if ENABLE_RME 58d836df71SManish V Badarkhe #define ARM_TZC_RME_REGIONS_DEF \ 59d836df71SManish V Badarkhe {ARM_AP_TZC_DRAM1_BASE, ARM_AP_TZC_DRAM1_END, TZC_REGION_S_RDWR, 0},\ 60d836df71SManish V Badarkhe {ARM_EL3_TZC_DRAM1_BASE, ARM_L1_GPT_END, TZC_REGION_S_RDWR, 0}, \ 61d836df71SManish V Badarkhe {ARM_NS_DRAM1_BASE, ARM_NS_DRAM1_END, ARM_TZC_NS_DRAM_S_ACCESS, \ 62d836df71SManish V Badarkhe PLAT_ARM_TZC_NS_DEV_ACCESS}, \ 63d836df71SManish V Badarkhe /* Realm and Shared area share the same PAS */ \ 64d836df71SManish V Badarkhe {ARM_REALM_BASE, ARM_EL3_RMM_SHARED_END, ARM_TZC_NS_DRAM_S_ACCESS, \ 65d836df71SManish V Badarkhe PLAT_ARM_TZC_NS_DEV_ACCESS}, \ 66d836df71SManish V Badarkhe {ARM_DRAM2_BASE, ARM_DRAM2_END, ARM_TZC_NS_DRAM_S_ACCESS, \ 67d836df71SManish V Badarkhe PLAT_ARM_TZC_NS_DEV_ACCESS} 68d836df71SManish V Badarkhe #endif 69d836df71SManish V Badarkhe 705df1dccdSNishant Sharma #if SPM_MM || (SPMC_AT_EL3 && SPMC_AT_EL3_SEL0_SP) 7123411d2cSSummer Qin #define ARM_TZC_REGIONS_DEF \ 72c8720729SZelalem Aweke {ARM_AP_TZC_DRAM1_BASE, ARM_EL3_TZC_DRAM1_END + ARM_L1_GPT_SIZE,\ 7323411d2cSSummer Qin TZC_REGION_S_RDWR, 0}, \ 7423411d2cSSummer Qin {ARM_NS_DRAM1_BASE, ARM_NS_DRAM1_END, ARM_TZC_NS_DRAM_S_ACCESS, \ 7523411d2cSSummer Qin PLAT_ARM_TZC_NS_DEV_ACCESS}, \ 7623411d2cSSummer Qin {ARM_DRAM2_BASE, ARM_DRAM2_END, ARM_TZC_NS_DRAM_S_ACCESS, \ 7723411d2cSSummer Qin PLAT_ARM_TZC_NS_DEV_ACCESS}, \ 780560efb9SArd Biesheuvel {PLAT_SP_IMAGE_NS_BUF_BASE, (PLAT_SP_IMAGE_NS_BUF_BASE + \ 790560efb9SArd Biesheuvel PLAT_SP_IMAGE_NS_BUF_SIZE) - 1, TZC_REGION_S_NONE, \ 8023411d2cSSummer Qin PLAT_ARM_TZC_NS_DEV_ACCESS} 8123411d2cSSummer Qin 82c8720729SZelalem Aweke #elif ENABLE_RME 83d836df71SManish V Badarkhe #if (defined(SPD_tspd) || defined(SPD_opteed) || defined(SPD_spmd)) && \ 84d836df71SManish V Badarkhe MEASURED_BOOT 85c8720729SZelalem Aweke #define ARM_TZC_REGIONS_DEF \ 86d836df71SManish V Badarkhe ARM_TZC_RME_REGIONS_DEF, \ 87d836df71SManish V Badarkhe {ARM_EVENT_LOG_DRAM1_BASE, ARM_EVENT_LOG_DRAM1_END, \ 88d836df71SManish V Badarkhe TZC_REGION_S_RDWR, 0} 89d836df71SManish V Badarkhe #else 90d836df71SManish V Badarkhe #define ARM_TZC_REGIONS_DEF \ 91d836df71SManish V Badarkhe ARM_TZC_RME_REGIONS_DEF 92d836df71SManish V Badarkhe #endif 93c8720729SZelalem Aweke 9423411d2cSSummer Qin #else 9523411d2cSSummer Qin #define ARM_TZC_REGIONS_DEF \ 96c8720729SZelalem Aweke {ARM_AP_TZC_DRAM1_BASE, ARM_EL3_TZC_DRAM1_END + ARM_L1_GPT_SIZE,\ 9723411d2cSSummer Qin TZC_REGION_S_RDWR, 0}, \ 9823411d2cSSummer Qin {ARM_NS_DRAM1_BASE, ARM_NS_DRAM1_END, ARM_TZC_NS_DRAM_S_ACCESS, \ 9923411d2cSSummer Qin PLAT_ARM_TZC_NS_DEV_ACCESS}, \ 10023411d2cSSummer Qin {ARM_DRAM2_BASE, ARM_DRAM2_END, ARM_TZC_NS_DRAM_S_ACCESS, \ 10123411d2cSSummer Qin PLAT_ARM_TZC_NS_DEV_ACCESS} 10223411d2cSSummer Qin #endif 10323411d2cSSummer Qin 104b4315306SDan Handley #define ARM_CASSERT_MMAP \ 105053b4f92SChris Kay CASSERT((ARRAY_SIZE(plat_arm_mmap) - 1) <= PLAT_ARM_MMAP_ENTRIES, \ 106053b4f92SChris Kay assert_plat_arm_mmap_mismatch); \ 107053b4f92SChris Kay CASSERT((PLAT_ARM_MMAP_ENTRIES + ARM_BL_REGIONS) \ 108b4315306SDan Handley <= MAX_MMAP_REGIONS, \ 109b4315306SDan Handley assert_max_mmap_regions); 110b4315306SDan Handley 1111eb735d7SRoberto Vargas void arm_setup_romlib(void); 1121eb735d7SRoberto Vargas 113402b3cf8SJulius Werner #if defined(IMAGE_BL31) || (!defined(__aarch64__) && defined(IMAGE_BL32)) 114b4315306SDan Handley /* 115b4315306SDan Handley * Use this macro to instantiate lock before it is used in below 116b4315306SDan Handley * arm_lock_xxx() macros 117b4315306SDan Handley */ 1181931d1d7SSandrine Bailleux #define ARM_INSTANTIATE_LOCK static DEFINE_BAKERY_LOCK(arm_lock) 119c04a3b6cSSoby Mathew #define ARM_LOCK_GET_INSTANCE (&arm_lock) 12032aee841SRoberto Vargas 12132aee841SRoberto Vargas #if !HW_ASSISTED_COHERENCY 12232aee841SRoberto Vargas #define ARM_SCMI_INSTANTIATE_LOCK DEFINE_BAKERY_LOCK(arm_scmi_lock) 12332aee841SRoberto Vargas #else 12432aee841SRoberto Vargas #define ARM_SCMI_INSTANTIATE_LOCK spinlock_t arm_scmi_lock 12532aee841SRoberto Vargas #endif 12632aee841SRoberto Vargas #define ARM_SCMI_LOCK_GET_INSTANCE (&arm_scmi_lock) 12732aee841SRoberto Vargas 128b4315306SDan Handley /* 129b4315306SDan Handley * These are wrapper macros to the Coherent Memory Bakery Lock API. 130b4315306SDan Handley */ 131b4315306SDan Handley #define arm_lock_init() bakery_lock_init(&arm_lock) 132b4315306SDan Handley #define arm_lock_get() bakery_lock_get(&arm_lock) 133b4315306SDan Handley #define arm_lock_release() bakery_lock_release(&arm_lock) 134b4315306SDan Handley 135b4315306SDan Handley #else 136b4315306SDan Handley 137b4315306SDan Handley /* 1386f249345SYatharth Kochar * Empty macros for all other BL stages other than BL31 and BL32 139b4315306SDan Handley */ 14019583169SJeenu Viswambharan #define ARM_INSTANTIATE_LOCK static int arm_lock __unused 141c04a3b6cSSoby Mathew #define ARM_LOCK_GET_INSTANCE 0 142b4315306SDan Handley #define arm_lock_init() 143b4315306SDan Handley #define arm_lock_get() 144b4315306SDan Handley #define arm_lock_release() 145b4315306SDan Handley 146402b3cf8SJulius Werner #endif /* defined(IMAGE_BL31) || (!defined(__aarch64__) && defined(IMAGE_BL32)) */ 147b4315306SDan Handley 1482204afdeSSoby Mathew #if ARM_RECOM_STATE_ID_ENC 1492204afdeSSoby Mathew /* 1502204afdeSSoby Mathew * Macros used to parse state information from State-ID if it is using the 1512204afdeSSoby Mathew * recommended encoding for State-ID. 1522204afdeSSoby Mathew */ 1532204afdeSSoby Mathew #define ARM_LOCAL_PSTATE_WIDTH 4 1542204afdeSSoby Mathew #define ARM_LOCAL_PSTATE_MASK ((1 << ARM_LOCAL_PSTATE_WIDTH) - 1) 1552204afdeSSoby Mathew 1560a9c244bSJayanth Dodderi Chidanand /* Last in Level for the OS-initiated */ 157e75cc247SWing Li #define ARM_LAST_AT_PLVL_MASK (ARM_LOCAL_PSTATE_MASK << \ 158e75cc247SWing Li (ARM_LOCAL_PSTATE_WIDTH * \ 159e75cc247SWing Li (PLAT_MAX_PWR_LVL + 1))) 160e75cc247SWing Li 1612204afdeSSoby Mathew /* Macros to construct the composite power state */ 1622204afdeSSoby Mathew 1632204afdeSSoby Mathew /* Make composite power state parameter till power level 0 */ 1642204afdeSSoby Mathew #if PSCI_EXTENDED_STATE_ID 1652204afdeSSoby Mathew 1662204afdeSSoby Mathew #define arm_make_pwrstate_lvl0(lvl0_state, pwr_lvl, type) \ 1672204afdeSSoby Mathew (((lvl0_state) << PSTATE_ID_SHIFT) | ((type) << PSTATE_TYPE_SHIFT)) 1682204afdeSSoby Mathew #else 1692204afdeSSoby Mathew #define arm_make_pwrstate_lvl0(lvl0_state, pwr_lvl, type) \ 1702204afdeSSoby Mathew (((lvl0_state) << PSTATE_ID_SHIFT) | \ 1712204afdeSSoby Mathew ((pwr_lvl) << PSTATE_PWR_LVL_SHIFT) | \ 1722204afdeSSoby Mathew ((type) << PSTATE_TYPE_SHIFT)) 1732204afdeSSoby Mathew #endif /* __PSCI_EXTENDED_STATE_ID__ */ 1742204afdeSSoby Mathew 1752204afdeSSoby Mathew /* Make composite power state parameter till power level 1 */ 1762204afdeSSoby Mathew #define arm_make_pwrstate_lvl1(lvl1_state, lvl0_state, pwr_lvl, type) \ 1772204afdeSSoby Mathew (((lvl1_state) << ARM_LOCAL_PSTATE_WIDTH) | \ 1782204afdeSSoby Mathew arm_make_pwrstate_lvl0(lvl0_state, pwr_lvl, type)) 1792204afdeSSoby Mathew 1805f3a6030SSoby Mathew /* Make composite power state parameter till power level 2 */ 1815f3a6030SSoby Mathew #define arm_make_pwrstate_lvl2(lvl2_state, lvl1_state, lvl0_state, pwr_lvl, type) \ 1825f3a6030SSoby Mathew (((lvl2_state) << (ARM_LOCAL_PSTATE_WIDTH * 2)) | \ 1835f3a6030SSoby Mathew arm_make_pwrstate_lvl1(lvl1_state, lvl0_state, pwr_lvl, type)) 1845f3a6030SSoby Mathew 1852204afdeSSoby Mathew #endif /* __ARM_RECOM_STATE_ID_ENC__ */ 1862204afdeSSoby Mathew 187b10d4499SJeenu Viswambharan /* ARM State switch error codes */ 188b10d4499SJeenu Viswambharan #define STATE_SW_E_PARAM (-2) 189b10d4499SJeenu Viswambharan #define STATE_SW_E_DENIED (-3) 190b4315306SDan Handley 191a6ffddecSMax Shvetsov /* plat_get_rotpk_info() flags */ 192a6ffddecSMax Shvetsov #define ARM_ROTPK_REGS_ID 1 193a6ffddecSMax Shvetsov #define ARM_ROTPK_DEVEL_RSA_ID 2 194a6ffddecSMax Shvetsov #define ARM_ROTPK_DEVEL_ECDSA_ID 3 1955f899286Slaurenw-arm #define ARM_ROTPK_DEVEL_FULL_DEV_RSA_KEY_ID 4 196b8ae6890Slaurenw-arm #define ARM_ROTPK_DEVEL_FULL_DEV_ECDSA_KEY_ID 5 197b8ae6890Slaurenw-arm 198b8ae6890Slaurenw-arm #define ARM_USE_DEVEL_ROTPK \ 199b8ae6890Slaurenw-arm (ARM_ROTPK_LOCATION_ID == ARM_ROTPK_DEVEL_RSA_ID) || \ 200b8ae6890Slaurenw-arm (ARM_ROTPK_LOCATION_ID == ARM_ROTPK_DEVEL_ECDSA_ID) || \ 201b8ae6890Slaurenw-arm (ARM_ROTPK_LOCATION_ID == ARM_ROTPK_DEVEL_FULL_DEV_RSA_KEY_ID) || \ 202b8ae6890Slaurenw-arm (ARM_ROTPK_LOCATION_ID == ARM_ROTPK_DEVEL_FULL_DEV_ECDSA_KEY_ID) 2030e753437SManish V Badarkhe 204b4315306SDan Handley /* IO storage utility functions */ 20597399821SLouis Mayencourt int arm_io_setup(void); 206b4315306SDan Handley 207ef1daa42SManish V Badarkhe /* Set image specification in IO block policy */ 2082f1177b2SManish V Badarkhe int arm_set_image_source(unsigned int image_id, const char *part_name, 2092f1177b2SManish V Badarkhe uintptr_t *dev_handle, uintptr_t *image_spec); 2102f1177b2SManish V Badarkhe void arm_set_fip_addr(uint32_t active_fw_bank_idx); 211ef1daa42SManish V Badarkhe 212b4315306SDan Handley /* Security utility functions */ 2134ed16765SSuyash Pathak void arm_tzc400_setup(uintptr_t tzc_base, 2144ed16765SSuyash Pathak const arm_tzc_regions_info_t *tzc_regions); 215618f0feeSVikram Kanigiri struct tzc_dmc500_driver_data; 21623411d2cSSummer Qin void arm_tzc_dmc500_setup(struct tzc_dmc500_driver_data *plat_driver_data, 21723411d2cSSummer Qin const arm_tzc_regions_info_t *tzc_regions); 218b4315306SDan Handley 21988a0523eSAntonio Nino Diaz /* Console utility functions */ 22088a0523eSAntonio Nino Diaz void arm_console_boot_init(void); 22188a0523eSAntonio Nino Diaz void arm_console_boot_end(void); 22288a0523eSAntonio Nino Diaz void arm_console_runtime_init(void); 22388a0523eSAntonio Nino Diaz void arm_console_runtime_end(void); 22488a0523eSAntonio Nino Diaz 225c1bb8a05SSoby Mathew /* Systimer utility function */ 226c1bb8a05SSoby Mathew void arm_configure_sys_timer(void); 227c1bb8a05SSoby Mathew 228b4315306SDan Handley /* PM utility functions */ 22938dce70fSSoby Mathew int arm_validate_power_state(unsigned int power_state, 23038dce70fSSoby Mathew psci_power_state_t *req_state); 23171e7a4e5SJeenu Viswambharan int arm_validate_psci_entrypoint(uintptr_t entrypoint); 232f9e858b1SSoby Mathew int arm_validate_ns_entrypoint(uintptr_t entrypoint); 233e35a3fb5SSoby Mathew void arm_system_pwr_domain_save(void); 234c1bb8a05SSoby Mathew void arm_system_pwr_domain_resume(void); 235dc6aad2eSRoberto Vargas int arm_psci_read_mem_protect(int *enabled); 236f145403cSRoberto Vargas int arm_nor_psci_write_mem_protect(int val); 237638b034cSRoberto Vargas void arm_nor_psci_do_static_mem_protect(void); 238638b034cSRoberto Vargas void arm_nor_psci_do_dyn_mem_protect(void); 239f145403cSRoberto Vargas int arm_psci_mem_protect_chk(uintptr_t base, u_register_t length); 24038dce70fSSoby Mathew 24138dce70fSSoby Mathew /* Topology utility function */ 24238dce70fSSoby Mathew int arm_check_mpidr(u_register_t mpidr); 243b4315306SDan Handley 244b4315306SDan Handley /* BL1 utility functions */ 245b4315306SDan Handley void arm_bl1_early_platform_setup(void); 246b4315306SDan Handley void arm_bl1_platform_setup(void); 247b4315306SDan Handley void arm_bl1_plat_arch_setup(void); 248b4315306SDan Handley 249b4315306SDan Handley /* BL2 utility functions */ 25082869675SManish V Badarkhe void arm_bl2_early_platform_setup(uintptr_t fw_config, struct meminfo *mem_layout); 251b4315306SDan Handley void arm_bl2_platform_setup(void); 252b4315306SDan Handley void arm_bl2_plat_arch_setup(void); 253b4315306SDan Handley uint32_t arm_get_spsr_for_bl32_entry(void); 254b4315306SDan Handley uint32_t arm_get_spsr_for_bl33_entry(void); 255609e053cSAmbroise Vincent int arm_bl2_plat_handle_post_image_load(unsigned int image_id); 25607570d59SYatharth Kochar int arm_bl2_handle_post_image_load(unsigned int image_id); 2575b8d50e4SSathees Balya struct bl_params *arm_get_next_bl_params(void); 258a5566f65SHarrison Mutai void arm_bl2_setup_next_ep_info(bl_mem_params_node_t *next_param_node); 259b4315306SDan Handley 26081528dbcSRoberto Vargas /* BL2 at EL3 functions */ 26181528dbcSRoberto Vargas void arm_bl2_el3_early_platform_setup(void); 26281528dbcSRoberto Vargas void arm_bl2_el3_plat_arch_setup(void); 26381528dbcSRoberto Vargas 264dcda29f6SYatharth Kochar /* BL2U utility functions */ 265dcda29f6SYatharth Kochar void arm_bl2u_early_platform_setup(struct meminfo *mem_layout, 266dcda29f6SYatharth Kochar void *plat_info); 267dcda29f6SYatharth Kochar void arm_bl2u_platform_setup(void); 268dcda29f6SYatharth Kochar void arm_bl2u_plat_arch_setup(void); 269dcda29f6SYatharth Kochar 270d178637dSJuan Castillo /* BL31 utility functions */ 271a5566f65SHarrison Mutai #if TRANSFER_LIST 272a5566f65SHarrison Mutai void arm_bl31_early_platform_setup(u_register_t arg0, u_register_t arg1, 273a5566f65SHarrison Mutai u_register_t arg2, u_register_t arg3); 274a5566f65SHarrison Mutai #else 2750c306cc0SSoby Mathew void arm_bl31_early_platform_setup(void *from_bl2, uintptr_t soc_fw_config, 2760c306cc0SSoby Mathew uintptr_t hw_config, void *plat_params_from_bl2); 277a5566f65SHarrison Mutai #endif 278b4315306SDan Handley void arm_bl31_platform_setup(void); 279080225daSSoby Mathew void arm_bl31_plat_runtime_setup(void); 280b4315306SDan Handley void arm_bl31_plat_arch_setup(void); 281b4315306SDan Handley 282a5566f65SHarrison Mutai /* Firmware Handoff utility functions */ 283a5566f65SHarrison Mutai void arm_transfer_list_dyn_cfg_init(struct transfer_list_header *secure_tl); 284a5566f65SHarrison Mutai void arm_transfer_list_populate_ep_info(bl_mem_params_node_t *next_param_node, 285a5566f65SHarrison Mutai struct transfer_list_header *secure_tl, 286a5566f65SHarrison Mutai struct transfer_list_header *ns_tl); 287a5566f65SHarrison Mutai void arm_transfer_list_copy_hw_config(struct transfer_list_header *secure_tl, 288a5566f65SHarrison Mutai struct transfer_list_header *ns_tl); 289a5566f65SHarrison Mutai 290b4315306SDan Handley /* TSP utility functions */ 291b4315306SDan Handley void arm_tsp_early_platform_setup(void); 292b4315306SDan Handley 293181bbd41SSoby Mathew /* SP_MIN utility functions */ 2940c306cc0SSoby Mathew void arm_sp_min_early_platform_setup(void *from_bl2, uintptr_t tos_fw_config, 2950c306cc0SSoby Mathew uintptr_t hw_config, void *plat_params_from_bl2); 29621568304SDimitris Papastamos void arm_sp_min_plat_runtime_setup(void); 29726d1e0c3SMadhukar Pappireddy void arm_sp_min_plat_arch_setup(void); 298181bbd41SSoby Mathew 299436223deSYatharth Kochar /* FIP TOC validity check */ 300d6dcbcadSLouis Mayencourt bool arm_io_is_toc_valid(void); 301b4315306SDan Handley 302c228956aSSoby Mathew /* Utility functions for Dynamic Config */ 3033b48ca17SChris Kay 304ba597da7SJohn Tsichritzis void arm_bl1_set_mbedtls_heap(void); 305ba597da7SJohn Tsichritzis int arm_get_mbedtls_heap(void **heap_addr, size_t *heap_size); 306c228956aSSoby Mathew 3073b48ca17SChris Kay #if IMAGE_BL2 3083b48ca17SChris Kay void arm_bl2_dyn_cfg_init(void); 3093b48ca17SChris Kay #endif /* IMAGE_BL2 */ 3103b48ca17SChris Kay 3110ab49645SAlexei Fedorov #if MEASURED_BOOT 3121f47a713STamas Ban #if DICE_PROTECTION_ENVIRONMENT 3131f47a713STamas Ban int arm_set_nt_fw_info(int *ctx_handle); 3141f47a713STamas Ban int arm_set_tb_fw_info(int *ctx_handle); 3151f47a713STamas Ban int arm_get_tb_fw_info(int *ctx_handle); 3161f47a713STamas Ban #else 3171f47a713STamas Ban /* Specific to event log backend */ 318efa65218SManish V Badarkhe int arm_set_tos_fw_info(uintptr_t log_addr, size_t log_size); 319efa65218SManish V Badarkhe int arm_set_nt_fw_info( 3207b4e1fbbSAlexei Fedorov /* 3217b4e1fbbSAlexei Fedorov * Currently OP-TEE does not support reading DTBs from Secure memory 3227b4e1fbbSAlexei Fedorov * and this option should be removed when feature is supported. 3237b4e1fbbSAlexei Fedorov */ 3247b4e1fbbSAlexei Fedorov #ifdef SPD_opteed 3257b4e1fbbSAlexei Fedorov uintptr_t log_addr, 3260ab49645SAlexei Fedorov #endif 3277b4e1fbbSAlexei Fedorov size_t log_size, uintptr_t *ns_log_addr); 3281cf3e2f0SManish V Badarkhe int arm_set_tb_fw_info(uintptr_t log_addr, size_t log_size, 3291cf3e2f0SManish V Badarkhe size_t log_max_size); 3301cf3e2f0SManish V Badarkhe int arm_get_tb_fw_info(uint64_t *log_addr, size_t *log_size, 3311cf3e2f0SManish V Badarkhe size_t *log_max_size); 3321f47a713STamas Ban #endif /* DICE_PROTECTION_ENVIRONMENT */ 3337b4e1fbbSAlexei Fedorov #endif /* MEASURED_BOOT */ 3340ab49645SAlexei Fedorov 335b4315306SDan Handley /* 336cb4adb0dSDaniel Boulby * Free the memory storing initialization code only used during an images boot 337cb4adb0dSDaniel Boulby * time so it can be reclaimed for runtime data 338cb4adb0dSDaniel Boulby */ 339cb4adb0dSDaniel Boulby void arm_free_init_memory(void); 340cb4adb0dSDaniel Boulby 341cb4adb0dSDaniel Boulby /* 34260e8f3cfSPetre-Ionut Tudor * Make the higher level translation tables read-only 34360e8f3cfSPetre-Ionut Tudor */ 34460e8f3cfSPetre-Ionut Tudor void arm_xlat_make_tables_readonly(void); 34560e8f3cfSPetre-Ionut Tudor 34660e8f3cfSPetre-Ionut Tudor /* 347b4315306SDan Handley * Mandatory functions required in ARM standard platforms 348b4315306SDan Handley */ 3490108047aSSoby Mathew unsigned int plat_arm_get_cluster_core_count(u_register_t mpidr); 35027573c59SAchin Gupta void plat_arm_gic_driver_init(void); 351b4315306SDan Handley void plat_arm_gic_init(void); 35227573c59SAchin Gupta void plat_arm_gic_cpuif_enable(void); 35327573c59SAchin Gupta void plat_arm_gic_cpuif_disable(void); 354d17b953aSJeenu Viswambharan void plat_arm_gic_redistif_on(void); 355d17b953aSJeenu Viswambharan void plat_arm_gic_redistif_off(void); 35627573c59SAchin Gupta void plat_arm_gic_pcpu_init(void); 357e35a3fb5SSoby Mathew void plat_arm_gic_save(void); 358e35a3fb5SSoby Mathew void plat_arm_gic_resume(void); 359b4315306SDan Handley void plat_arm_security_setup(void); 360b4315306SDan Handley void plat_arm_pwrc_setup(void); 3616355f234SVikram Kanigiri void plat_arm_interconnect_init(void); 3626355f234SVikram Kanigiri void plat_arm_interconnect_enter_coherency(void); 3636355f234SVikram Kanigiri void plat_arm_interconnect_exit_coherency(void); 3642a246d2eSDimitris Papastamos void plat_arm_program_trusted_mailbox(uintptr_t address); 365d6dcbcadSLouis Mayencourt bool plat_arm_bl1_fwu_needed(void); 36637b70031SAmbroise Vincent __dead2 void plat_arm_error_handler(int err); 367586f60ccSManish V Badarkhe __dead2 void plat_arm_system_reset(void); 368b4315306SDan Handley 36974c21244SVijayenthiran Subramaniam /* 370a6ffddecSMax Shvetsov * Optional functions in ARM standard platforms 37174c21244SVijayenthiran Subramaniam */ 37274c21244SVijayenthiran Subramaniam void plat_arm_override_gicr_frames(const uintptr_t *plat_gicr_frames); 37388005701SSandrine Bailleux int arm_get_rotpk_info(void *cookie, void **key_ptr, unsigned int *key_len, 374a6ffddecSMax Shvetsov unsigned int *flags); 375a6ffddecSMax Shvetsov int arm_get_rotpk_info_regs(void **key_ptr, unsigned int *key_len, 376a6ffddecSMax Shvetsov unsigned int *flags); 377a6ffddecSMax Shvetsov int arm_get_rotpk_info_cc(void **key_ptr, unsigned int *key_len, 378a6ffddecSMax Shvetsov unsigned int *flags); 379a6ffddecSMax Shvetsov int arm_get_rotpk_info_dev(void **key_ptr, unsigned int *key_len, 380a6ffddecSMax Shvetsov unsigned int *flags); 38174c21244SVijayenthiran Subramaniam 382d8d6cf24SSummer Qin #if ARM_PLAT_MT 383d8d6cf24SSummer Qin unsigned int plat_arm_get_cpu_pe_count(u_register_t mpidr); 384d8d6cf24SSummer Qin #endif 385d8d6cf24SSummer Qin 386*e6ae019aSArvind Ram Prakash unsigned int plat_cluster_id_by_mpidr(u_register_t mpidr); 387*e6ae019aSArvind Ram Prakash 388a8aa7fecSYatharth Kochar /* 389a8aa7fecSYatharth Kochar * This function is called after loading SCP_BL2 image and it is used to perform 390a8aa7fecSYatharth Kochar * any platform-specific actions required to handle the SCP firmware. 391a8aa7fecSYatharth Kochar */ 392a8aa7fecSYatharth Kochar int plat_arm_bl2_handle_scp_bl2(struct image_info *scp_bl2_image_info); 393a8aa7fecSYatharth Kochar 394b4315306SDan Handley /* 395b4315306SDan Handley * Optional functions required in ARM standard platforms 396b4315306SDan Handley */ 397b4315306SDan Handley void plat_arm_io_setup(void); 398b4315306SDan Handley int plat_arm_get_alt_image_source( 39916948ae1SJuan Castillo unsigned int image_id, 40016948ae1SJuan Castillo uintptr_t *dev_handle, 40116948ae1SJuan Castillo uintptr_t *image_spec); 40238dce70fSSoby Mathew unsigned int plat_arm_calc_core_pos(u_register_t mpidr); 40365cb1c4cSVikram Kanigiri const mmap_region_t *plat_arm_get_mmap(void); 404b4315306SDan Handley 40586e4859aSRohit Mathew const arm_gpt_info_t *plat_arm_get_gpt_info(void); 406341df6afSRohit Mathew void arm_gpt_setup(void); 40786e4859aSRohit Mathew 4085486a965SSoby Mathew /* Allow platform to override psci_pm_ops during runtime */ 4095486a965SSoby Mathew const plat_psci_ops_t *plat_arm_psci_override_pm_ops(plat_psci_ops_t *ops); 4105486a965SSoby Mathew 411b10d4499SJeenu Viswambharan /* Execution state switch in ARM platforms */ 412b10d4499SJeenu Viswambharan int arm_execution_state_switch(unsigned int smc_fid, 413b10d4499SJeenu Viswambharan uint32_t pc_hi, 414b10d4499SJeenu Viswambharan uint32_t pc_lo, 415b10d4499SJeenu Viswambharan uint32_t cookie_hi, 416b10d4499SJeenu Viswambharan uint32_t cookie_lo, 417b10d4499SJeenu Viswambharan void *handle); 418b10d4499SJeenu Viswambharan 4190ed8c001SSoby Mathew /* Optional functions for SP_MIN */ 4200ed8c001SSoby Mathew void plat_arm_sp_min_early_platform_setup(u_register_t arg0, u_register_t arg1, 4210ed8c001SSoby Mathew u_register_t arg2, u_register_t arg3); 4220ed8c001SSoby Mathew 4231af540efSRoberto Vargas /* global variables */ 4241af540efSRoberto Vargas extern plat_psci_ops_t plat_arm_psci_pm_ops; 4251af540efSRoberto Vargas extern const mmap_region_t plat_arm_mmap[]; 426ecd62429SJeenu Viswambharan extern const unsigned int arm_pm_idle_states[]; 4271af540efSRoberto Vargas 428b0c97dafSAditya Angadi /* secure watchdog */ 429b0c97dafSAditya Angadi void plat_arm_secure_wdt_start(void); 430b0c97dafSAditya Angadi void plat_arm_secure_wdt_stop(void); 43128b2d86cSMadhukar Pappireddy void plat_arm_secure_wdt_refresh(void); 432b0c97dafSAditya Angadi 4330e753437SManish V Badarkhe /* Get SOC-ID of ARM platform */ 4340e753437SManish V Badarkhe uint32_t plat_arm_get_soc_id(void); 4350e753437SManish V Badarkhe 43615b94cc1SAntonio Nino Diaz #endif /* PLAT_ARM_H */ 437