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 A convenient struct to include all required Non-Secure state configuration.
38 */
40 uint32_t msp_ns;
41 uint32_t psp_ns;
42 uint32_t vtor_ns;
43 struct {
44 uint32_t npriv : 1;
45 uint32_t spsel : 1;
46 uint32_t reserved : 30;
47 } control_ns;
49
50/**
51 * \brief Configure nonsecure vtor offset
52 */
53void configure_nonsecure_vtor_offset(uint32_t vtor_ns);
54
55/**
56 * \brief Store the addresses of memory regions
57 */
59 uint32_t non_secure_code_start;
60 uint32_t non_secure_partition_base;
61 uint32_t non_secure_partition_limit;
62 uint32_t veneer_base;
63 uint32_t veneer_limit;
64#ifdef BL2
65 uint32_t secondary_partition_base;
66 uint32_t secondary_partition_limit;
67#endif /* BL2 */
68};
69
70/**
71 * \brief Holds the data necessary to do isolation for a specific peripheral.
72 */
74 uint32_t periph_start;
75 uint32_t periph_limit;
76};
77
78/**
79 * \brief Configures peripheral permissions via the System Protection Unit.
80 *
81 * The function does the following:
82 * - grants Non-Secure access to nRF peripherals that are not Secure-only
83 * - grants Non-Secure access to DDPI channels
84 * - grants Non-Secure access to GPIO pins
85 */
86void spu_periph_init_cfg(void);
87
88/**
89 * \brief Setup nonsecure state
90 */
92
93/**
94 * \brief Restrict access to peripheral to secure
95 */
96void spu_periph_configure_to_secure(uint32_t periph_num);
97
98/**
99 * \brief Allow non-secure access to peripheral
100 */
101void spu_periph_configure_to_non_secure(uint32_t periph_num);
102
103/**
104 * \brief Configures the NRF_UARTE0 non-secure
105 */
106void spu_periph_config_uarte(void);
107
108/**
109 * \brief Configures SAU and IDAU.
110 */
111void sau_and_idau_cfg(void);
112
113/**
114 * \brief Configure rom, ram and peripherials non-secure
115 */
116void non_secure_configuration(void);
117
118/**
119 * \brief Enables the fault handlers and sets priorities.
120 */
121void enable_fault_handlers(void);
122
123/**
124 * \brief Configures the system reset request properties
125 */
126void system_reset_cfg(void);
127
128/**
129 * \brief Configures all external interrupts to target the
130 * NS state, apart for the ones associated to secure
131 * peripherals (plus SPU)
132 */
134
135/**
136 * \brief This function enable the interrupts associated
137 * to the secure peripherals (plus the isolation boundary violation
138 * interrupts)
139 */
140void nvic_interrupt_enable(void);
141
142/**
143 * \brief Report and clear any SPU violation captured by the previous
144 * boot's SPU_IRQHandler. Should be called early in secure
145 * initialization to surface the cause of an unexpected reset.
146 */
147void spu_report_violation(void);
148
149#endif /* __TZ_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.
void spu_periph_configure_to_secure(uint32_t periph_num)
Restrict access to peripheral to secure.
void spu_periph_init_cfg(void)
Configures peripheral permissions via the System Protection Unit.
void system_reset_cfg(void)
Configures the system reset request properties.
void spu_periph_config_uarte(void)
Configures the NRF_UARTE0 non-secure.
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.
void configure_nonsecure_vtor_offset(uint32_t vtor_ns)
Configure nonsecure vtor offset.
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.
void nvic_interrupt_target_state_cfg(void)
Configures all external interrupts to target the NS state, apart for the ones associated to secure pe...
void nvic_interrupt_enable(void)
This function enable the interrupts associated to the secure peripherals (plus the isolation boundary...
void enable_fault_handlers(void)
Enables the fault handlers and sets priorities.
void spu_report_violation(void)
Report and clear any SPU violation captured by the previous boot's SPU_IRQHandler.