AM64x MCU+ SDK  08.05.00
firewall/v0/firewall.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2022 Texas Instruments Incorporated
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
49 #ifndef FIREWALL_H_
50 #define FIREWALL_H_
51 
52 /* ========================================================================== */
53 /* Include Files */
54 /* ========================================================================== */
55 
56 #include <stdint.h>
57 #include <drivers/soc.h>
58 #include <kernel/dpl/HwiP.h>
59 #include <kernel/dpl/SemaphoreP.h>
60 
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64 
65 /* ========================================================================== */
66 /* Macros & Typedefs */
67 /* ========================================================================== */
68 
72 #define FWL_MAX_PRIVID_SLOTS (3U)
73 
82 #define PRIVID_NONE (0U)
83 #define PRIVID_EVERYONE (195U)
84 #define PRIVID_DMSC (202U)
85 #define PRIVID_BLOCK_EVERYONE (197U)
86 #define PRIVID_SPROXY_PRIVATE (11U)
87 #define PRIVID_A53_NON_SECURE (1U)
88 #define PRIVID_A53_SECURE (1U)
89 #define PRIVID_M4_0_NON_SECURE (100U)
90 #define PRIVID_MAIN_0_R5_0_NONSECURE (212U)
91 #define PRIVID_MAIN_0_R5_0_SECURE (212U)
92 #define PRIVID_MAIN_0_R5_1_NONSECURE (213U)
93 #define PRIVID_MAIN_0_R5_1_SECURE (213U)
94 #define PRIVID_MAIN_1_R5_0_NONSECURE (214U)
95 #define PRIVID_MAIN_1_R5_0_SECURE (214U)
96 #define PRIVID_MAIN_1_R5_1_NONSECURE (215U)
97 #define PRIVID_MAIN_1_R5_1_SECURE (215U)
98 #define PRIVID_MAIN_0_ICSSG_0 (136U)
99 
109 #define FWL_CONTROL_ENABLE_MASK (0xFU)
110 #define FWL_CONTROL_DISABLE (0x0U)
111 #define FWL_CONTROL_ENABLE (0xAU)
112 #define FWL_CONTROL_LOCK (0x10U)
113 #define FWL_CONTROL_BG (0x100U)
114 #define FWL_CONTROL_CACHE_MODE (0x200U)
115 
125 #define FWL_PERM_SEC_MASK (0x00FFU)
126 #define FWL_PERM_NSEC_MASK (0xFF00U)
127 #define FWL_PERM_PRIV_MASK (0x0F0FU)
128 #define FWL_PERM_USER_MASK (0xF0F0U)
129 
130 #define FWL_PERM_WRITE_MASK (0x1111U)
131 #define FWL_PERM_READ_MASK (0x2222U)
132 #define FWL_PERM_CACHE_MASK (0x4444U)
133 #define FWL_PERM_DEBUG_MASK (0x8888U)
134 #define FWL_PERM_DENY_ALL (0x0000U)
135 
145 #define FWL_PERM_RW_ALL (FWL_PERM_WRITE_MASK | \
146  FWL_PERM_READ_MASK | \
147  FWL_PERM_CACHE_MASK | \
148  FWL_PERM_DEBUG_MASK)
149 
150 #define FWL_PERM_RO_ALL (FWL_PERM_READ_MASK | \
151  FWL_PERM_CACHE_MASK | \
152  FWL_PERM_DEBUG_MASK)
153 
154 #define FWL_PERM_WO_ALL (FWL_PERM_WRITE_MASK | \
155  FWL_PERM_CACHE_MASK | \
156  FWL_PERM_DEBUG_MASK)
157 
158 #define FWL_PERM_SEC_RW (FWL_PERM_SEC_MASK & \
159  FWL_PERM_RW_ALL)
160 
161 #define FWL_PERM_NSEC_RW (FWL_PERM_NSEC_MASK & \
162  FWL_PERM_RW_ALL)
163 
164 #define FWL_PERM_PRIV_RW (FWL_PERM_PRIV_MASK & \
165  FWL_PERM_RW_ALL)
166 
167 #define FWL_PERM_USER_RW (FWL_PERM_USER_MASK & \
168  FWL_PERM_RW_ALL)
169 
170 #define FWL_PERM_SEC_RO (FWL_PERM_SEC_MASK & \
171  FWL_PERM_RO_ALL)
172 
173 #define FWL_PERM_NSEC_RO (FWL_PERM_NSEC_MASK & \
174  FWL_PERM_RO_ALL)
175 
176 #define FWL_PERM_PRIV_RO (FWL_PERM_PRIV_MASK & \
177  FWL_PERM_RO_ALL)
178 
179 #define FWL_PERM_USER_RO (FWL_PERM_USER_MASK & \
180  FWL_PERM_RO_ALL)
181 
183 /* ========================================================================== */
184 /* Structure Definitions */
185 /* ========================================================================== */
186 
187 
192 typedef struct
193 {
195  uint16_t regionIndex;
197  uint32_t control;
201  uint64_t startAddr;
203  uint64_t endAddr;
205 
214 typedef struct {
215  /* Id of Firewall to be used */
216  uint32_t firewallId;
217  /* Number of regions in the firewall */
218  uint32_t totalRegions;
219  /* Number of regions initialized */
220  uint32_t initRegions;
221  /* Region configuration */
224 
225 
229 typedef void *Firewall_Handle;
230 
234 typedef struct
235 {
239  uint32_t cfgDone;
241 
246 typedef struct
247 {
252 
254 
255 /* ========================================================================== */
256 /* Function Declarations */
257 /* ========================================================================== */
258 
262 void Firewall_init(void);
263 
267 void Firewall_deinit(void);
268 
279 
288 
298 
299 
300 
301 #ifdef __cplusplus
302 }
303 #endif
304 
305 #endif /* #ifndef FIREWALL_H_ */
306 
Firewall_RegionCfg::endAddr
uint64_t endAddr
Definition: firewall/v0/firewall.h:203
Firewall_Attrs::totalRegions
uint32_t totalRegions
Definition: firewall/v0/firewall.h:218
Firewall_RegionCfg::control
uint32_t control
Definition: firewall/v0/firewall.h:197
Firewall_Attrs
Firewall atributes.
Definition: firewall/v0/firewall.h:214
Firewall_Config
Firewall Instance Configuration. Pointer to this object is returned as handle by driver open.
Definition: firewall/v0/firewall.h:247
FWL_MAX_PRIVID_SLOTS
#define FWL_MAX_PRIVID_SLOTS
Maximun number of privilege ID slots.
Definition: firewall/v0/firewall.h:72
Firewall_init
void Firewall_init(void)
This function initializes the firewall module.
Firewall_RegionCfg
Firewall Region Cfg specifies the MMR configuration for the specified firewall ID.
Definition: firewall/v0/firewall.h:193
SemaphoreP.h
Firewall_RegionCfg::startAddr
uint64_t startAddr
Definition: firewall/v0/firewall.h:201
Firewall_Object
Firewall driver Object.
Definition: firewall/v0/firewall.h:235
Firewall_Attrs::firewallId
uint32_t firewallId
Definition: firewall/v0/firewall.h:216
Firewall_Object::handle
Firewall_Handle handle
Definition: firewall/v0/firewall.h:237
HwiP.h
Firewall_open
int32_t Firewall_open(Firewall_Handle handle)
This function opens a given Firewall peripheral.
Firewall_Attrs::regionInfo
Firewall_RegionCfg * regionInfo
Definition: firewall/v0/firewall.h:222
Firewall_configureRegion
int32_t Firewall_configureRegion(Firewall_Handle handle, Firewall_Attrs *attrs)
Intialize a firewall with multiple regions.
Firewall_deinit
void Firewall_deinit(void)
This function de-initializes the firewall module.
Firewall_Attrs::initRegions
uint32_t initRegions
Definition: firewall/v0/firewall.h:220
Firewall_close
void Firewall_close(Firewall_Handle handle)
Function to close Firewall peripheral specified by firewall handle.
Firewall_Config::attrs
Firewall_Attrs * attrs
Definition: firewall/v0/firewall.h:249
permissions
uint32_t permissions[FWL_MAX_PRIVID_SLOTS]
Definition: tisci_firewall.h:5
Firewall_RegionCfg::regionIndex
uint16_t regionIndex
Definition: firewall/v0/firewall.h:195
Firewall_Config::object
Firewall_Object * object
Definition: firewall/v0/firewall.h:251
Firewall_Handle
void * Firewall_Handle
A handle that is initialized in Firewall_open() call.
Definition: firewall/v0/firewall.h:229
Firewall_Object::cfgDone
uint32_t cfgDone
Definition: firewall/v0/firewall.h:239