cy_prot_8h

Provides an API declaration of the Protection Unit driver.

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
Version

1.60

Copyright

Copyright 2016-2020 Cypress Semiconductor Corporation SPDX-License-Identifier: Apache-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.

Defines

CY_PROT_DRV_VERSION_MAJOR

Driver major version.

CY_PROT_DRV_VERSION_MINOR

Driver minor version.

CY_PROT_ID

Prot driver ID.

PROT_SIZE_4B_BIT_SHIFT

Constants for memory region size setting.

These may be useful for pre-processor-time tests.4 bytes

PROT_SIZE_8B_BIT_SHIFT

8 bytes

PROT_SIZE_16B_BIT_SHIFT

16 bytes

PROT_SIZE_32B_BIT_SHIFT

32 bytes

PROT_SIZE_64B_BIT_SHIFT

64 bytes

PROT_SIZE_128B_BIT_SHIFT

128 bytes

PROT_SIZE_256B_BIT_SHIFT

256 bytes

PROT_SIZE_512B_BIT_SHIFT

512 bytes

PROT_SIZE_1KB_BIT_SHIFT

1 Kilobyte

PROT_SIZE_2KB_BIT_SHIFT

2 Kilobytes

PROT_SIZE_4KB_BIT_SHIFT

4 Kilobytes

PROT_SIZE_8KB_BIT_SHIFT

8 Kilobytes

PROT_SIZE_16KB_BIT_SHIFT

16 Kilobytes

PROT_SIZE_32KB_BIT_SHIFT

32 Kilobytes

PROT_SIZE_64KB_BIT_SHIFT

64 Kilobytes

PROT_SIZE_128KB_BIT_SHIFT

128 Kilobytes

PROT_SIZE_256KB_BIT_SHIFT

256 Kilobytes

PROT_SIZE_512KB_BIT_SHIFT

512 Kilobytes

PROT_SIZE_1MB_BIT_SHIFT

1 Megabyte

PROT_SIZE_2MB_BIT_SHIFT

2 Megabytes

PROT_SIZE_4MB_BIT_SHIFT

4 Megabytes

PROT_SIZE_8MB_BIT_SHIFT

8 Megabytes

PROT_SIZE_16MB_BIT_SHIFT

16 Megabytes

PROT_SIZE_32MB_BIT_SHIFT

32 Megabytes

PROT_SIZE_64MB_BIT_SHIFT

64 Megabytes

PROT_SIZE_128MB_BIT_SHIFT

128 Megabytes

PROT_SIZE_256MB_BIT_SHIFT

256 Megabytes

PROT_SIZE_512MB_BIT_SHIFT

512 Megabytes

PROT_SIZE_1GB_BIT_SHIFT

1 Gigabyte

PROT_SIZE_2GB_BIT_SHIFT

2 Gigabytes

PROT_SIZE_4GB_BIT_SHIFT

4 Gigabytes

Enums

enum cy_en_prot_status_t

cy_en_prot_status_t: Prot Driver error codes.

Values:

enumerator CY_PROT_SUCCESS

Returned successful.

enumerator CY_PROT_BAD_PARAM

Bad parameter was passed.

enumerator CY_PROT_INVALID_STATE

The operation is not setup.

enumerator CY_PROT_FAILURE

The resource is locked.

enumerator CY_PROT_UNAVAILABLE

The resource is unavailable.

enum cy_en_prot_perm_t

cy_en_prot_perm_t: User/Privileged permission.

Values:

enumerator CY_PROT_PERM_DISABLED

Read, Write and Execute disabled.

enumerator CY_PROT_PERM_R

Read enabled.

enumerator CY_PROT_PERM_W

Write enabled.

enumerator CY_PROT_PERM_RW

Read and Write enabled.

enumerator CY_PROT_PERM_X

Execute enabled.

enumerator CY_PROT_PERM_RX

Read and Execute enabled.

enumerator CY_PROT_PERM_WX

Write and Execute enabled.

enumerator CY_PROT_PERM_RWX

Read, Write and Execute enabled.

enum cy_en_prot_size_t

cy_en_prot_size_t: Memory region size.

Values:

enumerator CY_PROT_SIZE_4B

4 bytes

enumerator CY_PROT_SIZE_8B

8 bytes

enumerator CY_PROT_SIZE_16B

16 bytes

enumerator CY_PROT_SIZE_32B

32 bytes

enumerator CY_PROT_SIZE_64B

64 bytes

enumerator CY_PROT_SIZE_128B

128 bytes

enumerator CY_PROT_SIZE_256B

256 bytes

enumerator CY_PROT_SIZE_512B

512 bytes

enumerator CY_PROT_SIZE_1KB

1 Kilobyte

enumerator CY_PROT_SIZE_2KB

2 Kilobytes

enumerator CY_PROT_SIZE_4KB

4 Kilobytes

enumerator CY_PROT_SIZE_8KB

8 Kilobytes

enumerator CY_PROT_SIZE_16KB

16 Kilobytes

enumerator CY_PROT_SIZE_32KB

32 Kilobytes

enumerator CY_PROT_SIZE_64KB

64 Kilobytes

enumerator CY_PROT_SIZE_128KB

128 Kilobytes

enumerator CY_PROT_SIZE_256KB

256 Kilobytes

enumerator CY_PROT_SIZE_512KB

512 Kilobytes

enumerator CY_PROT_SIZE_1MB

1 Megabyte

enumerator CY_PROT_SIZE_2MB

2 Megabytes

enumerator CY_PROT_SIZE_4MB

4 Megabytes

enumerator CY_PROT_SIZE_8MB

8 Megabytes

enumerator CY_PROT_SIZE_16MB

16 Megabytes

enumerator CY_PROT_SIZE_32MB

32 Megabytes

enumerator CY_PROT_SIZE_64MB

64 Megabytes

enumerator CY_PROT_SIZE_128MB

128 Megabytes

enumerator CY_PROT_SIZE_256MB

256 Megabytes

enumerator CY_PROT_SIZE_512MB

512 Megabytes

enumerator CY_PROT_SIZE_1GB

1 Gigabyte

enumerator CY_PROT_SIZE_2GB

2 Gigabytes

enumerator CY_PROT_SIZE_4GB

4 Gigabytes

enum cy_en_prot_pc_t

cy_en_prot_pc_t: Protection Context (PC)

Values:

enumerator CY_PROT_PC1

PC = 1.

enumerator CY_PROT_PC2

PC = 2.

enumerator CY_PROT_PC3

PC = 3.

enumerator CY_PROT_PC4

PC = 4.

enumerator CY_PROT_PC5

PC = 5.

enumerator CY_PROT_PC6

PC = 6.

enumerator CY_PROT_PC7

PC = 7.

enumerator CY_PROT_PC8

PC = 8.

enumerator CY_PROT_PC9

PC = 9.

enumerator CY_PROT_PC10

PC = 10.

enumerator CY_PROT_PC11

PC = 11.

enumerator CY_PROT_PC12

PC = 12.

enumerator CY_PROT_PC13

PC = 13.

enumerator CY_PROT_PC14

PC = 14.

enumerator CY_PROT_PC15

PC = 15.

enum cy_en_prot_subreg_t

cy_en_prot_subreg_t: Subregion disable (0-7)

Values:

enumerator CY_PROT_SUBREGION_DIS0

Disable subregion 0.

enumerator CY_PROT_SUBREGION_DIS1

Disable subregion 1.

enumerator CY_PROT_SUBREGION_DIS2

Disable subregion 2.

enumerator CY_PROT_SUBREGION_DIS3

Disable subregion 3.

enumerator CY_PROT_SUBREGION_DIS4

Disable subregion 4.

enumerator CY_PROT_SUBREGION_DIS5

Disable subregion 5.

enumerator CY_PROT_SUBREGION_DIS6

Disable subregion 6.

enumerator CY_PROT_SUBREGION_DIS7

Disable subregion 7.

enum cy_en_prot_pcmask_t

cy_en_prot_pcmask_t: Protection context mask (PC_MASK)

Values:

enumerator CY_PROT_PCMASK1

Mask to allow PC = 1.

enumerator CY_PROT_PCMASK2

Mask to allow PC = 2.

enumerator CY_PROT_PCMASK3

Mask to allow PC = 3.

enumerator CY_PROT_PCMASK4

Mask to allow PC = 4.

enumerator CY_PROT_PCMASK5

Mask to allow PC = 5.

enumerator CY_PROT_PCMASK6

Mask to allow PC = 6.

enumerator CY_PROT_PCMASK7

Mask to allow PC = 7.

enumerator CY_PROT_PCMASK8

Mask to allow PC = 8.

enumerator CY_PROT_PCMASK9

Mask to allow PC = 9.

enumerator CY_PROT_PCMASK10

Mask to allow PC = 10.

enumerator CY_PROT_PCMASK11

Mask to allow PC = 11.

enumerator CY_PROT_PCMASK12

Mask to allow PC = 12.

enumerator CY_PROT_PCMASK13

Mask to allow PC = 13.

enumerator CY_PROT_PCMASK14

Mask to allow PC = 14.

enumerator CY_PROT_PCMASK15

Mask to allow PC = 15.

enum cy_en_prot_req_mode_t

cy_en_prot_req_mode_t: Request mode to get the SMPU or programmed PU structure.

Values:

enumerator CY_PROT_REQMODE_HIGHPRIOR

Request mode to return PU structure with highest priority.

enumerator CY_PROT_REQMODE_LOWPRIOR

Request mode to return PU structure with lowest priority.

enumerator CY_PROT_REQMODE_INDEX

Request mode to return PU structure with specific index.

Functions

cy_en_prot_status_t Cy_Prot_ConfigBusMaster(en_prot_master_t busMaster, bool privileged, bool secure, uint32_t pcMask)

Configures the allowed protection contexts, security (secure/non-secure) and privilege level of the bus transaction created by the specified master.

note

This function is applicable for both CPUSS ver_1 and ver_2.

note

The function accepts pcMask values from CY_PROT_PCMASK1 to CY_PROT_PCMASK15. But each device has its own number of available protection contexts. That number is defined by PERI_PC_NR in the config file.

Status

Description

CY_PROT_SUCCESS

The function completed successfully.

CY_PROT_FAILURE

The resource is locked.

Return

Status of the function call.

Function Usage


    /* Scenario: CM0+ needs to be able to access resources protected with privileged, 
                 secure and set PC value (PC=0, PC=1 or PC=2) access settings */
    
    /* Configure the CM0+ bus master - privileged, secure, allow setting PC to PC=1 and PC=2 */
    if(CY_PROT_SUCCESS != Cy_Prot_ConfigBusMaster(CPUSS_MS_ID_CM0, true, true, CY_PROT_PCMASK1 | CY_PROT_PCMASK2))
    {
        /* Insert error handling */
    }

Parameters
  • busMaster: Indicates which master needs to be configured. Refer to the CPUSS_MS_ID_X defines in the device config header file.

  • privileged: Boolean to define the privilege level of all subsequent bus transfers. True - privileged, False - not privileged. Note that this is an inherited value. If not inherited, then this bit will be used.

  • secure: Security setting for the master. True - Secure, False - Not secure.

  • pcMask: This is a 16 bit value of the allowed contexts, it is an OR’ed (|) field of the provided defines in cy_prot.h. For example: (CY_PROT_PCMASK1 | CY_PROT_PCMASK3 | CY_PROT_PCMASK4)

