aboutsummaryrefslogtreecommitdiff
path: root/platform/include/tfm_spm_hal.h
diff options
context:
space:
mode:
authorMate Toth-Pal <mate.toth-pal@arm.com>2018-04-10 14:02:07 +0200
committerMate Toth-Pal <mate.toth-pal@arm.com>2018-07-12 14:38:07 +0200
commit936c33b88272d5ad0f5b040c00d98c30e2395ba1 (patch)
treea6ff0a87df39073c0dbbd03c5a7456438c084b18 /platform/include/tfm_spm_hal.h
parente1475330b310a4efad34f04a878d2b8846b481a4 (diff)
downloadtrusted-firmware-m-936c33b88272d5ad0f5b040c00d98c30e2395ba1.tar.gz
Platform: Move isolation hw code to SPM hal
Moves code related to hardware specific aspects of MPU, PPC, MPC and SAU to SPM hal. Leaves the code parts that use cmse defined interface to access these peripherals in secure_sw folder. Change-Id: I594847686cac51ee0f9fae217152b6e90723bb9e Signed-off-by: Mate Toth-Pal <mate.toth-pal@arm.com>
Diffstat (limited to 'platform/include/tfm_spm_hal.h')
-rw-r--r--platform/include/tfm_spm_hal.h139
1 files changed, 128 insertions, 11 deletions
diff --git a/platform/include/tfm_spm_hal.h b/platform/include/tfm_spm_hal.h
index bbd000155e..24e987bd64 100644
--- a/platform/include/tfm_spm_hal.h
+++ b/platform/include/tfm_spm_hal.h
@@ -9,26 +9,143 @@
#define __TFM_SPM_HAL_H__
#include <stdint.h>
+#include "tfm_secure_api.h"
+#include "spm_api.h"
/**
- * Holds the data necessary to do isolation for a specific peripheral.
+ * \brief Holds peripheral specific data fields required to manage the
+ * peripherals isolation
+ *
+ * This structure has to be defined in the platform directory, and may have
+ * different definition for each platform. The structure should contain fields
+ * that describe the peripheral for the functions that are prototyped in this
+ * file and are responsible for configuring the isolation of the peripherals.
+ *
+ * Pointers to structures of this type are managed by the SPM, and passed to the
+ * necessary function on isolation request. The pointers are also defined by the
+ * platform in the header file tfm_peripherals_def.h. For details on this, see
+ * the documentation of that file.
+ */
+struct tfm_spm_partition_platform_data_t;
+
+#if TFM_LVL != 1
+/**
+ * \brief Holds SPM db fields that define the memory regions used by a
+ * partition.
*/
-struct tfm_spm_partition_platform_data_t
+struct tfm_spm_partition_memory_data_t
{
- uint32_t periph_start;
- uint32_t periph_limit;
- uint16_t periph_ppc_bank;
- uint16_t periph_ppc_loc;
+ uint32_t code_start; /*!< Start of the code memory of this partition. */
+ uint32_t code_limit; /*!< Address of the byte beyond the end of the code
+ * memory of this partition.
+ */
+ uint32_t ro_start; /*!< Start of the read only memory of this
+ * partition.
+ */
+ uint32_t ro_limit; /*!< Address of the byte beyond the end of the read
+ * only memory of this partition.
+ */
+ uint32_t rw_start; /*!< Start of the data region of this partition. */
+ uint32_t rw_limit; /*!< Address of the byte beyond the end of the data
+ * region of this partition.
+ */
+ uint32_t zi_start; /*!< Start of the zero initialised data region of
+ * this partition.
+ */
+ uint32_t zi_limit; /*!< Address of the byte beyond the end of the zero
+ * initialised region of this partition.
+ */
+ uint32_t stack_bottom; /*!< The bottom of the stack for the partition. */
+ uint32_t stack_top; /*!< The top of the stack for the partition. */
};
+#endif
/**
- * \brief Initialise the platform related fields of a partition DB record.
+ * \brief This function initialises the HW used for isolation, and sets the
+ * default configuration for them.
+ *
+ * This function is called during TF-M core early startup, before DB init
+ */
+void tfm_spm_hal_init_isolation_hw(void);
+
+/**
+ * \brief This function initialises the HW used for isolation, and sets the
+ * default configuration for them.
+ * This function is called during TF-M core early startup, after DB init
+ */
+void tfm_spm_hal_setup_isolation_hw(void);
+
+/**
+ * \brief Configure peripherals for a partition based on the platfotm data from
+ * the DB
+ *
+ * This function is called during partition initialisation (before calling the
+ * init function for the partition)
*
- * \param[in] partition_id The id of the partition
* \param[in] platform_data The platform fields of the partition DB record to
- * init
+ * be used for configuration. Can be NULL.
+ */
+void tfm_spm_hal_configure_default_isolation(
+ const struct tfm_spm_partition_platform_data_t *platform_data);
+
+/**
+ * \brief Enables the fault handlers
+ */
+void enable_fault_handlers(void);
+
+/**
+ * \brief Configures all external interrupts to target the
+ * NS state, apart for the ones associated to secure
+ * peripherals (plus MPC and PPC)
+ */
+void nvic_interrupt_target_state_cfg(void);
+
+/**
+ * \brief This function enable the interrupts associated
+ * to the secure peripherals (plus the isolation boundary violation
+ * interrupts)
+ */
+void nvic_interrupt_enable(void);
+
+
+#if TFM_LVL != 1
+/**
+ * \brief Configure the sandbox for a partition.
+ *
+ * \param[in] memory_data The memory ranges from the partition DB for this
+ * partition
+ * \param[in] platform_data The platform fields of the partition DB record
+ * for this partition. Can be NULL.
+ *
+ * \return Returns the result operation as per \ref spm_err_t
+ */
+enum spm_err_t tfm_spm_hal_partition_sandbox_config(
+ const struct tfm_spm_partition_memory_data_t *memory_data,
+ const struct tfm_spm_partition_platform_data_t *platform_data);
+
+/**
+ * \brief Deconfigure the sandbox for a partition.
+ *
+ * \param[in] memory_data The memory ranges from the partition DB for this
+ * partition
+ * \param[in] platform_data The platform fields of the partition DB record
+ * for this partition. Can be NULL.
+ *
+ * \return Returns the result operation as per \ref spm_err_t
+ */
+enum spm_err_t tfm_spm_hal_partition_sandbox_deconfig(
+ const struct tfm_spm_partition_memory_data_t *memory_data,
+ const struct tfm_spm_partition_platform_data_t *platform_data);
+
+/**
+ * \brief Set the share region mode
+ *
+ * \param[in] share The mode to set
+ *
+ * \return Returns the result operation as per \ref spm_err_t
*/
-void tfm_spm_hal_init_platform_data(uint32_t partition_id,
- struct tfm_spm_partition_platform_data_t *platform_data);
+enum spm_err_t tfm_spm_hal_set_share_region(
+ enum tfm_buffer_share_region_e share);
+#endif
#endif /* __TFM_SPM_HAL_H__ */