18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#include <linux/linkage.h>
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci#define R0 0x00
58c2ecf20Sopenharmony_ci#define R1 0x08
68c2ecf20Sopenharmony_ci#define R2 0x10
78c2ecf20Sopenharmony_ci#define R3 0x18
88c2ecf20Sopenharmony_ci#define R4 0x20
98c2ecf20Sopenharmony_ci#define R5 0x28
108c2ecf20Sopenharmony_ci#define R6 0x30
118c2ecf20Sopenharmony_ci#define R7 0x38
128c2ecf20Sopenharmony_ci#define R8 0x40
138c2ecf20Sopenharmony_ci#define R9 0x48
148c2ecf20Sopenharmony_ci#define SL 0x50
158c2ecf20Sopenharmony_ci#define FP 0x58
168c2ecf20Sopenharmony_ci#define IP 0x60
178c2ecf20Sopenharmony_ci#define SP 0x68
188c2ecf20Sopenharmony_ci#define LR 0x70
198c2ecf20Sopenharmony_ci#define PC 0x78
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci/*
228c2ecf20Sopenharmony_ci * Implementation of void perf_regs_load(u64 *regs);
238c2ecf20Sopenharmony_ci *
248c2ecf20Sopenharmony_ci * This functions fills in the 'regs' buffer from the actual registers values,
258c2ecf20Sopenharmony_ci * in the way the perf built-in unwinding test expects them:
268c2ecf20Sopenharmony_ci * - the PC at the time at the call to this function. Since this function
278c2ecf20Sopenharmony_ci *   is called using a bl instruction, the PC value is taken from LR.
288c2ecf20Sopenharmony_ci * The built-in unwinding test then unwinds the call stack from the dwarf
298c2ecf20Sopenharmony_ci * information in unwind__get_entries.
308c2ecf20Sopenharmony_ci *
318c2ecf20Sopenharmony_ci * Notes:
328c2ecf20Sopenharmony_ci * - the 8 bytes stride in the registers offsets comes from the fact
338c2ecf20Sopenharmony_ci * that the registers are stored in an u64 array (u64 *regs),
348c2ecf20Sopenharmony_ci * - the regs buffer needs to be zeroed before the call to this function,
358c2ecf20Sopenharmony_ci * in this case using a calloc in dwarf-unwind.c.
368c2ecf20Sopenharmony_ci */
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci.text
398c2ecf20Sopenharmony_ci.type perf_regs_load,%function
408c2ecf20Sopenharmony_ciSYM_FUNC_START(perf_regs_load)
418c2ecf20Sopenharmony_ci	str r0, [r0, #R0]
428c2ecf20Sopenharmony_ci	str r1, [r0, #R1]
438c2ecf20Sopenharmony_ci	str r2, [r0, #R2]
448c2ecf20Sopenharmony_ci	str r3, [r0, #R3]
458c2ecf20Sopenharmony_ci	str r4, [r0, #R4]
468c2ecf20Sopenharmony_ci	str r5, [r0, #R5]
478c2ecf20Sopenharmony_ci	str r6, [r0, #R6]
488c2ecf20Sopenharmony_ci	str r7, [r0, #R7]
498c2ecf20Sopenharmony_ci	str r8, [r0, #R8]
508c2ecf20Sopenharmony_ci	str r9, [r0, #R9]
518c2ecf20Sopenharmony_ci	str sl, [r0, #SL]
528c2ecf20Sopenharmony_ci	str fp, [r0, #FP]
538c2ecf20Sopenharmony_ci	str ip, [r0, #IP]
548c2ecf20Sopenharmony_ci	str sp, [r0, #SP]
558c2ecf20Sopenharmony_ci	str lr, [r0, #LR]
568c2ecf20Sopenharmony_ci	str lr, [r0, #PC]	// store pc as lr in order to skip the call
578c2ecf20Sopenharmony_ci	                        //  to this function
588c2ecf20Sopenharmony_ci	mov pc, lr
598c2ecf20Sopenharmony_ciSYM_FUNC_END(perf_regs_load)
60