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