revert between 56095 -> 55830 in arch
[AROS.git] / arch / all-pc / kernel / kernel_debug.h
blobef86ac0def0acc5cd59ff0c5c936f42b277e02e7
1 /*
2 Copyright � 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 */
8 /*
9 * This file contains useful redefinition of bug() macro which uses
10 * kernel.resource's own debugging facilities. Include it if you
11 * need bug() in your code.
14 #ifndef __KERNEL_DEBUG_H_
15 #define __KERNEL_DEBUG_H_
17 #include <aros/config.h>
18 #include <aros/asmcall.h>
19 #include <aros/libcall.h>
20 #include <stdarg.h>
22 #include "kernel_intern.h"
24 #ifdef bug
25 #undef bug
26 #endif
28 int krnPutC(int chr, struct KernelBase *KernelBase);
29 int krnBug(const char *format, va_list args, APTR kernelBase);
30 void krnDisplayAlert(const char *text, struct KernelBase *KernelBase);
31 void krnPanic(struct KernelBase *KernelBase, const char *fmt, ...);
34 #define __cli() __asm__ __volatile__("cli": : :"memory")
35 #define __sti() __asm__ __volatile__("sti": : :"memory")
37 #if defined(__AROSEXEC_SMP__)
38 #include <aros/atomic.h>
39 #include <asm/cpu.h>
40 extern volatile ULONG safedebug;
41 #endif
43 static inline void _bug(APTR kernelBase, const char *format, ...)
45 va_list args;
46 #if defined(__AROSEXEC_SMP__)
47 unsigned long flags = 0;
48 if (safedebug & 1)
50 __save_flags(flags);
51 __cli();
53 #endif
54 va_start(args, format);
56 /*
57 * We use internal entry here. This is done because this function can be used
58 * during early boot, while KernelBase is NULL. However it's still passed,
59 * just in case.
61 krnBug(format, args, kernelBase);
63 va_end(args);
64 #if defined(__AROSEXEC_SMP__)
65 if (safedebug & 1)
67 __restore_flags(flags);
69 #endif
72 #define bug(...) _bug(KernelBase, __VA_ARGS__)
73 #define nbug(...) _bug(NULL, __VA_ARGS__)
74 #endif