The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Thu Nov 08 11:45:42 2018 +0000
Revision:
171:3a7713b1edbc
Parent:
TARGET_K64F/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/drivers/fsl_sysmpu.h@169:a7c7b631e539
mbed library. Release version 164

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Anna Bridge 169:a7c7b631e539 1 /*
Anna Bridge 169:a7c7b631e539 2 * Copyright (c) 2015 - 2016, Freescale Semiconductor, Inc.
Anna Bridge 169:a7c7b631e539 3 * Copyright 2016-2017 NXP
Anna Bridge 169:a7c7b631e539 4 *
Anna Bridge 169:a7c7b631e539 5 * Redistribution and use in source and binary forms, with or without modification,
Anna Bridge 169:a7c7b631e539 6 * are permitted provided that the following conditions are met:
Anna Bridge 169:a7c7b631e539 7 *
Anna Bridge 169:a7c7b631e539 8 * o Redistributions of source code must retain the above copyright notice, this list
Anna Bridge 169:a7c7b631e539 9 * of conditions and the following disclaimer.
Anna Bridge 169:a7c7b631e539 10 *
Anna Bridge 169:a7c7b631e539 11 * o Redistributions in binary form must reproduce the above copyright notice, this
Anna Bridge 169:a7c7b631e539 12 * list of conditions and the following disclaimer in the documentation and/or
Anna Bridge 169:a7c7b631e539 13 * other materials provided with the distribution.
Anna Bridge 169:a7c7b631e539 14 *
Anna Bridge 169:a7c7b631e539 15 * o Neither the name of the copyright holder nor the names of its
Anna Bridge 169:a7c7b631e539 16 * contributors may be used to endorse or promote products derived from this
Anna Bridge 169:a7c7b631e539 17 * software without specific prior written permission.
Anna Bridge 169:a7c7b631e539 18 *
Anna Bridge 169:a7c7b631e539 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
Anna Bridge 169:a7c7b631e539 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Anna Bridge 169:a7c7b631e539 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Anna Bridge 169:a7c7b631e539 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
Anna Bridge 169:a7c7b631e539 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
Anna Bridge 169:a7c7b631e539 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
Anna Bridge 169:a7c7b631e539 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
Anna Bridge 169:a7c7b631e539 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Anna Bridge 169:a7c7b631e539 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Anna Bridge 169:a7c7b631e539 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Anna Bridge 169:a7c7b631e539 29 */
Anna Bridge 169:a7c7b631e539 30 #ifndef _FSL_SYSMPU_H_
Anna Bridge 169:a7c7b631e539 31 #define _FSL_SYSMPU_H_
Anna Bridge 169:a7c7b631e539 32
Anna Bridge 169:a7c7b631e539 33 #include "fsl_common.h"
Anna Bridge 169:a7c7b631e539 34
Anna Bridge 169:a7c7b631e539 35 /*!
Anna Bridge 169:a7c7b631e539 36 * @addtogroup sysmpu
Anna Bridge 169:a7c7b631e539 37 * @{
Anna Bridge 169:a7c7b631e539 38 */
Anna Bridge 169:a7c7b631e539 39
Anna Bridge 169:a7c7b631e539 40
Anna Bridge 169:a7c7b631e539 41 /*******************************************************************************
Anna Bridge 169:a7c7b631e539 42 * Definitions
Anna Bridge 169:a7c7b631e539 43 ******************************************************************************/
Anna Bridge 169:a7c7b631e539 44
Anna Bridge 169:a7c7b631e539 45 /*! @name Driver version */
Anna Bridge 169:a7c7b631e539 46 /*@{*/
Anna Bridge 169:a7c7b631e539 47 /*! @brief SYSMPU driver version 2.2.0. */
Anna Bridge 169:a7c7b631e539 48 #define FSL_SYSMPU_DRIVER_VERSION (MAKE_VERSION(2, 2, 0))
Anna Bridge 169:a7c7b631e539 49 /*@}*/
Anna Bridge 169:a7c7b631e539 50
Anna Bridge 169:a7c7b631e539 51 /*! @brief define the start master port with read and write attributes. */
Anna Bridge 169:a7c7b631e539 52 #define SYSMPU_MASTER_RWATTRIBUTE_START_PORT (4)
Anna Bridge 169:a7c7b631e539 53
Anna Bridge 169:a7c7b631e539 54 /*! @brief SYSMPU the bit shift for masters with privilege rights: read write and execute. */
Anna Bridge 169:a7c7b631e539 55 #define SYSMPU_REGION_RWXRIGHTS_MASTER_SHIFT(n) (n * 6)
Anna Bridge 169:a7c7b631e539 56
Anna Bridge 169:a7c7b631e539 57 /*! @brief SYSMPU masters with read, write and execute rights bit mask. */
Anna Bridge 169:a7c7b631e539 58 #define SYSMPU_REGION_RWXRIGHTS_MASTER_MASK(n) (0x1Fu << SYSMPU_REGION_RWXRIGHTS_MASTER_SHIFT(n))
Anna Bridge 169:a7c7b631e539 59
Anna Bridge 169:a7c7b631e539 60 /*! @brief SYSMPU masters with read, write and execute rights bit width. */
Anna Bridge 169:a7c7b631e539 61 #define SYSMPU_REGION_RWXRIGHTS_MASTER_WIDTH 5
Anna Bridge 169:a7c7b631e539 62
Anna Bridge 169:a7c7b631e539 63 /*! @brief SYSMPU masters with read, write and execute rights priority setting. */
Anna Bridge 169:a7c7b631e539 64 #define SYSMPU_REGION_RWXRIGHTS_MASTER(n, x) \
Anna Bridge 169:a7c7b631e539 65 (((uint32_t)(((uint32_t)(x)) << SYSMPU_REGION_RWXRIGHTS_MASTER_SHIFT(n))) & SYSMPU_REGION_RWXRIGHTS_MASTER_MASK(n))
Anna Bridge 169:a7c7b631e539 66
Anna Bridge 169:a7c7b631e539 67 /*! @brief SYSMPU masters with read, write and execute rights process enable bit shift. */
Anna Bridge 169:a7c7b631e539 68 #define SYSMPU_REGION_RWXRIGHTS_MASTER_PE_SHIFT(n) (n * 6 + SYSMPU_REGION_RWXRIGHTS_MASTER_WIDTH)
Anna Bridge 169:a7c7b631e539 69
Anna Bridge 169:a7c7b631e539 70 /*! @brief SYSMPU masters with read, write and execute rights process enable bit mask. */
Anna Bridge 169:a7c7b631e539 71 #define SYSMPU_REGION_RWXRIGHTS_MASTER_PE_MASK(n) (0x1u << SYSMPU_REGION_RWXRIGHTS_MASTER_PE_SHIFT(n))
Anna Bridge 169:a7c7b631e539 72
Anna Bridge 169:a7c7b631e539 73 /*! @brief SYSMPU masters with read, write and execute rights process enable setting. */
Anna Bridge 169:a7c7b631e539 74 #define SYSMPU_REGION_RWXRIGHTS_MASTER_PE(n, x) \
Anna Bridge 169:a7c7b631e539 75 (((uint32_t)(((uint32_t)(x)) << SYSMPU_REGION_RWXRIGHTS_MASTER_PE_SHIFT(n))) & SYSMPU_REGION_RWXRIGHTS_MASTER_PE_MASK(n))
Anna Bridge 169:a7c7b631e539 76
Anna Bridge 169:a7c7b631e539 77 /*! @brief SYSMPU masters with normal read write permission bit shift. */
Anna Bridge 169:a7c7b631e539 78 #define SYSMPU_REGION_RWRIGHTS_MASTER_SHIFT(n) ((n - SYSMPU_MASTER_RWATTRIBUTE_START_PORT) * 2 + 24)
Anna Bridge 169:a7c7b631e539 79
Anna Bridge 169:a7c7b631e539 80 /*! @brief SYSMPU masters with normal read write rights bit mask. */
Anna Bridge 169:a7c7b631e539 81 #define SYSMPU_REGION_RWRIGHTS_MASTER_MASK(n) (0x3u << SYSMPU_REGION_RWRIGHTS_MASTER_SHIFT(n))
Anna Bridge 169:a7c7b631e539 82
Anna Bridge 169:a7c7b631e539 83 /*! @brief SYSMPU masters with normal read write rights priority setting. */
Anna Bridge 169:a7c7b631e539 84 #define SYSMPU_REGION_RWRIGHTS_MASTER(n, x) \
Anna Bridge 169:a7c7b631e539 85 (((uint32_t)(((uint32_t)(x)) << SYSMPU_REGION_RWRIGHTS_MASTER_SHIFT(n))) & SYSMPU_REGION_RWRIGHTS_MASTER_MASK(n))
Anna Bridge 169:a7c7b631e539 86
Anna Bridge 169:a7c7b631e539 87
Anna Bridge 169:a7c7b631e539 88 /*! @brief Describes the number of SYSMPU regions. */
Anna Bridge 169:a7c7b631e539 89 typedef enum _sysmpu_region_total_num
Anna Bridge 169:a7c7b631e539 90 {
Anna Bridge 169:a7c7b631e539 91 kSYSMPU_8Regions = 0x0U, /*!< SYSMPU supports 8 regions. */
Anna Bridge 169:a7c7b631e539 92 kSYSMPU_12Regions = 0x1U, /*!< SYSMPU supports 12 regions. */
Anna Bridge 169:a7c7b631e539 93 kSYSMPU_16Regions = 0x2U /*!< SYSMPU supports 16 regions. */
Anna Bridge 169:a7c7b631e539 94 } sysmpu_region_total_num_t;
Anna Bridge 169:a7c7b631e539 95
Anna Bridge 169:a7c7b631e539 96 /*! @brief SYSMPU slave port number. */
Anna Bridge 169:a7c7b631e539 97 typedef enum _sysmpu_slave
Anna Bridge 169:a7c7b631e539 98 {
Anna Bridge 169:a7c7b631e539 99 kSYSMPU_Slave0 = 0U, /*!< SYSMPU slave port 0. */
Anna Bridge 169:a7c7b631e539 100 kSYSMPU_Slave1 = 1U, /*!< SYSMPU slave port 1. */
Anna Bridge 169:a7c7b631e539 101 kSYSMPU_Slave2 = 2U, /*!< SYSMPU slave port 2. */
Anna Bridge 169:a7c7b631e539 102 kSYSMPU_Slave3 = 3U, /*!< SYSMPU slave port 3. */
Anna Bridge 169:a7c7b631e539 103 kSYSMPU_Slave4 = 4U, /*!< SYSMPU slave port 4. */
Anna Bridge 169:a7c7b631e539 104 #if FSL_FEATURE_SYSMPU_SLAVE_COUNT > 5
Anna Bridge 169:a7c7b631e539 105 kSYSMPU_Slave5 = 5U, /*!< SYSMPU slave port 5. */
Anna Bridge 169:a7c7b631e539 106 #endif
Anna Bridge 169:a7c7b631e539 107 #if FSL_FEATURE_SYSMPU_SLAVE_COUNT > 6
Anna Bridge 169:a7c7b631e539 108 kSYSMPU_Slave6 = 6U, /*!< SYSMPU slave port 6. */
Anna Bridge 169:a7c7b631e539 109 #endif
Anna Bridge 169:a7c7b631e539 110 #if FSL_FEATURE_SYSMPU_SLAVE_COUNT > 7
Anna Bridge 169:a7c7b631e539 111 kSYSMPU_Slave7 = 7U, /*!< SYSMPU slave port 7. */
Anna Bridge 169:a7c7b631e539 112 #endif
Anna Bridge 169:a7c7b631e539 113 } sysmpu_slave_t;
Anna Bridge 169:a7c7b631e539 114
Anna Bridge 169:a7c7b631e539 115 /*! @brief SYSMPU error access control detail. */
Anna Bridge 169:a7c7b631e539 116 typedef enum _sysmpu_err_access_control
Anna Bridge 169:a7c7b631e539 117 {
Anna Bridge 169:a7c7b631e539 118 kSYSMPU_NoRegionHit = 0U, /*!< No region hit error. */
Anna Bridge 169:a7c7b631e539 119 kSYSMPU_NoneOverlappRegion = 1U, /*!< Access single region error. */
Anna Bridge 169:a7c7b631e539 120 kSYSMPU_OverlappRegion = 2U /*!< Access overlapping region error. */
Anna Bridge 169:a7c7b631e539 121 } sysmpu_err_access_control_t;
Anna Bridge 169:a7c7b631e539 122
Anna Bridge 169:a7c7b631e539 123 /*! @brief SYSMPU error access type. */
Anna Bridge 169:a7c7b631e539 124 typedef enum _sysmpu_err_access_type
Anna Bridge 169:a7c7b631e539 125 {
Anna Bridge 169:a7c7b631e539 126 kSYSMPU_ErrTypeRead = 0U, /*!< SYSMPU error access type --- read. */
Anna Bridge 169:a7c7b631e539 127 kSYSMPU_ErrTypeWrite = 1U /*!< SYSMPU error access type --- write. */
Anna Bridge 169:a7c7b631e539 128 } sysmpu_err_access_type_t;
Anna Bridge 169:a7c7b631e539 129
Anna Bridge 169:a7c7b631e539 130 /*! @brief SYSMPU access error attributes.*/
Anna Bridge 169:a7c7b631e539 131 typedef enum _sysmpu_err_attributes
Anna Bridge 169:a7c7b631e539 132 {
Anna Bridge 169:a7c7b631e539 133 kSYSMPU_InstructionAccessInUserMode = 0U, /*!< Access instruction error in user mode. */
Anna Bridge 169:a7c7b631e539 134 kSYSMPU_DataAccessInUserMode = 1U, /*!< Access data error in user mode. */
Anna Bridge 169:a7c7b631e539 135 kSYSMPU_InstructionAccessInSupervisorMode = 2U, /*!< Access instruction error in supervisor mode. */
Anna Bridge 169:a7c7b631e539 136 kSYSMPU_DataAccessInSupervisorMode = 3U /*!< Access data error in supervisor mode. */
Anna Bridge 169:a7c7b631e539 137 } sysmpu_err_attributes_t;
Anna Bridge 169:a7c7b631e539 138
Anna Bridge 169:a7c7b631e539 139 /*! @brief SYSMPU access rights in supervisor mode for bus master 0 ~ 3. */
Anna Bridge 169:a7c7b631e539 140 typedef enum _sysmpu_supervisor_access_rights
Anna Bridge 169:a7c7b631e539 141 {
Anna Bridge 169:a7c7b631e539 142 kSYSMPU_SupervisorReadWriteExecute = 0U, /*!< Read write and execute operations are allowed in supervisor mode. */
Anna Bridge 169:a7c7b631e539 143 kSYSMPU_SupervisorReadExecute = 1U, /*!< Read and execute operations are allowed in supervisor mode. */
Anna Bridge 169:a7c7b631e539 144 kSYSMPU_SupervisorReadWrite = 2U, /*!< Read write operations are allowed in supervisor mode. */
Anna Bridge 169:a7c7b631e539 145 kSYSMPU_SupervisorEqualToUsermode = 3U /*!< Access permission equal to user mode. */
Anna Bridge 169:a7c7b631e539 146 } sysmpu_supervisor_access_rights_t;
Anna Bridge 169:a7c7b631e539 147
Anna Bridge 169:a7c7b631e539 148 /*! @brief SYSMPU access rights in user mode for bus master 0 ~ 3. */
Anna Bridge 169:a7c7b631e539 149 typedef enum _sysmpu_user_access_rights
Anna Bridge 169:a7c7b631e539 150 {
Anna Bridge 169:a7c7b631e539 151 kSYSMPU_UserNoAccessRights = 0U, /*!< No access allowed in user mode. */
Anna Bridge 169:a7c7b631e539 152 kSYSMPU_UserExecute = 1U, /*!< Execute operation is allowed in user mode. */
Anna Bridge 169:a7c7b631e539 153 kSYSMPU_UserWrite = 2U, /*!< Write operation is allowed in user mode. */
Anna Bridge 169:a7c7b631e539 154 kSYSMPU_UserWriteExecute = 3U, /*!< Write and execute operations are allowed in user mode. */
Anna Bridge 169:a7c7b631e539 155 kSYSMPU_UserRead = 4U, /*!< Read is allowed in user mode. */
Anna Bridge 169:a7c7b631e539 156 kSYSMPU_UserReadExecute = 5U, /*!< Read and execute operations are allowed in user mode. */
Anna Bridge 169:a7c7b631e539 157 kSYSMPU_UserReadWrite = 6U, /*!< Read and write operations are allowed in user mode. */
Anna Bridge 169:a7c7b631e539 158 kSYSMPU_UserReadWriteExecute = 7U /*!< Read write and execute operations are allowed in user mode. */
Anna Bridge 169:a7c7b631e539 159 } sysmpu_user_access_rights_t;
Anna Bridge 169:a7c7b631e539 160
Anna Bridge 169:a7c7b631e539 161 /*! @brief SYSMPU hardware basic information. */
Anna Bridge 169:a7c7b631e539 162 typedef struct _sysmpu_hardware_info
Anna Bridge 169:a7c7b631e539 163 {
Anna Bridge 169:a7c7b631e539 164 uint8_t hardwareRevisionLevel; /*!< Specifies the SYSMPU's hardware and definition reversion level. */
Anna Bridge 169:a7c7b631e539 165 uint8_t slavePortsNumbers; /*!< Specifies the number of slave ports connected to SYSMPU. */
Anna Bridge 169:a7c7b631e539 166 sysmpu_region_total_num_t regionsNumbers; /*!< Indicates the number of region descriptors implemented. */
Anna Bridge 169:a7c7b631e539 167 } sysmpu_hardware_info_t;
Anna Bridge 169:a7c7b631e539 168
Anna Bridge 169:a7c7b631e539 169 /*! @brief SYSMPU detail error access information. */
Anna Bridge 169:a7c7b631e539 170 typedef struct _sysmpu_access_err_info
Anna Bridge 169:a7c7b631e539 171 {
Anna Bridge 169:a7c7b631e539 172 uint32_t master; /*!< Access error master. */
Anna Bridge 169:a7c7b631e539 173 sysmpu_err_attributes_t attributes; /*!< Access error attributes. */
Anna Bridge 169:a7c7b631e539 174 sysmpu_err_access_type_t accessType; /*!< Access error type. */
Anna Bridge 169:a7c7b631e539 175 sysmpu_err_access_control_t accessControl; /*!< Access error control. */
Anna Bridge 169:a7c7b631e539 176 uint32_t address; /*!< Access error address. */
Anna Bridge 169:a7c7b631e539 177 #if FSL_FEATURE_SYSMPU_HAS_PROCESS_IDENTIFIER
Anna Bridge 169:a7c7b631e539 178 uint8_t processorIdentification; /*!< Access error processor identification. */
Anna Bridge 169:a7c7b631e539 179 #endif /* FSL_FEATURE_SYSMPU_HAS_PROCESS_IDENTIFIER */
Anna Bridge 169:a7c7b631e539 180 } sysmpu_access_err_info_t;
Anna Bridge 169:a7c7b631e539 181
Anna Bridge 169:a7c7b631e539 182 /*! @brief SYSMPU read/write/execute rights control for bus master 0 ~ 3. */
Anna Bridge 169:a7c7b631e539 183 typedef struct _sysmpu_rwxrights_master_access_control
Anna Bridge 169:a7c7b631e539 184 {
Anna Bridge 169:a7c7b631e539 185 sysmpu_supervisor_access_rights_t superAccessRights; /*!< Master access rights in supervisor mode. */
Anna Bridge 169:a7c7b631e539 186 sysmpu_user_access_rights_t userAccessRights; /*!< Master access rights in user mode. */
Anna Bridge 169:a7c7b631e539 187 #if FSL_FEATURE_SYSMPU_HAS_PROCESS_IDENTIFIER
Anna Bridge 169:a7c7b631e539 188 bool processIdentifierEnable; /*!< Enables or disables process identifier. */
Anna Bridge 169:a7c7b631e539 189 #endif /* FSL_FEATURE_SYSMPU_HAS_PROCESS_IDENTIFIER */
Anna Bridge 169:a7c7b631e539 190 } sysmpu_rwxrights_master_access_control_t;
Anna Bridge 169:a7c7b631e539 191
Anna Bridge 169:a7c7b631e539 192 /*! @brief SYSMPU read/write access control for bus master 4 ~ 7. */
Anna Bridge 169:a7c7b631e539 193 typedef struct _sysmpu_rwrights_master_access_control
Anna Bridge 169:a7c7b631e539 194 {
Anna Bridge 169:a7c7b631e539 195 bool writeEnable; /*!< Enables or disables write permission. */
Anna Bridge 169:a7c7b631e539 196 bool readEnable; /*!< Enables or disables read permission. */
Anna Bridge 169:a7c7b631e539 197 } sysmpu_rwrights_master_access_control_t;
Anna Bridge 169:a7c7b631e539 198
Anna Bridge 169:a7c7b631e539 199 /*!
Anna Bridge 169:a7c7b631e539 200 * @brief SYSMPU region configuration structure.
Anna Bridge 169:a7c7b631e539 201 *
Anna Bridge 169:a7c7b631e539 202 * This structure is used to configure the regionNum region.
Anna Bridge 169:a7c7b631e539 203 * The accessRights1[0] ~ accessRights1[3] are used to configure the bus master
Anna Bridge 169:a7c7b631e539 204 * 0 ~ 3 with the privilege rights setting. The accessRights2[0] ~ accessRights2[3]
Anna Bridge 169:a7c7b631e539 205 * are used to configure the high master 4 ~ 7 with the normal read write permission.
Anna Bridge 169:a7c7b631e539 206 * The master port assignment is the chip configuration. Normally, the core is the
Anna Bridge 169:a7c7b631e539 207 * master 0, debugger is the master 1.
Anna Bridge 169:a7c7b631e539 208 * Note that the SYSMPU assigns a priority scheme where the debugger is treated as the highest
Anna Bridge 169:a7c7b631e539 209 * priority master followed by the core and then all the remaining masters.
Anna Bridge 169:a7c7b631e539 210 * SYSMPU protection does not allow writes from the core to affect the "regionNum 0" start
Anna Bridge 169:a7c7b631e539 211 * and end address nor the permissions associated with the debugger. It can only write
Anna Bridge 169:a7c7b631e539 212 * the permission fields associated with the other masters. This protection guarantees that
Anna Bridge 169:a7c7b631e539 213 * the debugger always has access to the entire address space and those rights can't
Anna Bridge 169:a7c7b631e539 214 * be changed by the core or any other bus master. Prepare
Anna Bridge 169:a7c7b631e539 215 * the region configuration when regionNum is 0.
Anna Bridge 169:a7c7b631e539 216 */
Anna Bridge 169:a7c7b631e539 217 typedef struct _sysmpu_region_config
Anna Bridge 169:a7c7b631e539 218 {
Anna Bridge 169:a7c7b631e539 219 uint32_t regionNum; /*!< SYSMPU region number, range form 0 ~ FSL_FEATURE_SYSMPU_DESCRIPTOR_COUNT - 1. */
Anna Bridge 169:a7c7b631e539 220 uint32_t startAddress; /*!< Memory region start address. Note: bit0 ~ bit4 always be marked as 0 by SYSMPU. The actual
Anna Bridge 169:a7c7b631e539 221 start address is 0-modulo-32 byte address. */
Anna Bridge 169:a7c7b631e539 222 uint32_t endAddress; /*!< Memory region end address. Note: bit0 ~ bit4 always be marked as 1 by SYSMPU. The actual end
Anna Bridge 169:a7c7b631e539 223 address is 31-modulo-32 byte address. */
Anna Bridge 169:a7c7b631e539 224 sysmpu_rwxrights_master_access_control_t accessRights1[4]; /*!< Masters with read, write and execute rights setting. */
Anna Bridge 169:a7c7b631e539 225 sysmpu_rwrights_master_access_control_t accessRights2[4]; /*!< Masters with normal read write rights setting. */
Anna Bridge 169:a7c7b631e539 226 #if FSL_FEATURE_SYSMPU_HAS_PROCESS_IDENTIFIER
Anna Bridge 169:a7c7b631e539 227 uint8_t processIdentifier; /*!< Process identifier used when "processIdentifierEnable" set with true. */
Anna Bridge 169:a7c7b631e539 228 uint8_t
Anna Bridge 169:a7c7b631e539 229 processIdMask; /*!< Process identifier mask. The setting bit will ignore the same bit in process identifier. */
Anna Bridge 169:a7c7b631e539 230 #endif /* FSL_FEATURE_SYSMPU_HAS_PROCESS_IDENTIFIER */
Anna Bridge 169:a7c7b631e539 231 } sysmpu_region_config_t;
Anna Bridge 169:a7c7b631e539 232
Anna Bridge 169:a7c7b631e539 233 /*!
Anna Bridge 169:a7c7b631e539 234 * @brief The configuration structure for the SYSMPU initialization.
Anna Bridge 169:a7c7b631e539 235 *
Anna Bridge 169:a7c7b631e539 236 * This structure is used when calling the SYSMPU_Init function.
Anna Bridge 169:a7c7b631e539 237 */
Anna Bridge 169:a7c7b631e539 238 typedef struct _sysmpu_config
Anna Bridge 169:a7c7b631e539 239 {
Anna Bridge 169:a7c7b631e539 240 sysmpu_region_config_t regionConfig; /*!< Region access permission. */
Anna Bridge 169:a7c7b631e539 241 struct _sysmpu_config *next; /*!< Pointer to the next structure. */
Anna Bridge 169:a7c7b631e539 242 } sysmpu_config_t;
Anna Bridge 169:a7c7b631e539 243
Anna Bridge 169:a7c7b631e539 244 /*******************************************************************************
Anna Bridge 169:a7c7b631e539 245 * API
Anna Bridge 169:a7c7b631e539 246 ******************************************************************************/
Anna Bridge 169:a7c7b631e539 247
Anna Bridge 169:a7c7b631e539 248 #if defined(__cplusplus)
Anna Bridge 169:a7c7b631e539 249 extern "C" {
Anna Bridge 169:a7c7b631e539 250 #endif /* _cplusplus */
Anna Bridge 169:a7c7b631e539 251
Anna Bridge 169:a7c7b631e539 252 /*!
Anna Bridge 169:a7c7b631e539 253 * @name Initialization and deinitialization
Anna Bridge 169:a7c7b631e539 254 * @{
Anna Bridge 169:a7c7b631e539 255 */
Anna Bridge 169:a7c7b631e539 256
Anna Bridge 169:a7c7b631e539 257 /*!
Anna Bridge 169:a7c7b631e539 258 * @brief Initializes the SYSMPU with the user configuration structure.
Anna Bridge 169:a7c7b631e539 259 *
Anna Bridge 169:a7c7b631e539 260 * This function configures the SYSMPU module with the user-defined configuration.
Anna Bridge 169:a7c7b631e539 261 *
Anna Bridge 169:a7c7b631e539 262 * @param base SYSMPU peripheral base address.
Anna Bridge 169:a7c7b631e539 263 * @param config The pointer to the configuration structure.
Anna Bridge 169:a7c7b631e539 264 */
Anna Bridge 169:a7c7b631e539 265 void SYSMPU_Init(SYSMPU_Type *base, const sysmpu_config_t *config);
Anna Bridge 169:a7c7b631e539 266
Anna Bridge 169:a7c7b631e539 267 /*!
Anna Bridge 169:a7c7b631e539 268 * @brief Deinitializes the SYSMPU regions.
Anna Bridge 169:a7c7b631e539 269 *
Anna Bridge 169:a7c7b631e539 270 * @param base SYSMPU peripheral base address.
Anna Bridge 169:a7c7b631e539 271 */
Anna Bridge 169:a7c7b631e539 272 void SYSMPU_Deinit(SYSMPU_Type *base);
Anna Bridge 169:a7c7b631e539 273
Anna Bridge 169:a7c7b631e539 274 /* @}*/
Anna Bridge 169:a7c7b631e539 275
Anna Bridge 169:a7c7b631e539 276 /*!
Anna Bridge 169:a7c7b631e539 277 * @name Basic Control Operations
Anna Bridge 169:a7c7b631e539 278 * @{
Anna Bridge 169:a7c7b631e539 279 */
Anna Bridge 169:a7c7b631e539 280
Anna Bridge 169:a7c7b631e539 281 /*!
Anna Bridge 169:a7c7b631e539 282 * @brief Enables/disables the SYSMPU globally.
Anna Bridge 169:a7c7b631e539 283 *
Anna Bridge 169:a7c7b631e539 284 * Call this API to enable or disable the SYSMPU module.
Anna Bridge 169:a7c7b631e539 285 *
Anna Bridge 169:a7c7b631e539 286 * @param base SYSMPU peripheral base address.
Anna Bridge 169:a7c7b631e539 287 * @param enable True enable SYSMPU, false disable SYSMPU.
Anna Bridge 169:a7c7b631e539 288 */
Anna Bridge 169:a7c7b631e539 289 static inline void SYSMPU_Enable(SYSMPU_Type *base, bool enable)
Anna Bridge 169:a7c7b631e539 290 {
Anna Bridge 169:a7c7b631e539 291 if (enable)
Anna Bridge 169:a7c7b631e539 292 {
Anna Bridge 169:a7c7b631e539 293 /* Enable the SYSMPU globally. */
Anna Bridge 169:a7c7b631e539 294 base->CESR |= SYSMPU_CESR_VLD_MASK;
Anna Bridge 169:a7c7b631e539 295 }
Anna Bridge 169:a7c7b631e539 296 else
Anna Bridge 169:a7c7b631e539 297 { /* Disable the SYSMPU globally. */
Anna Bridge 169:a7c7b631e539 298 base->CESR &= ~SYSMPU_CESR_VLD_MASK;
Anna Bridge 169:a7c7b631e539 299 }
Anna Bridge 169:a7c7b631e539 300 }
Anna Bridge 169:a7c7b631e539 301
Anna Bridge 169:a7c7b631e539 302 /*!
Anna Bridge 169:a7c7b631e539 303 * @brief Enables/disables the SYSMPU for a special region.
Anna Bridge 169:a7c7b631e539 304 *
Anna Bridge 169:a7c7b631e539 305 * When SYSMPU is enabled, call this API to disable an unused region
Anna Bridge 169:a7c7b631e539 306 * of an enabled SYSMPU. Call this API to minimize the power dissipation.
Anna Bridge 169:a7c7b631e539 307 *
Anna Bridge 169:a7c7b631e539 308 * @param base SYSMPU peripheral base address.
Anna Bridge 169:a7c7b631e539 309 * @param number SYSMPU region number.
Anna Bridge 169:a7c7b631e539 310 * @param enable True enable the special region SYSMPU, false disable the special region SYSMPU.
Anna Bridge 169:a7c7b631e539 311 */
Anna Bridge 169:a7c7b631e539 312 static inline void SYSMPU_RegionEnable(SYSMPU_Type *base, uint32_t number, bool enable)
Anna Bridge 169:a7c7b631e539 313 {
Anna Bridge 169:a7c7b631e539 314 if (enable)
Anna Bridge 169:a7c7b631e539 315 {
Anna Bridge 169:a7c7b631e539 316 /* Enable the #number region SYSMPU. */
Anna Bridge 169:a7c7b631e539 317 base->WORD[number][3] |= SYSMPU_WORD_VLD_MASK;
Anna Bridge 169:a7c7b631e539 318 }
Anna Bridge 169:a7c7b631e539 319 else
Anna Bridge 169:a7c7b631e539 320 { /* Disable the #number region SYSMPU. */
Anna Bridge 169:a7c7b631e539 321 base->WORD[number][3] &= ~SYSMPU_WORD_VLD_MASK;
Anna Bridge 169:a7c7b631e539 322 }
Anna Bridge 169:a7c7b631e539 323 }
Anna Bridge 169:a7c7b631e539 324
Anna Bridge 169:a7c7b631e539 325 /*!
Anna Bridge 169:a7c7b631e539 326 * @brief Gets the SYSMPU basic hardware information.
Anna Bridge 169:a7c7b631e539 327 *
Anna Bridge 169:a7c7b631e539 328 * @param base SYSMPU peripheral base address.
Anna Bridge 169:a7c7b631e539 329 * @param hardwareInform The pointer to the SYSMPU hardware information structure. See "sysmpu_hardware_info_t".
Anna Bridge 169:a7c7b631e539 330 */
Anna Bridge 169:a7c7b631e539 331 void SYSMPU_GetHardwareInfo(SYSMPU_Type *base, sysmpu_hardware_info_t *hardwareInform);
Anna Bridge 169:a7c7b631e539 332
Anna Bridge 169:a7c7b631e539 333 /*!
Anna Bridge 169:a7c7b631e539 334 * @brief Sets the SYSMPU region.
Anna Bridge 169:a7c7b631e539 335 *
Anna Bridge 169:a7c7b631e539 336 * Note: Due to the SYSMPU protection, the region number 0 does not allow writes from
Anna Bridge 169:a7c7b631e539 337 * core to affect the start and end address nor the permissions associated with
Anna Bridge 169:a7c7b631e539 338 * the debugger. It can only write the permission fields associated
Anna Bridge 169:a7c7b631e539 339 * with the other masters.
Anna Bridge 169:a7c7b631e539 340 *
Anna Bridge 169:a7c7b631e539 341 * @param base SYSMPU peripheral base address.
Anna Bridge 169:a7c7b631e539 342 * @param regionConfig The pointer to the SYSMPU user configuration structure. See "sysmpu_region_config_t".
Anna Bridge 169:a7c7b631e539 343 */
Anna Bridge 169:a7c7b631e539 344 void SYSMPU_SetRegionConfig(SYSMPU_Type *base, const sysmpu_region_config_t *regionConfig);
Anna Bridge 169:a7c7b631e539 345
Anna Bridge 169:a7c7b631e539 346 /*!
Anna Bridge 169:a7c7b631e539 347 * @brief Sets the region start and end address.
Anna Bridge 169:a7c7b631e539 348 *
Anna Bridge 169:a7c7b631e539 349 * Memory region start address. Note: bit0 ~ bit4 is always marked as 0 by SYSMPU.
Anna Bridge 169:a7c7b631e539 350 * The actual start address by SYSMPU is 0-modulo-32 byte address.
Anna Bridge 169:a7c7b631e539 351 * Memory region end address. Note: bit0 ~ bit4 always be marked as 1 by SYSMPU.
Anna Bridge 169:a7c7b631e539 352 * The end address used by the SYSMPU is 31-modulo-32 byte address.
Anna Bridge 169:a7c7b631e539 353 * Note: Due to the SYSMPU protection, the startAddr and endAddr can't be
Anna Bridge 169:a7c7b631e539 354 * changed by the core when regionNum is 0.
Anna Bridge 169:a7c7b631e539 355 *
Anna Bridge 169:a7c7b631e539 356 * @param base SYSMPU peripheral base address.
Anna Bridge 169:a7c7b631e539 357 * @param regionNum SYSMPU region number. The range is from 0 to
Anna Bridge 169:a7c7b631e539 358 * FSL_FEATURE_SYSMPU_DESCRIPTOR_COUNT - 1.
Anna Bridge 169:a7c7b631e539 359 * @param startAddr Region start address.
Anna Bridge 169:a7c7b631e539 360 * @param endAddr Region end address.
Anna Bridge 169:a7c7b631e539 361 */
Anna Bridge 169:a7c7b631e539 362 void SYSMPU_SetRegionAddr(SYSMPU_Type *base, uint32_t regionNum, uint32_t startAddr, uint32_t endAddr);
Anna Bridge 169:a7c7b631e539 363
Anna Bridge 169:a7c7b631e539 364 /*!
Anna Bridge 169:a7c7b631e539 365 * @brief Sets the SYSMPU region access rights for masters with read, write, and execute rights.
Anna Bridge 169:a7c7b631e539 366 * The SYSMPU access rights depend on two board classifications of bus masters.
Anna Bridge 169:a7c7b631e539 367 * The privilege rights masters and the normal rights masters.
Anna Bridge 169:a7c7b631e539 368 * The privilege rights masters have the read, write, and execute access rights.
Anna Bridge 169:a7c7b631e539 369 * Except the normal read and write rights, the execute rights are also
Anna Bridge 169:a7c7b631e539 370 * allowed for these masters. The privilege rights masters normally range from
Anna Bridge 169:a7c7b631e539 371 * bus masters 0 - 3. However, the maximum master number is device-specific.
Anna Bridge 169:a7c7b631e539 372 * See the "SYSMPU_PRIVILEGED_RIGHTS_MASTER_MAX_INDEX".
Anna Bridge 169:a7c7b631e539 373 * The normal rights masters access rights control see
Anna Bridge 169:a7c7b631e539 374 * "SYSMPU_SetRegionRwMasterAccessRights()".
Anna Bridge 169:a7c7b631e539 375 *
Anna Bridge 169:a7c7b631e539 376 * @param base SYSMPU peripheral base address.
Anna Bridge 169:a7c7b631e539 377 * @param regionNum SYSMPU region number. Should range from 0 to
Anna Bridge 169:a7c7b631e539 378 * FSL_FEATURE_SYSMPU_DESCRIPTOR_COUNT - 1.
Anna Bridge 169:a7c7b631e539 379 * @param masterNum SYSMPU bus master number. Should range from 0 to
Anna Bridge 169:a7c7b631e539 380 * SYSMPU_PRIVILEGED_RIGHTS_MASTER_MAX_INDEX.
Anna Bridge 169:a7c7b631e539 381 * @param accessRights The pointer to the SYSMPU access rights configuration. See "sysmpu_rwxrights_master_access_control_t".
Anna Bridge 169:a7c7b631e539 382 */
Anna Bridge 169:a7c7b631e539 383 void SYSMPU_SetRegionRwxMasterAccessRights(SYSMPU_Type *base,
Anna Bridge 169:a7c7b631e539 384 uint32_t regionNum,
Anna Bridge 169:a7c7b631e539 385 uint32_t masterNum,
Anna Bridge 169:a7c7b631e539 386 const sysmpu_rwxrights_master_access_control_t *accessRights);
Anna Bridge 169:a7c7b631e539 387 #if FSL_FEATURE_SYSMPU_MASTER_COUNT > 4
Anna Bridge 169:a7c7b631e539 388 /*!
Anna Bridge 169:a7c7b631e539 389 * @brief Sets the SYSMPU region access rights for masters with read and write rights.
Anna Bridge 169:a7c7b631e539 390 * The SYSMPU access rights depend on two board classifications of bus masters.
Anna Bridge 169:a7c7b631e539 391 * The privilege rights masters and the normal rights masters.
Anna Bridge 169:a7c7b631e539 392 * The normal rights masters only have the read and write access permissions.
Anna Bridge 169:a7c7b631e539 393 * The privilege rights access control see "SYSMPU_SetRegionRwxMasterAccessRights".
Anna Bridge 169:a7c7b631e539 394 *
Anna Bridge 169:a7c7b631e539 395 * @param base SYSMPU peripheral base address.
Anna Bridge 169:a7c7b631e539 396 * @param regionNum SYSMPU region number. The range is from 0 to
Anna Bridge 169:a7c7b631e539 397 * FSL_FEATURE_SYSMPU_DESCRIPTOR_COUNT - 1.
Anna Bridge 169:a7c7b631e539 398 * @param masterNum SYSMPU bus master number. Should range from SYSMPU_MASTER_RWATTRIBUTE_START_PORT
Anna Bridge 169:a7c7b631e539 399 * to ~ FSL_FEATURE_SYSMPU_MASTER_COUNT - 1.
Anna Bridge 169:a7c7b631e539 400 * @param accessRights The pointer to the SYSMPU access rights configuration. See "sysmpu_rwrights_master_access_control_t".
Anna Bridge 169:a7c7b631e539 401 */
Anna Bridge 169:a7c7b631e539 402 void SYSMPU_SetRegionRwMasterAccessRights(SYSMPU_Type *base,
Anna Bridge 169:a7c7b631e539 403 uint32_t regionNum,
Anna Bridge 169:a7c7b631e539 404 uint32_t masterNum,
Anna Bridge 169:a7c7b631e539 405 const sysmpu_rwrights_master_access_control_t *accessRights);
Anna Bridge 169:a7c7b631e539 406 #endif /* FSL_FEATURE_SYSMPU_MASTER_COUNT > 4 */
Anna Bridge 169:a7c7b631e539 407 /*!
Anna Bridge 169:a7c7b631e539 408 * @brief Gets the numbers of slave ports where errors occur.
Anna Bridge 169:a7c7b631e539 409 *
Anna Bridge 169:a7c7b631e539 410 * @param base SYSMPU peripheral base address.
Anna Bridge 169:a7c7b631e539 411 * @param slaveNum SYSMPU slave port number.
Anna Bridge 169:a7c7b631e539 412 * @return The slave ports error status.
Anna Bridge 169:a7c7b631e539 413 * true - error happens in this slave port.
Anna Bridge 169:a7c7b631e539 414 * false - error didn't happen in this slave port.
Anna Bridge 169:a7c7b631e539 415 */
Anna Bridge 169:a7c7b631e539 416 bool SYSMPU_GetSlavePortErrorStatus(SYSMPU_Type *base, sysmpu_slave_t slaveNum);
Anna Bridge 169:a7c7b631e539 417
Anna Bridge 169:a7c7b631e539 418 /*!
Anna Bridge 169:a7c7b631e539 419 * @brief Gets the SYSMPU detailed error access information.
Anna Bridge 169:a7c7b631e539 420 *
Anna Bridge 169:a7c7b631e539 421 * @param base SYSMPU peripheral base address.
Anna Bridge 169:a7c7b631e539 422 * @param slaveNum SYSMPU slave port number.
Anna Bridge 169:a7c7b631e539 423 * @param errInform The pointer to the SYSMPU access error information. See "sysmpu_access_err_info_t".
Anna Bridge 169:a7c7b631e539 424 */
Anna Bridge 169:a7c7b631e539 425 void SYSMPU_GetDetailErrorAccessInfo(SYSMPU_Type *base, sysmpu_slave_t slaveNum, sysmpu_access_err_info_t *errInform);
Anna Bridge 169:a7c7b631e539 426
Anna Bridge 169:a7c7b631e539 427 /* @} */
Anna Bridge 169:a7c7b631e539 428
Anna Bridge 169:a7c7b631e539 429 #if defined(__cplusplus)
Anna Bridge 169:a7c7b631e539 430 }
Anna Bridge 169:a7c7b631e539 431 #endif
Anna Bridge 169:a7c7b631e539 432
Anna Bridge 169:a7c7b631e539 433 /*! @}*/
Anna Bridge 169:a7c7b631e539 434
Anna Bridge 169:a7c7b631e539 435 #endif /* _FSL_SYSMPU_H_ */