Wed Dec 2 13:49:32 2009 UTC ()
Define DPRINTF and use it.


(skrll)
diff -r1.57 -r1.58 src/sys/arch/hp700/hp700/mainbus.c

cvs diff -r1.57 -r1.58 src/sys/arch/hp700/hp700/Attic/mainbus.c (expand / switch to context diff)
--- src/sys/arch/hp700/hp700/Attic/mainbus.c 2009/12/02 13:45:13 1.57
+++ src/sys/arch/hp700/hp700/Attic/mainbus.c 2009/12/02 13:49:32 1.58
@@ -1,4 +1,4 @@
-/*	$NetBSD: mainbus.c,v 1.57 2009/12/02 13:45:13 skrll Exp $	*/
+/*	$NetBSD: mainbus.c,v 1.58 2009/12/02 13:49:32 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.57 2009/12/02 13:45:13 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.58 2009/12/02 13:49:32 skrll Exp $");
 
 #include "locators.h"
 #include "power.h"
@@ -83,6 +83,18 @@
 
 static struct pdc_hpa pdc_hpa PDC_ALIGNMENT;
 
+#ifdef MBUSDEBUG
+
+#define	DPRINTF(s)	do {	\
+	if (mbusdebug)		\
+		printf s;	\
+} while(0)
+
+int mbusdebug = 1;
+#else
+#define	DPRINTF(s)	/* */
+#endif
+
 struct mainbus_softc {
 	device_t sc_dv;
 
@@ -178,6 +190,9 @@
 	int error;
 #endif /* USE_BTLB */
 
+	DPRINTF(("\n%s(%lx,%lx,%scachable,%p)\n", __func__,
+	    bpa, size, flags? "" : "non", bshp));
+
 	/*
 	 * We must be called with a page-aligned address in
 	 * I/O space, and with a multiple of the page size.
@@ -330,9 +345,9 @@
 	error = mbus_add_mapping(bpa, size, flags, bshp);
 	*bshp |= offset;
 	if (error) {
+		DPRINTF(("bus_space_map: pa 0x%lx, size 0x%lx failed\n",
+		    bpa, size));
 		if (extent_free(hp700_io_extent, bpa, size, EX_NOWAIT)) {
-			printf ("bus_space_map: pa 0x%lx, size 0x%lx\n",
-				bpa, size);
 			printf ("bus_space_map: can't free region\n");
 		}
 	}
@@ -367,8 +382,8 @@
 	 */
 	error = extent_free(hp700_io_extent, bpa, size, EX_NOWAIT);
 	if (error) {
-		printf("bus_space_unmap: ps 0x%lx, size 0x%lx\n",
-		    bpa, size);
+		DPRINTF(("bus_space_unmap: ps 0x%lx, size 0x%lx\n",
+		    bpa, size));
 		panic("bus_space_unmap: can't free region (%d)", error);
 	}
 }
@@ -405,9 +420,9 @@
 	 */
 	error = mbus_add_mapping(bpa, size, flags, bshp);
 	if (error) {
+		DPRINTF(("bus_space_alloc: pa 0x%lx, size 0x%lx failed\n",
+		    bpa, size));
 		if (extent_free(hp700_io_extent, bpa, size, EX_NOWAIT)) {
-			printf("bus_space_alloc: pa 0x%lx, size 0x%lx\n",
-				bpa, size);
 			printf("bus_space_alloc: can't free region\n");
 		}
 	}