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 .SECTION P,CODE 34;/**************************************************************************/ 35;/* */ 36;/* FUNCTION RELEASE */ 37;/* */ 38;/* _tx_thread_stack_build RXv1/CCRX */ 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;/* 08-02-2021 William E. Lamie Initial Version 6.1.8 */ 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 .GLB __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; R6 93; R7 94; R8 95; R9 96; R10 97; R11 98; R12 99; R13 100; R14 101; R15 102; R3 103; R4 104; R5 105; R1 106; R2 107; PC 108; PSW 109 110; 111; Stack Bottom: (higher memory address) */ 112; 113 MOV.L 16[R1],R3 ; Pickup end of stack area 114 BCLR #0, R3 ; Mask for 4-byte alignment 115 BCLR #1, R3 116; 117; /* Build the stack frame. */ 118; 119 MOV.L #30000h, R4 120 MOV.L R4, [-R3] ; Initial PSW (SVC mode, U flag set) 121 MOV.L R2, [-R3] ; Initial PC 122 MOV.L #0, R4 123 MOV.L R4,[-R3] ; Initial R2 ... 124 MOV.L R4,[-R3] ; Initial R1 ... 125 MOV.L R4,[-R3] ; Initial R5 ... 126 MOV.L R4,[-R3] ; Initial R4 ... 127 MOV.L R4,[-R3] ; Initial R3 ... 128 MOV.L R4,[-R3] ; Initial R15 ... 129 MOV.L R4,[-R3] ; Initial R14 ... 130 MOV.L R4,[-R3] ; Initial R13 ... 131 MOV.L R4,[-R3] ; Initial R12 ... 132 MOV.L R4,[-R3] ; Initial R11 ... 133 MOV.L R4,[-R3] ; Initial R10 ... 134 MOV.L R4,[-R3] ; Initial R9 ... 135 MOV.L R4,[-R3] ; Initial R8 ... 136 MOV.L R4,[-R3] ; Initial R7 ... 137 MOV.L R4,[-R3] ; Initial R6 ... 138 139 MOV.L R4,[-R3] ; Accumulator 0 140 MOV.L R4,[-R3] 141 142; /* Setup stack pointer. */ 143; thread_ptr -> tx_thread_stack_ptr = R1; 144 MOV.L R3, 8[R1] 145 ; Store initial SP in thread control block 146 RTS 147 148;} 149 .END 150 151