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 | |
Mike Frysinger | 70f1256 | 2009-06-07 17:18:25 -0400 | [diff] [blame] | 12 | #define BFIN_BUG_OPCODE 0xefcd |
| 13 | |
| 14 | #ifdef CONFIG_DEBUG_BUGVERBOSE |
| 15 | |
| 16 | #define _BUG_OR_WARN(flags) \ |
| 17 | asm volatile( \ |
| 18 | "1: .hword %0\n" \ |
| 19 | " .section __bug_table,\"a\",@progbits\n" \ |
| 20 | "2: .long 1b\n" \ |
| 21 | " .long %1\n" \ |
| 22 | " .short %2\n" \ |
| 23 | " .short %3\n" \ |
| 24 | " .org 2b + %4\n" \ |
| 25 | " .previous" \ |
| 26 | : \ |
| 27 | : "i"(BFIN_BUG_OPCODE), "i"(__FILE__), \ |
| 28 | "i"(__LINE__), "i"(flags), \ |
| 29 | "i"(sizeof(struct bug_entry))) |
| 30 | |
| 31 | #else |
| 32 | |
| 33 | #define _BUG_OR_WARN(flags) \ |
| 34 | asm volatile( \ |
| 35 | "1: .hword %0\n" \ |
| 36 | " .section __bug_table,\"a\",@progbits\n" \ |
| 37 | "2: .long 1b\n" \ |
| 38 | " .short %1\n" \ |
| 39 | " .org 2b + %2\n" \ |
| 40 | " .previous" \ |
| 41 | : \ |
| 42 | : "i"(BFIN_BUG_OPCODE), "i"(flags), \ |
| 43 | "i"(sizeof(struct bug_entry))) |
| 44 | |
| 45 | #endif /* CONFIG_DEBUG_BUGVERBOSE */ |
| 46 | |
| 47 | #define BUG() \ |
| 48 | do { \ |
| 49 | _BUG_OR_WARN(0); \ |
David Daney | 64a2b16 | 2009-12-10 09:28:21 -0800 | [diff] [blame] | 50 | unreachable(); \ |
Mike Frysinger | 70f1256 | 2009-06-07 17:18:25 -0400 | [diff] [blame] | 51 | } while (0) |
| 52 | |
| 53 | #define WARN_ON(condition) \ |
| 54 | ({ \ |
| 55 | int __ret_warn_on = !!(condition); \ |
| 56 | if (unlikely(__ret_warn_on)) \ |
| 57 | _BUG_OR_WARN(BUGFLAG_WARNING); \ |
| 58 | unlikely(__ret_warn_on); \ |
| 59 | }) |
| 60 | |
| 61 | #define HAVE_ARCH_BUG |
| 62 | #define HAVE_ARCH_WARN_ON |
Mike Frysinger | 2d19123 | 2008-04-24 08:58:44 +0800 | [diff] [blame] | 63 | |
| 64 | #endif |
| 65 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 66 | #include <asm-generic/bug.h> |
Mike Frysinger | 2d19123 | 2008-04-24 08:58:44 +0800 | [diff] [blame] | 67 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 68 | #endif |