revert between 56095 -> 55830 in arch
[AROS.git] / arch / all-pc / kernel / _bug.c
blob5ce7e9ca38df47d5f5caf49fbaf38e60cdc72692
1 /*
2 Copyright © 1995-2018, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 */
8 #include <stdarg.h>
9 #include <stdio.h>
11 #include <kernel_base.h>
12 #include <kernel_debug.h>
14 #if defined(__AROSEXEC_SMP__)
15 #include <aros/atomic.h>
16 #include <asm/cpu.h>
17 extern volatile ULONG safedebug;
18 #endif
20 #include <proto/exec.h>
22 static int UniPutC(int c, struct KernelBase *KernelBase);
25 * This is internal version of KrnBug(), to be called directly by bug() macro.
26 * If you want to reimplement it, override this file.
27 * However, generally you won't want to do this, because __vcformat() supports
28 * AROS-specific extensions, like %b, which are unlikely supported by your host OS.
30 int krnBug(const char *format, va_list args, APTR kernelBase)
32 int retval = 0;
34 #if defined(__AROSEXEC_SMP__)
35 if (safedebug & 1)
37 while (bit_test_and_set_long((ULONG*)&safedebug, 1)) { asm volatile("pause"); };
39 #endif
41 retval = __vcformat(kernelBase, (int (*)(int, void *))UniPutC, format, args);
43 #if defined(__AROSEXEC_SMP__)
44 if (safedebug & 1)
46 __AROS_ATOMIC_AND_L(safedebug, ~(1 << 1));
48 #endif
50 return retval;
54 * This is yet another character stuffing callback for debug output. This one unifies the output
55 * with debug output from outside the kernel where possible, allowing kernel debug output to be
56 * redirected alongside that other output (e.g. with Sashimi or Bifteck).
58 static int UniPutC(int c, struct KernelBase *KernelBase)
60 int result;
62 if (SysBase != NULL)
64 RawPutChar(c);
65 result = 1;
67 else
68 result = krnPutC(c, KernelBase);
70 return result;