Module Name:    src
Committed By:   skrll
Date:           Tue Jul 31 07:00:48 UTC 2018

Modified Files:
        src/sys/arch/aarch64/aarch64: cpu.c pmap.c
        src/sys/arch/arm/arm32: arm32_boot.c arm32_kvminit.c arm32_machdep.c
            pmap.c

Log Message:
Define and use VPRINTF


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/aarch64/aarch64/cpu.c
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/aarch64/aarch64/pmap.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/arm32/arm32_boot.c
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/arm/arm32/arm32_kvminit.c
cvs rdiff -u -r1.115 -r1.116 src/sys/arch/arm/arm32/arm32_machdep.c
cvs rdiff -u -r1.365 -r1.366 src/sys/arch/arm/arm32/pmap.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/aarch64/aarch64/cpu.c
diff -u src/sys/arch/aarch64/aarch64/cpu.c:1.3 src/sys/arch/aarch64/aarch64/cpu.c:1.4
--- src/sys/arch/aarch64/aarch64/cpu.c:1.3	Tue Jul 17 00:29:55 2018
+++ src/sys/arch/aarch64/aarch64/cpu.c	Tue Jul 31 07:00:48 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.3 2018/07/17 00:29:55 christos Exp $ */
+/* $NetBSD: cpu.c,v 1.4 2018/07/31 07:00:48 skrll Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu <r...@nerv.org>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.3 2018/07/17 00:29:55 christos Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.4 2018/07/31 07:00:48 skrll Exp $");
 
 #include "locators.h"
 #include "opt_arm_debug.h"
@@ -50,6 +50,12 @@ __KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.3 
 #include <arm/fdt/arm_fdtvar.h>
 #endif
 
+#ifdef VERBOSE_INIT_ARM
+#define VPRINTF(...)	printf(__VA_ARGS__)
+#else
+#define VPRINTF(...)	do { } while (/* CONSTCOND */ 0)
+#endif
+
 void cpu_attach(device_t, cpuid_t);
 static void identify_aarch64_model(uint32_t, char *, size_t);
 static void cpu_identify(device_t self, struct cpu_info *, uint32_t, uint64_t);
@@ -495,9 +501,7 @@ cpu_boot_secondary_processors(void)
 {
 	mutex_init(&cpu_hatch_lock, MUTEX_DEFAULT, IPL_NONE);
 
-#ifdef VERBOSE_INIT_ARM
-	printf("%s: writing mbox with %#x\n", __func__, arm_cpu_hatched);
-#endif
+	VPRINTF("%s: writing mbox with %#x\n", __func__, arm_cpu_hatched);
 
 	/* send mbox to have secondary processors do cpu_hatch() */
 	atomic_or_32(&arm_cpu_mbox, arm_cpu_hatched);
@@ -508,9 +512,7 @@ cpu_boot_secondary_processors(void)
 		__asm __volatile ("wfe");
 	}
 
-#ifdef VERBOSE_INIT_ARM
-	printf("%s: secondary processors hatched\n", __func__);
-#endif
+	VPRINTF("%s: secondary processors hatched\n", __func__);
 
 	/* add available processors to kcpuset */
 	uint32_t mbox = arm_cpu_hatched;

Index: src/sys/arch/aarch64/aarch64/pmap.c
diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.15 src/sys/arch/aarch64/aarch64/pmap.c:1.16
--- src/sys/arch/aarch64/aarch64/pmap.c:1.15	Fri Jul 27 07:04:04 2018
+++ src/sys/arch/aarch64/aarch64/pmap.c	Tue Jul 31 07:00:48 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.15 2018/07/27 07:04:04 ryo Exp $	*/
+/*	$NetBSD: pmap.c,v 1.16 2018/07/31 07:00:48 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu <r...@nerv.org>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.15 2018/07/27 07:04:04 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.16 2018/07/31 07:00:48 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -50,6 +50,11 @@ __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.1
 //#define PMAP_DEBUG
 //#define PMAP_PV_DEBUG
 
+#ifdef VERBOSE_INIT_ARM
+#define VPRINTF(...)	printf(__VA_ARGS__)
+#else
+#define VPRINTF(...)	do { } while (/* CONSTCOND */ 0)
+#endif
 
 UVMHIST_DEFINE(pmaphist);
 #ifdef UVMHIST
