kerndebug.h revision 1.1.14.2 1 1.1.14.2 jdolecek /* $NetBSD: kerndebug.h,v 1.1.14.2 2002/06/23 17:41:09 jdolecek Exp $ */
2 1.1.14.2 jdolecek
3 1.1.14.2 jdolecek /*
4 1.1.14.2 jdolecek * Copyright 1997
5 1.1.14.2 jdolecek * Digital Equipment Corporation. All rights reserved.
6 1.1.14.2 jdolecek *
7 1.1.14.2 jdolecek * This software is furnished under license and may be used and
8 1.1.14.2 jdolecek * copied only in accordance with the following terms and conditions.
9 1.1.14.2 jdolecek * Subject to these conditions, you may download, copy, install,
10 1.1.14.2 jdolecek * use, modify and distribute this software in source and/or binary
11 1.1.14.2 jdolecek * form. No title or ownership is transferred hereby.
12 1.1.14.2 jdolecek *
13 1.1.14.2 jdolecek * 1) Any source code used, modified or distributed must reproduce
14 1.1.14.2 jdolecek * and retain this copyright notice and list of conditions as
15 1.1.14.2 jdolecek * they appear in the source file.
16 1.1.14.2 jdolecek *
17 1.1.14.2 jdolecek * 2) No right is granted to use any trade name, trademark, or logo of
18 1.1.14.2 jdolecek * Digital Equipment Corporation. Neither the "Digital Equipment
19 1.1.14.2 jdolecek * Corporation" name nor any trademark or logo of Digital Equipment
20 1.1.14.2 jdolecek * Corporation may be used to endorse or promote products derived
21 1.1.14.2 jdolecek * from this software without the prior written permission of
22 1.1.14.2 jdolecek * Digital Equipment Corporation.
23 1.1.14.2 jdolecek *
24 1.1.14.2 jdolecek * 3) This software is provided "AS-IS" and any express or implied
25 1.1.14.2 jdolecek * warranties, including but not limited to, any implied warranties
26 1.1.14.2 jdolecek * of merchantability, fitness for a particular purpose, or
27 1.1.14.2 jdolecek * non-infringement are disclaimed. In no event shall DIGITAL be
28 1.1.14.2 jdolecek * liable for any damages whatsoever, and in particular, DIGITAL
29 1.1.14.2 jdolecek * shall not be liable for special, indirect, consequential, or
30 1.1.14.2 jdolecek * incidental damages or damages for lost profits, loss of
31 1.1.14.2 jdolecek * revenue or loss of use, whether such damages arise in contract,
32 1.1.14.2 jdolecek * negligence, tort, under statute, in equity, at law or otherwise,
33 1.1.14.2 jdolecek * even if advised of the possibility of such damage.
34 1.1.14.2 jdolecek */
35 1.1.14.2 jdolecek
36 1.1.14.2 jdolecek /*
37 1.1.14.2 jdolecek **++
38 1.1.14.2 jdolecek ** FACILITY:
39 1.1.14.2 jdolecek **
40 1.1.14.2 jdolecek ** kerndebug.h
41 1.1.14.2 jdolecek **
42 1.1.14.2 jdolecek **
43 1.1.14.2 jdolecek ** ABSTRACT:
44 1.1.14.2 jdolecek **
45 1.1.14.2 jdolecek ** This header provides generic debugging capabilities using printf.
46 1.1.14.2 jdolecek ** All debugging can be compiled out by not defining the
47 1.1.14.2 jdolecek ** KERNEL_DEBUG macro. In addition the amount of debug output is
48 1.1.14.2 jdolecek ** defined by individual variables controlled by each subsystem
49 1.1.14.2 jdolecek ** using this utility. Finally note that the two middle bytes of
50 1.1.14.2 jdolecek ** the kern debug flags (bits 16 to 23) are free for individual
51 1.1.14.2 jdolecek ** subsystems to use as they please (eg. define switches for
52 1.1.14.2 jdolecek ** individual functions etc).
53 1.1.14.2 jdolecek **
54 1.1.14.2 jdolecek ** AUTHORS:
55 1.1.14.2 jdolecek **
56 1.1.14.2 jdolecek ** John Court
57 1.1.14.2 jdolecek **
58 1.1.14.2 jdolecek ** CREATION DATE: 2-Feb-1992
59 1.1.14.2 jdolecek **
60 1.1.14.2 jdolecek ** MODIFICATION HISTORY:
61 1.1.14.2 jdolecek **
62 1.1.14.2 jdolecek **--
63 1.1.14.2 jdolecek */
64 1.1.14.2 jdolecek #ifndef _KERNDEBUG_H_
65 1.1.14.2 jdolecek #define _KERNDEBUG_H_
66 1.1.14.2 jdolecek
67 1.1.14.2 jdolecek #define KERN_DEBUG_INFO 0x00000001
68 1.1.14.2 jdolecek #define KERN_DEBUG_WARNING 0x00000002
69 1.1.14.2 jdolecek #define KERN_DEBUG_ERROR 0x00000010
70 1.1.14.2 jdolecek #define KERN_DEBUG_SMP 0x00000020
71 1.1.14.2 jdolecek #define KERN_DEBUG_PANIC 0x40000000
72 1.1.14.2 jdolecek #define KERN_REAL_PANIC 0x80000000
73 1.1.14.2 jdolecek #define KERN_DEBUG_ALL KERN_DEBUG_INFO | KERN_DEBUG_WARNING | \
74 1.1.14.2 jdolecek KERN_DEBUG_ERROR | KERN_DEBUG_PANIC
75 1.1.14.2 jdolecek /*
76 1.1.14.2 jdolecek ** Define the type for debugging flag subsystem variables
77 1.1.14.2 jdolecek */
78 1.1.14.2 jdolecek typedef unsigned int Kern_Debug_Flags;
79 1.1.14.2 jdolecek /*
80 1.1.14.2 jdolecek ** Set up source line location macro for extra debugging and panics
81 1.1.14.2 jdolecek */
82 1.1.14.2 jdolecek #ifdef __FILE__
83 1.1.14.2 jdolecek #define KERN_DEBUG_LOC ":%s:%d:=\n\t",__FILE__,__LINE__
84 1.1.14.2 jdolecek #else
85 1.1.14.2 jdolecek #define KERN_DEBUG_LOC ":__FILE__ not supported :=\n\t"
86 1.1.14.2 jdolecek #endif
87 1.1.14.2 jdolecek
88 1.1.14.2 jdolecek /*
89 1.1.14.2 jdolecek ** This is real nasty in that it requires several printf's but is
90 1.1.14.2 jdolecek ** unavoidable due to the differences between
91 1.1.14.2 jdolecek ** preprocessors supporting standard ANSI C and others.
92 1.1.14.2 jdolecek **
93 1.1.14.2 jdolecek ** NOTE: The format of calls to this macro must be
94 1.1.14.2 jdolecek **
95 1.1.14.2 jdolecek ** KERN_DEBUG((Kern_Debug_Flags)CntrlVar, KERN_DEBUG_xxxx,
96 1.1.14.2 jdolecek ** (normal printf arguments));
97 1.1.14.2 jdolecek **
98 1.1.14.2 jdolecek ** pay special attention to the extra set of () around the
99 1.1.14.2 jdolecek ** final arguement.
100 1.1.14.2 jdolecek **
101 1.1.14.2 jdolecek */
102 1.1.14.2 jdolecek #ifdef KERNEL_DEBUG
103 1.1.14.2 jdolecek #define KERN_DEBUG(CntrlVar,Level,Output) \
104 1.1.14.2 jdolecek { \
105 1.1.14.2 jdolecek if ( (CntrlVar) & (Level) ) \
106 1.1.14.2 jdolecek { \
107 1.1.14.2 jdolecek if ( (CntrlVar) & (Level) & KERN_DEBUG_PANIC ) \
108 1.1.14.2 jdolecek { \
109 1.1.14.2 jdolecek printf ("KERNEL:DEBUG PANIC"); \
110 1.1.14.2 jdolecek printf (KERN_DEBUG_LOC); \
111 1.1.14.2 jdolecek printf Output; \
112 1.1.14.2 jdolecek panic("KERN_DEBUG Panicing"); \
113 1.1.14.2 jdolecek } \
114 1.1.14.2 jdolecek else \
115 1.1.14.2 jdolecek { \
116 1.1.14.2 jdolecek printf Output; \
117 1.1.14.2 jdolecek } \
118 1.1.14.2 jdolecek } \
119 1.1.14.2 jdolecek }
120 1.1.14.2 jdolecek #else /* else KERNEL_DEBUG not defined */
121 1.1.14.2 jdolecek #define KERN_DEBUG(CntrlVar,Level,Output)
122 1.1.14.2 jdolecek #endif /* end else KERNEL_DEBUG not defined */
123 1.1.14.2 jdolecek
124 1.1.14.2 jdolecek #endif /* _KERNDEBUG_H_ */
125 1.1.14.2 jdolecek
126 1.1.14.2 jdolecek
127 1.1.14.2 jdolecek
128 1.1.14.2 jdolecek
129 1.1.14.2 jdolecek
130 1.1.14.2 jdolecek
131 1.1.14.2 jdolecek
132 1.1.14.2 jdolecek
133