HAL GTZC Use Cases

Switch from secure application to non-secure application for TZEN=1

@startuml

hide footbox

participant "Secure Application"

participant "Non-Secure Application"

participant "System"

participant "GTZC Driver"



activate "Secure Application"



group #9898fb Initialization

"Secure Application"->"System" ++ : HAL_Init()

end



group #lightblue Isolation configuration

"Secure Application"->"GTZC Driver" ++ : HAL_GTZC_BLOCKBASED_SetMemBlockAttr()

note right: by block entity  : Configure internal SRAM as non-secure for the Non-secure App

"Secure Application"->"GTZC Driver" : HAL_GTZC_BLOCKBASED_SetMemAddrAttr()

note right: by address entity : Configure internal SRAM as non-secure for the Non-secure App

end



group #lightsalmon jump to non-secure application

"Secure Application"->"Non-Secure Application" ++ : NonSecure_Init()

note right: - Set non-secure main stack (MSP_NS) \n- Get non-secure reset handler \n- Start non-secure state software application 

end



deactivate "Secure Application"



group #9898fb Initialization

"Non-Secure Application"->"System" : HAL_Init()

"Non-Secure Application"->"System" : SystemClock_Config()

end

@enduml

Called functions:

Isolation configuration for TZEN=1

@startuml

hide footbox

participant "Secure Application"

participant "Non-Secure Application"

participant "System"

participant "GTZC Driver"





activate "Secure Application"



group #9898fb Initialization

"Secure Application" ->"System" ++ : HAL_Init()

end



group #lightblue Isolation configuration

"Secure Application"->"GTZC Driver" ++ : HAL_GTZC_SetPeriphAttr()

note right : Set the security attribute and the privilege attribute of securable peripherals 

"Secure Application"->"GTZC Driver" : HAL_GTZC_WATERMARK_SetConfigMemSubRegionAttr()

note right : Set the security attribute and the privilege attribute of watermark memories 

"Secure Application"->"GTZC Driver" : HAL_GTZC_BLOCKBASED_SetMemAddrAttr()

note right : Set the security attribute and the privilege attribute of block based memories

end



group #lightsalmon jump to non-secure application

"Secure Application"->"Non-Secure Application" ++ : NonSecure_Init()

note right: - Set non-secure main stack (MSP_NS) \n- Get non-secure reset handler \n- Start non-secure state software application 

end



group #9898fb Initialization

"Non-Secure Application"->"System" : HAL_Init()

"Non-Secure Application"->"System" : SystemClock_Config()

end



group #lightblue Isolation configuration

"Non-Secure Application"->"GTZC Driver": HAL_GTZC_SetPeriphAttr()

note right : Set only the privilege attribute of securable peripherals

"Non-Secure Application"->"GTZC Driver": HAL_GTZC_BLOCKBASED_SetMemAddrAttr()

note right : Set only the privilege attribute of block based memories

end



@enduml

Called functions:

Isolation configuration for TZEN=0

@startuml

hide footbox

participant "Application"

participant "System"

participant "GTZC Driver"



activate "Application"



group #9898fb Initialization

"Application" ->"System" ++ : HAL_Init()

"Application"->"System" : SystemClock_Config()

end



group #lightblue Isolation configuration

"Application"->"GTZC Driver" ++ : HAL_GTZC_SetPeriphAttr()

note right : Set only the privilege attribute of securable peripherals

"Application"->"GTZC Driver" : HAL_GTZC_BLOCKBASED_SetMemAddrAttr()

note right : Set only the privilege attribute of block based memories 

end



@enduml

Called functions:

Illegal access interrupt for TZEN=1

@startuml

hide footbox



participant "Secure Application"

participant "Non-Secure Application"

participant "System"

participant "GTZC Driver"

participant "Secure GTZC_IRQHandler"

participant "SRAM1"

participant "CORTEX Driver"



participant "TZIC"

activate "Secure Application"



group #9898fb Initialization

"Secure Application"->"System" ++ : HAL_Init()

end



group #lightblue Isolation configuration

"Secure Application"->"GTZC Driver" ++ : HAL_GTZC_BLOCKBASED_SetMemAddrAttr()

note right: Configure SRAM3 as non-secure

"Secure Application"->"GTZC Driver" : HAL_GTZC_ILLEGALACCESS_EnableIT()

note right: Enable Illegal access interrupt to SRAM1

group #LightSkyBlue GTZC_IRQHandler configuration

"Secure Application"->"CORTEX Driver" ++ : HAL_NVIC_SetPriority(GTZC_IRQn, PreemptPriority, SubPriority)

