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 1209d40e0eSAntonio Nino Diaz #include <drivers/arm/tzc_common.h> 1309d40e0eSAntonio Nino Diaz #include <lib/bakery_lock.h> 1409d40e0eSAntonio Nino Diaz #include <lib/cassert.h> 1509d40e0eSAntonio Nino Diaz #include <lib/el3_runtime/cpu_data.h> 1686e4859aSRohit Mathew #include <lib/gpt_rme/gpt_rme.h> 1709d40e0eSAntonio Nino Diaz #include <lib/spinlock.h> 1809d40e0eSAntonio Nino Diaz #include <lib/utils_def.h> 1909d40e0eSAntonio Nino Diaz #include <lib/xlat_tables/xlat_tables_compat.h> 20b4315306SDan Handley 21afc931f5SSandrine Bailleux /******************************************************************************* 22afc931f5SSandrine Bailleux * Forward declarations 23afc931f5SSandrine Bailleux ******************************************************************************/ 24afc931f5SSandrine Bailleux struct meminfo; 25a8aa7fecSYatharth Kochar struct image_info; 26cab0b5b0SSoby Mathew struct bl_params; 27afc931f5SSandrine Bailleux 2823411d2cSSummer Qin typedef struct arm_tzc_regions_info { 2923411d2cSSummer Qin unsigned long long base; 3023411d2cSSummer Qin unsigned long long end; 31af6491f8SAntonio Nino Diaz unsigned int sec_attr; 3223411d2cSSummer Qin unsigned int nsaid_permissions; 3323411d2cSSummer Qin } arm_tzc_regions_info_t; 3423411d2cSSummer Qin 3586e4859aSRohit Mathew typedef struct arm_gpt_info { 3686e4859aSRohit Mathew pas_region_t *pas_region_base; 3786e4859aSRohit Mathew unsigned int pas_region_count; 3886e4859aSRohit Mathew uintptr_t l0_base; 3986e4859aSRohit Mathew uintptr_t l1_base; 4086e4859aSRohit Mathew size_t l0_size; 4186e4859aSRohit Mathew size_t l1_size; 4286e4859aSRohit Mathew gpccr_pps_e pps; 4386e4859aSRohit Mathew gpccr_pgs_e pgs; 4486e4859aSRohit Mathew } arm_gpt_info_t; 4586e4859aSRohit Mathew 4623411d2cSSummer Qin /******************************************************************************* 4723411d2cSSummer Qin * Default mapping definition of the TrustZone Controller for ARM standard 4823411d2cSSummer Qin * platforms. 4923411d2cSSummer Qin * Configure: 5023411d2cSSummer Qin * - Region 0 with no access; 5123411d2cSSummer Qin * - Region 1 with secure access only; 5223411d2cSSummer Qin * - the remaining DRAM regions access from the given Non-Secure masters. 5323411d2cSSummer Qin ******************************************************************************/ 54d836df71SManish V Badarkhe 55d836df71SManish V Badarkhe #if ENABLE_RME 56d836df71SManish V Badarkhe #define ARM_TZC_RME_REGIONS_DEF \ 57d836df71SManish V Badarkhe {ARM_AP_TZC_DRAM1_BASE, ARM_AP_TZC_DRAM1_END, TZC_REGION_S_RDWR, 0},\ 58d836df71SManish V Badarkhe {ARM_EL3_TZC_DRAM1_BASE, ARM_L1_GPT_END, TZC_REGION_S_RDWR, 0}, \ 59d836df71SManish V Badarkhe {ARM_NS_DRAM1_BASE, ARM_NS_DRAM1_END, ARM_TZC_NS_DRAM_S_ACCESS, \ 60d836df71SManish V Badarkhe PLAT_ARM_TZC_NS_DEV_ACCESS}, \ 61d836df71SManish V Badarkhe /* Realm and Shared area share the same PAS */ \ 62d836df71SManish V Badarkhe {ARM_REALM_BASE, ARM_EL3_RMM_SHARED_END, ARM_TZC_NS_DRAM_S_ACCESS, \ 63d836df71SManish V Badarkhe PLAT_ARM_TZC_NS_DEV_ACCESS}, \ 64d836df71SManish V Badarkhe {ARM_DRAM2_BASE, ARM_DRAM2_END, ARM_TZC_NS_DRAM_S_ACCESS, \ 65d836df71SManish V Badarkhe PLAT_ARM_TZC_NS_DEV_ACCESS} 66d836df71SManish V Badarkhe #endif 67d836df71SManish V Badarkhe 685df1dccdSNishant Sharma #if SPM_MM || (SPMC_AT_EL3 && SPMC_AT_EL3_SEL0_SP) 6923411d2cSSummer Qin #define ARM_TZC_REGIONS_DEF \ 70c8720729SZelalem Aweke {ARM_AP_TZC_DRAM1_BASE, ARM_EL3_TZC_DRAM1_END + ARM_L1_GPT_SIZE,\ 7123411d2cSSummer Qin TZC_REGION_S_RDWR, 0}, \ 7223411d2cSSummer Qin {ARM_NS_DRAM1_BASE, ARM_NS_DRAM1_END, ARM_TZC_NS_DRAM_S_ACCESS, \ 7323411d2cSSummer Qin PLAT_ARM_TZC_NS_DEV_ACCESS}, \ 7423411d2cSSummer Qin {ARM_DRAM2_BASE, ARM_DRAM2_END, ARM_TZC_NS_DRAM_S_ACCESS, \ 7523411d2cSSummer Qin PLAT_ARM_TZC_NS_DEV_ACCESS}, \ 760560efb9SArd Biesheuvel {PLAT_SP_IMAGE_NS_BUF_BASE, (PLAT_SP_IMAGE_NS_BUF_BASE + \ 770560efb9SArd Biesheuvel PLAT_SP_IMAGE_NS_BUF_SIZE) - 1, TZC_REGION_S_NONE, \ 7823411d2cSSummer Qin PLAT_ARM_TZC_NS_DEV_ACCESS} 7923411d2cSSummer Qin 80c8720729SZelalem Aweke #elif ENABLE_RME 81d836df71SManish V Badarkhe #if (defined(SPD_tspd) || defined(SPD_opteed) || defined(SPD_spmd)) && \ 82d836df71SManish V Badarkhe MEASURED_BOOT 83c8720729SZelalem Aweke #define ARM_TZC_REGIONS_DEF \ 84d836df71SManish V Badarkhe ARM_TZC_RME_REGIONS_DEF, \ 85d836df71SManish V Badarkhe {ARM_EVENT_LOG_DRAM1_BASE, ARM_EVENT_LOG_DRAM1_END, \ 86d836df71SManish V Badarkhe TZC_REGION_S_RDWR, 0} 87d836df71SManish V Badarkhe #else 88d836df71SManish V Badarkhe #define ARM_TZC_REGIONS_DEF \ 89d836df71SManish V Badarkhe ARM_TZC_RME_REGIONS_DEF 90d836df71SManish V Badarkhe #endif 91c8720729SZelalem Aweke 9223411d2cSSummer Qin #else 9323411d2cSSummer Qin #define ARM_TZC_REGIONS_DEF \ 94c8720729SZelalem Aweke {ARM_AP_TZC_DRAM1_BASE, ARM_EL3_TZC_DRAM1_END + ARM_L1_GPT_SIZE,\ 9523411d2cSSummer Qin TZC_REGION_S_RDWR, 0}, \ 9623411d2cSSummer Qin {ARM_NS_DRAM1_BASE, ARM_NS_DRAM1_END, ARM_TZC_NS_DRAM_S_ACCESS, \ 9723411d2cSSummer Qin PLAT_ARM_TZC_NS_DEV_ACCESS}, \ 9823411d2cSSummer Qin {ARM_DRAM2_BASE, ARM_DRAM2_END, ARM_TZC_NS_DRAM_S_ACCESS, \ 9923411d2cSSummer Qin PLAT_ARM_TZC_NS_DEV_ACCESS} 10023411d2cSSummer Qin #endif 10123411d2cSSummer Qin 102b4315306SDan Handley #define ARM_CASSERT_MMAP \ 103053b4f92SChris Kay CASSERT((ARRAY_SIZE(plat_arm_mmap) - 1) <= PLAT_ARM_MMAP_ENTRIES, \ 104053b4f92SChris Kay assert_plat_arm_mmap_mismatch); \ 105053b4f92SChris Kay CASSERT((PLAT_ARM_MMAP_ENTRIES + ARM_BL_REGIONS) \ 106b4315306SDan Handley <= MAX_MMAP_REGIONS, \ 107b4315306SDan Handley assert_max_mmap_regions); 108b4315306SDan Handley 1091eb735d7SRoberto Vargas void arm_setup_romlib(void); 1101eb735d7SRoberto Vargas 111402b3cf8SJulius Werner #if defined(IMAGE_BL31) || (!defined(__aarch64__) && defined(IMAGE_BL32)) 112b4315306SDan Handley /* 113b4315306SDan Handley * Use this macro to instantiate lock before it is used in below 114b4315306SDan Handley * arm_lock_xxx() macros 115b4315306SDan Handley */ 1161931d1d7SSandrine Bailleux #define ARM_INSTANTIATE_LOCK static DEFINE_BAKERY_LOCK(arm_lock) 117c04a3b6cSSoby Mathew #define ARM_LOCK_GET_INSTANCE (&arm_lock) 11832aee841SRoberto Vargas 11932aee841SRoberto Vargas #if !HW_ASSISTED_COHERENCY 12032aee841SRoberto Vargas #define ARM_SCMI_INSTANTIATE_LOCK DEFINE_BAKERY_LOCK(arm_scmi_lock) 12132aee841SRoberto Vargas #else 12232aee841SRoberto Vargas #define ARM_SCMI_INSTANTIATE_LOCK spinlock_t arm_scmi_lock 12332aee841SRoberto Vargas #endif 12432aee841SRoberto Vargas #define ARM_SCMI_LOCK_GET_INSTANCE (&arm_scmi_lock) 12532aee841SRoberto Vargas 126b4315306SDan Handley /* 127b4315306SDan Handley * These are wrapper macros to the Coherent Memory Bakery Lock API. 128b4315306SDan Handley */ 129b4315306SDan Handley #define arm_lock_init() bakery_lock_init(&arm_lock) 130b4315306SDan Handley #define arm_lock_get() bakery_lock_get(&arm_lock) 131b4315306SDan Handley #define arm_lock_release() bakery_lock_release(&arm_lock) 132b4315306SDan Handley 133b4315306SDan Handley #else 134b4315306SDan Handley 135b4315306SDan Handley /* 1366f249345SYatharth Kochar * Empty macros for all other BL stages other than BL31 and BL32 137b4315306SDan Handley */ 13819583169SJeenu Viswambharan #define ARM_INSTANTIATE_LOCK static int arm_lock __unused 139c04a3b6cSSoby Mathew #define ARM_LOCK_GET_INSTANCE 0 140b4315306SDan Handley #define arm_lock_init() 141b4315306SDan Handley #define arm_lock_get() 142b4315306SDan Handley #define arm_lock_release() 143b4315306SDan Handley 144402b3cf8SJulius Werner #endif /* defined(IMAGE_BL31) || (!defined(__aarch64__) && defined(IMAGE_BL32)) */ 145b4315306SDan Handley 1462204afdeSSoby Mathew #if ARM_RECOM_STATE_ID_ENC 1472204afdeSSoby Mathew /* 1482204afdeSSoby Mathew * Macros used to parse state information from State-ID if it is using the 1492204afdeSSoby Mathew * recommended encoding for State-ID. 1502204afdeSSoby Mathew */ 1512204afdeSSoby Mathew #define ARM_LOCAL_PSTATE_WIDTH 4 1522204afdeSSoby Mathew #define ARM_LOCAL_PSTATE_MASK ((1 << ARM_LOCAL_PSTATE_WIDTH) - 1) 1532204afdeSSoby Mathew 154e75cc247SWing Li #if PSCI_OS_INIT_MODE 155e75cc247SWing Li #define ARM_LAST_AT_PLVL_MASK (ARM_LOCAL_PSTATE_MASK << \ 156e75cc247SWing Li (ARM_LOCAL_PSTATE_WIDTH * \ 157e75cc247SWing Li (PLAT_MAX_PWR_LVL + 1))) 158e75cc247SWing Li #endif /* __PSCI_OS_INIT_MODE__ */ 159e75cc247SWing Li 1602204afdeSSoby Mathew /* Macros to construct the composite power state */ 1612204afdeSSoby Mathew 1622204afdeSSoby Mathew /* Make composite power state parameter till power level 0 */ 1632204afdeSSoby Mathew #if PSCI_EXTENDED_STATE_ID 1642204afdeSSoby Mathew 1652204afdeSSoby Mathew #define arm_make_pwrstate_lvl0(lvl0_state, pwr_lvl, type) \ 1662204afdeSSoby Mathew (((lvl0_state) << PSTATE_ID_SHIFT) | ((type) << PSTATE_TYPE_SHIFT)) 1672204afdeSSoby Mathew #else 1682204afdeSSoby Mathew #define arm_make_pwrstate_lvl0(lvl0_state, pwr_lvl, type) \ 1692204afdeSSoby Mathew (((lvl0_state) << PSTATE_ID_SHIFT) | \ 1702204afdeSSoby Mathew ((pwr_lvl) << PSTATE_PWR_LVL_SHIFT) | \ 1712204afdeSSoby Mathew ((type) << PSTATE_TYPE_SHIFT)) 1722204afdeSSoby Mathew #endif /* __PSCI_EXTENDED_STATE_ID__ */ 1732204afdeSSoby Mathew 1742204afdeSSoby Mathew /* Make composite power state parameter till power level 1 */ 1752204afdeSSoby Mathew #define arm_make_pwrstate_lvl1(lvl1_state, lvl0_state, pwr_lvl, type) \ 1762204afdeSSoby Mathew (((lvl1_state) << ARM_LOCAL_PSTATE_WIDTH) | \ 1772204afdeSSoby Mathew arm_make_pwrstate_lvl0(lvl0_state, pwr_lvl, type)) 1782204afdeSSoby Mathew 1795f3a6030SSoby Mathew /* Make composite power state parameter till power level 2 */ 1805f3a6030SSoby Mathew #define arm_make_pwrstate_lvl2(lvl2_state, lvl1_state, lvl0_state, pwr_lvl, type) \ 1815f3a6030SSoby Mathew (((lvl2_state) << (ARM_LOCAL_PSTATE_WIDTH * 2)) | \ 1825f3a6030SSoby Mathew arm_make_pwrstate_lvl1(lvl1_state, lvl0_state, pwr_lvl, type)) 1835f3a6030SSoby Mathew 1842204afdeSSoby Mathew #endif /* __ARM_RECOM_STATE_ID_ENC__ */ 1852204afdeSSoby Mathew 186b10d4499SJeenu Viswambharan /* ARM State switch error codes */ 187b10d4499SJeenu Viswambharan #define STATE_SW_E_PARAM (-2) 188b10d4499SJeenu Viswambharan #define STATE_SW_E_DENIED (-3) 189b4315306SDan Handley 190a6ffddecSMax Shvetsov /* plat_get_rotpk_info() flags */ 191a6ffddecSMax Shvetsov #define ARM_ROTPK_REGS_ID 1 192a6ffddecSMax Shvetsov #define ARM_ROTPK_DEVEL_RSA_ID 2 193a6ffddecSMax Shvetsov #define ARM_ROTPK_DEVEL_ECDSA_ID 3 1945f899286Slaurenw-arm #define ARM_ROTPK_DEVEL_FULL_DEV_RSA_KEY_ID 4 195b8ae6890Slaurenw-arm #define ARM_ROTPK_DEVEL_FULL_DEV_ECDSA_KEY_ID 5 196b8ae6890Slaurenw-arm 197b8ae6890Slaurenw-arm #define ARM_USE_DEVEL_ROTPK \ 198b8ae6890Slaurenw-arm (ARM_ROTPK_LOCATION_ID == ARM_ROTPK_DEVEL_RSA_ID) || \ 199b8ae6890Slaurenw-arm (ARM_ROTPK_LOCATION_ID == ARM_ROTPK_DEVEL_ECDSA_ID) || \ 200b8ae6890Slaurenw-arm (ARM_ROTPK_LOCATION_ID == ARM_ROTPK_DEVEL_FULL_DEV_RSA_KEY_ID) || \ 201b8ae6890Slaurenw-arm (ARM_ROTPK_LOCATION_ID == ARM_ROTPK_DEVEL_FULL_DEV_ECDSA_KEY_ID) 2020e753437SManish V Badarkhe 203b4315306SDan Handley /* IO storage utility functions */ 20497399821SLouis Mayencourt int arm_io_setup(void); 205b4315306SDan Handley 206ef1daa42SManish V Badarkhe /* Set image specification in IO block policy */ 2072f1177b2SManish V Badarkhe int arm_set_image_source(unsigned int image_id, const char *part_name, 2082f1177b2SManish V Badarkhe uintptr_t *dev_handle, uintptr_t *image_spec); 2092f1177b2SManish V Badarkhe void arm_set_fip_addr(uint32_t active_fw_bank_idx); 210ef1daa42SManish V Badarkhe 211b4315306SDan Handley /* Security utility functions */ 2124ed16765SSuyash Pathak void arm_tzc400_setup(uintptr_t tzc_base, 2134ed16765SSuyash Pathak const arm_tzc_regions_info_t *tzc_regions); 214618f0feeSVikram Kanigiri struct tzc_dmc500_driver_data; 21523411d2cSSummer Qin void arm_tzc_dmc500_setup(struct tzc_dmc500_driver_data *plat_driver_data, 21623411d2cSSummer Qin const arm_tzc_regions_info_t *tzc_regions); 217b4315306SDan Handley 21888a0523eSAntonio Nino Diaz /* Console utility functions */ 21988a0523eSAntonio Nino Diaz void arm_console_boot_init(void); 22088a0523eSAntonio Nino Diaz void arm_console_boot_end(void); 22188a0523eSAntonio Nino Diaz void arm_console_runtime_init(void); 22288a0523eSAntonio Nino Diaz void arm_console_runtime_end(void); 22388a0523eSAntonio Nino Diaz 224c1bb8a05SSoby Mathew /* Systimer utility function */ 225c1bb8a05SSoby Mathew void arm_configure_sys_timer(void); 226c1bb8a05SSoby Mathew 227b4315306SDan Handley /* PM utility functions */ 22838dce70fSSoby Mathew int arm_validate_power_state(unsigned int power_state, 22938dce70fSSoby Mathew psci_power_state_t *req_state); 23071e7a4e5SJeenu Viswambharan int arm_validate_psci_entrypoint(uintptr_t entrypoint); 231f9e858b1SSoby Mathew int arm_validate_ns_entrypoint(uintptr_t entrypoint); 232e35a3fb5SSoby Mathew void arm_system_pwr_domain_save(void); 233c1bb8a05SSoby Mathew void arm_system_pwr_domain_resume(void); 234dc6aad2eSRoberto Vargas int arm_psci_read_mem_protect(int *enabled); 235f145403cSRoberto Vargas int arm_nor_psci_write_mem_protect(int val); 236638b034cSRoberto Vargas void arm_nor_psci_do_static_mem_protect(void); 237638b034cSRoberto Vargas void arm_nor_psci_do_dyn_mem_protect(void); 238f145403cSRoberto Vargas int arm_psci_mem_protect_chk(uintptr_t base, u_register_t length); 23938dce70fSSoby Mathew 24038dce70fSSoby Mathew /* Topology utility function */ 24138dce70fSSoby Mathew int arm_check_mpidr(u_register_t mpidr); 242b4315306SDan Handley 243b4315306SDan Handley /* BL1 utility functions */ 244b4315306SDan Handley void arm_bl1_early_platform_setup(void); 245b4315306SDan Handley void arm_bl1_platform_setup(void); 246b4315306SDan Handley void arm_bl1_plat_arch_setup(void); 247b4315306SDan Handley 248b4315306SDan Handley /* BL2 utility functions */ 24982869675SManish V Badarkhe void arm_bl2_early_platform_setup(uintptr_t fw_config, struct meminfo *mem_layout); 250b4315306SDan Handley void arm_bl2_platform_setup(void); 251b4315306SDan Handley void arm_bl2_plat_arch_setup(void); 252b4315306SDan Handley uint32_t arm_get_spsr_for_bl32_entry(void); 253b4315306SDan Handley uint32_t arm_get_spsr_for_bl33_entry(void); 254609e053cSAmbroise Vincent int arm_bl2_plat_handle_post_image_load(unsigned int image_id); 25507570d59SYatharth Kochar int arm_bl2_handle_post_image_load(unsigned int image_id); 2565b8d50e4SSathees Balya struct bl_params *arm_get_next_bl_params(void); 257b4315306SDan Handley 25881528dbcSRoberto Vargas /* BL2 at EL3 functions */ 25981528dbcSRoberto Vargas void arm_bl2_el3_early_platform_setup(void); 26081528dbcSRoberto Vargas void arm_bl2_el3_plat_arch_setup(void); 26181528dbcSRoberto Vargas 262dcda29f6SYatharth Kochar /* BL2U utility functions */ 263dcda29f6SYatharth Kochar void arm_bl2u_early_platform_setup(struct meminfo *mem_layout, 264dcda29f6SYatharth Kochar void *plat_info); 265dcda29f6SYatharth Kochar void arm_bl2u_platform_setup(void); 266dcda29f6SYatharth Kochar void arm_bl2u_plat_arch_setup(void); 267dcda29f6SYatharth Kochar 268d178637dSJuan Castillo /* BL31 utility functions */ 2690c306cc0SSoby Mathew void arm_bl31_early_platform_setup(void *from_bl2, uintptr_t soc_fw_config, 2700c306cc0SSoby Mathew uintptr_t hw_config, void *plat_params_from_bl2); 271b4315306SDan Handley void arm_bl31_platform_setup(void); 272080225daSSoby Mathew void arm_bl31_plat_runtime_setup(void); 273b4315306SDan Handley void arm_bl31_plat_arch_setup(void); 274b4315306SDan Handley 275b4315306SDan Handley /* TSP utility functions */ 276b4315306SDan Handley void arm_tsp_early_platform_setup(void); 277b4315306SDan Handley 278181bbd41SSoby Mathew /* SP_MIN utility functions */ 2790c306cc0SSoby Mathew void arm_sp_min_early_platform_setup(void *from_bl2, uintptr_t tos_fw_config, 2800c306cc0SSoby Mathew uintptr_t hw_config, void *plat_params_from_bl2); 28121568304SDimitris Papastamos void arm_sp_min_plat_runtime_setup(void); 28226d1e0c3SMadhukar Pappireddy void arm_sp_min_plat_arch_setup(void); 283181bbd41SSoby Mathew 284436223deSYatharth Kochar /* FIP TOC validity check */ 285d6dcbcadSLouis Mayencourt bool arm_io_is_toc_valid(void); 286b4315306SDan Handley 287c228956aSSoby Mathew /* Utility functions for Dynamic Config */ 288cab0b5b0SSoby Mathew void arm_bl2_dyn_cfg_init(void); 289ba597da7SJohn Tsichritzis void arm_bl1_set_mbedtls_heap(void); 290ba597da7SJohn Tsichritzis int arm_get_mbedtls_heap(void **heap_addr, size_t *heap_size); 291c228956aSSoby Mathew 2920ab49645SAlexei Fedorov #if MEASURED_BOOT 293efa65218SManish V Badarkhe int arm_set_tos_fw_info(uintptr_t log_addr, size_t log_size); 294efa65218SManish V Badarkhe int arm_set_nt_fw_info( 2957b4e1fbbSAlexei Fedorov /* 2967b4e1fbbSAlexei Fedorov * Currently OP-TEE does not support reading DTBs from Secure memory 2977b4e1fbbSAlexei Fedorov * and this option should be removed when feature is supported. 2987b4e1fbbSAlexei Fedorov */ 2997b4e1fbbSAlexei Fedorov #ifdef SPD_opteed 3007b4e1fbbSAlexei Fedorov uintptr_t log_addr, 3010ab49645SAlexei Fedorov #endif 3027b4e1fbbSAlexei Fedorov size_t log_size, uintptr_t *ns_log_addr); 3031cf3e2f0SManish V Badarkhe int arm_set_tb_fw_info(uintptr_t log_addr, size_t log_size, 3041cf3e2f0SManish V Badarkhe size_t log_max_size); 3051cf3e2f0SManish V Badarkhe int arm_get_tb_fw_info(uint64_t *log_addr, size_t *log_size, 3061cf3e2f0SManish V Badarkhe size_t *log_max_size); 3077b4e1fbbSAlexei Fedorov #endif /* MEASURED_BOOT */ 3080ab49645SAlexei Fedorov 309b4315306SDan Handley /* 310cb4adb0dSDaniel Boulby * Free the memory storing initialization code only used during an images boot 311cb4adb0dSDaniel Boulby * time so it can be reclaimed for runtime data 312cb4adb0dSDaniel Boulby */ 313cb4adb0dSDaniel Boulby void arm_free_init_memory(void); 314cb4adb0dSDaniel Boulby 315cb4adb0dSDaniel Boulby /* 31660e8f3cfSPetre-Ionut Tudor * Make the higher level translation tables read-only 31760e8f3cfSPetre-Ionut Tudor */ 31860e8f3cfSPetre-Ionut Tudor void arm_xlat_make_tables_readonly(void); 31960e8f3cfSPetre-Ionut Tudor 32060e8f3cfSPetre-Ionut Tudor /* 321b4315306SDan Handley * Mandatory functions required in ARM standard platforms 322b4315306SDan Handley */ 3230108047aSSoby Mathew unsigned int plat_arm_get_cluster_core_count(u_register_t mpidr); 32427573c59SAchin Gupta void plat_arm_gic_driver_init(void); 325b4315306SDan Handley void plat_arm_gic_init(void); 32627573c59SAchin Gupta void plat_arm_gic_cpuif_enable(void); 32727573c59SAchin Gupta void plat_arm_gic_cpuif_disable(void); 328d17b953aSJeenu Viswambharan void plat_arm_gic_redistif_on(void); 329d17b953aSJeenu Viswambharan void plat_arm_gic_redistif_off(void); 33027573c59SAchin Gupta void plat_arm_gic_pcpu_init(void); 331e35a3fb5SSoby Mathew void plat_arm_gic_save(void); 332e35a3fb5SSoby Mathew void plat_arm_gic_resume(void); 333b4315306SDan Handley void plat_arm_security_setup(void); 334b4315306SDan Handley void plat_arm_pwrc_setup(void); 3356355f234SVikram Kanigiri void plat_arm_interconnect_init(void); 3366355f234SVikram Kanigiri void plat_arm_interconnect_enter_coherency(void); 3376355f234SVikram Kanigiri void plat_arm_interconnect_exit_coherency(void); 3382a246d2eSDimitris Papastamos void plat_arm_program_trusted_mailbox(uintptr_t address); 339d6dcbcadSLouis Mayencourt bool plat_arm_bl1_fwu_needed(void); 34037b70031SAmbroise Vincent __dead2 void plat_arm_error_handler(int err); 341586f60ccSManish V Badarkhe __dead2 void plat_arm_system_reset(void); 342b4315306SDan Handley 34374c21244SVijayenthiran Subramaniam /* 344a6ffddecSMax Shvetsov * Optional functions in ARM standard platforms 34574c21244SVijayenthiran Subramaniam */ 34674c21244SVijayenthiran Subramaniam void plat_arm_override_gicr_frames(const uintptr_t *plat_gicr_frames); 34788005701SSandrine Bailleux int arm_get_rotpk_info(void *cookie, void **key_ptr, unsigned int *key_len, 348a6ffddecSMax Shvetsov unsigned int *flags); 349a6ffddecSMax Shvetsov int arm_get_rotpk_info_regs(void **key_ptr, unsigned int *key_len, 350a6ffddecSMax Shvetsov unsigned int *flags); 351a6ffddecSMax Shvetsov int arm_get_rotpk_info_cc(void **key_ptr, unsigned int *key_len, 352a6ffddecSMax Shvetsov unsigned int *flags); 353a6ffddecSMax Shvetsov int arm_get_rotpk_info_dev(void **key_ptr, unsigned int *key_len, 354a6ffddecSMax Shvetsov unsigned int *flags); 35574c21244SVijayenthiran Subramaniam 356d8d6cf24SSummer Qin #if ARM_PLAT_MT 357d8d6cf24SSummer Qin unsigned int plat_arm_get_cpu_pe_count(u_register_t mpidr); 358d8d6cf24SSummer Qin #endif 359d8d6cf24SSummer Qin 360a8aa7fecSYatharth Kochar /* 361a8aa7fecSYatharth Kochar * This function is called after loading SCP_BL2 image and it is used to perform 362a8aa7fecSYatharth Kochar * any platform-specific actions required to handle the SCP firmware. 363a8aa7fecSYatharth Kochar */ 364a8aa7fecSYatharth Kochar int plat_arm_bl2_handle_scp_bl2(struct image_info *scp_bl2_image_info); 365a8aa7fecSYatharth Kochar 366b4315306SDan Handley /* 367b4315306SDan Handley * Optional functions required in ARM standard platforms 368b4315306SDan Handley */ 369b4315306SDan Handley void plat_arm_io_setup(void); 370b4315306SDan Handley int plat_arm_get_alt_image_source( 37116948ae1SJuan Castillo unsigned int image_id, 37216948ae1SJuan Castillo uintptr_t *dev_handle, 37316948ae1SJuan Castillo uintptr_t *image_spec); 37438dce70fSSoby Mathew unsigned int plat_arm_calc_core_pos(u_register_t mpidr); 37565cb1c4cSVikram Kanigiri const mmap_region_t *plat_arm_get_mmap(void); 376b4315306SDan Handley 37786e4859aSRohit Mathew const arm_gpt_info_t *plat_arm_get_gpt_info(void); 378*341df6afSRohit Mathew void arm_gpt_setup(void); 37986e4859aSRohit Mathew 3805486a965SSoby Mathew /* Allow platform to override psci_pm_ops during runtime */ 3815486a965SSoby Mathew const plat_psci_ops_t *plat_arm_psci_override_pm_ops(plat_psci_ops_t *ops); 3825486a965SSoby Mathew 383b10d4499SJeenu Viswambharan /* Execution state switch in ARM platforms */ 384b10d4499SJeenu Viswambharan int arm_execution_state_switch(unsigned int smc_fid, 385b10d4499SJeenu Viswambharan uint32_t pc_hi, 386b10d4499SJeenu Viswambharan uint32_t pc_lo, 387b10d4499SJeenu Viswambharan uint32_t cookie_hi, 388b10d4499SJeenu Viswambharan uint32_t cookie_lo, 389b10d4499SJeenu Viswambharan void *handle); 390b10d4499SJeenu Viswambharan 3910ed8c001SSoby Mathew /* Optional functions for SP_MIN */ 3920ed8c001SSoby Mathew void plat_arm_sp_min_early_platform_setup(u_register_t arg0, u_register_t arg1, 3930ed8c001SSoby Mathew u_register_t arg2, u_register_t arg3); 3940ed8c001SSoby Mathew 3951af540efSRoberto Vargas /* global variables */ 3961af540efSRoberto Vargas extern plat_psci_ops_t plat_arm_psci_pm_ops; 3971af540efSRoberto Vargas extern const mmap_region_t plat_arm_mmap[]; 398ecd62429SJeenu Viswambharan extern const unsigned int arm_pm_idle_states[]; 3991af540efSRoberto Vargas 400b0c97dafSAditya Angadi /* secure watchdog */ 401b0c97dafSAditya Angadi void plat_arm_secure_wdt_start(void); 402b0c97dafSAditya Angadi void plat_arm_secure_wdt_stop(void); 40328b2d86cSMadhukar Pappireddy void plat_arm_secure_wdt_refresh(void); 404b0c97dafSAditya Angadi 4050e753437SManish V Badarkhe /* Get SOC-ID of ARM platform */ 4060e753437SManish V Badarkhe uint32_t plat_arm_get_soc_id(void); 4070e753437SManish V Badarkhe 40815b94cc1SAntonio Nino Diaz #endif /* PLAT_ARM_H */ 409