1
1
/* mbed Microcontroller Library
2
- *
2
+ *
3
3
* \copyright
4
4
5
5
* (c) 2018, Cypress Semiconductor Corporation
25
25
#define _CYPROTECTION_CONFIG_H_
26
26
27
27
#include "cyprotection.h"
28
+ #include "mbed_assert.h"
28
29
29
30
/* Add to M0_PSA target in targets.json:
30
31
* - INITIAL_ROT_PROTECTION_AVAILABLE - to disable pc0 related protections
@@ -42,10 +43,46 @@ CY_PROT_PCMASK3 + CY_PROT_PCMASK4)
42
43
43
44
#define ALL_SUBREGIONS (0x0)
44
45
46
+
47
+ /* protected rom region size */
48
+
49
+ #if PSA_SECURE_ROM_SIZE == 0x10000
50
+ #define CY_PROT_ROM_REGION_SIZE CY_PROT_SIZE_64KB /* 0x10000 */
51
+ #elif PSA_SECURE_ROM_SIZE == 0x20000
52
+ #define CY_PROT_ROM_REGION_SIZE CY_PROT_SIZE_128KB /* 0x20000 */
53
+ #elif PSA_SECURE_ROM_SIZE == 0x40000
54
+ #define CY_PROT_ROM_REGION_SIZE CY_PROT_SIZE_256KB /* 0x40000 */
55
+ #elif PSA_SECURE_ROM_SIZE == 0x80000
56
+ #define CY_PROT_ROM_REGION_SIZE CY_PROT_SIZE_512KB /* 0x80000 */
57
+ #elif PSA_SECURE_ROM_SIZE == 0x100000
58
+ #define CY_PROT_ROM_REGION_SIZE CY_PROT_SIZE_1MB /* 0x100000 */
59
+ #else
60
+ #error unsupported protected rom region size - not aligned or out of range
61
+ #endif
62
+
63
+
64
+ /* protected ram region size */
65
+
66
+ #if PSA_SECURE_RAM_SIZE == 0x8000
67
+ #define CY_PROT_RAM_REGION_SIZE CY_PROT_SIZE_32KB /* 0x8000 */
68
+ #elif PSA_SECURE_RAM_SIZE == 0x10000
69
+ #define CY_PROT_RAM_REGION_SIZE CY_PROT_SIZE_64KB /* 0x10000 */
70
+ #elif PSA_SECURE_RAM_SIZE == 0x20000
71
+ #define CY_PROT_RAM_REGION_SIZE CY_PROT_SIZE_128KB /* 0x20000 */
72
+ #elif PSA_SECURE_RAM_SIZE == 0x40000
73
+ #define CY_PROT_RAM_REGION_SIZE CY_PROT_SIZE_256KB /* 0x40000 */
74
+ #else
75
+ #error unsupported protected ram region size - not aligned or out of range
76
+ #endif
77
+
78
+ MBED_STATIC_ASSERT ((PSA_SECURE_ROM_START % PSA_SECURE_ROM_SIZE ) == 0 , "PSA_SECURE_ROM_START is not alligned with PSA_SECURE_ROM_SIZE" );
79
+ MBED_STATIC_ASSERT ((PSA_SECURE_RAM_START % PSA_SECURE_RAM_SIZE ) == 0 , "PSA_SECURE_RAM_START is not alligned with PSA_SECURE_RAM_SIZE" );
80
+
81
+
45
82
const cy_smpu_region_config_t flash_spm_smpu_config [] = {
46
83
{ /* FLASH_PC1_SPM */
47
84
.address = (uint32_t * )PSA_SECURE_ROM_START , /* 0x10000000 */
48
- .regionSize = CY_PROT_SIZE_512KB , /* 0x80000 */
85
+ .regionSize = CY_PROT_ROM_REGION_SIZE ,
49
86
.subregions = ALL_SUBREGIONS ,
50
87
.userPermission = CY_PROT_PERM_RWX ,
51
88
.privPermission = CY_PROT_PERM_RWX ,
@@ -62,7 +99,7 @@ const cy_smpu_region_config_t flash_spm_smpu_config[] = {
62
99
const cy_smpu_region_config_t sram_spm_smpu_config [] = {
63
100
{ /* SRAM_SPM_PRIV - must include SRAM_SPM_PUB area */
64
101
.address = (uint32_t * )PSA_SECURE_RAM_START , /* 0x08020000 */
65
- .regionSize = CY_PROT_SIZE_64KB , /* 0x10000 */
102
+ .regionSize = CY_PROT_RAM_REGION_SIZE ,
66
103
.subregions = ALL_SUBREGIONS , /* 0xC0, /*Size 0xC000 ALL_SUBREGIONS,*/
67
104
.userPermission = CY_PROT_PERM_DISABLED ,
68
105
.privPermission = CY_PROT_PERM_RWX ,
0 commit comments