ThirdParty/bsp/freertos10_xilinx/src/Source/portable/GCC/MicroBlazeV9/port.c
StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters )
{
extern void *_SDA2_BASE_, *_SDA_BASE_;
const UINTPTR ulR2 = ( UINTPTR ) &_SDA2_BASE_;
const UINTPTR ulR13 = ( UINTPTR ) &_SDA_BASE_;
extern void _start1( void );

	/* Place a few bytes of known values on the bottom of the stack.
	This is essential for the Microblaze port and these lines must
	not be omitted. */
	*pxTopOfStack = ( StackType_t ) 0x00000000;
	pxTopOfStack--;
	*pxTopOfStack = ( StackType_t ) 0x00000000;
	pxTopOfStack--;
	*pxTopOfStack = ( StackType_t ) 0x00000000;
	pxTopOfStack--;

	#if( XPAR_MICROBLAZE_USE_FPU != 0 )
		/* The FSR value placed in the initial task context is just 0. */
		*pxTopOfStack = portINITIAL_FSR;
		pxTopOfStack--;
	#endif

	/* The MSR value placed in the initial task context should have interrupts
	disabled.  Each task will enable interrupts automatically when it enters
	the running state for the first time. */
	*pxTopOfStack = mfmsr() & ~portMSR_IE;

	#if( MICROBLAZE_EXCEPTIONS_ENABLED == 1 )
	{
		/* Ensure exceptions are enabled for the task. */
		*pxTopOfStack |= portMSR_EE;
	}
	#endif

	pxTopOfStack--;

	/* First stack an initial value for the critical section nesting.  This
	is initialised to zero. */
	*pxTopOfStack = ( StackType_t ) 0x00;

	/* R0 is always zero. */
	/* R1 is the SP. */

	/* Place an initial value for all the general purpose registers. */
	pxTopOfStack--;
	*pxTopOfStack = ( StackType_t ) ulR2;	/* R2 - read only small data area. */
	pxTopOfStack--;
	*pxTopOfStack = ( StackType_t ) 0x03;	/* R3 - return values and temporaries. */
	pxTopOfStack--;
	*pxTopOfStack = ( StackType_t ) 0x04;	/* R4 - return values and temporaries. */
	pxTopOfStack--;
	*pxTopOfStack = ( StackType_t ) pvParameters;/* R5 contains the function call parameters. */

	#ifdef portPRE_LOAD_STACK_FOR_DEBUGGING
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x06;	/* R6 - other parameters and temporaries. */
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x07;	/* R7 - other parameters and temporaries. */
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) NULL;	/* R8 - other parameters and temporaries. */
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x09;	/* R9 - other parameters and temporaries. */
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x0a;	/* R10 - other parameters and temporaries. */
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x0b;	/* R11 - temporaries. */
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x0c;	/* R12 - temporaries. */
		pxTopOfStack--;
	#else
		pxTopOfStack-= 8;
	#endif

	*pxTopOfStack = ( StackType_t ) ulR13;	/* R13 - read/write small data area. */
	pxTopOfStack--;
	*pxTopOfStack = ( StackType_t ) pxCode;	/* R14 - return address for interrupt. */
	pxTopOfStack--;
	*pxTopOfStack = ( StackType_t ) portTASK_RETURN_ADDRESS;	/* R15 - return address for subroutine. */

	#ifdef portPRE_LOAD_STACK_FOR_DEBUGGING
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x10;	/* R16 - return address for trap (debugger). */
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x11;	/* R17 - return address for exceptions, if configured. */
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x12;	/* R18 - reserved for assembler and compiler temporaries. */
		pxTopOfStack--;
	#else
		pxTopOfStack -= 4;
	#endif

	*pxTopOfStack = ( StackType_t ) 0x00;	/* R19 - must be saved across function calls. Callee-save.  Seems to be interpreted as the frame pointer. */

	#ifdef portPRE_LOAD_STACK_FOR_DEBUGGING
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 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. */
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x15;	/* R21 - must be saved across function calls. Callee-save. */
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x16;	/* R22 - must be saved across function calls. Callee-save. */
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x17;	/* R23 - must be saved across function calls. Callee-save. */
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x18;	/* R24 - must be saved across function calls. Callee-save. */
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x19;	/* R25 - must be saved across function calls. Callee-save. */
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x1a;	/* R26 - must be saved across function calls. Callee-save. */
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x1b;	/* R27 - must be saved across function calls. Callee-save. */
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x1c;	/* R28 - must be saved across function calls. Callee-save. */
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x1d;	/* R29 - must be saved across function calls. Callee-save. */
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x1e;	/* R30 - must be saved across function calls. Callee-save. */
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x1f;	/* R31 - must be saved across function calls. Callee-save. */
		pxTopOfStack--;
	#else
		pxTopOfStack -= 13;
	#endif

	/* Return a pointer to the top of the stack that has been generated so this
	can	be stored in the task control block for the task. */
	return pxTopOfStack;
}
/*
 * Initialise the stack of a task to look exactly as if a call to
 * portSAVE_CONTEXT had been made.
 *
 * See the portable.h header file.
 */
