stm32l5xx_hal_gtzc.c 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507
  1. /**
  2. ******************************************************************************
  3. * @file stm32l5xx_hal_gtzc.c
  4. * @author MCD Application Team
  5. * @brief GTZC HAL module driver.
  6. * This file provides firmware functions to manage the following
  7. * functionalities of GTZC peripheral:
  8. * + TZSC Initialization and Configuration functions
  9. * + TZSC-MPCWM Initialization and Configuration functions
  10. * + MPCBB Initialization and Configuration functions
  11. * + TZSC, TZSC-MPCWM and MPCBB Lock functions
  12. * + TZIC Initialization and Configuration functions
  13. *
  14. ******************************************************************************
  15. * @attention
  16. *
  17. * Copyright (c) 2019 STMicroelectronics.
  18. * All rights reserved.
  19. *
  20. * This software is licensed under terms that can be found in the LICENSE file
  21. * in the root directory of this software component.
  22. * If no LICENSE file comes with this software, it is provided AS-IS.
  23. *
  24. ******************************************************************************
  25. @verbatim
  26. ==============================================================================
  27. ##### GTZC main features #####
  28. ==============================================================================
  29. [..]
  30. (+) Global TrustZone Controller (GTZC) composed of three sub-blocks:
  31. (++) TZSC: TrustZone security controller
  32. This sub-block defines the secure/privileged state of master and slave
  33. peripherals. It also controls the secure state of subregions
  34. for the watermark memory peripheral controller (MPCWM).
  35. (++) MPCBB: Block-Based memory protection controller
  36. This sub-block defines the secure state of all blocks
  37. (256-byte pages) of the associated SRAM.
  38. (++) TZIC: TrustZone illegal access controller
  39. This sub-block gathers all illegal access events in the system and
  40. generates a secure interrupt towards NVIC.
  41. (+) These sub-blocks are used to configure TrustZone system security in
  42. a product having bus agents with programmable-security and privileged
  43. attributes (securable) such as:
  44. (++) on-chip RAM with programmable secure blocks (pages)
  45. (++) AHB and APB peripherals with programmable security and/or privilege access
  46. (++) AHB master granted as secure and/or privilege
  47. (++) off-chip memories with secure areas
  48. [..]
  49. (+) TZIC accessible only with secure privileged transactions.
  50. (+) Secure and non-secure access supported for privileged and unprivileged
  51. part of TZSC and MPCBB
  52. ==============================================================================
  53. ##### How to use this driver #####
  54. ==============================================================================
  55. [..]
  56. The GTZC HAL driver can be used as follows:
  57. (#) Configure or get back securable peripherals attributes using
  58. HAL_GTZC_TZSC_ConfigPeriphAttributes() / HAL_GTZC_TZSC_GetConfigPeriphAttributes()
  59. (#) Configure or get back MPCWM memories attributes using
  60. HAL_GTZC_TZSC_MPCWM_ConfigMemAttributes() / HAL_GTZC_TZSC_MPCWM_GetConfigMemAttributes()
  61. (#) Lock TZSC sub-block or get lock status using HAL_GTZC_TZSC_Lock() /
  62. HAL_GTZC_TZSC_GetLock()
  63. (#) Configure or get back MPCBB memories complete configuration using
  64. HAL_GTZC_MPCBB_ConfigMem() / HAL_GTZC_MPCBB_GetConfigMem()
  65. (#) Configure or get back MPCBB memories attributes using
  66. HAL_GTZC_MPCBB_ConfigMemAttributes() / HAL_GTZC_MPCBB_GetConfigMemAttributes()
  67. (#) Lock MPCBB configuration or get lock status using HAL_GTZC_MPCBB_Lock() /
  68. HAL_GTZC_MPCBB_GetLock()
  69. (#) Lock MPCBB super-blocks or get lock status using HAL_GTZC_MPCBB_LockConfig() /
  70. HAL_GTZC_MPCBB_GetLockConfig()
  71. (#) Illegal access detection can be configured through TZIC sub-block using
  72. following functions: HAL_GTZC_TZIC_DisableIT() / HAL_GTZC_TZIC_EnableIT()
  73. (#) Illegal access flags can be retrieved through HAL_GTZC_TZIC_GetFlag() and
  74. HAL_GTZC_TZIC_ClearFlag() functions
  75. (#) Illegal access interrupt service routines are served by HAL_GTZC_IRQHandler()
  76. and user can add his own code using HAL_GTZC_TZIC_Callback()
  77. @endverbatim
  78. ******************************************************************************
  79. */
  80. /* Includes ------------------------------------------------------------------*/
  81. #include "stm32l5xx_hal.h"
  82. /** @addtogroup STM32L5xx_HAL_Driver
  83. * @{
  84. */
  85. /** @defgroup GTZC GTZC
  86. * @brief GTZC HAL module driver
  87. * @{
  88. */
  89. #ifdef HAL_GTZC_MODULE_ENABLED
  90. /* Private typedef -----------------------------------------------------------*/
  91. /* Private constants ---------------------------------------------------------*/
  92. /** @defgroup GTZC_Private_Constants GTZC Private Constants
  93. * @{
  94. */
  95. /* Definitions for GTZC_TZSC_MPCWM */
  96. #define GTZC_TZSC_MPCWM1_MEM_SIZE 0x10000000U /* 256MB max size */
  97. #define GTZC_TZSC_MPCWM2_MEM_SIZE 0x10000000U /* 256MB max size */
  98. #define GTZC_TZSC_MPCWM3_MEM_SIZE 0x10000000U /* 256MB max size */
  99. /* Definitions for GTZC TZSC & TZIC ALL register values */
  100. #define TZSC_SECCFGR1_ALL (0xFFFFFFFFUL)
  101. #if defined (STM32L562xx)
  102. #define TZSC_SECCFGR2_ALL (0x0007FFFFUL)
  103. #else
  104. #define TZSC_SECCFGR2_ALL (0x00076FFFUL)
  105. #endif /* STM32L562xx */
  106. #define TZSC_PRIVCFGR1_ALL (0xFFFFFFFFUL)
  107. #if defined (STM32L562xx)
  108. #define TZSC_PRIVCFGR2_ALL (0x0007FFFFUL)
  109. #else
  110. #define TZSC_PRIVCFGR2_ALL (0x00076FFFUL)
  111. #endif /* STM32L562xx */
  112. #define TZIC_IER1_ALL (0xFFFFFFFFUL)
  113. #if defined (STM32L562xx)
  114. #define TZIC_IER2_ALL (0x3FFFFFFFUL)
  115. #else
  116. #define TZIC_IER2_ALL (0x3FFF6FFFUL)
  117. #endif /* STM32L562xx */
  118. #define TZIC_IER3_ALL (0x000000FFUL)
  119. #define TZIC_FCR1_ALL (0xFFFFFFFFUL)
  120. #if defined (STM32L562xx)
  121. #define TZIC_FCR2_ALL (0x3FFFFFFFUL)
  122. #else
  123. #define TZIC_FCR2_ALL (0x3FFF6FFFUL)
  124. #endif /* STM32L562xx */
  125. #define TZIC_FCR3_ALL (0x000000FFUL)
  126. /**
  127. * @}
  128. */
  129. /* Private macros ------------------------------------------------------------*/
  130. /** @defgroup GTZC_Private_Macros GTZC Private Macros
  131. * @{
  132. */
  133. #define IS_ADDRESS_IN(mem, address)\
  134. ( ( ( (uint32_t)(address) >= (uint32_t)GTZC_BASE_ADDRESS_NS(mem) ) \
  135. && ( (uint32_t)(address) < ((uint32_t)GTZC_BASE_ADDRESS_NS(mem) + (uint32_t)GTZC_MEM_SIZE(mem) ) ) ) \
  136. || ( ( (uint32_t)(address) >= (uint32_t)GTZC_BASE_ADDRESS_S(mem) ) \
  137. && ( (uint32_t)(address) < ((uint32_t)GTZC_BASE_ADDRESS_S(mem) + (uint32_t)GTZC_MEM_SIZE(mem) ) ) ) )
  138. #define IS_ADDRESS_IN_S(mem, address)\
  139. ( ( (uint32_t)(address) >= (uint32_t)GTZC_BASE_ADDRESS_S(mem) ) \
  140. && ( (uint32_t)(address) < ((uint32_t)GTZC_BASE_ADDRESS_S(mem) + (uint32_t)GTZC_MEM_SIZE(mem) ) ) )
  141. #define IS_ADDRESS_IN_NS(mem, address)\
  142. ( ( (uint32_t)(address) >= (uint32_t)GTZC_BASE_ADDRESS_NS(mem) ) \
  143. && ( (uint32_t)(address) < ((uint32_t)GTZC_BASE_ADDRESS_NS(mem) + (uint32_t)GTZC_MEM_SIZE(mem) ) ) )
  144. #define GTZC_BASE_ADDRESS(mem)\
  145. ( mem ## _BASE )
  146. /**
  147. * @}
  148. */
  149. /* Private variables ---------------------------------------------------------*/
  150. /* Private function prototypes -----------------------------------------------*/
  151. /* Exported functions --------------------------------------------------------*/
  152. /** @defgroup GTZC_Exported_Functions GTZC Exported Functions
  153. * @{
  154. */
  155. /** @defgroup GTZC_Exported_Functions_Group1 TZSC Configuration functions
  156. * @brief TZSC Configuration functions
  157. *
  158. @verbatim
  159. ==============================================================================
  160. ##### TZSC Configuration functions #####
  161. ==============================================================================
  162. [..]
  163. This section provides functions allowing to configure TZSC
  164. TZSC is TrustZone Security Controller
  165. @endverbatim
  166. * @{
  167. */
  168. /**
  169. * @brief Configure TZSC on a single peripheral or on all peripherals.
  170. * @note Secure and non-secure attributes can only be set from the secure
  171. * state when the system implements the security (TZEN=1).
  172. * @note Privilege and non-privilege attributes can only be set from the
  173. * privilege state when TZEN=0 or TZEN=1
  174. * @note Security and privilege attributes can be set independently.
  175. * @note Default state is non-secure and unprivileged access allowed.
  176. * @param PeriphId Peripheral identifier
  177. * This parameter can be a value of @ref GTZC_TZSC_TZIC_PeriphId.
  178. * Use GTZC_PERIPH_ALL to select all peripherals.
  179. * @param PeriphAttributes Peripheral attributes, see @ref GTZC_TZSC_PeriphAttributes.
  180. * @retval HAL status.
  181. */
  182. HAL_StatusTypeDef HAL_GTZC_TZSC_ConfigPeriphAttributes(uint32_t PeriphId,
  183. uint32_t PeriphAttributes)
  184. {
  185. uint32_t register_address;
  186. /* check entry parameters */
  187. if ((PeriphAttributes > (GTZC_TZSC_PERIPH_SEC | GTZC_TZSC_PERIPH_PRIV))
  188. || (HAL_GTZC_GET_ARRAY_INDEX(PeriphId) >= GTZC_TZSC_PERIPH_NUMBER)
  189. || (((PeriphId & GTZC_PERIPH_ALL) != 0U) && (HAL_GTZC_GET_ARRAY_INDEX(PeriphId) != 0U)))
  190. {
  191. return HAL_ERROR;
  192. }
  193. if ((PeriphId & GTZC_PERIPH_ALL) != 0U)
  194. {
  195. /* special case where same attributes are applied to all peripherals */
  196. #if defined(__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  197. /* secure configuration */
  198. if ((PeriphAttributes & GTZC_TZSC_PERIPH_SEC) == GTZC_TZSC_PERIPH_SEC)
  199. {
  200. SET_BIT(GTZC_TZSC->SECCFGR1, TZSC_SECCFGR1_ALL);
  201. SET_BIT(GTZC_TZSC->SECCFGR2, TZSC_SECCFGR2_ALL);
  202. }
  203. else if ((PeriphAttributes & GTZC_TZSC_PERIPH_NSEC) == GTZC_TZSC_PERIPH_NSEC)
  204. {
  205. CLEAR_BIT(GTZC_TZSC->SECCFGR1, TZSC_SECCFGR1_ALL);
  206. CLEAR_BIT(GTZC_TZSC->SECCFGR2, TZSC_SECCFGR2_ALL);
  207. }
  208. else
  209. {
  210. /* do nothing */
  211. }
  212. #endif /* defined(__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */
  213. /* privilege configuration */
  214. if ((PeriphAttributes & GTZC_TZSC_PERIPH_PRIV) == GTZC_TZSC_PERIPH_PRIV)
  215. {
  216. SET_BIT(GTZC_TZSC->PRIVCFGR1, TZSC_PRIVCFGR1_ALL);
  217. SET_BIT(GTZC_TZSC->PRIVCFGR2, TZSC_PRIVCFGR2_ALL);
  218. }
  219. else if ((PeriphAttributes & GTZC_TZSC_PERIPH_NPRIV) == GTZC_TZSC_PERIPH_NPRIV)
  220. {
  221. CLEAR_BIT(GTZC_TZSC->PRIVCFGR1, TZSC_PRIVCFGR1_ALL);
  222. CLEAR_BIT(GTZC_TZSC->PRIVCFGR2, TZSC_PRIVCFGR2_ALL);
  223. }
  224. else
  225. {
  226. /* do nothing */
  227. }
  228. }
  229. else
  230. {
  231. /* common case where only one peripheral is configured */
  232. #if defined(__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  233. /* secure configuration */
  234. register_address = (uint32_t) &(GTZC_TZSC->SECCFGR1) + (4U * GTZC_GET_REG_INDEX(PeriphId));
  235. if ((PeriphAttributes & GTZC_TZSC_PERIPH_SEC) == GTZC_TZSC_PERIPH_SEC)
  236. {
  237. SET_BIT(*(__IO uint32_t *)register_address, 1UL << GTZC_GET_PERIPH_POS(PeriphId));
  238. }
  239. else if ((PeriphAttributes & GTZC_TZSC_PERIPH_NSEC) == GTZC_TZSC_PERIPH_NSEC)
  240. {
  241. CLEAR_BIT(*(__IO uint32_t *)register_address, 1UL << GTZC_GET_PERIPH_POS(PeriphId));
  242. }
  243. else
  244. {
  245. /* do nothing */
  246. }
  247. #endif /* defined(__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */
  248. /* privilege configuration */
  249. register_address = (uint32_t) &(GTZC_TZSC->PRIVCFGR1) + (4U * GTZC_GET_REG_INDEX(PeriphId));
  250. if ((PeriphAttributes & GTZC_TZSC_PERIPH_PRIV) == GTZC_TZSC_PERIPH_PRIV)
  251. {
  252. SET_BIT(*(__IO uint32_t *)register_address, 1UL << GTZC_GET_PERIPH_POS(PeriphId));
  253. }
  254. else if ((PeriphAttributes & GTZC_TZSC_PERIPH_NPRIV) == GTZC_TZSC_PERIPH_NPRIV)
  255. {
  256. CLEAR_BIT(*(__IO uint32_t *)register_address, 1UL << GTZC_GET_PERIPH_POS(PeriphId));
  257. }
  258. else
  259. {
  260. /* do nothing */
  261. }
  262. }
  263. return HAL_OK;
  264. }
  265. /**
  266. * @brief Get TZSC configuration on a single peripheral or on all peripherals.
  267. * @param PeriphId Peripheral identifier.
  268. * This parameter can be a value of @ref GTZC_TZSC_TZIC_PeriphId.
  269. * Use GTZC_PERIPH_ALL to select all peripherals.
  270. * @param PeriphAttributes Peripheral attribute pointer.
  271. * This parameter can be a value of @ref GTZC_TZSC_PeriphAttributes.
  272. * If PeriphId target a single peripheral, pointer on a single element.
  273. * If all peripherals selected (GTZC_PERIPH_ALL), pointer to an array of
  274. * GTZC_TZSC_PERIPH_NUMBER elements is to be provided.
  275. * @retval HAL status.
  276. */
  277. HAL_StatusTypeDef HAL_GTZC_TZSC_GetConfigPeriphAttributes(uint32_t PeriphId,
  278. uint32_t *PeriphAttributes)
  279. {
  280. uint32_t i;
  281. uint32_t reg_value;
  282. uint32_t register_address;
  283. /* check entry parameters */
  284. if ((PeriphAttributes == NULL)
  285. || (HAL_GTZC_GET_ARRAY_INDEX(PeriphId) >= GTZC_TZSC_PERIPH_NUMBER)
  286. || (((PeriphId & GTZC_PERIPH_ALL) != 0U) && (HAL_GTZC_GET_ARRAY_INDEX(PeriphId) != 0U)))
  287. {
  288. return HAL_ERROR;
  289. }
  290. if ((PeriphId & GTZC_PERIPH_ALL) != 0U)
  291. {
  292. /* get secure configuration: read each register and deploy each bit value
  293. * of corresponding index in the destination array
  294. */
  295. reg_value = READ_REG(GTZC_TZSC->SECCFGR1);
  296. for (i = 0U; i < 32U; i++)
  297. {
  298. if (((reg_value & (1UL << i)) >> i) != 0U)
  299. {
  300. PeriphAttributes[i] = GTZC_TZSC_PERIPH_SEC;
  301. }
  302. else
  303. {
  304. PeriphAttributes[i] = GTZC_TZSC_PERIPH_NSEC;
  305. }
  306. }
  307. reg_value = READ_REG(GTZC_TZSC->SECCFGR2);
  308. for (/*i = 32U*/; i < GTZC_TZSC_PERIPH_NUMBER; i++)
  309. {
  310. if (((reg_value & (1UL << (i - 32U))) >> (i - 32U)) != 0U)
  311. {
  312. PeriphAttributes[i] = GTZC_TZSC_PERIPH_SEC;
  313. }
  314. else
  315. {
  316. PeriphAttributes[i] = GTZC_TZSC_PERIPH_NSEC;
  317. }
  318. }
  319. /* get privilege configuration: read each register and deploy each bit value
  320. * of corresponding index in the destination array
  321. */
  322. reg_value = READ_REG(GTZC_TZSC->PRIVCFGR1);
  323. for (i = 0U; i < 32U; i++)
  324. {
  325. if (((reg_value & (1UL << i)) >> i) != 0U)
  326. {
  327. PeriphAttributes[i] |= GTZC_TZSC_PERIPH_PRIV;
  328. }
  329. else
  330. {
  331. PeriphAttributes[i] |= GTZC_TZSC_PERIPH_NPRIV;
  332. }
  333. }
  334. reg_value = READ_REG(GTZC_TZSC->PRIVCFGR2);
  335. for (/*i = 32U*/; i < GTZC_TZSC_PERIPH_NUMBER; i++)
  336. {
  337. if (((reg_value & (1UL << (i - 32U))) >> (i - 32U)) != 0U)
  338. {
  339. PeriphAttributes[i] |= GTZC_TZSC_PERIPH_PRIV;
  340. }
  341. else
  342. {
  343. PeriphAttributes[i] |= GTZC_TZSC_PERIPH_NPRIV;
  344. }
  345. }
  346. }
  347. else
  348. {
  349. /* common case where only one peripheral is configured */
  350. /* secure configuration */
  351. register_address = (uint32_t) &(GTZC_TZSC->SECCFGR1) + (4U * GTZC_GET_REG_INDEX(PeriphId));
  352. if (((READ_BIT(*(__IO uint32_t *)register_address,
  353. 1UL << GTZC_GET_PERIPH_POS(PeriphId))) >> GTZC_GET_PERIPH_POS(PeriphId))
  354. != 0U)
  355. {
  356. *PeriphAttributes = GTZC_TZSC_PERIPH_SEC;
  357. }
  358. else
  359. {
  360. *PeriphAttributes = GTZC_TZSC_PERIPH_NSEC;
  361. }
  362. /* privilege configuration */
  363. register_address = (uint32_t) &(GTZC_TZSC->PRIVCFGR1) + (4U * GTZC_GET_REG_INDEX(PeriphId));
  364. if (((READ_BIT(*(__IO uint32_t *)register_address,
  365. 1UL << GTZC_GET_PERIPH_POS(PeriphId))) >> GTZC_GET_PERIPH_POS(PeriphId))
  366. != 0U)
  367. {
  368. *PeriphAttributes |= GTZC_TZSC_PERIPH_PRIV;
  369. }
  370. else
  371. {
  372. *PeriphAttributes |= GTZC_TZSC_PERIPH_NPRIV;
  373. }
  374. }
  375. return HAL_OK;
  376. }
  377. /**
  378. * @}
  379. */
  380. #if defined(__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  381. /** @defgroup GTZC_Exported_Functions_Group2 MPCWM Configuration functions
  382. * @brief MPCWM Configuration functions
  383. *
  384. @verbatim
  385. ==============================================================================
  386. ##### MPCWM Configuration functions #####
  387. ==============================================================================
  388. [..]
  389. This section provides functions allowing to configure MPCWM
  390. MPCWM is Memory Protection Controller WaterMark
  391. @endverbatim
  392. * @{
  393. */
  394. /**
  395. * @brief Configure a TZSC-MPCWM area.
  396. * @param MemBaseAddress WM identifier.
  397. * @param pMPCWM_Desc TZSC-MPCWM descriptor pointer.
  398. * The structure description is available in @ref GTZC_Exported_Types.
  399. * @retval HAL status.
  400. */
  401. HAL_StatusTypeDef HAL_GTZC_TZSC_MPCWM_ConfigMemAttributes(uint32_t MemBaseAddress,
  402. const MPCWM_ConfigTypeDef *pMPCWM_Desc)
  403. {
  404. uint32_t register_address;
  405. uint32_t reg_value;
  406. uint32_t size;
  407. uint32_t start_pos, start_msk;
  408. uint32_t length_pos, length_msk;
  409. /* check entry parameters */
  410. if ((pMPCWM_Desc->AreaId > GTZC_TZSC_MPCWM_ID2)
  411. || ((MemBaseAddress == FMC_BANK3) && (pMPCWM_Desc->AreaId == GTZC_TZSC_MPCWM_ID2))
  412. || ((pMPCWM_Desc->Offset % GTZC_TZSC_MPCWM_GRANULARITY) != 0U)
  413. || ((pMPCWM_Desc->Length % GTZC_TZSC_MPCWM_GRANULARITY) != 0U))
  414. {
  415. return HAL_ERROR;
  416. }
  417. /* check descriptor content vs. memory capacity */
  418. switch (MemBaseAddress)
  419. {
  420. case OCTOSPI1_BASE:
  421. size = GTZC_TZSC_MPCWM1_MEM_SIZE;
  422. if (pMPCWM_Desc->AreaId == GTZC_TZSC_MPCWM_ID1)
  423. {
  424. register_address = (uint32_t) &(GTZC_TZSC_S->MPCWM1_NSWMR1);
  425. start_pos = GTZC_TZSC_MPCWM1_NSWMR1_NSWM1STRT_Pos;
  426. start_msk = GTZC_TZSC_MPCWM1_NSWMR1_NSWM1STRT_Msk;
  427. length_pos = GTZC_TZSC_MPCWM1_NSWMR1_NSWM1LGTH_Pos;
  428. length_msk = GTZC_TZSC_MPCWM1_NSWMR1_NSWM1LGTH_Msk;
  429. }
  430. else
  431. {
  432. /* Here pMPCWM_Desc->AreaId == GTZC_TZSC_MPCWM_ID2
  433. * (Parameter already checked)
  434. */
  435. register_address = (uint32_t) &(GTZC_TZSC_S->MPCWM1_NSWMR2);
  436. start_pos = GTZC_TZSC_MPCWM1_NSWMR2_NSWM2STRT_Pos;
  437. start_msk = GTZC_TZSC_MPCWM1_NSWMR2_NSWM2STRT_Msk;
  438. length_pos = GTZC_TZSC_MPCWM1_NSWMR2_NSWM2LGTH_Pos;
  439. length_msk = GTZC_TZSC_MPCWM1_NSWMR2_NSWM2LGTH_Msk;
  440. }
  441. break;
  442. case FMC_BANK1:
  443. size = GTZC_TZSC_MPCWM1_MEM_SIZE;
  444. if (pMPCWM_Desc->AreaId == GTZC_TZSC_MPCWM_ID1)
  445. {
  446. register_address = (uint32_t) &(GTZC_TZSC_S->MPCWM2_NSWMR1);
  447. start_pos = GTZC_TZSC_MPCWM2_NSWMR1_NSWM1STRT_Pos;
  448. start_msk = GTZC_TZSC_MPCWM2_NSWMR1_NSWM1STRT_Msk;
  449. length_pos = GTZC_TZSC_MPCWM2_NSWMR1_NSWM1LGTH_Pos;
  450. length_msk = GTZC_TZSC_MPCWM2_NSWMR1_NSWM1LGTH_Msk;
  451. }
  452. else
  453. {
  454. /* Here pMPCWM_Desc->AreaId == GTZC_TZSC_MPCWM_ID2
  455. * (Parameter already checked)
  456. */
  457. register_address = (uint32_t) &(GTZC_TZSC_S->MPCWM2_NSWMR2);
  458. start_pos = GTZC_TZSC_MPCWM2_NSWMR2_NSWM2STRT_Pos;
  459. start_msk = GTZC_TZSC_MPCWM2_NSWMR2_NSWM2STRT_Msk;
  460. length_pos = GTZC_TZSC_MPCWM2_NSWMR2_NSWM2LGTH_Pos;
  461. length_msk = GTZC_TZSC_MPCWM2_NSWMR2_NSWM2LGTH_Msk;
  462. }
  463. break;
  464. case FMC_BANK3:
  465. /* Here pMPCWM_Desc->AreaId == GTZC_TZSC_MPCWM_ID1
  466. * (Parameter already checked)
  467. */
  468. size = GTZC_TZSC_MPCWM3_MEM_SIZE;
  469. register_address = (uint32_t) &(GTZC_TZSC_S->MPCWM3_NSWMR1);
  470. start_pos = GTZC_TZSC_MPCWM3_NSWMR1_NSWM1STRT_Pos;
  471. start_msk = GTZC_TZSC_MPCWM3_NSWMR1_NSWM1STRT_Msk;
  472. length_pos = GTZC_TZSC_MPCWM3_NSWMR1_NSWM1LGTH_Pos;
  473. length_msk = GTZC_TZSC_MPCWM3_NSWMR1_NSWM1LGTH_Msk;
  474. break;
  475. default:
  476. return HAL_ERROR;
  477. break;
  478. }
  479. if ((pMPCWM_Desc->Offset > size)
  480. || ((pMPCWM_Desc->Offset + pMPCWM_Desc->Length) > size))
  481. {
  482. return HAL_ERROR;
  483. }
  484. /* write descriptor value */
  485. reg_value = ((pMPCWM_Desc->Offset / GTZC_TZSC_MPCWM_GRANULARITY) << start_pos) & start_msk;
  486. reg_value |= ((pMPCWM_Desc->Length / GTZC_TZSC_MPCWM_GRANULARITY) << length_pos) & length_msk;
  487. MODIFY_REG(*(__IO uint32_t *)register_address, start_msk | length_msk, reg_value);
  488. return HAL_OK;
  489. }
  490. /**
  491. * @brief Get a TZSC-MPCWM area configuration.
  492. * @param MemBaseAddress WM identifier.
  493. * @param pMPCWM_Desc pointer to a TZSC-MPCWM descriptor.
  494. * The structure description is available in @ref GTZC_Exported_Types.
  495. * @retval HAL status.
  496. */
  497. HAL_StatusTypeDef HAL_GTZC_TZSC_MPCWM_GetConfigMemAttributes(uint32_t MemBaseAddress,
  498. MPCWM_ConfigTypeDef *pMPCWM_Desc)
  499. {
  500. uint32_t register_address;
  501. uint32_t reg_value;
  502. uint32_t start_pos, start_msk;
  503. uint32_t length_pos, length_msk;
  504. /* firstly take care of the first area, present on all MPCWM sub-blocks */
  505. switch (MemBaseAddress)
  506. {
  507. case OCTOSPI1_BASE:
  508. register_address = (uint32_t) &(GTZC_TZSC_S->MPCWM1_NSWMR1);
  509. start_pos = GTZC_TZSC_MPCWM1_NSWMR1_NSWM1STRT_Pos;
  510. start_msk = GTZC_TZSC_MPCWM1_NSWMR1_NSWM1STRT_Msk;
  511. length_pos = GTZC_TZSC_MPCWM1_NSWMR1_NSWM1LGTH_Pos;
  512. length_msk = GTZC_TZSC_MPCWM1_NSWMR1_NSWM1LGTH_Msk;
  513. break;
  514. case FMC_BANK1:
  515. register_address = (uint32_t) &(GTZC_TZSC_S->MPCWM2_NSWMR1);
  516. start_pos = GTZC_TZSC_MPCWM2_NSWMR1_NSWM1STRT_Pos;
  517. start_msk = GTZC_TZSC_MPCWM2_NSWMR1_NSWM1STRT_Msk;
  518. length_pos = GTZC_TZSC_MPCWM2_NSWMR1_NSWM1LGTH_Pos;
  519. length_msk = GTZC_TZSC_MPCWM2_NSWMR1_NSWM1LGTH_Msk;
  520. break;
  521. case FMC_BANK3:
  522. register_address = (uint32_t) &(GTZC_TZSC_S->MPCWM3_NSWMR1);
  523. start_pos = GTZC_TZSC_MPCWM3_NSWMR1_NSWM1STRT_Pos;
  524. start_msk = GTZC_TZSC_MPCWM3_NSWMR1_NSWM1STRT_Msk;
  525. length_pos = GTZC_TZSC_MPCWM3_NSWMR1_NSWM1LGTH_Pos;
  526. length_msk = GTZC_TZSC_MPCWM3_NSWMR1_NSWM1LGTH_Msk;
  527. break;
  528. default:
  529. return HAL_ERROR;
  530. break;
  531. }
  532. /* read register and update the descriptor for first area*/
  533. reg_value = READ_REG(*(__IO uint32_t *)register_address);
  534. pMPCWM_Desc[0].AreaId = GTZC_TZSC_MPCWM_ID1;
  535. pMPCWM_Desc[0].Offset = ((reg_value & start_msk) >> start_pos) * GTZC_TZSC_MPCWM_GRANULARITY;
  536. pMPCWM_Desc[0].Length = ((reg_value & length_msk) >> length_pos) * GTZC_TZSC_MPCWM_GRANULARITY;
  537. if (MemBaseAddress != FMC_BANK3)
  538. {
  539. /* Here MemBaseAddress = OCTOSPI1_BASE
  540. * or FMC_BANK1 (already tested)
  541. * Now take care of the second area, present on these sub-blocks
  542. */
  543. switch (MemBaseAddress)
  544. {
  545. case OCTOSPI1_BASE:
  546. register_address = (uint32_t) &(GTZC_TZSC_S->MPCWM1_NSWMR2);
  547. start_pos = GTZC_TZSC_MPCWM1_NSWMR2_NSWM2STRT_Pos;
  548. start_msk = GTZC_TZSC_MPCWM1_NSWMR2_NSWM2STRT_Msk;
  549. length_pos = GTZC_TZSC_MPCWM1_NSWMR2_NSWM2LGTH_Pos;
  550. length_msk = GTZC_TZSC_MPCWM1_NSWMR2_NSWM2LGTH_Msk;
  551. break;
  552. case FMC_BANK1:
  553. register_address = (uint32_t) &(GTZC_TZSC_S->MPCWM2_NSWMR2);
  554. start_pos = GTZC_TZSC_MPCWM2_NSWMR2_NSWM2STRT_Pos;
  555. start_msk = GTZC_TZSC_MPCWM2_NSWMR2_NSWM2STRT_Msk;
  556. length_pos = GTZC_TZSC_MPCWM2_NSWMR2_NSWM2LGTH_Pos;
  557. length_msk = GTZC_TZSC_MPCWM2_NSWMR2_NSWM2LGTH_Msk;
  558. break;
  559. default:
  560. return HAL_ERROR;
  561. break;
  562. }
  563. /* read register and update the descriptor for second area*/
  564. reg_value = READ_REG(*(__IO uint32_t *)register_address);
  565. pMPCWM_Desc[1].AreaId = GTZC_TZSC_MPCWM_ID2;
  566. pMPCWM_Desc[1].Offset = ((reg_value & start_msk) >> start_pos) * GTZC_TZSC_MPCWM_GRANULARITY;
  567. pMPCWM_Desc[1].Length = ((reg_value & length_msk) >> length_pos) * GTZC_TZSC_MPCWM_GRANULARITY;
  568. }
  569. return HAL_OK;
  570. }
  571. /**
  572. * @}
  573. */
  574. #endif /* defined(__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */
  575. /** @defgroup GTZC_Exported_Functions_Group3 TZSC and TZSC-MPCWM Lock functions
  576. * @brief TZSC and TZSC-MPCWM Lock functions
  577. *
  578. @verbatim
  579. ==============================================================================
  580. ##### TZSC and TZSC-MPCWM Lock functions #####
  581. ==============================================================================
  582. [..]
  583. This section provides functions allowing to manage the common TZSC and
  584. TZSC-MPCWM lock. It includes lock enable, and current value read.
  585. TZSC is TrustZone Security Controller
  586. MPCWM is Memory Protection Controller WaterMark
  587. @endverbatim
  588. * @{
  589. */
  590. /**
  591. * @brief Lock TZSC and TZSC-MPCWM configuration.
  592. * @param TZSC_Instance TZSC sub-block instance.
  593. */
  594. #if defined(__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  595. void HAL_GTZC_TZSC_Lock(GTZC_TZSC_TypeDef *TZSC_Instance)
  596. {
  597. SET_BIT(TZSC_Instance->CR, GTZC_TZSC_CR_LCK_Msk);
  598. }
  599. #endif /* defined(__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */
  600. /**
  601. * @brief Get TZSC and TZSC-MPCWM configuration lock state.
  602. * @param TZSC_Instance TZSC sub-block instance.
  603. * @retval Lock State (GTZC_TZSC_LOCK_OFF or GTZC_TZSC_LOCK_ON)
  604. */
  605. uint32_t HAL_GTZC_TZSC_GetLock(const GTZC_TZSC_TypeDef *TZSC_Instance)
  606. {
  607. return READ_BIT(TZSC_Instance->CR, GTZC_TZSC_CR_LCK_Msk);
  608. }
  609. /**
  610. * @}
  611. */
  612. #if defined(__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  613. /** @defgroup GTZC_Exported_Functions_Group4 MPCBB Configuration functions
  614. * @brief MPCBB Configuration functions
  615. *
  616. @verbatim
  617. ==============================================================================
  618. ##### MPCBB Configuration functions #####
  619. ==============================================================================
  620. [..]
  621. This section provides functions allowing to configure MPCBB
  622. MPCBB is Memory Protection Controller Block Base
  623. @endverbatim
  624. * @{
  625. */
  626. /**
  627. * @brief Set a complete MPCBB configuration on the SRAM passed as parameter.
  628. * @param MemBaseAddress MPCBB identifier.
  629. * @param pMPCBB_desc pointer to MPCBB descriptor.
  630. * The structure description is available in @ref GTZC_Exported_Types.
  631. * @retval HAL status.
  632. */
  633. HAL_StatusTypeDef HAL_GTZC_MPCBB_ConfigMem(uint32_t MemBaseAddress,
  634. const MPCBB_ConfigTypeDef *pMPCBB_desc)
  635. {
  636. GTZC_MPCBB_TypeDef *mpcbb_ptr;
  637. uint32_t reg_value;
  638. uint32_t mem_size;
  639. uint32_t size_mask;
  640. uint32_t size_in_superblocks;
  641. uint32_t i;
  642. /* check entry parameters */
  643. if ((!(IS_GTZC_BASE_ADDRESS(SRAM1, MemBaseAddress))
  644. && !(IS_GTZC_BASE_ADDRESS(SRAM2, MemBaseAddress)))
  645. || ((pMPCBB_desc->SecureRWIllegalMode != GTZC_MPCBB_SRWILADIS_ENABLE)
  646. && (pMPCBB_desc->SecureRWIllegalMode != GTZC_MPCBB_SRWILADIS_DISABLE))
  647. || ((pMPCBB_desc->InvertSecureState != GTZC_MPCBB_INVSECSTATE_NOT_INVERTED)
  648. && (pMPCBB_desc->InvertSecureState != GTZC_MPCBB_INVSECSTATE_INVERTED)))
  649. {
  650. return HAL_ERROR;
  651. }
  652. /* write InvertSecureState and SecureRWIllegalMode properties */
  653. /* assume their Position/Mask is identical for all sub-blocks */
  654. reg_value = pMPCBB_desc->InvertSecureState;
  655. reg_value |= pMPCBB_desc->SecureRWIllegalMode;
  656. if (IS_GTZC_BASE_ADDRESS(SRAM1, MemBaseAddress))
  657. {
  658. mpcbb_ptr = GTZC_MPCBB1_S;
  659. mem_size = GTZC_MEM_SIZE(SRAM1);
  660. }
  661. else
  662. {
  663. /* Here MemBaseAddress is inside SRAM2 (already tested) */
  664. mpcbb_ptr = GTZC_MPCBB2_S;
  665. mem_size = GTZC_MEM_SIZE(SRAM2);
  666. }
  667. /* write vector register information */
  668. size_in_superblocks = (mem_size / GTZC_MPCBB_SUPERBLOCK_SIZE);
  669. for (i = 0U; i < size_in_superblocks; i++)
  670. {
  671. WRITE_REG(mpcbb_ptr->VCTR[i],
  672. pMPCBB_desc->AttributeConfig.MPCBB_SecConfig_array[i]);
  673. }
  674. /* write configuration and lock register information */
  675. MODIFY_REG(mpcbb_ptr->CR,
  676. GTZC_MPCBB_CR_INVSECSTATE_Msk | GTZC_MPCBB_CR_SRWILADIS_Msk, reg_value);
  677. size_mask = (1UL << (mem_size / GTZC_MPCBB_SUPERBLOCK_SIZE)) - 1U;
  678. /* limitation: code not portable with memory > 256K */
  679. MODIFY_REG(mpcbb_ptr->LCKVTR1, size_mask, pMPCBB_desc->AttributeConfig.MPCBB_LockConfig_array[0]);
  680. return HAL_OK;
  681. }
  682. /**
  683. * @brief Get a complete MPCBB configuration on the SRAM passed as parameter.
  684. * @param MemBaseAddress MPCBB identifier.
  685. * @param pMPCBB_desc pointer to a MPCBB descriptor.
  686. * The structure description is available in @ref GTZC_Exported_Types.
  687. * @retval HAL status.
  688. */
  689. HAL_StatusTypeDef HAL_GTZC_MPCBB_GetConfigMem(uint32_t MemBaseAddress,
  690. MPCBB_ConfigTypeDef *pMPCBB_desc)
  691. {
  692. GTZC_MPCBB_TypeDef *mpcbb_ptr;
  693. uint32_t reg_value;
  694. uint32_t mem_size;
  695. uint32_t size_mask;
  696. uint32_t size_in_superblocks;
  697. uint32_t i;
  698. /* check entry parameters */
  699. if (!(IS_GTZC_BASE_ADDRESS(SRAM1, MemBaseAddress))
  700. && !(IS_GTZC_BASE_ADDRESS(SRAM2, MemBaseAddress)))
  701. {
  702. return HAL_ERROR;
  703. }
  704. /* read InvertSecureState and SecureRWIllegalMode properties */
  705. /* assume their Position/Mask is identical for all sub-blocks */
  706. if (IS_GTZC_BASE_ADDRESS(SRAM1, MemBaseAddress))
  707. {
  708. mpcbb_ptr = GTZC_MPCBB1_S;
  709. mem_size = GTZC_MEM_SIZE(SRAM1);
  710. }
  711. else
  712. {
  713. mpcbb_ptr = GTZC_MPCBB2_S;
  714. mem_size = GTZC_MEM_SIZE(SRAM2);
  715. }
  716. /* read configuration and lock register information */
  717. reg_value = READ_REG(mpcbb_ptr->CR);
  718. pMPCBB_desc->InvertSecureState = (reg_value & GTZC_MPCBB_CR_INVSECSTATE_Msk);
  719. pMPCBB_desc->SecureRWIllegalMode = (reg_value & GTZC_MPCBB_CR_SRWILADIS_Msk);
  720. size_mask = (1UL << (mem_size / GTZC_MPCBB_SUPERBLOCK_SIZE)) - 1U;
  721. /* limitation: code not portable with memory > 256K */
  722. pMPCBB_desc->AttributeConfig.MPCBB_LockConfig_array[0] = READ_REG(mpcbb_ptr->LCKVTR1)& size_mask;
  723. /* read vector register information */
  724. size_in_superblocks = (mem_size / GTZC_MPCBB_SUPERBLOCK_SIZE);
  725. for (i = 0U; i < size_in_superblocks; i++)
  726. {
  727. pMPCBB_desc->AttributeConfig.MPCBB_SecConfig_array[i] = mpcbb_ptr->VCTR[i];
  728. }
  729. return HAL_OK;
  730. }
  731. /**
  732. * @brief Set a MPCBB attribute configuration on the SRAM passed as parameter
  733. * for a number of blocks.
  734. * @param MemAddress MPCBB identifier, and start block to configure
  735. * (must be 256 Bytes aligned).
  736. * @param NbBlocks Number of blocks to configure.
  737. * @param pMemAttributes pointer to an array (containing "NbBlocks" elements),
  738. * with each element must be GTZC_MCPBB_BLOCK_NSEC or GTZC_MCPBB_BLOCK_SEC.
  739. * @retval HAL status.
  740. */
  741. HAL_StatusTypeDef HAL_GTZC_MPCBB_ConfigMemAttributes(uint32_t MemAddress,
  742. uint32_t NbBlocks,
  743. const uint32_t *pMemAttributes)
  744. {
  745. GTZC_MPCBB_TypeDef *mpcbb_ptr;
  746. uint32_t base_address, end_address;
  747. uint32_t block_start, offset_reg_start, offset_bit_start;
  748. uint32_t i;
  749. /* firstly check that MemAddress is well 256 Bytes aligned */
  750. if ((MemAddress % GTZC_MPCBB_BLOCK_SIZE) != 0U)
  751. {
  752. return HAL_ERROR;
  753. }
  754. /* check entry parameters and deduce physical base address */
  755. end_address = MemAddress + (NbBlocks * GTZC_MPCBB_BLOCK_SIZE) - 1U;
  756. if (((IS_ADDRESS_IN_NS(SRAM1, MemAddress))
  757. && (IS_ADDRESS_IN_NS(SRAM1, end_address))) != 0U)
  758. {
  759. mpcbb_ptr = GTZC_MPCBB1_S;
  760. base_address = SRAM1_BASE_NS;
  761. }
  762. else if (((IS_ADDRESS_IN_S(SRAM1, MemAddress))
  763. && (IS_ADDRESS_IN_S(SRAM1, end_address))) != 0U)
  764. {
  765. mpcbb_ptr = GTZC_MPCBB1_S;
  766. base_address = SRAM1_BASE_S;
  767. }
  768. else if (((IS_ADDRESS_IN_NS(SRAM2, MemAddress))
  769. && (IS_ADDRESS_IN_NS(SRAM2, end_address))) != 0U)
  770. {
  771. mpcbb_ptr = GTZC_MPCBB2_S;
  772. base_address = SRAM2_BASE_NS;
  773. }
  774. else if (((IS_ADDRESS_IN_S(SRAM2, MemAddress))
  775. && (IS_ADDRESS_IN_S(SRAM2, end_address))) != 0U)
  776. {
  777. mpcbb_ptr = GTZC_MPCBB2_S;
  778. base_address = SRAM2_BASE_S;
  779. }
  780. else
  781. {
  782. return HAL_ERROR;
  783. }
  784. /* get start coordinates of the configuration */
  785. block_start = (MemAddress - base_address) / GTZC_MPCBB_BLOCK_SIZE;
  786. offset_reg_start = block_start / 32U;
  787. offset_bit_start = block_start % 32U;
  788. for (i = 0U; i < NbBlocks; i++)
  789. {
  790. if (pMemAttributes[i] == GTZC_MCPBB_BLOCK_SEC)
  791. {
  792. SET_BIT(mpcbb_ptr->VCTR[offset_reg_start],
  793. 1UL << (offset_bit_start % 32U));
  794. }
  795. else if (pMemAttributes[i] == GTZC_MCPBB_BLOCK_NSEC)
  796. {
  797. CLEAR_BIT(mpcbb_ptr->VCTR[offset_reg_start],
  798. 1UL << (offset_bit_start % 32U));
  799. }
  800. else
  801. {
  802. break;
  803. }
  804. offset_bit_start++;
  805. if (offset_bit_start == 32U)
  806. {
  807. offset_bit_start = 0U;
  808. offset_reg_start++;
  809. }
  810. }
  811. /* an unexpected value in pMemAttributes array leads to error status */
  812. if (i != NbBlocks)
  813. {
  814. return HAL_ERROR;
  815. }
  816. return HAL_OK;
  817. }
  818. /**
  819. * @brief Get a MPCBB attribute configuration on the SRAM passed as parameter
  820. * for a number of blocks.
  821. * @param MemAddress MPCBB identifier, and start block to get configuration
  822. * (must be 256 Bytes aligned).
  823. * @param NbBlocks Number of blocks to get configuration.
  824. * @param pMemAttributes pointer to an array (containing "NbBlocks" elements),
  825. * with each element will be GTZC_MCPBB_BLOCK_NSEC or GTZC_MCPBB_BLOCK_SEC.
  826. * @retval HAL status.
  827. */
  828. HAL_StatusTypeDef HAL_GTZC_MPCBB_GetConfigMemAttributes(uint32_t MemAddress,
  829. uint32_t NbBlocks,
  830. uint32_t *pMemAttributes)
  831. {
  832. GTZC_MPCBB_TypeDef *mpcbb_ptr;
  833. uint32_t base_address, end_address;
  834. uint32_t block_start, offset_reg_start, offset_bit_start;
  835. uint32_t i;
  836. /* firstly check that MemAddress is well 256 Bytes aligned */
  837. if ((MemAddress % GTZC_MPCBB_BLOCK_SIZE) != 0U)
  838. {
  839. return HAL_ERROR;
  840. }
  841. /* check entry parameters and deduce physical base address */
  842. end_address = MemAddress + (NbBlocks * GTZC_MPCBB_BLOCK_SIZE) - 1U;
  843. if ((IS_ADDRESS_IN_NS(SRAM1, MemAddress))
  844. && (IS_ADDRESS_IN_NS(SRAM1, end_address)))
  845. {
  846. mpcbb_ptr = GTZC_MPCBB1_S;
  847. base_address = SRAM1_BASE_NS;
  848. }
  849. else if ((IS_ADDRESS_IN_S(SRAM1, MemAddress))
  850. && (IS_ADDRESS_IN_S(SRAM1, end_address)))
  851. {
  852. mpcbb_ptr = GTZC_MPCBB1_S;
  853. base_address = SRAM1_BASE_S;
  854. }
  855. else if ((IS_ADDRESS_IN_NS(SRAM2, MemAddress))
  856. && (IS_ADDRESS_IN_NS(SRAM2, end_address)))
  857. {
  858. mpcbb_ptr = GTZC_MPCBB2_S;
  859. base_address = SRAM2_BASE_NS;
  860. }
  861. else if ((IS_ADDRESS_IN_S(SRAM2, MemAddress))
  862. && (IS_ADDRESS_IN_S(SRAM2, end_address)))
  863. {
  864. mpcbb_ptr = GTZC_MPCBB2_S;
  865. base_address = SRAM2_BASE_S;
  866. }
  867. else
  868. {
  869. return HAL_ERROR;
  870. }
  871. /* get start coordinates of the configuration */
  872. block_start = (MemAddress - base_address) / GTZC_MPCBB_BLOCK_SIZE;
  873. offset_reg_start = block_start / 32U;
  874. offset_bit_start = block_start % 32U;
  875. for (i = 0U; i < NbBlocks; i++)
  876. {
  877. pMemAttributes[i] = READ_BIT(mpcbb_ptr->VCTR[offset_reg_start],
  878. 1UL << (offset_bit_start % 32U))
  879. >> (offset_bit_start % 32U);
  880. offset_bit_start++;
  881. if (offset_bit_start == 32U)
  882. {
  883. offset_bit_start = 0U;
  884. offset_reg_start++;
  885. }
  886. }
  887. return HAL_OK;
  888. }
  889. /**
  890. * @brief Lock MPCBB super-blocks on the SRAM passed as parameter.
  891. * @param MemAddress MPCBB identifier, and start super-block to configure
  892. * (must be 8KBytes aligned).
  893. * @param NbSuperBlocks Number of super-blocks to configure.
  894. * @param pLockAttributes pointer to an array (containing "NbSuperBlocks" elements),
  895. * with for each element:
  896. * value 0 super-block is unlocked, value 1 super-block is locked
  897. * (corresponds to GTZC_MCPBB_SUPERBLOCK_UNLOCKED and
  898. * GTZC_MCPBB_SUPERBLOCK_LOCKED values).
  899. * @retval HAL status.
  900. */
  901. HAL_StatusTypeDef HAL_GTZC_MPCBB_LockConfig(uint32_t MemAddress,
  902. uint32_t NbSuperBlocks,
  903. const uint32_t *pLockAttributes)
  904. {
  905. __IO uint32_t *reg_mpcbb;
  906. uint32_t base_address;
  907. uint32_t superblock_start, offset_bit_start;
  908. uint32_t i;
  909. /* firstly check that MemAddress is well 8KBytes aligned */
  910. if ((MemAddress % GTZC_MPCBB_SUPERBLOCK_SIZE) != 0U)
  911. {
  912. return HAL_ERROR;
  913. }
  914. /* check entry parameters */
  915. if ((IS_ADDRESS_IN(SRAM1, MemAddress))
  916. && (IS_ADDRESS_IN(SRAM1, (MemAddress
  917. + (NbSuperBlocks * GTZC_MPCBB_SUPERBLOCK_SIZE)
  918. - 1U))))
  919. {
  920. base_address = GTZC_BASE_ADDRESS(SRAM1);
  921. /* limitation: code not portable with memory > 256K */
  922. reg_mpcbb = (__IO uint32_t *)&GTZC_MPCBB1_S->LCKVTR1;
  923. }
  924. else if ((IS_ADDRESS_IN(SRAM2, MemAddress))
  925. && (IS_ADDRESS_IN(SRAM2, (MemAddress
  926. + (NbSuperBlocks * GTZC_MPCBB_SUPERBLOCK_SIZE)
  927. - 1U))))
  928. {
  929. base_address = GTZC_BASE_ADDRESS(SRAM2);
  930. /* limitation: code not portable with memory > 256K */
  931. reg_mpcbb = (__IO uint32_t *)&GTZC_MPCBB2_S->LCKVTR1;
  932. }
  933. else
  934. {
  935. return HAL_ERROR;
  936. }
  937. /* get start coordinates of the configuration */
  938. superblock_start = (MemAddress - base_address) / GTZC_MPCBB_SUPERBLOCK_SIZE;
  939. offset_bit_start = superblock_start % 32U;
  940. for (i = 0U; i < NbSuperBlocks; i++)
  941. {
  942. if (pLockAttributes[i] == GTZC_MCPBB_SUPERBLOCK_LOCKED)
  943. {
  944. SET_BIT(*reg_mpcbb, 1UL << (offset_bit_start % 32U));
  945. }
  946. else if (pLockAttributes[i] == GTZC_MCPBB_SUPERBLOCK_UNLOCKED)
  947. {
  948. CLEAR_BIT(*reg_mpcbb, 1UL << (offset_bit_start % 32U));
  949. }
  950. else
  951. {
  952. break;
  953. }
  954. offset_bit_start++;
  955. }
  956. /* an unexpected value in pLockAttributes array leads to an error status */
  957. if (i != NbSuperBlocks)
  958. {
  959. return HAL_ERROR;
  960. }
  961. return HAL_OK;
  962. }
  963. /**
  964. * @brief Get MPCBB super-blocks lock configuration on the SRAM passed as parameter.
  965. * @param MemAddress MPCBB identifier, and start super-block to get
  966. * configuration (must be 8KBytes aligned).
  967. * @param NbSuperBlocks Number of super-blocks to get configuration.
  968. * @param pLockAttributes pointer to an array (size is NbSuperBlocks),
  969. * with for each element:
  970. * value 0 super-block is unlocked, value 1 super-block is locked
  971. * (corresponds to GTZC_MCPBB_SUPERBLOCK_UNLOCKED and
  972. * GTZC_MCPBB_SUPERBLOCK_LOCKED values).
  973. * @retval HAL status.
  974. */
  975. HAL_StatusTypeDef HAL_GTZC_MPCBB_GetLockConfig(uint32_t MemAddress,
  976. uint32_t NbSuperBlocks,
  977. uint32_t *pLockAttributes)
  978. {
  979. uint32_t reg_mpcbb;
  980. uint32_t base_address;
  981. uint32_t superblock_start, offset_bit_start;
  982. uint32_t i;
  983. /* firstly check that MemAddress is well 8KBytes aligned */
  984. if ((MemAddress % GTZC_MPCBB_SUPERBLOCK_SIZE) != 0U)
  985. {
  986. return HAL_ERROR;
  987. }
  988. /* check entry parameters */
  989. if ((IS_ADDRESS_IN(SRAM1, MemAddress))
  990. && (IS_ADDRESS_IN(SRAM1, (MemAddress
  991. + (NbSuperBlocks * GTZC_MPCBB_SUPERBLOCK_SIZE)
  992. - 1U))))
  993. {
  994. base_address = GTZC_BASE_ADDRESS(SRAM1);
  995. /* limitation: code not portable with memory > 256K */
  996. reg_mpcbb = GTZC_MPCBB1_S->LCKVTR1;
  997. }
  998. else if ((IS_ADDRESS_IN(SRAM2, MemAddress))
  999. && (IS_ADDRESS_IN(SRAM2, (MemAddress
  1000. + (NbSuperBlocks * GTZC_MPCBB_SUPERBLOCK_SIZE)
  1001. - 1U))))
  1002. {
  1003. base_address = GTZC_BASE_ADDRESS(SRAM2);
  1004. /* limitation: code not portable with memory > 256K */
  1005. reg_mpcbb = GTZC_MPCBB2_S->LCKVTR1;
  1006. }
  1007. else
  1008. {
  1009. return HAL_ERROR;
  1010. }
  1011. /* get start coordinates of the configuration */
  1012. superblock_start = (MemAddress - base_address) / GTZC_MPCBB_SUPERBLOCK_SIZE;
  1013. offset_bit_start = superblock_start % 32U;
  1014. for (i = 0U; i < NbSuperBlocks; i++)
  1015. {
  1016. pLockAttributes[i] = (reg_mpcbb & (1UL << (offset_bit_start % 32U)))
  1017. >> (offset_bit_start % 32U);
  1018. offset_bit_start++;
  1019. }
  1020. return HAL_OK;
  1021. }
  1022. /**
  1023. * @brief Lock a MPCBB configuration on the SRAM base address passed as parameter.
  1024. * @param MemBaseAddress MPCBB identifier.
  1025. * @retval HAL status.
  1026. */
  1027. HAL_StatusTypeDef HAL_GTZC_MPCBB_Lock(uint32_t MemBaseAddress)
  1028. {
  1029. /* check entry parameters */
  1030. if (IS_GTZC_BASE_ADDRESS(SRAM1, MemBaseAddress))
  1031. {
  1032. SET_BIT(GTZC_MPCBB1_S->CR, GTZC_MPCBB_CR_LCK_Msk);
  1033. }
  1034. else if (IS_GTZC_BASE_ADDRESS(SRAM2, MemBaseAddress))
  1035. {
  1036. SET_BIT(GTZC_MPCBB2_S->CR, GTZC_MPCBB_CR_LCK_Msk);
  1037. }
  1038. else
  1039. {
  1040. return HAL_ERROR;
  1041. }
  1042. return HAL_OK;
  1043. }
  1044. /**
  1045. * @brief Get MPCBB configuration lock state on the SRAM base address passed as parameter.
  1046. * @param MemBaseAddress MPCBB identifier.
  1047. * @param pLockState pointer to Lock State (GTZC_MCPBB_LOCK_OFF or GTZC_MCPBB_LOCK_ON).
  1048. * @retval HAL status.
  1049. */
  1050. HAL_StatusTypeDef HAL_GTZC_MPCBB_GetLock(uint32_t MemBaseAddress,
  1051. uint32_t *pLockState)
  1052. {
  1053. /* check entry parameters */
  1054. if (IS_GTZC_BASE_ADDRESS(SRAM1, MemBaseAddress))
  1055. {
  1056. *pLockState = READ_BIT(GTZC_MPCBB1_S->CR, GTZC_MPCBB_CR_LCK_Msk);
  1057. }
  1058. else if (IS_GTZC_BASE_ADDRESS(SRAM2, MemBaseAddress))
  1059. {
  1060. *pLockState = READ_BIT(GTZC_MPCBB2_S->CR, GTZC_MPCBB_CR_LCK_Msk);
  1061. }
  1062. else
  1063. {
  1064. return HAL_ERROR;
  1065. }
  1066. return HAL_OK;
  1067. }
  1068. /**
  1069. * @}
  1070. */
  1071. /** @defgroup GTZC_Exported_Functions_Group5 TZIC Configuration and Control functions
  1072. * @brief TZIC Configuration and Control functions
  1073. *
  1074. @verbatim
  1075. ==============================================================================
  1076. ##### TZIC Configuration and Control functions #####
  1077. ==============================================================================
  1078. [..]
  1079. This section provides functions allowing to configure and control TZIC
  1080. TZIC is Trust Zone Interrupt Controller
  1081. @endverbatim
  1082. * @{
  1083. */
  1084. /**
  1085. * @brief Disable the interrupt associated to a single TZIC peripheral or on all peripherals.
  1086. * @param PeriphId Peripheral identifier.
  1087. * This parameter can be a value of @ref GTZC_TZSC_TZIC_PeriphId.
  1088. * Use GTZC_PERIPH_ALL to select all peripherals.
  1089. * @retval HAL status.
  1090. */
  1091. HAL_StatusTypeDef HAL_GTZC_TZIC_DisableIT(uint32_t PeriphId)
  1092. {
  1093. uint32_t register_address;
  1094. /* check entry parameters */
  1095. if ((HAL_GTZC_GET_ARRAY_INDEX(PeriphId) >= GTZC_TZIC_PERIPH_NUMBER)
  1096. || (((PeriphId & GTZC_PERIPH_ALL) != 0U) && (HAL_GTZC_GET_ARRAY_INDEX(PeriphId) != 0U)))
  1097. {
  1098. return HAL_ERROR;
  1099. }
  1100. if ((PeriphId & GTZC_PERIPH_ALL) != 0U)
  1101. {
  1102. /* same configuration is applied to all peripherals */
  1103. WRITE_REG(GTZC_TZIC->IER1, 0U);
  1104. WRITE_REG(GTZC_TZIC->IER2, 0U);
  1105. WRITE_REG(GTZC_TZIC->IER3, 0U);
  1106. }
  1107. else
  1108. {
  1109. /* common case where only one peripheral is configured */
  1110. register_address = (uint32_t) &(GTZC_TZIC->IER1) + (4U * GTZC_GET_REG_INDEX(PeriphId));
  1111. CLEAR_BIT(*(__IO uint32_t *)register_address, 1UL << GTZC_GET_PERIPH_POS(PeriphId));
  1112. }
  1113. return HAL_OK;
  1114. }
  1115. /**
  1116. * @brief Enable the interrupt associated to a single TZIC peripheral or on all peripherals.
  1117. * @param PeriphId Peripheral identifier.
  1118. * This parameter can be a value of @ref GTZC_TZSC_TZIC_PeriphId.
  1119. * Use GTZC_PERIPH_ALL to select all peripherals.
  1120. * @retval HAL status.
  1121. */
  1122. HAL_StatusTypeDef HAL_GTZC_TZIC_EnableIT(uint32_t PeriphId)
  1123. {
  1124. uint32_t register_address;
  1125. /* check entry parameters */
  1126. if ((HAL_GTZC_GET_ARRAY_INDEX(PeriphId) >= GTZC_TZIC_PERIPH_NUMBER)
  1127. || (((PeriphId & GTZC_PERIPH_ALL) != 0U) && (HAL_GTZC_GET_ARRAY_INDEX(PeriphId) != 0U)))
  1128. {
  1129. return HAL_ERROR;
  1130. }
  1131. if ((PeriphId & GTZC_PERIPH_ALL) != 0U)
  1132. {
  1133. /* same configuration is applied to all peripherals */
  1134. WRITE_REG(GTZC_TZIC->IER1, TZIC_IER1_ALL);
  1135. WRITE_REG(GTZC_TZIC->IER2, TZIC_IER2_ALL);
  1136. WRITE_REG(GTZC_TZIC->IER3, TZIC_IER3_ALL);
  1137. }
  1138. else
  1139. {
  1140. /* common case where only one peripheral is configured */
  1141. register_address = (uint32_t) &(GTZC_TZIC->IER1) + (4U * GTZC_GET_REG_INDEX(PeriphId));
  1142. SET_BIT(*(__IO uint32_t *)register_address, 1UL << GTZC_GET_PERIPH_POS(PeriphId));
  1143. }
  1144. return HAL_OK;
  1145. }
  1146. /**
  1147. * @brief Get TZIC flag on a single TZIC peripheral or on all peripherals.
  1148. * @param PeriphId Peripheral identifier.
  1149. * This parameter can be a value of @ref GTZC_TZSC_TZIC_PeriphId.
  1150. * Use GTZC_PERIPH_ALL to select all peripherals.
  1151. * @param pFlag Pointer to the flags.
  1152. * If PeriphId target a single peripheral, pointer on a single element.
  1153. * If all peripherals selected (GTZC_PERIPH_ALL), pointer to an array
  1154. * of GTZC_TZIC_PERIPH_NUMBER elements.
  1155. * Element content is either GTZC_TZIC_NO_ILA_EVENT
  1156. * or GTZC_TZSC_ILA_EVENT_PENDING.
  1157. * @retval HAL status
  1158. */
  1159. HAL_StatusTypeDef HAL_GTZC_TZIC_GetFlag(uint32_t PeriphId, uint32_t *pFlag)
  1160. {
  1161. uint32_t i;
  1162. uint32_t reg_value;
  1163. uint32_t register_address;
  1164. /* check entry parameters */
  1165. if ((HAL_GTZC_GET_ARRAY_INDEX(PeriphId) >= GTZC_TZIC_PERIPH_NUMBER)
  1166. || (((PeriphId & GTZC_PERIPH_ALL) != 0U) && (HAL_GTZC_GET_ARRAY_INDEX(PeriphId) != 0U)))
  1167. {
  1168. return HAL_ERROR;
  1169. }
  1170. if ((PeriphId & GTZC_PERIPH_ALL) != 0U)
  1171. {
  1172. /* special case where it is applied to all peripherals */
  1173. reg_value = READ_REG(GTZC_TZIC->SR1);
  1174. for (i = 0U; i < 32U; i++)
  1175. {
  1176. pFlag[i] = (reg_value & (1UL << i)) >> i;
  1177. }
  1178. reg_value = READ_REG(GTZC_TZIC->SR2);
  1179. for (/*i = 32U*/; i < 64U; i++)
  1180. {
  1181. pFlag[i] = (reg_value & (1UL << (i - 32U))) >> (i - 32U);
  1182. }
  1183. reg_value = READ_REG(GTZC_TZIC->SR3);
  1184. for (/*i = 64U*/; i < GTZC_TZIC_PERIPH_NUMBER; i++)
  1185. {
  1186. pFlag[i] = (reg_value & (1UL << (i - 64U))) >> (i - 64U);
  1187. }
  1188. }
  1189. else
  1190. {
  1191. /* common case where only one peripheral is concerned */
  1192. register_address = (uint32_t) &(GTZC_TZIC->SR1) + (4U * GTZC_GET_REG_INDEX(PeriphId));
  1193. *pFlag = READ_BIT(*(__IO uint32_t *)register_address,
  1194. 1UL << GTZC_GET_PERIPH_POS(PeriphId)) >> GTZC_GET_PERIPH_POS(PeriphId);
  1195. }
  1196. return HAL_OK;
  1197. }
  1198. /**
  1199. * @brief Clear TZIC flag on a single TZIC peripheral or on all peripherals.
  1200. * @param PeriphId Peripheral identifier.
  1201. * This parameter can be a value of @ref GTZC_TZSC_TZIC_PeriphId.
  1202. * Use GTZC_PERIPH_ALL to select all peripherals.
  1203. * @retval HAL status.
  1204. */
  1205. HAL_StatusTypeDef HAL_GTZC_TZIC_ClearFlag(uint32_t PeriphId)
  1206. {
  1207. uint32_t register_address;
  1208. /* check entry parameters */
  1209. if ((HAL_GTZC_GET_ARRAY_INDEX(PeriphId) >= GTZC_TZIC_PERIPH_NUMBER)
  1210. || (((PeriphId & GTZC_PERIPH_ALL) != 0U) && (HAL_GTZC_GET_ARRAY_INDEX(PeriphId) != 0U)))
  1211. {
  1212. return HAL_ERROR;
  1213. }
  1214. if ((PeriphId & GTZC_PERIPH_ALL) != 0U)
  1215. {
  1216. /* same configuration is applied to all peripherals */
  1217. WRITE_REG(GTZC_TZIC->FCR1, TZIC_FCR1_ALL);
  1218. WRITE_REG(GTZC_TZIC->FCR2, TZIC_FCR2_ALL);
  1219. WRITE_REG(GTZC_TZIC->FCR3, TZIC_FCR3_ALL);
  1220. }
  1221. else
  1222. {
  1223. /* common case where only one peripheral is configured */
  1224. register_address = (uint32_t) &(GTZC_TZIC->FCR1) + (4U * GTZC_GET_REG_INDEX(PeriphId));
  1225. SET_BIT(*(__IO uint32_t *)register_address, 1UL << GTZC_GET_PERIPH_POS(PeriphId));
  1226. }
  1227. return HAL_OK;
  1228. }
  1229. /**
  1230. * @}
  1231. */
  1232. /** @defgroup GTZC_Exported_Functions_Group6 IRQ related functions
  1233. * @brief IRQ related functions
  1234. *
  1235. @verbatim
  1236. ==============================================================================
  1237. ##### TZIC IRQ Handler and Callback functions #####
  1238. ==============================================================================
  1239. [..]
  1240. This section provides functions allowing to treat ISR and provide user callback
  1241. @endverbatim
  1242. * @{
  1243. */
  1244. /**
  1245. * @brief This function handles GTZC interrupt request.
  1246. * @retval None.
  1247. */
  1248. void HAL_GTZC_IRQHandler(void)
  1249. {
  1250. uint32_t position;
  1251. uint32_t flag;
  1252. uint32_t ier_itsources;
  1253. uint32_t sr_flags;
  1254. /* Get current IT Flags and IT sources value on 1st register */
  1255. ier_itsources = READ_REG(GTZC_TZIC->IER1);
  1256. sr_flags = READ_REG(GTZC_TZIC->SR1);
  1257. /* Get Mask interrupt and then clear them */
  1258. flag = ier_itsources & sr_flags;
  1259. if (flag != 0U)
  1260. {
  1261. WRITE_REG(GTZC_TZIC->FCR1, flag);
  1262. /* Loop on flag to check, which ones have been raised */
  1263. position = 0U;
  1264. while ((flag >> position) != 0U)
  1265. {
  1266. if ((flag & (1UL << position)) != 0U)
  1267. {
  1268. HAL_GTZC_TZIC_Callback(GTZC_PERIPH_REG1 | position);
  1269. }
  1270. /* Position bit to be updated */
  1271. position++;
  1272. }
  1273. }
  1274. /* Get current IT Flags and IT sources value on 2nd register */
  1275. ier_itsources = READ_REG(GTZC_TZIC->IER2);
  1276. sr_flags = READ_REG(GTZC_TZIC->SR2);
  1277. /* Get Mask interrupt and then clear them */
  1278. flag = ier_itsources & sr_flags;
  1279. if (flag != 0U)
  1280. {
  1281. WRITE_REG(GTZC_TZIC->FCR2, flag);
  1282. /* Loop on flag to check, which ones have been raised */
  1283. position = 0U;
  1284. while ((flag >> position) != 0U)
  1285. {
  1286. if ((flag & (1UL << position)) != 0U)
  1287. {
  1288. HAL_GTZC_TZIC_Callback(GTZC_PERIPH_REG2 | position);
  1289. }
  1290. /* Position bit to be updated */
  1291. position++;
  1292. }
  1293. }
  1294. /* Get current IT Flags and IT sources value on 3rd register */
  1295. ier_itsources = READ_REG(GTZC_TZIC->IER3);
  1296. sr_flags = READ_REG(GTZC_TZIC->SR3);
  1297. /* Get Mask interrupt and then clear them */
  1298. flag = ier_itsources & sr_flags;
  1299. if (flag != 0U)
  1300. {
  1301. WRITE_REG(GTZC_TZIC->FCR3, flag);
  1302. /* Loop on flag to check, which ones have been raised */
  1303. position = 0U;
  1304. while ((flag >> position) != 0U)
  1305. {
  1306. if ((flag & (1UL << position)) != 0U)
  1307. {
  1308. HAL_GTZC_TZIC_Callback(GTZC_PERIPH_REG3 | position);
  1309. }
  1310. /* Position bit to be updated */
  1311. position++;
  1312. }
  1313. }
  1314. }
  1315. /**
  1316. * @brief GTZC TZIC sub-block interrupt callback.
  1317. * @param PeriphId Peripheral identifier triggering the illegal access.
  1318. * This parameter can be a value of @ref GTZC_TZSC_TZIC_PeriphId
  1319. * @retval None.
  1320. */
  1321. __weak void HAL_GTZC_TZIC_Callback(uint32_t PeriphId)
  1322. {
  1323. /* Prevent unused argument(s) compilation warning */
  1324. UNUSED(PeriphId);
  1325. /* NOTE: This function should not be modified. When the callback is needed,
  1326. * the HAL_GTZC_TZIC_Callback is to be implemented in the user file
  1327. */
  1328. }
  1329. /**
  1330. * @}
  1331. */
  1332. #endif /* defined(__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */
  1333. /**
  1334. * @}
  1335. */
  1336. #endif /*HAL_GTZC_MODULE_ENABLED*/
  1337. /**
  1338. * @}
  1339. */
  1340. /**
  1341. * @}
  1342. */