cy_en_prot_status_t Cy_Prot_SetActivePC(en_prot_master_t busMaster, uint32_t pc)

Sets the current/active protection context of the specified bus master.

Allowed PC values are 1-15. If this value is not inherited from another bus master, the value set through this function is used.

note

This function is applicable for both CPUSS ver_1 and ver_2.

note

The function does not have access and returns an error for the secure CYB06xx7 devices.

note

that only those protection contexts allowed by the pcMask (which was configured in Cy_Prot_ConfigBusMaster) will take effect.

note

The function accepts pcMask values from CY_PROT_PC1 to CY_PROT_PC15. But each device has its own number of available protection contexts. That number is defined by PERI_PC_NR in the config file.

Status

Description

CY_PROT_SUCCESS

The function completed successfully.

CY_PROT_FAILURE

The resource is locked.

Return

Status of the function call.

Function Usage


    /* Scenario: CM0+ needs to access a protected resources that requires PC=1 attribute */
    
    /* Configure the bus master to allow setting PC to PC=1 and PC=2 */
     Cy_Prot_ConfigBusMaster(CPUSS_MS_ID_CM0, true, true, CY_PROT_PCMASK1 | CY_PROT_PCMASK2);
    
    /* Get the active PC value of CM0+ */
    if(CY_PROT_PC1 != Cy_Prot_GetActivePC(CPUSS_MS_ID_CM0))
    {
        /* Set the CM0+ PC value to 1 */
        if(CY_PROT_SUCCESS != Cy_Prot_SetActivePC(CPUSS_MS_ID_CM0, CY_PROT_PC1))
        {
            /* Insert error handling */
        }
    }

Parameters
  • busMaster: The bus master to configure. Refer to the CPUSS_MS_ID_X defines in the device config header file.

  • pc: Active protection context of the specified master cy_en_prot_pc_t.

uint32_t Cy_Prot_GetActivePC(en_prot_master_t busMaster)

note

This function is applicable for both CPUSS ver_1 and ver_2.

Returns the active protection context of a master.

Return

Active protection context of the master cy_en_prot_pc_t.

Function Usage


    /* Scenario: CM0+ needs to access a protected resources that requires PC=1 attribute */
    
    /* Configure the bus master to allow setting PC to PC=1 and PC=2 */
     Cy_Prot_ConfigBusMaster(CPUSS_MS_ID_CM0, true, true, CY_PROT_PCMASK1 | CY_PROT_PCMASK2);
    
    /* Get the active PC value of CM0+ */
    if(CY_PROT_PC1 != Cy_Prot_GetActivePC(CPUSS_MS_ID_CM0))
    {
        /* Set the CM0+ PC value to 1 */
        if(CY_PROT_SUCCESS != Cy_Prot_SetActivePC(CPUSS_MS_ID_CM0, CY_PROT_PC1))
        {
            /* Insert error handling */
        }
    }

Parameters
  • busMaster: The bus master, whose protection context is being read. Refer to the CPUSS_MS_ID_X defines in the device config header file.

cy_en_prot_status_t Cy_Prot_ConfigMpuStruct(PROT_MPU_MPU_STRUCT_Type *base, const cy_stc_mpu_cfg_t *config)

This function configures a memory protection unit (MPU) struct with its protection attributes.

The protection structs act like the gatekeepers for a master’s accesses to memory, allowing only the permitted transactions to go through.

note

This function is applicable for both CPUSS ver_1 and ver_2.

Status

Description

CY_PROT_SUCCESS

The MPU struct was configured.

CY_PROT_FAILURE

Configuration failed due to a protection violation.

Return

Status of the function call.

Function Usage

    {
        /* Scenario: Crypto bus master must not be able access the memory region 
                     0x08000020 ~ 0x080000FF unless it is operating in privileged
                     and secure mode */
        
        cy_stc_mpu_cfg_t mpuCfg = {
            /*.address =*/ (uint32_t *)0x08000000UL,    /* Starting address at start of SRAM */
            /*.regionSize =*/ CY_PROT_SIZE_256B,        /* Protect block of 256 Bytes */
            /*.subregions =*/ CY_PROT_SUBREGION_DIS0,   /* Disable protection for first 32 (256/8) Bytes */
            /*.userPermission =*/ CY_PROT_PERM_DISABLED,/* Disallow all user mode accesses */
            /*.privPermission =*/ CY_PROT_PERM_RWX,     /* Allow all privileged mode accesses */
            /*.secure =*/ true                          /* Require the bus master to have "secure" attribute */
        };
        
        /* Configure the Crypto (CPUSS_MS_ID_CRYPTO = 1) MPU struct #0 */
        if(CY_PROT_SUCCESS != Cy_Prot_ConfigMpuStruct(PROT_MPU1_MPU_STRUCT0, &mpuCfg))
        {
            /* Insert error handling */
        }
        else
        {
            /* Enable the Crypto MPU struct #0 */
            if(CY_PROT_SUCCESS != Cy_Prot_EnableMpuStruct(PROT_MPU1_MPU_STRUCT0))
            {
                /* Insert error handling */
            }
        }
    }

Parameters
  • base: The base address for the MPU struct being configured.

  • config: Initialization structure containing all the protection attributes.

cy_en_prot_status_t Cy_Prot_EnableMpuStruct(PROT_MPU_MPU_STRUCT_Type *base)

Enables the MPU struct, which allows the MPU protection attributes to take effect.

note

This function is applicable for both CPUSS ver_1 and ver_2.

Status

Description

CY_PROT_SUCCESS

The MPU struct was enabled.

CY_PROT_FAILURE

The MPU struct is disabled and possibly locked.

Return

Status of the function call.

Function Usage


    /* Scenario: PROT_MPU1_MPU_STRUCT0 is configured to protect a resource and
                 needs to be enabled. */

    if(CY_PROT_SUCCESS != Cy_Prot_EnableMpuStruct(PROT_MPU1_MPU_STRUCT0))
    {
        /* Insert error handling */
    }

Parameters
  • base: The base address of the MPU struct being configured.

cy_en_prot_status_t Cy_Prot_DisableMpuStruct(PROT_MPU_MPU_STRUCT_Type *base)

Disables the MPU struct, which prevents the MPU protection attributes from taking effect.

note

This function is applicable for both CPUSS ver_1 and ver_2.

Status

Description

CY_PROT_SUCCESS

The MPU struct was disabled.

CY_PROT_FAILURE

The MPU struct is enabled and possibly locked.

Return

Status of the function call.

Function Usage

    
    /* Scenario: PROT_MPU1_MPU_STRUCT0 needs to be disabled. Or it needs to be
                 reconfigured and hence must first be disabled. */
    
    if(CY_PROT_SUCCESS != Cy_Prot_DisableMpuStruct(PROT_MPU1_MPU_STRUCT0))
    {
        /* Insert error handling */
    }

Parameters
  • base: The base address of the MPU struct being configured.

__STATIC_INLINE cy_en_prot_status_t Cy_Prot_DisableSmpuStruct (PROT_SMPU_SMPU_STRUCT_Type *base)

This function disables both the master and slave parts of a protection unit.

Status

Description

CY_PROT_SUCCESS

The Master and Slave SMPU struct was disabled

CY_PROT_FAILURE

The Master and/or slave SMPU struct was not disabled

CY_PROT_INVALID_STATE

Function was called on the unsupported PERI IP version

Return

Status of the function call.

Function Usage

    
    /* Scenario: The struct of PROT_SMPU_SMPU_STRUCT0 needs to be disabled.
                 Or it needs to be reconfigured and hence must first be disabled. 
                 Both Slave and Master structures will be disabled. */
    
    if(CY_PROT_SUCCESS != Cy_Prot_DisableSmpuStruct(PROT_SMPU_SMPU_STRUCT0))
    {
        /* Insert error handling */
    }

Parameters
  • base: The base address for the SMPU structure to be disabled.

cy_en_prot_status_t Cy_Prot_GetSmpuStruct(PROT_SMPU_SMPU_STRUCT_Type **base, cy_en_prot_req_mode_t reqMode, uint32_t smpuIndex)

Functions returns a pointer of the requested unused SMPU structure.

It searches the SMPU structures until it finds one that both the slave and master sections are disabled. After an available structure is located, function enables the slave structure and set the ATT0[7:0] bits to 0xFF, to make sure that a subsequent call will not see this as an available (unused) SMPU.

It is up to the user to implement, if needed, a system in which a semaphore will lock-out all but one CPU from calling this function at once.

note

This function is applicable for both CPUSS ver_1 and ver_2.

reqMode

Description

CY_PROT_REQMODE_HIGHPRIOR

Return the SMPU structure with the highest priority.

CY_PROT_REQMODE_LOWPRIOR

Return the SMPU structure with the lowest priority.

CY_PROT_REQMODE_INDEX

Return the SMPU structure with the specific index.

Status

Description

CY_PROT_SUCCESS

The Slave PU struct was disabled.

CY_PROT_FAILURE

The Master or Slave SMPU struct is disabled and possibly locked.

CY_PROT_UNAVAILABLE

The requested structure in use or there were no unused structures.

Return

Status of the function call.

Function Usage


    /* Scenario: Need to find available SMPU structure with highest priority 
    *  and configure it.
    */
    
    PROT_SMPU_SMPU_STRUCT_Type *reqStr;
    
    /* Find required SMPU structure */
    if (CY_PROT_SUCCESS != Cy_Prot_GetSmpuStruct(&reqStr, CY_PROT_REQMODE_HIGHPRIOR, 0U))
    {
       /* Insert error handling */
    }
    else
    {
        cy_stc_smpu_cfg_t smpuCfg_m = {
            /*.address =*/ 0UL,                         /* Not applicable for master struct */
            /*.regionSize =*/ (cy_en_prot_size_t)0UL,   /* Not applicable for master struct */
            /*.subregions =*/ 0UL,                      /* Not applicable for master struct */
            /*.userPermission =*/ CY_PROT_PERM_R,       /* Read access always available for Master */
            /*.privPermission =*/ CY_PROT_PERM_RW,      /* Allow read and write accesses */
            /*.secure =*/ true,                         /* Only allow "secure" bus masters */
            /*.pcMatch =*/ false,                       /* Perform access evaluation */
            /*.pcMask =*/ (uint16_t)0UL                 /* Only allow PC=0 bus masters */
        };
        
        /* Configure the master of the found struct */
        if(CY_PROT_SUCCESS != Cy_Prot_ConfigSmpuMasterStruct(reqStr, &smpuCfg_m))
        {
            /* Insert error handling */
        }
        else
        {
            /* Enable the master of the found struct */
            if(CY_PROT_SUCCESS != Cy_Prot_EnableSmpuMasterStruct(reqStr))
            {
                /* Insert error handling */
            }
        }
    }

