Contiki-NG
Loading...
Searching...
No Matches
tz-target-cfg.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017-2019 Arm Limited
3 * Copyright (c) 2020 Nordic Semiconductor ASA
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/* This file has been modified for use in the Contiki-NG operating system. */
19
20#ifndef __TZ_TARGET_CFG_H__
21#define __TZ_TARGET_CFG_H__
22
23/**
24 * \file tz-target-cfg.h
25 * \brief nRF5340 target configuration header
26 *
27 * This file contains the platform specific functions to configure
28 * the Cortex-M33 core, memory permissions and security attribution
29 * on the nRF5340 platform.
30 *
31 * Memory permissions and security attribution are configured via
32 * the System Protection Unit (SPU) which is the nRF specific Implementation
33 * Defined Attribution Unit (IDAU).
34 */
35
36/**
37 * \brief TFM error codes.
38 */
40 TFM_PLAT_ERR_SUCCESS = 0,
41 TFM_PLAT_ERR_SYSTEM_ERR = 0x3A5C,
42 TFM_PLAT_ERR_MAX_VALUE = 0x55A3,
43 TFM_PLAT_ERR_INVALID_INPUT = 0xA3C5,
44 TFM_PLAT_ERR_UNSUPPORTED = 0xC35A,
45 /* Following entry is only to ensure the error code of int size */
46 /* TFM_PLAT_ERR_FORCE_INT_SIZE = INT_MAX */
47};
48
49#define TFM_DRIVER_STDIO Driver_USART1
50#define NS_DRIVER_STDIO Driver_USART0
51
52/**
53 * \brief A convenient struct to include all required Non-Secure state configuration.
54 */
56 uint32_t msp_ns;
57 uint32_t psp_ns;
58 uint32_t vtor_ns;
59 struct {
60 uint32_t npriv : 1;
61 uint32_t spsel : 1;
62 uint32_t reserved : 30;
63 } control_ns;
65
66/**
67 * \brief Configure nonsecure vtor offset
68 */
69void configure_nonsecure_vtor_offset(uint32_t vtor_ns);
70
71/**
72 * \brief Store the addresses of memory regions
73 */
75 uint32_t non_secure_code_start;
76 uint32_t non_secure_partition_base;
77 uint32_t non_secure_partition_limit;
78 uint32_t veneer_base;
79 uint32_t veneer_limit;
80#ifdef BL2
81 uint32_t secondary_partition_base;
82 uint32_t secondary_partition_limit;
83#endif /* BL2 */
84};
85
86/**
87 * \brief Holds the data necessary to do isolation for a specific peripheral.
88 */
90 uint32_t periph_start;
91 uint32_t periph_limit;
92};
93
94/**
95 * \brief Configures memory permissions via the System Protection Unit.
96 *
97 * \return Returns values as specified by the \ref tfm_plat_err_t
98 */
100
101/**
102 * \brief Configures peripheral permissions via the System Protection Unit.
103 *
104 * The function does the following:
105 * - grants Non-Secure access to nRF peripherals that are not Secure-only
106 * - grants Non-Secure access to DDPI channels
107 * - grants Non-Secure access to GPIO pins
108 *
109 * \return Returns values as specified by the \ref tfm_plat_err_t
110 */
112
113/**
114 * \brief Setup nonsecure state
115 */
117
118/**
119 * \brief Restrict access to peripheral to secure
120 */
121void spu_periph_configure_to_secure(uint32_t periph_num);
122
123/**
124 * \brief Allow non-secure access to peripheral
125 */
126void spu_periph_configure_to_non_secure(uint32_t periph_num);
127
128/**
129 * \brief Configures the NRF_UARTE0 non-secure
130 */
131void spu_periph_config_uarte(void);
132
133/**
134 * \brief Clears SPU interrupt.
135 */
136void spu_clear_irq(void);
137
138/**
139 * \brief Configures SAU and IDAU.
140 */
141void sau_and_idau_cfg(void);
142
143/**
144 * \brief Configure rom, ram and peripherials non-secure
145 */
146void non_secure_configuration(void);
147
148/**
149 * \brief Get non-secure vector table.
150 */
152
153/**
154 * \brief Get non-secure MSP location.
155 */
157
158/**
159 * \brief Get entry point location.
160 */
162
163/**
164 * \brief Enables the fault handlers and sets priorities.
165 *
166 * \return Returns values as specified by the \ref tfm_plat_err_t
167 */
169
170/**
171 * \brief Configures the system reset request properties
172 *
173 * \return Returns values as specified by the \ref tfm_plat_err_t
174 */
176
177/**
178 * \brief Configures the system debug properties.
179 *
180 * \return Returns values as specified by the \ref tfm_plat_err_t
181 */
183
184/**
185 * \brief Configures all external interrupts to target the
186 * NS state, apart for the ones associated to secure
187 * peripherals (plus SPU)
188 *
189 * \return Returns values as specified by the \ref tfm_plat_err_t
190 */
192
193/**
194 * \brief This function enable the interrupts associated
195 * to the secure peripherals (plus the isolation boundary violation
196 * interrupts)
197 *
198 * \return Returns values as specified by the \ref tfm_plat_err_t
199 */
201
202#endif /* __TARGET_CFG_H__ */
Store the addresses of memory regions.
Holds the data necessary to do isolation for a specific peripheral.
A convenient struct to include all required Non-Secure state configuration.
enum tfm_plat_err_t enable_fault_handlers(void)
Enables the fault handlers and sets priorities.
uint32_t tfm_spm_hal_get_ns_MSP(void)
Get non-secure MSP location.
void spu_periph_configure_to_secure(uint32_t periph_num)
Restrict access to peripheral to secure.
enum tfm_plat_err_t spu_init_cfg(void)
Configures memory permissions via the System Protection Unit.
enum tfm_plat_err_t nvic_interrupt_target_state_cfg(void)
Configures all external interrupts to target the NS state, apart for the ones associated to secure pe...
void spu_periph_config_uarte(void)
Configures the NRF_UARTE0 non-secure.
enum tfm_plat_err_t spu_periph_init_cfg(void)
Configures peripheral permissions via the System Protection Unit.
void spu_clear_irq(void)
Clears SPU interrupt.
void tz_nonsecure_state_setup(const tz_nonsecure_setup_conf_t *p_ns_conf)
Setup nonsecure state.
void spu_periph_configure_to_non_secure(uint32_t periph_num)
Allow non-secure access to peripheral.
void sau_and_idau_cfg(void)
Configures SAU and IDAU.
enum tfm_plat_err_t init_debug(void)
Configures the system debug properties.
enum tfm_plat_err_t system_reset_cfg(void)
Configures the system reset request properties.
void configure_nonsecure_vtor_offset(uint32_t vtor_ns)
Configure nonsecure vtor offset.
uint32_t tfm_spm_hal_get_ns_entry_point(void)
Get entry point location.
void non_secure_configuration(void)
Configure rom, ram and peripherials non-secure.
struct tz_nonsecure_setup_conf tz_nonsecure_setup_conf_t
A convenient struct to include all required Non-Secure state configuration.
tfm_plat_err_t
TFM error codes.
uint32_t tfm_spm_hal_get_ns_VTOR(void)
Get non-secure vector table.
enum tfm_plat_err_t nvic_interrupt_enable(void)
This function enable the interrupts associated to the secure peripherals (plus the isolation boundary...