blob: 75f6dc336d46d4b13e04a42bf8facb44ea79a49f [file] [log] [blame]
Robin Getz96f10502009-09-24 14:11:24 +00001/*
2 * Copyright 2004-2009 Analog Devices Inc.
3 *
4 * Licensed under the GPL-2 or later.
5 */
6
Bryan Wu1394f032007-05-06 14:50:22 -07007#ifndef _BLACKFIN_BUG_H
8#define _BLACKFIN_BUG_H
Mike Frysinger2d191232008-04-24 08:58:44 +08009
10#ifdef CONFIG_BUG
Mike Frysinger2d191232008-04-24 08:58:44 +080011
Mike Frysinger70f12562009-06-07 17:18:25 -040012#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 Daney64a2b162009-12-10 09:28:21 -080050 unreachable(); \
Mike Frysinger70f12562009-06-07 17:18:25 -040051 } 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 Frysinger2d191232008-04-24 08:58:44 +080063
64#endif
65
Bryan Wu1394f032007-05-06 14:50:22 -070066#include <asm-generic/bug.h>
Mike Frysinger2d191232008-04-24 08:58:44 +080067
Bryan Wu1394f032007-05-06 14:50:22 -070068#endif