Parameters
  • base: The base address for the SMPU structure returned if an unused structure was found. If an empty structure was not found, the returned pointer is NULL.

  • reqMode: This parameter (request mode) selects how the user wants to select a SMPU structure.

Parameters
  • smpuIndex: This is the index of the requested SMPU structure. It is only used if the request mode is reqMode = CY_PROT_REQMODE_INDEX.

cy_en_prot_status_t Cy_Prot_ConfigSmpuMasterStruct(PROT_SMPU_SMPU_STRUCT_Type *base, const cy_stc_smpu_cfg_t *config)

Configures a Shared Memory Protection Unit (SMPU) master protection struct with its protection attributes.

This function configures the master struct governing the corresponding slave struct pair. It is a mechanism to protect the slave SMPU struct. Since the memory location of the slave struct is known, the address, regionSize and subregions of the configuration struct are not applicable.

Note that only the user/privileged write permissions are configurable. The read and execute permissions are read-only and cannot be configured.

note

This function is applicable for both CPUSS ver_1 and ver_2.

Status

Description

CY_PROT_SUCCESS

SMPU master struct was successfully configured.

CY_PROT_FAILURE

The resource is locked.

CY_PROT_BAD_PARAM

An incorrect/invalid parameter was passed.

Return

Status of the function call.

Function Usage


    /* Scenario: A bus master must not be able to access the PROT_SMPU_SMPU_STRUCT0
                 master and slave structs unless operating with PC=0, "secure" and
                 "privileged" access settings. The PROT_SMPU_SMPU_STRUCT0 slave 
                 struct is already configured and enabled. */
    
    cy_stc_smpu_cfg_t smpuCfg_m = {
        /*.address =*/ 0UL,                         /* Not applicable for master struct */
        /*.regionSize =*/ (cy_en_prot_size_t)0UL,   /* Not applicable for master struct */
        /*.subregions =*/ 0UL,                      /* Not applicable for master struct */
        /*.userPermission =*/ CY_PROT_PERM_R,       /* Read access always available for Master */
        /*.privPermission =*/ CY_PROT_PERM_RW,      /* Allow read and write accesses */
        /*.secure =*/ true,                         /* Only allow "secure" bus masters */
        /*.pcMatch =*/ false,                       /* Perform access evaluation */
        /*.pcMask =*/ (uint16_t)0UL                 /* Only allow PC=0 bus masters */
    };
    
    /* Configure the master struct of SMPU #0 */
    if(CY_PROT_SUCCESS != Cy_Prot_ConfigSmpuMasterStruct(PROT_SMPU_SMPU_STRUCT0, &smpuCfg_m))
    {
        /* Insert error handling */
    }
    else
    {
        /* Enable the master struct of SMPU #0 */
        if(CY_PROT_SUCCESS != Cy_Prot_EnableSmpuMasterStruct(PROT_SMPU_SMPU_STRUCT0))
        {
            /* Insert error handling */
        }
    }

Parameters
  • base: The register base address of the protection struct being configured.

  • config: Initialization structure with all the protection attributes.

cy_en_prot_status_t Cy_Prot_ConfigSmpuSlaveStruct(PROT_SMPU_SMPU_STRUCT_Type *base, const cy_stc_smpu_cfg_t *config)

Configures a Shared Memory Protection Unit (SMPU) slave protection struct with its protection attributes.

This function configures the slave struct of an SMPU pair, which can protect any memory region in a device from invalid bus master accesses.

note

This function is applicable for both CPUSS ver_1 and ver_2.

Status

Description

CY_PROT_SUCCESS

SMPU slave struct was successfully configured.

CY_PROT_FAILURE

The resource is locked.

CY_PROT_BAD_PARAM

An incorrect/invalid parameter was passed.

Return

Status of the function call.

Function Usage


    /* Scenario: A bus master must not be able to access the memory region 
                 0x10000200 ~ 0x10000FFF unless it is operating at PC=0 or PC=2 */
    
    cy_stc_smpu_cfg_t smpuCfg_s = {
        /*.address =*/ (uint32_t *)0x10000000UL,    /* Starting address at start of Flash */
        /*.regionSize =*/ CY_PROT_SIZE_4KB,         /* Protect block of 4 KBytes */
        /*.subregions =*/ CY_PROT_SUBREGION_DIS0,   /* Disable protection for first 512 (4096/8) Bytes */
        /*.userPermission =*/ CY_PROT_PERM_RWX,     /* Allow all user mode accesses */
        /*.privPermission =*/ CY_PROT_PERM_RWX,     /* Allow all privileged mode accesses */
        /*.secure =*/ false,                        /* Allow "non-secure" bus masters */
        /*.pcMatch =*/ false,                       /* Perform access evaluation */
        /*.pcMask =*/ (uint16_t)CY_PROT_PCMASK2     /* Allow PC=0 and PC=2 accesses */
    };
    
    /* Configure the slave struct of SMPU #0 */
    if(CY_PROT_SUCCESS != Cy_Prot_ConfigSmpuSlaveStruct(PROT_SMPU_SMPU_STRUCT0, &smpuCfg_s))
    {
        /* Insert error handling */
    }
    else
    {
        /* Enable the slave struct of SMPU #0 */
        if(CY_PROT_SUCCESS != Cy_Prot_EnableSmpuSlaveStruct(PROT_SMPU_SMPU_STRUCT0))
        {
            /* Insert error handling */
        }
    }

Parameters
  • base: The register base address of the protection structure being configured.

  • config: Initialization structure with all the protection attributes.

cy_en_prot_status_t Cy_Prot_EnableSmpuMasterStruct(PROT_SMPU_SMPU_STRUCT_Type *base)

Enables the Master SMPU structure.

This is an SMPU master struct enable function. The SMPU protection settings will take effect after successful completion of this function call.

note

This function is applicable for both CPUSS ver_1 and ver_2.

Status

Description

CY_PROT_SUCCESS

The Master PU struct was enabled.

CY_PROT_FAILURE

The Master PU struct is disabled and possibly locked.

Return

Status of the function call.

Function Usage


    /* Scenario: The master struct of PROT_SMPU_SMPU_STRUCT0 is configured to 
                 protect its slave struct and needs to be enabled. */
    
    if(CY_PROT_SUCCESS != Cy_Prot_EnableSmpuMasterStruct(PROT_SMPU_SMPU_STRUCT0))
    {
        /* Insert error handling */
    }

Parameters
  • base: The base address for the protection unit structure being configured.

cy_en_prot_status_t Cy_Prot_DisableSmpuMasterStruct(PROT_SMPU_SMPU_STRUCT_Type *base)

Disables the Master SMPU structure.

This is an SMPU master struct disable function. The SMPU protection settings will seize to take effect after successful completion of this function call.

note

This function is applicable for both CPUSS ver_1 and ver_2.

Status

Description

CY_PROT_SUCCESS

The Master PU struct was disabled.

CY_PROT_FAILURE

The Master PU struct is enabled and possibly locked.

Return

Status of the function call.

Function Usage

    
    /* Scenario: The master sturct of PROT_SMPU_SMPU_STRUCT0 needs to be disabled.
                 Or it needs to be reconfigured and hence must first be disabled. */
    
    if(CY_PROT_SUCCESS != Cy_Prot_EnableSmpuMasterStruct(PROT_SMPU_SMPU_STRUCT0))
    {
        /* Insert error handling */
    }

Parameters
  • base: The base address for the protection unit structure being configured.

cy_en_prot_status_t Cy_Prot_EnableSmpuSlaveStruct(PROT_SMPU_SMPU_STRUCT_Type *base)

Enables the Slave SMPU structure.

This is an SMPU slave struct enable function. The SMPU protection settings will take effect after successful completion of this function call.

note

This function is applicable for both CPUSS ver_1 and ver_2.

Status

Description

CY_PROT_SUCCESS

The Slave PU struct was enabled.

CY_PROT_FAILURE

The Slave PU struct is disabled and possibly locked.

Return

Status of the function call.

Function Usage


    /* Scenario: The slave struct of PROT_SMPU_SMPU_STRUCT0 is configured to 
                 protect a resource and needs to be enabled. */
    
    if(CY_PROT_SUCCESS != Cy_Prot_EnableSmpuSlaveStruct(PROT_SMPU_SMPU_STRUCT0))
    {
        /* Insert error handling */
    }

Parameters
  • base: The base address for the protection unit structure being configured.

cy_en_prot_status_t Cy_Prot_DisableSmpuSlaveStruct(PROT_SMPU_SMPU_STRUCT_Type *base)

Disables the Slave SMPU structure.

This is an SMPU slave struct disable function. The SMPU protection settings will seize to take effect after successful completion of this function call.

note

This function is applicable for both CPUSS ver_1 and ver_2.

Status

Description

CY_PROT_SUCCESS

The Slave PU struct was disabled.

CY_PROT_FAILURE

The Slave PU struct is enabled and possibly locked.

Return

Status of the function call.

Function Usage

    
    /* Scenario: The slave struct of PROT_SMPU_SMPU_STRUCT0 needs to be disabled.
                 Or it needs to be reconfigured and hence must first be disabled. */
    
    if(CY_PROT_SUCCESS != Cy_Prot_DisableSmpuSlaveStruct(PROT_SMPU_SMPU_STRUCT0))
    {
        /* Insert error handling */
    }

Parameters
  • base: The base address for the protection unit structure being configured.

cy_en_prot_status_t Cy_Prot_ConfigPpuProgMasterAtt(PERI_MS_PPU_PR_Type *base, uint16_t pcMask, cy_en_prot_perm_t userPermission, cy_en_prot_perm_t privPermission, bool secure)

Configures the protection-structure attributes of the Programmable Peripheral Protection Unit (PPU PROG) master.

This function configures the master structure governing the corresponding slave structure pair. It is a mechanism to protect the slave PPU PROG structure. The memory location of the slave structure is known, so the address, regionSize, and sub-regions of the configuration structure are not applicable.

note

This function is applicable for CPUSS ver_2 only.

note

The function accepts pcMask values from CY_PROT_PCMASK1 to CY_PROT_PCMASK15. But each device has its own number of available protection contexts. That number is defined by PERI_PC_NR in the config file. If pcMask is passed beyond the range of available protection context, the bits above PERI_PC_NR will be ignored.

Status

Description

CY_PROT_SUCCESS

The attributes were set up.

CY_PROT_FAILURE

The attributes were not set up because the structure is possibly locked.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

note

Only the user's/privileged Write permissions are configurable. The Read permissions are read-only and cannot be configured.

note

PC0 accesses are read-only and are always enabled.

Return

The status of the function call.

Function Usage

    
    /* Scenario: A bus master is forbidden to have access to the PERI_MS_PPU_PR4 master 
                 and slave attributes when it is operating with PC=0, "secure", 
                 and "privileged" access settings. The PERI_MS_PPU_PR4 slave attributes
                 and address are already configured and enabled. */

    if(CY_PROT_SUCCESS !=  Cy_Prot_ConfigPpuProgMasterAtt(PERI_MS_PPU_PR4, /* Programmable protection structure pair 4 base */
                                                          (uint16_t)0UL, /* Only allow PC=0 bus masters */
                                                           CY_PROT_PERM_R,  /* Read access always available for Master */
                                                           CY_PROT_PERM_RW,  /* Allow read and write privileged mode accesses */
                                                           true))  /* Only allow "secure" bus masters */
    {
        /* Insert error handling */
    }

