Home | History | Annotate | Line # | Download | only in scsipi
      1  1.17    martin /*	$NetBSD: scsipi_debug.h,v 1.17 2008/04/28 20:23:58 martin Exp $	*/
      2  1.13    bouyer 
      3  1.13    bouyer /*-
      4  1.13    bouyer  * Copyright (c) 1999 The NetBSD Foundation, Inc.
      5  1.13    bouyer  * All rights reserved.
      6  1.13    bouyer  *
      7  1.13    bouyer  * This code is derived from software contributed to The NetBSD Foundation
      8  1.13    bouyer  * by by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      9  1.13    bouyer  * NASA Ames Research Center.
     10  1.13    bouyer  *
     11  1.13    bouyer  * Redistribution and use in source and binary forms, with or without
     12  1.13    bouyer  * modification, are permitted provided that the following conditions
     13  1.13    bouyer  * are met:
     14  1.13    bouyer  * 1. Redistributions of source code must retain the above copyright
     15  1.13    bouyer  *    notice, this list of conditions and the following disclaimer.
     16  1.13    bouyer  * 2. Redistributions in binary form must reproduce the above copyright
     17  1.13    bouyer  *    notice, this list of conditions and the following disclaimer in the
     18  1.13    bouyer  *    documentation and/or other materials provided with the distribution.
     19  1.13    bouyer  *
     20  1.13    bouyer  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     21  1.13    bouyer  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     22  1.13    bouyer  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     23  1.13    bouyer  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     24  1.13    bouyer  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     25  1.13    bouyer  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     26  1.13    bouyer  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     27  1.13    bouyer  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     28  1.13    bouyer  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     29  1.13    bouyer  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     30  1.13    bouyer  * POSSIBILITY OF SUCH DAMAGE.
     31  1.13    bouyer  */
     32  1.13    bouyer 
     33  1.14       mrg #if defined(_KERNEL_OPT)
     34  1.13    bouyer #include "opt_scsipi_debug.h"
     35  1.13    bouyer #endif
     36   1.3       cgd 
     37   1.1   mycroft /*
     38  1.13    bouyer  * Originally written by Julian Elischer (julian (at) tfs.com)
     39   1.1   mycroft  */
     40  1.11     enami 
     41  1.15     perry #define	SCSIPI_DB1	0x0001		/* scsi commands, errors, data */
     42  1.13    bouyer #define	SCSIPI_DB2	0x0002		/* routine flow tracking */
     43  1.13    bouyer #define	SCSIPI_DB3	0x0004		/* internal to routine flows */
     44  1.13    bouyer #define	SCSIPI_DB4	0x0008		/* level 4 debugging for this dev */
     45  1.13    bouyer 
     46   1.1   mycroft /*
     47  1.13    bouyer  * The following options allow us to build a kernel with debugging on
     48  1.13    bouyer  * by default for a certain type of device.  We can always enable
     49  1.13    bouyer  * debugging on a specific device using an ioctl.
     50   1.1   mycroft  */
     51  1.13    bouyer #ifndef SCSIPI_DEBUG_TYPE
     52  1.13    bouyer #define	SCSIPI_DEBUG_TYPE	SCSIPI_BUSTYPE_ATAPI
     53  1.13    bouyer #endif
     54  1.13    bouyer 
     55  1.13    bouyer #ifndef SCSIPI_DEBUG_TARGET
     56  1.13    bouyer #define	SCSIPI_DEBUG_TARGET	-1	/* disabled */
     57  1.13    bouyer #endif
     58  1.13    bouyer 
     59  1.13    bouyer #ifndef	SCSIPI_DEBUG_LUN
     60  1.13    bouyer #define	SCSIPI_DEBUG_LUN	0
     61  1.13    bouyer #endif
     62  1.13    bouyer 
     63   1.1   mycroft /*
     64  1.13    bouyer  * Default debugging flags for above.
     65   1.1   mycroft  */
     66  1.13    bouyer #ifndef SCSIPI_DEBUG_FLAGS
     67  1.13    bouyer #define	SCSIPI_DEBUG_FLAGS	(SCSIPI_DB1|SCSIPI_DB2|SCSIPI_DB3)
     68  1.13    bouyer #endif
     69  1.13    bouyer 
     70  1.13    bouyer #ifdef SCSIPI_DEBUG
     71  1.13    bouyer #define	SC_DEBUG(periph, flags, x)					\
     72   1.8    bouyer do {									\
     73  1.13    bouyer 	if ((periph)->periph_dbflags & (flags)) {			\
     74  1.13    bouyer 		scsipi_printaddr((periph));				\
     75  1.13    bouyer 		printf x ;						\
     76   1.8    bouyer 	}								\
     77  1.10  christos } while (0)
     78   1.8    bouyer 
     79  1.13    bouyer #define	SC_DEBUGN(periph, flags, x)					\
     80   1.8    bouyer do {									\
     81  1.13    bouyer 	if ((periph)->periph_dbflags & (flags))				\
     82  1.13    bouyer 		printf x ;						\
     83  1.10  christos } while (0)
     84   1.1   mycroft #else
     85  1.13    bouyer #define	SC_DEBUG(periph, flags, x)	/* nothing */
     86  1.13    bouyer #define	SC_DEBUGN(periph, flags, x)	/* nothing */
     87   1.1   mycroft #endif
     88