Home | History | Annotate | Line # | Download | only in alchemy
machdep.c revision 1.7
      1  1.7  thorpej /* $NetBSD: machdep.c,v 1.7 2003/04/02 03:51:33 thorpej Exp $ */
      2  1.1   simonb 
      3  1.1   simonb /*
      4  1.1   simonb  * Copyright (c) 1988 University of Utah.
      5  1.1   simonb  * Copyright (c) 1992, 1993
      6  1.1   simonb  *	The Regents of the University of California.  All rights reserved.
      7  1.1   simonb  *
      8  1.1   simonb  * This code is derived from software contributed to Berkeley by
      9  1.1   simonb  * the Systems Programming Group of the University of Utah Computer
     10  1.1   simonb  * Science Department, The Mach Operating System project at
     11  1.1   simonb  * Carnegie-Mellon University and Ralph Campbell.
     12  1.1   simonb  *
     13  1.1   simonb  * Redistribution and use in source and binary forms, with or without
     14  1.1   simonb  * modification, are permitted provided that the following conditions
     15  1.1   simonb  * are met:
     16  1.1   simonb  * 1. Redistributions of source code must retain the above copyright
     17  1.1   simonb  *    notice, this list of conditions and the following disclaimer.
     18  1.1   simonb  * 2. Redistributions in binary form must reproduce the above copyright
     19  1.1   simonb  *    notice, this list of conditions and the following disclaimer in the
     20  1.1   simonb  *    documentation and/or other materials provided with the distribution.
     21  1.1   simonb  * 3. All advertising materials mentioning features or use of this software
     22  1.1   simonb  *    must display the following acknowledgement:
     23  1.1   simonb  *	This product includes software developed by the University of
     24  1.1   simonb  *	California, Berkeley and its contributors.
     25  1.1   simonb  * 4. Neither the name of the University nor the names of its contributors
     26  1.1   simonb  *    may be used to endorse or promote products derived from this software
     27  1.1   simonb  *    without specific prior written permission.
     28  1.1   simonb  *
     29  1.1   simonb  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     30  1.1   simonb  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     31  1.1   simonb  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     32  1.1   simonb  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     33  1.1   simonb  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     34  1.1   simonb  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     35  1.1   simonb  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     36  1.1   simonb  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     37  1.1   simonb  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     38  1.1   simonb  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     39  1.1   simonb  * SUCH DAMAGE.
     40  1.1   simonb  *
     41  1.1   simonb  *	@(#)machdep.c	8.3 (Berkeley) 1/12/94
     42  1.1   simonb  * 	from: Utah Hdr: machdep.c 1.63 91/04/24
     43  1.1   simonb  */
     44  1.1   simonb 
     45  1.1   simonb #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
     46  1.7  thorpej __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.7 2003/04/02 03:51:33 thorpej Exp $");
     47  1.1   simonb 
     48  1.1   simonb #include "opt_ddb.h"
     49  1.1   simonb #include "opt_kgdb.h"
     50  1.1   simonb 
     51  1.1   simonb #include "opt_memsize.h"
     52  1.1   simonb #include "opt_ethaddr.h"
     53  1.1   simonb 
     54  1.1   simonb #include <sys/param.h>
     55  1.1   simonb #include <sys/systm.h>
     56  1.1   simonb #include <sys/kernel.h>
     57  1.1   simonb #include <sys/buf.h>
     58  1.1   simonb #include <sys/reboot.h>
     59  1.1   simonb #include <sys/user.h>
     60  1.1   simonb #include <sys/mount.h>
     61  1.1   simonb #include <sys/kcore.h>
     62  1.1   simonb #include <sys/boot_flag.h>
     63  1.1   simonb #include <sys/termios.h>
     64  1.1   simonb 
     65  1.1   simonb #include <net/if.h>
     66  1.1   simonb #include <net/if_ether.h>
     67  1.1   simonb 
     68  1.1   simonb #include <uvm/uvm_extern.h>
     69  1.1   simonb 
     70  1.1   simonb #include <dev/cons.h>
     71  1.1   simonb 
     72  1.1   simonb #ifdef DDB
     73  1.1   simonb #include <machine/db_machdep.h>
     74  1.1   simonb #include <ddb/db_extern.h>
     75  1.1   simonb #endif
     76  1.1   simonb 
     77  1.1   simonb #include <mips/cache.h>
     78  1.1   simonb #include <mips/locore.h>
     79  1.1   simonb #include <machine/yamon.h>
     80  1.1   simonb 
     81  1.1   simonb #include <evbmips/alchemy/pb1000var.h>
     82  1.1   simonb #include <mips/alchemy/include/aureg.h>
     83  1.1   simonb #include <mips/alchemy/include/auvar.h>
     84  1.1   simonb #include <mips/alchemy/include/aubusvar.h>
     85  1.1   simonb 
     86  1.1   simonb #include "aucom.h"
     87  1.1   simonb #if NAUCOM > 0
     88  1.1   simonb #include <mips/alchemy/dev/aucomvar.h>
     89  1.1   simonb 
     90  1.1   simonb #ifndef CONSPEED
     91  1.1   simonb #define CONSPEED TTYDEF_SPEED
     92  1.1   simonb #endif
     93  1.1   simonb int	aucomcnrate = CONSPEED;
     94  1.1   simonb #endif /* NAUCOM > 0 */
     95  1.1   simonb 
     96  1.6  hpeyerl #include "ohci.h"
     97  1.6  hpeyerl 
     98  1.1   simonb /* The following are used externally (sysctl_hw). */
     99  1.2   simonb extern char	cpu_model[];
    100  1.1   simonb 
    101  1.1   simonb struct	user *proc0paddr;
    102  1.1   simonb 
    103  1.1   simonb /* Our exported CPU info; we can have only one. */
    104  1.1   simonb struct cpu_info cpu_info_store;
    105  1.1   simonb 
    106  1.1   simonb /* Maps for VM objects. */
    107  1.1   simonb struct vm_map *exec_map = NULL;
    108  1.1   simonb struct vm_map *mb_map = NULL;
    109  1.1   simonb struct vm_map *phys_map = NULL;
    110  1.1   simonb 
    111  1.1   simonb int physmem;		/* # pages of physical memory */
    112  1.1   simonb int maxmem;			/* max memory per process */
    113  1.1   simonb 
    114  1.1   simonb int mem_cluster_cnt;
    115  1.1   simonb phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX];
    116  1.1   simonb 
    117  1.1   simonb yamon_env_var *yamon_envp;
    118  1.1   simonb struct pb1000_config pb1000_configuration;
    119  1.1   simonb struct propdb *alchemy_prop_info;
    120  1.1   simonb 
    121  1.1   simonb void	mach_init(int, char **, yamon_env_var *, u_long); /* XXX */
    122  1.1   simonb 
    123  1.1   simonb void
    124  1.1   simonb mach_init(int argc, char **argv, yamon_env_var *envp, u_long memsize)
    125  1.1   simonb {
    126  1.1   simonb 	struct pb1000_config *pbc = &pb1000_configuration;
    127  1.1   simonb 	bus_space_handle_t sh;
    128  1.1   simonb 	caddr_t kernend;
    129  1.1   simonb 	const char *cp;
    130  1.1   simonb 	u_long first, last;
    131  1.1   simonb 	caddr_t v;
    132  1.1   simonb 	int howto, i;
    133  1.1   simonb 
    134  1.1   simonb 	extern char edata[], end[];	/* XXX */
    135  1.1   simonb 
    136  1.1   simonb 	/* clear the BSS segment */
    137  1.1   simonb 	kernend = (caddr_t)mips_round_page(end);
    138  1.1   simonb 	memset(edata, 0, kernend - (caddr_t)edata);
    139  1.1   simonb 
    140  1.2   simonb 	/* set cpu model info for sysctl_hw */
    141  1.2   simonb 	strcpy(cpu_model, "Alchemy Semiconductor Pb1000");
    142  1.2   simonb 
    143  1.1   simonb 	/* save the yamon environment pointer */
    144  1.1   simonb 	yamon_envp = envp;
    145  1.1   simonb 
    146  1.1   simonb 	/* Use YAMON callbacks for early console I/O */
    147  1.1   simonb 	cn_tab = &yamon_promcd;
    148  1.1   simonb 
    149  1.1   simonb 	/*
    150  1.1   simonb 	 * Set up the exception vectors and cpu-specific function
    151  1.1   simonb 	 * vectors early on.  We need the wbflush() vector set up
    152  1.1   simonb 	 * before comcnattach() is called (or at least before the
    153  1.1   simonb 	 * first printf() after that is called).
    154  1.1   simonb 	 * Also clears the I+D caches.
    155  1.1   simonb 	 */
    156  1.1   simonb 	mips_vector_init();
    157  1.1   simonb 
    158  1.1   simonb 	/*
    159  1.1   simonb 	 * Set the VM page size.
    160  1.1   simonb 	 */
    161  1.1   simonb 	uvm_setpagesize();
    162  1.1   simonb 
    163  1.1   simonb 	/*
    164  1.1   simonb 	 * Initialize bus space tags.
    165  1.1   simonb 	 */
    166  1.1   simonb 	au_cpureg_bus_mem_init(&pbc->pc_cpuregt, pbc);
    167  1.1   simonb 	aubus_st = &pbc->pc_cpuregt;		/* XXX: for aubus.c */
    168  1.1   simonb 
    169  1.1   simonb 	/*
    170  1.1   simonb 	 * Calibrate the timer, delay() relies on this.
    171  1.1   simonb 	 */
    172  1.1   simonb 	bus_space_map(&pbc->pc_cpuregt, PC_BASE, PC_SIZE, 0, &sh);
    173  1.1   simonb 	au_cal_timers(&pbc->pc_cpuregt, sh);
    174  1.1   simonb 	bus_space_unmap(&pbc->pc_cpuregt, sh, PC_SIZE);
    175  1.1   simonb 
    176  1.1   simonb 	/*
    177  1.1   simonb 	 * Bring up the console.
    178  1.1   simonb 	 */
    179  1.1   simonb #if NAUCOM > 0
    180  1.1   simonb 	/*
    181  1.1   simonb 	 * Delay to allow firmware putchars to complete.
    182  1.1   simonb 	 * FIFO depth * character time.
    183  1.1   simonb 	 * character time = (1000000 / (defaultrate / 10))
    184  1.1   simonb 	 */
    185  1.1   simonb 	delay(160000000 / aucomcnrate);
    186  1.1   simonb 	if (aucomcnattach(&pbc->pc_cpuregt, UART0_BASE, aucomcnrate,
    187  1.1   simonb 	    curcpu()->ci_cpu_freq / 4,
    188  1.1   simonb 	    (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8) != 0)
    189  1.1   simonb 		panic("pb1000: unable to initialize serial console");
    190  1.1   simonb #else
    191  1.1   simonb 	panic("pb1000: not configured to use serial console");
    192  1.1   simonb #endif /* NAUCOM > 0 */
    193  1.1   simonb 
    194  1.1   simonb 	/*
    195  1.1   simonb 	 * Look at arguments passed to us and compute boothowto.
    196  1.1   simonb 	 */
    197  1.1   simonb 	boothowto = RB_AUTOBOOT;
    198  1.1   simonb #ifdef KADB
    199  1.1   simonb 	boothowto |= RB_KDB;
    200  1.1   simonb #endif
    201  1.1   simonb 	for (i = 1; i < argc; i++) {
    202  1.1   simonb 		for (cp = argv[i]; *cp; cp++) {
    203  1.1   simonb 			/* Ignore superfluous '-', if there is one */
    204  1.1   simonb 			if (*cp == '-')
    205  1.1   simonb 				continue;
    206  1.1   simonb 
    207  1.1   simonb 			howto = 0;
    208  1.1   simonb 			BOOT_FLAG(*cp, howto);
    209  1.1   simonb 			if (! howto)
    210  1.1   simonb 				printf("bootflag '%c' not recognised\n", *cp);
    211  1.1   simonb 			else
    212  1.1   simonb 				boothowto |= howto;
    213  1.1   simonb 		}
    214  1.1   simonb 	}
    215  1.1   simonb 
    216  1.1   simonb 	/*
    217  1.1   simonb 	 * Determine the memory size.  Use the `memsize' PMON
    218  1.1   simonb 	 * variable.  If that's not available, panic.
    219  1.1   simonb 	 *
    220  1.1   simonb 	 * Note: Reserve the first page!  That's where the trap
    221  1.1   simonb 	 * vectors are located.
    222  1.1   simonb 	 */
    223  1.1   simonb 
    224  1.1   simonb #if defined(MEMSIZE)
    225  1.4      scw 	memsize = MEMSIZE;
    226  1.1   simonb #else
    227  1.1   simonb 	if (memsize == 0) {
    228  1.1   simonb 		if ((cp = yamon_getenv("memsize")) != NULL)
    229  1.1   simonb 			memsize = strtoul(cp, NULL, 0);
    230  1.1   simonb 		else {
    231  1.1   simonb 			printf("FATAL: `memsize' YAMON variable not set.  Set it to\n");
    232  1.1   simonb 			printf("       the amount of memory (in MB) and try again.\n");
    233  1.1   simonb 			printf("       Or, build a kernel with the `MEMSIZE' "
    234  1.1   simonb 			    "option.\n");
    235  1.1   simonb 			panic("pb1000_init");
    236  1.1   simonb 		}
    237  1.1   simonb 	}
    238  1.1   simonb #endif /* MEMSIZE */
    239  1.1   simonb 	printf("Memory size: 0x%08lx\n", memsize);
    240  1.1   simonb 	physmem = btoc(memsize);
    241  1.1   simonb 
    242  1.7  thorpej 	mem_clusters[mem_cluster_cnt].start = PAGE_SIZE;
    243  1.1   simonb 	mem_clusters[mem_cluster_cnt].size =
    244  1.1   simonb 	    memsize - mem_clusters[mem_cluster_cnt].start;
    245  1.1   simonb 	mem_cluster_cnt++;
    246  1.1   simonb 
    247  1.1   simonb 	/*
    248  1.1   simonb 	 * Load the rest of the available pages into the VM system.
    249  1.1   simonb 	 */
    250  1.1   simonb 	first = round_page(MIPS_KSEG0_TO_PHYS(kernend));
    251  1.1   simonb 	last = mem_clusters[0].start + mem_clusters[0].size;
    252  1.1   simonb 	uvm_page_physload(atop(first), atop(last), atop(first), atop(last),
    253  1.1   simonb 	    VM_FREELIST_DEFAULT);
    254  1.1   simonb 
    255  1.1   simonb 	/*
    256  1.1   simonb 	 * Initialize message buffer (at end of core).
    257  1.1   simonb 	 */
    258  1.1   simonb 	mips_init_msgbuf();
    259  1.1   simonb 
    260  1.1   simonb 	/*
    261  1.1   simonb 	 * Compute the size of system data structures.  pmap_bootstrap()
    262  1.1   simonb 	 * needs some of this information.
    263  1.1   simonb 	 */
    264  1.1   simonb 	memsize = (u_long)allocsys(NULL, NULL);
    265  1.1   simonb 
    266  1.1   simonb 	/*
    267  1.1   simonb 	 * Initialize the virtual memory system.
    268  1.1   simonb 	 */
    269  1.1   simonb 	pmap_bootstrap();
    270  1.1   simonb 
    271  1.1   simonb 	/*
    272  1.1   simonb 	 * Init mapping for u page(s) for proc0.
    273  1.1   simonb 	 */
    274  1.1   simonb 	v = (caddr_t) uvm_pageboot_alloc(USPACE);
    275  1.5  thorpej 	lwp0.l_addr = proc0paddr = (struct user *)v;
    276  1.5  thorpej 	lwp0.l_md.md_regs = (struct frame *)(v + USPACE) - 1;
    277  1.5  thorpej 	curpcb = &lwp0.l_addr->u_pcb;
    278  1.1   simonb 	curpcb->pcb_context[11] = MIPS_INT_MASK | MIPS_SR_INT_IE; /* SR */
    279  1.1   simonb 
    280  1.1   simonb 	/*
    281  1.1   simonb 	 * Allocate space for system data structures.  These data structures
    282  1.1   simonb 	 * are allocated here instead of cpu_startup() because physical
    283  1.1   simonb 	 * memory is directly addressable.  We don't have to map these into
    284  1.1   simonb 	 * the virtual address space.
    285  1.1   simonb 	 */
    286  1.1   simonb 	v = (caddr_t)uvm_pageboot_alloc(memsize);
    287  1.1   simonb 	if ((allocsys(v, NULL) - v) != memsize)
    288  1.1   simonb 		panic("mach_init: table size inconsistency");
    289  1.1   simonb 
    290  1.6  hpeyerl #if NOHCI > 0
    291  1.6  hpeyerl 	{
    292  1.6  hpeyerl #define	USBH_ALL   (0x1f<<10)  /* All relevant bits in USBH portion of SYS_CLKSRC */
    293  1.6  hpeyerl 		/*
    294  1.6  hpeyerl 		 * Assign a clock for the USB Host controller.
    295  1.6  hpeyerl 		 */
    296  1.6  hpeyerl 		volatile u_int32_t *scsreg;
    297  1.6  hpeyerl 		u_int32_t	tmp;
    298  1.6  hpeyerl 
    299  1.6  hpeyerl 		scsreg = (volatile u_int32_t *)(MIPS_PHYS_TO_KSEG1(SYS_CLKSRC));
    300  1.6  hpeyerl #if 0
    301  1.6  hpeyerl 		auxpll = (volatile u_int32_t *)(MIPS_PHYS_TO_KSEG1(SYS_AUXPLL));
    302  1.6  hpeyerl 		*auxpll = 8;		/* 96Mhz */
    303  1.6  hpeyerl 		tmp = *sfc0;
    304  1.6  hpeyerl 		tmp |= SFC_FE0|SFC_FRDIV0;
    305  1.6  hpeyerl 		*sfc0 = tmp;
    306  1.6  hpeyerl #endif
    307  1.6  hpeyerl 		tmp = *scsreg;
    308  1.6  hpeyerl 		tmp &= ~USBH_ALL;	/* clear all USBH bits in SYS_CLKSRC first */
    309  1.6  hpeyerl 		tmp |= (SCS_DUH|SCS_CUH|SCS_MUH(SCS_MEx_AUX));	/* 48Mhz */
    310  1.6  hpeyerl 		*scsreg = tmp;
    311  1.6  hpeyerl 	}
    312  1.6  hpeyerl #endif   /* NOHCI */
    313  1.1   simonb 	/*
    314  1.1   simonb 	 * Initialize debuggers, and break into them, if appropriate.
    315  1.1   simonb 	 */
    316  1.1   simonb #ifdef DDB
    317  1.1   simonb 	ddb_init(0, 0, 0);
    318  1.1   simonb 	if (boothowto & RB_KDB)
    319  1.1   simonb 		Debugger();
    320  1.1   simonb #endif
    321  1.1   simonb }
    322  1.1   simonb 
    323  1.1   simonb void
    324  1.1   simonb consinit(void)
    325  1.1   simonb {
    326  1.1   simonb 
    327  1.1   simonb 	/*
    328  1.1   simonb 	 * Everything related to console initialization is done
    329  1.1   simonb 	 * in mach_init().
    330  1.1   simonb 	 */
    331  1.1   simonb }
    332  1.1   simonb 
    333  1.1   simonb void
    334  1.1   simonb cpu_startup(void)
    335  1.1   simonb {
    336  1.1   simonb 	char pbuf[9];
    337  1.1   simonb 	vaddr_t minaddr, maxaddr;
    338  1.1   simonb 	vsize_t size;
    339  1.3  thorpej 	u_int i, base, residual;
    340  1.1   simonb #ifdef DEBUG
    341  1.1   simonb 	extern int pmapdebug;		/* XXX */
    342  1.1   simonb 	int opmapdebug = pmapdebug;
    343  1.1   simonb 
    344  1.1   simonb 	pmapdebug = 0;		/* Shut up pmap debug during bootstrap */
    345  1.1   simonb #endif
    346  1.1   simonb 
    347  1.1   simonb 	/*
    348  1.1   simonb 	 * Good {morning,afternoon,evening,night}.
    349  1.1   simonb 	 */
    350  1.1   simonb 	printf(version);
    351  1.1   simonb 	printf("%s\n", cpu_model);
    352  1.1   simonb 	format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
    353  1.1   simonb 	printf("total memory = %s\n", pbuf);
    354  1.1   simonb 
    355  1.1   simonb 	/*
    356  1.1   simonb 	 * Allocate virtual address space for file I/O buffers.
    357  1.1   simonb 	 * Note they are different than the array of headers, 'buf',
    358  1.1   simonb 	 * and usually occupy more virtual memory than physical.
    359  1.1   simonb 	 */
    360  1.1   simonb 	size = MAXBSIZE * nbuf;
    361  1.1   simonb 	if (uvm_map(kernel_map, (vaddr_t *)&buffers, round_page(size),
    362  1.1   simonb 		    NULL, UVM_UNKNOWN_OFFSET, 0,
    363  1.1   simonb 		    UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
    364  1.1   simonb 				UVM_ADV_NORMAL, 0)) != 0)
    365  1.1   simonb 		panic("cpu_startup: cannot allocate VM for buffers");
    366  1.1   simonb 
    367  1.1   simonb 	minaddr = (vaddr_t)buffers;
    368  1.1   simonb 	if ((bufpages / nbuf) >= btoc(MAXBSIZE)) {
    369  1.1   simonb 		bufpages = btoc(MAXBSIZE) * nbuf; /* do not overallocate RAM */
    370  1.1   simonb 	}
    371  1.1   simonb 	base = bufpages / nbuf;
    372  1.1   simonb 	residual = bufpages % nbuf;
    373  1.1   simonb 
    374  1.1   simonb 	/* now allocate RAM for buffers */
    375  1.1   simonb 	for (i = 0; i < nbuf; i++) {
    376  1.1   simonb 		vsize_t curbufsize;
    377  1.1   simonb 		vaddr_t curbuf;
    378  1.1   simonb 		struct vm_page *pg;
    379  1.1   simonb 
    380  1.1   simonb 		/*
    381  1.1   simonb 		 * Each buffer has MAXBSIZE bytes of VM space allocated.  Of
    382  1.1   simonb 		 * that MAXBSIZE space, we allocate and map (base+1) pages
    383  1.1   simonb 		 * for the first "residual" buffers, and then we allocate
    384  1.1   simonb 		 * "base" pages for the rest.
    385  1.1   simonb 		 */
    386  1.1   simonb 		curbuf = (vaddr_t)buffers + (i * MAXBSIZE);
    387  1.7  thorpej 		curbufsize = PAGE_SIZE * ((i < residual) ? (base+1) : base);
    388  1.1   simonb 
    389  1.1   simonb 		while (curbufsize) {
    390  1.1   simonb 			pg = uvm_pagealloc(NULL, 0, NULL, 0);
    391  1.1   simonb 			if (pg == NULL)
    392  1.1   simonb 				panic("cpu_startup: not enough memory for "
    393  1.1   simonb 				    "buffer cache");
    394  1.1   simonb 			pmap_kenter_pa(curbuf, VM_PAGE_TO_PHYS(pg),
    395  1.1   simonb 			    VM_PROT_READ|VM_PROT_WRITE);
    396  1.1   simonb 			curbuf += PAGE_SIZE;
    397  1.1   simonb 			curbufsize -= PAGE_SIZE;
    398  1.1   simonb 		}
    399  1.1   simonb 	}
    400  1.1   simonb 	pmap_update(pmap_kernel());
    401  1.1   simonb 
    402  1.1   simonb 	/*
    403  1.1   simonb 	 * Allocate a submap for exec arguments.  This map effectively
    404  1.1   simonb 	 * limits the number of processes exec'ing at any time.
    405  1.1   simonb 	 */
    406  1.1   simonb 	exec_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
    407  1.1   simonb 	    16 * NCARGS, VM_MAP_PAGEABLE, FALSE, NULL);
    408  1.1   simonb 
    409  1.1   simonb 	/*
    410  1.1   simonb 	 * Allocate a submap for physio
    411  1.1   simonb 	 */
    412  1.1   simonb 	phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
    413  1.1   simonb 	    VM_PHYS_SIZE, 0, FALSE, NULL);
    414  1.1   simonb 
    415  1.1   simonb 	/*
    416  1.1   simonb 	 * No need to allocate an mbuf cluster submap.  Mbuf clusters
    417  1.1   simonb 	 * are allocated via the pool allocator, and we use KSEG to
    418  1.1   simonb 	 * map those pages.
    419  1.1   simonb 	 */
    420  1.1   simonb 
    421  1.1   simonb #ifdef DEBUG
    422  1.1   simonb 	pmapdebug = opmapdebug;
    423  1.1   simonb #endif
    424  1.1   simonb 	format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
    425  1.1   simonb 	printf("avail memory = %s\n", pbuf);
    426  1.7  thorpej 	format_bytes(pbuf, sizeof(pbuf), bufpages * PAGE_SIZE);
    427  1.3  thorpej 	printf("using %u buffers containing %s of memory\n", nbuf, pbuf);
    428  1.1   simonb 
    429  1.1   simonb 	/*
    430  1.1   simonb 	 * Set up buffers, so they can be used to read disklabels.
    431  1.1   simonb 	 */
    432  1.1   simonb 	bufinit();
    433  1.1   simonb 
    434  1.1   simonb 	/*
    435  1.1   simonb 	 * Set up the chip/board properties database.
    436  1.1   simonb 	 */
    437  1.1   simonb 	if (!(alchemy_prop_info = propdb_create("board info")))
    438  1.1   simonb 		panic("Cannot create board info database");
    439  1.1   simonb }
    440  1.1   simonb 
    441  1.1   simonb void
    442  1.1   simonb cpu_reboot(int howto, char *bootstr)
    443  1.1   simonb {
    444  1.1   simonb 	static int waittime = -1;
    445  1.1   simonb 
    446  1.1   simonb 	/* Take a snapshot before clobbering any registers. */
    447  1.1   simonb 	if (curproc)
    448  1.1   simonb 		savectx((struct user *)curpcb);
    449  1.1   simonb 
    450  1.1   simonb 	/* If "always halt" was specified as a boot flag, obey. */
    451  1.1   simonb 	if (boothowto & RB_HALT)
    452  1.1   simonb 		howto |= RB_HALT;
    453  1.1   simonb 
    454  1.1   simonb 	boothowto = howto;
    455  1.1   simonb 
    456  1.1   simonb 	/* If system is cold, just halt. */
    457  1.1   simonb 	if (cold) {
    458  1.1   simonb 		boothowto |= RB_HALT;
    459  1.1   simonb 		goto haltsys;
    460  1.1   simonb 	}
    461  1.1   simonb 
    462  1.1   simonb 	if ((boothowto & RB_NOSYNC) == 0 && waittime < 0) {
    463  1.1   simonb 		waittime = 0;
    464  1.1   simonb 
    465  1.1   simonb 		/*
    466  1.1   simonb 		 * Synchronize the disks....
    467  1.1   simonb 		 */
    468  1.1   simonb 		vfs_shutdown();
    469  1.1   simonb 
    470  1.1   simonb 		/*
    471  1.1   simonb 		 * If we've been adjusting the clock, the todr
    472  1.1   simonb 		 * will be out of synch; adjust it now.
    473  1.1   simonb 		 */
    474  1.1   simonb 		resettodr();
    475  1.1   simonb 	}
    476  1.1   simonb 
    477  1.1   simonb 	/* Disable interrupts. */
    478  1.1   simonb 	splhigh();
    479  1.1   simonb 
    480  1.1   simonb 	if (boothowto & RB_DUMP)
    481  1.1   simonb 		dumpsys();
    482  1.1   simonb 
    483  1.1   simonb  haltsys:
    484  1.1   simonb 	/* Run any shutdown hooks. */
    485  1.1   simonb 	doshutdownhooks();
    486  1.1   simonb 
    487  1.1   simonb #if 1
    488  1.1   simonb 	/* XXX
    489  1.1   simonb 	 * For some reason we are leaving the ethernet MAC in a state where
    490  1.1   simonb 	 * YAMON isn't happy with it.  So just call the reset vector (grr,
    491  1.1   simonb 	 * Alchemy YAMON doesn't have a "reset" command).
    492  1.1   simonb 	 */
    493  1.1   simonb 	printf("reseting board...\n\n");
    494  1.1   simonb 	mips_icache_sync_all();
    495  1.1   simonb 	mips_dcache_wbinv_all();
    496  1.1   simonb 	asm volatile("jr	%0" :: "r"(MIPS_RESET_EXC_VEC));
    497  1.1   simonb #else
    498  1.1   simonb 	printf("%s\n\n", ((howto & RB_HALT) != 0) ? "halted." : "rebooting...");
    499  1.1   simonb 	yamon_exit(boothowto);
    500  1.1   simonb 	printf("Oops, back from yamon_exit()\n\nSpinning...");
    501  1.1   simonb #endif
    502  1.1   simonb 	for (;;)
    503  1.1   simonb 		/* spin forever */ ;	/* XXX */
    504  1.1   simonb 	/*NOTREACHED*/
    505  1.1   simonb }
    506