11/* mbed Microcontroller Library
2- *
2+ *
33* \copyright
44
55* (c) 2018, Cypress Semiconductor Corporation
2525#define _CYPROTECTION_CONFIG_H_
2626
2727#include "cyprotection.h"
28+ #include "mbed_assert.h"
2829
2930/* Add to M0_PSA target in targets.json:
3031 * - INITIAL_ROT_PROTECTION_AVAILABLE - to disable pc0 related protections
@@ -42,10 +43,46 @@ CY_PROT_PCMASK3 + CY_PROT_PCMASK4)
4243
4344#define ALL_SUBREGIONS (0x0)
4445
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+
4582const cy_smpu_region_config_t flash_spm_smpu_config [] = {
4683 { /* FLASH_PC1_SPM */
4784 .address = (uint32_t * )PSA_SECURE_ROM_START , /* 0x10000000 */
48- .regionSize = CY_PROT_SIZE_512KB , /* 0x80000 */
85+ .regionSize = CY_PROT_ROM_REGION_SIZE ,
4986 .subregions = ALL_SUBREGIONS ,
5087 .userPermission = CY_PROT_PERM_RWX ,
5188 .privPermission = CY_PROT_PERM_RWX ,
@@ -62,7 +99,7 @@ const cy_smpu_region_config_t flash_spm_smpu_config[] = {
6299const cy_smpu_region_config_t sram_spm_smpu_config [] = {
63100 { /* SRAM_SPM_PRIV - must include SRAM_SPM_PUB area */
64101 .address = (uint32_t * )PSA_SECURE_RAM_START , /* 0x08020000 */
65- .regionSize = CY_PROT_SIZE_64KB , /* 0x10000 */
102+ .regionSize = CY_PROT_RAM_REGION_SIZE ,
66103 .subregions = ALL_SUBREGIONS , /* 0xC0, /*Size 0xC000 ALL_SUBREGIONS,*/
67104 .userPermission = CY_PROT_PERM_DISABLED ,
68105 .privPermission = CY_PROT_PERM_RWX ,
0 commit comments