Home | History | Annotate | Line # | Download | only in arm32
arm32_machdep.c revision 1.6.2.10
      1  1.6.2.10  thorpej /*	$NetBSD: arm32_machdep.c,v 1.6.2.10 2002/08/27 06:03:15 thorpej 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 	paddr_t minaddr;
    194   1.6.2.2  thorpej 	paddr_t maxaddr;
    195   1.6.2.2  thorpej 	caddr_t sysbase;
    196   1.6.2.2  thorpej 	caddr_t size;
    197   1.6.2.2  thorpej 	vsize_t bufsize;
    198  1.6.2.10  thorpej 	u_int loop, base, residual;
    199   1.6.2.2  thorpej 	char pbuf[9];
    200   1.6.2.2  thorpej 
    201   1.6.2.2  thorpej 	proc0paddr = (struct user *)kernelstack.pv_va;
    202   1.6.2.2  thorpej 	lwp0.l_addr = proc0paddr;
    203   1.6.2.2  thorpej 
    204   1.6.2.2  thorpej 	/* Set the cpu control register */
    205   1.6.2.2  thorpej 	cpu_setup(boot_args);
    206   1.6.2.2  thorpej 
    207   1.6.2.2  thorpej 	/* All domains MUST be clients, permissions are VERY important */
    208   1.6.2.2  thorpej 	cpu_domains(DOMAIN_CLIENT);
    209   1.6.2.2  thorpej 
    210   1.6.2.2  thorpej 	/* Lock down zero page */
    211   1.6.2.7  nathanw 	vector_page_setprot(VM_PROT_READ);
    212   1.6.2.2  thorpej 
    213   1.6.2.2  thorpej 	/*
    214   1.6.2.2  thorpej 	 * Give pmap a chance to set up a few more things now the vm
    215   1.6.2.2  thorpej 	 * is initialised
    216   1.6.2.2  thorpej 	 */
    217   1.6.2.2  thorpej 	pmap_postinit();
    218   1.6.2.2  thorpej 
    219   1.6.2.2  thorpej 	/*
    220   1.6.2.2  thorpej 	 * Initialize error message buffer (at end of core).
    221   1.6.2.2  thorpej 	 */
    222   1.6.2.2  thorpej 
    223   1.6.2.2  thorpej 	/* msgbufphys was setup during the secondary boot strap */
    224   1.6.2.2  thorpej 	for (loop = 0; loop < btoc(MSGBUFSIZE); ++loop)
    225   1.6.2.2  thorpej 		pmap_kenter_pa((vaddr_t)msgbufaddr + loop * NBPG,
    226   1.6.2.2  thorpej 		    msgbufphys + loop * NBPG, VM_PROT_READ|VM_PROT_WRITE);
    227   1.6.2.2  thorpej 	pmap_update(pmap_kernel());
    228   1.6.2.2  thorpej 	initmsgbuf(msgbufaddr, round_page(MSGBUFSIZE));
    229   1.6.2.2  thorpej 
    230   1.6.2.2  thorpej 	/*
    231   1.6.2.2  thorpej 	 * Identify ourselves for the msgbuf (everything printed earlier will
    232   1.6.2.2  thorpej 	 * not be buffered).
    233   1.6.2.2  thorpej 	 */
    234   1.6.2.2  thorpej 	printf(version);
    235   1.6.2.2  thorpej 
    236   1.6.2.6  nathanw 	format_bytes(pbuf, sizeof(pbuf), arm_ptob(physmem));
    237   1.6.2.2  thorpej 	printf("total memory = %s\n", pbuf);
    238   1.6.2.2  thorpej 
    239   1.6.2.2  thorpej 	/*
    240   1.6.2.2  thorpej 	 * Find out how much space we need, allocate it,
    241   1.6.2.2  thorpej 	 * and then give everything true virtual addresses.
    242   1.6.2.2  thorpej 	 */
    243   1.6.2.2  thorpej 	size = allocsys(NULL, NULL);
    244   1.6.2.2  thorpej 	sysbase = (caddr_t)uvm_km_zalloc(kernel_map, round_page((vaddr_t)size));
    245   1.6.2.2  thorpej 	if (sysbase == 0)
    246   1.6.2.2  thorpej 		panic(
    247   1.6.2.2  thorpej 		    "cpu_startup: no room for system tables; %d bytes required",
    248   1.6.2.2  thorpej 		    (u_int)size);
    249   1.6.2.2  thorpej 	if ((caddr_t)((allocsys(sysbase, NULL) - sysbase)) != size)
    250   1.6.2.2  thorpej 		panic("cpu_startup: system table size inconsistency");
    251   1.6.2.2  thorpej 
    252   1.6.2.2  thorpej    	/*
    253   1.6.2.2  thorpej 	 * Now allocate buffers proper.  They are different than the above
    254   1.6.2.2  thorpej 	 * in that they usually occupy more virtual memory than physical.
    255   1.6.2.2  thorpej 	 */
    256   1.6.2.2  thorpej 	bufsize = MAXBSIZE * nbuf;
    257   1.6.2.2  thorpej 	if (uvm_map(kernel_map, (vaddr_t *)&buffers, round_page(bufsize),
    258   1.6.2.2  thorpej 	    NULL, UVM_UNKNOWN_OFFSET, 0,
    259   1.6.2.2  thorpej 	    UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
    260   1.6.2.2  thorpej 	    UVM_ADV_NORMAL, 0)) != 0)
    261   1.6.2.2  thorpej 		panic("cpu_startup: cannot allocate UVM space for buffers");
    262   1.6.2.2  thorpej 	minaddr = (vaddr_t)buffers;
    263   1.6.2.2  thorpej 	if ((bufpages / nbuf) >= btoc(MAXBSIZE)) {
    264   1.6.2.2  thorpej 		/* don't want to alloc more physical mem than needed */
    265   1.6.2.2  thorpej 		bufpages = btoc(MAXBSIZE) * nbuf;
    266   1.6.2.2  thorpej 	}
    267   1.6.2.2  thorpej 
    268   1.6.2.2  thorpej 	base = bufpages / nbuf;
    269   1.6.2.2  thorpej 	residual = bufpages % nbuf;
    270   1.6.2.2  thorpej 	for (loop = 0; loop < nbuf; ++loop) {
    271   1.6.2.2  thorpej 		vsize_t curbufsize;
    272   1.6.2.2  thorpej 		vaddr_t curbuf;
    273   1.6.2.2  thorpej 		struct vm_page *pg;
    274   1.6.2.2  thorpej 
    275   1.6.2.2  thorpej 		/*
    276   1.6.2.2  thorpej 		 * Each buffer has MAXBSIZE bytes of VM space allocated.  Of
    277   1.6.2.2  thorpej 		 * that MAXBSIZE space, we allocate and map (base+1) pages
    278   1.6.2.2  thorpej 		 * for the first "residual" buffers, and then we allocate
    279   1.6.2.2  thorpej 		 * "base" pages for the rest.
    280   1.6.2.2  thorpej 		 */
    281   1.6.2.2  thorpej 		curbuf = (vaddr_t) buffers + (loop * MAXBSIZE);
    282   1.6.2.2  thorpej 		curbufsize = NBPG * ((loop < residual) ? (base+1) : base);
    283   1.6.2.2  thorpej 
    284   1.6.2.2  thorpej 		while (curbufsize) {
    285   1.6.2.2  thorpej 			pg = uvm_pagealloc(NULL, 0, NULL, 0);
    286   1.6.2.2  thorpej 			if (pg == NULL)
    287   1.6.2.2  thorpej 				panic("cpu_startup: not enough memory for buffer cache");
    288   1.6.2.2  thorpej 			pmap_kenter_pa(curbuf, VM_PAGE_TO_PHYS(pg),
    289   1.6.2.2  thorpej 				VM_PROT_READ|VM_PROT_WRITE);
    290   1.6.2.2  thorpej 			curbuf += PAGE_SIZE;
    291   1.6.2.2  thorpej 			curbufsize -= PAGE_SIZE;
    292   1.6.2.2  thorpej 		}
    293   1.6.2.2  thorpej 	}
    294   1.6.2.2  thorpej 	pmap_update(pmap_kernel());
    295   1.6.2.2  thorpej 
    296   1.6.2.2  thorpej 	/*
    297   1.6.2.2  thorpej 	 * Allocate a submap for exec arguments.  This map effectively
    298   1.6.2.2  thorpej 	 * limits the number of processes exec'ing at any time.
    299   1.6.2.2  thorpej 	 */
    300   1.6.2.2  thorpej 	exec_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
    301   1.6.2.2  thorpej 				   16*NCARGS, VM_MAP_PAGEABLE, FALSE, NULL);
    302   1.6.2.2  thorpej 
    303   1.6.2.2  thorpej 	/*
    304   1.6.2.2  thorpej 	 * Allocate a submap for physio
    305   1.6.2.2  thorpej 	 */
    306   1.6.2.2  thorpej 	phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
    307   1.6.2.2  thorpej 				   VM_PHYS_SIZE, 0, FALSE, NULL);
    308   1.6.2.2  thorpej 
    309   1.6.2.2  thorpej 	/*
    310   1.6.2.2  thorpej 	 * Finally, allocate mbuf cluster submap.
    311   1.6.2.2  thorpej 	 */
    312   1.6.2.2  thorpej 	mb_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
    313   1.6.2.2  thorpej 				 nmbclusters * mclbytes, VM_MAP_INTRSAFE,
    314   1.6.2.2  thorpej 				 FALSE, NULL);
    315   1.6.2.2  thorpej 
    316   1.6.2.2  thorpej 	format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
    317   1.6.2.2  thorpej 	printf("avail memory = %s\n", pbuf);
    318   1.6.2.2  thorpej 	format_bytes(pbuf, sizeof(pbuf), bufpages * NBPG);
    319  1.6.2.10  thorpej 	printf("using %u buffers containing %s of memory\n", nbuf, pbuf);
    320   1.6.2.2  thorpej 
    321   1.6.2.2  thorpej 	/*
    322   1.6.2.2  thorpej 	 * Set up buffers, so they can be used to read disk labels.
    323   1.6.2.2  thorpej 	 */
    324   1.6.2.2  thorpej 	bufinit();
    325   1.6.2.2  thorpej 
    326   1.6.2.2  thorpej 	curpcb = &lwp0.l_addr->u_pcb;
    327   1.6.2.2  thorpej 	curpcb->pcb_flags = 0;
    328   1.6.2.2  thorpej 	curpcb->pcb_un.un_32.pcb32_und_sp = (u_int)lwp0.l_addr +
    329   1.6.2.2  thorpej 	    USPACE_UNDEF_STACK_TOP;
    330   1.6.2.2  thorpej 	curpcb->pcb_un.un_32.pcb32_sp = (u_int)lwp0.l_addr +
    331   1.6.2.2  thorpej 	    USPACE_SVC_STACK_TOP;
    332   1.6.2.2  thorpej 	(void) pmap_extract(pmap_kernel(), (vaddr_t)(pmap_kernel())->pm_pdir,
    333   1.6.2.2  thorpej 	    (paddr_t *)&curpcb->pcb_pagedir);
    334   1.6.2.2  thorpej 
    335   1.6.2.2  thorpej         curpcb->pcb_tf = (struct trapframe *)curpcb->pcb_un.un_32.pcb32_sp - 1;
    336   1.6.2.2  thorpej }
    337   1.6.2.2  thorpej 
    338   1.6.2.2  thorpej /*
    339   1.6.2.2  thorpej  * machine dependent system variables.
    340   1.6.2.2  thorpej  */
    341   1.6.2.2  thorpej 
    342   1.6.2.2  thorpej int
    343   1.6.2.2  thorpej cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
    344   1.6.2.2  thorpej 	int *name;
    345   1.6.2.2  thorpej 	u_int namelen;
    346   1.6.2.2  thorpej 	void *oldp;
    347   1.6.2.2  thorpej 	size_t *oldlenp;
    348   1.6.2.2  thorpej 	void *newp;
    349   1.6.2.2  thorpej 	size_t newlen;
    350   1.6.2.2  thorpej 	struct proc *p;
    351   1.6.2.2  thorpej {
    352   1.6.2.2  thorpej 	/* all sysctl names at this level are terminal */
    353   1.6.2.2  thorpej 	if (namelen != 1)
    354   1.6.2.2  thorpej 		return (ENOTDIR);		/* overloaded */
    355   1.6.2.2  thorpej 
    356   1.6.2.2  thorpej 	switch (name[0]) {
    357   1.6.2.2  thorpej 	case CPU_DEBUG:
    358   1.6.2.2  thorpej 		return(sysctl_int(oldp, oldlenp, newp, newlen, &kernel_debug));
    359   1.6.2.2  thorpej 
    360   1.6.2.2  thorpej 	case CPU_BOOTED_DEVICE:
    361   1.6.2.2  thorpej 		if (booted_device != NULL)
    362   1.6.2.2  thorpej 			return (sysctl_rdstring(oldp, oldlenp, newp,
    363   1.6.2.2  thorpej 			    booted_device->dv_xname));
    364   1.6.2.2  thorpej 		return (EOPNOTSUPP);
    365   1.6.2.2  thorpej 
    366   1.6.2.2  thorpej 	case CPU_CONSDEV: {
    367   1.6.2.2  thorpej 		dev_t consdev;
    368   1.6.2.2  thorpej 		if (cn_tab != NULL)
    369   1.6.2.2  thorpej 			consdev = cn_tab->cn_dev;
    370   1.6.2.2  thorpej 		else
    371   1.6.2.2  thorpej 			consdev = NODEV;
    372   1.6.2.2  thorpej 		return (sysctl_rdstruct(oldp, oldlenp, newp, &consdev,
    373   1.6.2.2  thorpej 			sizeof consdev));
    374   1.6.2.2  thorpej 	}
    375   1.6.2.2  thorpej 	case CPU_BOOTED_KERNEL: {
    376   1.6.2.2  thorpej 		if (booted_kernel != NULL && booted_kernel[0] != '\0')
    377   1.6.2.2  thorpej 			return sysctl_rdstring(oldp, oldlenp, newp,
    378   1.6.2.2  thorpej 			    booted_kernel);
    379   1.6.2.2  thorpej 		return (EOPNOTSUPP);
    380   1.6.2.2  thorpej 	}
    381   1.6.2.9  thorpej 	case CPU_POWERSAVE: {
    382   1.6.2.9  thorpej 		int error, newval;
    383   1.6.2.9  thorpej 
    384   1.6.2.9  thorpej 		newval = cpu_do_powersave;
    385   1.6.2.9  thorpej 
    386   1.6.2.9  thorpej 		if (cpufuncs.cf_sleep == (void *) cpufunc_nullop)
    387   1.6.2.9  thorpej 			error = sysctl_rdint(oldp, oldlenp, newp, newval);
    388   1.6.2.9  thorpej 		else
    389   1.6.2.9  thorpej 			error = sysctl_int(oldp, oldlenp, newp, newlen,
    390   1.6.2.9  thorpej 			    &newval);
    391   1.6.2.9  thorpej 		if (error || newval == cpu_do_powersave)
    392   1.6.2.9  thorpej 			return (error);
    393   1.6.2.9  thorpej 
    394   1.6.2.9  thorpej 		if (newval < 0 || newval > 1)
    395   1.6.2.9  thorpej 			return (EINVAL);
    396   1.6.2.9  thorpej 
    397   1.6.2.9  thorpej 		cpu_do_powersave = newval;
    398   1.6.2.9  thorpej 		return (0);
    399   1.6.2.9  thorpej 	}
    400   1.6.2.2  thorpej 
    401   1.6.2.2  thorpej 	default:
    402   1.6.2.2  thorpej 		return (EOPNOTSUPP);
    403   1.6.2.2  thorpej 	}
    404   1.6.2.2  thorpej 	/* NOTREACHED */
    405   1.6.2.2  thorpej }
    406   1.6.2.2  thorpej 
    407   1.6.2.2  thorpej void
    408   1.6.2.2  thorpej parse_mi_bootargs(args)
    409   1.6.2.2  thorpej 	char *args;
    410   1.6.2.2  thorpej {
    411   1.6.2.2  thorpej 	int integer;
    412   1.6.2.2  thorpej 
    413   1.6.2.2  thorpej 	if (get_bootconf_option(args, "single", BOOTOPT_TYPE_BOOLEAN, &integer)
    414   1.6.2.2  thorpej 	    || get_bootconf_option(args, "-s", BOOTOPT_TYPE_BOOLEAN, &integer))
    415   1.6.2.2  thorpej 		if (integer)
    416   1.6.2.2  thorpej 			boothowto |= RB_SINGLE;
    417   1.6.2.2  thorpej 	if (get_bootconf_option(args, "kdb", BOOTOPT_TYPE_BOOLEAN, &integer)
    418   1.6.2.2  thorpej 	    || get_bootconf_option(args, "-k", BOOTOPT_TYPE_BOOLEAN, &integer))
    419   1.6.2.2  thorpej 		if (integer)
    420   1.6.2.2  thorpej 			boothowto |= RB_KDB;
    421   1.6.2.2  thorpej 	if (get_bootconf_option(args, "ask", BOOTOPT_TYPE_BOOLEAN, &integer)
    422   1.6.2.2  thorpej 	    || get_bootconf_option(args, "-a", BOOTOPT_TYPE_BOOLEAN, &integer))
    423   1.6.2.2  thorpej 		if (integer)
    424   1.6.2.2  thorpej 			boothowto |= RB_ASKNAME;
    425   1.6.2.2  thorpej 
    426   1.6.2.2  thorpej #ifdef PMAP_DEBUG
    427   1.6.2.2  thorpej 	if (get_bootconf_option(args, "pmapdebug", BOOTOPT_TYPE_INT, &integer)) {
    428   1.6.2.2  thorpej 		pmap_debug_level = integer;
    429   1.6.2.2  thorpej 		pmap_debug(pmap_debug_level);
    430   1.6.2.2  thorpej 	}
    431   1.6.2.2  thorpej #endif	/* PMAP_DEBUG */
    432   1.6.2.2  thorpej 
    433   1.6.2.2  thorpej /*	if (get_bootconf_option(args, "nbuf", BOOTOPT_TYPE_INT, &integer))
    434   1.6.2.2  thorpej 		bufpages = integer;*/
    435   1.6.2.2  thorpej 
    436   1.6.2.2  thorpej #ifndef PMAP_STATIC_L1S
    437   1.6.2.2  thorpej 	if (get_bootconf_option(args, "maxproc", BOOTOPT_TYPE_INT, &integer)) {
    438   1.6.2.2  thorpej 		max_processes = integer;
    439   1.6.2.2  thorpej 		if (max_processes < 16)
    440   1.6.2.2  thorpej 			max_processes = 16;
    441   1.6.2.2  thorpej 		/* Limit is PDSIZE * (max_processes + 1) <= 4MB */
    442   1.6.2.2  thorpej 		if (max_processes > 255)
    443   1.6.2.2  thorpej 			max_processes = 255;
    444   1.6.2.2  thorpej 	}
    445   1.6.2.2  thorpej #endif	/* !PMAP_STATUC_L1S */
    446   1.6.2.7  nathanw #if NMD > 0 && defined(MEMORY_DISK_HOOKS) && !defined(MEMORY_DISK_ROOT_SIZE)
    447   1.6.2.2  thorpej 	if (get_bootconf_option(args, "memorydisc", BOOTOPT_TYPE_INT, &integer)
    448   1.6.2.2  thorpej 	    || get_bootconf_option(args, "memorydisk", BOOTOPT_TYPE_INT, &integer)) {
    449   1.6.2.8  nathanw 		md_root_size = integer;
    450   1.6.2.8  nathanw 		md_root_size *= 1024;
    451   1.6.2.8  nathanw 		if (md_root_size < 32*1024)
    452   1.6.2.8  nathanw 			md_root_size = 32*1024;
    453   1.6.2.8  nathanw 		if (md_root_size > 2048*1024)
    454   1.6.2.8  nathanw 			md_root_size = 2048*1024;
    455   1.6.2.2  thorpej 	}
    456   1.6.2.7  nathanw #endif	/* NMD && MEMORY_DISK_HOOKS && !MEMORY_DISK_ROOT_SIZE */
    457   1.6.2.2  thorpej 
    458   1.6.2.2  thorpej 	if (get_bootconf_option(args, "quiet", BOOTOPT_TYPE_BOOLEAN, &integer)
    459   1.6.2.2  thorpej 	    || get_bootconf_option(args, "-q", BOOTOPT_TYPE_BOOLEAN, &integer))
    460   1.6.2.2  thorpej 		if (integer)
    461   1.6.2.2  thorpej 			boothowto |= AB_QUIET;
    462   1.6.2.2  thorpej 	if (get_bootconf_option(args, "verbose", BOOTOPT_TYPE_BOOLEAN, &integer)
    463   1.6.2.2  thorpej 	    || get_bootconf_option(args, "-v", BOOTOPT_TYPE_BOOLEAN, &integer))
    464   1.6.2.2  thorpej 		if (integer)
    465   1.6.2.2  thorpej 			boothowto |= AB_VERBOSE;
    466   1.6.2.2  thorpej }
    467