Home | History | Annotate | Line # | Download | only in arm32
arm32_machdep.c revision 1.97
      1 /*	$NetBSD: arm32_machdep.c,v 1.97 2013/09/07 23:10:02 matt Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1994-1998 Mark Brinicombe.
      5  * Copyright (c) 1994 Brini.
      6  * All rights reserved.
      7  *
      8  * This code is derived from software written for Brini by Mark Brinicombe
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *	This product includes software developed by Mark Brinicombe
     21  *	for the NetBSD Project.
     22  * 4. The name of the company nor the name of the author may be used to
     23  *    endorse or promote products derived from this software without specific
     24  *    prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
     27  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     28  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     29  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     30  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     31  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     32  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36  * SUCH DAMAGE.
     37  *
     38  * Machine dependent functions for kernel setup
     39  *
     40  * Created      : 17/09/94
     41  * Updated	: 18/04/01 updated for new wscons
     42  */
     43 
     44 #include <sys/cdefs.h>
     45 __KERNEL_RCSID(0, "$NetBSD: arm32_machdep.c,v 1.97 2013/09/07 23:10:02 matt Exp $");
     46 
     47 #include "opt_modular.h"
     48 #include "opt_md.h"
     49 #include "opt_pmap_debug.h"
     50 
     51 #include <sys/param.h>
     52 #include <sys/systm.h>
     53 #include <sys/reboot.h>
     54 #include <sys/proc.h>
     55 #include <sys/kauth.h>
     56 #include <sys/kernel.h>
     57 #include <sys/mbuf.h>
     58 #include <sys/mount.h>
     59 #include <sys/buf.h>
     60 #include <sys/msgbuf.h>
     61 #include <sys/device.h>
     62 #include <sys/sysctl.h>
     63 #include <sys/cpu.h>
     64 #include <sys/intr.h>
     65 #include <sys/module.h>
     66 #include <sys/atomic.h>
     67 #include <sys/xcall.h>
     68 
     69 #include <uvm/uvm_extern.h>
     70 
     71 #include <dev/cons.h>
     72 #include <dev/mm.h>
     73 
     74 #include <arm/locore.h>
     75 
     76 #include <arm/arm32/katelib.h>
     77 #include <arm/arm32/machdep.h>
     78 
     79 #include <machine/bootconfig.h>
     80 #include <machine/pcb.h>
     81 
     82 void (*cpu_reset_address)(void);	/* Used by locore */
     83 paddr_t cpu_reset_address_paddr;	/* Used by locore */
     84 
     85 struct vm_map *phys_map = NULL;
     86 
     87 #if defined(MEMORY_DISK_HOOKS) && !defined(MEMORY_DISK_ROOT_SIZE)
     88 extern size_t md_root_size;		/* Memory disc size */
     89 #endif	/* MEMORY_DISK_HOOKS && !MEMORY_DISK_ROOT_SIZE */
     90 
     91 pv_addr_t kernelstack;
     92 pv_addr_t abtstack;
     93 pv_addr_t fiqstack;
     94 pv_addr_t irqstack;
     95 pv_addr_t undstack;
     96 pv_addr_t idlestack;
     97 
     98 void *	msgbufaddr;
     99 extern paddr_t msgbufphys;
    100 
    101 int kernel_debug = 0;
    102 int cpu_fpu_present;
    103 int cpu_hwdiv_present;
    104 int cpu_neon_present;
    105 int cpu_simd_present;
    106 int cpu_simdex_present;
    107 int cpu_umull_present;
    108 const char *cpu_arch = "";
    109 
    110 int cpu_instruction_set_attributes[6];
    111 int cpu_memory_model_features[4];
    112 int cpu_processor_features[2];
    113 int cpu_media_and_vfp_features[2];
    114 
    115 /* exported variable to be filled in by the bootloaders */
    116 char *booted_kernel;
    117 
    118 /* Prototypes */
    119 
    120 void data_abort_handler(trapframe_t *frame);
    121 void prefetch_abort_handler(trapframe_t *frame);
    122 extern void configure(void);
    123 
    124 /*
    125  * arm32_vector_init:
    126  *
    127  *	Initialize the vector page, and select whether or not to
    128  *	relocate the vectors.
    129  *
    130  *	NOTE: We expect the vector page to be mapped at its expected
    131  *	destination.
    132  */
    133 void
    134 arm32_vector_init(vaddr_t va, int which)
    135 {
    136 #if defined(CPU_ARMV7) || defined(CPU_ARM11) || defined(ARM_HAS_VBAR)
    137 	/*
    138 	 * If this processor has the security extension, don't bother
    139 	 * to move/map the vector page.  Simply point VBAR to the copy
    140 	 * that exists in the .text segment.
    141 	 */
    142 #ifndef ARM_HAS_VBAR
    143 	if (va == ARM_VECTORS_LOW
    144 	    && (armreg_pfr1_read() & ARM_PFR1_SEC_MASK) != 0) {
    145 #endif
    146 		extern const uint32_t page0rel[];
    147 		vector_page = (vaddr_t)page0rel;
    148 		KASSERT((vector_page & 0x1f) == 0);
    149 		armreg_vbar_write(vector_page);
    150 #ifdef VERBOSE_INIT_ARM
    151 		printf(" vbar=%p", page0rel);
    152 #endif
    153 		cpu_control(CPU_CONTROL_VECRELOC, 0);
    154 		return;
    155 #ifndef ARM_HAS_VBAR
    156 	}
    157 #endif
    158 #endif
    159 #ifndef ARM_HAS_VBAR
    160 	if (CPU_IS_PRIMARY(curcpu())) {
    161 		extern unsigned int page0[], page0_data[];
    162 		unsigned int *vectors = (int *) va;
    163 		unsigned int *vectors_data = vectors + (page0_data - page0);
    164 		int vec;
    165 
    166 		/*
    167 		 * Loop through the vectors we're taking over, and copy the
    168 		 * vector's insn and data word.
    169 		 */
    170 		for (vec = 0; vec < ARM_NVEC; vec++) {
    171 			if ((which & (1 << vec)) == 0) {
    172 				/* Don't want to take over this vector. */
    173 				continue;
    174 			}
    175 			vectors[vec] = page0[vec];
    176 			vectors_data[vec] = page0_data[vec];
    177 		}
    178 
    179 		/* Now sync the vectors. */
    180 		cpu_icache_sync_range(va, (ARM_NVEC * 2) * sizeof(u_int));
    181 
    182 		vector_page = va;
    183 	}
    184 
    185 	if (va == ARM_VECTORS_HIGH) {
    186 		/*
    187 		 * Assume the MD caller knows what it's doing here, and
    188 		 * really does want the vector page relocated.
    189 		 *
    190 		 * Note: This has to be done here (and not just in
    191 		 * cpu_setup()) because the vector page needs to be
    192 		 * accessible *before* cpu_startup() is called.
    193 		 * Think ddb(9) ...
    194 		 *
    195 		 * NOTE: If the CPU control register is not readable,
    196 		 * this will totally fail!  We'll just assume that
    197 		 * any system that has high vector support has a
    198 		 * readable CPU control register, for now.  If we
    199 		 * ever encounter one that does not, we'll have to
    200 		 * rethink this.
    201 		 */
    202 		cpu_control(CPU_CONTROL_VECRELOC, CPU_CONTROL_VECRELOC);
    203 	}
    204 #endif
    205 }
    206 
    207 /*
    208  * Debug function just to park the CPU
    209  */
    210 
    211 void
    212 halt(void)
    213 {
    214 	while (1)
    215 		cpu_sleep(0);
    216 }
    217 
    218 
    219 /* Sync the discs, unmount the filesystems, and adjust the todr */
    220 
    221 void
    222 bootsync(void)
    223 {
    224 	static bool bootsyncdone = false;
    225 
    226 	if (bootsyncdone) return;
    227 
    228 	bootsyncdone = true;
    229 
    230 	/* Make sure we can still manage to do things */
    231 	if (GetCPSR() & I32_bit) {
    232 		/*
    233 		 * If we get here then boot has been called without RB_NOSYNC
    234 		 * and interrupts were disabled. This means the boot() call
    235 		 * did not come from a user process e.g. shutdown, but must
    236 		 * have come from somewhere in the kernel.
    237 		 */
    238 		IRQenable;
    239 		printf("Warning IRQ's disabled during boot()\n");
    240 	}
    241 
    242 	vfs_shutdown();
    243 
    244 	resettodr();
    245 }
    246 
    247 /*
    248  * void cpu_startup(void)
    249  *
    250  * Machine dependent startup code.
    251  *
    252  */
    253 void
    254 cpu_startup(void)
    255 {
    256 	vaddr_t minaddr;
    257 	vaddr_t maxaddr;
    258 	u_int loop;
    259 	char pbuf[9];
    260 
    261 	/*
    262 	 * Until we better locking, we have to live under the kernel lock.
    263 	 */
    264 	//KERNEL_LOCK(1, NULL);
    265 
    266 	/* Set the CPU control register */
    267 	cpu_setup(boot_args);
    268 
    269 #ifndef ARM_HAS_VBAR
    270 	/* Lock down zero page */
    271 	vector_page_setprot(VM_PROT_READ);
    272 #endif
    273 
    274 	/*
    275 	 * Give pmap a chance to set up a few more things now the vm
    276 	 * is initialised
    277 	 */
    278 	pmap_postinit();
    279 
    280 	/*
    281 	 * Initialize error message buffer (at end of core).
    282 	 */
    283 
    284 	/* msgbufphys was setup during the secondary boot strap */
    285 	for (loop = 0; loop < btoc(MSGBUFSIZE); ++loop)
    286 		pmap_kenter_pa((vaddr_t)msgbufaddr + loop * PAGE_SIZE,
    287 		    msgbufphys + loop * PAGE_SIZE,
    288 		    VM_PROT_READ|VM_PROT_WRITE, 0);
    289 	pmap_update(pmap_kernel());
    290 	initmsgbuf(msgbufaddr, round_page(MSGBUFSIZE));
    291 
    292 	/*
    293 	 * Identify ourselves for the msgbuf (everything printed earlier will
    294 	 * not be buffered).
    295 	 */
    296 	printf("%s%s", copyright, version);
    297 
    298 	format_bytes(pbuf, sizeof(pbuf), arm_ptob(physmem));
    299 	printf("total memory = %s\n", pbuf);
    300 
    301 	minaddr = 0;
    302 
    303 	/*
    304 	 * Allocate a submap for physio
    305 	 */
    306 	phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
    307 				   VM_PHYS_SIZE, 0, false, NULL);
    308 
    309 	format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
    310 	printf("avail memory = %s\n", pbuf);
    311 
    312 	struct lwp * const l = &lwp0;
    313 	struct pcb * const pcb = lwp_getpcb(l);
    314 	pcb->pcb_ksp = uvm_lwp_getuarea(l) + USPACE_SVC_STACK_TOP;
    315 	lwp_settrapframe(l, (struct trapframe *)pcb->pcb_ksp - 1);
    316 }
    317 
    318 /*
    319  * machine dependent system variables.
    320  */
    321 static int
    322 sysctl_machdep_booted_device(SYSCTLFN_ARGS)
    323 {
    324 	struct sysctlnode node;
    325 
    326 	if (booted_device == NULL)
    327 		return (EOPNOTSUPP);
    328 
    329 	node = *rnode;
    330 	node.sysctl_data = __UNCONST(device_xname(booted_device));
    331 	node.sysctl_size = strlen(device_xname(booted_device)) + 1;
    332 	return (sysctl_lookup(SYSCTLFN_CALL(&node)));
    333 }
    334 
    335 static int
    336 sysctl_machdep_booted_kernel(SYSCTLFN_ARGS)
    337 {
    338 	struct sysctlnode node;
    339 
    340 	if (booted_kernel == NULL || booted_kernel[0] == '\0')
    341 		return (EOPNOTSUPP);
    342 
    343 	node = *rnode;
    344 	node.sysctl_data = booted_kernel;
    345 	node.sysctl_size = strlen(booted_kernel) + 1;
    346 	return (sysctl_lookup(SYSCTLFN_CALL(&node)));
    347 }
    348 
    349 static int
    350 sysctl_machdep_cpu_arch(SYSCTLFN_ARGS)
    351 {
    352 	struct sysctlnode node = *rnode;
    353 	node.sysctl_data = __UNCONST(cpu_arch);
    354 	node.sysctl_size = strlen(cpu_arch) + 1;
    355 	return sysctl_lookup(SYSCTLFN_CALL(&node));
    356 }
    357 
    358 static int
    359 sysctl_machdep_powersave(SYSCTLFN_ARGS)
    360 {
    361 	struct sysctlnode node = *rnode;
    362 	int error, newval;
    363 
    364 	newval = cpu_do_powersave;
    365 	node.sysctl_data = &newval;
    366 	if (cpufuncs.cf_sleep == (void *) cpufunc_nullop)
    367 		node.sysctl_flags &= ~CTLFLAG_READWRITE;
    368 	error = sysctl_lookup(SYSCTLFN_CALL(&node));
    369 	if (error || newp == NULL || newval == cpu_do_powersave)
    370 		return (error);
    371 
    372 	if (newval < 0 || newval > 1)
    373 		return (EINVAL);
    374 	cpu_do_powersave = newval;
    375 
    376 	return (0);
    377 }
    378 
    379 SYSCTL_SETUP(sysctl_machdep_setup, "sysctl machdep subtree setup")
    380 {
    381 
    382 	sysctl_createv(clog, 0, NULL, NULL,
    383 		       CTLFLAG_PERMANENT,
    384 		       CTLTYPE_NODE, "machdep", NULL,
    385 		       NULL, 0, NULL, 0,
    386 		       CTL_MACHDEP, CTL_EOL);
    387 
    388 	sysctl_createv(clog, 0, NULL, NULL,
    389 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    390 		       CTLTYPE_INT, "debug", NULL,
    391 		       NULL, 0, &kernel_debug, 0,
    392 		       CTL_MACHDEP, CPU_DEBUG, CTL_EOL);
    393 	sysctl_createv(clog, 0, NULL, NULL,
    394 		       CTLFLAG_PERMANENT,
    395 		       CTLTYPE_STRING, "booted_device", NULL,
    396 		       sysctl_machdep_booted_device, 0, NULL, 0,
    397 		       CTL_MACHDEP, CPU_BOOTED_DEVICE, CTL_EOL);
    398 	sysctl_createv(clog, 0, NULL, NULL,
    399 		       CTLFLAG_PERMANENT,
    400 		       CTLTYPE_STRING, "booted_kernel", NULL,
    401 		       sysctl_machdep_booted_kernel, 0, NULL, 0,
    402 		       CTL_MACHDEP, CPU_BOOTED_KERNEL, CTL_EOL);
    403 	sysctl_createv(clog, 0, NULL, NULL,
    404 		       CTLFLAG_PERMANENT,
    405 		       CTLTYPE_STRUCT, "console_device", NULL,
    406 		       sysctl_consdev, 0, NULL, sizeof(dev_t),
    407 		       CTL_MACHDEP, CPU_CONSDEV, CTL_EOL);
    408 	sysctl_createv(clog, 0, NULL, NULL,
    409 		       CTLFLAG_PERMANENT,
    410 		       CTLTYPE_STRING, "cpu_arch", NULL,
    411 		       sysctl_machdep_cpu_arch, 0, NULL, 0,
    412 		       CTL_MACHDEP, CTL_CREATE, CTL_EOL);
    413 	sysctl_createv(clog, 0, NULL, NULL,
    414 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    415 		       CTLTYPE_INT, "powersave", NULL,
    416 		       sysctl_machdep_powersave, 0, &cpu_do_powersave, 0,
    417 		       CTL_MACHDEP, CPU_POWERSAVE, CTL_EOL);
    418 	sysctl_createv(clog, 0, NULL, NULL,
    419 		       CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE,
    420 		       CTLTYPE_INT, "cpu_id", NULL,
    421 		       NULL, curcpu()->ci_arm_cpuid, NULL, 0,
    422 		       CTL_MACHDEP, CTL_CREATE, CTL_EOL);
    423 #ifdef FPU_VFP
    424 	sysctl_createv(clog, 0, NULL, NULL,
    425 		       CTLFLAG_PERMANENT|CTLFLAG_READONLY,
    426 		       CTLTYPE_INT, "fpu_id", NULL,
    427 		       NULL, 0, &cpu_info_store.ci_vfp_id, 0,
    428 		       CTL_MACHDEP, CTL_CREATE, CTL_EOL);
    429 #endif
    430 	sysctl_createv(clog, 0, NULL, NULL,
    431 		       CTLFLAG_PERMANENT|CTLFLAG_READONLY,
    432 		       CTLTYPE_INT, "fpu_present", NULL,
    433 		       NULL, 0, &cpu_fpu_present, 0,
    434 		       CTL_MACHDEP, CTL_CREATE, CTL_EOL);
    435 	sysctl_createv(clog, 0, NULL, NULL,
    436 		       CTLFLAG_PERMANENT|CTLFLAG_READONLY,
    437 		       CTLTYPE_INT, "hwdiv_present", NULL,
    438 		       NULL, 0, &cpu_hwdiv_present, 0,
    439 		       CTL_MACHDEP, CTL_CREATE, CTL_EOL);
    440 	sysctl_createv(clog, 0, NULL, NULL,
    441 		       CTLFLAG_PERMANENT|CTLFLAG_READONLY,
    442 		       CTLTYPE_INT, "neon_present", NULL,
    443 		       NULL, 0, &cpu_neon_present, 0,
    444 		       CTL_MACHDEP, CTL_CREATE, CTL_EOL);
    445 	sysctl_createv(clog, 0, NULL, NULL,
    446 		       CTLFLAG_PERMANENT|CTLFLAG_READONLY,
    447 		       CTLTYPE_STRUCT, "id_isar", NULL,
    448 		       NULL, 0,
    449 		       cpu_instruction_set_attributes,
    450 		       sizeof(cpu_instruction_set_attributes),
    451 		       CTL_MACHDEP, CTL_CREATE, CTL_EOL);
    452 	sysctl_createv(clog, 0, NULL, NULL,
    453 		       CTLFLAG_PERMANENT|CTLFLAG_READONLY,
    454 		       CTLTYPE_STRUCT, "id_mmfr", NULL,
    455 		       NULL, 0,
    456 		       cpu_memory_model_features,
    457 		       sizeof(cpu_memory_model_features),
    458 		       CTL_MACHDEP, CTL_CREATE, CTL_EOL);
    459 	sysctl_createv(clog, 0, NULL, NULL,
    460 		       CTLFLAG_PERMANENT|CTLFLAG_READONLY,
    461 		       CTLTYPE_STRUCT, "id_pfr", NULL,
    462 		       NULL, 0,
    463 		       cpu_processor_features,
    464 		       sizeof(cpu_processor_features),
    465 		       CTL_MACHDEP, CTL_CREATE, CTL_EOL);
    466 	sysctl_createv(clog, 0, NULL, NULL,
    467 		       CTLFLAG_PERMANENT|CTLFLAG_READONLY,
    468 		       CTLTYPE_STRUCT, "id_mvfr", NULL,
    469 		       NULL, 0,
    470 		       cpu_media_and_vfp_features,
    471 		       sizeof(cpu_media_and_vfp_features),
    472 		       CTL_MACHDEP, CTL_CREATE, CTL_EOL);
    473 	sysctl_createv(clog, 0, NULL, NULL,
    474 		       CTLFLAG_PERMANENT|CTLFLAG_READONLY,
    475 		       CTLTYPE_INT, "simd_present", NULL,
    476 		       NULL, 0, &cpu_simd_present, 0,
    477 		       CTL_MACHDEP, CTL_CREATE, CTL_EOL);
    478 	sysctl_createv(clog, 0, NULL, NULL,
    479 		       CTLFLAG_PERMANENT|CTLFLAG_READONLY,
    480 		       CTLTYPE_INT, "simdex_present", NULL,
    481 		       NULL, 0, &cpu_simdex_present, 0,
    482 		       CTL_MACHDEP, CTL_CREATE, CTL_EOL);
    483 }
    484 
    485 void
    486 parse_mi_bootargs(char *args)
    487 {
    488 	int integer;
    489 
    490 	if (get_bootconf_option(args, "single", BOOTOPT_TYPE_BOOLEAN, &integer)
    491 	    || get_bootconf_option(args, "-s", BOOTOPT_TYPE_BOOLEAN, &integer))
    492 		if (integer)
    493 			boothowto |= RB_SINGLE;
    494 	if (get_bootconf_option(args, "kdb", BOOTOPT_TYPE_BOOLEAN, &integer)
    495 	    || get_bootconf_option(args, "-k", BOOTOPT_TYPE_BOOLEAN, &integer)
    496 	    || get_bootconf_option(args, "-d", BOOTOPT_TYPE_BOOLEAN, &integer))
    497 		if (integer)
    498 			boothowto |= RB_KDB;
    499 	if (get_bootconf_option(args, "ask", BOOTOPT_TYPE_BOOLEAN, &integer)
    500 	    || get_bootconf_option(args, "-a", BOOTOPT_TYPE_BOOLEAN, &integer))
    501 		if (integer)
    502 			boothowto |= RB_ASKNAME;
    503 
    504 #ifdef PMAP_DEBUG
    505 	if (get_bootconf_option(args, "pmapdebug", BOOTOPT_TYPE_INT, &integer)) {
    506 		pmap_debug_level = integer;
    507 		pmap_debug(pmap_debug_level);
    508 	}
    509 #endif	/* PMAP_DEBUG */
    510 
    511 /*	if (get_bootconf_option(args, "nbuf", BOOTOPT_TYPE_INT, &integer))
    512 		bufpages = integer;*/
    513 
    514 #if defined(MEMORY_DISK_HOOKS) && !defined(MEMORY_DISK_ROOT_SIZE)
    515 	if (get_bootconf_option(args, "memorydisc", BOOTOPT_TYPE_INT, &integer)
    516 	    || get_bootconf_option(args, "memorydisk", BOOTOPT_TYPE_INT, &integer)) {
    517 		md_root_size = integer;
    518 		md_root_size *= 1024;
    519 		if (md_root_size < 32*1024)
    520 			md_root_size = 32*1024;
    521 		if (md_root_size > 2048*1024)
    522 			md_root_size = 2048*1024;
    523 	}
    524 #endif	/* MEMORY_DISK_HOOKS && !MEMORY_DISK_ROOT_SIZE */
    525 
    526 	if (get_bootconf_option(args, "quiet", BOOTOPT_TYPE_BOOLEAN, &integer)
    527 	    || get_bootconf_option(args, "-q", BOOTOPT_TYPE_BOOLEAN, &integer))
    528 		if (integer)
    529 			boothowto |= AB_QUIET;
    530 	if (get_bootconf_option(args, "verbose", BOOTOPT_TYPE_BOOLEAN, &integer)
    531 	    || get_bootconf_option(args, "-v", BOOTOPT_TYPE_BOOLEAN, &integer))
    532 		if (integer)
    533 			boothowto |= AB_VERBOSE;
    534 }
    535 
    536 #ifdef __HAVE_FAST_SOFTINTS
    537 #if IPL_SOFTSERIAL != IPL_SOFTNET + 1
    538 #error IPLs are screwed up
    539 #elif IPL_SOFTNET != IPL_SOFTBIO + 1
    540 #error IPLs are screwed up
    541 #elif IPL_SOFTBIO != IPL_SOFTCLOCK + 1
    542 #error IPLs are screwed up
    543 #elif !(IPL_SOFTCLOCK > IPL_NONE)
    544 #error IPLs are screwed up
    545 #elif (IPL_NONE != 0)
    546 #error IPLs are screwed up
    547 #endif
    548 
    549 #ifndef __HAVE_PIC_FAST_SOFTINTS
    550 #define	SOFTINT2IPLMAP \
    551 	(((IPL_SOFTSERIAL - IPL_SOFTCLOCK) << (SOFTINT_SERIAL * 4)) | \
    552 	 ((IPL_SOFTNET    - IPL_SOFTCLOCK) << (SOFTINT_NET    * 4)) | \
    553 	 ((IPL_SOFTBIO    - IPL_SOFTCLOCK) << (SOFTINT_BIO    * 4)) | \
    554 	 ((IPL_SOFTCLOCK  - IPL_SOFTCLOCK) << (SOFTINT_CLOCK  * 4)))
    555 #define	SOFTINT2IPL(l)	((SOFTINT2IPLMAP >> ((l) * 4)) & 0x0f)
    556 
    557 /*
    558  * This returns a mask of softint IPLs that be dispatch at <ipl>
    559  * SOFTIPLMASK(IPL_NONE)	= 0x0000000f
    560  * SOFTIPLMASK(IPL_SOFTCLOCK)	= 0x0000000e
    561  * SOFTIPLMASK(IPL_SOFTBIO)	= 0x0000000c
    562  * SOFTIPLMASK(IPL_SOFTNET)	= 0x00000008
    563  * SOFTIPLMASK(IPL_SOFTSERIAL)	= 0x00000000
    564  */
    565 #define	SOFTIPLMASK(ipl) ((0x0f << (ipl)) & 0x0f)
    566 
    567 void softint_switch(lwp_t *, int);
    568 
    569 void
    570 softint_trigger(uintptr_t mask)
    571 {
    572 	curcpu()->ci_softints |= mask;
    573 }
    574 
    575 void
    576 softint_init_md(lwp_t *l, u_int level, uintptr_t *machdep)
    577 {
    578 	lwp_t ** lp = &l->l_cpu->ci_softlwps[level];
    579 	KASSERT(*lp == NULL || *lp == l);
    580 	*lp = l;
    581 	*machdep = 1 << SOFTINT2IPL(level);
    582 	KASSERT(level != SOFTINT_CLOCK || *machdep == (1 << (IPL_SOFTCLOCK - IPL_SOFTCLOCK)));
    583 	KASSERT(level != SOFTINT_BIO || *machdep == (1 << (IPL_SOFTBIO - IPL_SOFTCLOCK)));
    584 	KASSERT(level != SOFTINT_NET || *machdep == (1 << (IPL_SOFTNET - IPL_SOFTCLOCK)));
    585 	KASSERT(level != SOFTINT_SERIAL || *machdep == (1 << (IPL_SOFTSERIAL - IPL_SOFTCLOCK)));
    586 }
    587 
    588 void
    589 dosoftints(void)
    590 {
    591 	struct cpu_info * const ci = curcpu();
    592 	const int opl = ci->ci_cpl;
    593 	const uint32_t softiplmask = SOFTIPLMASK(opl);
    594 
    595 	splhigh();
    596 	for (;;) {
    597 		u_int softints = ci->ci_softints & softiplmask;
    598 		KASSERT((softints != 0) == ((ci->ci_softints >> opl) != 0));
    599 		KASSERT(opl == IPL_NONE || (softints & (1 << (opl - IPL_SOFTCLOCK))) == 0);
    600 		if (softints == 0) {
    601 			splx(opl);
    602 			return;
    603 		}
    604 #define	DOSOFTINT(n) \
    605 		if (ci->ci_softints & (1 << (IPL_SOFT ## n - IPL_SOFTCLOCK))) { \
    606 			ci->ci_softints &= \
    607 			    ~(1 << (IPL_SOFT ## n - IPL_SOFTCLOCK)); \
    608 			softint_switch(ci->ci_softlwps[SOFTINT_ ## n], \
    609 			    IPL_SOFT ## n); \
    610 			continue; \
    611 		}
    612 		DOSOFTINT(SERIAL);
    613 		DOSOFTINT(NET);
    614 		DOSOFTINT(BIO);
    615 		DOSOFTINT(CLOCK);
    616 		panic("dosoftints wtf (softints=%u?, ipl=%d)", softints, opl);
    617 	}
    618 }
    619 #endif /* !__HAVE_PIC_FAST_SOFTINTS */
    620 #endif /* __HAVE_FAST_SOFTINTS */
    621 
    622 #ifdef MODULAR
    623 /*
    624  * Push any modules loaded by the boot loader.
    625  */
    626 void
    627 module_init_md(void)
    628 {
    629 }
    630 #endif /* MODULAR */
    631 
    632 int
    633 mm_md_physacc(paddr_t pa, vm_prot_t prot)
    634 {
    635 
    636 	return (pa < ctob(physmem)) ? 0 : EFAULT;
    637 }
    638 
    639 #ifdef __HAVE_CPU_UAREA_ALLOC_IDLELWP
    640 vaddr_t
    641 cpu_uarea_alloc_idlelwp(struct cpu_info *ci)
    642 {
    643 	const vaddr_t va = idlestack.pv_va + ci->ci_cpuid * USPACE;
    644 	// printf("%s: %s: va=%lx\n", __func__, ci->ci_data.cpu_name, va);
    645 	return va;
    646 }
    647 #endif
    648 
    649 #ifdef MULTIPROCESSOR
    650 void
    651 cpu_boot_secondary_processors(void)
    652 {
    653 	uint32_t mbox;
    654 	kcpuset_export_u32(kcpuset_attached, &mbox, sizeof(mbox));
    655 	atomic_swap_32(&arm_cpu_mbox, mbox);
    656 	membar_producer();
    657 #ifdef _ARM_ARCH_7
    658 	__asm __volatile("sev; sev; sev");
    659 #endif
    660 }
    661 
    662 void
    663 xc_send_ipi(struct cpu_info *ci)
    664 {
    665 	KASSERT(kpreempt_disabled());
    666 	KASSERT(curcpu() != ci);
    667 
    668 
    669 	if (ci) {
    670 		/* Unicast, remote CPU */
    671 		printf("%s: -> %s", __func__, ci->ci_data.cpu_name);
    672 		intr_ipi_send(ci->ci_kcpuset, IPI_XCALL);
    673 	} else {
    674 		printf("%s: -> !%s", __func__, ci->ci_data.cpu_name);
    675 		/* Broadcast to all but ourselves */
    676 		kcpuset_t *kcp;
    677 		kcpuset_create(&kcp, (ci != NULL));
    678 		KASSERT(kcp != NULL);
    679 		kcpuset_copy(kcp, kcpuset_running);
    680 		kcpuset_clear(kcp, cpu_index(ci));
    681 		intr_ipi_send(kcp, IPI_XCALL);
    682 		kcpuset_destroy(kcp);
    683 	}
    684 	printf("\n");
    685 }
    686 #endif /* MULTIPROCESSOR */
    687 
    688 #ifdef __HAVE_MM_MD_DIRECT_MAPPED_PHYS
    689 bool
    690 mm_md_direct_mapped_phys(paddr_t pa, vaddr_t *vap)
    691 {
    692 	if (physical_start <= pa && pa < physical_end) {
    693 		*vap = KERNEL_BASE + (pa - physical_start);
    694 		return true;
    695 	}
    696 
    697 	return false;
    698 }
    699 #endif
    700