18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci#ifndef __ASM_ASM_BUG_H
38c2ecf20Sopenharmony_ci/*
48c2ecf20Sopenharmony_ci * Copyright (C) 2017  ARM Limited
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci#define __ASM_ASM_BUG_H
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#include <asm/brk-imm.h>
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#ifdef CONFIG_DEBUG_BUGVERBOSE
118c2ecf20Sopenharmony_ci#define _BUGVERBOSE_LOCATION(file, line) __BUGVERBOSE_LOCATION(file, line)
128c2ecf20Sopenharmony_ci#define __BUGVERBOSE_LOCATION(file, line)			\
138c2ecf20Sopenharmony_ci		.pushsection .rodata.str,"aMS",@progbits,1;	\
148c2ecf20Sopenharmony_ci	14472:	.string file;					\
158c2ecf20Sopenharmony_ci		.popsection;					\
168c2ecf20Sopenharmony_ci								\
178c2ecf20Sopenharmony_ci		.long 14472b - 14470b;				\
188c2ecf20Sopenharmony_ci		.short line;
198c2ecf20Sopenharmony_ci#else
208c2ecf20Sopenharmony_ci#define _BUGVERBOSE_LOCATION(file, line)
218c2ecf20Sopenharmony_ci#endif
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#ifdef CONFIG_GENERIC_BUG
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci#define __BUG_ENTRY(flags) 				\
268c2ecf20Sopenharmony_ci		.pushsection __bug_table,"aw";		\
278c2ecf20Sopenharmony_ci		.align 2;				\
288c2ecf20Sopenharmony_ci	14470:	.long 14471f - 14470b;			\
298c2ecf20Sopenharmony_ci_BUGVERBOSE_LOCATION(__FILE__, __LINE__)		\
308c2ecf20Sopenharmony_ci		.short flags; 				\
318c2ecf20Sopenharmony_ci		.popsection;				\
328c2ecf20Sopenharmony_ci	14471:
338c2ecf20Sopenharmony_ci#else
348c2ecf20Sopenharmony_ci#define __BUG_ENTRY(flags)
358c2ecf20Sopenharmony_ci#endif
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci#define ASM_BUG_FLAGS(flags)				\
388c2ecf20Sopenharmony_ci	__BUG_ENTRY(flags)				\
398c2ecf20Sopenharmony_ci	brk	BUG_BRK_IMM
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci#define ASM_BUG()	ASM_BUG_FLAGS(0)
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci#endif /* __ASM_ASM_BUG_H */
44