]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/GCC/ARM_CA9/port.c
Carry on working on the Cortex-A/GCC port layer - still a work in progress.
[freertos] / FreeRTOS / Source / portable / GCC / 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 configINSTALL_FREERTOS_VECTOR_TABLE\r
114         #warning configINSTALL_FREERTOS_VECTOR_TABLE was undefined.  Defaulting configINSTALL_FREERTOS_VECTOR_TABLE to 0.\r
115 #endif\r
116 \r
117 /* A critical section is exited when the critical section nesting count reaches\r
118 this value. */\r
119 #define portNO_CRITICAL_NESTING                 ( ( uint32_t ) 0 )\r
120 \r
121 /* In all GICs 255 can be written to the priority mask register to unmask all\r
122 (but the lowest) interrupt priority. */\r
123 #define portUNMASK_VALUE                                ( 0xFF )\r
124 \r
125 /* Tasks are not created with a floating point context, but can be given a\r
126 floating point context after they have been created.  A variable is stored as\r
127 part of the tasks context that holds portNO_FLOATING_POINT_CONTEXT if the task\r
128 does not have an FPU context, or any other value if the task does have an FPU\r
129 context. */\r
130 #define portNO_FLOATING_POINT_CONTEXT   ( ( StackType_t ) 0 )\r
131 \r
132 /* Constants required to setup the initial task context. */\r
133 #warning FIQ is disabled\r
134 #define portINITIAL_SPSR                                ( ( StackType_t ) 0x5f ) /* System mode, ARM mode, IRQ enabled FIQ disabled.  1f is required to enable FIQ. */\r
135 #define portTHUMB_MODE_BIT                              ( ( StackType_t ) 0x20 )\r
136 #define portINTERRUPT_ENABLE_BIT                ( 0x80UL )\r
137 #define portTHUMB_MODE_ADDRESS                  ( 0x01UL )\r
138 \r
139 /* Used by portASSERT_IF_INTERRUPT_PRIORITY_INVALID() when ensuring the binary\r
140 point is zero. */\r
141 #define portBINARY_POINT_BITS                   ( ( uint8_t ) 0x03 )\r
142 \r
143 /* Masks all bits in the APSR other than the mode bits. */\r
144 #define portAPSR_MODE_BITS_MASK                 ( 0x1F )\r
145 \r
146 /* The value of the mode bits in the APSR when the CPU is executing in user\r
147 mode. */\r
148 #define portAPSR_USER_MODE                              ( 0x10 )\r
149 \r
150 /* Macro to unmask all interrupt priorities. */\r
151 #define portCLEAR_INTERRUPT_MASK()                                                                                      \\r
152 {                                                                                                                                                       \\r
153         __asm volatile ( "cpsid i" );                                                                                   \\r
154         __asm volatile ( "dsb" );                                                                                               \\r
155         __asm volatile ( "isb" );                                                                                               \\r
156         portICCPMR_PRIORITY_MASK_REGISTER = portUNMASK_VALUE;                                   \\r
157         __asm(  "DSB            \n"                                                                                                     \\r
158                         "ISB            \n" );                                                                                          \\r
159         __asm volatile( "cpsie i" );                                                                                    \\r
160         __asm volatile ( "dsb" );                                                                                               \\r
161         __asm volatile ( "isb" );                                                                                               \\r
162 }\r
163 \r
164 #define portINTERRUPT_PRIORITY_REGISTER_OFFSET          0x400UL\r
165 #define portMAX_8_BIT_VALUE                                                     ( ( uint8_t ) 0xff )\r
166 #define portBIT_0_SET                                                           ( ( uint8_t ) 0x01 )\r
167 \r
168 /*-----------------------------------------------------------*/\r
169 \r
170 /*\r
171  * Starts the first task executing.  This function is necessarily written in\r
172  * assembly code so is implemented in portASM.s.\r
173  */\r
174 extern void vPortRestoreTaskContext( void );\r
175 \r
176 /*-----------------------------------------------------------*/\r
177 \r
178 /* A variable is used to keep track of the critical section nesting.  This\r
179 variable has to be stored as part of the task context and must be initialised to\r
180 a non zero value to ensure interrupts don't inadvertently become unmasked before\r
181 the scheduler starts.  As it is stored as part of the task context it will\r
182 automatically be set to 0 when the first task is started. */\r
183 volatile uint32_t ulCriticalNesting = 9999UL;\r
184 \r
185 /* Saved as part of the task context.  If ulPortTaskHasFPUContext is non-zero then\r
186 a floating point context must be saved and restored for the task. */\r
187 uint32_t ulPortTaskHasFPUContext = pdFALSE;\r
188 \r
189 /* Set to 1 to pend a context switch from an ISR. */\r
190 uint32_t ulPortYieldRequired = pdFALSE;\r
191 \r
192 /* Counts the interrupt nesting depth.  A context switch is only performed if\r
193 if the nesting depth is 0. */\r
194 uint32_t ulPortInterruptNesting = 0UL;\r
195 \r
196 __attribute__(( used )) const uint32_t ulICCIAR = portICCIAR_INTERRUPT_ACKNOWLEDGE_REGISTER_ADDRESS;\r
197 __attribute__(( used )) const uint32_t ulICCEOIR = portICCEOIR_END_OF_INTERRUPT_REGISTER_ADDRESS;\r
198 __attribute__(( used )) const uint32_t ulICCPMR = portICCPMR_PRIORITY_MASK_REGISTER_ADDRESS;\r
199 __attribute__(( used )) const uint32_t ulMaxAPIPriorityMask = ( configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT );\r
200 \r
201 /*-----------------------------------------------------------*/\r
202 \r
203 /*\r
204  * See header file for description.\r
205  */\r
206 StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters )\r
207 {\r
208         /* Setup the initial stack of the task.  The stack is set exactly as\r
209         expected by the portRESTORE_CONTEXT() macro.\r
210 \r
211         The fist real value on the stack is the status register, which is set for\r
212         system mode, with interrupts enabled.  A few NULLs are added first to ensure\r
213         GDB does not try decoding a non-existent return address. */\r
214         *pxTopOfStack = ( StackType_t ) NULL;\r
215         pxTopOfStack--;\r
216         *pxTopOfStack = ( StackType_t ) NULL;\r
217         pxTopOfStack--;\r
218         *pxTopOfStack = ( StackType_t ) NULL;\r
219         pxTopOfStack--;\r
220         *pxTopOfStack = ( StackType_t ) portINITIAL_SPSR;\r
221 \r
222         if( ( ( uint32_t ) pxCode & portTHUMB_MODE_ADDRESS ) != 0x00UL )\r
223         {\r
224                 /* The task will start in THUMB mode. */\r
225                 *pxTopOfStack |= portTHUMB_MODE_BIT;\r
226         }\r
227 \r
228         pxTopOfStack--;\r
229 \r
230         /* Next the return address, which in this case is the start of the task. */\r
231         *pxTopOfStack = ( StackType_t ) pxCode;\r
232         pxTopOfStack--;\r
233 \r
234         /* Next all the registers other than the stack pointer. */\r
235         *pxTopOfStack = ( StackType_t ) 0x00000000;     /* R14 */\r
236         pxTopOfStack--;\r
237         *pxTopOfStack = ( StackType_t ) 0x12121212;     /* R12 */\r
238         pxTopOfStack--;\r
239         *pxTopOfStack = ( StackType_t ) 0x11111111;     /* R11 */\r
240         pxTopOfStack--;\r
241         *pxTopOfStack = ( StackType_t ) 0x10101010;     /* R10 */\r
242         pxTopOfStack--;\r
243         *pxTopOfStack = ( StackType_t ) 0x09090909;     /* R9 */\r
244         pxTopOfStack--;\r
245         *pxTopOfStack = ( StackType_t ) 0x08080808;     /* R8 */\r
246         pxTopOfStack--;\r
247         *pxTopOfStack = ( StackType_t ) 0x07070707;     /* R7 */\r
248         pxTopOfStack--;\r
249         *pxTopOfStack = ( StackType_t ) 0x06060606;     /* R6 */\r
250         pxTopOfStack--;\r
251         *pxTopOfStack = ( StackType_t ) 0x05050505;     /* R5 */\r
252         pxTopOfStack--;\r
253         *pxTopOfStack = ( StackType_t ) 0x04040404;     /* R4 */\r
254         pxTopOfStack--;\r
255         *pxTopOfStack = ( StackType_t ) 0x03030303;     /* R3 */\r
256         pxTopOfStack--;\r
257         *pxTopOfStack = ( StackType_t ) 0x02020202;     /* R2 */\r
258         pxTopOfStack--;\r
259         *pxTopOfStack = ( StackType_t ) 0x01010101;     /* R1 */\r
260         pxTopOfStack--;\r
261         *pxTopOfStack = ( StackType_t ) pvParameters; /* R0 */\r
262         pxTopOfStack--;\r
263 \r
264         /* The task will start with a critical nesting count of 0 as interrupts are\r
265         enabled. */\r
266         *pxTopOfStack = portNO_CRITICAL_NESTING;\r
267         pxTopOfStack--;\r
268 \r
269         /* The task will start without a floating point context.  A task that uses\r
270         the floating point hardware must call vPortTaskUsesFPU() before executing\r
271         any floating point instructions. */\r
272         *pxTopOfStack = portNO_FLOATING_POINT_CONTEXT;\r
273 \r
274         return pxTopOfStack;\r
275 }\r
276 /*-----------------------------------------------------------*/\r
277 \r
278 BaseType_t xPortStartScheduler( void )\r
279 {\r
280 uint32_t ulAPSR;\r
281 \r
282         #if( configASSERT_DEFINED == 1 )\r
283         {\r
284                 volatile uint32_t ulOriginalPriority;\r
285                 volatile uint8_t * const pucFirstUserPriorityRegister = ( volatile uint8_t * const ) ( configINTERRUPT_CONTROLLER_BASE_ADDRESS + portINTERRUPT_PRIORITY_REGISTER_OFFSET );\r
286                 volatile uint8_t ucMaxPriorityValue;\r
287 \r
288                 /* Determine how many priority bits are implemented in the GIC.\r
289 \r
290                 Save the interrupt priority value that is about to be clobbered. */\r
291                 ulOriginalPriority = *pucFirstUserPriorityRegister;\r
292 \r
293                 /* Determine the number of priority bits available.  First write to\r
294                 all possible bits. */\r
295                 *pucFirstUserPriorityRegister = portMAX_8_BIT_VALUE;\r
296 \r
297                 /* Read the value back to see how many bits stuck. */\r
298                 ucMaxPriorityValue = *pucFirstUserPriorityRegister;\r
299 \r
300                 /* Shift to the least significant bits. */\r
301                 while( ( ucMaxPriorityValue & portBIT_0_SET ) != portBIT_0_SET )\r
302                 {\r
303                         ucMaxPriorityValue >>= ( uint8_t ) 0x01;\r
304                 }\r
305 \r
306                 /* Sanity check configUNIQUE_INTERRUPT_PRIORITIES matches the read\r
307                 value. */\r
308                 configASSERT( ucMaxPriorityValue == portLOWEST_INTERRUPT_PRIORITY );\r
309 \r
310                 /* Restore the clobbered interrupt priority register to its original\r
311                 value. */\r
312                 *pucFirstUserPriorityRegister = ulOriginalPriority;\r
313         }\r
314         #endif /* conifgASSERT_DEFINED */\r
315 \r
316 \r
317         /* Only continue if the CPU is not in User mode.  The CPU must be in a\r
318         Privileged mode for the scheduler to start. */\r
319         __asm volatile ( "MRS %0, APSR" : "=r" ( ulAPSR ) );\r
320         ulAPSR &= portAPSR_MODE_BITS_MASK;\r
321         configASSERT( ulAPSR != portAPSR_USER_MODE );\r
322 \r
323         #if configINSTALL_FREERTOS_VECTOR_TABLE == 1\r
324         {\r
325                 vPortInstallFreeRTOSVectorTable();\r
326         }\r
327         #endif\r
328 \r
329 \r
330         if( ulAPSR != portAPSR_USER_MODE )\r
331         {\r
332                 /* Only continue if the binary point value is set to its lowest possible\r
333                 setting.  See the comments in vPortValidateInterruptPriority() below for\r
334                 more information. */\r
335                 configASSERT( ( portICCBPR_BINARY_POINT_REGISTER & portBINARY_POINT_BITS ) <= portMAX_BINARY_POINT_VALUE );\r
336 \r
337                 if( ( portICCBPR_BINARY_POINT_REGISTER & portBINARY_POINT_BITS ) <= portMAX_BINARY_POINT_VALUE )\r
338                 {\r
339                         /* Start the timer that generates the tick ISR. */\r
340                         configSETUP_TICK_INTERRUPT();\r
341 \r
342 //                      __asm volatile( "cpsie i" );\r
343                         vPortRestoreTaskContext();\r
344                 }\r
345         }\r
346 \r
347         /* Will only get here if xTaskStartScheduler() was called with the CPU in\r
348         a non-privileged mode or the binary point register was not set to its lowest\r
349         possible value. */\r
350         return 0;\r
351 }\r
352 /*-----------------------------------------------------------*/\r
353 \r
354 void vPortEndScheduler( void )\r
355 {\r
356         /* Not implemented in ports where there is nothing to return to.\r
357         Artificially force an assert. */\r
358         configASSERT( ulCriticalNesting == 1000UL );\r
359 }\r
360 /*-----------------------------------------------------------*/\r
361 \r
362 void vPortEnterCritical( void )\r
363 {\r
364         /* Disable interrupts as per portDISABLE_INTERRUPTS();  */\r
365         ulPortSetInterruptMask();\r
366 \r
367         /* Now interrupts are disabled ulCriticalNesting can be accessed\r
368         directly.  Increment ulCriticalNesting to keep a count of how many times\r
369         portENTER_CRITICAL() has been called. */\r
370         ulCriticalNesting++;\r
371 }\r
372 /*-----------------------------------------------------------*/\r
373 \r
374 void vPortExitCritical( void )\r
375 {\r
376         if( ulCriticalNesting > portNO_CRITICAL_NESTING )\r
377         {\r
378                 /* Decrement the nesting count as the critical section is being\r
379                 exited. */\r
380                 ulCriticalNesting--;\r
381 \r
382                 /* If the nesting level has reached zero then all interrupt\r
383                 priorities must be re-enabled. */\r
384                 if( ulCriticalNesting == portNO_CRITICAL_NESTING )\r
385                 {\r
386                         /* Critical nesting has reached zero so all interrupt priorities\r
387                         should be unmasked. */\r
388                         portCLEAR_INTERRUPT_MASK();\r
389                 }\r
390         }\r
391 }\r
392 /*-----------------------------------------------------------*/\r
393 \r
394 void FreeRTOS_Tick_Handler( void )\r
395 {\r
396         /* Set interrupt mask before altering scheduler structures.   The tick\r
397         handler runs at the lowest priority, so interrupts cannot already be masked,\r
398         so there is no need to save and restore the current mask value. */\r
399         __asm volatile( "cpsid i" );\r
400         __asm volatile ( "dsb" );\r
401         __asm volatile ( "isb" );\r
402         portICCPMR_PRIORITY_MASK_REGISTER = ( configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT );\r
403         __asm(  "dsb            \n"\r
404                         "isb            \n"\r
405                         "cpsie i        \n"\r
406                         "dsb            \n"\r
407                         "isb" );\r
408 \r
409         /* Increment the RTOS tick. */\r
410         if( xTaskIncrementTick() != pdFALSE )\r
411         {\r
412                 ulPortYieldRequired = pdTRUE;\r
413         }\r
414 \r
415         /* Ensure all interrupt priorities are active again. */\r
416         portCLEAR_INTERRUPT_MASK();\r
417 }\r
418 /*-----------------------------------------------------------*/\r
419 \r
420 void vPortTaskUsesFPU( void )\r
421 {\r
422 uint32_t ulInitialFPSCR = 0;\r
423 \r
424         /* A task is registering the fact that it needs an FPU context.  Set the\r
425         FPU flag (which is saved as part of the task context). */\r
426         ulPortTaskHasFPUContext = pdTRUE;\r
427 \r
428         /* Initialise the floating point status register. */\r
429         __asm( "FMXR    FPSCR, %0" :: "r" (ulInitialFPSCR) );\r
430 }\r
431 /*-----------------------------------------------------------*/\r
432 \r
433 void vPortClearInterruptMask( uint32_t ulNewMaskValue )\r
434 {\r
435         if( ulNewMaskValue == pdFALSE )\r
436         {\r
437                 portCLEAR_INTERRUPT_MASK();\r
438         }\r
439 }\r
440 /*-----------------------------------------------------------*/\r
441 \r
442 uint32_t ulPortSetInterruptMask( void )\r
443 {\r
444 uint32_t ulReturn;\r
445 \r
446         __asm volatile ( "cpsid i" );\r
447         __asm volatile ( "dsb" );\r
448         __asm volatile ( "isb" );\r
449         if( portICCPMR_PRIORITY_MASK_REGISTER == ( configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT ) )\r
450         {\r
451                 /* Interrupts were already masked. */\r
452                 ulReturn = pdTRUE;\r
453         }\r
454         else\r
455         {\r
456                 ulReturn = pdFALSE;\r
457                 portICCPMR_PRIORITY_MASK_REGISTER = ( configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT );\r
458                 __asm(  "dsb            \n"\r
459                                 "isb            \n" );\r
460         }\r
461         __asm volatile ( "cpsie i" );\r
462         __asm volatile ( "dsb" );\r
463         __asm volatile ( "isb" );\r
464 \r
465         return ulReturn;\r
466 }\r
467 /*-----------------------------------------------------------*/\r
468 \r
469 #if( configASSERT_DEFINED == 1 )\r
470 \r
471         void vPortValidateInterruptPriority( void )\r
472         {\r
473                 /* The following assertion will fail if a service routine (ISR) for\r
474                 an interrupt that has been assigned a priority above\r
475                 configMAX_SYSCALL_INTERRUPT_PRIORITY calls an ISR safe FreeRTOS API\r
476                 function.  ISR safe FreeRTOS API functions must *only* be called\r
477                 from interrupts that have been assigned a priority at or below\r
478                 configMAX_SYSCALL_INTERRUPT_PRIORITY.\r
479 \r
480                 Numerically low interrupt priority numbers represent logically high\r
481                 interrupt priorities, therefore the priority of the interrupt must\r
482                 be set to a value equal to or numerically *higher* than\r
483                 configMAX_SYSCALL_INTERRUPT_PRIORITY.\r
484 \r
485                 FreeRTOS maintains separate thread and ISR API functions to ensure\r
486                 interrupt entry is as fast and simple as possible.\r
487 \r
488                 The following links provide detailed information:\r
489                 http://www.freertos.org/RTOS-Cortex-M3-M4.html\r
490                 http://www.freertos.org/FAQHelp.html */\r
491                 configASSERT( portICCRPR_RUNNING_PRIORITY_REGISTER >= ( configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT ) );\r
492 \r
493                 /* Priority grouping:  The interrupt controller (GIC) allows the bits\r
494                 that define each interrupt's priority to be split between bits that\r
495                 define the interrupt's pre-emption priority bits and bits that define\r
496                 the interrupt's sub-priority.  For simplicity all bits must be defined\r
497                 to be pre-emption priority bits.  The following assertion will fail if\r
498                 this is not the case (if some bits represent a sub-priority).\r
499 \r
500                 The priority grouping is configured by the GIC's binary point register\r
501                 (ICCBPR).  Writting 0 to ICCBPR will ensure it is set to its lowest\r
502                 possible value (which may be above 0). */\r
503                 configASSERT( ( portICCBPR_BINARY_POINT_REGISTER & portBINARY_POINT_BITS ) <= portMAX_BINARY_POINT_VALUE );\r
504         }\r
505 \r
506 #endif /* configASSERT_DEFINED */\r
507 /*-----------------------------------------------------------*/\r
508 \r