note right: Set GTZC_IRQn priority 

"Secure Application"->"CORTEX Driver" : HAL_NVIC_EnableIRQ(GTZC_IRQn)

note right: Enable GTZC_IRQn

end

end 



deactivate "CORTEX Driver"



group #4ef84e Access to SRAM1

"Secure Application"->"SRAM1" ++ : Read/Write in (secure) SRAM1

note right : Access accepted

end 



group #lightsalmon jump to non-secure application

"Secure Application"->"Non-Secure Application" ++ : NonSecure_Init()

note right: - Set non-secure main stack (MSP_NS) \n- Get non-secure reset handler \n- Start non-secure state software application 

end



group #9898fb Initialization

"Non-Secure Application"->"System" : HAL_Init()

"Non-Secure Application"->"System" : SystemClock_Config()

end



deactivate "System"



group #Red Access to SRAM1

"Non-Secure Application"->"SRAM1" : Read/Write in (secure) SRAM1

note right : Denied access

end 



deactivate "SRAM1"







group #LightSkyBlue  Interrupt Service Routine 

"TZIC" -> "Secure GTZC_IRQHandler" ++ : Illegal access interrupt

note left: Receive an illegal access interrupt signal

"GTZC Driver" <- "Secure GTZC_IRQHandler" : HAL_GTZC_ILLEGALACCESS_IRQHandler()

note left: Fetch the source of illegal access interrupt





"GTZC Driver" -> "Secure Application" : HAL_GTZC_ILLEGALACCESS_Callback()

note right: Execute the callback function

end



@enduml

Called functions:

Securable peripherals configuration APIs in secure application

@startuml

hide footbox

participant "Secure Application"

participant "GTZC Driver"



group #lightblue Configuration securable peripherals APIs in secure application

"Secure Application"->"GTZC Driver" ++ : HAL_GTZC_SetPeriphAttr()

note right : Set the security and privilege attributes 

activate "Secure Application"

"Secure Application"->"GTZC Driver"  : HAL_GTZC_GetPeriphAttr()

note right : Get the security and privilege attributes 

"Secure Application"->"GTZC Driver"  : HAL_GTZC_LockPeriphAttr()

note right : Lock the security and privilege attributes configuration

"Secure Application"->"GTZC Driver"  : HAL_GTZC_IsPeriphAttrLocked()

note right : Get Lock state of security and privilege attributes configuration

end

@enduml

Called functions:

Securable peripherals configuration APIs in non-secure application

@startuml

hide footbox

participant "Non-Secure Application"

participant "GTZC Driver"



group #lightblue Configuration securable peripherals APIs in non-secure application

"Non-Secure Application" ->"GTZC Driver" ++ : HAL_GTZC_SetPeriphAttr()

note right : Set only the privilege attribute 

activate "Non-Secure Application"

"Non-Secure Application" ->"GTZC Driver" : HAL_GTZC_GetPeriphAttr()

note right : Get the security and privilege attributes 

end

@enduml

Called functions:

Watermark configuration APIs in secure application

@startuml

hide footbox

participant "Secure Application"

participant "GTZC Driver"



group #lightblue Configuration watermark APIs

"Secure Application"->"GTZC Driver" ++ : HAL_GTZC_WATERMARK_SetConfigMemSubRegionAttr()

note right : Set the security and privilege attributes 

activate "Secure Application"

"Secure Application"->"GTZC Driver"  : HAL_GTZC_WATERMARK_GetMemAreaAttr()

note right : Get the security and privilege attributes 

"Secure Application"->"GTZC Driver"  : HAL_GTZC_WATERMARK_GetMemMapAttr()

note right : Get the security and privilege attributes of all memory region 

"Secure Application" ->"GTZC Driver" : HAL_GTZC_WATERMARK_EnableMemSubRegionAttr()

note right : Enable sub-region of watermark memory

"Secure Application" ->"GTZC Driver" : HAL_GTZC_WATERMARK_DisableMemSubRegionAttr()

note right : Disable sub-region of watermark memory

"Secure Application" ->"GTZC Driver" : HAL_GTZC_WATERMARK_IsEnabledMemSubRegionAttr()

note right : Check the watermark memory sub-region is enabled or disabled

"Secure Application" ->"GTZC Driver" : HAL_GTZC_WATERMARK_LockMemSubRegionConfig()

note right : Lock the security and privilege attributes configuration

"Secure Application" ->"GTZC Driver" : HAL_GTZC_WATERMARK_IsMemSubRegionConfigLocked()

note right : Get the lock state of security and privilege attributes configuration

