; Restore the context of the task selected to execute.\r
portRESTORE_CONTEXT\r
\r
-;-------------------------------------------------------------------------------\r
-\r
- .def ulPortCountLeadingZeros\r
-\r
-ulPortCountLeadingZeros:\r
-\r
- CLZ R0, R0\r
- BX LR\r
-\r
;-------------------------------------------------------------------------------\r
\r
.if (__TI_VFP_SUPPORT__)\r
/* Architecture specific optimisations. */\r
#if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1\r
\r
- /* Generic helper function. */\r
- unsigned long ulPortCountLeadingZeros( unsigned long ulBitmap );\r
-\r
/* Check the configuration. */\r
#if( configMAX_PRIORITIES > 32 )\r
#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
\r
/*-----------------------------------------------------------*/\r
\r
- #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31 - ulPortCountLeadingZeros( ( uxReadyPriorities ) ) )\r
+ #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31 - __clz( ( uxReadyPriorities ) ) )\r
\r
#endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */\r
\r
/*\r
FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd.\r
\r
- FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT \r
+ FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT\r
http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
\r
***************************************************************************\r
FreeRTOS WEB site.\r
\r
1 tab == 4 spaces!\r
- \r
+\r
***************************************************************************\r
* *\r
* Having a problem? Start by reading the FAQ "My application does *\r
* *\r
***************************************************************************\r
\r
- \r
- http://www.FreeRTOS.org - Documentation, training, latest versions, license \r
- and contact details. \r
- \r
+\r
+ http://www.FreeRTOS.org - Documentation, training, latest versions, license\r
+ and contact details.\r
+\r
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
including FreeRTOS+Trace - an indispensable productivity tool.\r
\r
- Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell \r
- the code with commercial support, indemnification, and middleware, under \r
+ Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell\r
+ the code with commercial support, indemnification, and middleware, under\r
the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also\r
- provide a safety engineered and independently SIL3 certified version under \r
+ provide a safety engineered and independently SIL3 certified version under\r
the SafeRTOS brand: http://www.SafeRTOS.com.\r
*/\r
\r
#define portTIMER_PRESCALE 8\r
#define portINITIAL_SR 0\r
\r
-/* Defined for backward compatability with project created prior to \r
+/* Defined for backward compatability with project created prior to\r
FreeRTOS.org V4.3.0. */\r
#ifndef configKERNEL_INTERRUPT_PRIORITY\r
#define configKERNEL_INTERRUPT_PRIORITY 1\r
\r
#ifdef MPLAB_PIC24_PORT\r
\r
- #define portRESTORE_CONTEXT() \\r
- asm volatile( "MOV _pxCurrentTCB, W0 \n" /* Restore the stack pointer for the task. */ \\r
- "MOV [W0], W15 \n" \\r
- "POP W0 \n" /* Restore the critical nesting counter for the task. */ \\r
- "MOV W0, _uxCriticalNesting \n" \\r
- "POP PSVPAG \n" \\r
- "POP CORCON \n" \\r
- "POP TBLPAG \n" \\r
- "POP RCOUNT \n" /* Restore the registers from the stack. */ \\r
- "POP W14 \n" \\r
- "POP.D W12 \n" \\r
- "POP.D W10 \n" \\r
- "POP.D W8 \n" \\r
- "POP.D W6 \n" \\r
- "POP.D W4 \n" \\r
- "POP.D W2 \n" \\r
- "POP.D W0 \n" \\r
- "POP SR " );\r
-\r
+ #ifdef __HAS_EDS__\r
+ #define portRESTORE_CONTEXT() \\r
+ asm volatile( "MOV _pxCurrentTCB, W0 \n" /* Restore the stack pointer for the task. */ \\r
+ "MOV [W0], W15 \n" \\r
+ "POP W0 \n" /* Restore the critical nesting counter for the task. */ \\r
+ "MOV W0, _uxCriticalNesting \n" \\r
+ "POP DSWPAG \n" \\r
+ "POP DSRPAG \n" \\r
+ "POP CORCON \n" \\r
+ "POP TBLPAG \n" \\r
+ "POP RCOUNT \n" /* Restore the registers from the stack. */ \\r
+ "POP W14 \n" \\r
+ "POP.D W12 \n" \\r
+ "POP.D W10 \n" \\r
+ "POP.D W8 \n" \\r
+ "POP.D W6 \n" \\r
+ "POP.D W4 \n" \\r
+ "POP.D W2 \n" \\r
+ "POP.D W0 \n" \\r
+ "POP SR " );\r
+ #else /* __HAS_EDS__ */\r
+ #define portRESTORE_CONTEXT() \\r
+ asm volatile( "MOV _pxCurrentTCB, W0 \n" /* Restore the stack pointer for the task. */ \\r
+ "MOV [W0], W15 \n" \\r
+ "POP W0 \n" /* Restore the critical nesting counter for the task. */ \\r
+ "MOV W0, _uxCriticalNesting \n" \\r
+ "POP PSVPAG \n" \\r
+ "POP CORCON \n" \\r
+ "POP TBLPAG \n" \\r
+ "POP RCOUNT \n" /* Restore the registers from the stack. */ \\r
+ "POP W14 \n" \\r
+ "POP.D W12 \n" \\r
+ "POP.D W10 \n" \\r
+ "POP.D W8 \n" \\r
+ "POP.D W6 \n" \\r
+ "POP.D W4 \n" \\r
+ "POP.D W2 \n" \\r
+ "POP.D W0 \n" \\r
+ "POP SR " );\r
+ #endif /* __HAS_EDS__ */\r
#endif /* MPLAB_PIC24_PORT */\r
\r
#ifdef MPLAB_DSPIC_PORT\r
*/\r
static void prvSetupTimerInterrupt( void );\r
\r
-/* \r
- * See header file for description. \r
+/*\r
+ * See header file for description.\r
*/\r
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )\r
{\r
unsigned short usCode;\r
portBASE_TYPE i;\r
\r
-const portSTACK_TYPE xInitialStack[] = \r
+const portSTACK_TYPE xInitialStack[] =\r
{\r
0x1111, /* W1 */\r
0x2222, /* W2 */\r
\r
*pxTopOfStack = CORCON;\r
pxTopOfStack++;\r
- *pxTopOfStack = PSVPAG;\r
- pxTopOfStack++;\r
+\r
+ #if defined(__HAS_EDS__)\r
+ *pxTopOfStack = DSRPAG;\r
+ pxTopOfStack++;\r
+ *pxTopOfStack = DSWPAG;\r
+ pxTopOfStack++;\r
+ #else /* __HAS_EDS__ */\r
+ *pxTopOfStack = PSVPAG;\r
+ pxTopOfStack++;\r
+ #endif /* __HAS_EDS__ */\r
\r
/* Finally the critical nesting depth. */\r
*pxTopOfStack = 0x00;\r
portBASE_TYPE xPortStartScheduler( void )\r
{\r
/* Setup a timer for the tick ISR. */\r
- prvSetupTimerInterrupt(); \r
+ prvSetupTimerInterrupt();\r
\r
/* Restore the context of the first task to run. */\r
portRESTORE_CONTEXT();\r
void vPortEndScheduler( void )\r
{\r
/* It is unlikely that the scheduler for the PIC port will get stopped\r
- once running. If required disable the tick interrupt here, then return \r
+ once running. If required disable the tick interrupt here, then return\r
to xPortStartScheduler(). */\r
}\r
/*-----------------------------------------------------------*/\r
/*\r
FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd.\r
\r
- FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT \r
+ FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT\r
http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
\r
***************************************************************************\r
FreeRTOS WEB site.\r
\r
1 tab == 4 spaces!\r
- \r
+\r
***************************************************************************\r
* *\r
* Having a problem? Start by reading the FAQ "My application does *\r
* *\r
***************************************************************************\r
\r
- \r
- http://www.FreeRTOS.org - Documentation, training, latest versions, license \r
- and contact details. \r
- \r
+\r
+ http://www.FreeRTOS.org - Documentation, training, latest versions, license\r
+ and contact details.\r
+\r
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
including FreeRTOS+Trace - an indispensable productivity tool.\r
\r
- Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell \r
- the code with commercial support, indemnification, and middleware, under \r
+ Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell\r
+ the code with commercial support, indemnification, and middleware, under\r
the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also\r
- provide a safety engineered and independently SIL3 certified version under \r
+ provide a safety engineered and independently SIL3 certified version under\r
the SafeRTOS brand: http://www.SafeRTOS.com.\r
*/\r
\r
PUSH W14\r
PUSH RCOUNT\r
PUSH TBLPAG\r
- \r
+\r
PUSH CORCON\r
- PUSH PSVPAG\r
+ #ifdef __HAS_EDS__\r
+ PUSH DSRPAG\r
+ PUSH DSWPAG\r
+ #else\r
+ PUSH PSVPAG\r
+ #endif /* __HAS_EDS__ */\r
MOV _uxCriticalNesting, W0 /* Save the critical nesting counter for the task. */\r
PUSH W0\r
MOV _pxCurrentTCB, W0 /* Save the new top of stack into the TCB. */\r
MOV [W0], W15\r
POP W0 /* Restore the critical nesting counter for the task. */\r
MOV W0, _uxCriticalNesting\r
+#ifdef __HAS_EDS__\r
+ POP DSWPAG\r
+ POP DSRPAG\r
+#else\r
POP PSVPAG\r
+#endif /* __HAS_EDS__ */\r
POP CORCON\r
POP TBLPAG\r
POP RCOUNT /* Restore the registers from the stack. */\r
\r
mtc0 k0, _CP0_STATUS\r
mtc0 k1, _CP0_EPC\r
- ehb\r
eret \r
nop\r
\r
/*\r
FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd.\r
\r
- FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT \r
+ FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT\r
http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
\r
***************************************************************************\r
FreeRTOS WEB site.\r
\r
1 tab == 4 spaces!\r
- \r
+\r
***************************************************************************\r
* *\r
* Having a problem? Start by reading the FAQ "My application does *\r
* *\r
***************************************************************************\r
\r
- \r
- http://www.FreeRTOS.org - Documentation, training, latest versions, license \r
- and contact details. \r
- \r
+\r
+ http://www.FreeRTOS.org - Documentation, training, latest versions, license\r
+ and contact details.\r
+\r
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
including FreeRTOS+Trace - an indispensable productivity tool.\r
\r
- Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell \r
- the code with commercial support, indemnification, and middleware, under \r
+ Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell\r
+ the code with commercial support, indemnification, and middleware, under\r
the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also\r
- provide a safety engineered and independently SIL3 certified version under \r
+ provide a safety engineered and independently SIL3 certified version under\r
the SafeRTOS brand: http://www.SafeRTOS.com.\r
*/\r
- \r
+\r
#include <p32xxxx.h>\r
#include <sys/asm.h>\r
#include "ISR_Support.h"\r
- \r
+\r
\r
.set nomips16\r
.set noreorder\r
- \r
+\r
.extern pxCurrentTCB\r
.extern vTaskSwitchContext\r
.extern vPortIncrementTick\r
.extern xISRStackTop\r
- \r
+\r
.global vPortStartFirstTask\r
.global vPortYieldISR\r
.global vPortTickInterruptHandler\r
.set noreorder\r
.set noat\r
.ent vPortTickInterruptHandler\r
- \r
+\r
vPortTickInterruptHandler:\r
\r
portSAVE_CONTEXT\r
\r
vPortYieldISR:\r
\r
- /* Make room for the context. First save the current status so we can \r
- manipulate it, and the cause and EPC registers so we capture their \r
+ /* Make room for the context. First save the current status so we can\r
+ manipulate it, and the cause and EPC registers so we capture their\r
original values in case of interrupt nesting. */\r
mfc0 k0, _CP0_CAUSE\r
addiu sp, sp, -portCONTEXT_SIZE\r
ins s7, $0, 10, 6\r
ori s6, s7, ( configMAX_SYSCALL_INTERRUPT_PRIORITY << 10 ) | 1\r
\r
- /* This mtc0 re-enables interrupts, but only above \r
+ /* This mtc0 re-enables interrupts, but only above\r
configMAX_SYSCALL_INTERRUPT_PRIORITY. */\r
mtc0 s6, _CP0_STATUS\r
\r
/* Clear the software interrupt in the core. */\r
mfc0 s6, _CP0_CAUSE\r
- addiu s4,zero,-257\r
- and s6, s6, s4\r
+ ins s6, zero, 8, 1\r
mtc0 s6, _CP0_CAUSE\r
\r
/* Clear the interrupt in the interrupt controller. */\r
/* Remove stack frame. */\r
addiu sp, sp, portCONTEXT_SIZE\r
\r
- mtc0 k1, _CP0_STATUS \r
+ mtc0 k1, _CP0_STATUS\r
mtc0 k0, _CP0_EPC\r
- ehb\r
- eret \r
+ eret\r
nop\r
\r
.end vPortYieldISR\r