#include <xtmrctr.h>\r
#include <xil_exception.h>\r
\r
-/* Tasks are started with interrupts enabled. */\r
-#define portINITIAL_MSR_STATE ( ( portSTACK_TYPE ) 0x02 )\r
+/* Tasks are started with interrupts disabled as they will have their interrupts\r
+enabled as the task starts (when its context is restored for the first time). */\r
+#define portINITIAL_MSR_STATE ( ( portSTACK_TYPE ) 0x00 )\r
\r
/* Tasks are started with a critical section nesting of 0 - however prior\r
to the scheduler being commenced we don't want the critical nesting level\r
\r
/* To limit the amount of stack required by each task, this port uses a\r
separate stack for interrupts. */\r
-unsigned long ulISRStack;\r
-unsigned long *pulISRStack = &ulISRStack;\r
+unsigned long *pulISRStack;\r
\r
/* The instance of the interrupt controller used by this port. */\r
static XIntc xInterruptControllerInstance;\r
*pxTopOfStack = ( portSTACK_TYPE ) 0x33333333;\r
pxTopOfStack--; \r
\r
+ /* The debugger will look at the previous stack frame. */\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0x00000000;\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0x00000000;\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0x00000000;\r
+ pxTopOfStack--;\r
+\r
/* First stack an initial value for the critical section nesting. This\r
- is initialised to zero as tasks are started with interrupts enabled. */\r
- *pxTopOfStack = ( portSTACK_TYPE ) 0x00; /* R0 is always zero. */\r
+ is initialised to zero. */\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0x00;\r
\r
+ /* R0 is always zero. */\r
/* R1 is the SP. */\r
\r
/* Place an initial value for all the general purpose registers. */\r
pxTopOfStack--;\r
*pxTopOfStack = ( portSTACK_TYPE ) pvParameters;/* R5 contains the function call parameters. */\r
pxTopOfStack--;\r
- *pxTopOfStack = ( portSTACK_TYPE ) 0x06; /* R6 - other parameters and temporaries. */\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0x06; /* R6 - other parameters and temporaries. Used as the return address from vPortTaskEntryPoint. */\r
pxTopOfStack--;\r
*pxTopOfStack = ( portSTACK_TYPE ) 0x07; /* R7 - other parameters and temporaries. */\r
pxTopOfStack--;\r
pxTopOfStack--;\r
*pxTopOfStack = ( portSTACK_TYPE ) 0x12; /* R18 - reserved for assembler and compiler temporaries. */\r
pxTopOfStack--;\r
- *pxTopOfStack = ( portSTACK_TYPE ) 0x13; /* R19 - must be saved across function calls. Callee-save. */\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0x00; /* R19 - must be saved across function calls. Callee-save. Seems to be interpreted as the frame pointer. */\r
pxTopOfStack--;\r
*pxTopOfStack = ( portSTACK_TYPE ) 0x14; /* R20 - reserved for storing a pointer to the Global Offset Table (GOT) in Position Independent Code (PIC). Non-volatile in non-PIC code. Must be saved across function calls. Callee-save. Not used by FreeRTOS. */\r
pxTopOfStack--;\r
this function is called. */\r
vApplicationSetupTimerInterrupt();\r
\r
- /* Allocate the stack to be used by the interrupt handler. */\r
+ /* Reuse the stack from main as the stack for the interrupts/exceptions.\r
+ The value is adjusted slightly to allow functions called from the\r
+ interrupts/exceptions to write back into the stack of the interrupt/\r
+ exception function itself. */\r
pulISRStack = ( unsigned long * ) _stack;\r
- pulISRStack--;\r
+ pulISRStack -= 2;\r
\r
/* Restore the context of the first task that is going to run. From here\r
on, the created tasks will be executing. */\r