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