]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/RVDS/ARM_CA9/port.c
Add configCLEAR_TICK_INTERRUPT() to the IAR and RVDS Cortex-A9 ports.
[freertos] / FreeRTOS / Source / portable / RVDS / ARM_CA9 / port.c
1 /*\r
2     FreeRTOS V8.0.0:rc1 - Copyright (C) 2014 Real Time Engineers Ltd.\r
3     All rights reserved\r
4 \r
5     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
6 \r
7     ***************************************************************************\r
8      *                                                                       *\r
9      *    FreeRTOS provides completely free yet professionally developed,    *\r
10      *    robust, strictly quality controlled, supported, and cross          *\r
11      *    platform software that has become a de facto standard.             *\r
12      *                                                                       *\r
13      *    Help yourself get started quickly and support the FreeRTOS         *\r
14      *    project by purchasing a FreeRTOS tutorial book, reference          *\r
15      *    manual, or both from: http://www.FreeRTOS.org/Documentation        *\r
16      *                                                                       *\r
17      *    Thank you!                                                         *\r
18      *                                                                       *\r
19     ***************************************************************************\r
20 \r
21     This file is part of the FreeRTOS distribution.\r
22 \r
23     FreeRTOS is free software; you can redistribute it and/or modify it under\r
24     the terms of the GNU General Public License (version 2) as published by the\r
25     Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
26 \r
27     >>! NOTE: The modification to the GPL is included to allow you to distribute\r
28     >>! a combined work that includes FreeRTOS without being obliged to provide\r
29     >>! the source code for proprietary components outside of the FreeRTOS\r
30     >>! kernel.\r
31 \r
32     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
33     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
34     FOR A PARTICULAR PURPOSE.  Full license text is available from the following\r
35     link: http://www.freertos.org/a00114.html\r
36 \r
37     1 tab == 4 spaces!\r
38 \r
39     ***************************************************************************\r
40      *                                                                       *\r
41      *    Having a problem?  Start by reading the FAQ "My application does   *\r
42      *    not run, what could be wrong?"                                     *\r
43      *                                                                       *\r
44      *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
45      *                                                                       *\r
46     ***************************************************************************\r
47 \r
48     http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
49     license and Real Time Engineers Ltd. contact details.\r
50 \r
51     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
52     including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
53     compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
54 \r
55     http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
56     Integrity Systems to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
57     licenses offer ticketed support, indemnification and middleware.\r
58 \r
59     http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
60     engineered and independently SIL3 certified version for use in safety and\r
61     mission critical applications that require provable dependability.\r
62 \r
63     1 tab == 4 spaces!\r
64 */\r
65 \r
66 /* Standard includes. */\r
67 #include <stdlib.h>\r
68 \r
69 /* Scheduler includes. */\r
70 #include "FreeRTOS.h"\r
71 #include "task.h"\r
72 \r
73 #ifndef configINTERRUPT_CONTROLLER_BASE_ADDRESS\r
74         #error configINTERRUPT_CONTROLLER_BASE_ADDRESS must be defined.  See http://www.freertos.org/Using-FreeRTOS-on-Cortex-A-Embedded-Processors.html\r
75 #endif\r
76 \r
77 #ifndef configINTERRUPT_CONTROLLER_CPU_INTERFACE_OFFSET\r
78         #error configINTERRUPT_CONTROLLER_CPU_INTERFACE_OFFSET must be defined.  See http://www.freertos.org/Using-FreeRTOS-on-Cortex-A-Embedded-Processors.html\r
79 #endif\r
80 \r
81 #ifndef configUNIQUE_INTERRUPT_PRIORITIES\r
82         #error configUNIQUE_INTERRUPT_PRIORITIES must be defined.  See http://www.freertos.org/Using-FreeRTOS-on-Cortex-A-Embedded-Processors.html\r
83 #endif\r
84 \r
85 #ifndef configSETUP_TICK_INTERRUPT\r
86         #error configSETUP_TICK_INTERRUPT() must be defined.  See http://www.freertos.org/Using-FreeRTOS-on-Cortex-A-Embedded-Processors.html\r
87 #endif /* configSETUP_TICK_INTERRUPT */\r
88 \r
89 #ifndef configMAX_API_CALL_INTERRUPT_PRIORITY\r
90         #error configMAX_API_CALL_INTERRUPT_PRIORITY must be defined.  See http://www.freertos.org/Using-FreeRTOS-on-Cortex-A-Embedded-Processors.html\r
91 #endif\r
92 \r
93 #if configMAX_API_CALL_INTERRUPT_PRIORITY == 0\r
94         #error configMAX_API_CALL_INTERRUPT_PRIORITY must not be set to 0\r
95 #endif\r
96 \r
97 #if configMAX_API_CALL_INTERRUPT_PRIORITY > configUNIQUE_INTERRUPT_PRIORITIES\r
98         #error configMAX_API_CALL_INTERRUPT_PRIORITY must be less than or equal to configUNIQUE_INTERRUPT_PRIORITIES as the lower the numeric priority value the higher the logical interrupt priority\r
99 #endif\r
100 \r
101 #if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1\r
102         /* Check the configuration. */\r
103         #if( configMAX_PRIORITIES > 32 )\r
104                 #error configUSE_PORT_OPTIMISED_TASK_SELECTION can only be set to 1 when configMAX_PRIORITIES is less than or equal to 32.  It is very rare that a system requires more than 10 to 15 difference priorities as tasks that share a priority will time slice.\r
105         #endif\r
106 #endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */\r
107 \r
108 /* In case security extensions are implemented. */\r
109 #if configMAX_API_CALL_INTERRUPT_PRIORITY <= ( configUNIQUE_INTERRUPT_PRIORITIES / 2 )\r
110         #error configMAX_API_CALL_INTERRUPT_PRIORITY must be greater than ( configUNIQUE_INTERRUPT_PRIORITIES / 2 )\r
111 #endif\r
112 \r
113 #ifndef configCLEAR_TICK_INTERRUPT\r
114         #define configCLEAR_TICK_INTERRUPT()\r
115 #endif\r
116 \r
117 /* The number of bits to shift for an interrupt priority is dependent on the\r
118 number of bits implemented by the interrupt controller. */\r
119 #if configUNIQUE_INTERRUPT_PRIORITIES == 16\r
120         #define portPRIORITY_SHIFT 4\r
121         #define portMAX_BINARY_POINT_VALUE      3\r
122 #elif configUNIQUE_INTERRUPT_PRIORITIES == 32\r
123         #define portPRIORITY_SHIFT 3\r
124         #define portMAX_BINARY_POINT_VALUE      2\r
125 #elif configUNIQUE_INTERRUPT_PRIORITIES == 64\r
126         #define portPRIORITY_SHIFT 2\r
127         #define portMAX_BINARY_POINT_VALUE      1\r
128 #elif configUNIQUE_INTERRUPT_PRIORITIES == 128\r
129         #define portPRIORITY_SHIFT 1\r
130         #define portMAX_BINARY_POINT_VALUE      0\r
131 #elif configUNIQUE_INTERRUPT_PRIORITIES == 256\r
132         #define portPRIORITY_SHIFT 0\r
133         #define portMAX_BINARY_POINT_VALUE      0\r
134 #else\r
135         #error Invalid configUNIQUE_INTERRUPT_PRIORITIES setting.  configUNIQUE_INTERRUPT_PRIORITIES must be set to the number of unique priorities implemented by the target hardware\r
136 #endif\r
137 \r
138 /* A critical section is exited when the critical section nesting count reaches\r
139 this value. */\r
140 #define portNO_CRITICAL_NESTING                 ( ( uint32_t ) 0 )\r
141 \r
142 /* In all GICs 255 can be written to the priority mask register to unmask all\r
143 (but the lowest) interrupt priority. */\r
144 #define portUNMASK_VALUE                                ( 0xFF )\r
145 \r
146 /* Tasks are not created with a floating point context, but can be given a\r
147 floating point context after they have been created.  A variable is stored as\r
148 part of the tasks context that holds portNO_FLOATING_POINT_CONTEXT if the task\r
149 does not have an FPU context, or any other value if the task does have an FPU\r
150 context. */\r
151 #define portNO_FLOATING_POINT_CONTEXT   ( ( StackType_t ) 0 )\r
152 \r
153 /* Interrupt controller access addresses. */\r
154 #define portICCPMR_PRIORITY_MASK_OFFSET                 ( 0x04 )\r
155 #define portICCIAR_INTERRUPT_ACKNOWLEDGE_OFFSET ( 0x0C )\r
156 #define portICCEOIR_END_OF_INTERRUPT_OFFSET     ( 0x10 )\r
157 #define portICCBPR_BINARY_POINT_OFFSET                  ( 0x08 )\r
158 #define portICCRPR_RUNNING_PRIORITY_OFFSET              ( 0x14 )\r
159 #define portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS          ( configINTERRUPT_CONTROLLER_BASE_ADDRESS + configINTERRUPT_CONTROLLER_CPU_INTERFACE_OFFSET )\r
160 #define portICCPMR_PRIORITY_MASK_REGISTER                                       ( *( ( volatile uint32_t * ) ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCPMR_PRIORITY_MASK_OFFSET ) ) )\r
161 #define portICCIAR_INTERRUPT_ACKNOWLEDGE_REGISTER_ADDRESS       ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCIAR_INTERRUPT_ACKNOWLEDGE_OFFSET )\r
162 #define portICCEOIR_END_OF_INTERRUPT_REGISTER_ADDRESS           ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCEOIR_END_OF_INTERRUPT_OFFSET )\r
163 #define portICCPMR_PRIORITY_MASK_REGISTER_ADDRESS                       ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCPMR_PRIORITY_MASK_OFFSET )\r
164 #define portICCBPR_BINARY_POINT_REGISTER                                        ( *( ( const volatile uint32_t * ) ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCBPR_BINARY_POINT_OFFSET ) ) )\r
165 #define portICCRPR_RUNNING_PRIORITY_REGISTER                            ( *( ( const volatile uint8_t * ) ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCRPR_RUNNING_PRIORITY_OFFSET ) ) )\r
166 \r
167 /* Used by portASSERT_IF_INTERRUPT_PRIORITY_INVALID() when ensuring the binary\r
168 point is zero. */\r
169 #define portBINARY_POINT_BITS                   ( ( uint8_t ) 0x03 )\r
170 \r
171 /* Constants required to setup the initial task context. */\r
172 #define portINITIAL_SPSR                                ( ( StackType_t ) 0x1f ) /* System mode, ARM mode, interrupts enabled. */\r
173 #define portTHUMB_MODE_BIT                              ( ( StackType_t ) 0x20 )\r
174 #define portTHUMB_MODE_ADDRESS                  ( 0x01UL )\r
175 \r
176 /* Masks all bits in the APSR other than the mode bits. */\r
177 #define portAPSR_MODE_BITS_MASK                 ( 0x1F )\r
178 \r
179 /* The value of the mode bits in the APSR when the CPU is executing in user\r
180 mode. */\r
181 #define portAPSR_USER_MODE                              ( 0x10 )\r
182 \r
183 /* Macro to unmask all interrupt priorities. */\r
184 #define portCLEAR_INTERRUPT_MASK()                                                                                      \\r
185 {                                                                                                                                                       \\r
186         __disable_irq();                                                                                                                \\r
187         portICCPMR_PRIORITY_MASK_REGISTER = portUNMASK_VALUE;                                   \\r
188         __asm(  "DSB            \n"                                                                                                     \\r
189                         "ISB            \n" );                                                                                          \\r
190         __enable_irq();                                                                                                                 \\r
191 }\r
192 \r
193 /*-----------------------------------------------------------*/\r
194 \r
195 /*\r
196  * Starts the first task executing.  This function is necessarily written in\r
197  * assembly code so is implemented in portASM.s.\r
198  */\r
199 extern void vPortRestoreTaskContext( void );\r
200 \r
201 /*-----------------------------------------------------------*/\r
202 \r
203 /* A variable is used to keep track of the critical section nesting.  This\r
204 variable has to be stored as part of the task context and must be initialised to\r
205 a non zero value to ensure interrupts don't inadvertently become unmasked before\r
206 the scheduler starts.  As it is stored as part of the task context it will\r
207 automatically be set to 0 when the first task is started. */\r
208 volatile uint32_t ulCriticalNesting = 9999UL;\r
209 \r
210 /* Used to pass constants into the ASM code.  The address at which variables are\r
211 placed is the constant value so indirect loads in the asm code are not\r
212 required. */\r
213 uint32_t ulICCIAR __attribute__( ( at( portICCIAR_INTERRUPT_ACKNOWLEDGE_REGISTER_ADDRESS ) ) );\r
214 uint32_t ulICCEOIR __attribute__( ( at( portICCEOIR_END_OF_INTERRUPT_REGISTER_ADDRESS ) ) );\r
215 uint32_t ulICCPMR __attribute__( ( at( portICCPMR_PRIORITY_MASK_REGISTER_ADDRESS ) ) );\r
216 uint32_t ulAsmAPIPriorityMask __attribute__( ( at( configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT ) ) );\r
217 \r
218 /* Saved as part of the task context.  If ulPortTaskHasFPUContext is non-zero then\r
219 a floating point context must be saved and restored for the task. */\r
220 uint32_t ulPortTaskHasFPUContext = pdFALSE;\r
221 \r
222 /* Set to 1 to pend a context switch from an ISR. */\r
223 uint32_t ulPortYieldRequired = pdFALSE;\r
224 \r
225 /* Counts the interrupt nesting depth.  A context switch is only performed if\r
226 if the nesting depth is 0. */\r
227 uint32_t ulPortInterruptNesting = 0UL;\r
228 \r
229 /*-----------------------------------------------------------*/\r
230 \r
231 /*\r
232  * See header file for description.\r
233  */\r
234 StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters )\r
235 {\r
236         /* Setup the initial stack of the task.  The stack is set exactly as\r
237         expected by the portRESTORE_CONTEXT() macro.\r
238 \r
239         The fist real value on the stack is the status register, which is set for\r
240         system mode, with interrupts enabled.  A few NULLs are added first to ensure\r
241         GDB does not try decoding a non-existent return address. */\r
242         *pxTopOfStack = NULL;\r
243         pxTopOfStack--;\r
244         *pxTopOfStack = NULL;\r
245         pxTopOfStack--;\r
246         *pxTopOfStack = NULL;\r
247         pxTopOfStack--;\r
248         *pxTopOfStack = ( StackType_t ) portINITIAL_SPSR;\r
249 \r
250         if( ( ( uint32_t ) pxCode & portTHUMB_MODE_ADDRESS ) != 0x00UL )\r
251         {\r
252                 /* The task will start in THUMB mode. */\r
253                 *pxTopOfStack |= portTHUMB_MODE_BIT;\r
254         }\r
255 \r
256         pxTopOfStack--;\r
257 \r
258         /* Next the return address, which in this case is the start of the task. */\r
259         *pxTopOfStack = ( StackType_t ) pxCode;\r
260         pxTopOfStack--;\r
261 \r
262         /* Next all the registers other than the stack pointer. */\r
263         *pxTopOfStack = ( StackType_t ) 0x00000000;     /* R14 */\r
264         pxTopOfStack--;\r
265         *pxTopOfStack = ( StackType_t ) 0x12121212;     /* R12 */\r
266         pxTopOfStack--;\r
267         *pxTopOfStack = ( StackType_t ) 0x11111111;     /* R11 */\r
268         pxTopOfStack--;\r
269         *pxTopOfStack = ( StackType_t ) 0x10101010;     /* R10 */\r
270         pxTopOfStack--;\r
271         *pxTopOfStack = ( StackType_t ) 0x09090909;     /* R9 */\r
272         pxTopOfStack--;\r
273         *pxTopOfStack = ( StackType_t ) 0x08080808;     /* R8 */\r
274         pxTopOfStack--;\r
275         *pxTopOfStack = ( StackType_t ) 0x07070707;     /* R7 */\r
276         pxTopOfStack--;\r
277         *pxTopOfStack = ( StackType_t ) 0x06060606;     /* R6 */\r
278         pxTopOfStack--;\r
279         *pxTopOfStack = ( StackType_t ) 0x05050505;     /* R5 */\r
280         pxTopOfStack--;\r
281         *pxTopOfStack = ( StackType_t ) 0x04040404;     /* R4 */\r
282         pxTopOfStack--;\r
283         *pxTopOfStack = ( StackType_t ) 0x03030303;     /* R3 */\r
284         pxTopOfStack--;\r
285         *pxTopOfStack = ( StackType_t ) 0x02020202;     /* R2 */\r
286         pxTopOfStack--;\r
287         *pxTopOfStack = ( StackType_t ) 0x01010101;     /* R1 */\r
288         pxTopOfStack--;\r
289         *pxTopOfStack = ( StackType_t ) pvParameters; /* R0 */\r
290         pxTopOfStack--;\r
291 \r
292         /* The task will start with a critical nesting count of 0 as interrupts are\r
293         enabled. */\r
294         *pxTopOfStack = portNO_CRITICAL_NESTING;\r
295         pxTopOfStack--;\r
296 \r
297         /* The task will start without a floating point context.  A task that uses\r
298         the floating point hardware must call vPortTaskUsesFPU() before executing\r
299         any floating point instructions. */\r
300         *pxTopOfStack = portNO_FLOATING_POINT_CONTEXT;\r
301 \r
302         return pxTopOfStack;\r
303 }\r
304 /*-----------------------------------------------------------*/\r
305 \r
306 BaseType_t xPortStartScheduler( void )\r
307 {\r
308 uint32_t ulAPSR;\r
309 \r
310         /* Only continue if the CPU is not in User mode.  The CPU must be in a\r
311         Privileged mode for the scheduler to start. */\r
312         __asm( "MRS ulAPSR, APSR" );\r
313         ulAPSR &= portAPSR_MODE_BITS_MASK;\r
314         configASSERT( ulAPSR != portAPSR_USER_MODE );\r
315 \r
316         if( ulAPSR != portAPSR_USER_MODE )\r
317         {\r
318                 /* Only continue if the binary point value is set to its lowest possible\r
319                 setting.  See the comments in vPortValidateInterruptPriority() below for\r
320                 more information. */\r
321                 configASSERT( ( portICCBPR_BINARY_POINT_REGISTER & portBINARY_POINT_BITS ) <= portMAX_BINARY_POINT_VALUE );\r
322 \r
323                 if( ( portICCBPR_BINARY_POINT_REGISTER & portBINARY_POINT_BITS ) <= portMAX_BINARY_POINT_VALUE )\r
324                 {\r
325                         /* Start the timer that generates the tick ISR. */\r
326                         configSETUP_TICK_INTERRUPT();\r
327 \r
328                         __enable_irq();\r
329                         vPortRestoreTaskContext();\r
330                 }\r
331         }\r
332 \r
333         /* Will only get here if xTaskStartScheduler() was called with the CPU in\r
334         a non-privileged mode or the binary point register was not set to its lowest\r
335         possible value. */\r
336         return 0;\r
337 }\r
338 /*-----------------------------------------------------------*/\r
339 \r
340 void vPortEndScheduler( void )\r
341 {\r
342         /* Not implemented in ports where there is nothing to return to.\r
343         Artificially force an assert. */\r
344         configASSERT( ulCriticalNesting == 1000UL );\r
345 }\r
346 /*-----------------------------------------------------------*/\r
347 \r
348 void vPortEnterCritical( void )\r
349 {\r
350         /* Disable interrupts as per portDISABLE_INTERRUPTS();  */\r
351         ulPortSetInterruptMask();\r
352 \r
353         /* Now interrupts are disabled ulCriticalNesting can be accessed\r
354         directly.  Increment ulCriticalNesting to keep a count of how many times\r
355         portENTER_CRITICAL() has been called. */\r
356         ulCriticalNesting++;\r
357 }\r
358 /*-----------------------------------------------------------*/\r
359 \r
360 void vPortExitCritical( void )\r
361 {\r
362         if( ulCriticalNesting > portNO_CRITICAL_NESTING )\r
363         {\r
364                 /* Decrement the nesting count as the critical section is being\r
365                 exited. */\r
366                 ulCriticalNesting--;\r
367 \r
368                 /* If the nesting level has reached zero then all interrupt\r
369                 priorities must be re-enabled. */\r
370                 if( ulCriticalNesting == portNO_CRITICAL_NESTING )\r
371                 {\r
372                         /* Critical nesting has reached zero so all interrupt priorities\r
373                         should be unmasked. */\r
374                         portCLEAR_INTERRUPT_MASK();\r
375                 }\r
376         }\r
377 }\r
378 /*-----------------------------------------------------------*/\r
379 \r
380 void FreeRTOS_Tick_Handler( void )\r
381 {\r
382         /* Set interrupt mask before altering scheduler structures.   The tick\r
383         handler runs at the lowest priority, so interrupts cannot already be masked,\r
384         so there is no need to save and restore the current mask value. */\r
385         __disable_irq();\r
386         portICCPMR_PRIORITY_MASK_REGISTER = ( configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT );\r
387         __asm(  "DSB            \n"\r
388                         "ISB            \n" );\r
389         __enable_irq();\r
390 \r
391         /* Increment the RTOS tick. */\r
392         if( xTaskIncrementTick() != pdFALSE )\r
393         {\r
394                 ulPortYieldRequired = pdTRUE;\r
395         }\r
396 \r
397         /* Ensure all interrupt priorities are active again. */\r
398         portCLEAR_INTERRUPT_MASK();\r
399         configCLEAR_TICK_INTERRUPT();\r
400 }\r
401 /*-----------------------------------------------------------*/\r
402 \r
403 void vPortTaskUsesFPU( void )\r
404 {\r
405 uint32_t ulInitialFPSCR = 0;\r
406 \r
407         /* A task is registering the fact that it needs an FPU context.  Set the\r
408         FPU flag (which is saved as part of the task context). */\r
409         ulPortTaskHasFPUContext = pdTRUE;\r
410 \r
411         /* Initialise the floating point status register. */\r
412         __asm( "FMXR    FPSCR, ulInitialFPSCR" );\r
413 }\r
414 /*-----------------------------------------------------------*/\r
415 \r
416 void vPortClearInterruptMask( uint32_t ulNewMaskValue )\r
417 {\r
418         if( ulNewMaskValue == pdFALSE )\r
419         {\r
420                 portCLEAR_INTERRUPT_MASK();\r
421         }\r
422 }\r
423 /*-----------------------------------------------------------*/\r
424 \r
425 uint32_t ulPortSetInterruptMask( void )\r
426 {\r
427 uint32_t ulReturn;\r
428 \r
429         __disable_irq();\r
430         if( portICCPMR_PRIORITY_MASK_REGISTER == ( configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT ) )\r
431         {\r
432                 /* Interrupts were already masked. */\r
433                 ulReturn = pdTRUE;\r
434         }\r
435         else\r
436         {\r
437                 ulReturn = pdFALSE;\r
438                 portICCPMR_PRIORITY_MASK_REGISTER = ( configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT );\r
439                 __asm(  "DSB            \n"\r
440                                 "ISB            \n" );\r
441         }\r
442         __enable_irq();\r
443 \r
444         return ulReturn;\r
445 }\r
446 /*-----------------------------------------------------------*/\r
447 \r
448 #if( configASSERT_DEFINED == 1 )\r
449 \r
450         void vPortValidateInterruptPriority( void )\r
451         {\r
452                 /* The following assertion will fail if a service routine (ISR) for\r
453                 an interrupt that has been assigned a priority above\r
454                 configMAX_SYSCALL_INTERRUPT_PRIORITY calls an ISR safe FreeRTOS API\r
455                 function.  ISR safe FreeRTOS API functions must *only* be called\r
456                 from interrupts that have been assigned a priority at or below\r
457                 configMAX_SYSCALL_INTERRUPT_PRIORITY.\r
458 \r
459                 Numerically low interrupt priority numbers represent logically high\r
460                 interrupt priorities, therefore the priority of the interrupt must\r
461                 be set to a value equal to or numerically *higher* than\r
462                 configMAX_SYSCALL_INTERRUPT_PRIORITY.\r
463 \r
464                 FreeRTOS maintains separate thread and ISR API functions to ensure\r
465                 interrupt entry is as fast and simple as possible.\r
466 \r
467                 The following links provide detailed information:\r
468                 http://www.freertos.org/RTOS-Cortex-M3-M4.html\r
469                 http://www.freertos.org/FAQHelp.html */\r
470                 configASSERT( portICCRPR_RUNNING_PRIORITY_REGISTER >= ( configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT ) );\r
471 \r
472                 /* Priority grouping:  The interrupt controller (GIC) allows the bits\r
473                 that define each interrupt's priority to be split between bits that\r
474                 define the interrupt's pre-emption priority bits and bits that define\r
475                 the interrupt's sub-priority.  For simplicity all bits must be defined\r
476                 to be pre-emption priority bits.  The following assertion will fail if\r
477                 this is not the case (if some bits represent a sub-priority).\r
478 \r
479                 The priority grouping is configured by the GIC's binary point register\r
480                 (ICCBPR).  Writting 0 to ICCBPR will ensure it is set to its lowest\r
481                 possible value (which may be above 0). */\r
482                 configASSERT( portICCBPR_BINARY_POINT_REGISTER <= portMAX_BINARY_POINT_VALUE );\r
483         }\r
484 \r
485 #endif /* configASSERT_DEFINED */\r
486 \r
487 \r
488 \r
489 \r