aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/SAMA/SAMA5D2x/sama_matrix.h
blob: b899d413bc368f448ec695dd59ead2d1e88b921d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
/*
    ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
*/

/**
 * @file    SAMA5D2x/sama_matrix.h
 * @brief   SAMA MATRIX support macros and structures.
 *
 * @addtogroup SAMA5D2x_MATRIX
 * @{
 */

#ifndef SAMA_MATRIX_H
#define SAMA_MATRIX_H

/*===========================================================================*/
/* Driver constants.                                                         */
/*===========================================================================*/
/**
 * @name    SECURE MATRIX mode macros
 * @{
 */
/**
 * @brief   The low area of region is the securable one.
 */
#define LOWER_AREA_SECURABLE     0x0u

/**
 * @brief   The upper area of region is the non-securable one.
 */
#define UPPER_AREA_SECURABLE     0x1u

/**
 * @brief   Securable area is secured for reads.
 */
#define SECURE_READ              0x0u

/**
 * @brief   Securable area is secured for writes.
 */
#define SECURE_WRITE             0x0u

/**
 * @brief   Securable area is non-secured for reads.
 */
#define NOT_SECURE_READ          0x1u

/**
 * @brief   Securable area is non-secured for writes.
 */
#define NOT_SECURE_WRITE         0x1u

/**
 * @brief   Peripheral Securable as secure.
 */
#define SECURE_PER               FALSE

/**
 * @brief   Peripheral Securable as not-secure.
 */
#define NOT_SECURE_PER           TRUE
/** @} */

/**
 * @name    MASTER TYPE MATRIX macros
 * @{
 */
/**
 * @brief   No Default Master.
 */
#define NO_DEFAULT_MASTER        0x0u

/**
 * @brief   Last Default Master.
 */
#define LAST_DEFAULT_MASTER      0x1u

/**
 * @brief   Fixed Default Master.
 */
#define FIXED_DEFAULT_MASTER     0x2u
/** @} */

/**
 * @name    REGION MATRIX MASK macros
 * @{
 */
/**
 * @brief   Region 0.
 */
#define REGION_0_MSK             (0x1u << 0)

/**
 * @brief   Region 1.
 */
#define REGION_1_MSK             (0x1u << 1)

/**
 * @brief   Region 2.
 */
#define REGION_2_MSK             (0x1u << 2)

/**
 * @brief   Region 3.
 */
#define REGION_3_MSK             (0x1u << 3)

/**
 * @brief   Region 4.
 */
#define REGION_4_MSK             (0x1u << 4)

/**
 * @brief   Region 5.
 */
#define REGION_5_MSK             (0x1u << 5)

/**
 * @brief   Region 6.
 */
#define REGION_6_MSK             (0x1u << 6)

/**
 * @brief   Region 7.
 */
#define REGION_7_MSK             (0x1u << 7)
/** @} */

/**
 * @name    REGION MATRIX macros
 * @{
 */
/**
 * @brief   Region 0.
 */
#define REGION_0                 0x0u

/**
 * @brief   Region 1.
 */
#define REGION_1                 0x1u

/**
 * @brief   Region 2.
 */
#define REGION_2                 0x2u

/**
 * @brief   Region 3.
 */
#define REGION_3                 0x3u

/**
 * @brief   Region 4.
 */
#define REGION_4                 0x4u

/**
 * @brief   Region 5.
 */
#define REGION_5                 0x5u

/**
 * @brief   Region 6.
 */
#define REGION_6                 0x6u

/**
 * @brief   Region 7.
 */
#define REGION_7                 0x7u
/** @} */

/**
 * @name    AREA SIZE MATRIX macros
 * @{
 */
/**
 * @brief   Area size 4 KB.
 */
#define MATRIX_AREA_SIZE_4K      0x0u

/**
 * @brief   Area size 8 KB.
 */
#define MATRIX_AREA_SIZE_8K      0x1u

