mbed official / mbed

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

Committer:
AnnaBridge
Date:
Fri May 26 12:30:20 2017 +0100
Revision:
143:86740a56073b
Child:
167:84c0a372a020
Release 143 of the mbed library.

Who changed what in which revision?

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