TUKS MCU Introductory course / TUKS-COURSE-TIMER
Committer:
elmot
Date:
Fri Feb 24 21:13:56 2017 +0000
Revision:
1:d0dfbce63a89
Ready-to-copy

Who changed what in which revision?

UserRevisionLine numberNew contents of line
elmot 1:d0dfbce63a89 1 /**
elmot 1:d0dfbce63a89 2 ******************************************************************************
elmot 1:d0dfbce63a89 3 * @file stm32l4xx_hal_firewall.h
elmot 1:d0dfbce63a89 4 * @author MCD Application Team
elmot 1:d0dfbce63a89 5 * @version V1.5.1
elmot 1:d0dfbce63a89 6 * @date 31-May-2016
elmot 1:d0dfbce63a89 7 * @brief Header file of FIREWALL HAL module.
elmot 1:d0dfbce63a89 8 ******************************************************************************
elmot 1:d0dfbce63a89 9 * @attention
elmot 1:d0dfbce63a89 10 *
elmot 1:d0dfbce63a89 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
elmot 1:d0dfbce63a89 12 *
elmot 1:d0dfbce63a89 13 * Redistribution and use in source and binary forms, with or without modification,
elmot 1:d0dfbce63a89 14 * are permitted provided that the following conditions are met:
elmot 1:d0dfbce63a89 15 * 1. Redistributions of source code must retain the above copyright notice,
elmot 1:d0dfbce63a89 16 * this list of conditions and the following disclaimer.
elmot 1:d0dfbce63a89 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
elmot 1:d0dfbce63a89 18 * this list of conditions and the following disclaimer in the documentation
elmot 1:d0dfbce63a89 19 * and/or other materials provided with the distribution.
elmot 1:d0dfbce63a89 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
elmot 1:d0dfbce63a89 21 * may be used to endorse or promote products derived from this software
elmot 1:d0dfbce63a89 22 * without specific prior written permission.
elmot 1:d0dfbce63a89 23 *
elmot 1:d0dfbce63a89 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
elmot 1:d0dfbce63a89 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
elmot 1:d0dfbce63a89 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
elmot 1:d0dfbce63a89 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
elmot 1:d0dfbce63a89 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
elmot 1:d0dfbce63a89 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
elmot 1:d0dfbce63a89 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
elmot 1:d0dfbce63a89 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
elmot 1:d0dfbce63a89 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
elmot 1:d0dfbce63a89 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
elmot 1:d0dfbce63a89 34 *
elmot 1:d0dfbce63a89 35 ******************************************************************************
elmot 1:d0dfbce63a89 36 */
elmot 1:d0dfbce63a89 37
elmot 1:d0dfbce63a89 38 /* Define to prevent recursive inclusion -------------------------------------*/
elmot 1:d0dfbce63a89 39 #ifndef __STM32L4xx_HAL_FIREWALL_H
elmot 1:d0dfbce63a89 40 #define __STM32L4xx_HAL_FIREWALL_H
elmot 1:d0dfbce63a89 41
elmot 1:d0dfbce63a89 42 #ifdef __cplusplus
elmot 1:d0dfbce63a89 43 extern "C" {
elmot 1:d0dfbce63a89 44 #endif
elmot 1:d0dfbce63a89 45
elmot 1:d0dfbce63a89 46 /* Includes ------------------------------------------------------------------*/
elmot 1:d0dfbce63a89 47 #include "stm32l4xx_hal_def.h"
elmot 1:d0dfbce63a89 48
elmot 1:d0dfbce63a89 49 /** @addtogroup STM32L4xx_HAL_Driver
elmot 1:d0dfbce63a89 50 * @{
elmot 1:d0dfbce63a89 51 */
elmot 1:d0dfbce63a89 52
elmot 1:d0dfbce63a89 53 /** @addtogroup FIREWALL FIREWALL
elmot 1:d0dfbce63a89 54 * @{
elmot 1:d0dfbce63a89 55 */
elmot 1:d0dfbce63a89 56
elmot 1:d0dfbce63a89 57 /* Exported types ------------------------------------------------------------*/
elmot 1:d0dfbce63a89 58 /** @defgroup FIREWALL_Exported_Types FIREWALL Exported Types
elmot 1:d0dfbce63a89 59 * @{
elmot 1:d0dfbce63a89 60 */
elmot 1:d0dfbce63a89 61
elmot 1:d0dfbce63a89 62 /**
elmot 1:d0dfbce63a89 63 * @brief FIREWALL Initialization Structure definition
elmot 1:d0dfbce63a89 64 */
elmot 1:d0dfbce63a89 65 typedef struct
elmot 1:d0dfbce63a89 66 {
elmot 1:d0dfbce63a89 67 uint32_t CodeSegmentStartAddress; /*!< Protected code segment start address. This value is 24-bit long, the 8 LSB bits are
elmot 1:d0dfbce63a89 68 reserved and forced to 0 in order to allow a 256-byte granularity. */
elmot 1:d0dfbce63a89 69
elmot 1:d0dfbce63a89 70 uint32_t CodeSegmentLength; /*!< Protected code segment length in bytes. This value is 22-bit long, the 8 LSB bits are
elmot 1:d0dfbce63a89 71 reserved and forced to 0 for the length to be a multiple of 256 bytes. */
elmot 1:d0dfbce63a89 72
elmot 1:d0dfbce63a89 73 uint32_t NonVDataSegmentStartAddress; /*!< Protected non-volatile data segment start address. This value is 24-bit long, the 8 LSB
elmot 1:d0dfbce63a89 74 bits are reserved and forced to 0 in order to allow a 256-byte granularity. */
elmot 1:d0dfbce63a89 75
elmot 1:d0dfbce63a89 76 uint32_t NonVDataSegmentLength; /*!< Protected non-volatile data segment length in bytes. This value is 22-bit long, the 8 LSB
elmot 1:d0dfbce63a89 77 bits are reserved and forced to 0 for the length to be a multiple of 256 bytes. */
elmot 1:d0dfbce63a89 78
elmot 1:d0dfbce63a89 79 uint32_t VDataSegmentStartAddress; /*!< Protected volatile data segment start address. This value is 17-bit long, the 6 LSB bits
elmot 1:d0dfbce63a89 80 are reserved and forced to 0 in order to allow a 64-byte granularity. */
elmot 1:d0dfbce63a89 81
elmot 1:d0dfbce63a89 82 uint32_t VDataSegmentLength; /*!< Protected volatile data segment length in bytes. This value is 17-bit long, the 6 LSB
elmot 1:d0dfbce63a89 83 bits are reserved and forced to 0 for the length to be a multiple of 64 bytes. */
elmot 1:d0dfbce63a89 84
elmot 1:d0dfbce63a89 85 uint32_t VolatileDataExecution; /*!< Set VDE bit specifying whether or not the volatile data segment can be executed.
elmot 1:d0dfbce63a89 86 When VDS = 1 (set by parameter VolatileDataShared), VDE bit has no meaning.
elmot 1:d0dfbce63a89 87 This parameter can be a value of @ref FIREWALL_VolatileData_Executable */
elmot 1:d0dfbce63a89 88
elmot 1:d0dfbce63a89 89 uint32_t VolatileDataShared; /*!< Set VDS bit in specifying whether or not the volatile data segment can be shared with a
elmot 1:d0dfbce63a89 90 non-protected application code.
elmot 1:d0dfbce63a89 91 This parameter can be a value of @ref FIREWALL_VolatileData_Shared */
elmot 1:d0dfbce63a89 92
elmot 1:d0dfbce63a89 93 }FIREWALL_InitTypeDef;
elmot 1:d0dfbce63a89 94
elmot 1:d0dfbce63a89 95
elmot 1:d0dfbce63a89 96 /**
elmot 1:d0dfbce63a89 97 * @}
elmot 1:d0dfbce63a89 98 */
elmot 1:d0dfbce63a89 99
elmot 1:d0dfbce63a89 100
elmot 1:d0dfbce63a89 101 /* Exported constants --------------------------------------------------------*/
elmot 1:d0dfbce63a89 102 /** @defgroup FIREWALL_Exported_Constants FIREWALL Exported Constants
elmot 1:d0dfbce63a89 103 * @{
elmot 1:d0dfbce63a89 104 */
elmot 1:d0dfbce63a89 105
elmot 1:d0dfbce63a89 106 /** @defgroup FIREWALL_VolatileData_Executable FIREWALL volatile data segment execution status
elmot 1:d0dfbce63a89 107 * @{
elmot 1:d0dfbce63a89 108 */
elmot 1:d0dfbce63a89 109 #define FIREWALL_VOLATILEDATA_NOT_EXECUTABLE ((uint32_t)0x0000)
elmot 1:d0dfbce63a89 110 #define FIREWALL_VOLATILEDATA_EXECUTABLE ((uint32_t)FW_CR_VDE)
elmot 1:d0dfbce63a89 111 /**
elmot 1:d0dfbce63a89 112 * @}
elmot 1:d0dfbce63a89 113 */
elmot 1:d0dfbce63a89 114
elmot 1:d0dfbce63a89 115 /** @defgroup FIREWALL_VolatileData_Shared FIREWALL volatile data segment share status
elmot 1:d0dfbce63a89 116 * @{
elmot 1:d0dfbce63a89 117 */
elmot 1:d0dfbce63a89 118 #define FIREWALL_VOLATILEDATA_NOT_SHARED ((uint32_t)0x0000)
elmot 1:d0dfbce63a89 119 #define FIREWALL_VOLATILEDATA_SHARED ((uint32_t)FW_CR_VDS)
elmot 1:d0dfbce63a89 120 /**
elmot 1:d0dfbce63a89 121 * @}
elmot 1:d0dfbce63a89 122 */
elmot 1:d0dfbce63a89 123
elmot 1:d0dfbce63a89 124 /** @defgroup FIREWALL_Pre_Arm FIREWALL pre arm status
elmot 1:d0dfbce63a89 125 * @{
elmot 1:d0dfbce63a89 126 */
elmot 1:d0dfbce63a89 127 #define FIREWALL_PRE_ARM_RESET ((uint32_t)0x0000)
elmot 1:d0dfbce63a89 128 #define FIREWALL_PRE_ARM_SET ((uint32_t)FW_CR_FPA)
elmot 1:d0dfbce63a89 129
elmot 1:d0dfbce63a89 130 /**
elmot 1:d0dfbce63a89 131 * @}
elmot 1:d0dfbce63a89 132 */
elmot 1:d0dfbce63a89 133
elmot 1:d0dfbce63a89 134 /**
elmot 1:d0dfbce63a89 135 * @}
elmot 1:d0dfbce63a89 136 */
elmot 1:d0dfbce63a89 137
elmot 1:d0dfbce63a89 138 /* Private macros --------------------------------------------------------*/
elmot 1:d0dfbce63a89 139 /** @defgroup FIREWALL_Private_Macros FIREWALL Private Macros
elmot 1:d0dfbce63a89 140 * @{
elmot 1:d0dfbce63a89 141 */
elmot 1:d0dfbce63a89 142 #define IS_FIREWALL_CODE_SEGMENT_ADDRESS(ADDRESS) (((ADDRESS) >= FLASH_BASE) && ((ADDRESS) < (FLASH_BASE + FLASH_SIZE)))
elmot 1:d0dfbce63a89 143 #define IS_FIREWALL_CODE_SEGMENT_LENGTH(ADDRESS, LENGTH) (((ADDRESS) + (LENGTH)) <= (FLASH_BASE + FLASH_SIZE))
elmot 1:d0dfbce63a89 144
elmot 1:d0dfbce63a89 145 #define IS_FIREWALL_NONVOLATILEDATA_SEGMENT_ADDRESS(ADDRESS) (((ADDRESS) >= FLASH_BASE) && ((ADDRESS) < (FLASH_BASE + FLASH_SIZE)))
elmot 1:d0dfbce63a89 146 #define IS_FIREWALL_NONVOLATILEDATA_SEGMENT_LENGTH(ADDRESS, LENGTH) (((ADDRESS) + (LENGTH)) <= (FLASH_BASE + FLASH_SIZE))
elmot 1:d0dfbce63a89 147
elmot 1:d0dfbce63a89 148 #define IS_FIREWALL_VOLATILEDATA_SEGMENT_ADDRESS(ADDRESS) (((ADDRESS) >= SRAM1_BASE) && ((ADDRESS) < (SRAM1_BASE + SRAM1_SIZE_MAX)))
elmot 1:d0dfbce63a89 149 #define IS_FIREWALL_VOLATILEDATA_SEGMENT_LENGTH(ADDRESS, LENGTH) (((ADDRESS) + (LENGTH)) <= (SRAM1_BASE + SRAM1_SIZE_MAX))
elmot 1:d0dfbce63a89 150
elmot 1:d0dfbce63a89 151
elmot 1:d0dfbce63a89 152 #define IS_FIREWALL_VOLATILEDATA_SHARE(SHARE) (((SHARE) == FIREWALL_VOLATILEDATA_NOT_SHARED) || \
elmot 1:d0dfbce63a89 153 ((SHARE) == FIREWALL_VOLATILEDATA_SHARED))
elmot 1:d0dfbce63a89 154
elmot 1:d0dfbce63a89 155 #define IS_FIREWALL_VOLATILEDATA_EXECUTE(EXECUTE) (((EXECUTE) == FIREWALL_VOLATILEDATA_NOT_EXECUTABLE) || \
elmot 1:d0dfbce63a89 156 ((EXECUTE) == FIREWALL_VOLATILEDATA_EXECUTABLE))
elmot 1:d0dfbce63a89 157 /**
elmot 1:d0dfbce63a89 158 * @}
elmot 1:d0dfbce63a89 159 */
elmot 1:d0dfbce63a89 160
elmot 1:d0dfbce63a89 161
elmot 1:d0dfbce63a89 162 /* Exported macros -----------------------------------------------------------*/
elmot 1:d0dfbce63a89 163 /** @defgroup FIREWALL_Exported_Macros FIREWALL Exported Macros
elmot 1:d0dfbce63a89 164 * @{
elmot 1:d0dfbce63a89 165 */
elmot 1:d0dfbce63a89 166
elmot 1:d0dfbce63a89 167 /** @brief Check whether the FIREWALL is enabled or not.
elmot 1:d0dfbce63a89 168 * @retval FIREWALL enabling status (TRUE or FALSE).
elmot 1:d0dfbce63a89 169 */
elmot 1:d0dfbce63a89 170 #define __HAL_FIREWALL_IS_ENABLED() HAL_IS_BIT_CLR(SYSCFG->CFGR1, SYSCFG_CFGR1_FWDIS)
elmot 1:d0dfbce63a89 171
elmot 1:d0dfbce63a89 172
elmot 1:d0dfbce63a89 173 /** @brief Enable FIREWALL pre arm.
elmot 1:d0dfbce63a89 174 * @note When FPA bit is set, any code executed outside the protected segment
elmot 1:d0dfbce63a89 175 * closes the Firewall, otherwise it generates a system reset.
elmot 1:d0dfbce63a89 176 * @note This macro provides the same service as HAL_FIREWALL_EnablePreArmFlag() API
elmot 1:d0dfbce63a89 177 * but can be executed inside a code area protected by the Firewall.
elmot 1:d0dfbce63a89 178 * @note This macro can be executed whatever the Firewall state (opened or closed) when
elmot 1:d0dfbce63a89 179 * NVDSL register is equal to 0. Otherwise (when NVDSL register is different from
elmot 1:d0dfbce63a89 180 * 0, that is, when the non volatile data segment is defined), the macro can be
elmot 1:d0dfbce63a89 181 * executed only when the Firewall is opened.
elmot 1:d0dfbce63a89 182 */
elmot 1:d0dfbce63a89 183 #define __HAL_FIREWALL_PREARM_ENABLE() \
elmot 1:d0dfbce63a89 184 do { \
elmot 1:d0dfbce63a89 185 __IO uint32_t tmpreg; \
elmot 1:d0dfbce63a89 186 SET_BIT(FIREWALL->CR, FW_CR_FPA) ; \
elmot 1:d0dfbce63a89 187 /* Read bit back to ensure it is taken into account by IP */ \
elmot 1:d0dfbce63a89 188 /* (introduce proper delay inside macro execution) */ \
elmot 1:d0dfbce63a89 189 tmpreg = READ_BIT(FIREWALL->CR, FW_CR_FPA) ; \
elmot 1:d0dfbce63a89 190 UNUSED(tmpreg); \
elmot 1:d0dfbce63a89 191 } while(0)
elmot 1:d0dfbce63a89 192
elmot 1:d0dfbce63a89 193
elmot 1:d0dfbce63a89 194
elmot 1:d0dfbce63a89 195 /** @brief Disable FIREWALL pre arm.
elmot 1:d0dfbce63a89 196 * @note When FPA bit is set, any code executed outside the protected segment
elmot 1:d0dfbce63a89 197 * closes the Firewall, otherwise, it generates a system reset.
elmot 1:d0dfbce63a89 198 * @note This macro provides the same service as HAL_FIREWALL_DisablePreArmFlag() API
elmot 1:d0dfbce63a89 199 * but can be executed inside a code area protected by the Firewall.
elmot 1:d0dfbce63a89 200 * @note This macro can be executed whatever the Firewall state (opened or closed) when
elmot 1:d0dfbce63a89 201 * NVDSL register is equal to 0. Otherwise (when NVDSL register is different from
elmot 1:d0dfbce63a89 202 * 0, that is, when the non volatile data segment is defined), the macro can be
elmot 1:d0dfbce63a89 203 * executed only when the Firewall is opened.
elmot 1:d0dfbce63a89 204 */
elmot 1:d0dfbce63a89 205 #define __HAL_FIREWALL_PREARM_DISABLE() \
elmot 1:d0dfbce63a89 206 do { \
elmot 1:d0dfbce63a89 207 __IO uint32_t tmpreg; \
elmot 1:d0dfbce63a89 208 CLEAR_BIT(FIREWALL->CR, FW_CR_FPA) ; \
elmot 1:d0dfbce63a89 209 /* Read bit back to ensure it is taken into account by IP */ \
elmot 1:d0dfbce63a89 210 /* (introduce proper delay inside macro execution) */ \
elmot 1:d0dfbce63a89 211 tmpreg = READ_BIT(FIREWALL->CR, FW_CR_FPA) ; \
elmot 1:d0dfbce63a89 212 UNUSED(tmpreg); \
elmot 1:d0dfbce63a89 213 } while(0)
elmot 1:d0dfbce63a89 214
elmot 1:d0dfbce63a89 215 /** @brief Enable volatile data sharing in setting VDS bit.
elmot 1:d0dfbce63a89 216 * @note When VDS bit is set, the volatile data segment is shared with non-protected
elmot 1:d0dfbce63a89 217 * application code. It can be accessed whatever the Firewall state (opened or closed).
elmot 1:d0dfbce63a89 218 * @note This macro can be executed inside a code area protected by the Firewall.
elmot 1:d0dfbce63a89 219 * @note This macro can be executed whatever the Firewall state (opened or closed) when
elmot 1:d0dfbce63a89 220 * NVDSL register is equal to 0. Otherwise (when NVDSL register is different from
elmot 1:d0dfbce63a89 221 * 0, that is, when the non volatile data segment is defined), the macro can be
elmot 1:d0dfbce63a89 222 * executed only when the Firewall is opened.
elmot 1:d0dfbce63a89 223 */
elmot 1:d0dfbce63a89 224 #define __HAL_FIREWALL_VOLATILEDATA_SHARED_ENABLE() \
elmot 1:d0dfbce63a89 225 do { \
elmot 1:d0dfbce63a89 226 __IO uint32_t tmpreg; \
elmot 1:d0dfbce63a89 227 SET_BIT(FIREWALL->CR, FW_CR_VDS) ; \
elmot 1:d0dfbce63a89 228 /* Read bit back to ensure it is taken into account by IP */ \
elmot 1:d0dfbce63a89 229 /* (introduce proper delay inside macro execution) */ \
elmot 1:d0dfbce63a89 230 tmpreg = READ_BIT(FIREWALL->CR, FW_CR_VDS) ; \
elmot 1:d0dfbce63a89 231 UNUSED(tmpreg); \
elmot 1:d0dfbce63a89 232 } while(0)
elmot 1:d0dfbce63a89 233
elmot 1:d0dfbce63a89 234 /** @brief Disable volatile data sharing in resetting VDS bit.
elmot 1:d0dfbce63a89 235 * @note When VDS bit is reset, the volatile data segment is not shared and cannot be
elmot 1:d0dfbce63a89 236 * hit by a non protected executable code when the Firewall is closed. If it is
elmot 1:d0dfbce63a89 237 * accessed in such a condition, a system reset is generated by the Firewall.
elmot 1:d0dfbce63a89 238 * @note This macro can be executed inside a code area protected by the Firewall.
elmot 1:d0dfbce63a89 239 * @note This macro can be executed whatever the Firewall state (opened or closed) when
elmot 1:d0dfbce63a89 240 * NVDSL register is equal to 0. Otherwise (when NVDSL register is different from
elmot 1:d0dfbce63a89 241 * 0, that is, when the non volatile data segment is defined), the macro can be
elmot 1:d0dfbce63a89 242 * executed only when the Firewall is opened.
elmot 1:d0dfbce63a89 243 */
elmot 1:d0dfbce63a89 244 #define __HAL_FIREWALL_VOLATILEDATA_SHARED_DISABLE() \
elmot 1:d0dfbce63a89 245 do { \
elmot 1:d0dfbce63a89 246 __IO uint32_t tmpreg; \
elmot 1:d0dfbce63a89 247 CLEAR_BIT(FIREWALL->CR, FW_CR_VDS) ; \
elmot 1:d0dfbce63a89 248 /* Read bit back to ensure it is taken into account by IP */ \
elmot 1:d0dfbce63a89 249 /* (introduce proper delay inside macro execution) */ \
elmot 1:d0dfbce63a89 250 tmpreg = READ_BIT(FIREWALL->CR, FW_CR_VDS) ; \
elmot 1:d0dfbce63a89 251 UNUSED(tmpreg); \
elmot 1:d0dfbce63a89 252 } while(0)
elmot 1:d0dfbce63a89 253
elmot 1:d0dfbce63a89 254 /** @brief Enable volatile data execution in setting VDE bit.
elmot 1:d0dfbce63a89 255 * @note VDE bit is ignored when VDS is set. IF VDS = 1, the Volatile data segment can be
elmot 1:d0dfbce63a89 256 * executed whatever the VDE bit value.
elmot 1:d0dfbce63a89 257 * @note When VDE bit is set (with VDS = 0), the volatile data segment is executable. When
elmot 1:d0dfbce63a89 258 * the Firewall call is closed, a "call gate" entry procedure is required to open
elmot 1:d0dfbce63a89 259 * first the Firewall.
elmot 1:d0dfbce63a89 260 * @note This macro can be executed inside a code area protected by the Firewall.
elmot 1:d0dfbce63a89 261 * @note This macro can be executed whatever the Firewall state (opened or closed) when
elmot 1:d0dfbce63a89 262 * NVDSL register is equal to 0. Otherwise (when NVDSL register is different from
elmot 1:d0dfbce63a89 263 * 0, that is, when the non volatile data segment is defined), the macro can be
elmot 1:d0dfbce63a89 264 * executed only when the Firewall is opened.
elmot 1:d0dfbce63a89 265 */
elmot 1:d0dfbce63a89 266 #define __HAL_FIREWALL_VOLATILEDATA_EXECUTION_ENABLE() \
elmot 1:d0dfbce63a89 267 do { \
elmot 1:d0dfbce63a89 268 __IO uint32_t tmpreg; \
elmot 1:d0dfbce63a89 269 SET_BIT(FIREWALL->CR, FW_CR_VDE) ; \
elmot 1:d0dfbce63a89 270 /* Read bit back to ensure it is taken into account by IP */ \
elmot 1:d0dfbce63a89 271 /* (introduce proper delay inside macro execution) */ \
elmot 1:d0dfbce63a89 272 tmpreg = READ_BIT(FIREWALL->CR, FW_CR_VDE) ; \
elmot 1:d0dfbce63a89 273 UNUSED(tmpreg); \
elmot 1:d0dfbce63a89 274 } while(0)
elmot 1:d0dfbce63a89 275
elmot 1:d0dfbce63a89 276 /** @brief Disable volatile data execution in resetting VDE bit.
elmot 1:d0dfbce63a89 277 * @note VDE bit is ignored when VDS is set. IF VDS = 1, the Volatile data segment can be
elmot 1:d0dfbce63a89 278 * executed whatever the VDE bit value.
elmot 1:d0dfbce63a89 279 * @note When VDE bit is reset (with VDS = 0), the volatile data segment cannot be executed.
elmot 1:d0dfbce63a89 280 * @note This macro can be executed inside a code area protected by the Firewall.
elmot 1:d0dfbce63a89 281 * @note This macro can be executed whatever the Firewall state (opened or closed) when
elmot 1:d0dfbce63a89 282 * NVDSL register is equal to 0. Otherwise (when NVDSL register is different from
elmot 1:d0dfbce63a89 283 * 0, that is, when the non volatile data segment is defined), the macro can be
elmot 1:d0dfbce63a89 284 * executed only when the Firewall is opened.
elmot 1:d0dfbce63a89 285 */
elmot 1:d0dfbce63a89 286 #define __HAL_FIREWALL_VOLATILEDATA_EXECUTION_DISABLE() \
elmot 1:d0dfbce63a89 287 do { \
elmot 1:d0dfbce63a89 288 __IO uint32_t tmpreg; \
elmot 1:d0dfbce63a89 289 CLEAR_BIT(FIREWALL->CR, FW_CR_VDE) ; \
elmot 1:d0dfbce63a89 290 /* Read bit back to ensure it is taken into account by IP */ \
elmot 1:d0dfbce63a89 291 /* (introduce proper delay inside macro execution) */ \
elmot 1:d0dfbce63a89 292 tmpreg = READ_BIT(FIREWALL->CR, FW_CR_VDE) ; \
elmot 1:d0dfbce63a89 293 UNUSED(tmpreg); \
elmot 1:d0dfbce63a89 294 } while(0)
elmot 1:d0dfbce63a89 295
elmot 1:d0dfbce63a89 296
elmot 1:d0dfbce63a89 297 /** @brief Check whether or not the volatile data segment is shared.
elmot 1:d0dfbce63a89 298 * @note This macro can be executed inside a code area protected by the Firewall.
elmot 1:d0dfbce63a89 299 * @note This macro can be executed whatever the Firewall state (opened or closed) when
elmot 1:d0dfbce63a89 300 * NVDSL register is equal to 0. Otherwise (when NVDSL register is different from
elmot 1:d0dfbce63a89 301 * 0, that is, when the non volatile data segment is defined), the macro can be
elmot 1:d0dfbce63a89 302 * executed only when the Firewall is opened.
elmot 1:d0dfbce63a89 303 * @retval VDS bit setting status (TRUE or FALSE).
elmot 1:d0dfbce63a89 304 */
elmot 1:d0dfbce63a89 305 #define __HAL_FIREWALL_GET_VOLATILEDATA_SHARED() ((FIREWALL->CR & FW_CR_VDS) == FW_CR_VDS)
elmot 1:d0dfbce63a89 306
elmot 1:d0dfbce63a89 307 /** @brief Check whether or not the volatile data segment is declared executable.
elmot 1:d0dfbce63a89 308 * @note This macro can be executed inside a code area protected by the Firewall.
elmot 1:d0dfbce63a89 309 * @note This macro can be executed whatever the Firewall state (opened or closed) when
elmot 1:d0dfbce63a89 310 * NVDSL register is equal to 0. Otherwise (when NVDSL register is different from
elmot 1:d0dfbce63a89 311 * 0, that is, when the non volatile data segment is defined), the macro can be
elmot 1:d0dfbce63a89 312 * executed only when the Firewall is opened.
elmot 1:d0dfbce63a89 313 * @retval VDE bit setting status (TRUE or FALSE).
elmot 1:d0dfbce63a89 314 */
elmot 1:d0dfbce63a89 315 #define __HAL_FIREWALL_GET_VOLATILEDATA_EXECUTION() ((FIREWALL->CR & FW_CR_VDE) == FW_CR_VDE)
elmot 1:d0dfbce63a89 316
elmot 1:d0dfbce63a89 317 /** @brief Check whether or not the Firewall pre arm bit is set.
elmot 1:d0dfbce63a89 318 * @note This macro can be executed inside a code area protected by the Firewall.
elmot 1:d0dfbce63a89 319 * @note This macro can be executed whatever the Firewall state (opened or closed) when
elmot 1:d0dfbce63a89 320 * NVDSL register is equal to 0. Otherwise (when NVDSL register is different from
elmot 1:d0dfbce63a89 321 * 0, that is, when the non volatile data segment is defined), the macro can be
elmot 1:d0dfbce63a89 322 * executed only when the Firewall is opened.
elmot 1:d0dfbce63a89 323 * @retval FPA bit setting status (TRUE or FALSE).
elmot 1:d0dfbce63a89 324 */
elmot 1:d0dfbce63a89 325 #define __HAL_FIREWALL_GET_PREARM() ((FIREWALL->CR & FW_CR_FPA) == FW_CR_FPA)
elmot 1:d0dfbce63a89 326
elmot 1:d0dfbce63a89 327
elmot 1:d0dfbce63a89 328 /**
elmot 1:d0dfbce63a89 329 * @}
elmot 1:d0dfbce63a89 330 */
elmot 1:d0dfbce63a89 331
elmot 1:d0dfbce63a89 332 /* Exported functions --------------------------------------------------------*/
elmot 1:d0dfbce63a89 333
elmot 1:d0dfbce63a89 334 /** @addtogroup FIREWALL_Exported_Functions FIREWALL Exported Functions
elmot 1:d0dfbce63a89 335 * @{
elmot 1:d0dfbce63a89 336 */
elmot 1:d0dfbce63a89 337
elmot 1:d0dfbce63a89 338 /** @addtogroup FIREWALL_Exported_Functions_Group1 Initialization Functions
elmot 1:d0dfbce63a89 339 * @brief Initialization and Configuration Functions
elmot 1:d0dfbce63a89 340 * @{
elmot 1:d0dfbce63a89 341 */
elmot 1:d0dfbce63a89 342
elmot 1:d0dfbce63a89 343 /* Initialization functions ********************************/
elmot 1:d0dfbce63a89 344 HAL_StatusTypeDef HAL_FIREWALL_Config(FIREWALL_InitTypeDef * fw_init);
elmot 1:d0dfbce63a89 345 void HAL_FIREWALL_GetConfig(FIREWALL_InitTypeDef * fw_config);
elmot 1:d0dfbce63a89 346 void HAL_FIREWALL_EnableFirewall(void);
elmot 1:d0dfbce63a89 347 void HAL_FIREWALL_EnablePreArmFlag(void);
elmot 1:d0dfbce63a89 348 void HAL_FIREWALL_DisablePreArmFlag(void);
elmot 1:d0dfbce63a89 349
elmot 1:d0dfbce63a89 350 /**
elmot 1:d0dfbce63a89 351 * @}
elmot 1:d0dfbce63a89 352 */
elmot 1:d0dfbce63a89 353
elmot 1:d0dfbce63a89 354 /**
elmot 1:d0dfbce63a89 355 * @}
elmot 1:d0dfbce63a89 356 */
elmot 1:d0dfbce63a89 357
elmot 1:d0dfbce63a89 358 /**
elmot 1:d0dfbce63a89 359 * @}
elmot 1:d0dfbce63a89 360 */
elmot 1:d0dfbce63a89 361
elmot 1:d0dfbce63a89 362 /**
elmot 1:d0dfbce63a89 363 * @}
elmot 1:d0dfbce63a89 364 */
elmot 1:d0dfbce63a89 365
elmot 1:d0dfbce63a89 366 #ifdef __cplusplus
elmot 1:d0dfbce63a89 367 }
elmot 1:d0dfbce63a89 368 #endif
elmot 1:d0dfbce63a89 369
elmot 1:d0dfbce63a89 370 #endif /* __STM32L4xx_HAL_FIREWALL_H */
elmot 1:d0dfbce63a89 371
elmot 1:d0dfbce63a89 372 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/