Module Name:    src
Committed By:   skrll
Date:           Thu Apr  5 20:12:09 UTC 2012

Modified Files:
        src/sys/arch/hp700/hp700: machdep.c

Log Message:
Replace #ifdef DEBUG/BTLBDEBUG with DPRINTF{,N}


To generate a diff of this commit:
cvs rdiff -u -r1.109 -r1.110 src/sys/arch/hp700/hp700/machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/hp700/hp700/machdep.c
diff -u src/sys/arch/hp700/hp700/machdep.c:1.109 src/sys/arch/hp700/hp700/machdep.c:1.110
--- src/sys/arch/hp700/hp700/machdep.c:1.109	Sun Feb 26 07:52:52 2012
+++ src/sys/arch/hp700/hp700/machdep.c	Thu Apr  5 20:12:09 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.109 2012/02/26 07:52:52 skrll Exp $	*/
+/*	$NetBSD: machdep.c,v 1.110 2012/04/05 20:12:09 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.109 2012/02/26 07:52:52 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.110 2012/04/05 20:12:09 skrll Exp $");
 
 #include "opt_cputype.h"
 #include "opt_ddb.h"
@@ -133,6 +133,24 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 
 #include "ksyms.h"
 #include "lcd.h"
 
+#ifdef MACHDEPDEBUG
+
+#define	DPRINTF(s)	do {		\
+	if (machdepdebug)		\
+		printf s;		\
+} while(0)
+
+#define	DPRINTFN(l,s)	do {		\
+	if (machdepdebug >= (1))	\
+		printf s;		\
+} while(0)
+
+int machdepdebug = 1;
+#else
+#define	DPRINTF(s)	/* */
+#define	DPRINTFN(l,s)	/* */
+#endif
+
 /*
  * Different kinds of flags used throughout the kernel.
  */
@@ -466,9 +484,7 @@ hppa_init(paddr_t start, void *bi)
 	/* cache parameters */
 	error = pdcproc_cache(&pdc_cache);
 	if (error < 0) {
-#ifdef DEBUG
-		printf("WARNING: PDC_CACHE error %d\n", error);
-#endif
+		DPRINTF(("WARNING: PDC_CACHE error %d\n", error));
 	}
 
 	dcache_line_mask = pdc_cache.dc_conf.cc_line * 16 - 1;
@@ -477,9 +493,7 @@ hppa_init(paddr_t start, void *bi)
 	icache_stride = pdc_cache.ic_stride;
 
 	error = pdcproc_cache_spidbits(&pdc_spidbits);
-#ifdef DEBUG
-	printf("SPID bits: 0x%x, error = %d\n", pdc_spidbits.spidbits, error);
-#endif
+	DPRINTF(("SPID bits: 0x%x, error = %d\n", pdc_spidbits.spidbits, error));
 
 	/* Calculate the OS_HPMC handler checksums. */
 	p = &os_hpmc;
