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 \ 7223411d2cSSummer Qin {ARM_NS_DRAM1_BASE, ARM_NS_DRAM1_END, ARM_TZC_NS_DRAM_S_ACCESS, \ 7323411d2cSSummer Qin PLAT_ARM_TZC_NS_DEV_ACCESS}, \ 7419228752SOlivier Deprez {ARM_AP_TZC_DRAM1_BASE, (PLAT_SP_IMAGE_NS_BUF_BASE - 1), \ 7519228752SOlivier Deprez TZC_REGION_S_RDWR, 0}, \ 760560efb9SArd Biesheuvel {PLAT_SP_IMAGE_NS_BUF_BASE, (PLAT_SP_IMAGE_NS_BUF_BASE + \ 7719228752SOlivier Deprez PLAT_SP_IMAGE_NS_BUF_SIZE - 1), TZC_REGION_S_NONE, \ 7819228752SOlivier Deprez PLAT_ARM_TZC_NS_DEV_ACCESS}, \ 7919228752SOlivier Deprez {PLAT_SP_IMAGE_STACK_BASE, ARM_EL3_TZC_DRAM1_END, \ 8019228752SOlivier Deprez TZC_REGION_S_RDWR, 0}, \ 8119228752SOlivier Deprez {ARM_DRAM2_BASE, ARM_DRAM2_END, ARM_TZC_NS_DRAM_S_ACCESS, \ 8223411d2cSSummer Qin PLAT_ARM_TZC_NS_DEV_ACCESS} 8323411d2cSSummer Qin 84c8720729SZelalem Aweke #elif ENABLE_RME 85d836df71SManish V Badarkhe #if (defined(SPD_tspd) || defined(SPD_opteed) || defined(SPD_spmd)) && \ 86d836df71SManish V Badarkhe MEASURED_BOOT 87c8720729SZelalem Aweke #define ARM_TZC_REGIONS_DEF \ 88d836df71SManish V Badarkhe ARM_TZC_RME_REGIONS_DEF, \ 89d836df71SManish V Badarkhe {ARM_EVENT_LOG_DRAM1_BASE, ARM_EVENT_LOG_DRAM1_END, \ 90d836df71SManish V Badarkhe TZC_REGION_S_RDWR, 0} 91d836df71SManish V Badarkhe #else 92d836df71SManish V Badarkhe #define ARM_TZC_REGIONS_DEF \ 93d836df71SManish V Badarkhe ARM_TZC_RME_REGIONS_DEF 94d836df71SManish V Badarkhe #endif 95c8720729SZelalem Aweke 9623411d2cSSummer Qin #else 9723411d2cSSummer Qin #define ARM_TZC_REGIONS_DEF \ 98c8720729SZelalem Aweke {ARM_AP_TZC_DRAM1_BASE, ARM_EL3_TZC_DRAM1_END + ARM_L1_GPT_SIZE,\ 9923411d2cSSummer Qin TZC_REGION_S_RDWR, 0}, \ 10023411d2cSSummer Qin {ARM_NS_DRAM1_BASE, ARM_NS_DRAM1_END, ARM_TZC_NS_DRAM_S_ACCESS, \ 10123411d2cSSummer Qin PLAT_ARM_TZC_NS_DEV_ACCESS}, \ 10223411d2cSSummer Qin {ARM_DRAM2_BASE, ARM_DRAM2_END, ARM_TZC_NS_DRAM_S_ACCESS, \ 10323411d2cSSummer Qin PLAT_ARM_TZC_NS_DEV_ACCESS} 10423411d2cSSummer Qin #endif 10523411d2cSSummer Qin 106b4315306SDan Handley #define ARM_CASSERT_MMAP \ 107053b4f92SChris Kay CASSERT((ARRAY_SIZE(plat_arm_mmap) - 1) <= PLAT_ARM_MMAP_ENTRIES, \ 108053b4f92SChris Kay assert_plat_arm_mmap_mismatch); \ 109053b4f92SChris Kay CASSERT((PLAT_ARM_MMAP_ENTRIES + ARM_BL_REGIONS) \ 110b4315306SDan Handley <= MAX_MMAP_REGIONS, \ 111b4315306SDan Handley assert_max_mmap_regions); 112b4315306SDan Handley 1131eb735d7SRoberto Vargas void arm_setup_romlib(void); 1141eb735d7SRoberto Vargas 115402b3cf8SJulius Werner #if defined(IMAGE_BL31) || (!defined(__aarch64__) && defined(IMAGE_BL32)) 116b4315306SDan Handley /* 117b4315306SDan Handley * Use this macro to instantiate lock before it is used in below 118b4315306SDan Handley * arm_lock_xxx() macros 119b4315306SDan Handley */ 1201931d1d7SSandrine Bailleux #define ARM_INSTANTIATE_LOCK static DEFINE_BAKERY_LOCK(arm_lock) 121c04a3b6cSSoby Mathew #define ARM_LOCK_GET_INSTANCE (&arm_lock) 12232aee841SRoberto Vargas 12332aee841SRoberto Vargas #if !HW_ASSISTED_COHERENCY 12432aee841SRoberto Vargas #define ARM_SCMI_INSTANTIATE_LOCK DEFINE_BAKERY_LOCK(arm_scmi_lock) 12532aee841SRoberto Vargas #else 12632aee841SRoberto Vargas #define ARM_SCMI_INSTANTIATE_LOCK spinlock_t arm_scmi_lock 12732aee841SRoberto Vargas #endif 12832aee841SRoberto Vargas #define ARM_SCMI_LOCK_GET_INSTANCE (&arm_scmi_lock) 12932aee841SRoberto Vargas 130b4315306SDan Handley /* 131b4315306SDan Handley * These are wrapper macros to the Coherent Memory Bakery Lock API. 132b4315306SDan Handley */ 133b4315306SDan Handley #define arm_lock_init() bakery_lock_init(&arm_lock) 134b4315306SDan Handley #define arm_lock_get() bakery_lock_get(&arm_lock) 135b4315306SDan Handley #define arm_lock_release() bakery_lock_release(&arm_lock) 136b4315306SDan Handley 137b4315306SDan Handley #else 138b4315306SDan Handley 139b4315306SDan Handley /* 1406f249345SYatharth Kochar * Empty macros for all other BL stages other than BL31 and BL32 141b4315306SDan Handley */ 14219583169SJeenu Viswambharan #define ARM_INSTANTIATE_LOCK static int arm_lock __unused 143c04a3b6cSSoby Mathew #define ARM_LOCK_GET_INSTANCE 0 144b4315306SDan Handley #define arm_lock_init() 145b4315306SDan Handley #define arm_lock_get() 146b4315306SDan Handley #define arm_lock_release() 147b4315306SDan Handley 148402b3cf8SJulius Werner #endif /* defined(IMAGE_BL31) || (!defined(__aarch64__) && defined(IMAGE_BL32)) */ 149b4315306SDan Handley 1502204afdeSSoby Mathew #if ARM_RECOM_STATE_ID_ENC 1512204afdeSSoby Mathew /* 1522204afdeSSoby Mathew * Macros used to parse state information from State-ID if it is using the 1532204afdeSSoby Mathew * recommended encoding for State-ID. 1542204afdeSSoby Mathew */ 1552204afdeSSoby Mathew #define ARM_LOCAL_PSTATE_WIDTH 4 1562204afdeSSoby Mathew #define ARM_LOCAL_PSTATE_MASK ((1 << ARM_LOCAL_PSTATE_WIDTH) - 1) 1572204afdeSSoby Mathew 1580a9c244bSJayanth Dodderi Chidanand /* Last in Level for the OS-initiated */ 159e75cc247SWing Li #define ARM_LAST_AT_PLVL_MASK (ARM_LOCAL_PSTATE_MASK << \ 160e75cc247SWing Li (ARM_LOCAL_PSTATE_WIDTH * \ 161e75cc247SWing Li (PLAT_MAX_PWR_LVL + 1))) 162e75cc247SWing Li 1632204afdeSSoby Mathew /* Macros to construct the composite power state */ 1642204afdeSSoby Mathew 1652204afdeSSoby Mathew /* Make composite power state parameter till power level 0 */ 1662204afdeSSoby Mathew #if PSCI_EXTENDED_STATE_ID 1672204afdeSSoby Mathew 1682204afdeSSoby Mathew #define arm_make_pwrstate_lvl0(lvl0_state, pwr_lvl, type) \ 1692204afdeSSoby Mathew (((lvl0_state) << PSTATE_ID_SHIFT) | ((type) << PSTATE_TYPE_SHIFT)) 1702204afdeSSoby Mathew #else 1712204afdeSSoby Mathew #define arm_make_pwrstate_lvl0(lvl0_state, pwr_lvl, type) \ 1722204afdeSSoby Mathew (((lvl0_state) << PSTATE_ID_SHIFT) | \ 1732204afdeSSoby Mathew ((pwr_lvl) << PSTATE_PWR_LVL_SHIFT) | \ 1742204afdeSSoby Mathew ((type) << PSTATE_TYPE_SHIFT)) 1752204afdeSSoby Mathew #endif /* __PSCI_EXTENDED_STATE_ID__ */ 1762204afdeSSoby Mathew 1772204afdeSSoby Mathew /* Make composite power state parameter till power level 1 */ 1782204afdeSSoby Mathew #define arm_make_pwrstate_lvl1(lvl1_state, lvl0_state, pwr_lvl, type) \ 1792204afdeSSoby Mathew (((lvl1_state) << ARM_LOCAL_PSTATE_WIDTH) | \ 1802204afdeSSoby Mathew arm_make_pwrstate_lvl0(lvl0_state, pwr_lvl, type)) 1812204afdeSSoby Mathew 1825f3a6030SSoby Mathew /* Make composite power state parameter till power level 2 */ 1835f3a6030SSoby Mathew #define arm_make_pwrstate_lvl2(lvl2_state, lvl1_state, lvl0_state, pwr_lvl, type) \ 1845f3a6030SSoby Mathew (((lvl2_state) << (ARM_LOCAL_PSTATE_WIDTH * 2)) | \ 1855f3a6030SSoby Mathew arm_make_pwrstate_lvl1(lvl1_state, lvl0_state, pwr_lvl, type)) 1865f3a6030SSoby Mathew 1872204afdeSSoby Mathew #endif /* __ARM_RECOM_STATE_ID_ENC__ */ 1882204afdeSSoby Mathew 189b10d4499SJeenu Viswambharan /* ARM State switch error codes */ 190b10d4499SJeenu Viswambharan #define STATE_SW_E_PARAM (-2) 191b10d4499SJeenu Viswambharan #define STATE_SW_E_DENIED (-3) 192b4315306SDan Handley 193a6ffddecSMax Shvetsov /* plat_get_rotpk_info() flags */ 194a6ffddecSMax Shvetsov #define ARM_ROTPK_REGS_ID 1 195a6ffddecSMax Shvetsov #define ARM_ROTPK_DEVEL_RSA_ID 2 196a6ffddecSMax Shvetsov #define ARM_ROTPK_DEVEL_ECDSA_ID 3 1975f899286Slaurenw-arm #define ARM_ROTPK_DEVEL_FULL_DEV_RSA_KEY_ID 4 198b8ae6890Slaurenw-arm #define ARM_ROTPK_DEVEL_FULL_DEV_ECDSA_KEY_ID 5 199b8ae6890Slaurenw-arm 200b8ae6890Slaurenw-arm #define ARM_USE_DEVEL_ROTPK \ 201b8ae6890Slaurenw-arm (ARM_ROTPK_LOCATION_ID == ARM_ROTPK_DEVEL_RSA_ID) || \ 202b8ae6890Slaurenw-arm (ARM_ROTPK_LOCATION_ID == ARM_ROTPK_DEVEL_ECDSA_ID) || \ 203b8ae6890Slaurenw-arm (ARM_ROTPK_LOCATION_ID == ARM_ROTPK_DEVEL_FULL_DEV_RSA_KEY_ID) || \ 204b8ae6890Slaurenw-arm (ARM_ROTPK_LOCATION_ID == ARM_ROTPK_DEVEL_FULL_DEV_ECDSA_KEY_ID) 2050e753437SManish V Badarkhe 206b4315306SDan Handley /* IO storage utility functions */ 20797399821SLouis Mayencourt int arm_io_setup(void); 208b4315306SDan Handley 209ef1daa42SManish V Badarkhe /* Set image specification in IO block policy */ 2102f1177b2SManish V Badarkhe int arm_set_image_source(unsigned int image_id, const char *part_name, 2112f1177b2SManish V Badarkhe uintptr_t *dev_handle, uintptr_t *image_spec); 2122f1177b2SManish V Badarkhe void arm_set_fip_addr(uint32_t active_fw_bank_idx); 213ef1daa42SManish V Badarkhe 214b4315306SDan Handley /* Security utility functions */ 2154ed16765SSuyash Pathak void arm_tzc400_setup(uintptr_t tzc_base, 2164ed16765SSuyash Pathak const arm_tzc_regions_info_t *tzc_regions); 217618f0feeSVikram Kanigiri struct tzc_dmc500_driver_data; 21823411d2cSSummer Qin void arm_tzc_dmc500_setup(struct tzc_dmc500_driver_data *plat_driver_data, 21923411d2cSSummer Qin const arm_tzc_regions_info_t *tzc_regions); 220b4315306SDan Handley 22188a0523eSAntonio Nino Diaz /* Console utility functions */ 22288a0523eSAntonio Nino Diaz void arm_console_boot_init(void); 22388a0523eSAntonio Nino Diaz void arm_console_boot_end(void); 22488a0523eSAntonio Nino Diaz void arm_console_runtime_init(void); 22588a0523eSAntonio Nino Diaz void arm_console_runtime_end(void); 22688a0523eSAntonio Nino Diaz 227c1bb8a05SSoby Mathew /* Systimer utility function */ 228c1bb8a05SSoby Mathew void arm_configure_sys_timer(void); 229c1bb8a05SSoby Mathew 230b4315306SDan Handley /* PM utility functions */ 23138dce70fSSoby Mathew int arm_validate_power_state(unsigned int power_state, 23238dce70fSSoby Mathew psci_power_state_t *req_state); 23371e7a4e5SJeenu Viswambharan int arm_validate_psci_entrypoint(uintptr_t entrypoint); 234f9e858b1SSoby Mathew int arm_validate_ns_entrypoint(uintptr_t entrypoint); 235e35a3fb5SSoby Mathew void arm_system_pwr_domain_save(void); 236c1bb8a05SSoby Mathew void arm_system_pwr_domain_resume(void); 237dc6aad2eSRoberto Vargas int arm_psci_read_mem_protect(int *enabled); 238f145403cSRoberto Vargas int arm_nor_psci_write_mem_protect(int val); 239638b034cSRoberto Vargas void arm_nor_psci_do_static_mem_protect(void); 240638b034cSRoberto Vargas void arm_nor_psci_do_dyn_mem_protect(void); 241f145403cSRoberto Vargas int arm_psci_mem_protect_chk(uintptr_t base, u_register_t length); 24238dce70fSSoby Mathew 24338dce70fSSoby Mathew /* Topology utility function */ 24438dce70fSSoby Mathew int arm_check_mpidr(u_register_t mpidr); 245b4315306SDan Handley 246b4315306SDan Handley /* BL1 utility functions */ 247b4315306SDan Handley void arm_bl1_early_platform_setup(void); 248b4315306SDan Handley void arm_bl1_platform_setup(void); 249b4315306SDan Handley void arm_bl1_plat_arch_setup(void); 250b4315306SDan Handley 251b4315306SDan Handley /* BL2 utility functions */ 25282869675SManish V Badarkhe void arm_bl2_early_platform_setup(uintptr_t fw_config, struct meminfo *mem_layout); 253b4315306SDan Handley void arm_bl2_platform_setup(void); 254b4315306SDan Handley void arm_bl2_plat_arch_setup(void); 255b4315306SDan Handley uint32_t arm_get_spsr_for_bl32_entry(void); 256b4315306SDan Handley uint32_t arm_get_spsr_for_bl33_entry(void); 257609e053cSAmbroise Vincent int arm_bl2_plat_handle_post_image_load(unsigned int image_id); 25807570d59SYatharth Kochar int arm_bl2_handle_post_image_load(unsigned int image_id); 2595b8d50e4SSathees Balya struct bl_params *arm_get_next_bl_params(void); 260a5566f65SHarrison Mutai void arm_bl2_setup_next_ep_info(bl_mem_params_node_t *next_param_node); 261b4315306SDan Handley 26281528dbcSRoberto Vargas /* BL2 at EL3 functions */ 26381528dbcSRoberto Vargas void arm_bl2_el3_early_platform_setup(void); 26481528dbcSRoberto Vargas void arm_bl2_el3_plat_arch_setup(void); 26581528dbcSRoberto Vargas 266dcda29f6SYatharth Kochar /* BL2U utility functions */ 267dcda29f6SYatharth Kochar void arm_bl2u_early_platform_setup(struct meminfo *mem_layout, 268dcda29f6SYatharth Kochar void *plat_info); 269dcda29f6SYatharth Kochar void arm_bl2u_platform_setup(void); 270dcda29f6SYatharth Kochar void arm_bl2u_plat_arch_setup(void); 271dcda29f6SYatharth Kochar 272d178637dSJuan Castillo /* BL31 utility functions */ 273a5566f65SHarrison Mutai #if TRANSFER_LIST 274a5566f65SHarrison Mutai void arm_bl31_early_platform_setup(u_register_t arg0, u_register_t arg1, 275a5566f65SHarrison Mutai u_register_t arg2, u_register_t arg3); 276a5566f65SHarrison Mutai #else 2770c306cc0SSoby Mathew void arm_bl31_early_platform_setup(void *from_bl2, uintptr_t soc_fw_config, 2780c306cc0SSoby Mathew uintptr_t hw_config, void *plat_params_from_bl2); 279a5566f65SHarrison Mutai #endif 280b4315306SDan Handley void arm_bl31_platform_setup(void); 281080225daSSoby Mathew void arm_bl31_plat_runtime_setup(void); 282b4315306SDan Handley void arm_bl31_plat_arch_setup(void); 283b4315306SDan Handley 284a5566f65SHarrison Mutai /* Firmware Handoff utility functions */ 285a5566f65SHarrison Mutai void arm_transfer_list_dyn_cfg_init(struct transfer_list_header *secure_tl); 286a5566f65SHarrison Mutai void arm_transfer_list_populate_ep_info(bl_mem_params_node_t *next_param_node, 287*fe94a21aSHarrison Mutai struct transfer_list_header *secure_tl); 288a5566f65SHarrison Mutai 289b4315306SDan Handley /* TSP utility functions */ 290b4315306SDan Handley void arm_tsp_early_platform_setup(void); 291b4315306SDan Handley 292181bbd41SSoby Mathew /* SP_MIN utility functions */ 2930c306cc0SSoby Mathew void arm_sp_min_early_platform_setup(void *from_bl2, uintptr_t tos_fw_config, 2940c306cc0SSoby Mathew uintptr_t hw_config, void *plat_params_from_bl2); 29521568304SDimitris Papastamos void arm_sp_min_plat_runtime_setup(void); 29626d1e0c3SMadhukar Pappireddy void arm_sp_min_plat_arch_setup(void); 297181bbd41SSoby Mathew 298436223deSYatharth Kochar /* FIP TOC validity check */ 299d6dcbcadSLouis Mayencourt bool arm_io_is_toc_valid(void); 300b4315306SDan Handley 301c228956aSSoby Mathew /* Utility functions for Dynamic Config */ 3023b48ca17SChris Kay 303ba597da7SJohn Tsichritzis void arm_bl1_set_mbedtls_heap(void); 304ba597da7SJohn Tsichritzis int arm_get_mbedtls_heap(void **heap_addr, size_t *heap_size); 305c228956aSSoby Mathew 3063b48ca17SChris Kay #if IMAGE_BL2 3073b48ca17SChris Kay void arm_bl2_dyn_cfg_init(void); 3083b48ca17SChris Kay #endif /* IMAGE_BL2 */ 3093b48ca17SChris Kay 3100ab49645SAlexei Fedorov #if MEASURED_BOOT 3111f47a713STamas Ban #if DICE_PROTECTION_ENVIRONMENT 3121f47a713STamas Ban int arm_set_nt_fw_info(int *ctx_handle); 3131f47a713STamas Ban int arm_set_tb_fw_info(int *ctx_handle); 3141f47a713STamas Ban int arm_get_tb_fw_info(int *ctx_handle); 3151f47a713STamas Ban #else 3161f47a713STamas Ban /* Specific to event log backend */ 317efa65218SManish V Badarkhe int arm_set_tos_fw_info(uintptr_t log_addr, size_t log_size); 318efa65218SManish V Badarkhe int arm_set_nt_fw_info( 3197b4e1fbbSAlexei Fedorov /* 3207b4e1fbbSAlexei Fedorov * Currently OP-TEE does not support reading DTBs from Secure memory 3217b4e1fbbSAlexei Fedorov * and this option should be removed when feature is supported. 3227b4e1fbbSAlexei Fedorov */ 3237b4e1fbbSAlexei Fedorov #ifdef SPD_opteed 3247b4e1fbbSAlexei Fedorov uintptr_t log_addr, 3250ab49645SAlexei Fedorov #endif 3267b4e1fbbSAlexei Fedorov size_t log_size, uintptr_t *ns_log_addr); 3271cf3e2f0SManish V Badarkhe int arm_set_tb_fw_info(uintptr_t log_addr, size_t log_size, 3281cf3e2f0SManish V Badarkhe size_t log_max_size); 3291cf3e2f0SManish V Badarkhe int arm_get_tb_fw_info(uint64_t *log_addr, size_t *log_size, 3301cf3e2f0SManish V Badarkhe size_t *log_max_size); 3311f47a713STamas Ban #endif /* DICE_PROTECTION_ENVIRONMENT */ 3327b4e1fbbSAlexei Fedorov #endif /* MEASURED_BOOT */ 3330ab49645SAlexei Fedorov 334b4315306SDan Handley /* 335cb4adb0dSDaniel Boulby * Free the memory storing initialization code only used during an images boot 336cb4adb0dSDaniel Boulby * time so it can be reclaimed for runtime data 337cb4adb0dSDaniel Boulby */ 338cb4adb0dSDaniel Boulby void arm_free_init_memory(void); 339cb4adb0dSDaniel Boulby 340cb4adb0dSDaniel Boulby /* 34160e8f3cfSPetre-Ionut Tudor * Make the higher level translation tables read-only 34260e8f3cfSPetre-Ionut Tudor */ 34360e8f3cfSPetre-Ionut Tudor void arm_xlat_make_tables_readonly(void); 34460e8f3cfSPetre-Ionut Tudor 34560e8f3cfSPetre-Ionut Tudor /* 346b4315306SDan Handley * Mandatory functions required in ARM standard platforms 347b4315306SDan Handley */ 3480108047aSSoby Mathew unsigned int plat_arm_get_cluster_core_count(u_register_t mpidr); 34927573c59SAchin Gupta void plat_arm_gic_driver_init(void); 350b4315306SDan Handley void plat_arm_gic_init(void); 35127573c59SAchin Gupta void plat_arm_gic_cpuif_enable(void); 35227573c59SAchin Gupta void plat_arm_gic_cpuif_disable(void); 353d17b953aSJeenu Viswambharan void plat_arm_gic_redistif_on(void); 354d17b953aSJeenu Viswambharan void plat_arm_gic_redistif_off(void); 35527573c59SAchin Gupta void plat_arm_gic_pcpu_init(void); 356e35a3fb5SSoby Mathew void plat_arm_gic_save(void); 357e35a3fb5SSoby Mathew void plat_arm_gic_resume(void); 358b4315306SDan Handley void plat_arm_security_setup(void); 359b4315306SDan Handley void plat_arm_pwrc_setup(void); 3606355f234SVikram Kanigiri void plat_arm_interconnect_init(void); 3616355f234SVikram Kanigiri void plat_arm_interconnect_enter_coherency(void); 3626355f234SVikram Kanigiri void plat_arm_interconnect_exit_coherency(void); 3632a246d2eSDimitris Papastamos void plat_arm_program_trusted_mailbox(uintptr_t address); 364d6dcbcadSLouis Mayencourt bool plat_arm_bl1_fwu_needed(void); 36537b70031SAmbroise Vincent __dead2 void plat_arm_error_handler(int err); 366586f60ccSManish V Badarkhe __dead2 void plat_arm_system_reset(void); 367b4315306SDan Handley 36874c21244SVijayenthiran Subramaniam /* 369a6ffddecSMax Shvetsov * Optional functions in ARM standard platforms 37074c21244SVijayenthiran Subramaniam */ 37174c21244SVijayenthiran Subramaniam void plat_arm_override_gicr_frames(const uintptr_t *plat_gicr_frames); 37288005701SSandrine Bailleux int arm_get_rotpk_info(void *cookie, void **key_ptr, unsigned int *key_len, 373a6ffddecSMax Shvetsov unsigned int *flags); 374a6ffddecSMax Shvetsov int arm_get_rotpk_info_regs(void **key_ptr, unsigned int *key_len, 375a6ffddecSMax Shvetsov unsigned int *flags); 376a6ffddecSMax Shvetsov int arm_get_rotpk_info_cc(void **key_ptr, unsigned int *key_len, 377a6ffddecSMax Shvetsov unsigned int *flags); 378a6ffddecSMax Shvetsov int arm_get_rotpk_info_dev(void **key_ptr, unsigned int *key_len, 379a6ffddecSMax Shvetsov unsigned int *flags); 38074c21244SVijayenthiran Subramaniam 381d8d6cf24SSummer Qin #if ARM_PLAT_MT 382d8d6cf24SSummer Qin unsigned int plat_arm_get_cpu_pe_count(u_register_t mpidr); 383d8d6cf24SSummer Qin #endif 384d8d6cf24SSummer Qin 385e6ae019aSArvind Ram Prakash unsigned int plat_cluster_id_by_mpidr(u_register_t mpidr); 386e6ae019aSArvind Ram Prakash 387a8aa7fecSYatharth Kochar /* 388a8aa7fecSYatharth Kochar * This function is called after loading SCP_BL2 image and it is used to perform 389a8aa7fecSYatharth Kochar * any platform-specific actions required to handle the SCP firmware. 390a8aa7fecSYatharth Kochar */ 391a8aa7fecSYatharth Kochar int plat_arm_bl2_handle_scp_bl2(struct image_info *scp_bl2_image_info); 392a8aa7fecSYatharth Kochar 393b4315306SDan Handley /* 394b4315306SDan Handley * Optional functions required in ARM standard platforms 395b4315306SDan Handley */ 396b4315306SDan Handley void plat_arm_io_setup(void); 397b4315306SDan Handley int plat_arm_get_alt_image_source( 39816948ae1SJuan Castillo unsigned int image_id, 39916948ae1SJuan Castillo uintptr_t *dev_handle, 40016948ae1SJuan Castillo uintptr_t *image_spec); 40138dce70fSSoby Mathew unsigned int plat_arm_calc_core_pos(u_register_t mpidr); 40265cb1c4cSVikram Kanigiri const mmap_region_t *plat_arm_get_mmap(void); 403b4315306SDan Handley 40486e4859aSRohit Mathew const arm_gpt_info_t *plat_arm_get_gpt_info(void); 405341df6afSRohit Mathew void arm_gpt_setup(void); 40686e4859aSRohit Mathew 4075486a965SSoby Mathew /* Allow platform to override psci_pm_ops during runtime */ 4085486a965SSoby Mathew const plat_psci_ops_t *plat_arm_psci_override_pm_ops(plat_psci_ops_t *ops); 4095486a965SSoby Mathew 410b10d4499SJeenu Viswambharan /* Execution state switch in ARM platforms */ 411b10d4499SJeenu Viswambharan int arm_execution_state_switch(unsigned int smc_fid, 412b10d4499SJeenu Viswambharan uint32_t pc_hi, 413b10d4499SJeenu Viswambharan uint32_t pc_lo, 414b10d4499SJeenu Viswambharan uint32_t cookie_hi, 415b10d4499SJeenu Viswambharan uint32_t cookie_lo, 416b10d4499SJeenu Viswambharan void *handle); 417b10d4499SJeenu Viswambharan 4180ed8c001SSoby Mathew /* Optional functions for SP_MIN */ 4190ed8c001SSoby Mathew void plat_arm_sp_min_early_platform_setup(u_register_t arg0, u_register_t arg1, 4200ed8c001SSoby Mathew u_register_t arg2, u_register_t arg3); 4210ed8c001SSoby Mathew 4221af540efSRoberto Vargas /* global variables */ 4231af540efSRoberto Vargas extern plat_psci_ops_t plat_arm_psci_pm_ops; 4241af540efSRoberto Vargas extern const mmap_region_t plat_arm_mmap[]; 425ecd62429SJeenu Viswambharan extern const unsigned int arm_pm_idle_states[]; 4261af540efSRoberto Vargas 427b0c97dafSAditya Angadi /* secure watchdog */ 428b0c97dafSAditya Angadi void plat_arm_secure_wdt_start(void); 429b0c97dafSAditya Angadi void plat_arm_secure_wdt_stop(void); 43028b2d86cSMadhukar Pappireddy void plat_arm_secure_wdt_refresh(void); 431b0c97dafSAditya Angadi 4320e753437SManish V Badarkhe /* Get SOC-ID of ARM platform */ 4330e753437SManish V Badarkhe uint32_t plat_arm_get_soc_id(void); 4340e753437SManish V Badarkhe 43515b94cc1SAntonio Nino Diaz #endif /* PLAT_ARM_H */ 436