@@ -289,16 +294,12 @@ pmap_devmap_bootstrap(const struct pmap_
 
 	l0 = (void *)AARCH64_PA_TO_KVA(reg_ttbr1_el1_read());
 
-#ifdef VERBOSE_INIT_ARM
-	printf("%s:\n", __func__);
-#endif
+	VPRINTF("%s:\n", __func__);
 	for (i = 0; table[i].pd_size != 0; i++) {
-#ifdef VERBOSE_INIT_ARM
-		printf(" devmap: pa %08lx-%08lx = va %016lx\n",
+		VPRINTF(" devmap: pa %08lx-%08lx = va %016lx\n",
 		    table[i].pd_pa,
 		    table[i].pd_pa + table[i].pd_size - 1,
 		    table[i].pd_va);
-#endif
 		va = table[i].pd_va;
 
 		/* update and check virtual_devmap_addr */

Index: src/sys/arch/arm/arm32/arm32_boot.c
diff -u src/sys/arch/arm/arm32/arm32_boot.c:1.19 src/sys/arch/arm/arm32/arm32_boot.c:1.20
--- src/sys/arch/arm/arm32/arm32_boot.c:1.19	Sun Jul  2 16:16:44 2017
+++ src/sys/arch/arm/arm32/arm32_boot.c	Tue Jul 31 07:00:48 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: arm32_boot.c,v 1.19 2017/07/02 16:16:44 skrll Exp $	*/
+/*	$NetBSD: arm32_boot.c,v 1.20 2018/07/31 07:00:48 skrll Exp $	*/
 
 /*
  * Copyright (c) 2002, 2003, 2005  Genetec Corporation.  All rights reserved.
@@ -123,8 +123,9 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: arm32_boot.c,v 1.19 2017/07/02 16:16:44 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: arm32_boot.c,v 1.20 2018/07/31 07:00:48 skrll Exp $");
 
+#include "opt_arm_debug.h"
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
 #include "opt_multiprocessor.h"
@@ -151,6 +152,12 @@ __KERNEL_RCSID(1, "$NetBSD: arm32_boot.c
 #include <sys/kgdb.h>
 #endif
 
+#ifdef VERBOSE_INIT_ARM
+#define VPRINTF(...)	printf(__VA_ARGS__)
+#else
+#define VPRINTF(...)	do { } while (/* CONSTCOND */ 0)
+#endif
+
 #ifdef MULTIPROCESSOR
 static kmutex_t cpu_hatch_lock;
 #endif
@@ -161,11 +168,9 @@ initarm_common(vaddr_t kvm_base, vsize_t
 {
 	struct bootmem_info * const bmi = &bootmem_info;
 
-#ifdef VERBOSE_INIT_ARM
-	printf("nfreeblocks = %u, free_pages = %d (%#x)\n",
+	VPRINTF("nfreeblocks = %u, free_pages = %d (%#x)\n",
 	    bmi->bmi_nfreeblocks, bmi->bmi_freepages,
 	    bmi->bmi_freepages);
-#endif
 
 	/*
 	 * Moved from cpu_startup() as data_abort_handler() references
@@ -194,17 +199,11 @@ initarm_common(vaddr_t kvm_base, vsize_t
  	tf->tf_spsr = PSR_USR32_MODE;
 #endif
 
-#ifdef VERBOSE_INIT_ARM
-	printf("bootstrap done.\n");
-#endif
+	VPRINTF("bootstrap done.\n");
 
-#ifdef VERBOSE_INIT_ARM
-	printf("vectors");
-#endif
+	VPRINTF("vectors");
 	arm32_vector_init(systempage.pv_va, ARM_VEC_ALL);
-#ifdef VERBOSE_INIT_ARM
-	printf(" %#"PRIxVADDR"\n", vector_page);
-#endif
+	VPRINTF(" %#"PRIxVADDR"\n", vector_page);
 
 	/*
 	 * Pages were allocated during the secondary bootstrap for the
@@ -214,9 +213,7 @@ initarm_common(vaddr_t kvm_base, vsize_t
 	 * Since the ARM stacks use STMFD etc. we must set r13 to the top end
 	 * of the stack memory.
 	 */
-#ifdef VERBOSE_INIT_ARM
-	printf("init subsystems: stacks ");
-#endif
+	VPRINTF("init subsystems: stacks ");
 	set_stackptr(PSR_FIQ32_MODE,
 	    fiqstack.pv_va + FIQ_STACK_SIZE * PAGE_SIZE);
 	set_stackptr(PSR_IRQ32_MODE,
@@ -235,28 +232,20 @@ initarm_common(vaddr_t kvm_base, vsize_t
 	 * Initialisation of the vectors will just panic on a data abort.
 	 * This just fills in a slightly better one.
 	 */
-#ifdef VERBOSE_INIT_ARM
-	printf("vectors ");
-#endif
+	VPRINTF("vectors ");
 	data_abort_handler_address = (u_int)data_abort_handler;
 	prefetch_abort_handler_address = (u_int)prefetch_abort_handler;
 	undefined_handler_address = (u_int)undefinedinstruction_bounce;
 
 	/* Initialise the undefined instruction handlers */
-#ifdef VERBOSE_INIT_ARM
-	printf("undefined ");
-#endif
+	VPRINTF("undefined ");
 	undefined_init();
 
 	/* Load memory into UVM. */
-#ifdef VERBOSE_INIT_ARM
-	printf("page ");
-#endif
+	VPRINTF("page ");
 	uvm_md_init();
 
-#ifdef VERBOSE_INIT_ARM
-	printf("pmap_physload ");
-#endif
+	VPRINTF("pmap_physload ");
 	KASSERT(bp != NULL || nbp == 0);
 	KASSERT(bp == NULL || nbp != 0);
 
@@ -297,9 +286,7 @@ initarm_common(vaddr_t kvm_base, vsize_t
 	}
 
 	/* Boot strap pmap telling it where the kernel page table is */
-#ifdef VERBOSE_INIT_ARM
-	printf("pmap ");
-#endif
+	VPRINTF("pmap ");
 	pmap_bootstrap(kvm_base, kvm_base + kvm_size);
 
 #ifdef __HAVE_MEMORY_DISK__
@@ -329,9 +316,7 @@ initarm_common(vaddr_t kvm_base, vsize_t
 	mutex_init(&cpu_hatch_lock, MUTEX_DEFAULT, IPL_NONE);
 #endif
 
-#ifdef VERBOSE_INIT_ARM
-	printf("done.\n");
-#endif
+	VPRINTF("done.\n");
 
 	/* We return the new stack pointer address */
 	return pcb->pcb_ksp;
@@ -359,9 +344,7 @@ cpu_hatch(struct cpu_info *ci, cpuid_t c
 #endif
 #endif
 
-#ifdef VERBOSE_INIT_ARM
-	printf("%s(%s): ", __func__, ci->ci_data.cpu_name);
-#endif
+	VPRINTF("%s(%s): ", __func__, ci->ci_data.cpu_name);
 	uint32_t mpidr = armreg_mpidr_read();
 	if (mpidr & MPIDR_MT) {
 		ci->ci_data.cpu_smt_id = mpidr & MPIDR_AFF0;
@@ -375,18 +358,14 @@ cpu_hatch(struct cpu_info *ci, cpuid_t c
 	/*
 	 * Make sure we have the right vector page.
 	 */
-#ifdef VERBOSE_INIT_ARM
-	printf(" vectors");
-#endif
+	VPRINTF(" vectors");
 	arm32_vector_init(systempage.pv_va, ARM_VEC_ALL);
 
 	/*
 	 * Initialize the stack for each mode (we are already running on the
 	 * SVC32 stack of the idlelwp).
 	 */
-#ifdef VERBOSE_INIT_ARM
-	printf(" stacks");
-#endif
+	VPRINTF(" stacks");
 	set_stackptr(PSR_FIQ32_MODE,
 	    fiqstack.pv_va + (cpu_index(ci) + 1) * FIQ_STACK_SIZE * PAGE_SIZE);
 	set_stackptr(PSR_IRQ32_MODE,
@@ -399,9 +378,7 @@ cpu_hatch(struct cpu_info *ci, cpuid_t c
 	ci->ci_lastlwp = NULL;
 	ci->ci_pmap_lastuser = NULL;
 #ifdef ARM_MMU_EXTENDED
-#ifdef VERBOSE_INIT_ARM
-	printf(" tlb");
-#endif
+	VPRINTF(" tlb");
 	/*
 	 * Attach to the tlb.
 	 */
@@ -424,30 +401,22 @@ cpu_hatch(struct cpu_info *ci, cpuid_t c
 	aprint_naive("%s", device_xname(ci->ci_dev));
 	aprint_normal("%s", device_xname(ci->ci_dev));
 	identify_arm_cpu(ci->ci_dev, ci);
-#ifdef VERBOSE_INIT_ARM
-	printf(" vfp");
-#endif
+	VPRINTF(" vfp");
 	vfp_attach(ci);
 
 	mutex_exit(&cpu_hatch_lock);
 
-#ifdef VERBOSE_INIT_ARM
-	printf(" interrupts");
-#endif
+	VPRINTF(" interrupts");
 	/*
 	 * Let the interrupts do what they need to on this CPU.
 	 */
 	intr_cpu_init(ci);
 
-#ifdef VERBOSE_INIT_ARM
-	printf(" md(%p)", md_cpu_init);
-#endif
+	VPRINTF(" md(%p)", md_cpu_init);
 	if (md_cpu_init != NULL)
 		(*md_cpu_init)(ci);
 
-#ifdef VERBOSE_INIT_ARM
-	printf(" done!\n");
-#endif
+	VPRINTF(" done!\n");
 	atomic_and_32(&arm_cpu_mbox, ~(1 << cpuid));
 	membar_producer();
 	__asm __volatile("sev; sev; sev");

Index: src/sys/arch/arm/arm32/arm32_kvminit.c
diff -u src/sys/arch/arm/arm32/arm32_kvminit.c:1.41 src/sys/arch/arm/arm32/arm32_kvminit.c:1.42
--- src/sys/arch/arm/arm32/arm32_kvminit.c:1.41	Sun Dec 10 21:38:26 2017
+++ src/sys/arch/arm/arm32/arm32_kvminit.c	Tue Jul 31 07:00:48 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: arm32_kvminit.c,v 1.41 2017/12/10 21:38:26 skrll Exp $	*/
+/*	$NetBSD: arm32_kvminit.c,v 1.42 2018/07/31 07:00:48 skrll Exp $	*/
 
 /*
  * Copyright (c) 2002, 2003, 2005  Genetec Corporation.  All rights reserved.
@@ -121,11 +121,12 @@
  * SUCH DAMAGE.
  */
 
+#include "opt_arm_debug.h"
 #include "opt_fdt.h"
 #include "opt_multiprocessor.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: arm32_kvminit.c,v 1.41 2017/12/10 21:38:26 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arm32_kvminit.c,v 1.42 2018/07/31 07:00:48 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -153,6 +154,12 @@ __KERNEL_RCSID(0, "$NetBSD: arm32_kvmini
 #endif
 #endif
 
+#ifdef VERBOSE_INIT_ARM
+#define VPRINTF(...)	printf(__VA_ARGS__)
+#else
+#define VPRINTF(...)	do { } while (/* CONSTCOND */ 0)
+#endif
+
 struct bootmem_info bootmem_info;
 
 extern void *msgbufaddr;
@@ -190,10 +197,8 @@ arm32_bootmem_init(paddr_t memstart, psi
 	struct bootmem_info * const bmi = &bootmem_info;
 	pv_addr_t *pv = bmi->bmi_freeblocks;
 
-#ifdef VERBOSE_INIT_ARM
-	printf("%s: memstart=%#lx, memsize=%#lx, kernelstart=%#lx\n",
+	VPRINTF("%s: memstart=%#lx, memsize=%#lx, kernelstart=%#lx\n",
 	    __func__, memstart, memsize, kernelstart);
-#endif
 
 	physical_start = bmi->bmi_start = memstart;
 	physical_end = bmi->bmi_end = memstart + memsize;
@@ -202,10 +207,8 @@ arm32_bootmem_init(paddr_t memstart, psi
 		physical_end = -PAGE_SIZE;
 		memsize -= PAGE_SIZE;
 		bmi->bmi_end -= PAGE_SIZE;
-#ifdef VERBOSE_INIT_ARM
-		printf("%s: memsize shrunk by a page to avoid ending at 4GB\n",
+		VPRINTF("%s: memsize shrunk by a page to avoid ending at 4GB\n",
 		    __func__);
-#endif
 	}
 #endif
 	physmem = memsize / PAGE_SIZE;
@@ -221,9 +224,7 @@ arm32_bootmem_init(paddr_t memstart, psi
 	    bmi->bmi_kernelend - bmi->bmi_kernelstart);
 #endif
 
-#ifdef VERBOSE_INIT_ARM
-	printf("%s: kernelend=%#lx\n", __func__, bmi->bmi_kernelend);
-#endif
+	VPRINTF("%s: kernelend=%#lx\n", __func__, bmi->bmi_kernelend);
 
 	/*
 	 * Now the rest of the free memory must be after the kernel.
@@ -232,11 +233,9 @@ arm32_bootmem_init(paddr_t memstart, psi
 	pv->pv_va = KERN_PHYSTOV(bmi, pv->pv_pa);
 	pv->pv_size = bmi->bmi_end - bmi->bmi_kernelend;
 	bmi->bmi_freepages += pv->pv_size / PAGE_SIZE;
-#ifdef VERBOSE_INIT_ARM
-	printf("%s: adding %lu free pages: [%#lx..%#lx] (VA %#lx)\n",
+	VPRINTF("%s: adding %lu free pages: [%#lx..%#lx] (VA %#lx)\n",
 	    __func__, pv->pv_size / PAGE_SIZE, pv->pv_pa,
 	    pv->pv_pa + pv->pv_size - 1, pv->pv_va);
-#endif
 	pv++;
 
 #if !defined(FDT)
@@ -248,11 +247,9 @@ arm32_bootmem_init(paddr_t memstart, psi
 		pv->pv_va = KERN_PHYSTOV(bmi, pv->pv_pa);
 		pv->pv_size = bmi->bmi_kernelstart - pv->pv_pa;
 		bmi->bmi_freepages += pv->pv_size / PAGE_SIZE;
-#ifdef VERBOSE_INIT_ARM
-		printf("%s: adding %lu free pages: [%#lx..%#lx] (VA %#lx)\n",
+		VPRINTF("%s: adding %lu free pages: [%#lx..%#lx] (VA %#lx)\n",
 		    __func__, pv->pv_size / PAGE_SIZE, pv->pv_pa,
 		    pv->pv_pa + pv->pv_size - 1, pv->pv_va);
-#endif
 		pv++;
 	}
 #endif
@@ -270,11 +267,9 @@ concat_pvaddr(pv_addr_t *acc_pv, pv_addr
 	    && acc_pv->pv_va + acc_pv->pv_size == pv->pv_va
 	    && acc_pv->pv_prot == pv->pv_prot
 	    && acc_pv->pv_cache == pv->pv_cache) {
-#ifdef VERBOSE_INIT_ARMX
-		printf("%s: appending pv %p (%#lx..%#lx) to %#lx..%#lx\n",
+		VPRINTF("%s: appending pv %p (%#lx..%#lx) to %#lx..%#lx\n",
 		    __func__, pv, pv->pv_pa, pv->pv_pa + pv->pv_size + 1,
 		    acc_pv->pv_pa, acc_pv->pv_pa + acc_pv->pv_size + 1);
-#endif
 		acc_pv->pv_size += pv->pv_size;
 		return true;
 	}
@@ -290,21 +285,17 @@ add_pages(struct bootmem_info *bmi, pv_a
 		pv_addr_t * const pv0 = (*pvp);
 		KASSERT(SLIST_NEXT(pv0, pv_list) == NULL || pv0->pv_pa < SLIST_NEXT(pv0, pv_list)->pv_pa);
 		if (concat_pvaddr(pv0, pv)) {
-#ifdef VERBOSE_INIT_ARM
-			printf("%s: %s pv %p (%#lx..%#lx) to %#lx..%#lx\n",
+			VPRINTF("%s: %s pv %p (%#lx..%#lx) to %#lx..%#lx\n",
 			    __func__, "appending", pv,
 			    pv->pv_pa, pv->pv_pa + pv->pv_size - 1,
 			    pv0->pv_pa, pv0->pv_pa + pv0->pv_size - pv->pv_size - 1);
-#endif
 			pv = SLIST_NEXT(pv0, pv_list);
 			if (pv != NULL && concat_pvaddr(pv0, pv)) {
-#ifdef VERBOSE_INIT_ARM
-				printf("%s: %s pv %p (%#lx..%#lx) to %#lx..%#lx\n",
+				VPRINTF("%s: %s pv %p (%#lx..%#lx) to %#lx..%#lx\n",
 				    __func__, "merging", pv,
 				    pv->pv_pa, pv->pv_pa + pv->pv_size - 1,
 				    pv0->pv_pa,
 				    pv0->pv_pa + pv0->pv_size - pv->pv_size - 1);
-#endif
 				SLIST_REMOVE_AFTER(pv0, pv_list);
 				SLIST_INSERT_HEAD(&bmi->bmi_freechunks, pv, pv_list);
 			}
@@ -320,15 +311,15 @@ add_pages(struct bootmem_info *bmi, pv_a
 	*new_pv = *pv;
 	SLIST_NEXT(new_pv, pv_list) = *pvp;
 	(*pvp) = new_pv;
-#ifdef VERBOSE_INIT_ARM
-	printf("%s: adding pv %p (pa %#lx, va %#lx, %lu pages) ",
+
+	VPRINTF("%s: adding pv %p (pa %#lx, va %#lx, %lu pages) ",
 	    __func__, new_pv, new_pv->pv_pa, new_pv->pv_va,
 	    new_pv->pv_size / PAGE_SIZE);
-	if (SLIST_NEXT(new_pv, pv_list))
-		printf("before pa %#lx\n", SLIST_NEXT(new_pv, pv_list)->pv_pa);
-	else
-		printf("at tail\n");
-#endif
+	if (SLIST_NEXT(new_pv, pv_list)) {
+		VPRINTF("before pa %#lx\n", SLIST_NEXT(new_pv, pv_list)->pv_pa);
+	} else {
+		VPRINTF("at tail\n");
+	}
 }
 
 static void
@@ -468,10 +459,8 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b
 	const size_t KERNEL_L2PT_KERNEL_NUM =
 	    round_page(kernel_size + L2_S_SEGSIZE - 1) / L2_S_SEGSIZE;
 
-#ifdef VERBOSE_INIT_ARM
-	printf("%s: %zu L2 pages are needed to map %#zx kernel bytes\n",
+	VPRINTF("%s: %zu L2 pages are needed to map %#zx kernel bytes\n",
 	    __func__, KERNEL_L2PT_KERNEL_NUM, kernel_size);
-#endif
 
 	KASSERT(KERNEL_L2PT_KERNEL_NUM + KERNEL_L2PT_VMDATA_NUM < __arraycount(bmi->bmi_l2pts));
 	pv_addr_t * const kernel_l2pt = bmi->bmi_l2pts;
@@ -500,9 +489,7 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b
 	 * least one 16K aligned region.
 	 */
 
-#ifdef VERBOSE_INIT_ARM
-	printf("%s: allocating page tables for", __func__);
-#endif
+	VPRINTF("%s: allocating page tables for", __func__);
 	for (size_t i = 0; i < __arraycount(chunks); i++) {
 		SLIST_INSERT_HEAD(&bmi->bmi_freechunks, &chunks[i], pv_list);
 	}
@@ -520,9 +507,7 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b
 		/*
 		 * First allocate L2 page for the vectors.
 		 */
-#ifdef VERBOSE_INIT_ARM
-		printf(" vector");
-#endif
+		VPRINTF(" vector");
 		valloc_pages(bmi, &bmi->bmi_vector_l2pt, 1,
 		    VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE, true);
 		add_pages(bmi, &bmi->bmi_vector_l2pt);
@@ -531,9 +516,7 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b
 	/*
 	 * Now allocate L2 pages for the kernel
 	 */
-#ifdef VERBOSE_INIT_ARM
-	printf(" kernel");
-#endif
+	VPRINTF(" kernel");
 	for (size_t idx = 0; idx < KERNEL_L2PT_KERNEL_NUM; ++idx) {
 		valloc_pages(bmi, &kernel_l2pt[idx], 1,
 		    VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE, true);
@@ -543,9 +526,7 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b
 	/*
 	 * Now allocate L2 pages for the initial kernel VA space.
 	 */
-#ifdef VERBOSE_INIT_ARM
-	printf(" vm");
-#endif
+	VPRINTF(" vm");
 	for (size_t idx = 0; idx < KERNEL_L2PT_VMDATA_NUM; ++idx) {
 		valloc_pages(bmi, &vmdata_l2pt[idx], 1,
 		    VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE, true);
@@ -556,17 +537,13 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b
 	 * If someone wanted a L2 page for I/O, allocate it now.
 	 */
 	if (iovbase) {
-#ifdef VERBOSE_INIT_ARM
-		printf(" io");
-#endif
+		VPRINTF(" io");
 		valloc_pages(bmi, &bmi->bmi_io_l2pt, 1,
 		    VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE, true);
 		add_pages(bmi, &bmi->bmi_io_l2pt);
 	}
 
-#ifdef VERBOSE_INIT_ARM
-	printf("%s: allocating stacks\n", __func__);
-#endif
+	VPRINTF("%s: allocating stacks\n", __func__);
 
 	/* Allocate stacks for all modes and CPUs */
 	valloc_pages(bmi, &abtstack, ABT_STACK_SIZE * cpu_num,
@@ -629,9 +606,7 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b
 		    "page directory", __func__);
 
 
-#ifdef VERBOSE_INIT_ARM
-	printf("Creating L1 page table at 0x%08lx\n", kernel_l1pt.pv_pa);
-#endif
+	VPRINTF("Creating L1 page table at 0x%08lx\n", kernel_l1pt.pv_pa);
 
 	/*
 	 * Now we start construction of the L1 page table
@@ -645,12 +620,10 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b
 		/* Map the L2 pages tables in the L1 page table */
 		pmap_link_l2pt(l1pt_va, systempage.pv_va & -L2_S_SEGSIZE,
 		    &bmi->bmi_vector_l2pt);
-#ifdef VERBOSE_INIT_ARM
-		printf("%s: adding L2 pt (VA %#lx, PA %#lx) "
+		VPRINTF("%s: adding L2 pt (VA %#lx, PA %#lx) "
 		    "for VA %#lx\n (vectors)",
 		    __func__, bmi->bmi_vector_l2pt.pv_va,
 		    bmi->bmi_vector_l2pt.pv_pa, systempage.pv_va);
-#endif
 	}
 
 	const vaddr_t kernel_base =
@@ -658,38 +631,30 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b
 	for (size_t idx = 0; idx < KERNEL_L2PT_KERNEL_NUM; idx++) {
 		pmap_link_l2pt(l1pt_va, kernel_base + idx * L2_S_SEGSIZE,
 		    &kernel_l2pt[idx]);
-#ifdef VERBOSE_INIT_ARM
-		printf("%s: adding L2 pt (VA %#lx, PA %#lx) for VA %#lx (kernel)\n",
+		VPRINTF("%s: adding L2 pt (VA %#lx, PA %#lx) for VA %#lx (kernel)\n",
 		    __func__, kernel_l2pt[idx].pv_va,
 		    kernel_l2pt[idx].pv_pa, kernel_base + idx * L2_S_SEGSIZE);
-#endif
 	}
 
 	for (size_t idx = 0; idx < KERNEL_L2PT_VMDATA_NUM; idx++) {
 		pmap_link_l2pt(l1pt_va, kernel_vm_base + idx * L2_S_SEGSIZE,
 		    &vmdata_l2pt[idx]);
-#ifdef VERBOSE_INIT_ARM
-		printf("%s: adding L2 pt (VA %#lx, PA %#lx) for VA %#lx (vm)\n",
+		VPRINTF("%s: adding L2 pt (VA %#lx, PA %#lx) for VA %#lx (vm)\n",
 		    __func__, vmdata_l2pt[idx].pv_va, vmdata_l2pt[idx].pv_pa,
 		    kernel_vm_base + idx * L2_S_SEGSIZE);
-#endif
 	}
 	if (iovbase) {
 		pmap_link_l2pt(l1pt_va, iovbase & -L2_S_SEGSIZE, &bmi->bmi_io_l2pt);
-#ifdef VERBOSE_INIT_ARM
-		printf("%s: adding L2 pt (VA %#lx, PA %#lx) for VA %#lx (io)\n",
+		VPRINTF("%s: adding L2 pt (VA %#lx, PA %#lx) for VA %#lx (io)\n",
 		    __func__, bmi->bmi_io_l2pt.pv_va, bmi->bmi_io_l2pt.pv_pa,
 		    iovbase & -L2_S_SEGSIZE);
-#endif
 	}
 
 	/* update the top of the kernel VM */
 	pmap_curmaxkvaddr =
 	    kernel_vm_base + (KERNEL_L2PT_VMDATA_NUM * L2_S_SEGSIZE);
 
-#ifdef VERBOSE_INIT_ARM
-	printf("Mapping kernel\n");
-#endif
+	VPRINTF("Mapping kernel\n");
 
 	extern char etext[], _end[];
 	size_t totalsize = bmi->bmi_kernelend - bmi->bmi_kernelstart;
@@ -705,10 +670,8 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b
 	text.pv_prot = VM_PROT_READ | VM_PROT_EXECUTE;
 	text.pv_cache = PTE_CACHE;
 
-#ifdef VERBOSE_INIT_ARM
-	printf("%s: adding chunk for kernel text %#lx..%#lx (VA %#lx)\n",
+	VPRINTF("%s: adding chunk for kernel text %#lx..%#lx (VA %#lx)\n",
 	    __func__, text.pv_pa, text.pv_pa + text.pv_size - 1, text.pv_va);
-#endif
 
 	add_pages(bmi, &text);
 
@@ -718,25 +681,21 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b
 	data.pv_prot = VM_PROT_READ|VM_PROT_WRITE;
 	data.pv_cache = PTE_CACHE;
 
-#ifdef VERBOSE_INIT_ARM
-	printf("%s: adding chunk for kernel data/bss %#lx..%#lx (VA %#lx)\n",
+	VPRINTF("%s: adding chunk for kernel data/bss %#lx..%#lx (VA %#lx)\n",
 	    __func__, data.pv_pa, data.pv_pa + data.pv_size - 1, data.pv_va);
-#endif
 
 	add_pages(bmi, &data);
 
-#ifdef VERBOSE_INIT_ARM
-	printf("Listing Chunks\n");
+	VPRINTF("Listing Chunks\n");
 
 	pv_addr_t *lpv;
 	SLIST_FOREACH(lpv, &bmi->bmi_chunks, pv_list) {
-		printf("%s: pv %p: chunk VA %#lx..%#lx "
+		VPRINTF("%s: pv %p: chunk VA %#lx..%#lx "
 		    "(PA %#lx, prot %d, cache %d)\n",
 		    __func__, lpv, lpv->pv_va, lpv->pv_va + lpv->pv_size - 1,
 		    lpv->pv_pa, lpv->pv_prot, lpv->pv_cache);
 	}
-	printf("\nMapping Chunks\n");
-#endif
+	VPRINTF("\nMapping Chunks\n");
 
 	pv_addr_t cur_pv;
 	pv_addr_t *pv = SLIST_FIRST(&bmi->bmi_chunks);
@@ -771,13 +730,11 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b
 				/*
 				 * We couldn't so emit the current chunk and then
 				 */
-#ifdef VERBOSE_INIT_ARM
-				printf("%s: mapping chunk VA %#lx..%#lx "
+				VPRINTF("%s: mapping chunk VA %#lx..%#lx "
 				    "(PA %#lx, prot %d, cache %d)\n",
 				    __func__,
 				    cur_pv.pv_va, cur_pv.pv_va + cur_pv.pv_size - 1,
 				    cur_pv.pv_pa, cur_pv.pv_prot, cur_pv.pv_cache);
-#endif
 				pmap_map_chunk(l1pt_va, cur_pv.pv_va, cur_pv.pv_pa,
 				    cur_pv.pv_size, cur_pv.pv_prot, cur_pv.pv_cache);
 
@@ -797,12 +754,10 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b
 		 * The new pv didn't concatenate so emit the current one
 		 * and use the new pv as the current pv.
 		 */
-#ifdef VERBOSE_INIT_ARM
-		printf("%s: mapping chunk VA %#lx..%#lx "
+		VPRINTF("%s: mapping chunk VA %#lx..%#lx "
 		    "(PA %#lx, prot %d, cache %d)\n",
 		    __func__, cur_pv.pv_va, cur_pv.pv_va + cur_pv.pv_size - 1,
 		    cur_pv.pv_pa, cur_pv.pv_prot, cur_pv.pv_cache);
-#endif
 		pmap_map_chunk(l1pt_va, cur_pv.pv_va, cur_pv.pv_pa,
 		    cur_pv.pv_size, cur_pv.pv_prot, cur_pv.pv_cache);
 		cur_pv = *pv;
@@ -820,12 +775,10 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b
 			KASSERTMSG(cur_pv.pv_va + cur_pv.pv_size <= kernel_vm_base,
 			    "%#lx >= %#lx", cur_pv.pv_va + cur_pv.pv_size,
 			    kernel_vm_base);
-#ifdef VERBOSE_INIT_ARM
-			printf("%s: mapping chunk VA %#lx..%#lx "
+			VPRINTF("%s: mapping chunk VA %#lx..%#lx "
 			    "(PA %#lx, prot %d, cache %d)\n",
 			    __func__, cur_pv.pv_va, cur_pv.pv_va + cur_pv.pv_size - 1,
 			    cur_pv.pv_pa, cur_pv.pv_prot, cur_pv.pv_cache);
-#endif
 			pmap_map_chunk(l1pt_va, cur_pv.pv_va, cur_pv.pv_pa,
 			    cur_pv.pv_size, cur_pv.pv_prot, cur_pv.pv_cache);
 			cur_pv.pv_pa += cur_pv.pv_size;
@@ -846,11 +799,9 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b
 	/*
 	 * Now we map the final chunk.
 	 */
-#ifdef VERBOSE_INIT_ARM
-	printf("%s: mapping last chunk VA %#lx..%#lx (PA %#lx, prot %d, cache %d)\n",
+	VPRINTF("%s: mapping last chunk VA %#lx..%#lx (PA %#lx, prot %d, cache %d)\n",
 	    __func__, cur_pv.pv_va, cur_pv.pv_va + cur_pv.pv_size - 1,
 	    cur_pv.pv_pa, cur_pv.pv_prot, cur_pv.pv_cache);
-#endif
 	pmap_map_chunk(l1pt_va, cur_pv.pv_va, cur_pv.pv_pa,
 	    cur_pv.pv_size, cur_pv.pv_prot, cur_pv.pv_cache);
 
@@ -879,67 +830,66 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b
 	if (devmap)
 		pmap_devmap_bootstrap(l1pt_va, devmap);
 
-#ifdef VERBOSE_INIT_ARM
 	/* Tell the user about where all the bits and pieces live. */
-	printf("%22s       Physical              Virtual        Num\n", " ");
-	printf("%22s Starting    Ending    Starting    Ending   Pages\n", " ");
+	VPRINTF("%22s       Physical              Virtual        Num\n", " ");
+	VPRINTF("%22s Starting    Ending    Starting    Ending   Pages\n", " ");
 
 	static const char mem_fmt[] =
 	    "%20s: 0x%08lx 0x%08lx 0x%08lx 0x%08lx %u\n";
 	static const char mem_fmt_nov[] =
 	    "%20s: 0x%08lx 0x%08lx                       %zu\n";
 
-	printf(mem_fmt, "SDRAM", bmi->bmi_start, bmi->bmi_end - 1,
+	VPRINTF(mem_fmt, "SDRAM", bmi->bmi_start, bmi->bmi_end - 1,
 	    KERN_PHYSTOV(bmi, bmi->bmi_start), KERN_PHYSTOV(bmi, bmi->bmi_end - 1),
 	    (int)physmem);
-	printf(mem_fmt, "text section",
+	VPRINTF(mem_fmt, "text section",
 	       text.pv_pa, text.pv_pa + text.pv_size - 1,
 	       text.pv_va, text.pv_va + text.pv_size - 1,
 	       (int)(text.pv_size / PAGE_SIZE));
-	printf(mem_fmt, "data section",
+	VPRINTF(mem_fmt, "data section",
 	       KERN_VTOPHYS(bmi, __data_start), KERN_VTOPHYS(bmi, _edata),
 	       (vaddr_t)__data_start, (vaddr_t)_edata,
 	       (int)((round_page((vaddr_t)_edata)
 		      - trunc_page((vaddr_t)__data_start)) / PAGE_SIZE));
-	printf(mem_fmt, "bss section",
+	VPRINTF(mem_fmt, "bss section",
 	       KERN_VTOPHYS(bmi, __bss_start), KERN_VTOPHYS(bmi, __bss_end__),
 	       (vaddr_t)__bss_start, (vaddr_t)__bss_end__,
 	       (int)((round_page((vaddr_t)__bss_end__)
 		      - trunc_page((vaddr_t)__bss_start)) / PAGE_SIZE));
-	printf(mem_fmt, "L1 page directory",
+	VPRINTF(mem_fmt, "L1 page directory",
 	    kernel_l1pt.pv_pa, kernel_l1pt.pv_pa + L1_TABLE_SIZE - 1,
 	    kernel_l1pt.pv_va, kernel_l1pt.pv_va + L1_TABLE_SIZE - 1,
 	    L1_TABLE_SIZE / PAGE_SIZE);
-	printf(mem_fmt, "ABT stack (CPU 0)",
+	VPRINTF(mem_fmt, "ABT stack (CPU 0)",
 	    abtstack.pv_pa, abtstack.pv_pa + (ABT_STACK_SIZE * PAGE_SIZE) - 1,
 	    abtstack.pv_va, abtstack.pv_va + (ABT_STACK_SIZE * PAGE_SIZE) - 1,
 	    ABT_STACK_SIZE);
-	printf(mem_fmt, "FIQ stack (CPU 0)",
+	VPRINTF(mem_fmt, "FIQ stack (CPU 0)",
 	    fiqstack.pv_pa, fiqstack.pv_pa + (FIQ_STACK_SIZE * PAGE_SIZE) - 1,
 	    fiqstack.pv_va, fiqstack.pv_va + (FIQ_STACK_SIZE * PAGE_SIZE) - 1,
 	    FIQ_STACK_SIZE);
-	printf(mem_fmt, "IRQ stack (CPU 0)",
+	VPRINTF(mem_fmt, "IRQ stack (CPU 0)",
 	    irqstack.pv_pa, irqstack.pv_pa + (IRQ_STACK_SIZE * PAGE_SIZE) - 1,
 	    irqstack.pv_va, irqstack.pv_va + (IRQ_STACK_SIZE * PAGE_SIZE) - 1,
 	    IRQ_STACK_SIZE);
-	printf(mem_fmt, "UND stack (CPU 0)",
+	VPRINTF(mem_fmt, "UND stack (CPU 0)",
 	    undstack.pv_pa, undstack.pv_pa + (UND_STACK_SIZE * PAGE_SIZE) - 1,
 	    undstack.pv_va, undstack.pv_va + (UND_STACK_SIZE * PAGE_SIZE) - 1,
 	    UND_STACK_SIZE);
-	printf(mem_fmt, "IDLE stack (CPU 0)",
+	VPRINTF(mem_fmt, "IDLE stack (CPU 0)",
 	    idlestack.pv_pa, idlestack.pv_pa + (UPAGES * PAGE_SIZE) - 1,
 	    idlestack.pv_va, idlestack.pv_va + (UPAGES * PAGE_SIZE) - 1,
 	    UPAGES);
-	printf(mem_fmt, "SVC stack",
+	VPRINTF(mem_fmt, "SVC stack",
 	    kernelstack.pv_pa, kernelstack.pv_pa + (UPAGES * PAGE_SIZE) - 1,
 	    kernelstack.pv_va, kernelstack.pv_va + (UPAGES * PAGE_SIZE) - 1,
 	    UPAGES);
-	printf(mem_fmt, "Message Buffer",
+	VPRINTF(mem_fmt, "Message Buffer",
 	    msgbuf.pv_pa, msgbuf.pv_pa + (msgbuf_pgs * PAGE_SIZE) - 1,
 	    msgbuf.pv_va, msgbuf.pv_va + (msgbuf_pgs * PAGE_SIZE) - 1,
 	    (int)msgbuf_pgs);
 	if (map_vectors_p) {
-		printf(mem_fmt, "Exception Vectors",
+		VPRINTF(mem_fmt, "Exception Vectors",
 		    systempage.pv_pa, systempage.pv_pa + PAGE_SIZE - 1,
 		    systempage.pv_va, systempage.pv_va + PAGE_SIZE - 1,
 		    1);
@@ -947,31 +897,26 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b
 	for (size_t i = 0; i < bmi->bmi_nfreeblocks; i++) {
 		pv = &bmi->bmi_freeblocks[i];
 
-		printf(mem_fmt_nov, "Free Memory",
+		VPRINTF(mem_fmt_nov, "Free Memory",
 		    pv->pv_pa, pv->pv_pa + pv->pv_size - 1,
 		    pv->pv_size / PAGE_SIZE);
 	}
-#endif
 	/*
 	 * Now we have the real page tables in place so we can switch to them.
 	 * Once this is done we will be running with the REAL kernel page
 	 * tables.
 	 */
 
-#if defined(VERBOSE_INIT_ARM)
-	printf("TTBR0=%#x", armreg_ttbr_read());
+	VPRINTF("TTBR0=%#x", armreg_ttbr_read());
 #ifdef _ARM_ARCH_6
-	printf(" TTBR1=%#x TTBCR=%#x CONTEXTIDR=%#x",
+	VPRINTF(" TTBR1=%#x TTBCR=%#x CONTEXTIDR=%#x",
 	    armreg_ttbr1_read(), armreg_ttbcr_read(),
 	    armreg_contextidr_read());
 #endif
-	printf("\n");
-#endif
+	VPRINTF("\n");
 
 	/* Switch tables */
-#ifdef VERBOSE_INIT_ARM
-	printf("switching to new L1 page table @%#lx...", l1pt_pa);
-#endif
+	VPRINTF("switching to new L1 page table @%#lx...", l1pt_pa);
 
 #ifdef ARM_MMU_EXTENDED
 	cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2))
@@ -980,9 +925,7 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b
 	cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT);
 #endif
 	cpu_idcache_wbinv_all();
-#ifdef VERBOSE_INIT_ARM
-	printf(" ttb");
-#endif
+	VPRINTF(" ttb");
 #ifdef ARM_MMU_EXTENDED
 	/*
 	 * TTBCR should have been initialized by the MD start code.
@@ -1001,13 +944,11 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b
 #endif
 	cpu_tlb_flushID();
 
-#ifdef VERBOSE_INIT_ARM
 #ifdef ARM_MMU_EXTENDED
-	printf(" (TTBCR=%#x TTBR0=%#x TTBR1=%#x)",
+	VPRINTF(" (TTBCR=%#x TTBR0=%#x TTBR1=%#x)",
 	    armreg_ttbcr_read(), armreg_ttbr_read(), armreg_ttbr1_read());
 #else
-	printf(" (TTBR0=%#x)", armreg_ttbr_read());
-#endif
+	VPRINTF(" (TTBR0=%#x)", armreg_ttbr_read());
 #endif
 
 #ifdef MULTIPROCESSOR
@@ -1015,13 +956,9 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b
 	 * Kick the secondaries to load the TTB.  After which they'll go
 	 * back to sleep to wait for the final kick so they will hatch.
 	 */
-#ifdef VERBOSE_INIT_ARM
-	printf(" hatchlings");
-#endif
+	VPRINTF(" hatchlings");
 	cpu_boot_secondary_processors();
 #endif
 
-#ifdef VERBOSE_INIT_ARM
-	printf(" OK\n");
-#endif
+	VPRINTF(" OK\n");
 }

Index: src/sys/arch/arm/arm32/arm32_machdep.c
diff -u src/sys/arch/arm/arm32/arm32_machdep.c:1.115 src/sys/arch/arm/arm32/arm32_machdep.c:1.116
--- src/sys/arch/arm/arm32/arm32_machdep.c:1.115	Tue Oct 31 12:37:23 2017
+++ src/sys/arch/arm/arm32/arm32_machdep.c	Tue Jul 31 07:00:48 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: arm32_machdep.c,v 1.115 2017/10/31 12:37:23 martin Exp $	*/
+/*	$NetBSD: arm32_machdep.c,v 1.116 2018/07/31 07:00:48 skrll Exp $	*/
 
 /*
  * Copyright (c) 1994-1998 Mark Brinicombe.
@@ -42,8 +42,9 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: arm32_machdep.c,v 1.115 2017/10/31 12:37:23 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arm32_machdep.c,v 1.116 2018/07/31 07:00:48 skrll Exp $");
 
+#include "opt_arm_debug.h"
 #include "opt_modular.h"
 #include "opt_md.h"
 #include "opt_pmap_debug.h"
@@ -80,6 +81,13 @@ __KERNEL_RCSID(0, "$NetBSD: arm32_machde
 #include <machine/bootconfig.h>
 #include <machine/pcb.h>
 
+#ifdef VERBOSE_INIT_ARM
+#define VPRINTF(...)	printf(__VA_ARGS__)
+#else
+#define VPRINTF(...)	do { } while (/* CONSTCOND */ 0)
+#endif
+
+
 void (*cpu_reset_address)(void);	/* Used by locore */
 paddr_t cpu_reset_address_paddr;	/* Used by locore */
 
@@ -151,9 +159,7 @@ arm32_vector_init(vaddr_t va, int which)
 		vector_page = (vaddr_t)page0rel;
 		KASSERT((vector_page & 0x1f) == 0);
 		armreg_vbar_write(vector_page);
-#ifdef VERBOSE_INIT_ARM
-		printf(" vbar=%p", page0rel);
-#endif
+		VPRINTF(" vbar=%p", page0rel);
 		cpu_control(CPU_CONTROL_VECRELOC, 0);
 		return;
 #ifndef ARM_HAS_VBAR
@@ -700,9 +706,7 @@ cpu_uarea_alloc_idlelwp(struct cpu_info 
 void
 cpu_boot_secondary_processors(void)
 {
-#ifdef VERBOSE_INIT_ARM
-	printf("%s: writing mbox with %#x\n", __func__, arm_cpu_hatched);
-#endif
+	VPRINTF("%s: writing mbox with %#x\n", __func__, arm_cpu_hatched);
 	arm_cpu_mbox = arm_cpu_hatched;
 	membar_producer();
 #ifdef _ARM_ARCH_7

Index: src/sys/arch/arm/arm32/pmap.c
diff -u src/sys/arch/arm/arm32/pmap.c:1.365 src/sys/arch/arm/arm32/pmap.c:1.366
--- src/sys/arch/arm/arm32/pmap.c:1.365	Sun Apr  1 04:35:03 2018
+++ src/sys/arch/arm/arm32/pmap.c	Tue Jul 31 07:00:48 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.365 2018/04/01 04:35:03 ryo Exp $	*/
+/*	$NetBSD: pmap.c,v 1.366 2018/07/31 07:00:48 skrll Exp $	*/
 
 /*
  * Copyright 2003 Wasabi Systems, Inc.
@@ -217,7 +217,7 @@
 
 #include <arm/locore.h>
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.365 2018/04/01 04:35:03 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.366 2018/07/31 07:00:48 skrll Exp $");
 
 //#define PMAP_DEBUG
 #ifdef PMAP_DEBUG
@@ -258,6 +258,13 @@ int pmapdebug = 0;
 #define NPDEBUG(_lev_,_stat_) /* Nothing */
 #endif	/* PMAP_DEBUG */
 
+
+#ifdef VERBOSE_INIT_ARM
+#define VPRINTF(...)	printf(__VA_ARGS__)
+#else
+#define VPRINTF(...)	do { } while (/* CONSTCOND */ 0)
+#endif
+
 /*
  * pmap_kernel() points here
  */
@@ -6122,9 +6129,7 @@ pmap_bootstrap(vaddr_t vstart, vaddr_t v
 	KASSERT(pte_l2_s_cache_mode == pte_l2_s_cache_mode_pt);
 #endif
 
-#ifdef VERBOSE_INIT_ARM
-	printf("kpm ");
-#endif
+	VPRINTF("kpm ");
 	/*
 	 * Initialise the kernel pmap object
 	 */
@@ -6132,14 +6137,10 @@ pmap_bootstrap(vaddr_t vstart, vaddr_t v
 #ifdef ARM_MMU_EXTENDED
 	pm->pm_l1 = l1pt;
 	pm->pm_l1_pa = kernel_l1pt.pv_pa;
-#ifdef VERBOSE_INIT_ARM
-	printf("tlb0 ");
-#endif
+	VPRINTF("tlb0 ");
 	pmap_tlb_info_init(&pmap_tlb0_info);
 #ifdef MULTIPROCESSOR
-#ifdef VERBOSE_INIT_ARM
-	printf("kcpusets ");
-#endif
+	VPRINTF("kcpusets ");
 	pm->pm_onproc = kcpuset_running;
 	pm->pm_active = kcpuset_running;
 #endif
@@ -6147,9 +6148,7 @@ pmap_bootstrap(vaddr_t vstart, vaddr_t v
 	pm->pm_l1 = l1;
 #endif
 
-#ifdef VERBOSE_INIT_ARM
-	printf("locks ");
-#endif
+	VPRINTF("locks ");
 #if defined(PMAP_CACHE_VIPT) && !defined(ARM_MMU_EXTENDED)
 	if (arm_cache_prefer_mask != 0) {
 		mutex_init(&pmap_lock, MUTEX_DEFAULT, IPL_VM);
@@ -6163,9 +6162,7 @@ pmap_bootstrap(vaddr_t vstart, vaddr_t v
 	uvm_obj_init(&pm->pm_obj, NULL, false, 1);
 	uvm_obj_setlock(&pm->pm_obj, &pm->pm_obj_lock);
 
-#ifdef VERBOSE_INIT_ARM
-	printf("l1pt ");
-#endif
+	VPRINTF("l1pt ");
 	/*
 	 * Scan the L1 translation table created by initarm() and create
 	 * the required metadata for all valid mappings found in it.
@@ -6240,9 +6237,7 @@ pmap_bootstrap(vaddr_t vstart, vaddr_t v
 		}
 	}
 
-#ifdef VERBOSE_INIT_ARM
-	printf("cache(l1pt) ");
-#endif
+	VPRINTF("cache(l1pt) ");
 	/*
 	 * Ensure the primary (kernel) L1 has the correct cache mode for
 	 * a page table. Bitch if it is not correctly set.
@@ -6269,9 +6264,7 @@ pmap_bootstrap(vaddr_t vstart, vaddr_t v
 	virtual_avail = vstart;
 	virtual_end = vend;
 
-#ifdef VERBOSE_INIT_ARM
-	printf("specials ");
-#endif
+	VPRINTF("specials ");
 #ifdef PMAP_CACHE_VIPT
 	/*
 	 * If we have a VIPT cache, we need one page/pte per possible alias
@@ -6344,9 +6337,7 @@ pmap_bootstrap(vaddr_t vstart, vaddr_t v
 		pm->pm_pl1vec = NULL;
 #endif
 
-#ifdef VERBOSE_INIT_ARM
-	printf("pools ");
-#endif
+	VPRINTF("pools ");
 	/*
 	 * Initialize the pmap cache
 	 */
@@ -6749,10 +6740,8 @@ pmap_map_chunk(vaddr_t l1pt, vaddr_t va,
 	if (l1pt == 0)
 		panic("pmap_map_chunk: no L1 table provided");
 
-#ifdef VERBOSE_INIT_ARM
-	printf("pmap_map_chunk: pa=0x%lx va=0x%lx size=0x%lx resid=0x%lx "
+	VPRINTF("pmap_map_chunk: pa=0x%lx va=0x%lx size=0x%lx resid=0x%lx "
 	    "prot=0x%x cache=%d\n", pa, va, size, resid, prot, cache);
-#endif
 
 	switch (cache) {
 	case PTE_NOCACHE:
@@ -6789,9 +6778,7 @@ pmap_map_chunk(vaddr_t l1pt, vaddr_t va,
 			    | (va & 0x80000000 ? 0 : L1_S_V6_nG)
 #endif
 			    | L1_S_PROT(PTE_KERNEL, prot) | f1;
-#ifdef VERBOSE_INIT_ARM
-			printf("sS");
-#endif
+			VPRINTF("sS");
 			l1pte_set(&pdep[l1slot], npde);
 			PDE_SYNC_RANGE(&pdep[l1slot], L1_SS_SIZE / L1_S_SIZE);
 			va += L1_SS_SIZE;
@@ -6809,9 +6796,7 @@ pmap_map_chunk(vaddr_t l1pt, vaddr_t va,
 #endif
 			    | L1_S_PROT(PTE_KERNEL, prot) | f1
 			    | L1_S_DOM(PMAP_DOMAIN_KERNEL);
-#ifdef VERBOSE_INIT_ARM
-			printf("S");
-#endif
+			VPRINTF("S");
 			l1pte_set(&pdep[l1slot], npde);
 			PDE_SYNC(&pdep[l1slot]);
 			va += L1_S_SIZE;
@@ -6843,9 +6828,7 @@ pmap_map_chunk(vaddr_t l1pt, vaddr_t va,
 			    | (va & 0x80000000 ? 0 : L2_XS_nG)
 #endif
 			    | L2_L_PROT(PTE_KERNEL, prot) | f2l;
-#ifdef VERBOSE_INIT_ARM
-			printf("L");
-#endif
+			VPRINTF("L");
 			l2pte_set(ptep, npte, 0);
 			PTE_SYNC_RANGE(ptep, L2_L_SIZE / L2_S_SIZE);
 			va += L2_L_SIZE;
@@ -6854,9 +6837,7 @@ pmap_map_chunk(vaddr_t l1pt, vaddr_t va,
 			continue;
 		}
 
-#ifdef VERBOSE_INIT_ARM
-		printf("P");
-#endif
+		VPRINTF("P");
 		/* Use a small page mapping. */
 		pt_entry_t npte = L2_S_PROTO | pa
 #ifdef ARM_MMU_EXTENDED
@@ -6873,9 +6854,7 @@ pmap_map_chunk(vaddr_t l1pt, vaddr_t va,
 		pa += PAGE_SIZE;
 		resid -= PAGE_SIZE;
 	}
-#ifdef VERBOSE_INIT_ARM
-	printf("\n");
-#endif
+	VPRINTF("\n");
 	return (size);
 }
 
@@ -6908,13 +6887,11 @@ pmap_devmap_bootstrap(vaddr_t l1pt, cons
 	pmap_devmap_table = table;
 
 	for (i = 0; pmap_devmap_table[i].pd_size != 0; i++) {
-#ifdef VERBOSE_INIT_ARM
-		printf("devmap: %08lx -> %08lx @ %08lx\n",
+		VPRINTF("devmap: %08lx -> %08lx @ %08lx\n",
 		    pmap_devmap_table[i].pd_pa,
 		    pmap_devmap_table[i].pd_pa +
 			pmap_devmap_table[i].pd_size - 1,
 		    pmap_devmap_table[i].pd_va);
-#endif
 		pmap_map_chunk(l1pt, pmap_devmap_table[i].pd_va,
 		    pmap_devmap_table[i].pd_pa,
 		    pmap_devmap_table[i].pd_size,

Reply via email to