1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef __ASM_CRISv10_ARCH_BUG_H 3 #define __ASM_CRISv10_ARCH_BUG_H 4 5 #include <linux/stringify.h> 6 7 #ifdef CONFIG_BUG 8 #ifdef CONFIG_DEBUG_BUGVERBOSE 9 /* The BUG() macro is used for marking obviously incorrect code paths. 10 * It will cause a message with the file name and line number to be printed, 11 * and then cause an oops. The message is actually printed by handle_BUG() 12 * in arch/cris/kernel/traps.c, and the reason we use this method of storing 13 * the file name and line number is that we do not want to affect the registers 14 * by calling printk() before causing the oops. 15 */ 16 17 #define BUG_PREFIX 0x0D7F 18 #define BUG_MAGIC 0x00001234 19 20 struct bug_frame { 21 unsigned short prefix; 22 unsigned int magic; 23 unsigned short clear; 24 unsigned short movu; 25 unsigned short line; 26 unsigned short jump; 27 unsigned char *filename; 28 }; 29 30 #if 0 31 /* Unfortunately this version of the macro does not work due to a problem 32 * with the compiler (aka a bug) when compiling with -O2, which sometimes 33 * erroneously causes the second input to be stored in a register... 34 */ 35 #define BUG() \ 36 __asm__ __volatile__ ("clear.d [" __stringify(BUG_MAGIC) "]\n\t"\ 37 "movu.w %0,$r0\n\t" \ 38 "jump %1\n\t" \ 39 : : "i" (__LINE__), "i" (__FILE__)) 40 #else 41 /* This version will have to do for now, until the compiler is fixed. 42 * The drawbacks of this version are that the file name will appear multiple 43 * times in the .rodata section, and that __LINE__ and __FILE__ can probably 44 * not be used like this with newer versions of gcc. 45 */ 46 #define BUG() \ 47 do { \ 48 __asm__ __volatile__ ("clear.d [" __stringify(BUG_MAGIC) "]\n\t"\ 49 "movu.w " __stringify(__LINE__) ",$r0\n\t"\ 50 "jump 0f\n\t" \ 51 ".section .rodata\n" \ 52 "0:\t.string \"" __FILE__ "\"\n\t" \ 53 ".previous"); \ 54 unreachable(); \ 55 } while (0) 56 #endif 57 58 #else 59 60 /* This just causes an oops. */ 61 #define BUG() \ 62 do { \ 63 barrier_before_unreachable(); \ 64 __builtin_trap(); \ 65 } while (0) 66 67 #endif 68 69 #define HAVE_ARCH_BUG 70 #endif 71 72 #include <asm-generic/bug.h> 73 74 #endif 75