18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * arch/arm/include/asm/unwind.h
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2008 ARM Limited
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef __ASM_UNWIND_H
98c2ecf20Sopenharmony_ci#define __ASM_UNWIND_H
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci/* Unwind reason code according the the ARM EABI documents */
148c2ecf20Sopenharmony_cienum unwind_reason_code {
158c2ecf20Sopenharmony_ci	URC_OK = 0,			/* operation completed successfully */
168c2ecf20Sopenharmony_ci	URC_CONTINUE_UNWIND = 8,
178c2ecf20Sopenharmony_ci	URC_FAILURE = 9			/* unspecified failure of some kind */
188c2ecf20Sopenharmony_ci};
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_cistruct unwind_idx {
218c2ecf20Sopenharmony_ci	unsigned long addr_offset;
228c2ecf20Sopenharmony_ci	unsigned long insn;
238c2ecf20Sopenharmony_ci};
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_cistruct unwind_table {
268c2ecf20Sopenharmony_ci	struct list_head list;
278c2ecf20Sopenharmony_ci	const struct unwind_idx *start;
288c2ecf20Sopenharmony_ci	const struct unwind_idx *origin;
298c2ecf20Sopenharmony_ci	const struct unwind_idx *stop;
308c2ecf20Sopenharmony_ci	unsigned long begin_addr;
318c2ecf20Sopenharmony_ci	unsigned long end_addr;
328c2ecf20Sopenharmony_ci};
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ciextern struct unwind_table *unwind_table_add(unsigned long start,
358c2ecf20Sopenharmony_ci					     unsigned long size,
368c2ecf20Sopenharmony_ci					     unsigned long text_addr,
378c2ecf20Sopenharmony_ci					     unsigned long text_size);
388c2ecf20Sopenharmony_ciextern void unwind_table_del(struct unwind_table *tab);
398c2ecf20Sopenharmony_ciextern void unwind_backtrace(struct pt_regs *regs, struct task_struct *tsk,
408c2ecf20Sopenharmony_ci			     const char *loglvl);
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci#endif	/* !__ASSEMBLY__ */
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci#ifdef CONFIG_ARM_UNWIND
458c2ecf20Sopenharmony_ci#define UNWIND(code...)		code
468c2ecf20Sopenharmony_ci#else
478c2ecf20Sopenharmony_ci#define UNWIND(code...)
488c2ecf20Sopenharmony_ci#endif
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci#endif	/* __ASM_UNWIND_H */
51