HPM SDK
HPMicro Software Development Kit
hpm_exip_regs.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021-2023 HPMicro
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 
9 #ifndef HPM_EXIP_H
10 #define HPM_EXIP_H
11 
12 typedef struct {
13  __R uint8_t RESERVED0[3072]; /* 0x0 - 0xBFF: Reserved */
14  __RW uint32_t CFG; /* 0xC00: Configure Register */
15  __R uint32_t STA; /* 0xC04: Status Register */
16  __R uint8_t RESERVED1[248]; /* 0xC08 - 0xCFF: Reserved */
17  struct {
18  __RW uint32_t KEY0; /* 0xD00: AES KEY */
19  __RW uint32_t KEY1; /* 0xD04: AES KEY */
20  __RW uint32_t KEY2; /* 0xD08: AES KEY */
21  __RW uint32_t KEY3; /* 0xD0C: AES KEY */
22  __RW uint32_t CTR0; /* 0xD10: AES Counter Word */
23  __RW uint32_t CTR1; /* 0xD14: AES Counter Word */
24  __RW uint32_t RGN_SA; /* 0xD18: AES Region Descriptor Word */
25  __RW uint32_t RGN_EA; /* 0xD1C: AES Region Descriptor Word */
26  __R uint8_t RESERVED0[32]; /* 0xD20 - 0xD3F: Reserved */
27  } RGN[4];
28 } EXIP_Type;
29 
30 
31 /* Bitfield definition for register: CFG */
32 /*
33  * EXIPE (RW)
34  *
35  * Block Enable, when set to "0", this block disabled, and all the data from QSPI will pass the the read mast directly; EXIP process data as the configuration in the CR regs.
36  */
37 #define EXIP_CFG_EXIPE_MASK (0x80000000UL)
38 #define EXIP_CFG_EXIPE_SHIFT (31U)
39 #define EXIP_CFG_EXIPE_SET(x) (((uint32_t)(x) << EXIP_CFG_EXIPE_SHIFT) & EXIP_CFG_EXIPE_MASK)
40 #define EXIP_CFG_EXIPE_GET(x) (((uint32_t)(x) & EXIP_CFG_EXIPE_MASK) >> EXIP_CFG_EXIPE_SHIFT)
41 
42 /*
43  * KBS (RW)
44  *
45  * KeyBlob Initiate
46  * "0", Key Blob was not initiated yet.
47  * "1", Key Blob was properly initiated.
48  */
49 #define EXIP_CFG_KBS_MASK (0x40000000UL)
50 #define EXIP_CFG_KBS_SHIFT (30U)
51 #define EXIP_CFG_KBS_SET(x) (((uint32_t)(x) << EXIP_CFG_KBS_SHIFT) & EXIP_CFG_KBS_MASK)
52 #define EXIP_CFG_KBS_GET(x) (((uint32_t)(x) & EXIP_CFG_KBS_MASK) >> EXIP_CFG_KBS_SHIFT)
53 
54 /*
55  * KBEN (RW)
56  *
57  * Key Block Processing Enable.
58  * "0", key blob processing is enabled.
59  * "1", Key blob processing is disabled.
60  */
61 #define EXIP_CFG_KBEN_MASK (0x20U)
62 #define EXIP_CFG_KBEN_SHIFT (5U)
63 #define EXIP_CFG_KBEN_SET(x) (((uint32_t)(x) << EXIP_CFG_KBEN_SHIFT) & EXIP_CFG_KBEN_MASK)
64 #define EXIP_CFG_KBEN_GET(x) (((uint32_t)(x) & EXIP_CFG_KBEN_MASK) >> EXIP_CFG_KBEN_SHIFT)
65 
66 /*
67  * IE (RW)
68  *
69  * Interrupt Request Enable. This field determines if the setting of SR[KBERR] generates a system interrupt.
70  * 0b - SR[KBERR] = 1 does not generate an interrupt request.
71  * 1b - SR[KBERR] = 1 generates an interrupt request.
72  */
73 #define EXIP_CFG_IE_MASK (0x1U)
74 #define EXIP_CFG_IE_SHIFT (0U)
75 #define EXIP_CFG_IE_SET(x) (((uint32_t)(x) << EXIP_CFG_IE_SHIFT) & EXIP_CFG_IE_MASK)
76 #define EXIP_CFG_IE_GET(x) (((uint32_t)(x) & EXIP_CFG_IE_MASK) >> EXIP_CFG_IE_SHIFT)
77 
78 /* Bitfield definition for register: STA */
79 /*
80  * KBC (RO)
81  *
82  * Key Blob Processing Done
83  * "0", key blob was not enabled or processing not done yet.
84  * "1", key blob processing was enabled and done.
85  */
86 #define EXIP_STA_KBC_MASK (0x80000000UL)
87 #define EXIP_STA_KBC_SHIFT (31U)
88 #define EXIP_STA_KBC_GET(x) (((uint32_t)(x) & EXIP_STA_KBC_MASK) >> EXIP_STA_KBC_SHIFT)
89 
90 /*
91  * KBEN (RO)
92  *
93  * Key Blob Processing Enable
94  * “0”, Key Blob processing is not enabled.
95  * "1", Key Blob processing is enabled.
96  */
97 #define EXIP_STA_KBEN_MASK (0x40000000UL)
98 #define EXIP_STA_KBEN_SHIFT (30U)
99 #define EXIP_STA_KBEN_GET(x) (((uint32_t)(x) & EXIP_STA_KBEN_MASK) >> EXIP_STA_KBEN_SHIFT)
100 
101 /*
102  * EXIPE (RO)
103  *
104  * Block Enable Mode.
105  * "0", EXIP disabled and bypasses all the data by the QSPI
106  * "1", EXIP is enabled, and processes data from the QSPI as the hw configuration bits.
107  */
108 #define EXIP_STA_EXIPE_MASK (0x20000000UL)
109 #define EXIP_STA_EXIPE_SHIFT (29U)
110 #define EXIP_STA_EXIPE_GET(x) (((uint32_t)(x) & EXIP_STA_EXIPE_MASK) >> EXIP_STA_EXIPE_SHIFT)
111 
112 /*
113  * RGNE (RO)
114  *
115  * Context Integrity Error.
116  * This field signals an integrity error was detected in a specific context during key blob processing as signaled by SR[KBERR] = 1. bit 19 corresponds to context 3, bit 18 to context 2, bit 17 to context 1, bit 16 to context 0.
117  * This field is cleared if SR[KBERR] was set in response to a write asserting CR[FERR]. It is also cleared when SR[KBERR] is cleared.
118  * 0000b - No key blob integrity error was detected for context “n”.
119  * 0001b - A key blob integrity error was detected in context “n”.
120  */
121 #define EXIP_STA_RGNE_MASK (0xF0000UL)
122 #define EXIP_STA_RGNE_SHIFT (16U)
123 #define EXIP_STA_RGNE_GET(x) (((uint32_t)(x) & EXIP_STA_RGNE_MASK) >> EXIP_STA_RGNE_SHIFT)
124 
125 /*
126  * KBERR (RO)
127  *
128  * Key Blob Error
129  * This field signals that one or more errors were detected during key blob processing. SR[ERCTX] provides
130  * the details on which contexts detected errors. This indicator can also be set by writing CR[FERR] = 1 (for
131  * testing purposes). If CR[IRQE] = 1, then the assertion of KBERR generates an interrupt request.
132  * "0", No key blob error detected.
133  * "1", One or more key blob errors has been detected
134  */
135 #define EXIP_STA_KBERR_MASK (0x1U)
136 #define EXIP_STA_KBERR_SHIFT (0U)
137 #define EXIP_STA_KBERR_GET(x) (((uint32_t)(x) & EXIP_STA_KBERR_MASK) >> EXIP_STA_KBERR_SHIFT)
138 
139 /* Bitfield definition for register of struct array RGN: KEY0 */
140 /*
141  * KEY (RW)
142  *
143  * AES Key
144  * The key is typically loaded as the corresponding key blob is unwrapped; alternatively, if enabled, it can be
145  * written using the APB bus. The four consecutive little-endian memory-mapped registers
146  * provide 128 bits of key storage.
147  * Word0: KEY[31:0][A03, A02, A01, A00]
148  * Word1: KEY[31:0][A07, A06, A05, A04]
149  * Word2: KEY[31:0][A11, A10, A09, A08]
150  * Word3: KEY[31:0][A15, A14, A13, A12]
151  */
152 #define EXIP_RGN_KEY0_KEY_MASK (0xFFFFFFFFUL)
153 #define EXIP_RGN_KEY0_KEY_SHIFT (0U)
154 #define EXIP_RGN_KEY0_KEY_SET(x) (((uint32_t)(x) << EXIP_RGN_KEY0_KEY_SHIFT) & EXIP_RGN_KEY0_KEY_MASK)
155 #define EXIP_RGN_KEY0_KEY_GET(x) (((uint32_t)(x) & EXIP_RGN_KEY0_KEY_MASK) >> EXIP_RGN_KEY0_KEY_SHIFT)
156 
157 /* Bitfield definition for register of struct array RGN: KEY1 */
158 /*
159  * KEY (RW)
160  *
161  * AES Key
162  * The key is typically loaded as the corresponding key blob is unwrapped; alternatively, if enabled, it can be
163  * written using the APB bus. The four consecutive little-endian memory-mapped registers
164  * provide 128 bits of key storage.
165  * Word0: KEY[31:0][A03, A02, A01, A00]
166  * Word1: KEY[31:0][A07, A06, A05, A04]
167  * Word2: KEY[31:0][A11, A10, A09, A08]
168  * Word3: KEY[31:0][A15, A14, A13, A12]
169  */
170 #define EXIP_RGN_KEY1_KEY_MASK (0xFFFFFFFFUL)
171 #define EXIP_RGN_KEY1_KEY_SHIFT (0U)
172 #define EXIP_RGN_KEY1_KEY_SET(x) (((uint32_t)(x) << EXIP_RGN_KEY1_KEY_SHIFT) & EXIP_RGN_KEY1_KEY_MASK)
173 #define EXIP_RGN_KEY1_KEY_GET(x) (((uint32_t)(x) & EXIP_RGN_KEY1_KEY_MASK) >> EXIP_RGN_KEY1_KEY_SHIFT)
174 
175 /* Bitfield definition for register of struct array RGN: KEY2 */
176 /*
177  * KEY (RW)
178  *
179  * AES Key
180  * The key is typically loaded as the corresponding key blob is unwrapped; alternatively, if enabled, it can be
181  * written using the APB bus. The four consecutive little-endian memory-mapped registers
182  * provide 128 bits of key storage.
183  * Word0: KEY[31:0][A03, A02, A01, A00]
184  * Word1: KEY[31:0][A07, A06, A05, A04]
185  * Word2: KEY[31:0][A11, A10, A09, A08]
186  * Word3: KEY[31:0][A15, A14, A13, A12]
187  */
188 #define EXIP_RGN_KEY2_KEY_MASK (0xFFFFFFFFUL)
189 #define EXIP_RGN_KEY2_KEY_SHIFT (0U)
190 #define EXIP_RGN_KEY2_KEY_SET(x) (((uint32_t)(x) << EXIP_RGN_KEY2_KEY_SHIFT) & EXIP_RGN_KEY2_KEY_MASK)
191 #define EXIP_RGN_KEY2_KEY_GET(x) (((uint32_t)(x) & EXIP_RGN_KEY2_KEY_MASK) >> EXIP_RGN_KEY2_KEY_SHIFT)
192 
193 /* Bitfield definition for register of struct array RGN: KEY3 */
194 /*
195  * KEY (RW)
196  *
197  * AES Key
198  * The key is typically loaded as the corresponding key blob is unwrapped; alternatively, if enabled, it can be
199  * written using the APB bus. The four consecutive little-endian memory-mapped registers
200  * provide 128 bits of key storage.
201  * Word0: KEY[31:0][A03, A02, A01, A00]
202  * Word1: KEY[31:0][A07, A06, A05, A04]
203  * Word2: KEY[31:0][A11, A10, A09, A08]
204  * Word3: KEY[31:0][A15, A14, A13, A12]
205  */
206 #define EXIP_RGN_KEY3_KEY_MASK (0xFFFFFFFFUL)
207 #define EXIP_RGN_KEY3_KEY_SHIFT (0U)
208 #define EXIP_RGN_KEY3_KEY_SET(x) (((uint32_t)(x) << EXIP_RGN_KEY3_KEY_SHIFT) & EXIP_RGN_KEY3_KEY_MASK)
209 #define EXIP_RGN_KEY3_KEY_GET(x) (((uint32_t)(x) & EXIP_RGN_KEY3_KEY_MASK) >> EXIP_RGN_KEY3_KEY_SHIFT)
210 
211 /* Bitfield definition for register of struct array RGN: CTR0 */
212 /*
213  * CTR (RW)
214  *
215  * AES Counter
216  * The upper 64 bits of the counter are typically loaded as the corresponding key blob is unwrapped;
217  * alternatively, if enabled, it can be written using the slave peripheral bus. The two consecutive memorymapped registers directly provide the upper 64 bits of counter storage.
218  * Word0: CTR[31:0][C3, C2, C1, C0]
219  * Word1: CTR[31:0][C7, C6, C5, C4]
220  * The third 32-bit portion of the CTR is formed by exclusive-or’ing the upper 64 bits of the counter as two
221  * 32-bit values, while the least-significant portion of the counter is the 32-bit 0-modulo-16 byte system
222  * address of the external flash memory.
223  * CTR[C0...C15] = {CTR[C0...C7], CTR[C0...C3] ^ CTR[C4...C7], systemAddress[31–4], 0h}
224  */
225 #define EXIP_RGN_CTR0_CTR_MASK (0xFFFFFFFFUL)
226 #define EXIP_RGN_CTR0_CTR_SHIFT (0U)
227 #define EXIP_RGN_CTR0_CTR_SET(x) (((uint32_t)(x) << EXIP_RGN_CTR0_CTR_SHIFT) & EXIP_RGN_CTR0_CTR_MASK)
228 #define EXIP_RGN_CTR0_CTR_GET(x) (((uint32_t)(x) & EXIP_RGN_CTR0_CTR_MASK) >> EXIP_RGN_CTR0_CTR_SHIFT)
229 
230 /* Bitfield definition for register of struct array RGN: CTR1 */
231 /*
232  * CTR (RW)
233  *
234  * AES Counter
235  * The upper 64 bits of the counter are typically loaded as the corresponding key blob is unwrapped;
236  * alternatively, if enabled, it can be written using the slave peripheral bus. The two consecutive memorymapped registers directly provide the upper 64 bits of counter storage.
237  * Word0: CTR[31:0][C3, C2, C1, C0]
238  * Word1: CTR[31:0][C7, C6, C5, C4]
239  * The third 32-bit portion of the CTR is formed by exclusive-or’ing the upper 64 bits of the counter as two
240  * 32-bit values, while the least-significant portion of the counter is the 32-bit 0-modulo-16 byte system
241  * address of the external flash memory.
242  * CTR[C0...C15] = {CTR[C0...C7], CTR[C0...C3] ^ CTR[C4...C7], systemAddress[31–4], 0h}
243  */
244 #define EXIP_RGN_CTR1_CTR_MASK (0xFFFFFFFFUL)
245 #define EXIP_RGN_CTR1_CTR_SHIFT (0U)
246 #define EXIP_RGN_CTR1_CTR_SET(x) (((uint32_t)(x) << EXIP_RGN_CTR1_CTR_SHIFT) & EXIP_RGN_CTR1_CTR_MASK)
247 #define EXIP_RGN_CTR1_CTR_GET(x) (((uint32_t)(x) & EXIP_RGN_CTR1_CTR_MASK) >> EXIP_RGN_CTR1_CTR_SHIFT)
248 
249 /* Bitfield definition for register of struct array RGN: RGN_SA */
250 /*
251  * START (RW)
252  *
253  * Start Address
254  * This field defines the most significant bits of the 0-modulo-1024 byte start address of the memory region
255  * for context n.
256  */
257 #define EXIP_RGN_RGN_SA_START_MASK (0xFFFFFC00UL)
258 #define EXIP_RGN_RGN_SA_START_SHIFT (10U)
259 #define EXIP_RGN_RGN_SA_START_SET(x) (((uint32_t)(x) << EXIP_RGN_RGN_SA_START_SHIFT) & EXIP_RGN_RGN_SA_START_MASK)
260 #define EXIP_RGN_RGN_SA_START_GET(x) (((uint32_t)(x) & EXIP_RGN_RGN_SA_START_MASK) >> EXIP_RGN_RGN_SA_START_SHIFT)
261 
262 /* Bitfield definition for register of struct array RGN: RGN_EA */
263 /*
264  * END (RW)
265  *
266  * End Address
267  * This field defines the most significant bits of the 1023-modulo-1024 byte end address of the memory
268  * region for context n.
269  */
270 #define EXIP_RGN_RGN_EA_END_MASK (0xFFFFFC00UL)
271 #define EXIP_RGN_RGN_EA_END_SHIFT (10U)
272 #define EXIP_RGN_RGN_EA_END_SET(x) (((uint32_t)(x) << EXIP_RGN_RGN_EA_END_SHIFT) & EXIP_RGN_RGN_EA_END_MASK)
273 #define EXIP_RGN_RGN_EA_END_GET(x) (((uint32_t)(x) & EXIP_RGN_RGN_EA_END_MASK) >> EXIP_RGN_RGN_EA_END_SHIFT)
274 
275 /*
276  * DECEN (RW)
277  *
278  * AES Decryption Enable.
279  * For accesses hitting in a valid context, this bit indicates if the fetched data is to be decrypted or simply
280  * bypassed.
281  * "0" - Bypass the fetched data.
282  * "1" - Perform the CTR-AES128 mode decryption on the fetched data
283  */
284 #define EXIP_RGN_RGN_EA_DECEN_MASK (0x2U)
285 #define EXIP_RGN_RGN_EA_DECEN_SHIFT (1U)
286 #define EXIP_RGN_RGN_EA_DECEN_SET(x) (((uint32_t)(x) << EXIP_RGN_RGN_EA_DECEN_SHIFT) & EXIP_RGN_RGN_EA_DECEN_MASK)
287 #define EXIP_RGN_RGN_EA_DECEN_GET(x) (((uint32_t)(x) & EXIP_RGN_RGN_EA_DECEN_MASK) >> EXIP_RGN_RGN_EA_DECEN_SHIFT)
288 
289 /*
290  * VALID (RW)
291  *
292  * Valid
293  * This field signals if the context is valid or not.
294  * "0" - Context is invalid.
295  * "1" - Context is valid.
296  */
297 #define EXIP_RGN_RGN_EA_VALID_MASK (0x1U)
298 #define EXIP_RGN_RGN_EA_VALID_SHIFT (0U)
299 #define EXIP_RGN_RGN_EA_VALID_SET(x) (((uint32_t)(x) << EXIP_RGN_RGN_EA_VALID_SHIFT) & EXIP_RGN_RGN_EA_VALID_MASK)
300 #define EXIP_RGN_RGN_EA_VALID_GET(x) (((uint32_t)(x) & EXIP_RGN_RGN_EA_VALID_MASK) >> EXIP_RGN_RGN_EA_VALID_SHIFT)
301 
302 
303 
304 /* RGN register group index macro definition */
305 #define EXIP_RGN_0 (0UL)
306 #define EXIP_RGN_1 (1UL)
307 #define EXIP_RGN_2 (2UL)
308 #define EXIP_RGN_3 (3UL)
309 
310 
311 #endif /* HPM_EXIP_H */
Definition: hpm_exip_regs.h:12