@@ -568,15 +582,12 @@ do {									\
 	 * WITHOUT TAKING SPECIAL MEASURES.
 	 */
 
-#ifdef DEBUG
-	printf("%s: PDC_CHASSIS\n", __func__);
-#endif
+	DPRINTF(("%s: PDC_CHASSIS\n", __func__));
+
 	/* they say PDC_COPROC might turn fault light on */
 	pdcproc_chassis_display(PDC_OSTAT(PDC_OSTAT_RUN) | 0xCEC0);
 
-#ifdef DEBUG
-	printf("%s: intr bootstrap\n", __func__);
-#endif
+	DPRINTF(("%s: intr bootstrap\n", __func__));
 	/* Bootstrap interrupt masking and dispatching. */
 	hp700_intr_bootstrap();
 
@@ -658,39 +669,34 @@ cpuid(void)
 	/* identify system type */
 	error = pdcproc_model_info(&pdc_model);
 	if (error < 0) {
-#ifdef DEBUG
-		printf("WARNING: PDC_MODEL_INFO error %d\n", error);
-#endif
+		DPRINTF(("WARNING: PDC_MODEL_INFO error %d\n", error));
+		
 		pdc_model.hwmodel = 0;
 		pdc_model.hv = 0;
 	} else {
-#ifdef DEBUG
-		printf("pdc_model.hwmodel/hv %x/%x\n", pdc_model.hwmodel,
-		    pdc_model.hv);
-#endif
+		DPRINTF(("pdc_model.hwmodel/hv %x/%x\n", pdc_model.hwmodel,
+		    pdc_model.hv));
 	}
 	cpu_modelno = pdc_model.hwmodel;
 	model = hppa_mod_info(HPPA_TYPE_BOARD, cpu_modelno);
-#ifdef DEBUG
-	printf("%s: model %s\n", __func__, model);
-#endif
+
+	DPRINTF(("%s: model %s\n", __func__, model));
+
 	pdc_settype(cpu_modelno);
 
 	memset(&pdc_cpuid, 0, sizeof(pdc_cpuid));
 	error = pdcproc_model_cpuid(&pdc_cpuid);
 	if (error < 0) {
-#ifdef DEBUG
-		printf("WARNING: PDC_MODEL_CPUID error %d. "
-		    "Using cpu_modelno based cpu_type.\n", error);
-#endif
+		DPRINTF(("WARNING: PDC_MODEL_CPUID error %d. "
+		    "Using cpu_modelno based cpu_type.\n", error));
+
 		cpu_type = cpu_model_cpuid(cpu_modelno);
 	} else {
-#ifdef DEBUG
-		printf("%s: cpuid.version  = %x\n", __func__,
-		    pdc_cpuid.version);
-		printf("%s: cpuid.revision = %x\n", __func__,
-		    pdc_cpuid.revision);
-#endif
+		DPRINTF(("%s: cpuid.version  = %x\n", __func__,
+		    pdc_cpuid.version));
+		DPRINTF(("%s: cpuid.revision = %x\n", __func__,
+		    pdc_cpuid.revision));
+
 		cpu_version = pdc_cpuid.version;
 
 		/* XXXNH why? */
@@ -704,62 +710,50 @@ cpuid(void)
 	memset(&pdc_coproc, 0, sizeof(pdc_coproc));
 	error = pdcproc_coproc(&pdc_coproc);
 	if (error < 0) {
-		printf("WARNING: PDC_COPROC error %d\n", error);
+		DPRINTF(("WARNING: PDC_COPROC error %d\n", error));
 		pdc_coproc.ccr_enable = 0;
 	} else {
-#ifdef DEBUG
-		printf("pdc_coproc: 0x%x, 0x%x; model %x rev %x\n",
+		DPRINTF(("pdc_coproc: 0x%x, 0x%x; model %x rev %x\n",
 		    pdc_coproc.ccr_enable, pdc_coproc.ccr_present,
-		    pdc_coproc.fpu_model, pdc_coproc.fpu_revision);
+		    pdc_coproc.fpu_model, pdc_coproc.fpu_revision));
 
-#endif
 		/* a kludge to detect PCXW */
 		if (pdc_coproc.fpu_model == HPPA_FPU_PCXW)
 			cpu_version = HPPA_CPU_PCXW;
 	}
 	mtctl(pdc_coproc.ccr_enable & CCR_MASK, CR_CCR);
-#ifdef DEBUG
-	printf("%s: bootstrap fpu\n", __func__);
-#endif
-	
+	DPRINTF(("%s: bootstrap fpu\n", __func__));
+
 	usebtlb = 0;
 	if (cpu_version == HPPA_CPU_PCXW || cpu_version > HPPA_CPU_PCXL2) {
-#ifdef DEBUG
-		printf("WARNING: BTLB no supported on cpu %d\n", cpu_version);
-#endif
+		DPRINTF(("WARNING: BTLB no supported on cpu %d\n", cpu_version));
 	} else {
 
 		/* BTLB params */
 		error = pdcproc_block_tlb(&pdc_btlb);
 		if (error < 0) {
-#ifdef DEBUG
-			printf("WARNING: PDC_BTLB error %d\n", error);
-#endif
+			DPRINTF(("WARNING: PDC_BTLB error %d\n", error));
 		} else {
-#define BTLBDEBUG 1
-
-#ifdef BTLBDEBUG
-			printf("btlb info: minsz=%d, maxsz=%d\n",
-			    pdc_btlb.min_size, pdc_btlb.max_size);
-			printf("btlb fixed: i=%d, d=%d, c=%d\n",
+			DPRINTFN(10, ("btlb info: minsz=%d, maxsz=%d\n",
+			    pdc_btlb.min_size, pdc_btlb.max_size));
+			DPRINTFN(10, ("btlb fixed: i=%d, d=%d, c=%d\n",
 			    pdc_btlb.finfo.num_i,
 			    pdc_btlb.finfo.num_d,
-			    pdc_btlb.finfo.num_c);
-			printf("btlb varbl: i=%d, d=%d, c=%d\n",
+			    pdc_btlb.finfo.num_c));
+			DPRINTFN(10, ("btlb varbl: i=%d, d=%d, c=%d\n",
 			    pdc_btlb.vinfo.num_i,
 			    pdc_btlb.vinfo.num_d,
-			    pdc_btlb.vinfo.num_c);
-#endif /* BTLBDEBUG */
+			    pdc_btlb.vinfo.num_c));
+
 			/* purge TLBs and caches */
 			if (pdcproc_btlb_purgeall() < 0)
-				printf("WARNING: BTLB purge failed\n");
+				DPRINTFN(10, ("WARNING: BTLB purge failed\n"));
 
 			hppa_btlb_size_min = pdc_btlb.min_size;
 			hppa_btlb_size_max = pdc_btlb.max_size;
-#ifdef DEBUG
-			printf("hppa_btlb_size_min 0x%x\n", hppa_btlb_size_min);
-			printf("hppa_btlb_size_max 0x%x\n", hppa_btlb_size_max);
-#endif
+
+			DPRINTF(("hppa_btlb_size_min 0x%x\n", hppa_btlb_size_min));
+			DPRINTF(("hppa_btlb_size_max 0x%x\n", hppa_btlb_size_max));
 
 			if (pdc_btlb.finfo.num_c)
 				cpu_features |= HPPA_FTRS_BTLBU;
@@ -775,13 +769,11 @@ cpuid(void)
 			pmap_hptsize = pdc_hwtlb.max_size;
 		else if (pmap_hptsize && pmap_hptsize < pdc_hwtlb.min_size)
 			pmap_hptsize = pdc_hwtlb.min_size;
-#ifdef DEBUG
-		printf("%s: pmap_hptsize 0x%x\n", __func__, pmap_hptsize);
-#endif
+
+		DPRINTF(("%s: pmap_hptsize 0x%x\n", __func__, pmap_hptsize));
 	} else {
-#ifdef DEBUG
-		printf("WARNING: no HPT support, fine!\n");
-#endif
+		DPRINTF(("WARNING: no HPT support, fine!\n"));
+
 		pmap_hptsize = 0;
 	}
 
@@ -918,7 +910,7 @@ cpu_startup(void)
 #ifdef DEBUG
 	if (totalphysmem > physmem) {
 		format_bytes(pbuf[0], sizeof(pbuf[0]), ptoa(totalphysmem - physmem));
-		printf("lost mem = %s\n", pbuf[0]);
+		DPRINTF(("lost mem = %s\n", pbuf[0]));
 	}
 #endif
 
@@ -1067,7 +1059,7 @@ ibtlb_g(int i, pa_space_t sp, vaddr_t va
 	error = pdcproc_btlb_insert(sp, va, pa, sz, prot, i);
 	if (error < 0) {
 #ifdef BTLBDEBUG
-		printf("WARNING: BTLB insert failed (%d)\n", error);
+		DPRINTF(("WARNING: BTLB insert failed (%d)\n", error);
 #endif
 	}
 	return error;
@@ -1099,21 +1091,22 @@ _hp700_btlb_insert(struct btlb_slot *btl
 	default:		prot = "??????"; break;
 	}
 
-	printf("  [ BTLB slot %d: %s 0x%08x @ 0x%x:0x%08x len 0x%08x prot 0x%08x]  ",
-		btlb_slot->btlb_slot_number,
-		prot,
-		(u_int)btlb_slot->btlb_slot_pa_frame << PGSHIFT,
-		btlb_slot->btlb_slot_va_space,
-		(u_int)btlb_slot->btlb_slot_va_frame << PGSHIFT,
-		(u_int)btlb_slot->btlb_slot_frames << PGSHIFT,
-		btlb_slot->btlb_slot_tlbprot);
+	DPRINTFN(10, (
+	    "  [ BTLB %d: %s 0x%08x @ 0x%x:0x%08x len 0x%08x prot 0x%08x]  ",
+	    btlb_slot->btlb_slot_number,
+	    prot,
+	    (u_int)btlb_slot->btlb_slot_pa_frame << PGSHIFT,
+	    btlb_slot->btlb_slot_va_space,
+	    (u_int)btlb_slot->btlb_slot_va_frame << PGSHIFT,
+	    (u_int)btlb_slot->btlb_slot_frames << PGSHIFT,
+	    btlb_slot->btlb_slot_tlbprot));
 
 	/*
 	 * Non-I/O space mappings are entered by the pmap,
 	 * so we do print a newline to make things look better.
 	 */
 	if (btlb_slot->btlb_slot_pa_frame < (HPPA_IOSPACE >> PGSHIFT))
-		printf("\n");
+		DPRINTFN(10, ("\n"));
 #endif
 
 	/* Insert this mapping. */
@@ -1126,7 +1119,7 @@ _hp700_btlb_insert(struct btlb_slot *btl
 		btlb_slot->btlb_slot_number);
 	if (error < 0) {
 #ifdef BTLBDEBUG
-		printf("WARNING: BTLB insert failed (%d)\n", error);
+		DPRINTF(("WARNING: BTLB insert failed (%d)\n", error);
 #endif
 	}
 	return (error ? EINVAL : 0);
@@ -1181,7 +1174,7 @@ hppa_btlb_insert(pa_space_t space, vaddr
 	frames >>= PGSHIFT;
 	if (frames > pdc_btlb.max_size) {
 #ifdef BTLBDEBUG
-		printf("btlb_insert: too big (%u < %u < %u)\n",
+		DPRINTF(("btlb_insert: too big (%u < %u < %u)\n",
 		    pdc_btlb.min_size, (u_int) frames, pdc_btlb.max_size);
 #endif
 		return -(ENOMEM);
@@ -1247,9 +1240,7 @@ hppa_btlb_insert(pa_space_t space, vaddr
 		 * If there were no applicable slots.
 		 */
 		if (btlb_slot_best == NULL) {
-#ifdef BTLBDEBUG
-			printf("BTLB full\n");
-#endif
+			DPRINTFN(10, ("BTLB full\n"));
 			return -(ENOMEM);
 		}
 			
@@ -1303,9 +1294,7 @@ hppa_btlb_reload(void)
 			error = _hp700_btlb_insert(btlb_slot);
 		btlb_slot++;
 	}
-#ifdef DEBUG
-	printf("\n");
-#endif
+	DPRINTF(("\n"));
 	return (error);
 }
 
@@ -1336,10 +1325,9 @@ hppa_btlb_purge(pa_space_t space, vaddr_
 				btlb_slot->btlb_slot_number,
 				btlb_slot->btlb_slot_frames);
 			if (error < 0) {
-#ifdef BTLBDEBUG
-				printf("WARNING: BTLB purge failed (%d)\n",
-					error);
-#endif
+				DPRINTFN(10, ("WARNING: BTLB purge failed (%d)\n",
+					error));
+
 				return (error);
 			}
 

Reply via email to