1/* 2 * Copyright (c) 2023-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#ifndef PANDA_RUNTIME_FIBERS_ARCH_ARM_HELPERS_S 17#define PANDA_RUNTIME_FIBERS_ARCH_ARM_HELPERS_S 18 19/// stores GPR and FP context to the buffer that starts at the address stored in the register r0 using 20/// the register #tmp_regid as a temporary 21.macro STORE_CONTEXT tmp_regid 22 /* save GPR */ 23 // gpr (incl. fp): assuming that R4..R15 reside in a contiguous block 24 add r\tmp_regid, r0, # GPR_O(R4) 25 stm r\tmp_regid, {r4-r12} 26 str sp, [r0, # GPR_O(SP)] 27 str lr, [r0, # GPR_O(LR)] 28 // pc = lr (return to the caller) 29 str lr, [r0, # GPR_O(PC)] 30 // arg register: store 0 31 mov r\tmp_regid, #0 32 str r\tmp_regid, [r0, # GPR_O(R0)] 33 34#ifndef PANDA_TARGET_ARM32_ABI_SOFT 35 /* save FP */ 36 // regs: assuming that D8..D15 reside in a contiguous block 37 add r\tmp_regid, r0, # FP_O(D8) 38 vstm r\tmp_regid, {d8-d15} 39 // control/status 40 fmrx r\tmp_regid, fpscr // Get FPSCR value 41 str r\tmp_regid, [r0, # FP_O(FPSCR)] // and store it 42#endif 43.endm 44 45#endif /* PANDA_RUNTIME_FIBERS_ARCH_ARM_HELPERS_S */