PPU Programmable (PROG) v2 Functions

group group_prot_functions_ppu_prog_v2

Functions

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.