Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


hacked in PCI IO port auto assignment because our BIOS for whatever reason doesn...
[palacios.git] / geekos / include / geekos / kassert.h
1 /*
2  * Definition of KASSERT() macro, and other useful debug macros
3  * Copyright (c) 2001, David H. Hovemeyer <daveho@cs.umd.edu>
4  * $Revision: 1.1 $
5  * 
6  * This is free software.  You are permitted to use,
7  * redistribute, and modify it as specified in the file "COPYING".
8  */
9
10 #ifndef GEEKOS_KASSERT_H
11 #define GEEKOS_KASSERT_H
12
13 #include <geekos/screen.h>
14
15 #ifndef NDEBUG
16
17 struct Kernel_Thread;
18 extern struct Kernel_Thread* g_currentThread;
19
20 #define KASSERT(cond)                                   \
21 do {                                                    \
22     if (!(cond)) {                                      \
23         Set_Current_Attr(ATTRIB(RED, GRAY|BRIGHT));     \
24         Print("Failed assertion in %s: %s at %s, line %d, RA=%lx, thread=%p\n",\
25                 __func__, #cond, __FILE__, __LINE__,    \
26                 (ulong_t) __builtin_return_address(0),  \
27                 g_currentThread);                       \
28         while (1)                                       \
29            ;                                            \
30     }                                                   \
31 } while (0)
32
33 #define TODO(message)                                   \
34 do {                                                    \
35     Set_Current_Attr(ATTRIB(BLUE, GRAY|BRIGHT));        \
36     Print("Unimplemented feature: %s\n", (message));    \
37     while (1)                                           \
38         ;                                               \
39 } while (0)
40
41 /*
42  * Spin for some number of iterations.
43  * This is useful for slowing down things that go by too
44  * quickly.
45  */
46 #define PAUSE(count)                    \
47 do {                                    \
48     ulong_t i;                          \
49     for (i = 0; i < (count); ++i)       \
50         ;                               \
51 } while (0)
52
53 #else
54
55 /*
56  * The debug macros are no-ops when NDEBUG is defined.
57  */
58 #define KASSERT(cond)
59 #define TODO(message)
60 #define PAUSE(count)
61
62 #endif
63
64 /*
65  * Stop dead.
66  * Its behavior does not depend on whether or not this
67  * is a debug build.
68  */
69 #define STOP() while (1)
70
71 /*
72  * Panic function.
73  */
74 #define Panic(args...)                          \
75 do {                                            \
76     Set_Current_Attr(ATTRIB(RED, GRAY|BRIGHT)); \
77     Print(args);                                \
78     while (1) ;                                 \
79 } while (0)
80
81 #endif  /* GEEKOS_KASSERT_H */