Home | History | Annotate | Line # | Download | only in alchemy
machdep.c revision 1.51
      1  1.51      matt /* $NetBSD: machdep.c,v 1.51 2011/07/10 00:03:52 matt Exp $ */
      2   1.1    simonb 
      3  1.24   gdamore /*-
      4  1.24   gdamore  * Copyright (c) 2006 Itronix Inc.
      5  1.24   gdamore  * All rights reserved.
      6  1.24   gdamore  *
      7  1.24   gdamore  * Portions written by Garrett D'Amore for Itronix Inc.
      8  1.24   gdamore  *
      9  1.24   gdamore  * Redistribution and use in source and binary forms, with or without
     10  1.24   gdamore  * modification, are permitted provided that the following conditions
     11  1.24   gdamore  * are met:
     12  1.24   gdamore  * 1. Redistributions of source code must retain the above copyright
     13  1.24   gdamore  *    notice, this list of conditions and the following disclaimer.
     14  1.24   gdamore  * 2. Redistributions in binary form must reproduce the above copyright
     15  1.24   gdamore  *    notice, this list of conditions and the following disclaimer in the
     16  1.24   gdamore  *    documentation and/or other materials provided with the distribution.
     17  1.24   gdamore  * 3. The name of Itronix Inc. may not be used to endorse
     18  1.24   gdamore  *    or promote products derived from this software without specific
     19  1.24   gdamore  *    prior written permission.
     20  1.24   gdamore  *
     21  1.24   gdamore  * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND
     22  1.24   gdamore  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     23  1.24   gdamore  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     24  1.24   gdamore  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY
     25  1.24   gdamore  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     26  1.24   gdamore  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     27  1.24   gdamore  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     28  1.24   gdamore  * ON ANY THEORY OF LIABILITY, WHETHER IN
     29  1.24   gdamore  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     30  1.24   gdamore  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     31  1.24   gdamore  * POSSIBILITY OF SUCH DAMAGE.
     32  1.24   gdamore  */
     33  1.48     rmind 
     34   1.1    simonb /*
     35  1.48     rmind  * Copyright (c) 1988 University of Utah.
     36   1.1    simonb  * Copyright (c) 1992, 1993
     37   1.1    simonb  *	The Regents of the University of California.  All rights reserved.
     38   1.1    simonb  *
     39   1.1    simonb  * This code is derived from software contributed to Berkeley by
     40   1.1    simonb  * the Systems Programming Group of the University of Utah Computer
     41   1.1    simonb  * Science Department, The Mach Operating System project at
     42   1.1    simonb  * Carnegie-Mellon University and Ralph Campbell.
     43   1.1    simonb  *
     44   1.1    simonb  * Redistribution and use in source and binary forms, with or without
     45   1.1    simonb  * modification, are permitted provided that the following conditions
     46   1.1    simonb  * are met:
     47   1.1    simonb  * 1. Redistributions of source code must retain the above copyright
     48   1.1    simonb  *    notice, this list of conditions and the following disclaimer.
     49   1.1    simonb  * 2. Redistributions in binary form must reproduce the above copyright
     50   1.1    simonb  *    notice, this list of conditions and the following disclaimer in the
     51   1.1    simonb  *    documentation and/or other materials provided with the distribution.
     52  1.11       agc  * 3. Neither the name of the University nor the names of its contributors
     53  1.11       agc  *    may be used to endorse or promote products derived from this software
     54  1.11       agc  *    without specific prior written permission.
     55  1.11       agc  *
     56  1.11       agc  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     57  1.11       agc  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     58  1.11       agc  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     59  1.11       agc  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     60  1.11       agc  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     61  1.11       agc  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     62  1.11       agc  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     63  1.11       agc  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     64  1.11       agc  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     65  1.11       agc  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     66  1.11       agc  * SUCH DAMAGE.
     67  1.11       agc  *
     68  1.11       agc  *	@(#)machdep.c	8.3 (Berkeley) 1/12/94
     69  1.11       agc  * 	from: Utah Hdr: machdep.c 1.63 91/04/24
     70  1.11       agc  */
     71   1.1    simonb 
     72  1.48     rmind #include <sys/cdefs.h>
     73  1.51      matt __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.51 2011/07/10 00:03:52 matt Exp $");
     74   1.1    simonb 
     75   1.1    simonb #include "opt_ddb.h"
     76   1.1    simonb #include "opt_kgdb.h"
     77   1.1    simonb 
     78   1.1    simonb #include "opt_memsize.h"
     79  1.41       apb #include "opt_modular.h"
     80   1.1    simonb #include "opt_ethaddr.h"
     81   1.1    simonb 
     82   1.1    simonb #include <sys/param.h>
     83  1.51      matt #include <sys/boot_flag.h>
     84  1.51      matt #include <sys/buf.h>
     85  1.51      matt #include <sys/device.h>
     86  1.51      matt #include <sys/kcore.h>
     87   1.1    simonb #include <sys/kernel.h>
     88  1.51      matt #include <sys/ksyms.h>
     89  1.51      matt #include <sys/mount.h>
     90   1.1    simonb #include <sys/reboot.h>
     91  1.51      matt #include <sys/systm.h>
     92   1.1    simonb #include <sys/termios.h>
     93   1.1    simonb 
     94   1.1    simonb #include <net/if.h>
     95   1.1    simonb #include <net/if_ether.h>
     96   1.1    simonb 
     97   1.1    simonb #include <uvm/uvm_extern.h>
     98   1.1    simonb 
     99   1.1    simonb #include <dev/cons.h>
    100   1.1    simonb 
    101   1.8     ragge #include "ksyms.h"
    102   1.8     ragge 
    103  1.39        ad #if NKSYMS || defined(DDB) || defined(MODULAR)
    104  1.51      matt #include <mips/db_machdep.h>
    105   1.1    simonb #include <ddb/db_extern.h>
    106   1.1    simonb #endif
    107   1.1    simonb 
    108   1.1    simonb #include <mips/cache.h>
    109   1.1    simonb #include <mips/locore.h>
    110  1.51      matt 
    111   1.1    simonb #include <machine/yamon.h>
    112   1.1    simonb 
    113  1.24   gdamore #include <evbmips/alchemy/board.h>
    114  1.51      matt 
    115  1.25   gdamore #include <mips/alchemy/dev/aupcivar.h>
    116  1.27   gdamore #include <mips/alchemy/dev/aupcmciavar.h>
    117  1.31   gdamore #include <mips/alchemy/dev/auspivar.h>
    118   1.1    simonb #include <mips/alchemy/include/aureg.h>
    119   1.1    simonb #include <mips/alchemy/include/auvar.h>
    120   1.1    simonb #include <mips/alchemy/include/aubusvar.h>
    121   1.1    simonb 
    122  1.29   gdamore #include "com.h"
    123  1.29   gdamore #if NCOM > 0
    124   1.1    simonb 
    125  1.20  christos int	aucomcnrate = 0;
    126   1.1    simonb #endif /* NAUCOM > 0 */
    127   1.1    simonb 
    128   1.6   hpeyerl #include "ohci.h"
    129   1.6   hpeyerl 
    130   1.1    simonb /* Maps for VM objects. */
    131   1.1    simonb struct vm_map *phys_map = NULL;
    132   1.1    simonb 
    133  1.49      matt int physmem;			/* # pages of physical memory */
    134   1.1    simonb int maxmem;			/* max memory per process */
    135   1.1    simonb 
    136   1.1    simonb int mem_cluster_cnt;
    137   1.1    simonb phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX];
    138   1.1    simonb 
    139   1.1    simonb yamon_env_var *yamon_envp;
    140  1.24   gdamore struct mips_bus_space alchemy_cpuregt;
    141   1.1    simonb 
    142   1.1    simonb void	mach_init(int, char **, yamon_env_var *, u_long); /* XXX */
    143   1.1    simonb 
    144   1.1    simonb void
    145   1.1    simonb mach_init(int argc, char **argv, yamon_env_var *envp, u_long memsize)
    146   1.1    simonb {
    147   1.1    simonb 	bus_space_handle_t sh;
    148  1.33  christos 	void *kernend;
    149   1.1    simonb 	const char *cp;
    150  1.13    simonb 	int freqok, howto, i;
    151  1.24   gdamore 	const struct alchemy_board *board;
    152   1.1    simonb 
    153   1.1    simonb 	extern char edata[], end[];	/* XXX */
    154   1.1    simonb 
    155  1.24   gdamore 	board = board_info();
    156  1.24   gdamore 	KASSERT(board != NULL);
    157  1.24   gdamore 
    158   1.1    simonb 	/* clear the BSS segment */
    159  1.33  christos 	kernend = (void *)mips_round_page(end);
    160  1.34    simonb 	memset(edata, 0, (char *)kernend - edata);
    161   1.1    simonb 
    162  1.16       wiz 	/* set CPU model info for sysctl_hw */
    163  1.24   gdamore 	strcpy(cpu_model, board->ab_name);
    164   1.2    simonb 
    165   1.1    simonb 	/* save the yamon environment pointer */
    166   1.1    simonb 	yamon_envp = envp;
    167   1.1    simonb 
    168   1.1    simonb 	/* Use YAMON callbacks for early console I/O */
    169   1.1    simonb 	cn_tab = &yamon_promcd;
    170   1.1    simonb 
    171   1.1    simonb 	/*
    172  1.16       wiz 	 * Set up the exception vectors and CPU-specific function
    173   1.1    simonb 	 * vectors early on.  We need the wbflush() vector set up
    174   1.1    simonb 	 * before comcnattach() is called (or at least before the
    175   1.1    simonb 	 * first printf() after that is called).
    176  1.13    simonb 	 * Sets up mips_cpu_flags that may be queried by other
    177  1.13    simonb 	 * functions called during startup.
    178   1.1    simonb 	 * Also clears the I+D caches.
    179   1.1    simonb 	 */
    180  1.49      matt 	mips_vector_init(NULL, false);
    181   1.1    simonb 
    182   1.1    simonb 	/*
    183   1.1    simonb 	 * Set the VM page size.
    184   1.1    simonb 	 */
    185   1.1    simonb 	uvm_setpagesize();
    186   1.1    simonb 
    187   1.1    simonb 	/*
    188  1.13    simonb 	 * Use YAMON's CPU frequency if available.
    189  1.13    simonb 	 */
    190  1.13    simonb 	freqok = yamon_setcpufreq(1);
    191  1.13    simonb 
    192  1.13    simonb 	/*
    193   1.1    simonb 	 * Initialize bus space tags.
    194   1.1    simonb 	 */
    195  1.24   gdamore 	au_cpureg_bus_mem_init(&alchemy_cpuregt, &alchemy_cpuregt);
    196  1.24   gdamore 	aubus_st = &alchemy_cpuregt;
    197   1.1    simonb 
    198   1.1    simonb 	/*
    199  1.13    simonb 	 * Calibrate the timer if YAMON failed to tell us.
    200   1.1    simonb 	 */
    201  1.13    simonb 	if (!freqok) {
    202  1.24   gdamore 		bus_space_map(aubus_st, PC_BASE, PC_SIZE, 0, &sh);
    203  1.24   gdamore 		au_cal_timers(aubus_st, sh);
    204  1.24   gdamore 		bus_space_unmap(aubus_st, sh, PC_SIZE);
    205  1.13    simonb 	}
    206   1.1    simonb 
    207   1.1    simonb 	/*
    208  1.24   gdamore 	 * Perform board-specific initialization.
    209  1.24   gdamore 	 */
    210  1.24   gdamore 	board->ab_init();
    211  1.24   gdamore 
    212  1.24   gdamore 	/*
    213   1.1    simonb 	 * Bring up the console.
    214   1.1    simonb 	 */
    215  1.29   gdamore #if NCOM > 0
    216  1.20  christos #ifdef CONSPEED
    217  1.20  christos 	if (aucomcnrate == 0)
    218  1.20  christos 		aucomcnrate = CONSPEED;
    219  1.20  christos #else /* !CONSPEED */
    220  1.20  christos 	/*
    221  1.20  christos 	 * Learn default console speed.  We use the YAMON environment,
    222  1.20  christos 	 * though we could probably also figure it out by checking the
    223  1.20  christos 	 * aucom registers directly.
    224  1.20  christos 	 */
    225  1.20  christos 	if ((aucomcnrate == 0) && ((cp = yamon_getenv("modetty0")) != NULL))
    226  1.20  christos 		aucomcnrate = strtoul(cp, NULL, 0);
    227  1.20  christos 
    228  1.20  christos 	if (aucomcnrate == 0) {
    229  1.24   gdamore 		printf("FATAL: `modetty0' YAMON variable not set.  Set it\n");
    230  1.24   gdamore 		printf("       to the speed of the console and try again.\n");
    231  1.24   gdamore 		printf("       Or, build a kernel with the `CONSPEED' "
    232  1.24   gdamore 		    "option.\n");
    233  1.24   gdamore 		panic("mach_init");
    234  1.20  christos 	}
    235  1.20  christos #endif /* CONSPEED */
    236  1.20  christos 
    237   1.1    simonb 	/*
    238   1.1    simonb 	 * Delay to allow firmware putchars to complete.
    239   1.1    simonb 	 * FIFO depth * character time.
    240   1.1    simonb 	 * character time = (1000000 / (defaultrate / 10))
    241   1.1    simonb 	 */
    242   1.1    simonb 	delay(160000000 / aucomcnrate);
    243  1.29   gdamore 	if (com_aubus_cnattach(UART0_BASE, aucomcnrate) != 0)
    244  1.24   gdamore 		panic("mach_init: unable to initialize serial console");
    245  1.29   gdamore 
    246  1.29   gdamore #else /* NCOM > 0 */
    247  1.24   gdamore 	panic("mach_init: not configured to use serial console");
    248   1.1    simonb #endif /* NAUCOM > 0 */
    249   1.1    simonb 
    250   1.1    simonb 	/*
    251   1.1    simonb 	 * Look at arguments passed to us and compute boothowto.
    252   1.1    simonb 	 */
    253   1.1    simonb 	boothowto = RB_AUTOBOOT;
    254   1.1    simonb #ifdef KADB
    255   1.1    simonb 	boothowto |= RB_KDB;
    256   1.1    simonb #endif
    257   1.1    simonb 	for (i = 1; i < argc; i++) {
    258   1.1    simonb 		for (cp = argv[i]; *cp; cp++) {
    259   1.1    simonb 			/* Ignore superfluous '-', if there is one */
    260   1.1    simonb 			if (*cp == '-')
    261   1.1    simonb 				continue;
    262   1.1    simonb 
    263   1.1    simonb 			howto = 0;
    264   1.1    simonb 			BOOT_FLAG(*cp, howto);
    265   1.1    simonb 			if (! howto)
    266   1.1    simonb 				printf("bootflag '%c' not recognised\n", *cp);
    267   1.1    simonb 			else
    268   1.1    simonb 				boothowto |= howto;
    269   1.1    simonb 		}
    270   1.1    simonb 	}
    271   1.1    simonb 
    272   1.1    simonb 	/*
    273   1.1    simonb 	 * Determine the memory size.  Use the `memsize' PMON
    274   1.1    simonb 	 * variable.  If that's not available, panic.
    275   1.1    simonb 	 *
    276   1.1    simonb 	 * Note: Reserve the first page!  That's where the trap
    277   1.1    simonb 	 * vectors are located.
    278   1.1    simonb 	 */
    279   1.1    simonb 
    280   1.1    simonb #if defined(MEMSIZE)
    281   1.4       scw 	memsize = MEMSIZE;
    282   1.1    simonb #else
    283   1.1    simonb 	if (memsize == 0) {
    284   1.1    simonb 		if ((cp = yamon_getenv("memsize")) != NULL)
    285   1.1    simonb 			memsize = strtoul(cp, NULL, 0);
    286   1.1    simonb 		else {
    287   1.1    simonb 			printf("FATAL: `memsize' YAMON variable not set.  Set it to\n");
    288   1.1    simonb 			printf("       the amount of memory (in MB) and try again.\n");
    289   1.1    simonb 			printf("       Or, build a kernel with the `MEMSIZE' "
    290   1.1    simonb 			    "option.\n");
    291  1.24   gdamore 			panic("mach_init");
    292   1.1    simonb 		}
    293   1.1    simonb 	}
    294   1.1    simonb #endif /* MEMSIZE */
    295   1.1    simonb 	printf("Memory size: 0x%08lx\n", memsize);
    296   1.1    simonb 	physmem = btoc(memsize);
    297   1.1    simonb 
    298   1.7   thorpej 	mem_clusters[mem_cluster_cnt].start = PAGE_SIZE;
    299   1.1    simonb 	mem_clusters[mem_cluster_cnt].size =
    300   1.1    simonb 	    memsize - mem_clusters[mem_cluster_cnt].start;
    301   1.1    simonb 	mem_cluster_cnt++;
    302   1.1    simonb 
    303   1.1    simonb 	/*
    304   1.1    simonb 	 * Load the rest of the available pages into the VM system.
    305   1.1    simonb 	 */
    306  1.49      matt 	mips_page_physload(MIPS_KSEG0_START, (vaddr_t)kernend,
    307  1.49      matt 	    mem_clusters, mem_cluster_cnt, NULL, 0);
    308   1.1    simonb 
    309   1.1    simonb 	/*
    310   1.1    simonb 	 * Initialize message buffer (at end of core).
    311   1.1    simonb 	 */
    312   1.1    simonb 	mips_init_msgbuf();
    313   1.1    simonb 
    314   1.1    simonb 	/*
    315   1.1    simonb 	 * Initialize the virtual memory system.
    316   1.1    simonb 	 */
    317   1.1    simonb 	pmap_bootstrap();
    318   1.1    simonb 
    319   1.1    simonb 	/*
    320  1.44     rmind 	 * Allocate uarea page for lwp0 and set it.
    321   1.1    simonb 	 */
    322  1.45      matt 	mips_init_lwp0_uarea();
    323   1.1    simonb 
    324   1.1    simonb 	/*
    325   1.1    simonb 	 * Initialize debuggers, and break into them, if appropriate.
    326   1.1    simonb 	 */
    327   1.1    simonb #ifdef DDB
    328   1.1    simonb 	if (boothowto & RB_KDB)
    329   1.1    simonb 		Debugger();
    330   1.1    simonb #endif
    331   1.1    simonb }
    332   1.1    simonb 
    333   1.1    simonb void
    334   1.1    simonb consinit(void)
    335   1.1    simonb {
    336   1.1    simonb 
    337   1.1    simonb 	/*
    338   1.1    simonb 	 * Everything related to console initialization is done
    339   1.1    simonb 	 * in mach_init().
    340   1.1    simonb 	 */
    341   1.1    simonb }
    342   1.1    simonb 
    343   1.1    simonb void
    344   1.1    simonb cpu_startup(void)
    345   1.1    simonb {
    346   1.1    simonb 	char pbuf[9];
    347   1.1    simonb 	vaddr_t minaddr, maxaddr;
    348   1.1    simonb #ifdef DEBUG
    349   1.1    simonb 	extern int pmapdebug;		/* XXX */
    350   1.1    simonb 	int opmapdebug = pmapdebug;
    351   1.1    simonb 
    352   1.1    simonb 	pmapdebug = 0;		/* Shut up pmap debug during bootstrap */
    353   1.1    simonb #endif
    354   1.1    simonb 
    355   1.1    simonb 	/*
    356   1.1    simonb 	 * Good {morning,afternoon,evening,night}.
    357   1.1    simonb 	 */
    358  1.18     lukem 	printf("%s%s", copyright, version);
    359   1.1    simonb 	printf("%s\n", cpu_model);
    360   1.1    simonb 	format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
    361   1.1    simonb 	printf("total memory = %s\n", pbuf);
    362   1.1    simonb 
    363  1.15        pk 	minaddr = 0;
    364   1.1    simonb 
    365   1.1    simonb 	/*
    366   1.1    simonb 	 * Allocate a submap for physio
    367   1.1    simonb 	 */
    368   1.1    simonb 	phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
    369  1.32   thorpej 	    VM_PHYS_SIZE, 0, false, NULL);
    370   1.1    simonb 
    371   1.1    simonb 	/*
    372   1.1    simonb 	 * No need to allocate an mbuf cluster submap.  Mbuf clusters
    373   1.1    simonb 	 * are allocated via the pool allocator, and we use KSEG to
    374   1.1    simonb 	 * map those pages.
    375   1.1    simonb 	 */
    376   1.1    simonb 
    377   1.1    simonb #ifdef DEBUG
    378   1.1    simonb 	pmapdebug = opmapdebug;
    379   1.1    simonb #endif
    380   1.1    simonb 	format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
    381   1.1    simonb 	printf("avail memory = %s\n", pbuf);
    382   1.1    simonb }
    383   1.1    simonb 
    384   1.1    simonb void
    385   1.1    simonb cpu_reboot(int howto, char *bootstr)
    386   1.1    simonb {
    387   1.1    simonb 	static int waittime = -1;
    388  1.26   gdamore 	const struct alchemy_board *board;
    389   1.1    simonb 
    390   1.1    simonb 	/* Take a snapshot before clobbering any registers. */
    391  1.49      matt 	savectx(curpcb);
    392   1.1    simonb 
    393  1.26   gdamore 	board = board_info();
    394  1.26   gdamore 	KASSERT(board != NULL);
    395  1.26   gdamore 
    396   1.1    simonb 	/* If "always halt" was specified as a boot flag, obey. */
    397   1.1    simonb 	if (boothowto & RB_HALT)
    398   1.1    simonb 		howto |= RB_HALT;
    399   1.1    simonb 
    400   1.1    simonb 	boothowto = howto;
    401   1.1    simonb 
    402   1.1    simonb 	/* If system is cold, just halt. */
    403   1.1    simonb 	if (cold) {
    404   1.1    simonb 		boothowto |= RB_HALT;
    405   1.1    simonb 		goto haltsys;
    406   1.1    simonb 	}
    407   1.1    simonb 
    408   1.1    simonb 	if ((boothowto & RB_NOSYNC) == 0 && waittime < 0) {
    409   1.1    simonb 		waittime = 0;
    410   1.1    simonb 
    411   1.1    simonb 		/*
    412   1.1    simonb 		 * Synchronize the disks....
    413   1.1    simonb 		 */
    414   1.1    simonb 		vfs_shutdown();
    415   1.1    simonb 
    416   1.1    simonb 		/*
    417   1.1    simonb 		 * If we've been adjusting the clock, the todr
    418   1.1    simonb 		 * will be out of synch; adjust it now.
    419   1.1    simonb 		 */
    420   1.1    simonb 		resettodr();
    421   1.1    simonb 	}
    422   1.1    simonb 
    423   1.1    simonb 	/* Disable interrupts. */
    424   1.1    simonb 	splhigh();
    425   1.1    simonb 
    426   1.1    simonb 	if (boothowto & RB_DUMP)
    427   1.1    simonb 		dumpsys();
    428   1.1    simonb 
    429   1.1    simonb  haltsys:
    430   1.1    simonb 	/* Run any shutdown hooks. */
    431   1.1    simonb 	doshutdownhooks();
    432   1.1    simonb 
    433  1.38    dyoung 	pmf_system_shutdown(boothowto);
    434  1.38    dyoung 
    435  1.26   gdamore 	if ((boothowto & RB_POWERDOWN) == RB_POWERDOWN)
    436  1.26   gdamore 		if (board && board->ab_poweroff)
    437  1.26   gdamore 			board->ab_poweroff();
    438  1.26   gdamore 
    439  1.26   gdamore 	/*
    440  1.26   gdamore 	 * YAMON may autoboot (depending on settings), and we cannot pass
    441  1.26   gdamore 	 * flags to it (at least I haven't figured out how to yet), so
    442  1.26   gdamore 	 * we "pseudo-halt" now.
    443  1.26   gdamore 	 */
    444  1.26   gdamore 	if (boothowto & RB_HALT) {
    445  1.26   gdamore 		printf("\n");
    446  1.26   gdamore 		printf("The operating system has halted.\n");
    447  1.26   gdamore 		printf("Please press any key to reboot.\n\n");
    448  1.26   gdamore 		cnpollc(1);	/* For proper keyboard command handling */
    449  1.26   gdamore 		cngetc();
    450  1.26   gdamore 		cnpollc(0);
    451  1.26   gdamore 	}
    452  1.26   gdamore 
    453  1.30    simonb 	printf("reseting board...\n\n");
    454  1.30    simonb 
    455  1.26   gdamore 	/*
    456  1.26   gdamore 	 * Try to use board-specific reset logic, which might involve a better
    457  1.26   gdamore 	 * hardware reset.
    458  1.26   gdamore 	 */
    459  1.26   gdamore 	if (board->ab_reboot)
    460  1.26   gdamore 		board->ab_reboot();
    461  1.26   gdamore 
    462   1.1    simonb #if 1
    463   1.1    simonb 	/* XXX
    464   1.1    simonb 	 * For some reason we are leaving the ethernet MAC in a state where
    465   1.1    simonb 	 * YAMON isn't happy with it.  So just call the reset vector (grr,
    466   1.1    simonb 	 * Alchemy YAMON doesn't have a "reset" command).
    467   1.1    simonb 	 */
    468   1.1    simonb 	mips_icache_sync_all();
    469   1.1    simonb 	mips_dcache_wbinv_all();
    470  1.21     perry 	__asm volatile("jr	%0" :: "r"(MIPS_RESET_EXC_VEC));
    471   1.1    simonb #else
    472   1.1    simonb 	printf("%s\n\n", ((howto & RB_HALT) != 0) ? "halted." : "rebooting...");
    473   1.1    simonb 	yamon_exit(boothowto);
    474   1.1    simonb 	printf("Oops, back from yamon_exit()\n\nSpinning...");
    475   1.1    simonb #endif
    476   1.1    simonb 	for (;;)
    477   1.1    simonb 		/* spin forever */ ;	/* XXX */
    478   1.1    simonb 	/*NOTREACHED*/
    479   1.1    simonb }
    480  1.24   gdamore 
    481  1.25   gdamore /*
    482  1.25   gdamore  * Export our interrupt map function so aupci can find it.
    483  1.25   gdamore  */
    484  1.24   gdamore int
    485  1.50    dyoung aupci_intr_map(const struct pci_attach_args *pa, pci_intr_handle_t *ihp)
    486  1.24   gdamore {
    487  1.25   gdamore 	const struct alchemy_board *board;
    488  1.24   gdamore 
    489  1.24   gdamore 	board = board_info();
    490  1.24   gdamore 	if (board->ab_pci_intr_map != NULL)
    491  1.24   gdamore 		return (board->ab_pci_intr_map(pa, ihp));
    492  1.25   gdamore 	return 1;
    493  1.24   gdamore }
    494  1.27   gdamore 
    495  1.27   gdamore struct aupcmcia_machdep *
    496  1.27   gdamore aupcmcia_machdep(void)
    497  1.27   gdamore {
    498  1.27   gdamore 	const struct alchemy_board *board;
    499  1.27   gdamore 
    500  1.27   gdamore 	board = board_info();
    501  1.27   gdamore 	return (board->ab_pcmcia);
    502  1.27   gdamore }
    503  1.31   gdamore 
    504  1.31   gdamore const struct auspi_machdep *
    505  1.31   gdamore auspi_machdep(bus_addr_t ba)
    506  1.31   gdamore {
    507  1.31   gdamore 	const struct alchemy_board *board;
    508  1.31   gdamore 
    509  1.31   gdamore 	board = board_info();
    510  1.31   gdamore 	if (board->ab_spi != NULL)
    511  1.31   gdamore 		return (board->ab_spi(ba));
    512  1.31   gdamore 	return NULL;
    513  1.31   gdamore }
    514