Parameters
  • base: The register base address of the protection structure is being configured.

  • pcMask: The protection context mask. It specifies the protection context or a set of multiple protection contexts to be configured. It is a value of OR’d (|) items of cy_en_prot_pcmask_t.

Parameters
  • userPermission: The user permission setting. The CY_PROT_PERM_R or CY_PROT_PERM_RW values are valid for the master.

  • privPermission: The privileged permission setting. CY_PROT_PERM_R or CY_PROT_PERM_RW values are valid for the master.

  • secure: The secure flag.

cy_en_prot_status_t Cy_Prot_ConfigPpuProgSlaveAddr(PERI_MS_PPU_PR_Type *base, uint32_t address, cy_en_prot_size_t regionSize)

Configures the protection-structure address settings of the Programmable Peripheral Protection Unit (PPU PROG) slave.

This function configures the slave structure of the PPU PROG pair, which can protect any peripheral memory region in a device from an invalid bus-master access.

note

This function is applicable for CPUSS ver_2 only.

Status

Description

CY_PROT_SUCCESS

The address settings were set up.

CY_PROT_FAILURE

The address settings were not set up because the structure is possibly locked.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

note

PC0 accesses are Read-only and are always enabled.

Return

The status of the function call.

Function Usage

Cy_Prot_ConfigPpuProgSlaveAtt

Parameters
  • base: The register base address of the protection structure is being configured.

  • address: The address.

  • regionSize: The region size.

cy_en_prot_status_t Cy_Prot_ConfigPpuProgSlaveAtt(PERI_MS_PPU_PR_Type *base, uint16_t pcMask, cy_en_prot_perm_t userPermission, cy_en_prot_perm_t privPermission, bool secure)

Configures the protection structure with its protection attributes of the Programmable Peripheral Protection Unit (PPU PROG) slave.

This function configures the slave structure of the PPU PROG pair, which can protect any peripheral memory region in a device from invalid bus-master access.

note

This function is applicable for CPUSS ver_2 only.

note

The function accepts pcMask values from CY_PROT_PCMASK1 to CY_PROT_PCMASK15. But each device has its own number of available protection contexts. That number is defined by PERI_PC_NR in the config file.

Status

Description

CY_PROT_SUCCESS

The attributes were set up.

CY_PROT_FAILURE

The attributes were not set up because the structure is possibly locked.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

note

PC0 accesses are read-only and are always enabled.

Return

The status of the function call.

Function Usage

    
    /* Scenario: A bus master is forbidden to have access to the GPIO port 0 registers 
                 (0x40310000 ~ 0x4031007F) when it has the "secure" attribute 
                 and is operating at PC=3. */

    /* Configure the attributes settings */
    if(CY_PROT_SUCCESS != Cy_Prot_ConfigPpuProgSlaveAtt(PERI_MS_PPU_PR4, /* Programmable protection structure pair 4 base */
                                            (uint16_t)CY_PROT_PCMASK3,   /* Allow PC=0 and PC=3 accesses */
                                            CY_PROT_PERM_RW,  /* Allow Read and Write user mode accesses */
                                            CY_PROT_PERM_RW,  /* Allow Read and Write privileged mode accesses */
                                            true))  /* Only allow "secure" bus masters */
    {
        /* Insert error handling */
    }

    /* Configure the address settings */
    if(CY_PROT_SUCCESS !=  Cy_Prot_ConfigPpuProgSlaveAddr(PERI_MS_PPU_PR4, /* Programmable protection structure pair 4 base */
                                                           (uint32_t)GPIO_PRT0, /* Starting address at GPIO port 0 base */
                                                           CY_PROT_SIZE_256B))    /* Protect block of 256 Bytes */
    {
        /* Insert error handling */
    }

    /* Enables the Slave PPU PROG structure */
    Cy_Prot_EnablePpuProgSlaveRegion(PERI_MS_PPU_PR4);

Parameters
  • base: The register base address of the protection structure is being configured.

  • pcMask: The protection context mask. It specifies the protection context or a set of multiple protection contexts to be configured. It is a value of OR’d (|) items of cy_en_prot_pcmask_t. For example: (CY_PROT_PCMASK1 | CY_PROT_PCMASK3 | CY_PROT_PCMASK4).

Parameters
  • userPermission: The user permission setting.

  • privPermission: The privileged permission setting.

  • secure: The secure flag.

cy_en_prot_status_t Cy_Prot_EnablePpuProgSlaveRegion(PERI_MS_PPU_PR_Type *base)

Enables the Slave PPU PROG structure.

This is the PPU PROG slave-structure enable function. The PPU PROG protection settings will take effect after a successful completion of this function call.

note

This function is applicable for CPUSS ver_2 only.

Status

Description

CY_PROT_SUCCESS

The structure was enabled.

CY_PROT_FAILURE

The structure is disabled and possibly locked.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

Return

The status of the function call.

Function Usage

Cy_Prot_ConfigPpuProgSlaveAtt

Parameters
  • base: The base address for the protection unit structure is being configured.

cy_en_prot_status_t Cy_Prot_DisablePpuProgSlaveRegion(PERI_MS_PPU_PR_Type *base)

Disables the Slave PPU PROG structure.

This is the PPU PROG slave-structure disable function. The PPU PROG protection settings will seize to take effect after successful completion of this function call.

note

This function is applicable for CPUSS ver_2 only.

Status

Description

CY_PROT_SUCCESS

The slave PPU PROG structure was disabled.

CY_PROT_FAILURE

The structure is enabled and possibly locked.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

Return

The status of the function call.

Function Usage

    
    /* Scenario: The slave struct of PERI_MS_PPU_PR4 needs to be disabled. Or it
                 needs to be reconfigured and hence must first be disabled. */
     
    if(CY_PROT_SUCCESS != Cy_Prot_DisablePpuProgSlaveRegion(PERI_MS_PPU_PR4))
    {
        /* Insert error handling */
    }

Parameters
  • base: The base address for the protection unit structure is being configured.

cy_en_prot_status_t Cy_Prot_ConfigPpuFixedMasterAtt(PERI_MS_PPU_FX_Type *base, uint16_t pcMask, cy_en_prot_perm_t userPermission, cy_en_prot_perm_t privPermission, bool secure)

Configures the protection structure with its protection attributes of the Fixed Peripheral Protection Unit (PPU FIXED) master.

This function configures the master structure governing the corresponding slave structure pair. It is a mechanism to protect the slave PPU FIXED structure. The memory location of the slave structure is known, so the address, region size and sub-regions of the configuration structure are not applicable.

note

This function is applicable for CPUSS ver_2 only.

note

The function accepts pcMask values from CY_PROT_PCMASK1 to CY_PROT_PCMASK15. But each device has its own number of available protection contexts. That number is defined by PERI_PC_NR in the config file. If pcMask is passed beyond the range of available protection context, the bits above PERI_PC_NR will be ignored.

Status

Description

CY_PROT_SUCCESS

The attributes were set up.

CY_PROT_FAILURE

The attributes were not setup and the structure is possibly locked.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

note

Only the user/privileged write permissions are configurable. The read permissions are read-only and cannot be configured.

note

PC0 accesses are read-only and are always enabled.

Return

The status of the function call.

Function Usage

    
    /* Scenario: A bus master must not be able to access the PERI_MS_PPU_FX_HSIOM_PRT1_PRT
                  slave struct unless operating with PC=0, "secure" and
                  "privileged" access settings. The PERI_MS_PPU_FX_HSIOM_PRT1_PRT slave attributes
                  are already configured. */
    if(CY_PROT_SUCCESS !=  Cy_Prot_ConfigPpuFixedMasterAtt(PERI_MS_PPU_FX_HSIOM_PRT1_PRT,
                                                           (uint16_t)0U, /* Only allow PC=0 bus masters */
                                                           CY_PROT_PERM_R,  /* Read access always available for Master */
                                                           CY_PROT_PERM_RW,  /* Allow read and write privileged mode accesses */
                                                           true)) /* Only allow "secure" bus masters */
    {
        /* Insert error handling */
    }

Parameters
  • base: The register base address of the protection structure is being configured.

  • pcMask: The protection context mask. It specifies the protection context or a set of multiple protection contexts to be configured. It is a value of OR’d (|) items of cy_en_prot_pcmask_t.

Parameters
  • userPermission: The user permission setting. The CY_PROT_PERM_R or CY_PROT_PERM_RW values are valid for the master.

  • privPermission: The privileged permission setting. The CY_PROT_PERM_R or CY_PROT_PERM_RW values are valid for the master.

  • secure: The secure flag.

cy_en_prot_status_t Cy_Prot_ConfigPpuFixedSlaveAtt(PERI_MS_PPU_FX_Type *base, uint16_t pcMask, cy_en_prot_perm_t userPermission, cy_en_prot_perm_t privPermission, bool secure)

Configures the protection structure with its protection attributes of the Fixed Peripheral Protection Unit (PPU FIXED) slave.

This function configures the slave structure of the PPU FIXED pair, which can protect any peripheral memory region in a device from invalid bus-master access.

note

This function is applicable for CPUSS ver_2 only.

note

The function accepts pcMask values from CY_PROT_PCMASK1 to CY_PROT_PCMASK15. But each device has its own number of available protection contexts. That number is defined by PERI_PC_NR in the config file.

Status

Description

CY_PROT_SUCCESS

The attributes were set up.

CY_PROT_FAILURE

The attributes were not setup and the structure is possibly locked.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

note

PC0 accesses are read-only and are always enabled.

Return

The status of the function call.

Function Usage

    
    /* Scenario: Disallow a bus master on the CM4 core to change the HSIOM settings 
                  of port 1 but allow reading the HSIOM settings */

    /* Configure the CM4 bus master - privileged, secure, allow setting PC to PC=1 */
    Cy_Prot_ConfigBusMaster(CPUSS_MS_ID_CM4, /* Bus Master is the CM4 core */
                            true,  /* Set the privilege level to Bus Master */
                            true,  /* Set secure mode to Bus Master */
                            CY_PROT_PCMASK1); /* Allow setting PC to PC=1 only */

    /* Configure slave attributes for PC=1 which allow reading the HSIOM settings 
       of port 1 in privileged mode accesses for secure bus masters */
    if(CY_PROT_SUCCESS != Cy_Prot_ConfigPpuFixedSlaveAtt(PERI_MS_PPU_FX_HSIOM_PRT1_PRT,
                                                         (uint16_t)CY_PROT_PCMASK1, /* Allow PC=0 and PC=1 accesses */
                                                         CY_PROT_PERM_DISABLED,  /* Disallow all user mode accesses */
                                                         CY_PROT_PERM_R,  /* Allow Read privileged mode accesses */
                                                         true)) /* Only allow "secure" bus masters */
    {
        /* Insert error handling */
    }

    /* CM4 needs to access a protected resources that require PC=1 attribute */
    Cy_Prot_SetActivePC(CPUSS_MS_ID_CM4, CY_PROT_PC1);

