1;/*************************************************************************** 2; * Copyright (c) 2024 Microsoft Corporation 3; * 4; * This program and the accompanying materials are made available under the 5; * terms of the MIT License which is available at 6; * https://opensource.org/licenses/MIT. 7; * 8; * SPDX-License-Identifier: MIT 9; **************************************************************************/ 10; 11; 12;/**************************************************************************/ 13;/**************************************************************************/ 14;/** */ 15;/** ThreadX Component */ 16;/** */ 17;/** Thread */ 18;/** */ 19;/**************************************************************************/ 20;/**************************************************************************/ 21; 22; 23;#define TX_SOURCE_CODE 24; 25; 26;/* Include necessary system files. */ 27; 28;#include "tx_api.h" 29;#include "tx_thread.h" 30; 31; 32 .SECTION P,CODE 33;/**************************************************************************/ 34;/* */ 35;/* FUNCTION RELEASE */ 36;/* */ 37;/* _tx_thread_stack_build RXc2/CCRX */ 38;/* 6.1.11 */ 39;/* AUTHOR */ 40;/* */ 41;/* William E. Lamie, Microsoft Corporation */ 42;/* */ 43;/* DESCRIPTION */ 44;/* */ 45;/* This function builds a stack frame on the supplied thread's stack. */ 46;/* The stack frame results in a fake interrupt return to the supplied */ 47;/* function pointer. */ 48;/* */ 49;/* INPUT */ 50;/* */ 51;/* thread_ptr Pointer to thread control blk */ 52;/* function_ptr Pointer to return function */ 53;/* */ 54;/* OUTPUT */ 55;/* */ 56;/* None */ 57;/* */ 58;/* CALLS */ 59;/* */ 60;/* None */ 61;/* */ 62;/* CALLED BY */ 63;/* */ 64;/* _tx_thread_create Create thread service */ 65;/* */ 66;/* RELEASE HISTORY */ 67;/* */ 68;/* DATE NAME DESCRIPTION */ 69;/* */ 70;/* 12-30-2020 William E. Lamie Initial Version 6.1.3 */ 71;/* 10-15-2021 William E. Lamie Modified comment(s), and */ 72;/* removed unnecessary stack */ 73;/* type placement, */ 74;/* resulting in version 6.1.9 */ 75;/* 01-31-2022 William E. Lamie Modified comment(s), */ 76;/* resulting in version 6.1.10 */ 77;/* 04-25-2022 William E. Lamie Modified comment(s), */ 78;/* resulting in version 6.1.11 */ 79;/* */ 80;/**************************************************************************/ 81;VOID _tx_thread_stack_build(TX_THREAD *thread_ptr, VOID (*function_ptr)(VOID)) 82;{ 83 .GLB __tx_thread_stack_build 84__tx_thread_stack_build: 85; 86; 87; /* Build an interrupt frame. The form of the fake interrupt stack 88; on the Renesas RX should look like the following after it is built: 89; 90; Stack Top: ACC0 91; ACC1 92; R6 93; R7 94; R8 95; R9 96; R10 97; R11 98; R12 99; R13 100; FPSW 101; R14 102; R15 103; R3 104; R4 105; R5 106; R1 107; R2 108; PC 109; PSW 110 111; 112; Stack Bottom: (higher memory address) */ 113; 114 MOV.L 16[R1],R3 ; Pickup end of stack area 115 BCLR #0, R3 ; Mask for 4-byte alignment 116 BCLR #1, R3 117; 118; /* Build the stack frame. */ 119; 120 MOV.L #30000h, R4 121 MOV.L R4, [-R3] ; Initial PSW (SVC mode, U flag set) 122 MOV.L R2, [-R3] ; Initial PC 123 MOV.L #0, R4 124 MOV.L R4,[-R3] ; Initial R2 ... 125 MOV.L R4,[-R3] ; Initial R1 ... 126 MOV.L R4,[-R3] ; Initial R5 ... 127 MOV.L R4,[-R3] ; Initial R4 ... 128 MOV.L R4,[-R3] ; Initial R3 ... 129 MOV.L R4,[-R3] ; Initial R15 ... 130 MOV.L R4,[-R3] ; Initial R14 ... 131 MVFC FPSW, r4 132 MOV.L R4, [-R3] ; Initial FPSW 133 MOV.L #0, R4 134 MOV.L R4,[-R3] ; Initial R13 ... 135 MOV.L R4,[-R3] ; Initial R12 ... 136 MOV.L R4,[-R3] ; Initial R11 ... 137 MOV.L R4,[-R3] ; Initial R10 ... 138 MOV.L R4,[-R3] ; Initial R9 ... 139 MOV.L R4,[-R3] ; Initial R8 ... 140 MOV.L R4,[-R3] ; Initial R7 ... 141 MOV.L R4,[-R3] ; Initial R6 ... 142 143 MOV.L R4,[-R3] ; Accumulator 1 144 MOV.L R4,[-R3] 145 MOV.L R4,[-R3] 146 147 MOV.L R4,[-R3] ; Accumulator 0 148 MOV.L R4,[-R3] 149 MOV.L R4,[-R3] 150 151; /* Setup stack pointer. */ 152; thread_ptr -> tx_thread_stack_ptr = R1; 153 MOV.L R3, 8[R1] 154 ; Store initial SP in thread control block 155 RTS 156 157;} 158 .END 159