Initialise the stack of a task to look exactly as if a call to
portSAVE_CONTEXT had been made.

See the portable.h header file.
Initialise the stack of a task to look exactly as if a call to portSAVE_CONTEXT had been made . See the portable . h header file .
StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters )
{
extern void *_SDA2_BASE_, *_SDA_BASE_;
const UINTPTR ulR2 = ( UINTPTR ) &_SDA2_BASE_;
const UINTPTR ulR13 = ( UINTPTR ) &_SDA_BASE_;
extern void _start1( void );
	*pxTopOfStack = ( StackType_t ) 0x00000000;
	pxTopOfStack--;
	*pxTopOfStack = ( StackType_t ) 0x00000000;
	pxTopOfStack--;
	*pxTopOfStack = ( StackType_t ) 0x00000000;
	pxTopOfStack--;
	#if( XPAR_MICROBLAZE_USE_FPU != 0 )
		*pxTopOfStack = portINITIAL_FSR;
		pxTopOfStack--;
	#endif
	*pxTopOfStack = mfmsr() & ~portMSR_IE;
	#if( MICROBLAZE_EXCEPTIONS_ENABLED == 1 )
	{
		*pxTopOfStack |= portMSR_EE;
	}
	#endif
	pxTopOfStack--;
	*pxTopOfStack = ( StackType_t ) 0x00;
	pxTopOfStack--;
	*pxTopOfStack = ( StackType_t ) ulR2;	
	pxTopOfStack--;
	*pxTopOfStack = ( StackType_t ) 0x03;	
	pxTopOfStack--;
	*pxTopOfStack = ( StackType_t ) 0x04;	
	pxTopOfStack--;
	*pxTopOfStack = ( StackType_t ) pvParameters;
	#ifdef portPRE_LOAD_STACK_FOR_DEBUGGING
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x06;	
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x07;	
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) NULL;	
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x09;	
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x0a;	
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x0b;	
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x0c;	
		pxTopOfStack--;
	#else
		pxTopOfStack-= 8;
	#endif
	*pxTopOfStack = ( StackType_t ) ulR13;	
	pxTopOfStack--;
	*pxTopOfStack = ( StackType_t ) pxCode;	
	pxTopOfStack--;
	*pxTopOfStack = ( StackType_t ) portTASK_RETURN_ADDRESS;	
	#ifdef portPRE_LOAD_STACK_FOR_DEBUGGING
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x10;	
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x11;	
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x12;	
		pxTopOfStack--;
	#else
		pxTopOfStack -= 4;
	#endif
	*pxTopOfStack = ( StackType_t ) 0x00;	
	#ifdef portPRE_LOAD_STACK_FOR_DEBUGGING
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x14;	
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x15;	
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x16;	
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x17;	
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x18;	
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x19;	
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x1a;	
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x1b;	
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x1c;	
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x1d;	
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x1e;	
		pxTopOfStack--;
		*pxTopOfStack = ( StackType_t ) 0x1f;	
		pxTopOfStack--;
	#else
		pxTopOfStack -= 13;
	#endif
	return pxTopOfStack;
}
StackType_t * pxPortInitialiseStack ( StackType_t * pxTopOfStack , TaskFunction_t pxCode , void * pvParameters ) { extern void * _SDA2_BASE_ , * _SDA_BASE_ ; const UINTPTR ulR2 = ( UINTPTR ) & _SDA2_BASE_ ; const UINTPTR ulR13 = ( UINTPTR ) & _SDA_BASE_ ; extern void _start1 ( void ) ; * pxTopOfStack = ( StackType_t ) 0x00000000 ; pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) 0x00000000 ; pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) 0x00000000 ; pxTopOfStack -- ; #if ( XPAR_MICROBLAZE_USE_FPU != 0 ) * pxTopOfStack = portINITIAL_FSR ; pxTopOfStack -- ; #endif * pxTopOfStack = mfmsr ( ) & ~ portMSR_IE ; #if ( MICROBLAZE_EXCEPTIONS_ENABLED == 1 ) { * pxTopOfStack |= portMSR_EE ; } #endif pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) 0x00 ; pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) ulR2 ; pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) 0x03 ; pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) 0x04 ; pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) pvParameters ; #ifdef portPRE_LOAD_STACK_FOR_DEBUGGING pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) 0x06 ; pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) 0x07 ; pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) NULL ; pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) 0x09 ; pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) 0x0a ; pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) 0x0b ; pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) 0x0c ; pxTopOfStack -- ; #else pxTopOfStack -= 8 ; #endif * pxTopOfStack = ( StackType_t ) ulR13 ; pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) pxCode ; pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) portTASK_RETURN_ADDRESS ; #ifdef portPRE_LOAD_STACK_FOR_DEBUGGING pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) 0x10 ; pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) 0x11 ; pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) 0x12 ; pxTopOfStack -- ; #else pxTopOfStack -= 4 ; #endif * pxTopOfStack = ( StackType_t ) 0x00 ; #ifdef portPRE_LOAD_STACK_FOR_DEBUGGING pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) 0x14 ; pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) 0x15 ; pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) 0x16 ; pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) 0x17 ; pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) 0x18 ; pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) 0x19 ; pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) 0x1a ; pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) 0x1b ; pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) 0x1c ; pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) 0x1d ; pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) 0x1e ; pxTopOfStack -- ; * pxTopOfStack = ( StackType_t ) 0x1f ; pxTopOfStack -- ; #else pxTopOfStack -= 13 ; #endif return pxTopOfStack ; }
Initialise the stack of a task to look exactly as if a call to
 portSAVE_CONTEXT had been made.