/**
 * @brief   Area size 16 KB.
 */
#define MATRIX_AREA_SIZE_16K     0x2u

/**
 * @brief   Area size 32 KB.
 */
#define MATRIX_AREA_SIZE_32K     0x3u

/**
 * @brief   Area size 64 KB.
 */
#define MATRIX_AREA_SIZE_64K     0x4u

/**
 * @brief   Area size 128 KB.
 */
#define MATRIX_AREA_SIZE_128K    0x5u

/**
 * @brief   Area size 256 KB.
 */
#define MATRIX_AREA_SIZE_256K    0x6u

/**
 * @brief   Area size 512 KB.
 */
#define MATRIX_AREA_SIZE_512K    0x7u

/**
 * @brief   Area size 1 MB.
 */
#define MATRIX_AREA_SIZE_1M      0x8u

/**
 * @brief   Area size 2 MB.
 */
#define MATRIX_AREA_SIZE_2M      0x9u

/**
 * @brief   Area size 4 MB.
 */
#define MATRIX_AREA_SIZE_4M      0xAu

/**
 * @brief   Area size 8 MB.
 */
#define MATRIX_AREA_SIZE_8M      0xBu

/**
 * @brief   Area size 16 MB.
 */
#define MATRIX_AREA_SIZE_16M     0xCu

/**
 * @brief   Area size 32 MB.
 */
#define MATRIX_AREA_SIZE_32M     0xDu

/**
 * @brief   Area size 64 MB.
 */
#define MATRIX_AREA_SIZE_64M     0xEu

/**
 * @brief   Area size 128 MB.
 */
#define MATRIX_AREA_SIZE_128M    0xFu
/** @} */

/*===========================================================================*/
/* Driver pre-compile time settings.                                         */
/*===========================================================================*/

/*===========================================================================*/
/* Derived constants and error checks.                                       */
/*===========================================================================*/

/*===========================================================================*/
/* Driver data structures and types.                                         */
/*===========================================================================*/

/*===========================================================================*/
/* Driver macros.                                                            */
/*===========================================================================*/
/**
 * @brief   Configure LANSECH per Region.
 *
 * @param[in] region    Region to configure.
 * @param[in] lansech   Securable mode.
 *
 * @api
 */
#define mtxRegionLansech(region, lansech)                   (lansech << region)

/**
 * @brief   Configure RDNSECH per Region.
 *
 * @param[in] region    Region to configure.
 * @param[in] rdnsech   Read securable mode.
 *
 * @api
 */
#define mtxRegionRdnsech(region, rdnsech)                   (rdnsech << region)

/**
 * @brief   Configure WRNSECH per Region.
 *
 * @param[in] region    Region to configure.
 * @param[in] wrnsech   Write securable mode.
 *
 * @api
 */
#define mtxRegionWrnsech(region, wrnsech)                   (wrnsech << region)

/*===========================================================================*/
/* External declarations.                                                    */
/*===========================================================================*/

#ifdef __cplusplus
extern "C" {
#endif
 bool mtxConfigPeriphSecurity(Matrix *mtxp, uint32_t id, bool mode);
 void mtxConfigDefaultMaster(Matrix *mtxp, uint8_t slaveID,
                             uint8_t type, uint8_t masterID);
 void mtxConfigSlaveSec(Matrix *mtxp, uint8_t slaveID,
                        uint8_t selMask, uint8_t readMask,
                        uint8_t writeMask);
 void mtxSetSlaveSplitAddr(Matrix *mtxp, uint8_t slaveID,
                           uint8_t area, uint8_t mask);
 void mtxSetSlaveRegionSize(Matrix *mtxp, uint8_t slaveID,
                            uint8_t areaSize, uint8_t mask);
 void mtxRemapRom(void);
 void mtxRemapRam(void);
#ifdef __cplusplus
}
#endif

#endif /* SAMA_MATRIX_H */

/** @} */