2 * FreeRTOS Kernel <DEVELOPMENT BRANCH>
3 * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5 * SPDX-License-Identifier: MIT
7 * Permission is hereby granted, free of charge, to any person obtaining a copy of
8 * this software and associated documentation files (the "Software"), to deal in
9 * the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11 * the Software, and to permit persons to whom the Software is furnished to do so,
12 * subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in all
15 * copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 * https://www.FreeRTOS.org
25 * https://github.com/FreeRTOS
32 + pxPortInitialiseStack() now initialises the stack of new tasks to the
33 + same format used by the compiler. This allows the compiler generated
34 + interrupt mechanism to be used for context switches.
38 + Move usPortCheckFreeStackSpace() to tasks.c.
46 /*-----------------------------------------------------------*/
48 /* See header file for description. */
49 StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
50 TaskFunction_t pxCode,
53 StackType_t DS_Reg = 0;
55 /* Place a few bytes of known values on the bottom of the stack.
56 * This is just useful for debugging. */
58 *pxTopOfStack = 0x1111;
60 *pxTopOfStack = 0x2222;
62 *pxTopOfStack = 0x3333;
64 *pxTopOfStack = 0x4444;
66 *pxTopOfStack = 0x5555;
70 /*lint -e950 -e611 -e923 Lint doesn't like this much - but nothing I can do about it. */
72 /* We are going to start the scheduler using a return from interrupt
73 * instruction to load the program counter, so first there would be the
74 * function call with parameters preamble. */
76 *pxTopOfStack = FP_SEG( pvParameters );
78 *pxTopOfStack = FP_OFF( pvParameters );
80 *pxTopOfStack = FP_SEG( pxCode );
82 *pxTopOfStack = FP_OFF( pxCode );
85 /* Next the status register and interrupt return address. */
86 *pxTopOfStack = portINITIAL_SW;
88 *pxTopOfStack = FP_SEG( pxCode );
90 *pxTopOfStack = FP_OFF( pxCode );
93 /* The remaining registers would be pushed on the stack by our context
94 * switch function. These are loaded with values simply to make debugging
96 *pxTopOfStack = ( StackType_t ) 0xAAAA; /* AX */
98 *pxTopOfStack = ( StackType_t ) 0xBBBB; /* BX */
100 *pxTopOfStack = ( StackType_t ) 0xCCCC; /* CX */
102 *pxTopOfStack = ( StackType_t ) 0xDDDD; /* DX */
104 *pxTopOfStack = ( StackType_t ) 0xEEEE; /* ES */
107 /* We need the true data segment. */
112 *pxTopOfStack = DS_Reg; /* DS */
114 *pxTopOfStack = ( StackType_t ) 0x0123; /* SI */
116 *pxTopOfStack = ( StackType_t ) 0xDDDD; /* DI */
118 *pxTopOfStack = ( StackType_t ) 0xBBBB; /* BP */
120 /*lint +e950 +e611 +e923 */
124 /*-----------------------------------------------------------*/