Home | History | Annotate | Line # | Download | only in arm32
arm32_machdep.c revision 1.6.2.8
      1  1.6.2.8  nathanw /*	$NetBSD: arm32_machdep.c,v 1.6.2.8 2002/06/20 03:38:02 nathanw Exp $	*/
      2  1.6.2.2  thorpej 
      3  1.6.2.2  thorpej /*
      4  1.6.2.2  thorpej  * Copyright (c) 1994-1998 Mark Brinicombe.
      5  1.6.2.2  thorpej  * Copyright (c) 1994 Brini.
      6  1.6.2.2  thorpej  * All rights reserved.
      7  1.6.2.2  thorpej  *
      8  1.6.2.2  thorpej  * This code is derived from software written for Brini by Mark Brinicombe
      9  1.6.2.2  thorpej  *
     10  1.6.2.2  thorpej  * Redistribution and use in source and binary forms, with or without
     11  1.6.2.2  thorpej  * modification, are permitted provided that the following conditions
     12  1.6.2.2  thorpej  * are met:
     13  1.6.2.2  thorpej  * 1. Redistributions of source code must retain the above copyright
     14  1.6.2.2  thorpej  *    notice, this list of conditions and the following disclaimer.
     15  1.6.2.2  thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.6.2.2  thorpej  *    notice, this list of conditions and the following disclaimer in the
     17  1.6.2.2  thorpej  *    documentation and/or other materials provided with the distribution.
     18  1.6.2.2  thorpej  * 3. All advertising materials mentioning features or use of this software
     19  1.6.2.2  thorpej  *    must display the following acknowledgement:
     20  1.6.2.2  thorpej  *	This product includes software developed by Mark Brinicombe
     21  1.6.2.2  thorpej  *	for the NetBSD Project.
     22  1.6.2.2  thorpej  * 4. The name of the company nor the name of the author may be used to
     23  1.6.2.2  thorpej  *    endorse or promote products derived from this software without specific
     24  1.6.2.2  thorpej  *    prior written permission.
     25  1.6.2.2  thorpej  *
     26  1.6.2.2  thorpej  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
     27  1.6.2.2  thorpej  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     28  1.6.2.2  thorpej  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     29  1.6.2.2  thorpej  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     30  1.6.2.2  thorpej  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     31  1.6.2.2  thorpej  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     32  1.6.2.2  thorpej  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33  1.6.2.2  thorpej  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34  1.6.2.2  thorpej  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35  1.6.2.2  thorpej  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36  1.6.2.2  thorpej  * SUCH DAMAGE.
     37  1.6.2.2  thorpej  *
     38  1.6.2.2  thorpej  * Machine dependant functions for kernel setup
     39  1.6.2.2  thorpej  *
     40  1.6.2.2  thorpej  * Created      : 17/09/94
     41  1.6.2.2  thorpej  * Updated	: 18/04/01 updated for new wscons
     42  1.6.2.2  thorpej  */
     43  1.6.2.2  thorpej 
     44  1.6.2.2  thorpej #include "opt_md.h"
     45  1.6.2.2  thorpej #include "opt_pmap_debug.h"
     46  1.6.2.2  thorpej 
     47  1.6.2.2  thorpej #include <sys/param.h>
     48  1.6.2.2  thorpej #include <sys/systm.h>
     49  1.6.2.2  thorpej #include <sys/reboot.h>
     50  1.6.2.2  thorpej #include <sys/proc.h>
     51  1.6.2.2  thorpej #include <sys/user.h>
     52  1.6.2.2  thorpej #include <sys/kernel.h>
     53  1.6.2.2  thorpej #include <sys/mbuf.h>
     54  1.6.2.2  thorpej #include <sys/mount.h>
     55  1.6.2.2  thorpej #include <sys/buf.h>
     56  1.6.2.2  thorpej #include <sys/msgbuf.h>
     57  1.6.2.2  thorpej #include <sys/device.h>
     58  1.6.2.2  thorpej #include <uvm/uvm_extern.h>
     59  1.6.2.2  thorpej #include <sys/sysctl.h>
     60  1.6.2.2  thorpej 
     61  1.6.2.2  thorpej #include <dev/cons.h>
     62  1.6.2.2  thorpej 
     63  1.6.2.3  nathanw #include <arm/arm32/katelib.h>
     64  1.6.2.4  nathanw #include <arm/arm32/machdep.h>
     65  1.6.2.2  thorpej #include <machine/bootconfig.h>
     66  1.6.2.2  thorpej 
     67  1.6.2.2  thorpej #include "opt_ipkdb.h"
     68  1.6.2.2  thorpej #include "md.h"
     69  1.6.2.2  thorpej 
     70  1.6.2.2  thorpej struct vm_map *exec_map = NULL;
     71  1.6.2.2  thorpej struct vm_map *mb_map = NULL;
     72  1.6.2.2  thorpej struct vm_map *phys_map = NULL;
     73  1.6.2.2  thorpej 
     74  1.6.2.2  thorpej extern int physmem;
     75  1.6.2.2  thorpej 
     76  1.6.2.2  thorpej #ifndef PMAP_STATIC_L1S
     77  1.6.2.2  thorpej extern int max_processes;
     78  1.6.2.2  thorpej #endif	/* !PMAP_STATIC_L1S */
     79  1.6.2.7  nathanw #if NMD > 0 && defined(MEMORY_DISK_HOOKS) && !defined(MEMORY_DISK_ROOT_SIZE)
     80  1.6.2.8  nathanw extern size_t md_root_size;		/* Memory disc size */
     81  1.6.2.7  nathanw #endif	/* NMD && MEMORY_DISK_HOOKS && !MEMORY_DISK_ROOT_SIZE */
     82  1.6.2.2  thorpej 
     83  1.6.2.2  thorpej pv_addr_t kernelstack;
     84  1.6.2.2  thorpej 
     85  1.6.2.2  thorpej /* the following is used externally (sysctl_hw) */
     86  1.6.2.2  thorpej char	machine[] = MACHINE;		/* from <machine/param.h> */
     87  1.6.2.2  thorpej char	machine_arch[] = MACHINE_ARCH;	/* from <machine/param.h> */
     88  1.6.2.2  thorpej 
     89  1.6.2.2  thorpej /* Our exported CPU info; we can have only one. */
     90  1.6.2.2  thorpej struct cpu_info cpu_info_store;
     91  1.6.2.2  thorpej 
     92  1.6.2.2  thorpej caddr_t	msgbufaddr;
     93  1.6.2.2  thorpej extern paddr_t msgbufphys;
     94  1.6.2.2  thorpej 
     95  1.6.2.2  thorpej int kernel_debug = 0;
     96  1.6.2.2  thorpej 
     97  1.6.2.2  thorpej struct user *proc0paddr;
     98  1.6.2.2  thorpej 
     99  1.6.2.5  nathanw /* exported variable to be filled in by the bootloaders */
    100  1.6.2.2  thorpej char *booted_kernel;
    101  1.6.2.2  thorpej 
    102  1.6.2.2  thorpej 
    103  1.6.2.2  thorpej /* Prototypes */
    104  1.6.2.2  thorpej 
    105  1.6.2.2  thorpej u_long strtoul			__P((const char *s, char **ptr, int base));
    106  1.6.2.2  thorpej void data_abort_handler		__P((trapframe_t *frame));
    107  1.6.2.2  thorpej void prefetch_abort_handler	__P((trapframe_t *frame));
    108  1.6.2.2  thorpej extern void configure		__P((void));
    109  1.6.2.2  thorpej 
    110  1.6.2.2  thorpej /*
    111  1.6.2.7  nathanw  * arm32_vector_init:
    112  1.6.2.7  nathanw  *
    113  1.6.2.7  nathanw  *	Initialize the vector page, and select whether or not to
    114  1.6.2.7  nathanw  *	relocate the vectors.
    115  1.6.2.7  nathanw  *
    116  1.6.2.7  nathanw  *	NOTE: We expect the vector page to be mapped at its expected
    117  1.6.2.7  nathanw  *	destination.
    118  1.6.2.7  nathanw  */
    119  1.6.2.7  nathanw void
    120  1.6.2.7  nathanw arm32_vector_init(vaddr_t va, int which)
    121  1.6.2.7  nathanw {
    122  1.6.2.7  nathanw 	extern unsigned int page0[], page0_data[];
    123  1.6.2.7  nathanw 	unsigned int *vectors = (int *) va;
    124  1.6.2.7  nathanw 	unsigned int *vectors_data = vectors + (page0_data - page0);
    125  1.6.2.7  nathanw 	int vec;
    126  1.6.2.7  nathanw 
    127  1.6.2.7  nathanw 	/*
    128  1.6.2.7  nathanw 	 * Loop through the vectors we're taking over, and copy the
    129  1.6.2.7  nathanw 	 * vector's insn and data word.
    130  1.6.2.7  nathanw 	 */
    131  1.6.2.7  nathanw 	for (vec = 0; vec < ARM_NVEC; vec++) {
    132  1.6.2.7  nathanw 		if ((which & (1 << vec)) == 0) {
    133  1.6.2.7  nathanw 			/* Don't want to take over this vector. */
    134  1.6.2.7  nathanw 			continue;
    135  1.6.2.7  nathanw 		}
    136  1.6.2.7  nathanw 		vectors[vec] = page0[vec];
    137  1.6.2.7  nathanw 		vectors_data[vec] = page0_data[vec];
    138  1.6.2.7  nathanw 	}
    139  1.6.2.7  nathanw 
    140  1.6.2.7  nathanw 	/* Now sync the vectors. */
    141  1.6.2.7  nathanw 	cpu_icache_sync_range(va, (ARM_NVEC * 2) * sizeof(u_int));
    142  1.6.2.7  nathanw 
    143  1.6.2.7  nathanw 	vector_page = va;
    144  1.6.2.7  nathanw }
    145  1.6.2.7  nathanw 
    146  1.6.2.7  nathanw /*
    147  1.6.2.2  thorpej  * Debug function just to park the CPU
    148  1.6.2.2  thorpej  */
    149  1.6.2.2  thorpej 
    150  1.6.2.2  thorpej void
    151  1.6.2.2  thorpej halt()
    152  1.6.2.2  thorpej {
    153  1.6.2.2  thorpej 	while (1)
    154  1.6.2.2  thorpej 		cpu_sleep(0);
    155  1.6.2.2  thorpej }
    156  1.6.2.2  thorpej 
    157  1.6.2.2  thorpej 
    158  1.6.2.2  thorpej /* Sync the discs and unmount the filesystems */
    159  1.6.2.2  thorpej 
    160  1.6.2.2  thorpej void
    161  1.6.2.2  thorpej bootsync(void)
    162  1.6.2.2  thorpej {
    163  1.6.2.2  thorpej 	static int bootsyncdone = 0;
    164  1.6.2.2  thorpej 
    165  1.6.2.2  thorpej 	if (bootsyncdone) return;
    166  1.6.2.2  thorpej 
    167  1.6.2.2  thorpej 	bootsyncdone = 1;
    168  1.6.2.2  thorpej 
    169  1.6.2.2  thorpej 	/* Make sure we can still manage to do things */
    170  1.6.2.2  thorpej 	if (GetCPSR() & I32_bit) {
    171  1.6.2.2  thorpej 		/*
    172  1.6.2.2  thorpej 		 * If we get here then boot has been called without RB_NOSYNC
    173  1.6.2.2  thorpej 		 * and interrupts were disabled. This means the boot() call
    174  1.6.2.2  thorpej 		 * did not come from a user process e.g. shutdown, but must
    175  1.6.2.2  thorpej 		 * have come from somewhere in the kernel.
    176  1.6.2.2  thorpej 		 */
    177  1.6.2.2  thorpej 		IRQenable;
    178  1.6.2.2  thorpej 		printf("Warning IRQ's disabled during boot()\n");
    179  1.6.2.2  thorpej 	}
    180  1.6.2.2  thorpej 
    181  1.6.2.2  thorpej 	vfs_shutdown();
    182  1.6.2.2  thorpej }
    183  1.6.2.2  thorpej 
    184  1.6.2.2  thorpej /*
    185  1.6.2.2  thorpej  * void cpu_startup(void)
    186  1.6.2.2  thorpej  *
    187  1.6.2.2  thorpej  * Machine dependant startup code.
    188  1.6.2.2  thorpej  *
    189  1.6.2.2  thorpej  */
    190  1.6.2.2  thorpej void
    191  1.6.2.2  thorpej cpu_startup()
    192  1.6.2.2  thorpej {
    193  1.6.2.2  thorpej 	int loop;
    194  1.6.2.2  thorpej 	paddr_t minaddr;
    195  1.6.2.2  thorpej 	paddr_t maxaddr;
    196  1.6.2.2  thorpej 	caddr_t sysbase;
    197  1.6.2.2  thorpej 	caddr_t size;
    198  1.6.2.2  thorpej 	vsize_t bufsize;
    199  1.6.2.2  thorpej 	int base, residual;
    200  1.6.2.2  thorpej 	char pbuf[9];
    201  1.6.2.2  thorpej 
    202  1.6.2.2  thorpej 	proc0paddr = (struct user *)kernelstack.pv_va;
    203  1.6.2.2  thorpej 	lwp0.l_addr = proc0paddr;
    204  1.6.2.2  thorpej 
    205  1.6.2.2  thorpej 	/* Set the cpu control register */
    206  1.6.2.2  thorpej 	cpu_setup(boot_args);
    207  1.6.2.2  thorpej 
    208  1.6.2.2  thorpej 	/* All domains MUST be clients, permissions are VERY important */
    209  1.6.2.2  thorpej 	cpu_domains(DOMAIN_CLIENT);
    210  1.6.2.2  thorpej 
    211  1.6.2.2  thorpej 	/* Lock down zero page */
    212  1.6.2.7  nathanw 	vector_page_setprot(VM_PROT_READ);
    213  1.6.2.2  thorpej 
    214  1.6.2.2  thorpej 	/*
    215  1.6.2.2  thorpej 	 * Give pmap a chance to set up a few more things now the vm
    216  1.6.2.2  thorpej 	 * is initialised
    217  1.6.2.2  thorpej 	 */
    218  1.6.2.2  thorpej 	pmap_postinit();
    219  1.6.2.2  thorpej 
    220  1.6.2.2  thorpej 	/*
    221  1.6.2.2  thorpej 	 * Initialize error message buffer (at end of core).
    222  1.6.2.2  thorpej 	 */
    223  1.6.2.2  thorpej 
    224  1.6.2.2  thorpej 	/* msgbufphys was setup during the secondary boot strap */
    225  1.6.2.2  thorpej 	for (loop = 0; loop < btoc(MSGBUFSIZE); ++loop)
    226  1.6.2.2  thorpej 		pmap_kenter_pa((vaddr_t)msgbufaddr + loop * NBPG,
    227  1.6.2.2  thorpej 		    msgbufphys + loop * NBPG, VM_PROT_READ|VM_PROT_WRITE);
    228  1.6.2.2  thorpej 	pmap_update(pmap_kernel());
    229  1.6.2.2  thorpej 	initmsgbuf(msgbufaddr, round_page(MSGBUFSIZE));
    230  1.6.2.2  thorpej 
    231  1.6.2.2  thorpej 	/*
    232  1.6.2.2  thorpej 	 * Identify ourselves for the msgbuf (everything printed earlier will
    233  1.6.2.2  thorpej 	 * not be buffered).
    234  1.6.2.2  thorpej 	 */
    235  1.6.2.2  thorpej 	printf(version);
    236  1.6.2.2  thorpej 
    237  1.6.2.6  nathanw 	format_bytes(pbuf, sizeof(pbuf), arm_ptob(physmem));
    238  1.6.2.2  thorpej 	printf("total memory = %s\n", pbuf);
    239  1.6.2.2  thorpej 
    240  1.6.2.2  thorpej 	/*
    241  1.6.2.2  thorpej 	 * Find out how much space we need, allocate it,
    242  1.6.2.2  thorpej 	 * and then give everything true virtual addresses.
    243  1.6.2.2  thorpej 	 */
    244  1.6.2.2  thorpej 	size = allocsys(NULL, NULL);
    245  1.6.2.2  thorpej 	sysbase = (caddr_t)uvm_km_zalloc(kernel_map, round_page((vaddr_t)size));
    246  1.6.2.2  thorpej 	if (sysbase == 0)
    247  1.6.2.2  thorpej 		panic(
    248  1.6.2.2  thorpej 		    "cpu_startup: no room for system tables; %d bytes required",
    249  1.6.2.2  thorpej 		    (u_int)size);
    250  1.6.2.2  thorpej 	if ((caddr_t)((allocsys(sysbase, NULL) - sysbase)) != size)
    251  1.6.2.2  thorpej 		panic("cpu_startup: system table size inconsistency");
    252  1.6.2.2  thorpej 
    253  1.6.2.2  thorpej    	/*
    254  1.6.2.2  thorpej 	 * Now allocate buffers proper.  They are different than the above
    255  1.6.2.2  thorpej 	 * in that they usually occupy more virtual memory than physical.
    256  1.6.2.2  thorpej 	 */
    257  1.6.2.2  thorpej 	bufsize = MAXBSIZE * nbuf;
    258  1.6.2.2  thorpej 	if (uvm_map(kernel_map, (vaddr_t *)&buffers, round_page(bufsize),
    259  1.6.2.2  thorpej 	    NULL, UVM_UNKNOWN_OFFSET, 0,
    260  1.6.2.2  thorpej 	    UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
    261  1.6.2.2  thorpej 	    UVM_ADV_NORMAL, 0)) != 0)
    262  1.6.2.2  thorpej 		panic("cpu_startup: cannot allocate UVM space for buffers");
    263  1.6.2.2  thorpej 	minaddr = (vaddr_t)buffers;
    264  1.6.2.2  thorpej 	if ((bufpages / nbuf) >= btoc(MAXBSIZE)) {
    265  1.6.2.2  thorpej 		/* don't want to alloc more physical mem than needed */
    266  1.6.2.2  thorpej 		bufpages = btoc(MAXBSIZE) * nbuf;
    267  1.6.2.2  thorpej 	}
    268  1.6.2.2  thorpej 
    269  1.6.2.2  thorpej 	base = bufpages / nbuf;
    270  1.6.2.2  thorpej 	residual = bufpages % nbuf;
    271  1.6.2.2  thorpej 	for (loop = 0; loop < nbuf; ++loop) {
    272  1.6.2.2  thorpej 		vsize_t curbufsize;
    273  1.6.2.2  thorpej 		vaddr_t curbuf;
    274  1.6.2.2  thorpej 		struct vm_page *pg;
    275  1.6.2.2  thorpej 
    276  1.6.2.2  thorpej 		/*
    277  1.6.2.2  thorpej 		 * Each buffer has MAXBSIZE bytes of VM space allocated.  Of
    278  1.6.2.2  thorpej 		 * that MAXBSIZE space, we allocate and map (base+1) pages
    279  1.6.2.2  thorpej 		 * for the first "residual" buffers, and then we allocate
    280  1.6.2.2  thorpej 		 * "base" pages for the rest.
    281  1.6.2.2  thorpej 		 */
    282  1.6.2.2  thorpej 		curbuf = (vaddr_t) buffers + (loop * MAXBSIZE);
    283  1.6.2.2  thorpej 		curbufsize = NBPG * ((loop < residual) ? (base+1) : base);
    284  1.6.2.2  thorpej 
    285  1.6.2.2  thorpej 		while (curbufsize) {
    286  1.6.2.2  thorpej 			pg = uvm_pagealloc(NULL, 0, NULL, 0);
    287  1.6.2.2  thorpej 			if (pg == NULL)
    288  1.6.2.2  thorpej 				panic("cpu_startup: not enough memory for buffer cache");
    289  1.6.2.2  thorpej 			pmap_kenter_pa(curbuf, VM_PAGE_TO_PHYS(pg),
    290  1.6.2.2  thorpej 				VM_PROT_READ|VM_PROT_WRITE);
    291  1.6.2.2  thorpej 			curbuf += PAGE_SIZE;
    292  1.6.2.2  thorpej 			curbufsize -= PAGE_SIZE;
    293  1.6.2.2  thorpej 		}
    294  1.6.2.2  thorpej 	}
    295  1.6.2.2  thorpej 	pmap_update(pmap_kernel());
    296  1.6.2.2  thorpej 
    297  1.6.2.2  thorpej 	/*
    298  1.6.2.2  thorpej 	 * Allocate a submap for exec arguments.  This map effectively
    299  1.6.2.2  thorpej 	 * limits the number of processes exec'ing at any time.
    300  1.6.2.2  thorpej 	 */
    301  1.6.2.2  thorpej 	exec_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
    302  1.6.2.2  thorpej 				   16*NCARGS, VM_MAP_PAGEABLE, FALSE, NULL);
    303  1.6.2.2  thorpej 
    304  1.6.2.2  thorpej 	/*
    305  1.6.2.2  thorpej 	 * Allocate a submap for physio
    306  1.6.2.2  thorpej 	 */
    307  1.6.2.2  thorpej 	phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
    308  1.6.2.2  thorpej 				   VM_PHYS_SIZE, 0, FALSE, NULL);
    309  1.6.2.2  thorpej 
    310  1.6.2.2  thorpej 	/*
    311  1.6.2.2  thorpej 	 * Finally, allocate mbuf cluster submap.
    312  1.6.2.2  thorpej 	 */
    313  1.6.2.2  thorpej 	mb_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
    314  1.6.2.2  thorpej 				 nmbclusters * mclbytes, VM_MAP_INTRSAFE,
    315  1.6.2.2  thorpej 				 FALSE, NULL);
    316  1.6.2.2  thorpej 
    317  1.6.2.2  thorpej 	format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
    318  1.6.2.2  thorpej 	printf("avail memory = %s\n", pbuf);
    319  1.6.2.2  thorpej 	format_bytes(pbuf, sizeof(pbuf), bufpages * NBPG);
    320  1.6.2.2  thorpej 	printf("using %d buffers containing %s of memory\n", nbuf, pbuf);
    321  1.6.2.2  thorpej 
    322  1.6.2.2  thorpej 	/*
    323  1.6.2.2  thorpej 	 * Set up buffers, so they can be used to read disk labels.
    324  1.6.2.2  thorpej 	 */
    325  1.6.2.2  thorpej 	bufinit();
    326  1.6.2.2  thorpej 
    327  1.6.2.2  thorpej 	curpcb = &lwp0.l_addr->u_pcb;
    328  1.6.2.2  thorpej 	curpcb->pcb_flags = 0;
    329  1.6.2.2  thorpej 	curpcb->pcb_un.un_32.pcb32_und_sp = (u_int)lwp0.l_addr +
    330  1.6.2.2  thorpej 	    USPACE_UNDEF_STACK_TOP;
    331  1.6.2.2  thorpej 	curpcb->pcb_un.un_32.pcb32_sp = (u_int)lwp0.l_addr +
    332  1.6.2.2  thorpej 	    USPACE_SVC_STACK_TOP;
    333  1.6.2.2  thorpej 	(void) pmap_extract(pmap_kernel(), (vaddr_t)(pmap_kernel())->pm_pdir,
    334  1.6.2.2  thorpej 	    (paddr_t *)&curpcb->pcb_pagedir);
    335  1.6.2.2  thorpej 
    336  1.6.2.2  thorpej         curpcb->pcb_tf = (struct trapframe *)curpcb->pcb_un.un_32.pcb32_sp - 1;
    337  1.6.2.2  thorpej }
    338  1.6.2.2  thorpej 
    339  1.6.2.2  thorpej /*
    340  1.6.2.2  thorpej  * machine dependent system variables.
    341  1.6.2.2  thorpej  */
    342  1.6.2.2  thorpej 
    343  1.6.2.2  thorpej int
    344  1.6.2.2  thorpej cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
    345  1.6.2.2  thorpej 	int *name;
    346  1.6.2.2  thorpej 	u_int namelen;
    347  1.6.2.2  thorpej 	void *oldp;
    348  1.6.2.2  thorpej 	size_t *oldlenp;
    349  1.6.2.2  thorpej 	void *newp;
    350  1.6.2.2  thorpej 	size_t newlen;
    351  1.6.2.2  thorpej 	struct proc *p;
    352  1.6.2.2  thorpej {
    353  1.6.2.2  thorpej 	/* all sysctl names at this level are terminal */
    354  1.6.2.2  thorpej 	if (namelen != 1)
    355  1.6.2.2  thorpej 		return (ENOTDIR);		/* overloaded */
    356  1.6.2.2  thorpej 
    357  1.6.2.2  thorpej 	switch (name[0]) {
    358  1.6.2.2  thorpej 	case CPU_DEBUG:
    359  1.6.2.2  thorpej 		return(sysctl_int(oldp, oldlenp, newp, newlen, &kernel_debug));
    360  1.6.2.2  thorpej 
    361  1.6.2.2  thorpej 	case CPU_BOOTED_DEVICE:
    362  1.6.2.2  thorpej 		if (booted_device != NULL)
    363  1.6.2.2  thorpej 			return (sysctl_rdstring(oldp, oldlenp, newp,
    364  1.6.2.2  thorpej 			    booted_device->dv_xname));
    365  1.6.2.2  thorpej 		return (EOPNOTSUPP);
    366  1.6.2.2  thorpej 
    367  1.6.2.2  thorpej 	case CPU_CONSDEV: {
    368  1.6.2.2  thorpej 		dev_t consdev;
    369  1.6.2.2  thorpej 		if (cn_tab != NULL)
    370  1.6.2.2  thorpej 			consdev = cn_tab->cn_dev;
    371  1.6.2.2  thorpej 		else
    372  1.6.2.2  thorpej 			consdev = NODEV;
    373  1.6.2.2  thorpej 		return (sysctl_rdstruct(oldp, oldlenp, newp, &consdev,
    374  1.6.2.2  thorpej 			sizeof consdev));
    375  1.6.2.2  thorpej 	}
    376  1.6.2.2  thorpej 	case CPU_BOOTED_KERNEL: {
    377  1.6.2.2  thorpej 		if (booted_kernel != NULL && booted_kernel[0] != '\0')
    378  1.6.2.2  thorpej 			return sysctl_rdstring(oldp, oldlenp, newp,
    379  1.6.2.2  thorpej 			    booted_kernel);
    380  1.6.2.2  thorpej 		return (EOPNOTSUPP);
    381  1.6.2.2  thorpej 	}
    382  1.6.2.2  thorpej 
    383  1.6.2.2  thorpej 	default:
    384  1.6.2.2  thorpej 		return (EOPNOTSUPP);
    385  1.6.2.2  thorpej 	}
    386  1.6.2.2  thorpej 	/* NOTREACHED */
    387  1.6.2.2  thorpej }
    388  1.6.2.2  thorpej 
    389  1.6.2.2  thorpej void
    390  1.6.2.2  thorpej parse_mi_bootargs(args)
    391  1.6.2.2  thorpej 	char *args;
    392  1.6.2.2  thorpej {
    393  1.6.2.2  thorpej 	int integer;
    394  1.6.2.2  thorpej 
    395  1.6.2.2  thorpej 	if (get_bootconf_option(args, "single", BOOTOPT_TYPE_BOOLEAN, &integer)
    396  1.6.2.2  thorpej 	    || get_bootconf_option(args, "-s", BOOTOPT_TYPE_BOOLEAN, &integer))
    397  1.6.2.2  thorpej 		if (integer)
    398  1.6.2.2  thorpej 			boothowto |= RB_SINGLE;
    399  1.6.2.2  thorpej 	if (get_bootconf_option(args, "kdb", BOOTOPT_TYPE_BOOLEAN, &integer)
    400  1.6.2.2  thorpej 	    || get_bootconf_option(args, "-k", BOOTOPT_TYPE_BOOLEAN, &integer))
    401  1.6.2.2  thorpej 		if (integer)
    402  1.6.2.2  thorpej 			boothowto |= RB_KDB;
    403  1.6.2.2  thorpej 	if (get_bootconf_option(args, "ask", BOOTOPT_TYPE_BOOLEAN, &integer)
    404  1.6.2.2  thorpej 	    || get_bootconf_option(args, "-a", BOOTOPT_TYPE_BOOLEAN, &integer))
    405  1.6.2.2  thorpej 		if (integer)
    406  1.6.2.2  thorpej 			boothowto |= RB_ASKNAME;
    407  1.6.2.2  thorpej 
    408  1.6.2.2  thorpej #ifdef PMAP_DEBUG
    409  1.6.2.2  thorpej 	if (get_bootconf_option(args, "pmapdebug", BOOTOPT_TYPE_INT, &integer)) {
    410  1.6.2.2  thorpej 		pmap_debug_level = integer;
    411  1.6.2.2  thorpej 		pmap_debug(pmap_debug_level);
    412  1.6.2.2  thorpej 	}
    413  1.6.2.2  thorpej #endif	/* PMAP_DEBUG */
    414  1.6.2.2  thorpej 
    415  1.6.2.2  thorpej /*	if (get_bootconf_option(args, "nbuf", BOOTOPT_TYPE_INT, &integer))
    416  1.6.2.2  thorpej 		bufpages = integer;*/
    417  1.6.2.2  thorpej 
    418  1.6.2.2  thorpej #ifndef PMAP_STATIC_L1S
    419  1.6.2.2  thorpej 	if (get_bootconf_option(args, "maxproc", BOOTOPT_TYPE_INT, &integer)) {
    420  1.6.2.2  thorpej 		max_processes = integer;
    421  1.6.2.2  thorpej 		if (max_processes < 16)
    422  1.6.2.2  thorpej 			max_processes = 16;
    423  1.6.2.2  thorpej 		/* Limit is PDSIZE * (max_processes + 1) <= 4MB */
    424  1.6.2.2  thorpej 		if (max_processes > 255)
    425  1.6.2.2  thorpej 			max_processes = 255;
    426  1.6.2.2  thorpej 	}
    427  1.6.2.2  thorpej #endif	/* !PMAP_STATUC_L1S */
    428  1.6.2.7  nathanw #if NMD > 0 && defined(MEMORY_DISK_HOOKS) && !defined(MEMORY_DISK_ROOT_SIZE)
    429  1.6.2.2  thorpej 	if (get_bootconf_option(args, "memorydisc", BOOTOPT_TYPE_INT, &integer)
    430  1.6.2.2  thorpej 	    || get_bootconf_option(args, "memorydisk", BOOTOPT_TYPE_INT, &integer)) {
    431  1.6.2.8  nathanw 		md_root_size = integer;
    432  1.6.2.8  nathanw 		md_root_size *= 1024;
    433  1.6.2.8  nathanw 		if (md_root_size < 32*1024)
    434  1.6.2.8  nathanw 			md_root_size = 32*1024;
    435  1.6.2.8  nathanw 		if (md_root_size > 2048*1024)
    436  1.6.2.8  nathanw 			md_root_size = 2048*1024;
    437  1.6.2.2  thorpej 	}
    438  1.6.2.7  nathanw #endif	/* NMD && MEMORY_DISK_HOOKS && !MEMORY_DISK_ROOT_SIZE */
    439  1.6.2.2  thorpej 
    440  1.6.2.2  thorpej 	if (get_bootconf_option(args, "quiet", BOOTOPT_TYPE_BOOLEAN, &integer)
    441  1.6.2.2  thorpej 	    || get_bootconf_option(args, "-q", BOOTOPT_TYPE_BOOLEAN, &integer))
    442  1.6.2.2  thorpej 		if (integer)
    443  1.6.2.2  thorpej 			boothowto |= AB_QUIET;
    444  1.6.2.2  thorpej 	if (get_bootconf_option(args, "verbose", BOOTOPT_TYPE_BOOLEAN, &integer)
    445  1.6.2.2  thorpej 	    || get_bootconf_option(args, "-v", BOOTOPT_TYPE_BOOLEAN, &integer))
    446  1.6.2.2  thorpej 		if (integer)
    447  1.6.2.2  thorpej 			boothowto |= AB_VERBOSE;
    448  1.6.2.2  thorpej }
    449