|
ChibiOS/RT
2.5.1 |
00001 /* 00002 ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, 00003 2011,2012 Giovanni Di Sirio. 00004 00005 This file is part of ChibiOS/RT. 00006 00007 ChibiOS/RT is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 3 of the License, or 00010 (at your option) any later version. 00011 00012 ChibiOS/RT is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program. If not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 00021 /** 00022 * @file IAR/ARMCMx/chcore.h 00023 * @brief ARM Cortex-Mx port macros and structures. 00024 * 00025 * @addtogroup IAR_ARMCMx_CORE 00026 * @{ 00027 */ 00028 00029 #ifndef _CHCORE_H_ 00030 #define _CHCORE_H_ 00031 00032 /*===========================================================================*/ 00033 /* Port constants (common). */ 00034 /*===========================================================================*/ 00035 00036 /* Added to make the header stand-alone when included from asm.*/ 00037 #ifndef FALSE 00038 #define FALSE 0 00039 #endif 00040 #ifndef TRUE 00041 #define TRUE (!FALSE) 00042 #endif 00043 00044 #define CORTEX_M0 0 /**< @brief Cortex-M0 variant. */ 00045 #define CORTEX_M1 1 /**< @brief Cortex-M1 variant. */ 00046 #define CORTEX_M3 3 /**< @brief Cortex-M3 variant. */ 00047 #define CORTEX_M4 4 /**< @brief Cortex-M4 variant. */ 00048 00049 /* Inclusion of the Cortex-Mx implementation specific parameters.*/ 00050 #include "cmparams.h" 00051 00052 /* Cortex model check, only M0 and M3 supported right now.*/ 00053 #if (CORTEX_MODEL == CORTEX_M0) || (CORTEX_MODEL == CORTEX_M3) || \ 00054 (CORTEX_MODEL == CORTEX_M4) 00055 #elif (CORTEX_MODEL == CORTEX_M1) 00056 #error "untested Cortex-M model" 00057 #else 00058 #error "unknown or unsupported Cortex-M model" 00059 #endif 00060 00061 /** 00062 * @brief Total priority levels. 00063 */ 00064 #define CORTEX_PRIORITY_LEVELS (1 << CORTEX_PRIORITY_BITS) 00065 00066 /** 00067 * @brief Minimum priority level. 00068 * @details This minimum priority level is calculated from the number of 00069 * priority bits supported by the specific Cortex-Mx implementation. 00070 */ 00071 #define CORTEX_MINIMUM_PRIORITY (CORTEX_PRIORITY_LEVELS - 1) 00072 00073 /** 00074 * @brief Maximum priority level. 00075 * @details The maximum allowed priority level is always zero. 00076 */ 00077 #define CORTEX_MAXIMUM_PRIORITY 0 00078 00079 /*===========================================================================*/ 00080 /* Port macros (common). */ 00081 /*===========================================================================*/ 00082 00083 /** 00084 * @brief Priority level verification macro. 00085 */ 00086 #define CORTEX_IS_VALID_PRIORITY(n) \ 00087 (((n) >= 0) && ((n) < CORTEX_PRIORITY_LEVELS)) 00088 00089 /** 00090 * @brief Priority level verification macro. 00091 */ 00092 #define CORTEX_IS_VALID_KERNEL_PRIORITY(n) \ 00093 (((n) >= CORTEX_MAX_KERNEL_PRIORITY) && ((n) < CORTEX_PRIORITY_LEVELS)) 00094 00095 /** 00096 * @brief Priority level to priority mask conversion macro. 00097 */ 00098 #define CORTEX_PRIORITY_MASK(n) \ 00099 ((n) << (8 - CORTEX_PRIORITY_BITS)) 00100 00101 /*===========================================================================*/ 00102 /* Port configurable parameters (common). */ 00103 /*===========================================================================*/ 00104 00105 /*===========================================================================*/ 00106 /* Port derived parameters (common). */ 00107 /*===========================================================================*/ 00108 00109 /*===========================================================================*/ 00110 /* Port exported info (common). */ 00111 /*===========================================================================*/ 00112 00113 /** 00114 * @brief Macro defining a generic ARM architecture. 00115 */ 00116 #define CH_ARCHITECTURE_ARM 00117 00118 /** 00119 * @brief Name of the compiler supported by this port. 00120 */ 00121 #define CH_COMPILER_NAME "IAR" 00122 00123 /*===========================================================================*/ 00124 /* Port implementation part (common). */ 00125 /*===========================================================================*/ 00126 00127 /* Includes the sub-architecture-specific part.*/ 00128 #if (CORTEX_MODEL == CORTEX_M0) || (CORTEX_MODEL == CORTEX_M1) 00129 #include "chcore_v6m.h" 00130 #elif (CORTEX_MODEL == CORTEX_M3) || (CORTEX_MODEL == CORTEX_M4) 00131 #include "chcore_v7m.h" 00132 #endif 00133 00134 #if !defined(_FROM_ASM_) 00135 00136 #include <intrinsics.h> 00137 #include "nvic.h" 00138 00139 /* The following declarations are there just for Doxygen documentation, the 00140 real declarations are inside the sub-headers.*/ 00141 #if defined(__DOXYGEN__) 00142 00143 /** 00144 * @brief Stack and memory alignment enforcement. 00145 * @note In this architecture the stack alignment is enforced to 64 bits, 00146 * 32 bits alignment is supported by hardware but deprecated by ARM, 00147 * the implementation choice is to not offer the option. 00148 */ 00149 typedef uint64_t stkalign_t; 00150 00151 /** 00152 * @brief Interrupt saved context. 00153 * @details This structure represents the stack frame saved during a 00154 * preemption-capable interrupt handler. 00155 * @note It is implemented to match the Cortex-Mx exception context. 00156 */ 00157 struct extctx {}; 00158 00159 /** 00160 * @brief System saved context. 00161 * @details This structure represents the inner stack frame during a context 00162 * switching. 00163 */ 00164 struct intctx {}; 00165 00166 #endif /* defined(__DOXYGEN__) */ 00167 00168 /** 00169 * @brief Excludes the default @p chSchIsPreemptionRequired()implementation. 00170 */ 00171 #define PORT_OPTIMIZED_ISPREEMPTIONREQUIRED 00172 00173 #if (CH_TIME_QUANTUM > 0) || defined(__DOXYGEN__) 00174 /** 00175 * @brief Inline-able version of this kernel function. 00176 */ 00177 #define chSchIsPreemptionRequired() \ 00178 (currp->p_preempt ? firstprio(&rlist.r_queue) > currp->p_prio : \ 00179 firstprio(&rlist.r_queue) >= currp->p_prio) 00180 #else /* CH_TIME_QUANTUM == 0 */ 00181 #define chSchIsPreemptionRequired() \ 00182 (firstprio(&rlist.r_queue) > currp->p_prio) 00183 #endif /* CH_TIME_QUANTUM == 0 */ 00184 00185 #endif /* _FROM_ASM_ */ 00186 00187 #endif /* _CHCORE_H_ */ 00188 00189 /** @} */