Parameters
  • base: The register base address of the protection structure is being configured.

  • pcMask: The protection context mask. It specifies the protection context or a set of multiple protection contexts to be configured. It is a value of OR’d (|) items of cy_en_prot_pcmask_t. For example: (CY_PROT_PCMASK1 | CY_PROT_PCMASK3 | CY_PROT_PCMASK4).

Parameters
  • userPermission: The user permission setting.

  • privPermission: The privileged permission setting.

  • secure: The secure flag.

__STATIC_INLINE cy_en_prot_status_t Cy_Prot_DisablePpuProgStruct (PERI_PPU_PR_Type *base)

This function disables both the master and slave parts of a protection unit.

note

This functions has an effect only on devices with PERI IP version 1. Refer to the device datasheet for information about PERI HW IP version.

Status

Description

CY_PROT_SUCCESS

The Master and Slave Programmable PU struct was disabled

CY_PROT_FAILURE

The Master and/or slave Programmable PU struct was not disabled

CY_PROT_INVALID_STATE

Function was called on the unsupported PERI IP version

Return

Status of the function call.

Function Usage

    
    /* Scenario: The struct of PERI_PPU_PR0 needs to be disabled. Or it
                 needs to be reconfigured and hence must first be disabled. */
    
    if(CY_PROT_SUCCESS != Cy_Prot_DisablePpuProgStruct(PERI_PPU_PR0))
    {
        /* Insert error handling */
    }

Parameters
  • base: The base address for the Programmable PU structure to be disabled.

cy_en_prot_status_t Cy_Prot_ConfigPpuProgMasterStruct(PERI_PPU_PR_Type *base, const cy_stc_ppu_prog_cfg_t *config)

Configures a Programmable Peripheral Protection Unit (PPU PROG) master protection struct with its protection attributes.

This function configures the master struct governing the corresponding slave struct pair. It is a mechanism to protect the slave PPU PROG struct. Since the memory location of the slave struct is known, the address, regionSize and subregions of the configuration struct are not applicable.

Note that only the user/privileged write permissions are configurable. The read and execute permissions are read-only and cannot be configured.

note

This function is applicable for CPUSS ver_1 only.

Status

Description

CY_PROT_SUCCESS

PPU PROG master struct was successfully configured.

CY_PROT_FAILURE

The resource is locked.

CY_PROT_BAD_PARAM

An incorrect/invalid parameter was passed.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

Return

Status of the function call.

Function Usage


    /* Scenario: A bus master must not be able to access the PERI_PPU_PR0 master
                 and slave structs unless operating with PC=0, "secure" and
                 "privileged" access settings. The PERI_PPU_PR0 slave struct is 
                 already configured and enabled. */

    cy_stc_ppu_prog_cfg_t progPpuCfg_m = {
        /*.address =*/ 0UL,                         /* Not applicable for master struct */
        /*.regionSize =*/ (cy_en_prot_size_t)0UL,   /* Not applicable for master struct */
        /*.subregions =*/ 0UL,                      /* Not applicable for master struct */
        /*.userPermission =*/ CY_PROT_PERM_R,       /* Read access always available for Master */
        /*.privPermission =*/ CY_PROT_PERM_RW,      /*  Allow read and write privileged mode accesses */
        /*.secure =*/ true,                         /* Only allow "secure" bus masters */
        /*.pcMatch =*/ false,                       /* Perform access evaluation */
        /*.pcMask =*/ (uint16_t)0UL                 /* Only allow PC=0 bus masters */
    };
 
    /* Configure the master struct of PROG PPU #0 */
    if(CY_PROT_SUCCESS != Cy_Prot_ConfigPpuProgMasterStruct(PERI_PPU_PR0, &progPpuCfg_m))
    {
        /* Insert error handling */
    }
    else
    {
        /* Enable the master struct of PROG PPU #0 */
        if(CY_PROT_SUCCESS != Cy_Prot_EnablePpuProgMasterStruct(PERI_PPU_PR0))
        {
            /* Insert error handling */
        }
    }

Parameters
  • base: The register base address of the protection struct being configured.

  • config: Initialization structure with all the protection attributes.

cy_en_prot_status_t Cy_Prot_ConfigPpuProgSlaveStruct(PERI_PPU_PR_Type *base, const cy_stc_ppu_prog_cfg_t *config)

Configures a Programmable Peripheral Protection Unit (PPU PROG) slave protection struct with its protection attributes.

This function configures the slave struct of a PPU PROG pair, which can protect any peripheral memory region in a device from invalid bus master accesses.

Note that the user/privileged execute accesses are read-only and are always enabled.

note

This function is applicable for CPUSS ver_1 only.

Status

Description

CY_PROT_SUCCESS

PPU PROG slave struct was successfully configured.

CY_PROT_FAILURE

The resource is locked.

CY_PROT_BAD_PARAM

An incorrect/invalid parameter was passed.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

Return

Status of the function call.

Function Usage


    /* Scenario: A bus master must not be able to access the GPIO port 0 registers 
                 (0x40320000 ~ 0x4032007F) unless it has the "secure" attribute 
                 and is operating at PC=0 or PC=2. */
    
    cy_stc_ppu_prog_cfg_t progPpuCfg_s = {
        /*.address =*/ (uint32_t *)GPIO_PRT0,       /* Starting address at GPIO port 0 base */
        /*.regionSize =*/ CY_PROT_SIZE_256B,        /* Protect block of 256 Bytes */
        /*.subregions =*/ CY_PROT_SUBREGION_DIS4
                      | CY_PROT_SUBREGION_DIS5
                      | CY_PROT_SUBREGION_DIS6
                      | CY_PROT_SUBREGION_DIS7, /* Disable protection for last 128 (4*256/8) Bytes */
        /*.userPermission =*/ CY_PROT_PERM_RW,      /* Allow Read and Write user mode accesses */
        /*.privPermission =*/ CY_PROT_PERM_RW,      /* Allow Read and Write privileged mode accesses */
        /*.secure =*/ true,                         /* Only allow "secure" bus masters */
        /*.pcMatch =*/ false,                       /* Perform access evaluation */
        /*.pcMask =*/ (uint16_t)CY_PROT_PCMASK2     /* Allow PC=0 and PC=2 accesses */
    };
    
    /* Configure the slave struct of PROG PPU #0 */
    if(CY_PROT_SUCCESS != Cy_Prot_ConfigPpuProgSlaveStruct(PERI_PPU_PR0, &progPpuCfg_s))
    {
        /* Insert error handling */
    }
    else
    {
        /* Enable the slave struct of PROG PPU #0 */
        if(CY_PROT_SUCCESS != Cy_Prot_EnablePpuProgSlaveStruct(PERI_PPU_PR0))
        {
            /* Insert error handling */
        }
    }

Parameters
  • base: The register base address of the protection structure being configured.

  • config: Initialization structure with all the protection attributes.

cy_en_prot_status_t Cy_Prot_EnablePpuProgMasterStruct(PERI_PPU_PR_Type *base)

Enables the Master PPU PROG structure.

This is a PPU PROG master struct enable function. The PPU PROG protection settings will take effect after successful completion of this function call.

note

This function is applicable for CPUSS ver_1 only.

Status

Description

CY_PROT_SUCCESS

The Master PU struct was enabled.

CY_PROT_FAILURE

The Master PU struct is disabled and possibly locked.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

Return

Status of the function call.

Function Usage


    /* Scenario: The master struct of PERI_PPU_PR0 is configured to protect its
                 slave struct and needs to be enabled. */
    
    if(CY_PROT_SUCCESS != Cy_Prot_EnablePpuProgMasterStruct(PERI_PPU_PR0))
    {
        /* Insert error handling */
    }

Parameters
  • base: The base address for the protection unit structure being configured.

cy_en_prot_status_t Cy_Prot_DisablePpuProgMasterStruct(PERI_PPU_PR_Type *base)

Disables the Master PPU PROG structure.

This is a PPU PROG master struct disable function. The PPU PROG protection settings will seize to take effect after successful completion of this function call.

note

This function is applicable for CPUSS ver_1 only.

Status

Description

CY_PROT_SUCCESS

The Master PU struct was disabled.

CY_PROT_FAILURE

The Master PU struct is enabled and possibly locked.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

Return

Status of the function call.

Function Usage

    
    /* Scenario: The master struct of PERI_PPU_PR0 needs to be disabled. Or it
                 needs to be reconfigured and hence must first be disabled. */
    
    if(CY_PROT_SUCCESS != Cy_Prot_DisablePpuProgMasterStruct(PERI_PPU_PR0))
    {
        /* Insert error handling */
    }

Parameters
  • base: The base address for the protection unit structure being configured.

cy_en_prot_status_t Cy_Prot_EnablePpuProgSlaveStruct(PERI_PPU_PR_Type *base)

Enables the Slave PPU PROG structure.

This is a PPU PROG slave struct enable function. The PPU PROG protection settings will take effect after successful completion of this function call.

note

This function is applicable for CPUSS ver_1 only.

Status

Description

CY_PROT_SUCCESS

The Slave PU struct was enabled.

CY_PROT_FAILURE

The Slave PU struct is disabled and possibly locked.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

Return

Status of the function call.

Function Usage


    /* Scenario: The slave struct of PERI_PPU_PR0 is configured to protect a 
                 resource and needs to be enabled. */
    
    if(CY_PROT_SUCCESS != Cy_Prot_EnablePpuProgSlaveStruct(PERI_PPU_PR0))
    {
        /* Insert error handling */
    }

Parameters
  • base: The base address for the protection unit structure being configured.

cy_en_prot_status_t Cy_Prot_DisablePpuProgSlaveStruct(PERI_PPU_PR_Type *base)

Disables the Slave PPU PROG structure.

This is a PPU PROG slave struct disable function. The PPU PROG protection settings will seize to take effect after successful completion of this function call.

note

This function is applicable for CPUSS ver_1 only.

Status

Description

CY_PROT_SUCCESS

The Slave PU struct was disabled.

CY_PROT_FAILURE

The Slave PU struct is enabled and possibly locked.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

Return

Status of the function call.

Function Usage

    
    /* Scenario: The slave struct of PERI_PPU_PR0 needs to be disabled. Or it
                 needs to be reconfigured and hence must first be disabled. */
    
    if(CY_PROT_SUCCESS != Cy_Prot_DisablePpuProgSlaveStruct(PERI_PPU_PR0))
    {
        /* Insert error handling */
    }

Parameters
  • base: The base address for the protection unit structure being configured.

cy_en_prot_status_t Cy_Prot_GetPpuProgStruct(PERI_PPU_PR_Type **base, cy_en_prot_req_mode_t reqMode, uint32_t ppuProgIndex)

Functions returns a pointer of the requested unused Programmable PPU structure.

Function searches the Programmable PPU structure until it finds one that both the slave and master sections are disabled. After an available structure is located, function enables the slave structure and enables all attributes, to make sure that a subsequent call will not see this as an available (unused) Programmable PPU.

