1 /*
2 * Copyright (c) 2019 - 2023, Nordic Semiconductor ASA
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright notice, this
11 * list of conditions and the following disclaimer.
12 *
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * 3. Neither the name of the copyright holder nor the names of its
18 * contributors may be used to endorse or promote products derived from this
19 * software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 #ifndef NRF_DCNF_H__
35 #define NRF_DCNF_H__
36
37 #include <nrfx.h>
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43 /**
44 * @defgroup nrf_dcnf_hal DCNF HAL
45 * @{
46 * @ingroup nrf_dcnf
47 * @brief Hardware access layer for managing the Domain Configuration (DCNF) module.
48 */
49
50 /**
51 * @brief Function for getting the value of the CPU ID.
52 *
53 * CPU ID can be used to identify the specific CPU in the multi-core environment.
54 *
55 * @param[in] p_reg Pointer to the structure of registers of the peripheral.
56 *
57 * @return CPU ID.
58 */
59 NRF_STATIC_INLINE uint32_t nrf_dcnf_cpuid_get(NRF_DCNF_Type const * p_reg);
60
61 #if defined(DCNF_EXTPERI_PROTECT_SLAVE0_Msk)
62 /**
63 * @brief Function for configuring the control access to local peripheral memory regions.
64 * Intended for external master connected to specified AMLI master port.
65 *
66 * @param[in] p_reg Pointer to the structure of registers of the peripheral.
67 * @param[in] port_idx Index of the master port to configure.
68 * @param[in] mask Mask of the AHB slaves to be protected from being accessed
69 * by external AHB masters.
70 */
71 NRF_STATIC_INLINE void nrf_dcnf_peripheral_access_set(NRF_DCNF_Type * p_reg,
72 uint8_t port_idx,
73 uint32_t mask);
74
75 /**
76 * @brief Function for getting the configuration of control access to local peripheral
77 * memory regions. Intended for external master connected to specified AMLI master port.
78 *
79 * @param[in] p_reg Pointer to the structure of registers of the peripheral.
80 * @param[in] port_idx Index of the master port to configure.
81 *
82 * @return Mask of the AHB slaves that are currently protected.
83 */
84 NRF_STATIC_INLINE uint32_t nrf_dcnf_peripheral_access_get(NRF_DCNF_Type const * p_reg,
85 uint8_t port_idx);
86 #endif // defined(DCNF_EXTPERI_PROTECT_SLAVE0_Msk)
87
88 #if defined(DCNF_EXTRAM_PROTECT_SLAVE0_Msk)
89 /**
90 * @brief Function for configuring the control access to local RAM memory regions.
91 * Intended for external master connected to specified AMLI master port.
92 *
93 * @param[in] p_reg Pointer to the structure of registers of the peripheral.
94 * @param[in] port_idx Index of the master port to configure.
95 * @param[in] mask Mask of the AHB slaves to be protected from being accessed
96 * by external AHB masters.
97 */
98 NRF_STATIC_INLINE void nrf_dcnf_ram_access_set(NRF_DCNF_Type * p_reg,
99 uint8_t port_idx,
100 uint32_t mask);
101
102 /**
103 * @brief Function for getting the configuration of control access to local RAM
104 * memory regions. Intended for external master connected to specified AMLI master port.
105 *
106 * @param[in] p_reg Pointer to the structure of registers of the peripheral.
107 * @param[in] port_idx Index of the master port to configure.
108 *
109 * @return Mask of the AHB slaves that are currently protected.
110 */
111 NRF_STATIC_INLINE uint32_t nrf_dcnf_ram_access_get(NRF_DCNF_Type const * p_reg,
112 uint8_t port_idx);
113 #endif // defined(DCNF_EXTRAM_PROTECT_SLAVE0_Msk)
114
115 #if defined(DCNF_EXTCODE_PROTECT_SLAVE0_Msk)
116 /**
117 * @brief Function for configuring the control access to local code memory regions.
118 * Intended for external master connected to specified AMLI master port.
119 *
120 * @param[in] p_reg Pointer to the structure of registers of the peripheral.
121 * @param[in] port_idx Index of the master port to configure.
122 * @param[in] mask Mask of the AHB slaves to be protected from being accessed
123 * by external AHB masters.
124 */
125 NRF_STATIC_INLINE void nrf_dcnf_code_access_set(NRF_DCNF_Type * p_reg,
126 uint8_t port_idx,
127 uint32_t mask);
128
129 /**
130 * @brief Function for getting the configuration of control access to local code
131 * memory regions. Intended for external master connected to specified AMLI master port.
132 *
133 * @param[in] p_reg Pointer to the structure of registers of the peripheral.
134 * @param[in] port_idx Index of the master port to configure.
135 *
136 * @return Mask of the AHB slaves that are currently protected.
137 */
138 NRF_STATIC_INLINE uint32_t nrf_dcnf_code_access_get(NRF_DCNF_Type const * p_reg,
139 uint8_t port_idx);
140 #endif // defined(DCNF_EXTCODE_PROTECT_SLAVE0_Msk)
141
142 #ifndef NRF_DECLARE_ONLY
143
nrf_dcnf_cpuid_get(NRF_DCNF_Type const * p_reg)144 NRF_STATIC_INLINE uint32_t nrf_dcnf_cpuid_get(NRF_DCNF_Type const * p_reg)
145 {
146 return p_reg->CPUID;
147 }
148
149 #if defined(DCNF_EXTPERI_PROTECT_SLAVE0_Msk)
nrf_dcnf_peripheral_access_set(NRF_DCNF_Type * p_reg,uint8_t port_idx,uint32_t mask)150 NRF_STATIC_INLINE void nrf_dcnf_peripheral_access_set(NRF_DCNF_Type * p_reg,
151 uint8_t port_idx,
152 uint32_t mask)
153 {
154 p_reg->EXTPERI[port_idx].PROTECT = mask;
155 }
156
nrf_dcnf_peripheral_access_get(NRF_DCNF_Type const * p_reg,uint8_t port_idx)157 NRF_STATIC_INLINE uint32_t nrf_dcnf_peripheral_access_get(NRF_DCNF_Type const * p_reg,
158 uint8_t port_idx)
159 {
160 return p_reg->EXTPERI[port_idx].PROTECT;
161 }
162 #endif
163
164 #if defined(DCNF_EXTRAM_PROTECT_SLAVE0_Msk)
nrf_dcnf_ram_access_set(NRF_DCNF_Type * p_reg,uint8_t port_idx,uint32_t mask)165 NRF_STATIC_INLINE void nrf_dcnf_ram_access_set(NRF_DCNF_Type * p_reg,
166 uint8_t port_idx,
167 uint32_t mask)
168 {
169 p_reg->EXTRAM[port_idx].PROTECT = mask;
170 }
171
nrf_dcnf_ram_access_get(NRF_DCNF_Type const * p_reg,uint8_t port_idx)172 NRF_STATIC_INLINE uint32_t nrf_dcnf_ram_access_get(NRF_DCNF_Type const * p_reg,
173 uint8_t port_idx)
174 {
175 return p_reg->EXTRAM[port_idx].PROTECT;
176 }
177 #endif
178
179 #if defined(DCNF_EXTCODE_PROTECT_SLAVE0_Msk)
nrf_dcnf_code_access_set(NRF_DCNF_Type * p_reg,uint8_t port_idx,uint32_t mask)180 NRF_STATIC_INLINE void nrf_dcnf_code_access_set(NRF_DCNF_Type * p_reg,
181 uint8_t port_idx,
182 uint32_t mask)
183 {
184 p_reg->EXTCODE[port_idx].PROTECT = mask;
185 }
186
nrf_dcnf_code_access_get(NRF_DCNF_Type const * p_reg,uint8_t port_idx)187 NRF_STATIC_INLINE uint32_t nrf_dcnf_code_access_get(NRF_DCNF_Type const * p_reg,
188 uint8_t port_idx)
189 {
190 return p_reg->EXTCODE[port_idx].PROTECT;
191 }
192 #endif
193
194 #endif // NRF_DECLARE_ONLY
195
196 /** @} */
197
198 #ifdef __cplusplus
199 }
200 #endif
201
202 #endif // NRF_DCNF_H__
203