blob: 7c6a1d1d1f823f3aeadac3588248c7cac79fa85c [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
Tamas Ban6032c3b2018-07-17 22:11:20 +0100110/**
111 * \brief Get the VTOR value of non-secure image
112 *
113 * \return Returns the address where the vector table of the non-secure image
114 * is located
115 */
116uint32_t tfm_spm_hal_get_ns_VTOR(void);
117
118/**
119 * \brief Get the initial address of non-secure image main stack
120 *
121 * \return Returns the initial non-secure MSP
122 */
123uint32_t tfm_spm_hal_get_ns_MSP(void);
124
125/**
126 * \brief Get the entry point of the non-secure image
127 *
128 * \return Returns the address of the non-secure image entry point
129 */
130uint32_t tfm_spm_hal_get_ns_entry_point(void);
131
Mate Toth-Pal936c33b2018-04-10 14:02:07 +0200132
133#if TFM_LVL != 1
134/**
135 * \brief Configure the sandbox for a partition.
136 *
137 * \param[in] memory_data The memory ranges from the partition DB for this
138 * partition
139 * \param[in] platform_data The platform fields of the partition DB record
140 * for this partition. Can be NULL.
141 *
142 * \return Returns the result operation as per \ref spm_err_t
143 */
144enum spm_err_t tfm_spm_hal_partition_sandbox_config(
145 const struct tfm_spm_partition_memory_data_t *memory_data,
146 const struct tfm_spm_partition_platform_data_t *platform_data);
147
148/**
149 * \brief Deconfigure the sandbox for a partition.
150 *
151 * \param[in] memory_data The memory ranges from the partition DB for this
152 * partition
153 * \param[in] platform_data The platform fields of the partition DB record
154 * for this partition. Can be NULL.
155 *
156 * \return Returns the result operation as per \ref spm_err_t
157 */
158enum spm_err_t tfm_spm_hal_partition_sandbox_deconfig(
159 const struct tfm_spm_partition_memory_data_t *memory_data,
160 const struct tfm_spm_partition_platform_data_t *platform_data);
161
162/**
163 * \brief Set the share region mode
164 *
165 * \param[in] share The mode to set
166 *
167 * \return Returns the result operation as per \ref spm_err_t
168 */
169enum spm_err_t tfm_spm_hal_set_share_region(
170 enum tfm_buffer_share_region_e share);
171#endif
Mate Toth-Pale1475332018-04-09 17:28:49 +0200172
173#endif /* __TFM_SPM_HAL_H__ */