It is up to the user to implement, if needed, a system in which a semaphore will lock-out all but one CPU from calling this function at once.

note

This function is applicable for CPUSS ver_1 only.

reqMode

Description

CY_PROT_REQMODE_HIGHPRIOR

Return the Programmable PPU structure with the highest priority.

CY_PROT_REQMODE_LOWPRIOR

Return the Programmable PPU structure with the lowest priority.

CY_PROT_REQMODE_INDEX

Return the Programmable PPU structure with the specific index.

Status

Description

CY_PROT_SUCCESS

The Slave PU struct was disabled.

CY_PROT_FAILURE

The Master or Slave Programmable PPU struct is disabled and possibly locked.

CY_PROT_UNAVAILABLE

The requested structure in use or there were no unused structures.

CY_PROT_INVALID_STATE

Function was called on unsupported PERI HW version.

Return

Status of the function call.

Function Usage


    /* Scenario: Need to find available PERI_PPU structure with highest priority 
    *  and configure it.
    */
    
    
    PERI_PPU_PR_Type *reqStr;
    
    /* Check is required structure is unused */
    if (CY_PROT_SUCCESS != Cy_Prot_GetPpuProgStruct(&reqStr, CY_PROT_REQMODE_HIGHPRIOR, 0U))
    {
       /* Insert error handling */
    }
    else
    {
        cy_stc_ppu_prog_cfg_t progPpuCfg_m =
        {
        /*.address =*/ 0UL,                         /* Not applicable for master struct */
        /*.regionSize =*/ (cy_en_prot_size_t)0UL,   /* Not applicable for master struct */
        /*.subregions =*/ 0UL,                      /* Not applicable for master struct */
        /*.userPermission =*/ CY_PROT_PERM_R,       /* Read access always available for Master */
        /*.privPermission =*/ CY_PROT_PERM_RW,      /*  Allow read and write privileged mode accesses */
        /*.secure =*/ true,                         /* Only allow "secure" bus masters */
        /*.pcMatch =*/ false,                       /* Perform access evaluation */
        /*.pcMask =*/ (uint16_t)0UL                 /* Only allow PC=0 bus masters */
        };
         
        /* Configure the master struct of found PERI PPU struct */
        if(CY_PROT_SUCCESS != Cy_Prot_ConfigPpuProgMasterStruct(reqStr, &progPpuCfg_m))
        {
            /* Insert error handling */
        }
        else
        {
            /* Enable the master struct of PROG PPU */
            if(CY_PROT_SUCCESS != Cy_Prot_EnablePpuProgMasterStruct(reqStr))
            {
                /* Insert error handling */
            }
        }

    }

Parameters
  • base: The base address for the Programmable PPU structure returned if an unused structure was found. If an empty structure was not found, the returned pointer is NULL.

  • reqMode: This parameter (request mode) selects how the user wants to select a Programmable PPU structure.

Parameters
  • ppuProgIndex: This is the index of the requested Programmable PPU structure. It is only used if the request mode is reqMode = CY_PROT_REQMODE_INDEX.

cy_en_prot_status_t Cy_Prot_ConfigPpuFixedGrMasterStruct(PERI_PPU_GR_Type *base, const cy_stc_ppu_gr_cfg_t *config)

Configures a Fixed Peripheral Group Protection Unit (PPU GR) master protection struct with its protection attributes.

This function configures the master struct governing the corresponding slave struct pair. It is a mechanism to protect the slave PPU GR struct. Since the memory location of the slave struct is known, the address, regionSize and subregions of the configuration struct are not applicable.

Note that only the user/privileged write permissions are configurable. The read and execute permissions are read-only and cannot be configured.

note

This function is applicable for CPUSS ver_1 only.

Status

Description

CY_PROT_SUCCESS

PPU GR master struct was successfully configured.

CY_PROT_FAILURE

The resource is locked.

CY_PROT_BAD_PARAM

An incorrect/invalid parameter was passed.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

Return

Status of the function call.

Function Usage


    /* Scenario: A bus master must not be able to access the PERI_PPU_GR_MMIO0 master
                 and slave structs unless operating with PC=0, "secure" and
                 "privileged" access settings. The PERI_PPU_GR0 slave struct is 
                 already configured and enabled. */
    
    cy_stc_ppu_gr_cfg_t grPpuCfg_m = {
        /*.userPermission =*/ CY_PROT_PERM_R,       /* Read access always available for Master */
        /*.privPermission =*/ CY_PROT_PERM_RW,      /*  Allow read and write privileged mode accesses */
        /*.secure =*/ true,                         /* Only allow "secure" bus masters */
        /*.pcMatch =*/ false,                       /* Perform access evaluation */
        /*.pcMask =*/ (uint16_t)0UL                 /* Only allow PC=0 bus masters */
    };
    
    /* Configure the master struct of PPU MMIO Group #0 */
    if(CY_PROT_SUCCESS != Cy_Prot_ConfigPpuFixedGrMasterStruct(PERI_PPU_GR_MMIO0, &grPpuCfg_m))
    {
        /* Insert error handling */
    }
    else
    {
        /* Enable the master struct of PPU MMIO Group #0 */
        if(CY_PROT_SUCCESS != Cy_Prot_EnablePpuFixedGrMasterStruct(PERI_PPU_GR_MMIO0))
        {
            /* Insert error handling */
        }
    }

Parameters
  • base: The register base address of the protection struct being configured.

  • config: Initialization structure with all the protection attributes.

cy_en_prot_status_t Cy_Prot_ConfigPpuFixedGrSlaveStruct(PERI_PPU_GR_Type *base, const cy_stc_ppu_gr_cfg_t *config)

Configures a Fixed Peripheral Group Protection Unit (PPU GR) slave protection struct with its protection attributes.

This function configures the slave struct of a PPU GR pair, which can protect an entire peripheral MMIO group from invalid bus master accesses. Refer to the device Technical Reference manual for details on peripheral MMIO grouping and which peripherals belong to which groups.

Each fixed PPU GR is devoted to a defined MMIO group. Hence the address, regionSize and subregions of the configuration struct are not applicable.

Note that the user/privileged execute accesses are read-only and are always enabled.

note

This function is applicable for CPUSS ver_1 only.

Status

Description

CY_PROT_SUCCESS

PPU GR slave struct was successfully configured.

CY_PROT_FAILURE

The resource is locked.

CY_PROT_BAD_PARAM

An incorrect/invalid parameter was passed.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

Return

Status of the function call.

Function Usage


    /* Scenario: A bus master must not be able to access the Peripheral group 0 MMIO
                 registers (0x40000000 ~ 0x400FFFFF) unless it has the "secure"
                 attribute and is operating in "privileged" mode at PC=0 or PC=2. */
    
    cy_stc_ppu_gr_cfg_t grPpuCfg_s = {
        /*.userPermission =*/ CY_PROT_PERM_DISABLED,/* Disallow all user mode accesses */
        /*.privPermission =*/ CY_PROT_PERM_RW,      /* Allow Read and Write privileged mode accesses */
        /*.secure =*/ true,                         /* Only allow "secure" bus masters */
        /*.pcMatch =*/ false,                       /* Perform access evaluation */
        /*.pcMask =*/ (uint16_t)CY_PROT_PCMASK2     /* Allow PC=0 and PC=2 accesses */
    };
    
    /* Configure the slave struct of PPU MMIO Group #0 */
    if(CY_PROT_SUCCESS != Cy_Prot_ConfigPpuFixedGrSlaveStruct(PERI_PPU_GR_MMIO0, &grPpuCfg_s))
    {
        /* Insert error handling */
    }
    else
    {
        /* Enable the slave struct of PPU MMIO Group #0 */
        if(CY_PROT_SUCCESS != Cy_Prot_EnablePpuFixedGrSlaveStruct(PERI_PPU_GR_MMIO0))
        {
            /* Insert error handling */
        }
    }

Parameters
  • base: The register base address of the protection structure being configured.

  • config: Initialization structure with all the protection attributes.

cy_en_prot_status_t Cy_Prot_EnablePpuFixedGrMasterStruct(PERI_PPU_GR_Type *base)

Enables the Master PPU GR structure.

This is a PPU GR master struct enable function. The PPU GR protection settings will take effect after successful completion of this function call.

note

This function is applicable for CPUSS ver_1 only.

Status

Description

CY_PROT_SUCCESS

The Master PU struct was enabled.

CY_PROT_FAILURE

The Master PU struct is disabled and possibly locked.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

Return

Status of the function call.

Function Usage


    /* Scenario: The master struct of PERI_PPU_GR_MMIO0 is configured to protect
                 its slave struct and needs to be enabled. */
    
    if(CY_PROT_SUCCESS != Cy_Prot_EnablePpuFixedGrMasterStruct(PERI_PPU_GR_MMIO0))
    {
        /* Insert error handling */
    }

Parameters
  • base: The base address for the protection unit structure being configured.

cy_en_prot_status_t Cy_Prot_DisablePpuFixedGrMasterStruct(PERI_PPU_GR_Type *base)

Disables the Master PPU GR structure.

This is a PPU GR master struct disable function. The PPU GR protection settings will seize to take effect after successful completion of this function call.

note

This function is applicable for CPUSS ver_1 only.

Status

Description

CY_PROT_SUCCESS

The Master PU struct was disabled.

CY_PROT_FAILURE

The Master PU struct is enabled and possibly locked.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

Return

Status of the function call.

Function Usage


    /* Scenario: The master struct of PERI_PPU_GR_MMIO0 needs to be disabled. Or
                 it needs to be reconfigured and hence must first be disabled. */
    
    if(CY_PROT_SUCCESS != Cy_Prot_DisablePpuFixedGrMasterStruct(PERI_PPU_GR_MMIO0))
    {
        /* Insert error handling */
    }

Parameters
  • base: The base address for the protection unit structure being configured.

cy_en_prot_status_t Cy_Prot_EnablePpuFixedGrSlaveStruct(PERI_PPU_GR_Type *base)

Enables the Slave PPU GR structure.

This is a PPU GR slave struct enable function. The PPU GR protection settings will take effect after successful completion of this function call.

note

This function is applicable for CPUSS ver_1 only.

Status

Description

CY_PROT_SUCCESS

The Slave PU struct was enabled.

CY_PROT_FAILURE

The Slave PU struct is disabled and possibly locked.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

Return

Status of the function call.

Function Usage


    /* Scenario: The slave struct of PERI_PPU_GR_MMIO0 is configured to protect
                 MMIO #0 and needs to be enabled. */
    
    if(CY_PROT_SUCCESS != Cy_Prot_EnablePpuFixedGrSlaveStruct(PERI_PPU_GR_MMIO0))
    {
        /* Insert error handling */
    }

Parameters
  • base: The base address for the protection unit structure being configured.

cy_en_prot_status_t Cy_Prot_DisablePpuFixedGrSlaveStruct(PERI_PPU_GR_Type *base)

Disables the Slave PPU GR structure.

This is a PPU GR slave struct disable function. The PPU GR protection settings will seize to take effect after successful completion of this function call.

note

This function is applicable for CPUSS ver_1 only.

Status

Description

