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 section .text:CODE:ROOT 25 26;/**************************************************************************/ 27;/* */ 28;/* FUNCTION RELEASE */ 29;/* */ 30;/* _tx_thread_stack_build RXv1/IAR */ 31;/* 6.1.11 */ 32;/* AUTHOR */ 33;/* */ 34;/* William E. Lamie, Microsoft Corporation */ 35;/* */ 36;/* DESCRIPTION */ 37;/* */ 38;/* This function builds a stack frame on the supplied thread's stack. */ 39;/* The stack frame results in a fake interrupt return to the supplied */ 40;/* function pointer. */ 41;/* */ 42;/* INPUT */ 43;/* */ 44;/* thread_ptr Pointer to thread control blk */ 45;/* function_ptr Pointer to return function */ 46;/* */ 47;/* OUTPUT */ 48;/* */ 49;/* None */ 50;/* */ 51;/* CALLS */ 52;/* */ 53;/* None */ 54;/* */ 55;/* CALLED BY */ 56;/* */ 57;/* _tx_thread_create Create thread service */ 58;/* */ 59;/* RELEASE HISTORY */ 60;/* */ 61;/* DATE NAME DESCRIPTION */ 62;/* */ 63;/* 08-02-2021 William E. Lamie Initial Version 6.1.8 */ 64;/* 10-15-2021 William E. Lamie Modified comment(s), and */ 65;/* removed unnecessary stack */ 66;/* type placement, */ 67;/* resulting in version 6.1.9 */ 68;/* 01-31-2022 William E. Lamie Modified comment(s), */ 69;/* resulting in version 6.1.10 */ 70;/* 04-25-2022 William E. Lamie Modified comment(s), */ 71;/* resulting in version 6.1.11 */ 72;/* */ 73;/**************************************************************************/ 74 75 public __tx_thread_stack_build 76 77__tx_thread_stack_build: 78; 79; 80; /* Build an interrupt frame. The form of the fake interrupt stack 81; on the Renesas RX should look like the following after it is built: 82; 83; Stack Top: ACC0 84; R6 85; R7 86; R8 87; R9 88; R10 89; R11 90; R12 91; R13 92; R14 93; R15 94; R3 95; R4 96; R5 97; R1 98; R2 99; PC 100; PSW 101 102; 103; Stack Bottom: (higher memory address) */ 104; 105 MOV.L 16[R1],R3 ; Pickup end of stack area 106 BCLR #0, R3 ; Mask for 4-byte alignment 107 BCLR #1, R3 108; 109; /* Build the stack frame. */ 110; 111 MOV.L #30000h, R4 112 MOV.L R4, [-R3] ; Initial PSW (SVC mode, U flag set) 113 MOV.L R2, [-R3] ; Initial PC 114 MOV.L #0, R4 115 MOV.L R4,[-R3] ; Initial R2 ... 116 MOV.L R4,[-R3] ; Initial R1 ... 117 MOV.L R4,[-R3] ; Initial R5 ... 118 MOV.L R4,[-R3] ; Initial R4 ... 119 MOV.L R4,[-R3] ; Initial R3 ... 120 MOV.L R4,[-R3] ; Initial R15 ... 121 MOV.L R4,[-R3] ; Initial R14 ... 122 MOV.L R4,[-R3] ; Initial R13 ... 123 MOV.L R4,[-R3] ; Initial R12 ... 124 MOV.L R4,[-R3] ; Initial R11 ... 125 MOV.L R4,[-R3] ; Initial R10 ... 126 MOV.L R4,[-R3] ; Initial R9 ... 127 MOV.L R4,[-R3] ; Initial R8 ... 128 MOV.L R4,[-R3] ; Initial R7 ... 129 MOV.L R4,[-R3] ; Initial R6 ... 130 131 MOV.L R4,[-R3] ; Accumulator 0 132 MOV.L R4,[-R3] 133 134; /* Setup stack pointer. */ 135; thread_ptr -> tx_thread_stack_ptr = R1; 136 MOV.L R3, 8[R1] 137 ; Store initial SP in thread control block 138 RTS 139 140;} 141 142 END 143