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