CY_PROT_SUCCESS

The Slave PU struct was disabled.

CY_PROT_FAILURE

The Slave PU struct is enabled and possibly locked.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

Return

Status of the function call.

Function Usage

    
    /* Scenario: The slave struct of PERI_PPU_GR_MMIO0 needs to be disabled. Or
                 it needs to be reconfigured and hence must first be disabled. */
    
    if(CY_PROT_SUCCESS != Cy_Prot_DisablePpuFixedGrSlaveStruct(PERI_PPU_GR_MMIO0))
    {
        /* Insert error handling */
    }

Parameters
  • base: The base address for the protection unit structure being configured.

cy_en_prot_status_t Cy_Prot_ConfigPpuFixedSlMasterStruct(PERI_GR_PPU_SL_Type *base, const cy_stc_ppu_sl_cfg_t *config)

Configures a Fixed Peripheral Slave Protection Unit (PPU SL) master protection struct with its protection attributes.

This function configures the master struct governing the corresponding slave struct pair. It is a mechanism to protect the slave PPU SL struct. Since the memory location of the slave struct is known, the address, regionSize and subregions of the configuration struct are not applicable.

Note that only the user/privileged write permissions are configurable. The read and execute permissions are read-only and cannot be configured.

note

This function is applicable for CPUSS ver_1 only.

Status

Description

CY_PROT_SUCCESS

PPU SL master struct was successfully configured.

CY_PROT_FAILURE

The resource is locked.

CY_PROT_BAD_PARAM

An incorrect/invalid parameter was passed.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

Return

Status of the function call.

Function Usage


    /* Scenario: A bus master must not be able to access the PERI_GR_PPU_SL_CRYPTO
                 master and slave structs unless operating with PC=0, "secure" and
                 "privileged" access settings. The PERI_GR_PPU_SL_CRYPTO slave struct
                 is  already configured and enabled. */
    
    cy_stc_ppu_sl_cfg_t slPpuCfg_m = {
        /*.userPermission =*/ CY_PROT_PERM_R,       /* Read access always available for Master */
        /*.privPermission =*/ CY_PROT_PERM_RW,      /*  Allow read and write privileged mode accesses */
        /*.secure =*/ true,                         /* Only allow "secure" bus masters */
        /*.pcMatch =*/ false,                       /* Perform access evaluation */
        /*.pcMask =*/ (uint16_t)0UL                 /* Only allow PC=0 bus masters */
    };
    
    /* Configure the master struct of PPU Slave (SL) governing the Crypto registers */
    if(CY_PROT_SUCCESS != Cy_Prot_ConfigPpuFixedSlMasterStruct(PERI_GR_PPU_SL_CRYPTO, &slPpuCfg_m))
    {
        /* Insert error handling */
    }
    else
    {
        /* Enable the master struct of PPU Slave (SL) governing the Crypto registers */
        if(CY_PROT_SUCCESS != Cy_Prot_EnablePpuFixedSlMasterStruct(PERI_GR_PPU_SL_CRYPTO))
        {
            /* Insert error handling */
        }
    }

Parameters
  • base: The register base address of the protection struct being configured.

  • config: Initialization structure with all the protection attributes.

cy_en_prot_status_t Cy_Prot_ConfigPpuFixedSlSlaveStruct(PERI_GR_PPU_SL_Type *base, const cy_stc_ppu_sl_cfg_t *config)

Configures a Fixed Peripheral Slave Protection Unit (PPU SL) slave protection struct with its protection attributes.

This function configures the slave struct of a PPU SL pair, which can protect an entire peripheral slave instance from invalid bus master accesses. For example, TCPWM0, TCPWM1, SCB0 and SCB1 etc.

Each fixed PPU SL is devoted to a defined peripheral slave. Hence the address, regionSize and subregions of the configuration struct are not applicable.

Note that the user/privileged execute accesses are read-only and are always enabled.

note

This function is applicable for CPUSS ver_1 only.

Status

Description

CY_PROT_SUCCESS

PPU SL slave struct was successfully configured.

CY_PROT_FAILURE

The resource is locked.

CY_PROT_BAD_PARAM

An incorrect/invalid parameter was passed.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

Return

Status of the function call.

Function Usage


    /* Scenario: A bus master must not be able to access the Crypto registers 
                (governed by a dedicated slave PPU) unless it has the "secure"
                 attribute and is operating in "privileged" mode at PC=0 or PC=2. */
    
    cy_stc_ppu_sl_cfg_t slPpuCfg_s = {
        /*.userPermission =*/ CY_PROT_PERM_DISABLED,/* Disallow all user mode accesses */
        /*.privPermission =*/ CY_PROT_PERM_RW,      /* Allow Read and Write privileged mode accesses */
        /*.secure =*/ true,                         /* Only allow "secure" bus masters */
        /*.pcMatch =*/ false,                       /* Perform access evaluation */
        /*.pcMask =*/ (uint16_t)CY_PROT_PCMASK2     /* Allow PC=0 and PC=2 accesses */
    };
    
    /* Configure the slave struct of PPU Slave (SL) governing the Crypto registers */
    if(CY_PROT_SUCCESS != Cy_Prot_ConfigPpuFixedSlSlaveStruct(PERI_GR_PPU_SL_CRYPTO, &slPpuCfg_s))
    {
        /* Insert error handling */
    }
    else
    {
        /* Enable the slave struct of PPU Slave (SL) governing the Crypto registers  */
        if(CY_PROT_SUCCESS != Cy_Prot_EnablePpuFixedSlSlaveStruct(PERI_GR_PPU_SL_CRYPTO))
        {
            /* Insert error handling */
        }
    }

Parameters
  • base: The register base address of the protection structure being configured.

  • config: Initialization structure with all the protection attributes.

cy_en_prot_status_t Cy_Prot_EnablePpuFixedSlMasterStruct(PERI_GR_PPU_SL_Type *base)

Enables the Master PPU SL structure.

This is a PPU SL master struct enable function. The PPU SL protection settings will take effect after successful completion of this function call.

note

This function is applicable for CPUSS ver_1 only.

Status

Description

CY_PROT_SUCCESS

The Master PU struct was enabled.

CY_PROT_FAILURE

The Master PU struct is disabled and possibly locked.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

Return

Status of the function call.

Function Usage


    /* Scenario: The master struct of PERI_GR_PPU_SL_CRYPTO is configured to 
                 protect its slave struct and needs to be enabled. */
    
    if(CY_PROT_SUCCESS != Cy_Prot_EnablePpuFixedSlMasterStruct(PERI_GR_PPU_SL_CRYPTO))
    {
        /* Insert error handling */
    }
    

Parameters
  • base: The base address for the protection unit structure being configured.

cy_en_prot_status_t Cy_Prot_DisablePpuFixedSlMasterStruct(PERI_GR_PPU_SL_Type *base)

Disables the Master PPU SL structure.

This is a PPU SL master struct disable function. The PPU SL protection settings will seize to take effect after successful completion of this function call.

note

This function is applicable for CPUSS ver_1 only.

Status

Description

CY_PROT_SUCCESS

The Master PU struct was disabled.

CY_PROT_FAILURE

The Master PU struct is enabled and possibly locked.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

Return

Status of the function call.

Function Usage

    
    /* Scenario: The master struct of PERI_GR_PPU_SL_CRYPTO needs to be disabled.
                 Or it needs to be reconfigured and hence must first be disabled. */
    
    if(CY_PROT_SUCCESS != Cy_Prot_DisablePpuFixedSlMasterStruct(PERI_GR_PPU_SL_CRYPTO))
    {
        /* Insert error handling */
    }

Parameters
  • base: The base address for the protection unit structure being configured.

cy_en_prot_status_t Cy_Prot_EnablePpuFixedSlSlaveStruct(PERI_GR_PPU_SL_Type *base)

Enables the Slave PPU SL structure.

This is a PPU SL slave struct enable function. The PPU SL protection settings will take effect after successful completion of this function call.

note

This function is applicable for CPUSS ver_1 only.

Status

Description

CY_PROT_SUCCESS

The Slave PU struct was enabled.

CY_PROT_FAILURE

The Slave PU struct is disabled and possibly locked.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

Return

Status of the function call.

Function Usage


    /* Scenario: The slave struct of PERI_GR_PPU_SL_CRYPTO is configured to 
                 protect the Crypto registers and needs to be enabled. */
    
    if(CY_PROT_SUCCESS != Cy_Prot_EnablePpuFixedSlSlaveStruct(PERI_GR_PPU_SL_CRYPTO))
    {
        /* Insert error handling */
    }

Parameters
  • base: The base address for the protection unit structure being configured.

cy_en_prot_status_t Cy_Prot_DisablePpuFixedSlSlaveStruct(PERI_GR_PPU_SL_Type *base)

Disables the Slave PPU SL structure.

This is a PPU SL slave struct disable function. The PPU SL protection settings will seize to take effect after successful completion of this function call.

note

This function is applicable for CPUSS ver_1 only.

Status

Description

CY_PROT_SUCCESS

The Slave PU struct was enabled.

CY_PROT_FAILURE

The Slave PU struct is disabled and possibly locked.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

Return

Status of the function call.

Function Usage

    
    /* Scenario: The slave struct of PERI_GR_PPU_SL_CRYPTO needs to be disabled.
                 Or it needs to be reconfigured and hence must first be disabled. */
    
    if(CY_PROT_SUCCESS != Cy_Prot_DisablePpuFixedSlSlaveStruct(PERI_GR_PPU_SL_CRYPTO))
    {
        /* Insert error handling */
    }

Parameters
  • base: The base address for the protection unit structure being configured.

cy_en_prot_status_t Cy_Prot_ConfigPpuFixedRgMasterStruct(PERI_GR_PPU_RG_Type *base, const cy_stc_ppu_rg_cfg_t *config)

Configures a Fixed Peripheral Region Protection Unit (PPU RG) master protection struct with its protection attributes.

This function configures the master struct governing the corresponding slave struct pair. It is a mechanism to protect the slave PPU RG struct. Since the memory location of the slave struct is known, the address, regionSize and subregions of the configuration struct are not applicable.

Note that only the user/privileged write permissions are configurable. The read and execute permissions are read-only and cannot be configured.

note

This function is applicable for CPUSS ver_1 only.

Status

Description

CY_PROT_SUCCESS

PPU RG master struct was successfully configured.

CY_PROT_FAILURE

The resource is locked.

CY_PROT_BAD_PARAM

An incorrect/invalid parameter was passed.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

Return

Status of the function call.

