Fork of the official mbed C/C SDK provides the software platform and libraries to build your applications for RenBED.

Dependents:   1-RenBuggyTimed RenBED_RGB RenBED_RGB_PWM RenBED_RGB

Fork of mbed by mbed official

Committer:
elijahorr
Date:
Thu Apr 14 07:28:54 2016 +0000
Revision:
121:672067c3ada4
Parent:
107:4f6c30876dfa
.

Who changed what in which revision?

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