Home | History | Annotate | Line # | Download | only in arm32
arm32_machdep.c revision 1.56
      1  1.56      matt /*	$NetBSD: arm32_machdep.c,v 1.56 2008/04/27 18:58:43 matt 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.1     chris  * Machine dependant 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.56      matt __KERNEL_RCSID(0, "$NetBSD: arm32_machdep.c,v 1.56 2008/04/27 18:58:43 matt Exp $");
     46   1.1     chris 
     47   1.1     chris #include "opt_md.h"
     48  1.56      matt #include "opt_cpuoptions.h"
     49   1.1     chris #include "opt_pmap_debug.h"
     50   1.1     chris 
     51   1.1     chris #include <sys/param.h>
     52   1.1     chris #include <sys/systm.h>
     53   1.1     chris #include <sys/reboot.h>
     54   1.1     chris #include <sys/proc.h>
     55   1.1     chris #include <sys/user.h>
     56   1.1     chris #include <sys/kernel.h>
     57   1.1     chris #include <sys/mbuf.h>
     58   1.1     chris #include <sys/mount.h>
     59   1.1     chris #include <sys/buf.h>
     60   1.1     chris #include <sys/msgbuf.h>
     61   1.1     chris #include <sys/device.h>
     62   1.1     chris #include <uvm/uvm_extern.h>
     63   1.1     chris #include <sys/sysctl.h>
     64  1.49      yamt #include <sys/cpu.h>
     65   1.1     chris 
     66   1.1     chris #include <dev/cons.h>
     67   1.1     chris 
     68   1.7   thorpej #include <arm/arm32/katelib.h>
     69   1.9     chris #include <arm/arm32/machdep.h>
     70   1.1     chris #include <machine/bootconfig.h>
     71   1.1     chris 
     72   1.1     chris #include "md.h"
     73   1.1     chris 
     74   1.1     chris struct vm_map *exec_map = NULL;
     75   1.1     chris struct vm_map *mb_map = NULL;
     76   1.1     chris struct vm_map *phys_map = NULL;
     77   1.1     chris 
     78   1.1     chris extern int physmem;
     79   1.1     chris 
     80  1.21     lukem #if NMD > 0 && defined(MEMORY_DISK_HOOKS) && !defined(MEMORY_DISK_ROOT_SIZE)
     81  1.24  jdolecek extern size_t md_root_size;		/* Memory disc size */
     82  1.21     lukem #endif	/* NMD && MEMORY_DISK_HOOKS && !MEMORY_DISK_ROOT_SIZE */
     83   1.1     chris 
     84   1.1     chris pv_addr_t kernelstack;
     85   1.1     chris 
     86   1.1     chris /* the following is used externally (sysctl_hw) */
     87   1.1     chris char	machine[] = MACHINE;		/* from <machine/param.h> */
     88   1.1     chris char	machine_arch[] = MACHINE_ARCH;	/* from <machine/param.h> */
     89   1.1     chris 
     90   1.1     chris /* Our exported CPU info; we can have only one. */
     91  1.56      matt struct cpu_info cpu_info_store = {
     92  1.56      matt 	.ci_cpl = IPL_HIGH,
     93  1.56      matt #ifndef PROCESS_ID_IS_CURLWP
     94  1.56      matt 	.ci_curlwp = &lwp0,
     95  1.56      matt #endif
     96  1.56      matt };
     97   1.1     chris 
     98  1.48  christos void *	msgbufaddr;
     99   1.1     chris extern paddr_t msgbufphys;
    100   1.1     chris 
    101   1.1     chris int kernel_debug = 0;
    102   1.1     chris 
    103   1.1     chris struct user *proc0paddr;
    104   1.1     chris 
    105  1.12   reinoud /* exported variable to be filled in by the bootloaders */
    106   1.1     chris char *booted_kernel;
    107   1.1     chris 
    108   1.1     chris 
    109   1.1     chris /* Prototypes */
    110   1.1     chris 
    111   1.1     chris void data_abort_handler		__P((trapframe_t *frame));
    112   1.1     chris void prefetch_abort_handler	__P((trapframe_t *frame));
    113   1.1     chris extern void configure		__P((void));
    114   1.1     chris 
    115   1.1     chris /*
    116  1.22   thorpej  * arm32_vector_init:
    117  1.22   thorpej  *
    118  1.22   thorpej  *	Initialize the vector page, and select whether or not to
    119  1.22   thorpej  *	relocate the vectors.
    120  1.22   thorpej  *
    121  1.22   thorpej  *	NOTE: We expect the vector page to be mapped at its expected
    122  1.22   thorpej  *	destination.
    123  1.22   thorpej  */
    124  1.22   thorpej void
    125  1.22   thorpej arm32_vector_init(vaddr_t va, int which)
    126  1.22   thorpej {
    127  1.22   thorpej 	extern unsigned int page0[], page0_data[];
    128  1.22   thorpej 	unsigned int *vectors = (int *) va;
    129  1.22   thorpej 	unsigned int *vectors_data = vectors + (page0_data - page0);
    130  1.22   thorpej 	int vec;
    131  1.22   thorpej 
    132  1.22   thorpej 	/*
    133  1.22   thorpej 	 * Loop through the vectors we're taking over, and copy the
    134  1.22   thorpej 	 * vector's insn and data word.
    135  1.22   thorpej 	 */
    136  1.22   thorpej 	for (vec = 0; vec < ARM_NVEC; vec++) {
    137  1.22   thorpej 		if ((which & (1 << vec)) == 0) {
    138  1.22   thorpej 			/* Don't want to take over this vector. */
    139  1.22   thorpej 			continue;
    140  1.22   thorpej 		}
    141  1.22   thorpej 		vectors[vec] = page0[vec];
    142  1.22   thorpej 		vectors_data[vec] = page0_data[vec];
    143  1.22   thorpej 	}
    144  1.22   thorpej 
    145  1.22   thorpej 	/* Now sync the vectors. */
    146  1.22   thorpej 	cpu_icache_sync_range(va, (ARM_NVEC * 2) * sizeof(u_int));
    147  1.22   thorpej 
    148  1.22   thorpej 	vector_page = va;
    149  1.30       scw 
    150  1.30       scw 	if (va == ARM_VECTORS_HIGH) {
    151  1.30       scw 		/*
    152  1.30       scw 		 * Assume the MD caller knows what it's doing here, and
    153  1.30       scw 		 * really does want the vector page relocated.
    154  1.30       scw 		 *
    155  1.30       scw 		 * Note: This has to be done here (and not just in
    156  1.30       scw 		 * cpu_setup()) because the vector page needs to be
    157  1.30       scw 		 * accessible *before* cpu_startup() is called.
    158  1.30       scw 		 * Think ddb(9) ...
    159  1.32   thorpej 		 *
    160  1.32   thorpej 		 * NOTE: If the CPU control register is not readable,
    161  1.32   thorpej 		 * this will totally fail!  We'll just assume that
    162  1.32   thorpej 		 * any system that has high vector support has a
    163  1.32   thorpej 		 * readable CPU control register, for now.  If we
    164  1.32   thorpej 		 * ever encounter one that does not, we'll have to
    165  1.32   thorpej 		 * rethink this.
    166  1.30       scw 		 */
    167  1.30       scw 		cpu_control(CPU_CONTROL_VECRELOC, CPU_CONTROL_VECRELOC);
    168  1.30       scw 	}
    169  1.22   thorpej }
    170  1.22   thorpej 
    171  1.22   thorpej /*
    172   1.1     chris  * Debug function just to park the CPU
    173   1.1     chris  */
    174   1.1     chris 
    175   1.1     chris void
    176   1.1     chris halt()
    177   1.1     chris {
    178   1.1     chris 	while (1)
    179   1.1     chris 		cpu_sleep(0);
    180   1.1     chris }
    181   1.1     chris 
    182   1.1     chris 
    183   1.1     chris /* Sync the discs and unmount the filesystems */
    184   1.1     chris 
    185   1.1     chris void
    186   1.1     chris bootsync(void)
    187   1.1     chris {
    188   1.1     chris 	static int bootsyncdone = 0;
    189   1.1     chris 
    190   1.1     chris 	if (bootsyncdone) return;
    191   1.1     chris 
    192   1.1     chris 	bootsyncdone = 1;
    193   1.1     chris 
    194   1.1     chris 	/* Make sure we can still manage to do things */
    195   1.1     chris 	if (GetCPSR() & I32_bit) {
    196   1.1     chris 		/*
    197   1.1     chris 		 * If we get here then boot has been called without RB_NOSYNC
    198   1.1     chris 		 * and interrupts were disabled. This means the boot() call
    199   1.1     chris 		 * did not come from a user process e.g. shutdown, but must
    200   1.1     chris 		 * have come from somewhere in the kernel.
    201   1.1     chris 		 */
    202   1.1     chris 		IRQenable;
    203   1.1     chris 		printf("Warning IRQ's disabled during boot()\n");
    204   1.1     chris 	}
    205   1.1     chris 
    206   1.1     chris 	vfs_shutdown();
    207   1.1     chris }
    208   1.1     chris 
    209   1.1     chris /*
    210   1.1     chris  * void cpu_startup(void)
    211   1.1     chris  *
    212   1.1     chris  * Machine dependant startup code.
    213   1.1     chris  *
    214   1.1     chris  */
    215   1.1     chris void
    216   1.1     chris cpu_startup()
    217   1.1     chris {
    218  1.42        pk 	vaddr_t minaddr;
    219  1.42        pk 	vaddr_t maxaddr;
    220  1.42        pk 	u_int loop;
    221   1.1     chris 	char pbuf[9];
    222   1.1     chris 
    223  1.43       wiz 	/* Set the CPU control register */
    224   1.1     chris 	cpu_setup(boot_args);
    225   1.1     chris 
    226   1.1     chris 	/* Lock down zero page */
    227  1.22   thorpej 	vector_page_setprot(VM_PROT_READ);
    228   1.1     chris 
    229   1.1     chris 	/*
    230   1.1     chris 	 * Give pmap a chance to set up a few more things now the vm
    231   1.1     chris 	 * is initialised
    232   1.1     chris 	 */
    233   1.1     chris 	pmap_postinit();
    234   1.1     chris 
    235   1.1     chris 	/*
    236   1.1     chris 	 * Initialize error message buffer (at end of core).
    237   1.1     chris 	 */
    238   1.1     chris 
    239   1.1     chris 	/* msgbufphys was setup during the secondary boot strap */
    240   1.1     chris 	for (loop = 0; loop < btoc(MSGBUFSIZE); ++loop)
    241  1.29   thorpej 		pmap_kenter_pa((vaddr_t)msgbufaddr + loop * PAGE_SIZE,
    242  1.29   thorpej 		    msgbufphys + loop * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE);
    243   1.5     chris 	pmap_update(pmap_kernel());
    244   1.1     chris 	initmsgbuf(msgbufaddr, round_page(MSGBUFSIZE));
    245   1.1     chris 
    246   1.1     chris 	/*
    247   1.1     chris 	 * Identify ourselves for the msgbuf (everything printed earlier will
    248   1.1     chris 	 * not be buffered).
    249   1.1     chris 	 */
    250  1.45     lukem 	printf("%s%s", copyright, version);
    251   1.1     chris 
    252  1.20   thorpej 	format_bytes(pbuf, sizeof(pbuf), arm_ptob(physmem));
    253   1.1     chris 	printf("total memory = %s\n", pbuf);
    254   1.1     chris 
    255  1.42        pk 	minaddr = 0;
    256   1.1     chris 
    257   1.1     chris 	/*
    258   1.1     chris 	 * Allocate a submap for exec arguments.  This map effectively
    259   1.1     chris 	 * limits the number of processes exec'ing at any time.
    260   1.1     chris 	 */
    261   1.1     chris 	exec_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
    262  1.47   thorpej 				   16*NCARGS, VM_MAP_PAGEABLE, false, NULL);
    263   1.1     chris 
    264   1.1     chris 	/*
    265   1.1     chris 	 * Allocate a submap for physio
    266   1.1     chris 	 */
    267   1.1     chris 	phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
    268  1.47   thorpej 				   VM_PHYS_SIZE, 0, false, NULL);
    269   1.1     chris 
    270   1.1     chris 	/*
    271   1.1     chris 	 * Finally, allocate mbuf cluster submap.
    272   1.1     chris 	 */
    273   1.1     chris 	mb_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
    274   1.1     chris 				 nmbclusters * mclbytes, VM_MAP_INTRSAFE,
    275  1.47   thorpej 				 false, NULL);
    276   1.1     chris 
    277   1.1     chris 	format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
    278   1.1     chris 	printf("avail memory = %s\n", pbuf);
    279   1.1     chris 
    280  1.27   thorpej 	curpcb = &lwp0.l_addr->u_pcb;
    281   1.1     chris 	curpcb->pcb_flags = 0;
    282  1.27   thorpej 	curpcb->pcb_un.un_32.pcb32_sp = (u_int)lwp0.l_addr +
    283   1.4    toshii 	    USPACE_SVC_STACK_TOP;
    284   1.1     chris 
    285   1.4    toshii         curpcb->pcb_tf = (struct trapframe *)curpcb->pcb_un.un_32.pcb32_sp - 1;
    286   1.1     chris }
    287   1.1     chris 
    288   1.1     chris /*
    289   1.1     chris  * machine dependent system variables.
    290   1.1     chris  */
    291  1.39    atatat static int
    292  1.39    atatat sysctl_machdep_booted_device(SYSCTLFN_ARGS)
    293  1.39    atatat {
    294  1.39    atatat 	struct sysctlnode node;
    295  1.39    atatat 
    296  1.39    atatat 	if (booted_device == NULL)
    297  1.39    atatat 		return (EOPNOTSUPP);
    298  1.39    atatat 
    299  1.39    atatat 	node = *rnode;
    300  1.39    atatat 	node.sysctl_data = booted_device->dv_xname;
    301  1.39    atatat 	node.sysctl_size = strlen(booted_device->dv_xname) + 1;
    302  1.39    atatat 	return (sysctl_lookup(SYSCTLFN_CALL(&node)));
    303  1.39    atatat }
    304   1.1     chris 
    305  1.39    atatat static int
    306  1.39    atatat sysctl_machdep_booted_kernel(SYSCTLFN_ARGS)
    307   1.1     chris {
    308  1.39    atatat 	struct sysctlnode node;
    309  1.39    atatat 
    310  1.39    atatat 	if (booted_kernel == NULL || booted_kernel[0] == '\0')
    311   1.1     chris 		return (EOPNOTSUPP);
    312   1.1     chris 
    313  1.39    atatat 	node = *rnode;
    314  1.39    atatat 	node.sysctl_data = booted_kernel;
    315  1.39    atatat 	node.sysctl_size = strlen(booted_kernel) + 1;
    316  1.39    atatat 	return (sysctl_lookup(SYSCTLFN_CALL(&node)));
    317  1.39    atatat }
    318  1.25   thorpej 
    319  1.39    atatat static int
    320  1.39    atatat sysctl_machdep_powersave(SYSCTLFN_ARGS)
    321  1.39    atatat {
    322  1.39    atatat 	struct sysctlnode node = *rnode;
    323  1.39    atatat 	int error, newval;
    324  1.25   thorpej 
    325  1.39    atatat 	newval = cpu_do_powersave;
    326  1.39    atatat 	node.sysctl_data = &newval;
    327  1.39    atatat 	if (cpufuncs.cf_sleep == (void *) cpufunc_nullop)
    328  1.44    atatat 		node.sysctl_flags &= ~CTLFLAG_READWRITE;
    329  1.39    atatat 	error = sysctl_lookup(SYSCTLFN_CALL(&node));
    330  1.39    atatat 	if (error || newp == NULL || newval == cpu_do_powersave)
    331  1.39    atatat 		return (error);
    332  1.39    atatat 
    333  1.39    atatat 	if (newval < 0 || newval > 1)
    334  1.39    atatat 		return (EINVAL);
    335  1.39    atatat 	cpu_do_powersave = newval;
    336  1.25   thorpej 
    337  1.39    atatat 	return (0);
    338  1.39    atatat }
    339  1.25   thorpej 
    340  1.39    atatat SYSCTL_SETUP(sysctl_machdep_setup, "sysctl machdep subtree setup")
    341  1.39    atatat {
    342   1.1     chris 
    343  1.44    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    344  1.44    atatat 		       CTLFLAG_PERMANENT,
    345  1.39    atatat 		       CTLTYPE_NODE, "machdep", NULL,
    346  1.39    atatat 		       NULL, 0, NULL, 0,
    347  1.39    atatat 		       CTL_MACHDEP, CTL_EOL);
    348  1.39    atatat 
    349  1.44    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    350  1.44    atatat 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    351  1.40    atatat 		       CTLTYPE_INT, "debug", NULL,
    352  1.39    atatat 		       NULL, 0, &kernel_debug, 0,
    353  1.41  rearnsha 		       CTL_MACHDEP, CPU_DEBUG, CTL_EOL);
    354  1.44    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    355  1.44    atatat 		       CTLFLAG_PERMANENT,
    356  1.39    atatat 		       CTLTYPE_STRING, "booted_device", NULL,
    357  1.39    atatat 		       sysctl_machdep_booted_device, 0, NULL, 0,
    358  1.39    atatat 		       CTL_MACHDEP, CPU_BOOTED_DEVICE, CTL_EOL);
    359  1.44    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    360  1.44    atatat 		       CTLFLAG_PERMANENT,
    361  1.39    atatat 		       CTLTYPE_STRING, "booted_kernel", NULL,
    362  1.39    atatat 		       sysctl_machdep_booted_kernel, 0, NULL, 0,
    363  1.39    atatat 		       CTL_MACHDEP, CPU_BOOTED_KERNEL, CTL_EOL);
    364  1.44    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    365  1.44    atatat 		       CTLFLAG_PERMANENT,
    366  1.39    atatat 		       CTLTYPE_STRUCT, "console_device", NULL,
    367  1.39    atatat 		       sysctl_consdev, 0, NULL, sizeof(dev_t),
    368  1.39    atatat 		       CTL_MACHDEP, CPU_CONSDEV, CTL_EOL);
    369  1.44    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    370  1.44    atatat 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    371  1.39    atatat 		       CTLTYPE_INT, "powersave", NULL,
    372  1.39    atatat 		       sysctl_machdep_powersave, 0, &cpu_do_powersave, 0,
    373  1.39    atatat 		       CTL_MACHDEP, CPU_POWERSAVE, CTL_EOL);
    374   1.1     chris }
    375   1.1     chris 
    376   1.1     chris void
    377   1.1     chris parse_mi_bootargs(args)
    378   1.1     chris 	char *args;
    379   1.1     chris {
    380   1.1     chris 	int integer;
    381   1.1     chris 
    382   1.1     chris 	if (get_bootconf_option(args, "single", BOOTOPT_TYPE_BOOLEAN, &integer)
    383   1.1     chris 	    || get_bootconf_option(args, "-s", BOOTOPT_TYPE_BOOLEAN, &integer))
    384   1.1     chris 		if (integer)
    385   1.1     chris 			boothowto |= RB_SINGLE;
    386   1.1     chris 	if (get_bootconf_option(args, "kdb", BOOTOPT_TYPE_BOOLEAN, &integer)
    387   1.1     chris 	    || get_bootconf_option(args, "-k", BOOTOPT_TYPE_BOOLEAN, &integer))
    388   1.1     chris 		if (integer)
    389   1.1     chris 			boothowto |= RB_KDB;
    390   1.1     chris 	if (get_bootconf_option(args, "ask", BOOTOPT_TYPE_BOOLEAN, &integer)
    391   1.1     chris 	    || get_bootconf_option(args, "-a", BOOTOPT_TYPE_BOOLEAN, &integer))
    392   1.1     chris 		if (integer)
    393   1.1     chris 			boothowto |= RB_ASKNAME;
    394   1.1     chris 
    395   1.1     chris #ifdef PMAP_DEBUG
    396   1.1     chris 	if (get_bootconf_option(args, "pmapdebug", BOOTOPT_TYPE_INT, &integer)) {
    397   1.1     chris 		pmap_debug_level = integer;
    398   1.1     chris 		pmap_debug(pmap_debug_level);
    399   1.1     chris 	}
    400   1.1     chris #endif	/* PMAP_DEBUG */
    401   1.1     chris 
    402   1.1     chris /*	if (get_bootconf_option(args, "nbuf", BOOTOPT_TYPE_INT, &integer))
    403   1.1     chris 		bufpages = integer;*/
    404   1.1     chris 
    405  1.21     lukem #if NMD > 0 && defined(MEMORY_DISK_HOOKS) && !defined(MEMORY_DISK_ROOT_SIZE)
    406   1.1     chris 	if (get_bootconf_option(args, "memorydisc", BOOTOPT_TYPE_INT, &integer)
    407   1.1     chris 	    || get_bootconf_option(args, "memorydisk", BOOTOPT_TYPE_INT, &integer)) {
    408  1.24  jdolecek 		md_root_size = integer;
    409  1.24  jdolecek 		md_root_size *= 1024;
    410  1.24  jdolecek 		if (md_root_size < 32*1024)
    411  1.24  jdolecek 			md_root_size = 32*1024;
    412  1.24  jdolecek 		if (md_root_size > 2048*1024)
    413  1.24  jdolecek 			md_root_size = 2048*1024;
    414   1.1     chris 	}
    415  1.21     lukem #endif	/* NMD && MEMORY_DISK_HOOKS && !MEMORY_DISK_ROOT_SIZE */
    416   1.1     chris 
    417   1.1     chris 	if (get_bootconf_option(args, "quiet", BOOTOPT_TYPE_BOOLEAN, &integer)
    418   1.1     chris 	    || get_bootconf_option(args, "-q", BOOTOPT_TYPE_BOOLEAN, &integer))
    419   1.1     chris 		if (integer)
    420   1.1     chris 			boothowto |= AB_QUIET;
    421   1.1     chris 	if (get_bootconf_option(args, "verbose", BOOTOPT_TYPE_BOOLEAN, &integer)
    422   1.1     chris 	    || get_bootconf_option(args, "-v", BOOTOPT_TYPE_BOOLEAN, &integer))
    423   1.1     chris 		if (integer)
    424   1.1     chris 			boothowto |= AB_VERBOSE;
    425   1.1     chris }
    426  1.49      yamt 
    427  1.49      yamt void
    428  1.49      yamt cpu_need_resched(struct cpu_info *ci, int flags)
    429  1.49      yamt {
    430  1.49      yamt 	bool immed = (flags & RESCHED_IMMED) != 0;
    431  1.49      yamt 
    432  1.51        ad 	if (ci->ci_want_resched && !immed)
    433  1.49      yamt 		return;
    434  1.49      yamt 
    435  1.51        ad 	ci->ci_want_resched = 1;
    436  1.49      yamt 	if (curlwp != ci->ci_data.cpu_idlelwp)
    437  1.49      yamt 		setsoftast();
    438  1.49      yamt }
    439  1.53       mrg 
    440  1.53       mrg bool
    441  1.53       mrg cpu_intr_p(void)
    442  1.53       mrg {
    443  1.56      matt 	return curcpu()->ci_intr_depth != 0;
    444  1.56      matt }
    445  1.56      matt 
    446  1.56      matt #ifdef __HAVE_FAST_SOFTINTS
    447  1.56      matt #if IPL_SOFTSERIAL != IPL_SOFTNET + 1
    448  1.56      matt #error IPLs are screwed up
    449  1.56      matt #endif
    450  1.56      matt #if IPL_SOFTNET != IPL_SOFTBIO + 1
    451  1.56      matt #error IPLs are screwed up
    452  1.56      matt #endif
    453  1.56      matt #if IPL_SOFTBIO != IPL_SOFTCLOCK + 1
    454  1.56      matt #error IPLs are screwed up
    455  1.56      matt #endif
    456  1.56      matt #if !(IPL_SOFTCLOCK > IPL_NONE)
    457  1.56      matt #error IPLs are screwed up
    458  1.56      matt #endif
    459  1.56      matt #define	SOFTINT2IPLMAP \
    460  1.56      matt 	((IPL_SOFTSERIAL << (SOFTINT_SERIAL * 4)) | \
    461  1.56      matt 	 (IPL_SOFTNET    << (SOFTINT_NET    * 4)) | \
    462  1.56      matt 	 (IPL_SOFTBIO    << (SOFTINT_BIO    * 4)) | \
    463  1.56      matt 	 (IPL_SOFTCLOCK  << (SOFTINT_CLOCK  * 4)))
    464  1.56      matt #define	SOFTINT2IPL(l)	((SOFTINT2IPLMAP >> ((l) * 4)) & 0x0f)
    465  1.56      matt 
    466  1.56      matt /*
    467  1.56      matt  * This returns a mask of softint IPLs that be dispatch at <ipl>
    468  1.56      matt  * We want to shift 2 since we want a mask of <ipl> + 1.
    469  1.56      matt  * SOFTIPLMASK(IPL_NONE)	= 0xfffffffe
    470  1.56      matt  * SOFTIPLMASK(IPL_SOFTCLOCK)	= 0xffffffe0
    471  1.56      matt  */
    472  1.56      matt #define	SOFTIPLMASK(ipl) ((~((2 << (ipl)) - 1)) & (15 << IPL_SOFTCLOCK))
    473  1.56      matt 
    474  1.56      matt void softint_switch(lwp_t *, int);
    475  1.56      matt 
    476  1.56      matt void
    477  1.56      matt softint_trigger(uintptr_t mask)
    478  1.56      matt {
    479  1.56      matt 	curcpu()->ci_softints |= mask;
    480  1.56      matt }
    481  1.56      matt 
    482  1.56      matt void
    483  1.56      matt softint_init_md(lwp_t *l, u_int level, uintptr_t *machdep)
    484  1.56      matt {
    485  1.56      matt 	lwp_t ** lp = &curcpu()->ci_softlwps[level];
    486  1.56      matt 	KASSERT(*lp == NULL || *lp == l);
    487  1.56      matt 	*lp = l;
    488  1.56      matt 	*machdep = 1 << SOFTINT2IPL(level);
    489  1.56      matt }
    490  1.53       mrg 
    491  1.56      matt void
    492  1.56      matt dosoftints(void)
    493  1.56      matt {
    494  1.56      matt 	struct cpu_info * const ci = curcpu();
    495  1.56      matt 	const int opl = ci->ci_cpl;
    496  1.56      matt 	const uint32_t softiplmask = SOFTIPLMASK(opl);
    497  1.56      matt 
    498  1.56      matt 	for (;;) {
    499  1.56      matt 		u_int softints = ci->ci_softints & softiplmask;
    500  1.56      matt 		if (softints == 0)
    501  1.56      matt 			return;
    502  1.56      matt 		ci->ci_cpl = IPL_HIGH;
    503  1.56      matt #define	DOSOFTINT(n) \
    504  1.56      matt 		if (softints & (1 << IPL_SOFT ## n)) { \
    505  1.56      matt 			ci->ci_softints &= ~(1 << IPL_SOFT ## n); \
    506  1.56      matt 			softint_switch(ci->ci_softlwps[SOFTINT_ ## n], \
    507  1.56      matt 			    IPL_SOFT ## n); \
    508  1.56      matt 			ci->ci_cpl = opl; \
    509  1.56      matt 			continue; \
    510  1.56      matt 		}
    511  1.56      matt 		DOSOFTINT(SERIAL);
    512  1.56      matt 		DOSOFTINT(NET);
    513  1.56      matt 		DOSOFTINT(BIO);
    514  1.56      matt 		DOSOFTINT(CLOCK);
    515  1.56      matt 		panic("dosoftints wtf (softints=%u?, ipl=%d)", softints, opl);
    516  1.56      matt 	}
    517  1.53       mrg }
    518  1.56      matt #endif /* __HAVE_FAST_SOFTINTS */
    519