2002-05-05 20:26:30 +04:00
|
|
|
/* $NetBSD: arm32_machdep.c,v 1.24 2002/05/05 16:26:30 jdolecek Exp $ */
|
1996-02-01 02:14:53 +03:00
|
|
|
|
|
|
|
/*
|
1998-09-05 05:23:04 +04:00
|
|
|
* Copyright (c) 1994-1998 Mark Brinicombe.
|
1996-02-01 02:14:53 +03:00
|
|
|
* Copyright (c) 1994 Brini.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software written for Brini by Mark Brinicombe
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
1998-09-05 05:23:04 +04:00
|
|
|
* This product includes software developed by Mark Brinicombe
|
|
|
|
* for the NetBSD Project.
|
1996-02-01 02:14:53 +03:00
|
|
|
* 4. The name of the company nor the name of the author may be used to
|
|
|
|
* endorse or promote products derived from this software without specific
|
|
|
|
* prior written permission.
|
|
|
|
*
|
1998-09-05 05:23:04 +04:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
1996-02-01 02:14:53 +03:00
|
|
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
1998-09-05 05:23:04 +04:00
|
|
|
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
1996-02-01 02:14:53 +03:00
|
|
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* Machine dependant functions for kernel setup
|
|
|
|
*
|
|
|
|
* Created : 17/09/94
|
2001-03-20 21:20:53 +03:00
|
|
|
* Updated : 18/04/01 updated for new wscons
|
1996-02-01 02:14:53 +03:00
|
|
|
*/
|
|
|
|
|
1999-02-07 12:34:58 +03:00
|
|
|
#include "opt_md.h"
|
1998-07-06 06:40:42 +04:00
|
|
|
#include "opt_pmap_debug.h"
|
1998-06-03 00:41:46 +04:00
|
|
|
|
1996-02-01 02:14:53 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/reboot.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/user.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/mount.h>
|
2001-06-11 15:56:57 +04:00
|
|
|
#include <sys/buf.h>
|
1998-01-22 01:55:19 +03:00
|
|
|
#include <sys/msgbuf.h>
|
2000-06-07 08:59:28 +04:00
|
|
|
#include <sys/device.h>
|
2000-06-29 12:44:03 +04:00
|
|
|
#include <uvm/uvm_extern.h>
|
1996-02-01 02:14:53 +03:00
|
|
|
#include <sys/sysctl.h>
|
|
|
|
|
1996-06-04 01:53:33 +04:00
|
|
|
#include <dev/cons.h>
|
|
|
|
|
2001-11-22 21:34:30 +03:00
|
|
|
#include <arm/arm32/katelib.h>
|
2002-01-06 01:41:46 +03:00
|
|
|
#include <arm/arm32/machdep.h>
|
1997-10-14 15:21:21 +04:00
|
|
|
#include <machine/bootconfig.h>
|
1996-02-01 02:14:53 +03:00
|
|
|
|
2001-04-19 11:19:48 +04:00
|
|
|
#include "opt_ipkdb.h"
|
|
|
|
#include "md.h"
|
2001-03-20 21:20:53 +03:00
|
|
|
|
2001-06-02 22:09:08 +04:00
|
|
|
struct vm_map *exec_map = NULL;
|
|
|
|
struct vm_map *mb_map = NULL;
|
|
|
|
struct vm_map *phys_map = NULL;
|
1998-06-03 00:41:46 +04:00
|
|
|
|
1997-10-14 15:21:21 +04:00
|
|
|
extern int physmem;
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1997-10-14 15:21:21 +04:00
|
|
|
#ifndef PMAP_STATIC_L1S
|
|
|
|
extern int max_processes;
|
|
|
|
#endif /* !PMAP_STATIC_L1S */
|
2002-04-02 09:30:34 +04:00
|
|
|
#if NMD > 0 && defined(MEMORY_DISK_HOOKS) && !defined(MEMORY_DISK_ROOT_SIZE)
|
2002-05-05 20:26:30 +04:00
|
|
|
extern size_t md_root_size; /* Memory disc size */
|
2002-04-02 09:30:34 +04:00
|
|
|
#endif /* NMD && MEMORY_DISK_HOOKS && !MEMORY_DISK_ROOT_SIZE */
|
1996-02-01 02:14:53 +03:00
|
|
|
|
|
|
|
pv_addr_t kernelstack;
|
|
|
|
|
|
|
|
/* the following is used externally (sysctl_hw) */
|
1997-06-09 03:59:57 +04:00
|
|
|
char machine[] = MACHINE; /* from <machine/param.h> */
|
|
|
|
char machine_arch[] = MACHINE_ARCH; /* from <machine/param.h> */
|
1996-02-01 02:14:53 +03:00
|
|
|
|
2000-05-27 01:19:19 +04:00
|
|
|
/* Our exported CPU info; we can have only one. */
|
|
|
|
struct cpu_info cpu_info_store;
|
|
|
|
|
1997-09-19 17:52:37 +04:00
|
|
|
caddr_t msgbufaddr;
|
2001-03-04 22:05:55 +03:00
|
|
|
extern paddr_t msgbufphys;
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1997-10-14 15:21:21 +04:00
|
|
|
int kernel_debug = 0;
|
1996-02-01 02:14:53 +03:00
|
|
|
|
|
|
|
struct user *proc0paddr;
|
|
|
|
|
2002-02-10 16:20:26 +03:00
|
|
|
/* exported variable to be filled in by the bootloaders */
|
2001-03-04 04:50:53 +03:00
|
|
|
char *booted_kernel;
|
|
|
|
|
2001-04-13 00:15:06 +04:00
|
|
|
|
1996-02-01 02:14:53 +03:00
|
|
|
/* Prototypes */
|
|
|
|
|
1997-10-14 15:21:21 +04:00
|
|
|
u_long strtoul __P((const char *s, char **ptr, int base));
|
|
|
|
void data_abort_handler __P((trapframe_t *frame));
|
|
|
|
void prefetch_abort_handler __P((trapframe_t *frame));
|
|
|
|
extern void configure __P((void));
|
1996-02-01 02:14:53 +03:00
|
|
|
|
2002-04-04 03:33:26 +04:00
|
|
|
/*
|
|
|
|
* arm32_vector_init:
|
|
|
|
*
|
|
|
|
* Initialize the vector page, and select whether or not to
|
|
|
|
* relocate the vectors.
|
|
|
|
*
|
|
|
|
* NOTE: We expect the vector page to be mapped at its expected
|
|
|
|
* destination.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
arm32_vector_init(vaddr_t va, int which)
|
|
|
|
{
|
|
|
|
extern unsigned int page0[], page0_data[];
|
|
|
|
unsigned int *vectors = (int *) va;
|
|
|
|
unsigned int *vectors_data = vectors + (page0_data - page0);
|
|
|
|
int vec;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Loop through the vectors we're taking over, and copy the
|
|
|
|
* vector's insn and data word.
|
|
|
|
*/
|
|
|
|
for (vec = 0; vec < ARM_NVEC; vec++) {
|
|
|
|
if ((which & (1 << vec)) == 0) {
|
|
|
|
/* Don't want to take over this vector. */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
vectors[vec] = page0[vec];
|
|
|
|
vectors_data[vec] = page0_data[vec];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now sync the vectors. */
|
|
|
|
cpu_icache_sync_range(va, (ARM_NVEC * 2) * sizeof(u_int));
|
|
|
|
|
|
|
|
vector_page = va;
|
|
|
|
}
|
|
|
|
|
1997-10-14 15:21:21 +04:00
|
|
|
/*
|
|
|
|
* Debug function just to park the CPU
|
|
|
|
*/
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1997-10-14 15:21:21 +04:00
|
|
|
void
|
|
|
|
halt()
|
|
|
|
{
|
|
|
|
while (1)
|
|
|
|
cpu_sleep(0);
|
|
|
|
}
|
1996-10-16 04:35:45 +04:00
|
|
|
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1997-10-14 15:21:21 +04:00
|
|
|
/* Sync the discs and unmount the filesystems */
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1997-10-14 15:21:21 +04:00
|
|
|
void
|
|
|
|
bootsync(void)
|
|
|
|
{
|
|
|
|
static int bootsyncdone = 0;
|
1996-10-16 04:35:45 +04:00
|
|
|
|
1997-10-14 15:21:21 +04:00
|
|
|
if (bootsyncdone) return;
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1997-10-14 15:21:21 +04:00
|
|
|
bootsyncdone = 1;
|
1996-10-16 04:35:45 +04:00
|
|
|
|
1997-10-14 15:21:21 +04:00
|
|
|
/* Make sure we can still manage to do things */
|
|
|
|
if (GetCPSR() & I32_bit) {
|
|
|
|
/*
|
1998-04-03 05:56:34 +04:00
|
|
|
* If we get here then boot has been called without RB_NOSYNC
|
|
|
|
* and interrupts were disabled. This means the boot() call
|
|
|
|
* did not come from a user process e.g. shutdown, but must
|
|
|
|
* have come from somewhere in the kernel.
|
1997-10-14 15:21:21 +04:00
|
|
|
*/
|
|
|
|
IRQenable;
|
|
|
|
printf("Warning IRQ's disabled during boot()\n");
|
|
|
|
}
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1997-10-14 15:21:21 +04:00
|
|
|
vfs_shutdown();
|
|
|
|
}
|
1996-02-01 02:14:53 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* void cpu_startup(void)
|
|
|
|
*
|
|
|
|
* Machine dependant startup code.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
cpu_startup()
|
|
|
|
{
|
|
|
|
int loop;
|
2001-03-04 22:05:55 +03:00
|
|
|
paddr_t minaddr;
|
|
|
|
paddr_t maxaddr;
|
1996-02-01 02:14:53 +03:00
|
|
|
caddr_t sysbase;
|
|
|
|
caddr_t size;
|
2001-03-04 22:05:55 +03:00
|
|
|
vsize_t bufsize;
|
1996-02-01 02:14:53 +03:00
|
|
|
int base, residual;
|
1999-05-20 12:21:42 +04:00
|
|
|
char pbuf[9];
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1999-01-03 05:23:27 +03:00
|
|
|
proc0paddr = (struct user *)kernelstack.pv_va;
|
1998-04-03 05:56:34 +04:00
|
|
|
proc0.p_addr = proc0paddr;
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1998-04-03 05:56:34 +04:00
|
|
|
/* Set the cpu control register */
|
1997-10-14 15:21:21 +04:00
|
|
|
cpu_setup(boot_args);
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1996-10-16 04:35:45 +04:00
|
|
|
/* All domains MUST be clients, permissions are VERY important */
|
1996-02-01 02:14:53 +03:00
|
|
|
cpu_domains(DOMAIN_CLIENT);
|
|
|
|
|
1996-10-16 04:35:45 +04:00
|
|
|
/* Lock down zero page */
|
2002-04-04 03:33:26 +04:00
|
|
|
vector_page_setprot(VM_PROT_READ);
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1998-02-22 02:00:57 +03:00
|
|
|
/*
|
|
|
|
* Give pmap a chance to set up a few more things now the vm
|
|
|
|
* is initialised
|
|
|
|
*/
|
1997-10-14 15:21:21 +04:00
|
|
|
pmap_postinit();
|
|
|
|
|
1996-10-16 04:35:45 +04:00
|
|
|
/*
|
|
|
|
* Initialize error message buffer (at end of core).
|
|
|
|
*/
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1996-10-16 04:35:45 +04:00
|
|
|
/* msgbufphys was setup during the secondary boot strap */
|
1997-10-14 15:21:21 +04:00
|
|
|
for (loop = 0; loop < btoc(MSGBUFSIZE); ++loop)
|
2001-08-11 17:00:48 +04:00
|
|
|
pmap_kenter_pa((vaddr_t)msgbufaddr + loop * NBPG,
|
|
|
|
msgbufphys + loop * NBPG, VM_PROT_READ|VM_PROT_WRITE);
|
2001-09-11 01:19:08 +04:00
|
|
|
pmap_update(pmap_kernel());
|
1997-09-19 17:52:37 +04:00
|
|
|
initmsgbuf(msgbufaddr, round_page(MSGBUFSIZE));
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1996-10-16 04:35:45 +04:00
|
|
|
/*
|
|
|
|
* Identify ourselves for the msgbuf (everything printed earlier will
|
|
|
|
* not be buffered).
|
|
|
|
*/
|
1996-10-13 07:05:43 +04:00
|
|
|
printf(version);
|
1999-05-20 12:21:42 +04:00
|
|
|
|
2002-03-24 06:37:18 +03:00
|
|
|
format_bytes(pbuf, sizeof(pbuf), arm_ptob(physmem));
|
1999-05-20 12:21:42 +04:00
|
|
|
printf("total memory = %s\n", pbuf);
|
1996-02-01 02:14:53 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Find out how much space we need, allocate it,
|
|
|
|
* and then give everything true virtual addresses.
|
|
|
|
*/
|
1999-05-20 12:21:42 +04:00
|
|
|
size = allocsys(NULL, NULL);
|
2000-03-27 00:42:21 +04:00
|
|
|
sysbase = (caddr_t)uvm_km_zalloc(kernel_map, round_page((vaddr_t)size));
|
1996-02-01 02:14:53 +03:00
|
|
|
if (sysbase == 0)
|
1999-05-20 12:21:42 +04:00
|
|
|
panic(
|
|
|
|
"cpu_startup: no room for system tables; %d bytes required",
|
|
|
|
(u_int)size);
|
|
|
|
if ((caddr_t)((allocsys(sysbase, NULL) - sysbase)) != size)
|
1996-02-01 02:14:53 +03:00
|
|
|
panic("cpu_startup: system table size inconsistency");
|
|
|
|
|
1997-02-04 10:12:30 +03:00
|
|
|
/*
|
1996-10-16 04:35:45 +04:00
|
|
|
* Now allocate buffers proper. They are different than the above
|
|
|
|
* in that they usually occupy more virtual memory than physical.
|
|
|
|
*/
|
1996-02-01 02:14:53 +03:00
|
|
|
bufsize = MAXBSIZE * nbuf;
|
2001-03-04 22:05:55 +03:00
|
|
|
if (uvm_map(kernel_map, (vaddr_t *)&buffers, round_page(bufsize),
|
2000-09-13 19:00:15 +04:00
|
|
|
NULL, UVM_UNKNOWN_OFFSET, 0,
|
1998-06-03 00:41:46 +04:00
|
|
|
UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
|
2001-03-15 09:10:32 +03:00
|
|
|
UVM_ADV_NORMAL, 0)) != 0)
|
1998-06-03 00:41:46 +04:00
|
|
|
panic("cpu_startup: cannot allocate UVM space for buffers");
|
2001-03-04 22:05:55 +03:00
|
|
|
minaddr = (vaddr_t)buffers;
|
1996-02-01 02:14:53 +03:00
|
|
|
if ((bufpages / nbuf) >= btoc(MAXBSIZE)) {
|
1996-10-16 04:35:45 +04:00
|
|
|
/* don't want to alloc more physical mem than needed */
|
1996-02-01 02:14:53 +03:00
|
|
|
bufpages = btoc(MAXBSIZE) * nbuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
base = bufpages / nbuf;
|
|
|
|
residual = bufpages % nbuf;
|
|
|
|
for (loop = 0; loop < nbuf; ++loop) {
|
2001-03-04 22:05:55 +03:00
|
|
|
vsize_t curbufsize;
|
|
|
|
vaddr_t curbuf;
|
1998-06-03 00:41:46 +04:00
|
|
|
struct vm_page *pg;
|
|
|
|
|
2001-08-11 17:00:48 +04:00
|
|
|
/*
|
|
|
|
* Each buffer has MAXBSIZE bytes of VM space allocated. Of
|
|
|
|
* that MAXBSIZE space, we allocate and map (base+1) pages
|
|
|
|
* for the first "residual" buffers, and then we allocate
|
|
|
|
* "base" pages for the rest.
|
|
|
|
*/
|
2001-03-04 22:05:55 +03:00
|
|
|
curbuf = (vaddr_t) buffers + (loop * MAXBSIZE);
|
1999-12-05 00:13:19 +03:00
|
|
|
curbufsize = NBPG * ((loop < residual) ? (base+1) : base);
|
1998-06-03 00:41:46 +04:00
|
|
|
|
|
|
|
while (curbufsize) {
|
1999-04-11 08:04:04 +04:00
|
|
|
pg = uvm_pagealloc(NULL, 0, NULL, 0);
|
1999-03-27 01:00:24 +03:00
|
|
|
if (pg == NULL)
|
|
|
|
panic("cpu_startup: not enough memory for buffer cache");
|
2001-08-11 17:00:48 +04:00
|
|
|
pmap_kenter_pa(curbuf, VM_PAGE_TO_PHYS(pg),
|
|
|
|
VM_PROT_READ|VM_PROT_WRITE);
|
1998-06-03 00:41:46 +04:00
|
|
|
curbuf += PAGE_SIZE;
|
|
|
|
curbufsize -= PAGE_SIZE;
|
|
|
|
}
|
1996-02-01 02:14:53 +03:00
|
|
|
}
|
2001-09-11 01:19:08 +04:00
|
|
|
pmap_update(pmap_kernel());
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1996-10-16 04:35:45 +04:00
|
|
|
/*
|
|
|
|
* Allocate a submap for exec arguments. This map effectively
|
|
|
|
* limits the number of processes exec'ing at any time.
|
|
|
|
*/
|
1998-06-03 00:41:46 +04:00
|
|
|
exec_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
|
1999-05-26 23:16:28 +04:00
|
|
|
16*NCARGS, VM_MAP_PAGEABLE, FALSE, NULL);
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1996-10-16 04:35:45 +04:00
|
|
|
/*
|
|
|
|
* Allocate a submap for physio
|
|
|
|
*/
|
1998-06-03 00:41:46 +04:00
|
|
|
phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
|
1999-05-26 23:16:28 +04:00
|
|
|
VM_PHYS_SIZE, 0, FALSE, NULL);
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1996-10-16 04:35:45 +04:00
|
|
|
/*
|
1997-03-28 00:01:20 +03:00
|
|
|
* Finally, allocate mbuf cluster submap.
|
1996-10-16 04:35:45 +04:00
|
|
|
*/
|
1999-01-10 01:10:12 +03:00
|
|
|
mb_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
|
1999-05-26 23:16:28 +04:00
|
|
|
nmbclusters * mclbytes, VM_MAP_INTRSAFE,
|
|
|
|
FALSE, NULL);
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1999-05-20 12:21:42 +04:00
|
|
|
format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
|
|
|
|
printf("avail memory = %s\n", pbuf);
|
1999-12-05 00:13:19 +03:00
|
|
|
format_bytes(pbuf, sizeof(pbuf), bufpages * NBPG);
|
1999-05-20 12:21:42 +04:00
|
|
|
printf("using %d buffers containing %s of memory\n", nbuf, pbuf);
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1996-10-16 04:35:45 +04:00
|
|
|
/*
|
|
|
|
* Set up buffers, so they can be used to read disk labels.
|
|
|
|
*/
|
1996-02-01 02:14:53 +03:00
|
|
|
bufinit();
|
|
|
|
|
1996-03-14 00:32:39 +03:00
|
|
|
curpcb = &proc0.p_addr->u_pcb;
|
|
|
|
curpcb->pcb_flags = 0;
|
2001-09-09 14:33:42 +04:00
|
|
|
curpcb->pcb_un.un_32.pcb32_und_sp = (u_int)proc0.p_addr +
|
|
|
|
USPACE_UNDEF_STACK_TOP;
|
|
|
|
curpcb->pcb_un.un_32.pcb32_sp = (u_int)proc0.p_addr +
|
|
|
|
USPACE_SVC_STACK_TOP;
|
2001-07-28 22:12:43 +04:00
|
|
|
(void) pmap_extract(pmap_kernel(), (vaddr_t)(pmap_kernel())->pm_pdir,
|
1999-07-08 22:05:21 +04:00
|
|
|
(paddr_t *)&curpcb->pcb_pagedir);
|
|
|
|
|
2001-09-09 14:33:42 +04:00
|
|
|
curpcb->pcb_tf = (struct trapframe *)curpcb->pcb_un.un_32.pcb32_sp - 1;
|
1996-02-01 02:14:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* machine dependent system variables.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
|
|
|
|
int *name;
|
|
|
|
u_int namelen;
|
|
|
|
void *oldp;
|
|
|
|
size_t *oldlenp;
|
|
|
|
void *newp;
|
|
|
|
size_t newlen;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
1997-02-04 10:12:30 +03:00
|
|
|
/* all sysctl names at this level are terminal */
|
|
|
|
if (namelen != 1)
|
|
|
|
return (ENOTDIR); /* overloaded */
|
|
|
|
|
|
|
|
switch (name[0]) {
|
1997-10-14 15:21:21 +04:00
|
|
|
case CPU_DEBUG:
|
|
|
|
return(sysctl_int(oldp, oldlenp, newp, newlen, &kernel_debug));
|
|
|
|
|
2000-06-07 08:59:28 +04:00
|
|
|
case CPU_BOOTED_DEVICE:
|
|
|
|
if (booted_device != NULL)
|
|
|
|
return (sysctl_rdstring(oldp, oldlenp, newp,
|
|
|
|
booted_device->dv_xname));
|
|
|
|
return (EOPNOTSUPP);
|
|
|
|
|
|
|
|
case CPU_CONSDEV: {
|
|
|
|
dev_t consdev;
|
|
|
|
if (cn_tab != NULL)
|
|
|
|
consdev = cn_tab->cn_dev;
|
|
|
|
else
|
|
|
|
consdev = NODEV;
|
|
|
|
return (sysctl_rdstruct(oldp, oldlenp, newp, &consdev,
|
|
|
|
sizeof consdev));
|
|
|
|
}
|
|
|
|
case CPU_BOOTED_KERNEL: {
|
2001-03-04 04:50:53 +03:00
|
|
|
if (booted_kernel != NULL && booted_kernel[0] != '\0')
|
2000-06-07 08:59:28 +04:00
|
|
|
return sysctl_rdstring(oldp, oldlenp, newp,
|
2001-03-04 04:50:53 +03:00
|
|
|
booted_kernel);
|
2000-06-07 08:59:28 +04:00
|
|
|
return (EOPNOTSUPP);
|
|
|
|
}
|
|
|
|
|
1997-02-04 10:12:30 +03:00
|
|
|
default:
|
|
|
|
return (EOPNOTSUPP);
|
|
|
|
}
|
|
|
|
/* NOTREACHED */
|
1996-02-01 02:14:53 +03:00
|
|
|
}
|
|
|
|
|
1997-10-14 15:21:21 +04:00
|
|
|
void
|
|
|
|
parse_mi_bootargs(args)
|
|
|
|
char *args;
|
1996-02-01 02:14:53 +03:00
|
|
|
{
|
1997-10-14 15:21:21 +04:00
|
|
|
int integer;
|
1996-02-01 02:14:53 +03:00
|
|
|
|
1997-10-14 15:21:21 +04:00
|
|
|
if (get_bootconf_option(args, "single", BOOTOPT_TYPE_BOOLEAN, &integer)
|
|
|
|
|| get_bootconf_option(args, "-s", BOOTOPT_TYPE_BOOLEAN, &integer))
|
|
|
|
if (integer)
|
|
|
|
boothowto |= RB_SINGLE;
|
|
|
|
if (get_bootconf_option(args, "kdb", BOOTOPT_TYPE_BOOLEAN, &integer)
|
|
|
|
|| get_bootconf_option(args, "-k", BOOTOPT_TYPE_BOOLEAN, &integer))
|
|
|
|
if (integer)
|
|
|
|
boothowto |= RB_KDB;
|
|
|
|
if (get_bootconf_option(args, "ask", BOOTOPT_TYPE_BOOLEAN, &integer)
|
|
|
|
|| get_bootconf_option(args, "-a", BOOTOPT_TYPE_BOOLEAN, &integer))
|
|
|
|
if (integer)
|
|
|
|
boothowto |= RB_ASKNAME;
|
|
|
|
|
|
|
|
#ifdef PMAP_DEBUG
|
|
|
|
if (get_bootconf_option(args, "pmapdebug", BOOTOPT_TYPE_INT, &integer)) {
|
|
|
|
pmap_debug_level = integer;
|
|
|
|
pmap_debug(pmap_debug_level);
|
1996-02-01 02:14:53 +03:00
|
|
|
}
|
1997-10-14 15:21:21 +04:00
|
|
|
#endif /* PMAP_DEBUG */
|
|
|
|
|
1998-09-05 05:23:04 +04:00
|
|
|
/* if (get_bootconf_option(args, "nbuf", BOOTOPT_TYPE_INT, &integer))
|
|
|
|
bufpages = integer;*/
|
1997-10-14 15:21:21 +04:00
|
|
|
|
|
|
|
#ifndef PMAP_STATIC_L1S
|
|
|
|
if (get_bootconf_option(args, "maxproc", BOOTOPT_TYPE_INT, &integer)) {
|
|
|
|
max_processes = integer;
|
|
|
|
if (max_processes < 16)
|
|
|
|
max_processes = 16;
|
|
|
|
/* Limit is PDSIZE * (max_processes + 1) <= 4MB */
|
|
|
|
if (max_processes > 255)
|
|
|
|
max_processes = 255;
|
1996-10-17 06:48:39 +04:00
|
|
|
}
|
1997-10-14 15:21:21 +04:00
|
|
|
#endif /* !PMAP_STATUC_L1S */
|
2002-04-02 09:30:34 +04:00
|
|
|
#if NMD > 0 && defined(MEMORY_DISK_HOOKS) && !defined(MEMORY_DISK_ROOT_SIZE)
|
1997-10-14 15:21:21 +04:00
|
|
|
if (get_bootconf_option(args, "memorydisc", BOOTOPT_TYPE_INT, &integer)
|
|
|
|
|| get_bootconf_option(args, "memorydisk", BOOTOPT_TYPE_INT, &integer)) {
|
2002-05-05 20:26:30 +04:00
|
|
|
md_root_size = integer;
|
|
|
|
md_root_size *= 1024;
|
|
|
|
if (md_root_size < 32*1024)
|
|
|
|
md_root_size = 32*1024;
|
|
|
|
if (md_root_size > 2048*1024)
|
|
|
|
md_root_size = 2048*1024;
|
1996-02-01 02:14:53 +03:00
|
|
|
}
|
2002-04-02 09:30:34 +04:00
|
|
|
#endif /* NMD && MEMORY_DISK_HOOKS && !MEMORY_DISK_ROOT_SIZE */
|
2000-09-24 16:32:31 +04:00
|
|
|
|
|
|
|
if (get_bootconf_option(args, "quiet", BOOTOPT_TYPE_BOOLEAN, &integer)
|
|
|
|
|| get_bootconf_option(args, "-q", BOOTOPT_TYPE_BOOLEAN, &integer))
|
|
|
|
if (integer)
|
|
|
|
boothowto |= AB_QUIET;
|
|
|
|
if (get_bootconf_option(args, "verbose", BOOTOPT_TYPE_BOOLEAN, &integer)
|
|
|
|
|| get_bootconf_option(args, "-v", BOOTOPT_TYPE_BOOLEAN, &integer))
|
|
|
|
if (integer)
|
|
|
|
boothowto |= AB_VERBOSE;
|
1996-03-09 00:37:01 +03:00
|
|
|
}
|