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