2 * FreeRTOS SMP Kernel V202110.00
3 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 * this software and associated documentation files (the "Software"), to deal in
7 * the Software without restriction, including without limitation the rights to
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 * the Software, and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in all
13 * copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 * https://www.FreeRTOS.org
23 * https://github.com/FreeRTOS
31 + pxPortInitialiseStack() now initialises the stack of new tasks to the
32 same format used by the compiler. This allows the compiler generated
33 interrupt mechanism to be used for context switches.
37 + Move usPortCheckFreeStackSpace() to tasks.c.
45 /*-----------------------------------------------------------*/
47 /* See header file for description. */
48 StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters )
50 StackType_t DS_Reg = 0;
52 /* Place a few bytes of known values on the bottom of the stack.
53 This is just useful for debugging. */
55 *pxTopOfStack = 0x1111;
57 *pxTopOfStack = 0x2222;
59 *pxTopOfStack = 0x3333;
61 *pxTopOfStack = 0x4444;
63 *pxTopOfStack = 0x5555;
67 /*lint -e950 -e611 -e923 Lint doesn't like this much - but nothing I can do about it. */
69 /* We are going to start the scheduler using a return from interrupt
70 instruction to load the program counter, so first there would be the
71 function call with parameters preamble. */
73 *pxTopOfStack = FP_SEG( pvParameters );
75 *pxTopOfStack = FP_OFF( pvParameters );
77 *pxTopOfStack = FP_SEG( pxCode );
79 *pxTopOfStack = FP_OFF( pxCode );
82 /* Next the status register and interrupt return address. */
83 *pxTopOfStack = portINITIAL_SW;
85 *pxTopOfStack = FP_SEG( pxCode );
87 *pxTopOfStack = FP_OFF( pxCode );
90 /* The remaining registers would be pushed on the stack by our context
91 switch function. These are loaded with values simply to make debugging
93 *pxTopOfStack = ( StackType_t ) 0xAAAA; /* AX */
95 *pxTopOfStack = ( StackType_t ) 0xBBBB; /* BX */
97 *pxTopOfStack = ( StackType_t ) 0xCCCC; /* CX */
99 *pxTopOfStack = ( StackType_t ) 0xDDDD; /* DX */
101 *pxTopOfStack = ( StackType_t ) 0xEEEE; /* ES */
104 /* We need the true data segment. */
105 __asm{ MOV DS_Reg, DS };
107 *pxTopOfStack = DS_Reg; /* DS */
109 *pxTopOfStack = ( StackType_t ) 0x0123; /* SI */
111 *pxTopOfStack = ( StackType_t ) 0xDDDD; /* DI */
113 *pxTopOfStack = ( StackType_t ) 0xBBBB; /* BP */
115 /*lint +e950 +e611 +e923 */
119 /*-----------------------------------------------------------*/