blob: 24e987bd64d8cd8e4c17ada1ad0d4cac8ed43ff1 [file] [log] [blame]
Mate Toth-Pale1475332018-04-09 17:28:49 +02001/*
2 * Copyright (c) 2018, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#ifndef __TFM_SPM_HAL_H__
9#define __TFM_SPM_HAL_H__
10
11#include <stdint.h>
Mate Toth-Pal936c33b2018-04-10 14:02:07 +020012#include "tfm_secure_api.h"
13#include "spm_api.h"
Mate Toth-Pale1475332018-04-09 17:28:49 +020014
15/**
Mate Toth-Pal936c33b2018-04-10 14:02:07 +020016 * \brief Holds peripheral specific data fields required to manage the
17 * peripherals isolation
Mate Toth-Pale1475332018-04-09 17:28:49 +020018 *
Mate Toth-Pal936c33b2018-04-10 14:02:07 +020019 * This structure has to be defined in the platform directory, and may have
20 * different definition for each platform. The structure should contain fields
21 * that describe the peripheral for the functions that are prototyped in this
22 * file and are responsible for configuring the isolation of the peripherals.
23 *
24 * Pointers to structures of this type are managed by the SPM, and passed to the
25 * necessary function on isolation request. The pointers are also defined by the
26 * platform in the header file tfm_peripherals_def.h. For details on this, see
27 * the documentation of that file.
Mate Toth-Pale1475332018-04-09 17:28:49 +020028 */
Mate Toth-Pal936c33b2018-04-10 14:02:07 +020029struct tfm_spm_partition_platform_data_t;
30
31#if TFM_LVL != 1
32/**
33 * \brief Holds SPM db fields that define the memory regions used by a
34 * partition.
35 */
36struct tfm_spm_partition_memory_data_t
37{
38 uint32_t code_start; /*!< Start of the code memory of this partition. */
39 uint32_t code_limit; /*!< Address of the byte beyond the end of the code
40 * memory of this partition.
41 */
42 uint32_t ro_start; /*!< Start of the read only memory of this
43 * partition.
44 */
45 uint32_t ro_limit; /*!< Address of the byte beyond the end of the read
46 * only memory of this partition.
47 */
48 uint32_t rw_start; /*!< Start of the data region of this partition. */
49 uint32_t rw_limit; /*!< Address of the byte beyond the end of the data
50 * region of this partition.
51 */
52 uint32_t zi_start; /*!< Start of the zero initialised data region of
53 * this partition.
54 */
55 uint32_t zi_limit; /*!< Address of the byte beyond the end of the zero
56 * initialised region of this partition.
57 */
58 uint32_t stack_bottom; /*!< The bottom of the stack for the partition. */
59 uint32_t stack_top; /*!< The top of the stack for the partition. */
60};
61#endif
62
63/**
64 * \brief This function initialises the HW used for isolation, and sets the
65 * default configuration for them.
66 *
67 * This function is called during TF-M core early startup, before DB init
68 */
69void tfm_spm_hal_init_isolation_hw(void);
70
71/**
72 * \brief This function initialises the HW used for isolation, and sets the
73 * default configuration for them.
74 * This function is called during TF-M core early startup, after DB init
75 */
76void tfm_spm_hal_setup_isolation_hw(void);
77
78/**
79 * \brief Configure peripherals for a partition based on the platfotm data from
80 * the DB
81 *
82 * This function is called during partition initialisation (before calling the
83 * init function for the partition)
84 *
85 * \param[in] platform_data The platform fields of the partition DB record to
86 * be used for configuration. Can be NULL.
87 */
88void tfm_spm_hal_configure_default_isolation(
89 const struct tfm_spm_partition_platform_data_t *platform_data);
90
91/**
92 * \brief Enables the fault handlers
93 */
94void enable_fault_handlers(void);
95
96/**
97 * \brief Configures all external interrupts to target the
98 * NS state, apart for the ones associated to secure
99 * peripherals (plus MPC and PPC)
100 */
101void nvic_interrupt_target_state_cfg(void);
102
103/**
104 * \brief This function enable the interrupts associated
105 * to the secure peripherals (plus the isolation boundary violation
106 * interrupts)
107 */
108void nvic_interrupt_enable(void);
109
110
111#if TFM_LVL != 1
112/**
113 * \brief Configure the sandbox for a partition.
114 *
115 * \param[in] memory_data The memory ranges from the partition DB for this
116 * partition
117 * \param[in] platform_data The platform fields of the partition DB record
118 * for this partition. Can be NULL.
119 *
120 * \return Returns the result operation as per \ref spm_err_t
121 */
122enum spm_err_t tfm_spm_hal_partition_sandbox_config(
123 const struct tfm_spm_partition_memory_data_t *memory_data,
124 const struct tfm_spm_partition_platform_data_t *platform_data);
125
126/**
127 * \brief Deconfigure the sandbox for a partition.
128 *
129 * \param[in] memory_data The memory ranges from the partition DB for this
130 * partition
131 * \param[in] platform_data The platform fields of the partition DB record
132 * for this partition. Can be NULL.
133 *
134 * \return Returns the result operation as per \ref spm_err_t
135 */
136enum spm_err_t tfm_spm_hal_partition_sandbox_deconfig(
137 const struct tfm_spm_partition_memory_data_t *memory_data,
138 const struct tfm_spm_partition_platform_data_t *platform_data);
139
140/**
141 * \brief Set the share region mode
142 *
143 * \param[in] share The mode to set
144 *
145 * \return Returns the result operation as per \ref spm_err_t
146 */
147enum spm_err_t tfm_spm_hal_set_share_region(
148 enum tfm_buffer_share_region_e share);
149#endif
Mate Toth-Pale1475332018-04-09 17:28:49 +0200150
151#endif /* __TFM_SPM_HAL_H__ */