end

@enduml

Called functions:

Block based configuration APIs in secure application

@startuml

hide footbox

participant "Secure Application"

participant "GTZC Driver"



group #lightblue Configuration Block based APIs in secure application

"Secure Application"->"GTZC Driver" ++ : HAL_GTZC_BLOCKBASED_SetMemBlockAttr()

note right : Set the security and privilege attributes by block

activate "Secure Application"

"Secure Application"->"GTZC Driver" : HAL_GTZC_BLOCKBASED_GetMemBlockAttr()

note right : Get the security and privilege attributes by block

"Secure Application"->"GTZC Driver" : HAL_GTZC_BLOCKBASED_SetMemAddrAttr()

note right : Set the security and privilege attributes by byte

"Secure Application"->"GTZC Driver" : HAL_GTZC_BLOCKBASED_GetMemAddrAttr()

note right : Get the security and privilege attributes by byte

"Secure Application"->"GTZC Driver" : HAL_GTZC_BLOCKBASED_SetMemClkSecStateInvertion()

note right : Set the clock security state  

"Secure Application"->"GTZC Driver" : HAL_GTZC_BLOCKBASED_GetMemClkSecStateInvertion()

note right : Get the clock security state  

"Secure Application"->"GTZC Driver" : HAL_GTZC_BLOCKBASED_SetMemSecAccessState()

note right : Set the secure access state 

"Secure Application"->"GTZC Driver" : HAL_GTZC_BLOCKBASED_GetMemSecAccessState()

note right : Get the secure access state

"Secure Application"->"GTZC Driver" : HAL_GTZC_BLOCKBASED_LockMemSuperBlockAttr()

note right : Lock the security and privilege attributes configuration by super block

"Secure Application"->"GTZC Driver" : HAL_GTZC_BLOCKBASED_IsMemSuperBlockAttrLocked()

note right : Get the lock state of security and privilege attributes configuration by super block

"Secure Application"->"GTZC Driver" : HAL_GTZC_BLOCKBASED_LockMemkAttr()

note right : Lock the security and privilege attributes configuration by byte

"Secure Application"->"GTZC Driver" : HAL_GTZC_BLOCKBASED_IsMemAttrLocked()

note right : Get the lock state of security and privilege attributes configuration by byte

"Secure Application"->"GTZC Driver" : HAL_GTZC_BLOCKBASED_LockMemConfig()

note right : Lock the block based memory configuration

"Secure Application"->"GTZC Driver" : HAL_GTZC_BLOCKBASED_IsMemConfigLocked()

note right : Get the lock state of block based memory configuration

end

@enduml

Called functions:

Block based configuration APIs in non-secure application

@startuml

hide footbox

participant "Non-Secure Application"

participant "GTZC Driver"



group #lightblue Configuration Block based APIs in non-secure application

"Non-Secure Application"->"GTZC Driver" ++ : HAL_GTZC_BLOCKBASED_SetMemBlockAttr()

note right : Set the privilege attribute by block

activate "Non-Secure Application"

"Non-Secure Application"->"GTZC Driver" : HAL_GTZC_BLOCKBASED_GetMemBlockAttr()

note right : Get the security and privilege attributes by block

"Non-Secure Application"->"GTZC Driver" : HAL_GTZC_BLOCKBASED_SetMemAddrAttr()

note right : Set the privilege attribute by byte

"Non-Secure Application"->"GTZC Driver" : HAL_GTZC_BLOCKBASED_GetMemAddrAttr()

note right : Get the security and privilege attributes by byte

end

@enduml

Called functions:

Illegal access configuration APIs in secure application

@startuml

hide footbox

participant "Secure Application"

participant "GTZC Driver"



group #lightblue Configuration illegal access APIs

"Secure Application"->"GTZC Driver" ++ : HAL_GTZC_ILLEGALACCESS_EnableIT()

note right : Enable the illegal access interrupt

activate "Secure Application"

"Secure Application"->"GTZC Driver" : HAL_GTZC_ILLEGALACCESS_DisableIT()

note right : Disable the illegal access interrupt

"Secure Application"->"GTZC Driver" : HAL_GTZC_ILLEGALACCESS_IsEnabledIT()

note right : Check the illegal access interrupt is enabled or disabled

"Secure Application"->"GTZC Driver" : HAL_GTZC_ILLEGALACCESS_IRQHandler()

note right : Illegal access interrupt request

"Secure Application"->"GTZC Driver" : HAL_GTZC_ILLEGALACCESS_Callback()

note right : Illegal access interrupt callback

end

@enduml

Called functions: