HAL GTZC How to Use

group GTZC_How_To_Use

This file provides firmware functions to manage the following functionalities of GTZC peripheral:

  • Configure securable peripherals security and privilege attributes

  • Lock the security and privilege attributes configurations of securable peripherals

  • Configure memory subregion watermark security and privilege attributes

  • Enable/Disable memory subregion watermark

  • Lock the configurations of memory subregion watermark

  • Configure block based memories security and privilege attributes

  • Configure the clock security state of block based memories

  • Configure the secure access state of block based memories

  • Lock the configurations of block based memories

  • Enable/Disable the illegal access interrupt of peripherals

  • Treat the illegal access interrupt

GTZC main features

Global TrustZone Controller (GTZC) composed of three sub-blocks:

  1. TZSC: TrustZone security controller This sub-block defines the secure/privileged state of master and slave peripherals. It also controls the secure/privileged state of subregions for the watermark memory peripheral controller (MPCWM).

  2. MPCBB: Block-Based memory protection controller This sub-block defines the secure/privileged state of all blocks (block = 512-byte page) of the associated SRAM.

  3. TZIC: TrustZone illegal access controller This sub-block gathers all illegal access events in the system and generates a secure interrupt towards NVIC.

These sub-blocks are used to configure TrustZone system security in a product having bus agents with programmable-security and privileged attributes (securable) such as:

  • on-chip RAM with programmable secure and/or privilege blocks (pages)

  • AHB and APB peripherals with programmable security and/or privilege access

  • off-chip memories with secure and/or privilege areas

TZIC is accessible only with secure privileged transactions.

Secure and non-secure accesses are supported for privileged and unprivileged settings of TZSC and MPCBB.

GTZC clock configuration

  • GTZC1 : clocked by AHB1 bus clock

  • GTZC2 : clocked by AHB3 bus clock

How to use the GTZC HAL module driver

The GTZC HAL driver can be used as follows:

  1. Enable the GTZC low level resources using the functions HAL_RCC_GTZC1_EnableClock() for GTZC1 instance and HAL_RCC_GTZC2_EnableClock() for GTZC2 instance

  2. Declare a hal_gtzc_attr_config_t security attributes configuration structure: hal_gtzc_attr_config_t p_attr;

  3. Set the security and privilege attributes of securable peripherals using: HAL_GTZC_SetPeriphAttr() ;

  4. Get the security and privilege attributes of securable peripherals using: HAL_GTZC_GetPeriphAttr() ;

  5. Lock the security and privilege attributes configurations of securable peripherals using: HAL_GTZC_LockPeriphAttr() ;

  6. Retrieve the lock state of security and privilege attributes configurations of securable peripherals using: HAL_GTZC_IsPeriphAttrLocked() ;

  7. Set the security and privilege attributes configurations of memory subregion watermark using: HAL_GTZC_WATERMARK_SetConfigMemSubRegionAttr() ;

  8. Get the security and privilege attributes configurations of memory subregion watermark using: HAL_GTZC_WATERMARK_GetMemAreaAttr() ;

  9. Get the security and privilege attributes configurations of all watermark memories area using: HAL_GTZC_WATERMARK_GetMemMapAttr() ;

  10. Enable memory subregion watermark using: HAL_GTZC_WATERMARK_EnableMemSubRegionAttr() ;

  11. Disable memory subregion watermark using: HAL_GTZC_WATERMARK_DisableMemSubRegionAttr() ;

  12. Check if memory subregion watermark is enabled or disabled using: HAL_GTZC_WATERMARK_IsEnabledMemSubRegionAttr() ;

  13. Lock the configurations of memory subregion watermark using: HAL_GTZC_WATERMARK_LockMemSubRegionConfig() ;

  14. Check if memory subregion watermark configurations is locked or unlocked using: HAL_GTZC_WATERMARK_IsMemSubRegionConfigLocked() ;

  15. Set the security and privilege attributes of block based memories by block entity using: HAL_GTZC_BLOCKBASED_SetMemBlockAttr() ;

  16. Get the security and privilege attributes of block based memories by block entity using: HAL_GTZC_BLOCKBASED_GetMemBlockAttr() ;

  17. Set the security and privilege attributes of block based memories by address entity using: HAL_GTZC_BLOCKBASED_SetMemAddrAttr() ;

  18. Get the security and privilege attributes of block based memories by address entity using: HAL_GTZC_BLOCKBASED_GetMemAddrAttr() ;

  19. Set the clock security state of block based memories using: HAL_GTZC_BLOCKBASED_SetMemClkSecStateInvertion() ;

  20. Get the clock security state of block based memories using: HAL_GTZC_BLOCKBASED_GetMemClkSecStateInvertion() ;

  21. Set the secure access state of block based memories using: HAL_GTZC_BLOCKBASED_SetMemSecAccessState() ;

  22. Get the secure access state of block based memories using: HAL_GTZC_BLOCKBASED_GetMemSecAccessState() ;

  23. Lock the security and privilege attributes configurations of block based memories by super block entity using: HAL_GTZC_BLOCKBASED_LockMemSuperBlockAttr() ;

  24. Check if the security and privilege attributes configurations of block based memories is locked or unlocked by super block entity using: HAL_GTZC_BLOCKBASED_IsMemSuperBlockAttrLocked() ;

  25. Lock the security and privilege attributes configurations of block based memories by address entity using: HAL_GTZC_BLOCKBASED_LockMemAttr() ;

  26. Check if the security and privilege attributes configurations of block based memories is locked or unlocked by address entity using: HAL_GTZC_BLOCKBASED_IsMemAttrLocked() ;

  27. Lock the block based memories configurations using: HAL_GTZC_BLOCKBASED_LockMemConfig() ;

  28. Check if the block based memories configurations is locked or unlocked using: HAL_GTZC_BLOCKBASED_IsMemConfigLocked() ;

  29. Activate the illegal access interrupt of peripherals using: HAL_GTZC_ILLEGALACCESS_EnableIT() ;

  30. Deactivate the illegal access interrupt of peripherals using: HAL_GTZC_ILLEGALACCESS_DisableIT() ;

  31. Check if the illegal access interrupt of peripheral is enabled or disabled using: HAL_GTZC_ILLEGALACCESS_IsEnabledIT() ;

  32. Illegal access interrupt service routines are served by: HAL_GTZC_ILLEGALACCESS_IRQHandler() ;

  33. User can add his own code using: HAL_GTZC_ILLEGALACCESS_Callback() ;