hc
2024-11-01 2f529f9b558ca1c1bd74be7437a84e4711743404
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
 * Copyright (C) 2006 Philippe Gerum <rpm@xenomai.org>.
 *
 * Xenomai is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * by the Free Software Foundation; either version 2 of the License,
 * or (at your option) any later version.
 *
 * Xenomai is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Xenomai; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 */
#ifndef _COBALT_KERNEL_ASSERT_H
#define _COBALT_KERNEL_ASSERT_H
 
#include <linux/kconfig.h>
 
#define XENO_INFO    KERN_INFO    "[Xenomai] "
#define XENO_WARNING    KERN_WARNING "[Xenomai] "
#define XENO_ERR    KERN_ERR     "[Xenomai] "
 
#define XENO_DEBUG(__subsys)                \
   IS_ENABLED(CONFIG_XENO_OPT_DEBUG_##__subsys)
#define XENO_ASSERT(__subsys, __cond)            \
   (!WARN_ON(XENO_DEBUG(__subsys) && !(__cond)))
#define XENO_BUG(__subsys)                \
   BUG_ON(XENO_DEBUG(__subsys))
#define XENO_BUG_ON(__subsys, __cond)            \
   BUG_ON(XENO_DEBUG(__subsys) && (__cond))
#define XENO_WARN(__subsys, __cond, __fmt...)        \
   WARN(XENO_DEBUG(__subsys) && (__cond), __fmt)
#define XENO_WARN_ON(__subsys, __cond)            \
   WARN_ON(XENO_DEBUG(__subsys) && (__cond))
#define XENO_WARN_ON_ONCE(__subsys, __cond)        \
   WARN_ON_ONCE(XENO_DEBUG(__subsys) && (__cond))
#ifdef CONFIG_SMP
#define XENO_BUG_ON_SMP(__subsys, __cond)        \
   XENO_BUG_ON(__subsys, __cond)
#define XENO_WARN_ON_SMP(__subsys, __cond)        \
   XENO_WARN_ON(__subsys, __cond)
#define XENO_WARN_ON_ONCE_SMP(__subsys, __cond)        \
   XENO_WARN_ON_ONCE(__subsys, __cond)
#else
#define XENO_BUG_ON_SMP(__subsys, __cond)        \
   do { } while (0)
#define XENO_WARN_ON_SMP(__subsys, __cond)        \
   do { } while (0)
#define XENO_WARN_ON_ONCE_SMP(__subsys, __cond)        \
   do { } while (0)
#endif
 
#define primary_mode_only()    XENO_BUG_ON(CONTEXT, is_secondary_domain())
#define secondary_mode_only()    XENO_BUG_ON(CONTEXT, !is_secondary_domain())
#define interrupt_only()    XENO_BUG_ON(CONTEXT, !xnsched_interrupt_p())
#define realtime_cpu_only()    XENO_BUG_ON(CONTEXT, !xnsched_supported_cpu(raw_smp_processor_id()))
#define thread_only()        XENO_BUG_ON(CONTEXT, xnsched_interrupt_p())
#define irqoff_only()        XENO_BUG_ON(CONTEXT, hard_irqs_disabled() == 0)
#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
#define atomic_only()        XENO_BUG_ON(CONTEXT, (xnlock_is_owner(&nklock) && hard_irqs_disabled()) == 0)
#define preemptible_only()    XENO_BUG_ON(CONTEXT, xnlock_is_owner(&nklock) || hard_irqs_disabled())
#else
#define atomic_only()        XENO_BUG_ON(CONTEXT, hard_irqs_disabled() == 0)
#define preemptible_only()    XENO_BUG_ON(CONTEXT, hard_irqs_disabled() != 0)
#endif
 
#endif /* !_COBALT_KERNEL_ASSERT_H */