2005-04-25 19:02:02 +04:00
|
|
|
/* $NetBSD: arm32_machdep.c,v 1.45 2005/04/25 15:02:03 lukem 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
|
|
|
*/
|
|
|
|
|
2003-07-15 04:24:37 +04:00
|
|
|
#include <sys/cdefs.h>
|
2005-04-25 19:02:02 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: arm32_machdep.c,v 1.45 2005/04/25 15:02:03 lukem Exp $");
|
2003-07-15 04:24:37 +04: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
|
|
|
|
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
|
|
|
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;
|
2003-04-18 14:51:35 +04:00
|
|
|
|
|
|
|
if (va == ARM_VECTORS_HIGH) {
|
|
|
|
/*
|
|
|
|
* Assume the MD caller knows what it's doing here, and
|
|
|
|
* really does want the vector page relocated.
|
|
|
|
*
|
|
|
|
* Note: This has to be done here (and not just in
|
|
|
|
* cpu_setup()) because the vector page needs to be
|
|
|
|
* accessible *before* cpu_startup() is called.
|
|
|
|
* Think ddb(9) ...
|
2003-04-19 02:30:05 +04:00
|
|
|
*
|
|
|
|
* NOTE: If the CPU control register is not readable,
|
|
|
|
* this will totally fail! We'll just assume that
|
|
|
|
* any system that has high vector support has a
|
|
|
|
* readable CPU control register, for now. If we
|
|
|
|
* ever encounter one that does not, we'll have to
|
|
|
|
* rethink this.
|
2003-04-18 14:51:35 +04:00
|
|
|
*/
|
|
|
|
cpu_control(CPU_CONTROL_VECRELOC, CPU_CONTROL_VECRELOC);
|
|
|
|
}
|
2002-04-04 03:33:26 +04:00
|
|
|
}
|
|
|
|
|
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()
|
|
|
|
{
|
2003-12-30 15:33:13 +03:00
|
|
|
vaddr_t minaddr;
|
|
|
|
vaddr_t maxaddr;
|
|
|
|
u_int loop;
|
1999-05-20 12:21:42 +04:00
|
|
|
char pbuf[9];
|
1996-02-01 02:14:53 +03:00
|
|
|
|
2004-02-13 14:36:08 +03: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
|
|
|
/* 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)
|
2003-04-02 03:19:08 +04:00
|
|
|
pmap_kenter_pa((vaddr_t)msgbufaddr + loop * PAGE_SIZE,
|
|
|
|
msgbufphys + loop * PAGE_SIZE, 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).
|
|
|
|
*/
|
2005-04-25 19:02:02 +04:00
|
|
|
printf("%s%s", copyright, 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
|
|
|
|
2003-12-30 15:33:13 +03:00
|
|
|
minaddr = 0;
|
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);
|
1996-02-01 02:14:53 +03:00
|
|
|
|
2003-01-18 00:55:23 +03:00
|
|
|
curpcb = &lwp0.l_addr->u_pcb;
|
1996-03-14 00:32:39 +03:00
|
|
|
curpcb->pcb_flags = 0;
|
2003-01-18 00:55:23 +03:00
|
|
|
curpcb->pcb_un.un_32.pcb32_und_sp = (u_int)lwp0.l_addr +
|
2001-09-09 14:33:42 +04:00
|
|
|
USPACE_UNDEF_STACK_TOP;
|
2003-01-18 00:55:23 +03:00
|
|
|
curpcb->pcb_un.un_32.pcb32_sp = (u_int)lwp0.l_addr +
|
2001-09-09 14:33:42 +04:00
|
|
|
USPACE_SVC_STACK_TOP;
|
2003-04-18 15:08:24 +04:00
|
|
|
pmap_set_pcb_pagedir(pmap_kernel(), curpcb);
|
1999-07-08 22:05:21 +04:00
|
|
|
|
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.
|
|
|
|
*/
|
Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.
Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.
All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.
PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 22:38:21 +03:00
|
|
|
static int
|
|
|
|
sysctl_machdep_booted_device(SYSCTLFN_ARGS)
|
1996-02-01 02:14:53 +03:00
|
|
|
{
|
Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.
Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.
All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.
PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 22:38:21 +03:00
|
|
|
struct sysctlnode node;
|
2000-06-07 08:59:28 +04:00
|
|
|
|
Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.
Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.
All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.
PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 22:38:21 +03:00
|
|
|
if (booted_device == NULL)
|
2000-06-07 08:59:28 +04:00
|
|
|
return (EOPNOTSUPP);
|
2002-08-16 19:25:53 +04:00
|
|
|
|
Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.
Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.
All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.
PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 22:38:21 +03:00
|
|
|
node = *rnode;
|
|
|
|
node.sysctl_data = booted_device->dv_xname;
|
|
|
|
node.sysctl_size = strlen(booted_device->dv_xname) + 1;
|
|
|
|
return (sysctl_lookup(SYSCTLFN_CALL(&node)));
|
|
|
|
}
|
2002-08-16 19:25:53 +04:00
|
|
|
|
Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.
Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.
All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.
PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 22:38:21 +03:00
|
|
|
static int
|
|
|
|
sysctl_machdep_booted_kernel(SYSCTLFN_ARGS)
|
|
|
|
{
|
|
|
|
struct sysctlnode node;
|
2002-08-16 19:25:53 +04:00
|
|
|
|
Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.
Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.
All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.
PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 22:38:21 +03:00
|
|
|
if (booted_kernel == NULL || booted_kernel[0] == '\0')
|
|
|
|
return (EOPNOTSUPP);
|
2002-08-16 19:25:53 +04:00
|
|
|
|
Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.
Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.
All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.
PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 22:38:21 +03:00
|
|
|
node = *rnode;
|
|
|
|
node.sysctl_data = booted_kernel;
|
|
|
|
node.sysctl_size = strlen(booted_kernel) + 1;
|
|
|
|
return (sysctl_lookup(SYSCTLFN_CALL(&node)));
|
|
|
|
}
|
2000-06-07 08:59:28 +04:00
|
|
|
|
Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.
Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.
All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.
PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 22:38:21 +03:00
|
|
|
static int
|
|
|
|
sysctl_machdep_powersave(SYSCTLFN_ARGS)
|
|
|
|
{
|
|
|
|
struct sysctlnode node = *rnode;
|
|
|
|
int error, newval;
|
|
|
|
|
|
|
|
newval = cpu_do_powersave;
|
|
|
|
node.sysctl_data = &newval;
|
|
|
|
if (cpufuncs.cf_sleep == (void *) cpufunc_nullop)
|
2004-03-24 18:34:46 +03:00
|
|
|
node.sysctl_flags &= ~CTLFLAG_READWRITE;
|
Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.
Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.
All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.
PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 22:38:21 +03:00
|
|
|
error = sysctl_lookup(SYSCTLFN_CALL(&node));
|
|
|
|
if (error || newp == NULL || newval == cpu_do_powersave)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
if (newval < 0 || newval > 1)
|
|
|
|
return (EINVAL);
|
|
|
|
cpu_do_powersave = newval;
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
SYSCTL_SETUP(sysctl_machdep_setup, "sysctl machdep subtree setup")
|
|
|
|
{
|
|
|
|
|
2004-03-24 18:34:46 +03:00
|
|
|
sysctl_createv(clog, 0, NULL, NULL,
|
|
|
|
CTLFLAG_PERMANENT,
|
Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.
Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.
All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.
PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 22:38:21 +03:00
|
|
|
CTLTYPE_NODE, "machdep", NULL,
|
|
|
|
NULL, 0, NULL, 0,
|
|
|
|
CTL_MACHDEP, CTL_EOL);
|
|
|
|
|
2004-03-24 18:34:46 +03:00
|
|
|
sysctl_createv(clog, 0, NULL, NULL,
|
|
|
|
CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
|
2003-12-12 06:52:56 +03:00
|
|
|
CTLTYPE_INT, "debug", NULL,
|
Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.
Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.
All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.
PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 22:38:21 +03:00
|
|
|
NULL, 0, &kernel_debug, 0,
|
2003-12-13 15:07:41 +03:00
|
|
|
CTL_MACHDEP, CPU_DEBUG, CTL_EOL);
|
2004-03-24 18:34:46 +03:00
|
|
|
sysctl_createv(clog, 0, NULL, NULL,
|
|
|
|
CTLFLAG_PERMANENT,
|
Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.
Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.
All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.
PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 22:38:21 +03:00
|
|
|
CTLTYPE_STRING, "booted_device", NULL,
|
|
|
|
sysctl_machdep_booted_device, 0, NULL, 0,
|
|
|
|
CTL_MACHDEP, CPU_BOOTED_DEVICE, CTL_EOL);
|
2004-03-24 18:34:46 +03:00
|
|
|
sysctl_createv(clog, 0, NULL, NULL,
|
|
|
|
CTLFLAG_PERMANENT,
|
Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.
Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.
All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.
PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 22:38:21 +03:00
|
|
|
CTLTYPE_STRING, "booted_kernel", NULL,
|
|
|
|
sysctl_machdep_booted_kernel, 0, NULL, 0,
|
|
|
|
CTL_MACHDEP, CPU_BOOTED_KERNEL, CTL_EOL);
|
2004-03-24 18:34:46 +03:00
|
|
|
sysctl_createv(clog, 0, NULL, NULL,
|
|
|
|
CTLFLAG_PERMANENT,
|
Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.
Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.
All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.
PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 22:38:21 +03:00
|
|
|
CTLTYPE_STRUCT, "console_device", NULL,
|
|
|
|
sysctl_consdev, 0, NULL, sizeof(dev_t),
|
|
|
|
CTL_MACHDEP, CPU_CONSDEV, CTL_EOL);
|
2004-03-24 18:34:46 +03:00
|
|
|
sysctl_createv(clog, 0, NULL, NULL,
|
|
|
|
CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
|
Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.
Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.
All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.
PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 22:38:21 +03:00
|
|
|
CTLTYPE_INT, "powersave", NULL,
|
|
|
|
sysctl_machdep_powersave, 0, &cpu_do_powersave, 0,
|
|
|
|
CTL_MACHDEP, CPU_POWERSAVE, CTL_EOL);
|
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
|
|
|
|
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
|
|
|
}
|