2 * FreeRTOS Kernel V10.0.0
\r
3 * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
\r
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
\r
6 * this software and associated documentation files (the "Software"), to deal in
\r
7 * the Software without restriction, including without limitation the rights to
\r
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
\r
9 * the Software, and to permit persons to whom the Software is furnished to do so,
\r
10 * subject to the following conditions:
\r
12 * The above copyright notice and this permission notice shall be included in all
\r
13 * copies or substantial portions of the Software. If you wish to use our Amazon
\r
14 * FreeRTOS name, please do so in a fair use way that does not cause confusion.
\r
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
18 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
19 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
23 * http://www.FreeRTOS.org
\r
24 * http://aws.amazon.com/freertos
\r
26 * 1 tab == 4 spaces!
\r
32 + pxPortInitialiseStack() now initialises the stack of new tasks to the
\r
33 same format used by the compiler. This allows the compiler generated
\r
34 interrupt mechanism to be used for context switches.
\r
38 + Move usPortCheckFreeStackSpace() to tasks.c.
\r
44 #include "FreeRTOS.h"
\r
46 /*-----------------------------------------------------------*/
\r
48 /* See header file for description. */
\r
49 StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters )
\r
51 StackType_t DS_Reg = 0;
\r
53 /* Place a few bytes of known values on the bottom of the stack.
\r
54 This is just useful for debugging. */
\r
56 *pxTopOfStack = 0x1111;
\r
58 *pxTopOfStack = 0x2222;
\r
60 *pxTopOfStack = 0x3333;
\r
62 *pxTopOfStack = 0x4444;
\r
64 *pxTopOfStack = 0x5555;
\r
68 /*lint -e950 -e611 -e923 Lint doesn't like this much - but nothing I can do about it. */
\r
70 /* We are going to start the scheduler using a return from interrupt
\r
71 instruction to load the program counter, so first there would be the
\r
72 function call with parameters preamble. */
\r
74 *pxTopOfStack = FP_SEG( pvParameters );
\r
76 *pxTopOfStack = FP_OFF( pvParameters );
\r
78 *pxTopOfStack = FP_SEG( pxCode );
\r
80 *pxTopOfStack = FP_OFF( pxCode );
\r
83 /* Next the status register and interrupt return address. */
\r
84 *pxTopOfStack = portINITIAL_SW;
\r
86 *pxTopOfStack = FP_SEG( pxCode );
\r
88 *pxTopOfStack = FP_OFF( pxCode );
\r
91 /* The remaining registers would be pushed on the stack by our context
\r
92 switch function. These are loaded with values simply to make debugging
\r
94 *pxTopOfStack = ( StackType_t ) 0xAAAA; /* AX */
\r
96 *pxTopOfStack = ( StackType_t ) 0xBBBB; /* BX */
\r
98 *pxTopOfStack = ( StackType_t ) 0xCCCC; /* CX */
\r
100 *pxTopOfStack = ( StackType_t ) 0xDDDD; /* DX */
\r
102 *pxTopOfStack = ( StackType_t ) 0xEEEE; /* ES */
\r
105 /* We need the true data segment. */
\r
106 __asm{ MOV DS_Reg, DS };
\r
108 *pxTopOfStack = DS_Reg; /* DS */
\r
110 *pxTopOfStack = ( StackType_t ) 0x0123; /* SI */
\r
112 *pxTopOfStack = ( StackType_t ) 0xDDDD; /* DI */
\r
114 *pxTopOfStack = ( StackType_t ) 0xBBBB; /* BP */
\r
116 /*lint +e950 +e611 +e923 */
\r
118 return pxTopOfStack;
\r
120 /*-----------------------------------------------------------*/
\r