Initialise the stack of a task to look exactly as if a call to portSAVE_CONTEXT had been made .
/* Place a few bytes of known values on the bottom of the stack.
	This is essential for the Microblaze port and these lines must
	not be omitted. */ /* The FSR value placed in the initial task context is just 0. */ /* The MSR value placed in the initial task context should have interrupts
	disabled.  Each task will enable interrupts automatically when it enters
	the running state for the first time. */ /* Ensure exceptions are enabled for the task. */ /* First stack an initial value for the critical section nesting.  This
	is initialised to zero. */ /* R0 is always zero. */ /* R1 is the SP. */ /* Place an initial value for all the general purpose registers. */ /* R2 - read only small data area. */ /* R3 - return values and temporaries. */ /* R4 - return values and temporaries. */ /* R5 contains the function call parameters. */ /* R6 - other parameters and temporaries. */ /* R7 - other parameters and temporaries. */ /* R8 - other parameters and temporaries. */ /* R9 - other parameters and temporaries. */ /* R10 - other parameters and temporaries. */ /* R11 - temporaries. */ /* R12 - temporaries. */ /* R13 - read/write small data area. */ /* R14 - return address for interrupt. */ /* R15 - return address for subroutine. */ /* R16 - return address for trap (debugger). */ /* R17 - return address for exceptions, if configured. */ /* R18 - reserved for assembler and compiler temporaries. */ /* R19 - must be saved across function calls. Callee-save.  Seems to be interpreted as the frame pointer. */ /* 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. */ /* R21 - must be saved across function calls. Callee-save. */ /* R22 - must be saved across function calls. Callee-save. */ /* R23 - must be saved across function calls. Callee-save. */ /* R24 - must be saved across function calls. Callee-save. */ /* R25 - must be saved across function calls. Callee-save. */ /* R26 - must be saved across function calls. Callee-save. */ /* R27 - must be saved across function calls. Callee-save. */ /* R28 - must be saved across function calls. Callee-save. */ /* R29 - must be saved across function calls. Callee-save. */ /* R30 - must be saved across function calls. Callee-save. */ /* R31 - must be saved across function calls. Callee-save. */ /* Return a pointer to the top of the stack that has been generated so this
	can	be stored in the task control block for the task. */