| Robin Getz | 96f1050 | 2009-09-24 14:11:24 +0000 | [diff] [blame] | 1 | /* | 
 | 2 |  * Copyright 2004-2009 Analog Devices Inc. | 
 | 3 |  * | 
 | 4 |  * Licensed under the GPL-2 or later. | 
 | 5 |  */ | 
 | 6 |  | 
| Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 7 | #ifndef _BLACKFIN_BUG_H | 
 | 8 | #define _BLACKFIN_BUG_H | 
| Mike Frysinger | 2d19123 | 2008-04-24 08:58:44 +0800 | [diff] [blame] | 9 |  | 
 | 10 | #ifdef CONFIG_BUG | 
| Mike Frysinger | 2d19123 | 2008-04-24 08:58:44 +0800 | [diff] [blame] | 11 |  | 
| Robin Getz | 6a4110c | 2010-03-23 17:27:41 +0000 | [diff] [blame] | 12 | /* | 
 | 13 |  * This can be any undefined 16-bit opcode, meaning | 
 | 14 |  * ((opcode & 0xc000) != 0xc000) | 
 | 15 |  * Anything from 0x0001 to 0x000A (inclusive) will work | 
 | 16 |  */ | 
 | 17 | #define BFIN_BUG_OPCODE	0x0001 | 
| Mike Frysinger | 70f1256 | 2009-06-07 17:18:25 -0400 | [diff] [blame] | 18 |  | 
 | 19 | #ifdef CONFIG_DEBUG_BUGVERBOSE | 
 | 20 |  | 
 | 21 | #define _BUG_OR_WARN(flags)						\ | 
 | 22 | 	asm volatile(							\ | 
 | 23 | 		"1:	.hword	%0\n"					\ | 
 | 24 | 		"	.section __bug_table,\"a\",@progbits\n"		\ | 
 | 25 | 		"2:	.long	1b\n"					\ | 
 | 26 | 		"	.long	%1\n"					\ | 
 | 27 | 		"	.short	%2\n"					\ | 
 | 28 | 		"	.short	%3\n"					\ | 
 | 29 | 		"	.org	2b + %4\n"				\ | 
 | 30 | 		"	.previous"					\ | 
 | 31 | 		:							\ | 
 | 32 | 		: "i"(BFIN_BUG_OPCODE), "i"(__FILE__),			\ | 
 | 33 | 		  "i"(__LINE__), "i"(flags),				\ | 
 | 34 | 		  "i"(sizeof(struct bug_entry))) | 
 | 35 |  | 
 | 36 | #else | 
 | 37 |  | 
 | 38 | #define _BUG_OR_WARN(flags)						\ | 
 | 39 | 	asm volatile(							\ | 
 | 40 | 		"1:	.hword	%0\n"					\ | 
 | 41 | 		"	.section __bug_table,\"a\",@progbits\n"		\ | 
 | 42 | 		"2:	.long	1b\n"					\ | 
 | 43 | 		"	.short	%1\n"					\ | 
 | 44 | 		"	.org	2b + %2\n"				\ | 
 | 45 | 		"	.previous"					\ | 
 | 46 | 		:							\ | 
 | 47 | 		: "i"(BFIN_BUG_OPCODE), "i"(flags),			\ | 
 | 48 | 		  "i"(sizeof(struct bug_entry))) | 
 | 49 |  | 
 | 50 | #endif /* CONFIG_DEBUG_BUGVERBOSE */ | 
 | 51 |  | 
 | 52 | #define BUG()								\ | 
 | 53 | 	do {								\ | 
 | 54 | 		_BUG_OR_WARN(0);					\ | 
| David Daney | 64a2b16 | 2009-12-10 09:28:21 -0800 | [diff] [blame] | 55 | 		unreachable();						\ | 
| Mike Frysinger | 70f1256 | 2009-06-07 17:18:25 -0400 | [diff] [blame] | 56 | 	} while (0) | 
 | 57 |  | 
 | 58 | #define WARN_ON(condition)							\ | 
 | 59 | 	({								\ | 
 | 60 | 		int __ret_warn_on = !!(condition);			\ | 
 | 61 | 		if (unlikely(__ret_warn_on))				\ | 
 | 62 | 			_BUG_OR_WARN(BUGFLAG_WARNING);			\ | 
 | 63 | 		unlikely(__ret_warn_on);				\ | 
 | 64 | 	}) | 
 | 65 |  | 
 | 66 | #define HAVE_ARCH_BUG | 
 | 67 | #define HAVE_ARCH_WARN_ON | 
| Mike Frysinger | 2d19123 | 2008-04-24 08:58:44 +0800 | [diff] [blame] | 68 |  | 
 | 69 | #endif | 
 | 70 |  | 
| Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 71 | #include <asm-generic/bug.h> | 
| Mike Frysinger | 2d19123 | 2008-04-24 08:58:44 +0800 | [diff] [blame] | 72 |  | 
| Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 73 | #endif |