Function Usage


    /* Scenario: A bus master must not be able to access the PERI_GR_PPU_RG_IPC_STRUCT0
                 master and slave structs unless operating with PC=0, "secure" and
                 "privileged" access settings. The PERI_GR_PPU_RG_IPC_STRUCT0 slave
                 struct is already configured and enabled. */
    
    cy_stc_ppu_rg_cfg_t rgPpuCfg_m = {
        /*.userPermission =*/ CY_PROT_PERM_R,       /* Read access always available for Master */
        /*.privPermission =*/ CY_PROT_PERM_RW,      /*  Allow read and write privileged mode accesses */
        /*.secure =*/ true,                         /* Only allow "secure" bus masters */
        /*.pcMatch =*/ false,                       /* Perform access evaluation */
        /*.pcMask =*/ (uint16_t)0UL                 /* Only allow PC=0 bus masters */
    };
    
    /* Configure the master struct of PPU Region (RG) governing the IPC_STRUCT0 registers */
    if(CY_PROT_SUCCESS != Cy_Prot_ConfigPpuFixedRgMasterStruct(PERI_GR_PPU_RG_IPC_STRUCT0, &rgPpuCfg_m))
    {
        /* Insert error handling */
    }
    else
    {
        /* Enable the master struct of PPU Region (RG) governing the IPC_STRUCT0 registers */
        if(CY_PROT_SUCCESS != Cy_Prot_EnablePpuFixedRgMasterStruct(PERI_GR_PPU_RG_IPC_STRUCT0))
        {
            /* Insert error handling */
        }
    }

Parameters
  • base: The register base address of the protection struct being configured.

  • config: Initialization structure with all the protection attributes.

cy_en_prot_status_t Cy_Prot_ConfigPpuFixedRgSlaveStruct(PERI_GR_PPU_RG_Type *base, const cy_stc_ppu_rg_cfg_t *config)

Configures a Fixed Peripheral Region Protection Unit (PPU RG) slave protection struct with its protection attributes.

This function configures the slave struct of a PPU RG pair, which can protect specified regions of peripheral instances. For example, individual DW channel structs, SMPU structs, and IPC structs etc.

Each fixed PPU RG is devoted to a defined peripheral region. Hence the address, regionSize and subregions of the configuration struct are not applicable.

Note that the user/privileged execute accesses are read-only and are always enabled.

note

This function is applicable for CPUSS ver_1 only.

Status

Description

CY_PROT_SUCCESS

PPU RG slave struct was successfully configured.

CY_PROT_FAILURE

The resource is locked.

CY_PROT_BAD_PARAM

An incorrect/invalid parameter was passed.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

Return

Status of the function call.

Function Usage


    /* Scenario: A bus master must not be able to access the IPC_STRUCT #0 registers 
                (governed by a dedicated region PPU) unless it has the "secure"
                 attribute and is operating in "privileged" mode at PC=0 or PC=2. */
    
    cy_stc_ppu_rg_cfg_t rgPpuCfg_s = {
        /*.userPermission =*/ CY_PROT_PERM_DISABLED,/* Disallow all user mode accesses */
        /*.privPermission =*/ CY_PROT_PERM_RW,      /* Allow Read and Write privileged mode accesses */
        /*.secure =*/ true,                         /* Only allow "secure" bus masters */
        /*.pcMatch =*/ false,                       /* Perform access evaluation */
        /*.pcMask =*/ (uint16_t)CY_PROT_PCMASK2     /* Allow PC=0 and PC=2 accesses */
    };
    
    /* Configure the slave struct of PPU Region (RG) governing IPC_STRUCT0 */
    if(CY_PROT_SUCCESS != Cy_Prot_ConfigPpuFixedRgSlaveStruct(PERI_GR_PPU_RG_IPC_STRUCT0, &rgPpuCfg_s))
    {
        /* Insert error handling */
    }
    else
    {
        /* Enable the slave struct of PPU Slave (SL) governing IPC_STRUCT0  */
        if(CY_PROT_SUCCESS != Cy_Prot_EnablePpuFixedRgSlaveStruct(PERI_GR_PPU_RG_IPC_STRUCT0))
        {
            /* Insert error handling */
        }
    }

Parameters
  • base: The register base address of the protection structure being configured.

  • config: Initialization structure with all the protection attributes.

cy_en_prot_status_t Cy_Prot_EnablePpuFixedRgMasterStruct(PERI_GR_PPU_RG_Type *base)

Enables the Master PPU RG structure.

This is a PPU RG master struct enable function. The PPU RG protection settings will take effect after successful completion of this function call.

note

This function is applicable for CPUSS ver_1 only.

Status

Description

CY_PROT_SUCCESS

The Master PU struct was enabled.

CY_PROT_FAILURE

The Master PU struct is disabled and possibly locked.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

Return

Status of the function call.

Function Usage


    /* Scenario: The master struct of PERI_GR_PPU_RG_IPC_STRUCT0 is configured 
                 to protect its slave struct and needs to be enabled. */
    
    if(CY_PROT_SUCCESS != Cy_Prot_EnablePpuFixedRgMasterStruct(PERI_GR_PPU_RG_IPC_STRUCT0))
    {
        /* Insert error handling */
    }

Parameters
  • base: The base address for the protection unit structure being configured.

cy_en_prot_status_t Cy_Prot_DisablePpuFixedRgMasterStruct(PERI_GR_PPU_RG_Type *base)

Disables the Master PPU RG structure.

This is a PPU RG master struct disable function. The PPU RG protection settings will seize to take effect after successful completion of this function call.

note

This function is applicable for CPUSS ver_1 only.

Status

Description

CY_PROT_SUCCESS

The Master PU struct was disabled.

CY_PROT_FAILURE

The Master PU struct is enabled and possibly locked.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

Return

Status of the function call.

Function Usage

    
    /* Scenario: The master struct of PERI_GR_PPU_RG_IPC_STRUCT0 needs to be disabled.
                 Or it needs to be reconfigured and hence must first be disabled. */
    
    if(CY_PROT_SUCCESS != Cy_Prot_DisablePpuFixedRgMasterStruct(PERI_GR_PPU_RG_IPC_STRUCT0))
    {
        /* Insert error handling */
    }

Parameters
  • base: The base address for the protection unit structure being configured.

cy_en_prot_status_t Cy_Prot_EnablePpuFixedRgSlaveStruct(PERI_GR_PPU_RG_Type *base)

Enables the Slave PPU RG structure.

This is a PPU RG slave struct enable function. The PPU RG protection settings will take effect after successful completion of this function call.

note

This function is applicable for CPUSS ver_1 only.

Status

Description

CY_PROT_SUCCESS

The Slave PU struct was enabled.

CY_PROT_FAILURE

The Slave PU struct is disabled and possibly locked.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

Return

Status of the function call.

Function Usage


    /* Scenario: The slave struct of PERI_GR_PPU_RG_IPC_STRUCT0 is configured 
                 to protect the IPC_STRUCT0 registers and needs to be enabled. */
    
    if(CY_PROT_SUCCESS != Cy_Prot_EnablePpuFixedRgSlaveStruct(PERI_GR_PPU_RG_IPC_STRUCT0))
    {
        /* Insert error handling */
    }

Parameters
  • base: The base address for the protection unit structure being configured.

cy_en_prot_status_t Cy_Prot_DisablePpuFixedRgSlaveStruct(PERI_GR_PPU_RG_Type *base)

Disables the Slave PPU RG structure.

This is a PPU RG slave struct disable function. The PPU RG protection settings will seize to take effect after successful completion of this function call.

note

This function is applicable for CPUSS ver_1 only.

Status

Description

CY_PROT_SUCCESS

The Slave PU struct was disabled.

CY_PROT_FAILURE

The Slave PU struct is enabled and possibly locked.

CY_PROT_INVALID_STATE

The function was called on the device with an unsupported PERI HW version.

Return

Status of the function call.

Function Usage


    /* Scenario: The slave struct of PERI_GR_PPU_RG_IPC_STRUCT0 needs to be disabled.
                 Or it needs to be reconfigured and hence must first be disabled. */
    
    if(CY_PROT_SUCCESS != Cy_Prot_DisablePpuFixedRgSlaveStruct(PERI_GR_PPU_RG_IPC_STRUCT0))
    {
        /* Insert error handling */
    }

Parameters
  • base: The base address for the protection unit structure being configured.

struct cy_stc_mpu_cfg_t
#include <cy_prot.h>

Configuration structure for MPU Struct initialization.

Public Members

uint32_t *address

Base address of the memory region.

cy_en_prot_size_t regionSize

Size of the memory region.

uint8_t subregions

Mask of the 8 subregions to disable.

cy_en_prot_perm_t userPermission

User permissions for the region.

cy_en_prot_perm_t privPermission

Privileged permissions for the region.

bool secure

Non Secure = 0, Secure = 1.

struct cy_stc_smpu_cfg_t
#include <cy_prot.h>

Configuration structure for SMPU struct initialization.

Public Members

uint32_t *address

Base address of the memory region (Only applicable to slave)

cy_en_prot_size_t regionSize

Size of the memory region (Only applicable to slave)

uint8_t subregions

Mask of the 8 subregions to disable (Only applicable to slave)

cy_en_prot_perm_t userPermission

User permissions for the region.

cy_en_prot_perm_t privPermission

Privileged permissions for the region.

bool secure

Non Secure = 0, Secure = 1.

bool pcMatch

Access evaluation = 0, Matching = 1.

uint16_t pcMask

Mask of allowed protection context(s)

struct cy_stc_ppu_prog_cfg_t
#include <cy_prot.h>

Configuration structure for Programmable (PROG) PPU (PPU_PR) struct initialization.

Public Members

uint32_t *address

Base address of the memory region (Only applicable to slave)

cy_en_prot_size_t regionSize

Size of the memory region (Only applicable to slave)

uint8_t subregions

Mask of the 8 subregions to disable (Only applicable to slave)

cy_en_prot_perm_t userPermission

User permissions for the region.

cy_en_prot_perm_t privPermission

Privileged permissions for the region.

bool secure

Non Secure = 0, Secure = 1.

bool pcMatch

Access evaluation = 0, Matching = 1.

uint16_t pcMask

Mask of allowed protection context(s)

struct cy_stc_ppu_gr_cfg_t
#include <cy_prot.h>

Configuration structure for Fixed Group (GR) PPU (PPU_GR) struct initialization.

Public Members

cy_en_prot_perm_t userPermission

User permissions for the region.

cy_en_prot_perm_t privPermission

Privileged permissions for the region.

bool secure

Non Secure = 0, Secure = 1.

bool pcMatch

Access evaluation = 0, Matching = 1.

uint16_t pcMask

Mask of allowed protection context(s)

struct cy_stc_ppu_sl_cfg_t
#include <cy_prot.h>

Configuration structure for Fixed Slave (SL) PPU (PPU_SL) struct initialization.

Public Members

cy_en_prot_perm_t userPermission

User permissions for the region.

cy_en_prot_perm_t privPermission

Privileged permissions for the region.

bool secure

Non Secure = 0, Secure = 1.

bool pcMatch

Access evaluation = 0, Matching = 1.

uint16_t pcMask

Mask of allowed protection context(s)

struct cy_stc_ppu_rg_cfg_t
#include <cy_prot.h>

Configuration structure for Fixed Region (RG) PPU (PPU_RG) struct initialization.

Public Members

cy_en_prot_perm_t userPermission

User permissions for the region.

cy_en_prot_perm_t privPermission

Privileged permissions for the region.

bool secure

Non Secure = 0, Secure = 1.

bool pcMatch

Access evaluation = 0, Matching = 1.

uint16_t pcMask

Mask of allowed protection context(s)