diff options
| author | Dmitry Torokhov <dtor@insightbb.com> | 2007-05-08 01:31:11 -0400 |
|---|---|---|
| committer | Dmitry Torokhov <dtor@insightbb.com> | 2007-05-08 01:31:11 -0400 |
| commit | 334d0dd8b660557608142f0f77abc6812b48f08b (patch) | |
| tree | 9393a9aa099d7d42deda5f9f5054796c0c769be7 /include/asm-sh/bug.h | |
| parent | 3f07d8796262f6aee135c8dd9a91210da9f888e4 (diff) | |
| parent | 5b94f675f57e4ff16c8fda09088d7480a84dcd91 (diff) | |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'include/asm-sh/bug.h')
| -rw-r--r-- | include/asm-sh/bug.h | 92 |
1 files changed, 61 insertions, 31 deletions
diff --git a/include/asm-sh/bug.h b/include/asm-sh/bug.h index 2f89dd06d0cd..794c36daf06d 100644 --- a/include/asm-sh/bug.h +++ b/include/asm-sh/bug.h | |||
| @@ -2,50 +2,80 @@ | |||
| 2 | #define __ASM_SH_BUG_H | 2 | #define __ASM_SH_BUG_H |
| 3 | 3 | ||
| 4 | #ifdef CONFIG_BUG | 4 | #ifdef CONFIG_BUG |
| 5 | 5 | #define HAVE_ARCH_BUG | |
| 6 | struct bug_frame { | 6 | #define HAVE_ARCH_WARN_ON |
| 7 | unsigned short opcode; | ||
| 8 | unsigned short line; | ||
| 9 | const char *file; | ||
| 10 | const char *func; | ||
| 11 | }; | ||
| 12 | |||
| 13 | struct pt_regs; | ||
| 14 | |||
| 15 | extern void handle_BUG(struct pt_regs *); | ||
| 16 | 7 | ||
| 17 | #define TRAPA_BUG_OPCODE 0xc33e /* trapa #0x3e */ | 8 | #define TRAPA_BUG_OPCODE 0xc33e /* trapa #0x3e */ |
| 18 | 9 | ||
| 10 | /** | ||
| 11 | * _EMIT_BUG_ENTRY | ||
| 12 | * %1 - __FILE__ | ||
| 13 | * %2 - __LINE__ | ||
| 14 | * %3 - trap type | ||
| 15 | * %4 - sizeof(struct bug_entry) | ||
| 16 | * | ||
| 17 | * The trapa opcode itself sits in %0. | ||
| 18 | * The %O notation is used to avoid # generation. | ||
| 19 | * | ||
| 20 | * The offending file and line are encoded in the __bug_table section. | ||
| 21 | */ | ||
| 19 | #ifdef CONFIG_DEBUG_BUGVERBOSE | 22 | #ifdef CONFIG_DEBUG_BUGVERBOSE |
| 23 | #define _EMIT_BUG_ENTRY \ | ||
| 24 | "\t.pushsection __bug_table,\"a\"\n" \ | ||
| 25 | "2:\t.long 1b, %O1\n" \ | ||
| 26 | "\t.short %O2, %O3\n" \ | ||
| 27 | "\t.org 2b+%O4\n" \ | ||
| 28 | "\t.popsection\n" | ||
| 29 | #else | ||
| 30 | #define _EMIT_BUG_ENTRY \ | ||
| 31 | "\t.pushsection __bug_table,\"a\"\n" \ | ||
| 32 | "2:\t.long 1b\n" \ | ||
| 33 | "\t.short %O3\n" \ | ||
| 34 | "\t.org 2b+%O4\n" \ | ||
| 35 | "\t.popsection\n" | ||
| 36 | #endif | ||
| 20 | 37 | ||
| 21 | #define BUG() \ | 38 | #define BUG() \ |
| 22 | do { \ | 39 | do { \ |
| 23 | __asm__ __volatile__ ( \ | 40 | __asm__ __volatile__ ( \ |
| 24 | ".align 2\n\t" \ | 41 | "1:\t.short %O0\n" \ |
| 25 | ".short %O0\n\t" \ | 42 | _EMIT_BUG_ENTRY \ |
| 26 | ".short %O1\n\t" \ | 43 | : \ |
| 27 | ".long %O2\n\t" \ | 44 | : "n" (TRAPA_BUG_OPCODE), \ |
| 28 | ".long %O3\n\t" \ | 45 | "i" (__FILE__), \ |
| 29 | : \ | 46 | "i" (__LINE__), "i" (0), \ |
| 30 | : "n" (TRAPA_BUG_OPCODE), \ | 47 | "i" (sizeof(struct bug_entry))); \ |
| 31 | "i" (__LINE__), "X" (__FILE__), \ | ||
| 32 | "X" (__FUNCTION__)); \ | ||
| 33 | } while (0) | 48 | } while (0) |
| 34 | 49 | ||
| 35 | #else | 50 | #define __WARN() \ |
| 36 | 51 | do { \ | |
| 37 | #define BUG() \ | 52 | __asm__ __volatile__ ( \ |
| 38 | do { \ | 53 | "1:\t.short %O0\n" \ |
| 39 | __asm__ __volatile__ ( \ | 54 | _EMIT_BUG_ENTRY \ |
| 40 | ".align 2\n\t" \ | 55 | : \ |
| 41 | ".short %O0\n\t" \ | 56 | : "n" (TRAPA_BUG_OPCODE), \ |
| 42 | : \ | 57 | "i" (__FILE__), \ |
| 43 | : "n" (TRAPA_BUG_OPCODE)); \ | 58 | "i" (__LINE__), \ |
| 59 | "i" (BUGFLAG_WARNING), \ | ||
| 60 | "i" (sizeof(struct bug_entry))); \ | ||
| 44 | } while (0) | 61 | } while (0) |
| 45 | 62 | ||
| 46 | #endif /* CONFIG_DEBUG_BUGVERBOSE */ | 63 | #define WARN_ON(x) ({ \ |
| 64 | typeof(x) __ret_warn_on = (x); \ | ||
| 65 | if (__builtin_constant_p(__ret_warn_on)) { \ | ||
| 66 | if (__ret_warn_on) \ | ||
| 67 | __WARN(); \ | ||
| 68 | } else { \ | ||
| 69 | if (unlikely(__ret_warn_on)) \ | ||
| 70 | __WARN(); \ | ||
| 71 | } \ | ||
| 72 | unlikely(__ret_warn_on); \ | ||
| 73 | }) | ||
| 47 | 74 | ||
| 48 | #define HAVE_ARCH_BUG | 75 | struct pt_regs; |
| 76 | |||
| 77 | /* arch/sh/kernel/traps.c */ | ||
| 78 | void handle_BUG(struct pt_regs *); | ||
| 49 | 79 | ||
| 50 | #endif /* CONFIG_BUG */ | 80 | #endif /* CONFIG_BUG */ |
| 51 | 81 | ||
