1 /**
2   ******************************************************************************
3   * @file    stm32h7rsxx_hal_mce.h
4   * @author  MCD Application Team
5   * @brief   Header file of MCE HAL module.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2022 STMicroelectronics.
10   * All rights reserved.
11   *
12   * This software is licensed under terms that can be found in the LICENSE file
13   * in the root directory of this software component.
14   * If no LICENSE file comes with this software, it is provided AS-IS.
15   *
16   ******************************************************************************
17   */
18 
19 /* Define to prevent recursive inclusion -------------------------------------*/
20 #ifndef STM32H7RSxx_HAL_MCE_H
21 #define STM32H7RSxx_HAL_MCE_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32h7rsxx_hal_def.h"
29 
30 /** @addtogroup STM32H7RSxx_HAL_Driver
31   * @{
32   */
33 
34 #if defined(MCE1)
35 /** @addtogroup MCE
36   * @{
37   */
38 typedef struct
39 {
40   uint32_t         ContextID;              /*!< MCE region context ID (can be null) */
41   /*!< This parameter is a value of @ref MCE_Context_Index. */
42 
43   uint32_t         StartAddress;           /*!< MCE region start address */
44 
45   uint32_t         EndAddress;             /*!< MCE region end address */
46 
47   uint32_t         Mode;                   /*!< Indicates the chaining mode used for encryption. */
48   /*!< This parameter is a value of @defgroup MCE_Ciphering_Algorithm */
49   uint32_t         AccessMode;             /*!< MCE region writes enabled or not */
50   /*!< This parameter is a value of @ref MCE_Region_Privilege. */
51 
52   uint32_t         PrivilegedAccess;       /*!< MCE region privileged access or not */
53   /*!< This parameter is a value of @ref MCE_Region_Privilege. */
54 
55 } MCE_RegionConfigTypeDef;
56 
57 typedef struct
58 {
59   uint32_t         Nonce[2];              /*!< MCE context nonce */
60 
61   uint32_t         Version;               /*!< 16-bit long MCE context version */
62 
63   uint32_t         *pKey;                  /*!< Pointer at the key used for encryption/decryption */
64 
65 } MCE_AESConfigTypeDef;
66 
67 typedef struct
68 {
69   uint32_t          KeyType;             /*!< This parameter is a value of @ref MCE_KeyType. */
70 
71   uint32_t          *pKey;                   /*!< Pointer at the key used for encryption/decryption .*/
72 
73 } MCE_NoekeonConfigTypeDef;
74 
75 
76 /**
77   * @brief MCE states structure definition
78   */
79 typedef enum
80 {
81   HAL_MCE_STATE_RESET             = 0x00U,  /*!< MCE not yet initialized or disabled */
82   HAL_MCE_STATE_READY             = 0x01U,  /*!< MCE initialized and ready for use   */
83   HAL_MCE_STATE_BUSY              = 0x02U,  /*!< MCE internal processing is ongoing  */
84 } HAL_MCE_StateTypeDef;
85 
86 #if (USE_HAL_MCE_REGISTER_CALLBACKS == 1)
87 typedef struct __MCE_HandleTypeDef
88 #else
89 typedef struct
90 #endif /* USE_HAL_MCE_REGISTER_CALLBACKS */
91 {
92   MCE_TypeDef             *Instance;        /*!< MCE registers base address */
93 
94   HAL_MCE_StateTypeDef    State;            /*!< MCE state */
95 
96   HAL_LockTypeDef         Lock;             /*!< MCE Locking object */
97 
98   __IO uint32_t           ErrorCode;        /*!< MCE error code */
99 
100 #if (USE_HAL_MCE_REGISTER_CALLBACKS == 1)
101   void (* ErrorCallback)(struct __MCE_HandleTypeDef *hmce);     /*!< MCE error callback */
102 
103   void (* MspInitCallback)(struct __MCE_HandleTypeDef *hmce);   /*!< MCE Msp Init callback */
104 
105   void (* MspDeInitCallback)(struct __MCE_HandleTypeDef *hmce); /*!< MCE Msp DeInit callback */
106 #endif /* USE_HAL_MCE_REGISTER_CALLBACKS */
107 
108 } MCE_HandleTypeDef;
109 
110 #if (USE_HAL_MCE_REGISTER_CALLBACKS == 1)
111 /**
112   * @brief  HAL MCE Callback ID enumeration definition
113   */
114 typedef enum
115 {
116   HAL_MCE_ERROR_CB_ID       = 0x00U,  /*!< MCE error callback ID      */
117   HAL_MCE_MSPINIT_CB_ID     = 0x01U,  /*!< MCE Msp DeInit callback ID */
118   HAL_MCE_MSPDEINIT_CB_ID   = 0x02U   /*!< MCE Msp DeInit callback ID */
119 } HAL_MCE_CallbackIDTypeDef;
120 
121 /**
122   * @brief  HAL MCE Callback pointer definition
123   */
124 typedef  void (*pMCE_CallbackTypeDef)(MCE_HandleTypeDef *hmce); /*!< pointer to a MCE callback function */
125 
126 #endif /* USE_HAL_MCE_REGISTER_CALLBACKS */
127 
128 /* Exported constants --------------------------------------------------------*/
129 /** @defgroup MCE_Exported_Constants MCE Exported Constants
130   * @{
131   */
132 
133 /** @defgroup MCE_Error_Definition   MCE Error Definition
134   * @{
135   */
136 #define  HAL_MCE_ERROR_NONE                       ((uint32_t)0x00000000U)    /*!< No error                                                         */
137 #define  HAL_MCE_CONFIGURATION_ACCESS_ERROR       ((uint32_t)0x00000001U)    /*!< Configuration access error                                       */
138 #define  HAL_MCE_ILLEGAL_ACCESS_READ_PRIV_ERROR   ((uint32_t)0x00000002U)    /*!< Illegal privileged data read or instruction fetch access error   */
139 #define  HAL_MCE_ILLEGAL_ACCESS_READ_NPRIV_ERROR  ((uint32_t)0x00000004U)    /*!< Illegal unprivileged data read or instruction fetch access error */
140 #define  HAL_MCE_ILLEGAL_ACCESS_WRITE_PRIV_ERROR  ((uint32_t)0x00000008U)    /*!< Illegal privileged data write access error                       */
141 #define  HAL_MCE_ILLEGAL_ACCESS_WRITE_NPRIV_ERROR ((uint32_t)0x00000010U)    /*!< Illegal un privileged data write access error                    */
142 #define  HAL_MCE_MASTER_KEY_ERROR                 ((uint32_t)0x00000020U)    /*!< Master key error                                                 */
143 #define  HAL_MCE_FASTMASTER_KEY_ERROR             ((uint32_t)0x00000040U)    /*!< Fast master key error                                            */
144 #define  HAL_MCE_CONTEXT_KEY_ERROR                ((uint32_t)0x00000080U)    /*!< Context key error                                                */
145 #if (USE_HAL_MCE_REGISTER_CALLBACKS == 1)
146 #define HAL_MCE_ERROR_INVALID_CALLBACK            ((uint32_t)0x00000100U)    /*!< Invalid Callback error                                           */
147 #endif /* USE_HAL_MCE_REGISTER_CALLBACKS */
148 /**
149   * @}
150   */
151 
152 /** @defgroup MCE_Interrupts    MCE Interrupts
153   * @{
154   */
155 #define MCE_IT_ILLEGAL_ACCESS_ERROR        MCE_IAIER_IAEIE                   /*!< Illegal access error interrupt       */
156 #define MCE_IT_CONFIGURATION_ACCESS_ERROR  MCE_IAIER_CAEIE                   /*!< Configuration access error interrupt */
157 #define MCE_IT_ALL                        (MCE_IAIER_IAEIE|MCE_IAIER_CAEIE)  /*!< All interrupts                       */
158 /**
159   * @}
160   */
161 
162 /** @defgroup MCE_Illegal_Access_Flags    MCE Illegal Access Flags
163   * @{
164   */
165 #define MCE_CONFIGURATION_ACCESS_ERROR     MCE_IASR_CAEF                      /*!< Configuration access error                                    */
166 #define MCE_ILLEGAL_ACCESS_READ_NPRIV      MCE_IASR_IAEF                      /*!< Illegal unprivileged data read/instruction fetch access flag   */
167 #define MCE_ILLEGAL_ACCESS_READ_PRIV       (MCE_IASR_IAEF | MCE_IAESR_IAPRIV) /*!< Illegal privileged data read/instruction fetch access flag     */
168 #define MCE_ILLEGAL_ACCESS_WRITE_NPRIV     (MCE_IASR_IAEF | MCE_IAESR_IANRW)  /*!< Illegal unprivileged write access access flag                 */
169 #define MCE_ILLEGAL_ACCESS_WRITE_PRIV      (MCE_IASR_IAEF | MCE_IAESR_IANRW | MCE_IAESR_IAPRIV) /*!< Illegal privileged write access access flag */
170 /**
171   * @}
172   */
173 
174 
175 /** @defgroup MCE_Regions_Index   MCE Regions Index
176   * @{
177   */
178 #define MCE_REGION1                       0U    /*!< MCE region 1 */
179 #define MCE_REGION2                       1U    /*!< MCE region 2 */
180 #define MCE_REGION3                       2U    /*!< MCE region 3 */
181 #define MCE_REGION4                       3U    /*!< MCE region 4 */
182 /**
183   * @}
184   */
185 
186 /** @defgroup MCE_Context_Index   MCE Context Index
187   * @{
188   */
189 #define MCE_NO_CONTEXT                    0U                /*!< MCE no context */
190 #define MCE_CONTEXT1                      MCE_REGCR_CTXID_0 /*!< MCE context 1  */
191 #define MCE_CONTEXT2                      MCE_REGCR_CTXID_1 /*!< MCE context 2  */
192 /**
193   * @}
194   */
195 
196 /** @defgroup MCE_Ciphering_Algorithm   MCE Ciphering Algorithm
197   * @{
198   */
199 #define MCE_NO_CIPHER                     0U               /*!< MCE no cipher         */
200 #define MCE_STREAM_CIPHER                 MCE_REGCR_ENC_0  /*!< MCE stream cipher     */
201 #define MCE_BLOCK_CIPHER                  MCE_REGCR_ENC_1  /*!< MCE block cipher      */
202 #define MCE_FASTBLOCK_CIPHER              MCE_REGCR_ENC    /*!< MCE fast block cipher */
203 /**
204   * @}
205   */
206 
207 
208 /** @defgroup MCE_Region_Privilege   MCE Region Privilege
209   * @{
210   */
211 #define MCE_REGION_NPRIV                  0U               /*!< Region non-privileged and privileged access */
212 #define MCE_REGION_PRIV                   MCE_REGCR_PRIV   /*!< Region privileged access only               */
213 /**
214   * @}
215   */
216 
217 
218 /** @defgroup MCE_Region_Privilege   MCE Region Privilege
219   * @{
220   */
221 #define MCE_REGION_READONLY               0U               /*!< Writes to region are ignored, reads are allowed */
222 #define MCE_REGION_READWRITE              MCE_ATTR_WREN    /*!< Region can be read and written                  */
223 /**
224   * @}
225   */
226 
227 /** @defgroup MCE_Configuration_Attributes   MCE Configuration Attributes
228   * @{
229   */
230 #define MCE_ATTRIBUTE_NPRIV               0U                /*!< Non-privileged access protection */
231 #define MCE_ATTRIBUTE_PRIV                MCE_PRIVCFGR_PRIV /*!< Privileged access protection     */
232 /**
233   * @}
234   */
235 
236 /** @defgroup MCE_Lock MCE Lock values
237   * @{
238   */
239 #define MCE_LOCK_OFF                      0U            /*!< No global lock set */
240 #define MCE_LOCK_ON                       MCE_CR_GLOCK  /*!< Global lock set    */
241 /**
242   * @}
243   */
244 
245 /** @defgroup MCE_Lock MCE Lock values
246   * @{
247   */
248 #define MCE_MASTERKEYS_LOCK_OFF           0U             /*!< No master keys lock set */
249 #define MCE_MASTERKEYS_LOCK_ON            MCE_CR_MKLOCK  /*!< Master keys lock set    */
250 /**
251   * @}
252   */
253 
254 /** @defgroup MCE_KeyType key type used for encryption, Master key or Fast Master key
255   * @{
256   */
257 #define MCE_USE_MASTERKEYS              0U             /*!< Master keys used for encryption         */
258 #define MCE_USE_FASTMASTERKEYS          1U             /*!< Fast Master keys used for encryption    */
259 /**
260   * @}
261   */
262 
263 /**
264   * @}
265   */
266 
267 /* Exported macro ------------------------------------------------------------*/
268 /** @defgroup MCE_Exported_Macros MCE Exported Macros
269   * @{
270   */
271 
272 /** @brief  Reset MCE handle state.
273   * @param  __HANDLE__ pointer to an MCE_HandleTypeDef structure that contains
274   *         the configuration information for MCE module
275   * @retval None
276   */
277 #if (USE_HAL_MCE_REGISTER_CALLBACKS == 1)
278 #define __HAL_MCE_RESET_HANDLE_STATE(__HANDLE__)                            \
279   do{                                                                       \
280     (__HANDLE__)->State = HAL_MCE_STATE_RESET;                              \
281     (__HANDLE__)->MspInitCallback = NULL;                                   \
282     (__HANDLE__)->MspDeInitCallback = NULL;                                 \
283   } while(0)
284 #else
285 #define __HAL_MCE_RESET_HANDLE_STATE(__HANDLE__)                            \
286   ((__HANDLE__)->State = HAL_MCE_STATE_RESET)
287 #endif /* USE_HAL_MCE_REGISTER_CALLBACKS */
288 
289 /**
290   * @brief  Enable MCE peripheral interrupts combination
291   * @param  __HANDLE__ pointer to an MCE_HandleTypeDef structure that contains
292   *         the configuration information for MCE module
293   * @param  __INTERRUPT__ mask on enabled interrupts
294   *          This parameter can be one of the following values:
295   *            @arg @ref MCE_IT_ILLEGAL_ACCESS_ERROR        MCE illegal access error interrupt
296   *            @arg @ref MCE_IT_CONFIGURATION_ACCESS_ERROR  MCE configuration access error interrupt
297   *            @arg @ref MCE_IT_ALL                         MCE all interrupts
298   * @retval None
299   */
300 #define __HAL_MCE_ENABLE_IT(__HANDLE__, __INTERRUPT__)  SET_BIT(((__HANDLE__)->Instance->IAIER), (__INTERRUPT__))
301 
302 /**
303   * @brief  Disable MCE peripheral interrupts combination
304   * @param  __HANDLE__ pointer to an MCE_HandleTypeDef structure that contains
305   *         the configuration information for MCE module
306   * @param  __INTERRUPT__ mask on disabled interrupts
307   *          This parameter can be one of the following values:
308   *            @arg @ref MCE_IT_ILLEGAL_ACCESS_ERROR        MCE illegal access error interrupt
309   *            @arg @ref MCE_IT_CONFIGURATION_ACCESS_ERROR  MCE configuration access error interrupt
310   *            @arg @ref MCE_IT_ALL                         MCE all interrupts
311   * @retval None
312   */
313 #define __HAL_MCE_DISABLE_IT(__HANDLE__, __INTERRUPT__)  CLEAR_BIT(((__HANDLE__)->Instance->IAIER), (__INTERRUPT__))
314 
315 
316 /**
317   * @brief  Get MCE peripheral access error flag
318   * @param  __HANDLE__ pointer to an MCE_HandleTypeDef structure that contains
319   *         the configuration information for MCE module
320   * @param  __FLAG__ access error flag to check
321   *          This parameter can be one of the following values:
322   *          @arg @ref MCE_CONFIGURATION_ACCESS_ERROR  MCE configuration access error flag
323   *          @arg @ref MCE_ILLEGAL_ACCESS_READ_NPRIV   MCE illegal unprivileged data read/instruction fetch access flag
324   *          @arg @ref MCE_ILLEGAL_ACCESS_READ_PRIV    MCE illegal privileged data read/instruction fetch access flag
325   *          @arg @ref MCE_ILLEGAL_ACCESS_WRITE_NPRIV  MCE illegal unprivileged write access access flag
326   *          @arg @ref MCE_ILLEGAL_ACCESS_WRITE_PRIV   MCE illegal privileged write access access flag
327   * @retval 0 (not set) or 1 (set)
328   */
329 #define __HAL_MCE_GET_FLAG(__HANDLE__, __FLAG__)  \
330   (((__FLAG__) == MCE_CONFIGURATION_ACCESS_ERROR) ? \
331    (READ_BIT((__HANDLE__)->Instance->IASR, MCE_IASR_CAEF) == MCE_IASR_CAEF) : \
332    ((READ_BIT((__HANDLE__)->Instance->IASR, MCE_IASR_IAEF) == MCE_IASR_IAEF) && \
333     (READ_BIT((__HANDLE__)->Instance->IAESR, ((__FLAG__) & ~MCE_IASR_IAEF)) == ((__FLAG__) & ~MCE_IASR_IAEF))))
334 
335 /**
336   * @brief  Clear MCE peripheral illegal/configuration access flag
337   * @param  __HANDLE__ pointer to an MCE_HandleTypeDef structure that contains
338   *         the configuration information for MCE module
339   * @param  __FLAG__ illegal access flag to check
340   *        This parameter can be one of the following values:
341   *          @arg @ref MCE_CONFIGURATION_ACCESS_ERROR  MCE configuration access error flag
342   *          @arg @ref MCE_ILLEGAL_ACCESS_READ_NPRIV   MCE illegal unprivileged data read/instruction fetch access flag
343   *          @arg @ref MCE_ILLEGAL_ACCESS_READ_PRIV    MCE illegal privileged data read/instruction fetch access flag
344   *          @arg @ref MCE_ILLEGAL_ACCESS_WRITE_NPRIV  MCE illegal unprivileged write access access flag
345   *          @arg @ref MCE_ILLEGAL_ACCESS_WRITE_PRIV   MCE illegal privileged write access access flag
346   * @retval 0 (not set) or 1 (set)
347   */
348 #define __HAL_MCE_CLEAR_FLAG(__HANDLE__, __FLAG__)  \
349   (((__FLAG__) == MCE_CONFIGURATION_ACCESS_ERROR) ? WRITE_REG(((__HANDLE__)->Instance->IACR), MCE_IACR_CAEF) : \
350    WRITE_REG(((__HANDLE__)->Instance->IACR), MCE_IACR_IAEF))
351 
352 
353 /**
354   * @}
355   */
356 
357 
358 /* Exported functions ---------------------------------------------------------*/
359 
360 
361 HAL_StatusTypeDef HAL_MCE_Init(MCE_HandleTypeDef *hmce);
362 HAL_StatusTypeDef HAL_MCE_DeInit(MCE_HandleTypeDef *hmce);
363 void HAL_MCE_MspInit(MCE_HandleTypeDef *hmce);
364 void HAL_MCE_MspDeInit(MCE_HandleTypeDef *hmce);
365 
366 
367 HAL_StatusTypeDef HAL_MCE_ConfigNoekeon(MCE_HandleTypeDef *hmce, const MCE_NoekeonConfigTypeDef *pConfig);
368 HAL_StatusTypeDef HAL_MCE_ConfigAESContext(MCE_HandleTypeDef *hmce, const MCE_AESConfigTypeDef  *AESConfig,
369                                            uint32_t ContextIndex);
370 HAL_StatusTypeDef HAL_MCE_ConfigRegion(MCE_HandleTypeDef *hmce, uint32_t RegionIndex,
371                                        const MCE_RegionConfigTypeDef *pConfig);
372 HAL_StatusTypeDef HAL_MCE_SetRegionAESContext(MCE_HandleTypeDef *hmce, uint32_t ContextIndex, uint32_t RegionIndex);
373 HAL_StatusTypeDef HAL_MCE_EnableAESContext(MCE_HandleTypeDef *hmce, uint32_t ContextIndex);
374 HAL_StatusTypeDef HAL_MCE_DisableAESContext(MCE_HandleTypeDef *hmce, uint32_t ContextIndex);
375 HAL_StatusTypeDef HAL_MCE_EnableRegion(MCE_HandleTypeDef *hmce, uint32_t RegionIndex);
376 HAL_StatusTypeDef HAL_MCE_DisableRegion(MCE_HandleTypeDef *hmce, uint32_t RegionIndex);
377 HAL_StatusTypeDef HAL_MCE_LockGlobalConfig(MCE_HandleTypeDef *hmce);
378 HAL_StatusTypeDef HAL_MCE_LockAESContextConfig(MCE_HandleTypeDef *hmce, uint32_t ContextIndex);
379 HAL_StatusTypeDef HAL_MCE_LockAESContextKey(MCE_HandleTypeDef *hmce, uint32_t ContextIndex);
380 HAL_StatusTypeDef HAL_MCE_LockNoekeonMasterKeys(MCE_HandleTypeDef *hmce);
381 HAL_StatusTypeDef HAL_MCE_LockNoekeonFastKeys(MCE_HandleTypeDef *hmce);
382 HAL_StatusTypeDef HAL_MCE_GetAESContextCRCKey(const MCE_HandleTypeDef *hmce, uint32_t *pCRCKey, uint32_t ContextIndex);
383 
384 
385 void HAL_MCE_IRQHandler(MCE_HandleTypeDef *hmce);
386 void HAL_MCE_ErrorCallback(MCE_HandleTypeDef *hmce);
387 
388 HAL_MCE_StateTypeDef HAL_MCE_GetState(MCE_HandleTypeDef const *hmce);
389 uint32_t HAL_MCE_GetError(MCE_HandleTypeDef const *hmce);
390 uint32_t HAL_MCE_KeyCRCComputation(const uint32_t *pKey);
391 
392 #define IS_MCE_INTERRUPT(__INTERRUPT__) (((__INTERRUPT__) == MCE_IT_ILLEGAL_ACCESS_ERROR)       || \
393                                          ((__INTERRUPT__) == MCE_IT_CONFIGURATION_ACCESS_ERROR) || \
394                                          ((__INTERRUPT__) == MCE_IT_ALL)  )
395 
396 /**
397   * @brief Verify the MCE region index.
398   * @param __INDEX__ MCE region index
399   * @retval SET (__INDEX__ is valid) or RESET (__INDEX__ is invalid)
400   */
401 #define IS_MCE_REGIONINDEX(__INDEX__) (((__INDEX__) == MCE_REGION1)     || \
402                                        ((__INDEX__) == MCE_REGION2)     || \
403                                        ((__INDEX__) == MCE_REGION3)     || \
404                                        ((__INDEX__) == MCE_REGION4))
405 
406 /**
407   * @brief Verify the MCE configuration attributes.
408   * @param __ATTRIBUTE__ MCE region index
409   * @retval SET (__ATTRIBUTE__ is valid) or RESET (__ATTRIBUTE__ is invalid)
410   */
411 #define IS_MCE_ATTRIBUTE(__ATTRIBUTE__) (((__ATTRIBUTE__) == MCE_ATTRIBUTE_PRIV)   || \
412                                          ((__ATTRIBUTE__) == MCE_ATTRIBUTE_NPRIV))
413 
414 /**
415   * @brief Verify the MCE region privilege attribute.
416   * @param __PRIVILEGED__ MCE region privilege attribute
417   * @retval SET (__PRIVILEGED__ is valid) or RESET (__PRIVILEGED__ is invalid)
418   */
419 #define IS_MCE_REGIONPRIVILEGED(__PRIVILEGED__) (((__PRIVILEGED__) == MCE_REGION_NPRIV)   || \
420                                                  ((__PRIVILEGED__) == MCE_REGION_PRIV))
421 
422 /**
423   * @brief Verify the MCE region write enable attribute.
424   * @param __WRITE__ MCE region write enable attribute
425   * @retval SET (__WRITE__ is valid) or RESET (__WRITE__ is invalid)
426   */
427 #define IS_MCE_WRITE(__WRITE__) (((__WRITE__) == MCE_REGION_READONLY)   || \
428                                  ((__WRITE__) == MCE_REGION_READWRITE))
429 
430 /**
431   * @brief Verify the MCE region context.
432   * @param __INSTANCE__ MCE instance
433   * @param __CONTEXT__ MCE region context
434   * @retval SET (__CONTEXT__ is valid) or RESET (__CONTEXT__ is invalid)
435   */
436 #define IS_MCE_CONTEXT(__INSTANCE__, __CONTEXT__) (((__INSTANCE__) == (MCE1)) ?           \
437                                                    (((__CONTEXT__) == MCE_NO_CONTEXT)   || \
438                                                     ((__CONTEXT__) == MCE_CONTEXT1)     || \
439                                                     ((__CONTEXT__) == MCE_CONTEXT2))     : \
440                                                    ((__CONTEXT__) == MCE_NO_CONTEXT))
441 
442 /**
443   * @brief Verify the MCE region algorithm.
444   * @param __INSTANCE__ MCE instance
445   * @param __ALGO__ MCE region context
446   * @retval SET (__ALGO__ is valid) or RESET (__ALGO__ is invalid)
447   */
448 #define IS_MCE_ALGORITHM(__INSTANCE__, __ALGO__) (((__INSTANCE__) == (MCE1)) ?             \
449                                                   (((__ALGO__) == MCE_NO_CIPHER)         || \
450                                                    ((__ALGO__) == MCE_STREAM_CIPHER)     || \
451                                                    ((__ALGO__) == MCE_BLOCK_CIPHER)      || \
452                                                    ((__ALGO__) == MCE_FASTBLOCK_CIPHER))  : \
453                                                   (((__ALGO__) == MCE_NO_CIPHER)         || \
454                                                    ((__ALGO__) == MCE_BLOCK_CIPHER)      || \
455                                                    ((__ALGO__) == MCE_FASTBLOCK_CIPHER)))
456 
457 
458 #endif /* MCE1 */
459 
460 /**
461   * @}
462   */
463 
464 /**
465   * @}
466   */
467 #ifdef __cplusplus
468 }
469 #endif
470 
471 #endif /* STM32H7RSxx_HAL_MCE_H */
472