162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci#ifndef __ASM_ASM_BUG_H
362306a36Sopenharmony_ci/*
462306a36Sopenharmony_ci * Copyright (C) 2017  ARM Limited
562306a36Sopenharmony_ci */
662306a36Sopenharmony_ci#define __ASM_ASM_BUG_H
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#include <asm/brk-imm.h>
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#ifdef CONFIG_DEBUG_BUGVERBOSE
1162306a36Sopenharmony_ci#define _BUGVERBOSE_LOCATION(file, line) __BUGVERBOSE_LOCATION(file, line)
1262306a36Sopenharmony_ci#define __BUGVERBOSE_LOCATION(file, line)			\
1362306a36Sopenharmony_ci		.pushsection .rodata.str,"aMS",@progbits,1;	\
1462306a36Sopenharmony_ci	14472:	.string file;					\
1562306a36Sopenharmony_ci		.popsection;					\
1662306a36Sopenharmony_ci								\
1762306a36Sopenharmony_ci		.long 14472b - .;				\
1862306a36Sopenharmony_ci		.short line;
1962306a36Sopenharmony_ci#else
2062306a36Sopenharmony_ci#define _BUGVERBOSE_LOCATION(file, line)
2162306a36Sopenharmony_ci#endif
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci#ifdef CONFIG_GENERIC_BUG
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci#define __BUG_ENTRY(flags) 				\
2662306a36Sopenharmony_ci		.pushsection __bug_table,"aw";		\
2762306a36Sopenharmony_ci		.align 2;				\
2862306a36Sopenharmony_ci	14470:	.long 14471f - .;			\
2962306a36Sopenharmony_ci_BUGVERBOSE_LOCATION(__FILE__, __LINE__)		\
3062306a36Sopenharmony_ci		.short flags; 				\
3162306a36Sopenharmony_ci		.popsection;				\
3262306a36Sopenharmony_ci	14471:
3362306a36Sopenharmony_ci#else
3462306a36Sopenharmony_ci#define __BUG_ENTRY(flags)
3562306a36Sopenharmony_ci#endif
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci#define ASM_BUG_FLAGS(flags)				\
3862306a36Sopenharmony_ci	__BUG_ENTRY(flags)				\
3962306a36Sopenharmony_ci	brk	BUG_BRK_IMM
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci#define ASM_BUG()	ASM_BUG_FLAGS(0)
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci#endif /* __ASM_ASM_BUG_H */
44