Home | History | Annotate | Line # | Download | only in malta
machdep.c revision 1.28.10.10
      1  1.28.10.10      matt /*	machdep.c,v 1.28.10.9 2011/04/29 08:26:18 matt Exp	*/
      2         1.1    simonb 
      3         1.1    simonb /*
      4         1.1    simonb  * Copyright 2001, 2002 Wasabi Systems, Inc.
      5         1.1    simonb  * All rights reserved.
      6         1.1    simonb  *
      7         1.1    simonb  * Written by Jason R. Thorpe and Simon Burge for Wasabi Systems, Inc.
      8         1.1    simonb  *
      9         1.1    simonb  * Redistribution and use in source and binary forms, with or without
     10         1.1    simonb  * modification, are permitted provided that the following conditions
     11         1.1    simonb  * are met:
     12         1.1    simonb  * 1. Redistributions of source code must retain the above copyright
     13         1.1    simonb  *    notice, this list of conditions and the following disclaimer.
     14         1.1    simonb  * 2. Redistributions in binary form must reproduce the above copyright
     15         1.1    simonb  *    notice, this list of conditions and the following disclaimer in the
     16         1.1    simonb  *    documentation and/or other materials provided with the distribution.
     17         1.1    simonb  * 3. All advertising materials mentioning features or use of this software
     18         1.1    simonb  *    must display the following acknowledgement:
     19         1.1    simonb  *      This product includes software developed for the NetBSD Project by
     20         1.1    simonb  *      Wasabi Systems, Inc.
     21         1.1    simonb  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
     22         1.1    simonb  *    or promote products derived from this software without specific prior
     23         1.1    simonb  *    written permission.
     24         1.1    simonb  *
     25         1.1    simonb  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
     26         1.1    simonb  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     27         1.1    simonb  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     28         1.1    simonb  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
     29         1.1    simonb  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30         1.1    simonb  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     31         1.1    simonb  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     32         1.1    simonb  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     33         1.1    simonb  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     34         1.1    simonb  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     35         1.1    simonb  * POSSIBILITY OF SUCH DAMAGE.
     36         1.1    simonb  */
     37         1.1    simonb 
     38         1.1    simonb /*
     39         1.1    simonb  * Copyright (c) 1992, 1993
     40         1.1    simonb  *	The Regents of the University of California.  All rights reserved.
     41         1.1    simonb  *
     42         1.1    simonb  * This code is derived from software contributed to Berkeley by
     43         1.1    simonb  * the Systems Programming Group of the University of Utah Computer
     44         1.1    simonb  * Science Department, The Mach Operating System project at
     45         1.1    simonb  * Carnegie-Mellon University and Ralph Campbell.
     46         1.1    simonb  *
     47         1.1    simonb  * Redistribution and use in source and binary forms, with or without
     48         1.1    simonb  * modification, are permitted provided that the following conditions
     49         1.1    simonb  * are met:
     50         1.1    simonb  * 1. Redistributions of source code must retain the above copyright
     51         1.1    simonb  *    notice, this list of conditions and the following disclaimer.
     52         1.1    simonb  * 2. Redistributions in binary form must reproduce the above copyright
     53         1.1    simonb  *    notice, this list of conditions and the following disclaimer in the
     54         1.1    simonb  *    documentation and/or other materials provided with the distribution.
     55        1.13       agc  * 3. Neither the name of the University nor the names of its contributors
     56        1.13       agc  *    may be used to endorse or promote products derived from this software
     57        1.13       agc  *    without specific prior written permission.
     58        1.13       agc  *
     59        1.13       agc  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     60        1.13       agc  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     61        1.13       agc  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     62        1.13       agc  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     63        1.13       agc  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     64        1.13       agc  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     65        1.13       agc  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     66        1.13       agc  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     67        1.13       agc  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     68        1.13       agc  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     69        1.13       agc  * SUCH DAMAGE.
     70        1.13       agc  *
     71        1.13       agc  *	@(#)machdep.c   8.3 (Berkeley) 1/12/94
     72        1.13       agc  *	from: Utah Hdr: machdep.c 1.63 91/04/24
     73        1.13       agc  */
     74        1.13       agc /*
     75        1.13       agc  * Copyright (c) 1988 University of Utah.
     76        1.13       agc  *
     77        1.13       agc  * This code is derived from software contributed to Berkeley by
     78        1.13       agc  * the Systems Programming Group of the University of Utah Computer
     79        1.13       agc  * Science Department, The Mach Operating System project at
     80        1.13       agc  * Carnegie-Mellon University and Ralph Campbell.
     81        1.13       agc  *
     82        1.13       agc  * Redistribution and use in source and binary forms, with or without
     83        1.13       agc  * modification, are permitted provided that the following conditions
     84        1.13       agc  * are met:
     85        1.13       agc  * 1. Redistributions of source code must retain the above copyright
     86        1.13       agc  *    notice, this list of conditions and the following disclaimer.
     87        1.13       agc  * 2. Redistributions in binary form must reproduce the above copyright
     88        1.13       agc  *    notice, this list of conditions and the following disclaimer in the
     89        1.13       agc  *    documentation and/or other materials provided with the distribution.
     90         1.1    simonb  * 3. All advertising materials mentioning features or use of this software
     91         1.1    simonb  *    must display the following acknowledgement:
     92         1.1    simonb  *	This product includes software developed by the University of
     93         1.1    simonb  *	California, Berkeley and its contributors.
     94         1.1    simonb  * 4. Neither the name of the University nor the names of its contributors
     95         1.1    simonb  *    may be used to endorse or promote products derived from this software
     96         1.1    simonb  *    without specific prior written permission.
     97         1.1    simonb  *
     98         1.1    simonb  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     99         1.1    simonb  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    100         1.1    simonb  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    101         1.1    simonb  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
    102         1.1    simonb  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    103         1.1    simonb  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    104         1.1    simonb  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    105         1.1    simonb  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    106         1.1    simonb  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    107         1.1    simonb  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    108         1.1    simonb  * SUCH DAMAGE.
    109         1.1    simonb  *
    110         1.1    simonb  *	@(#)machdep.c   8.3 (Berkeley) 1/12/94
    111         1.1    simonb  *	from: Utah Hdr: machdep.c 1.63 91/04/24
    112         1.1    simonb  */
    113        1.12     lukem 
    114        1.12     lukem #include <sys/cdefs.h>
    115  1.28.10.10      matt __KERNEL_RCSID(0, "machdep.c,v 1.28.10.9 2011/04/29 08:26:18 matt Exp");
    116         1.1    simonb 
    117         1.1    simonb #include "opt_ddb.h"
    118         1.1    simonb #include "opt_execfmt.h"
    119         1.1    simonb 
    120         1.1    simonb #include <sys/param.h>
    121         1.1    simonb #include <sys/systm.h>
    122         1.1    simonb #include <sys/kernel.h>
    123         1.1    simonb #include <sys/buf.h>
    124         1.1    simonb #include <sys/reboot.h>
    125         1.1    simonb #include <sys/user.h>
    126         1.1    simonb #include <sys/mount.h>
    127         1.1    simonb #include <sys/kcore.h>
    128         1.1    simonb #include <sys/boot_flag.h>
    129         1.1    simonb #include <sys/termios.h>
    130        1.10     ragge #include <sys/ksyms.h>
    131   1.28.10.9      matt #include <sys/lwp.h>
    132         1.1    simonb 
    133         1.1    simonb #include <uvm/uvm_extern.h>
    134         1.1    simonb 
    135         1.1    simonb #include <dev/cons.h>
    136         1.1    simonb 
    137        1.10     ragge #include "ksyms.h"
    138        1.10     ragge 
    139        1.10     ragge #if NKSYMS || defined(DDB) || defined(LKM)
    140         1.1    simonb #include <machine/db_machdep.h>
    141         1.1    simonb #include <ddb/db_extern.h>
    142         1.1    simonb #endif
    143         1.1    simonb 
    144         1.1    simonb #include <machine/cpu.h>
    145         1.1    simonb #include <machine/psl.h>
    146         1.1    simonb #include <machine/yamon.h>
    147         1.1    simonb 
    148   1.28.10.5      matt #include <mips/locore.h>
    149   1.28.10.5      matt 
    150         1.1    simonb #include <evbmips/malta/autoconf.h>
    151         1.1    simonb #include <evbmips/malta/maltareg.h>
    152         1.1    simonb #include <evbmips/malta/maltavar.h>
    153         1.1    simonb 
    154         1.1    simonb #include "com.h"
    155         1.1    simonb #if NCOM > 0
    156         1.1    simonb #include <dev/ic/comreg.h>
    157         1.1    simonb #include <dev/ic/comvar.h>
    158         1.1    simonb 
    159         1.1    simonb int	comcnrate = 38400;	/* XXX should be config option */
    160         1.1    simonb #endif /* NCOM > 0 */
    161         1.1    simonb 
    162         1.1    simonb 
    163        1.22     perry #define REGVAL(x)       *((volatile u_int32_t *)(MIPS_PHYS_TO_KSEG1((x))))
    164         1.1    simonb 
    165         1.1    simonb struct malta_config malta_configuration;
    166         1.1    simonb 
    167         1.5  gmcgarry /* For sysctl_hw. */
    168         1.6    simonb extern char cpu_model[];
    169         1.1    simonb 
    170         1.1    simonb /* Maps for VM objects. */
    171         1.1    simonb struct vm_map *mb_map = NULL;
    172         1.1    simonb struct vm_map *phys_map = NULL;
    173         1.1    simonb 
    174         1.1    simonb int	physmem;		/* Total physical memory */
    175         1.1    simonb 
    176         1.1    simonb int	netboot;		/* Are we netbooting? */
    177         1.1    simonb 
    178         1.1    simonb yamon_env_var *yamon_envp;
    179         1.1    simonb 
    180         1.1    simonb phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX];
    181  1.28.10.10      matt u_int mem_cluster_cnt;
    182         1.1    simonb 
    183         1.1    simonb void	configure(void);
    184         1.1    simonb void	mach_init(int, char **, yamon_env_var *, u_long);
    185         1.1    simonb 
    186         1.1    simonb /*
    187         1.1    simonb  * Do all the stuff that locore normally does before calling main().
    188         1.1    simonb  */
    189         1.1    simonb void
    190         1.1    simonb mach_init(int argc, char **argv, yamon_env_var *envp, u_long memsize)
    191         1.1    simonb {
    192         1.1    simonb 	struct malta_config *mcp = &malta_configuration;
    193   1.28.10.3      matt 	uint8_t * const brkres = (uint8_t *)MIPS_PHYS_TO_KSEG1(MALTA_BRKRES);
    194         1.1    simonb 	bus_space_handle_t sh;
    195   1.28.10.3      matt 	void *kernend;
    196   1.28.10.1      matt 	int freqok;
    197         1.1    simonb 
    198         1.1    simonb 	extern char edata[], end[];
    199         1.1    simonb 
    200   1.28.10.1      matt 	CTASSERT((intptr_t)MIPS_PHYS_TO_KSEG1(MALTA_BRKRES) < 0);
    201   1.28.10.1      matt 
    202         1.1    simonb 	*brkres = 0;	/* Disable BREAK==reset on console */
    203         1.1    simonb 
    204         1.1    simonb 	/* Get the propaganda in early! */
    205         1.1    simonb 	led_display_str("NetBSD");
    206         1.1    simonb 
    207         1.1    simonb 	/*
    208         1.1    simonb 	 * Clear the BSS segment.
    209         1.1    simonb 	 */
    210        1.23  christos 	kernend = (void *)mips_round_page(end);
    211        1.25    simonb 	memset(edata, 0, (char *)kernend - edata);
    212         1.1    simonb 
    213         1.1    simonb 	/* save the yamon environment pointer */
    214         1.1    simonb 	yamon_envp = envp;
    215         1.1    simonb 
    216         1.1    simonb 	/* Use YAMON callbacks for early console I/O */
    217         1.1    simonb 	cn_tab = &yamon_promcd;
    218         1.1    simonb 
    219         1.2    simonb 	/*
    220        1.18       wiz 	 * Set up the exception vectors and CPU-specific function
    221         1.2    simonb 	 * vectors early on.  We need the wbflush() vector set up
    222         1.2    simonb 	 * before comcnattach() is called (or at least before the
    223         1.2    simonb 	 * first printf() after that is called).
    224         1.2    simonb 	 * Also clears the I+D caches.
    225         1.2    simonb 	 */
    226   1.28.10.9      matt 	mips_vector_init(NULL, false);
    227         1.2    simonb 
    228         1.4    simonb 	/* set the VM page size */
    229         1.1    simonb 	uvm_setpagesize();
    230         1.1    simonb 
    231         1.1    simonb 	physmem = btoc(memsize);
    232         1.1    simonb 
    233        1.16    simonb 	/*
    234        1.16    simonb 	 * Use YAMON's CPU frequency if available.
    235        1.16    simonb 	 */
    236        1.16    simonb 	freqok = yamon_setcpufreq(1);
    237        1.16    simonb 
    238         1.1    simonb 	gt_pci_init(&mcp->mc_pc, &mcp->mc_gt);
    239         1.1    simonb 	malta_bus_io_init(&mcp->mc_iot, mcp);
    240         1.1    simonb 	malta_bus_mem_init(&mcp->mc_memt, mcp);
    241         1.1    simonb 	malta_dma_init(mcp);
    242         1.1    simonb 
    243         1.3    simonb 	/*
    244        1.16    simonb 	 * Calibrate the timer if YAMON failed to tell us.
    245         1.3    simonb 	 */
    246        1.16    simonb 	if (!freqok) {
    247        1.16    simonb 		bus_space_map(&mcp->mc_iot, MALTA_RTCADR, 2, 0, &sh);
    248        1.16    simonb 		malta_cal_timer(&mcp->mc_iot, sh);
    249        1.16    simonb 		bus_space_unmap(&mcp->mc_iot, sh, 2);
    250        1.16    simonb 	}
    251         1.3    simonb 
    252         1.1    simonb #if NCOM > 0
    253         1.1    simonb 	/*
    254         1.1    simonb 	 * Delay to allow firmware putchars to complete.
    255         1.1    simonb 	 * FIFO depth * character time.
    256         1.1    simonb 	 * character time = (1000000 / (defaultrate / 10))
    257         1.1    simonb 	 */
    258         1.3    simonb 	delay(160000000 / comcnrate);
    259        1.11   thorpej 	if (comcnattach(&mcp->mc_iot, MALTA_UART0ADR, comcnrate,
    260        1.11   thorpej 	    COM_FREQ, COM_TYPE_NORMAL,
    261         1.1    simonb 	    (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8) != 0)
    262         1.1    simonb 		panic("malta: unable to initialize serial console");
    263         1.1    simonb #else
    264         1.1    simonb 	panic("malta: not configured to use serial console");
    265         1.1    simonb #endif /* NCOM > 0 */
    266         1.1    simonb 
    267         1.1    simonb 	mem_clusters[0].start = 0;
    268         1.1    simonb 	mem_clusters[0].size = ctob(physmem);
    269         1.1    simonb 	mem_cluster_cnt = 1;
    270         1.1    simonb 
    271         1.5  gmcgarry 	strcpy(cpu_model, "MIPS Malta Evaluation Board");
    272         1.5  gmcgarry 
    273         1.1    simonb 	/*
    274         1.1    simonb 	 * XXX: check argv[0] - do something if "gdb"???
    275         1.1    simonb 	 */
    276         1.1    simonb 
    277         1.1    simonb 	/*
    278         1.1    simonb 	 * Look at arguments passed to us and compute boothowto.
    279         1.1    simonb 	 */
    280         1.1    simonb 	boothowto = RB_AUTOBOOT;
    281   1.28.10.1      matt #ifndef _LP64
    282   1.28.10.1      matt 	for (int i = 1; i < argc; i++) {
    283   1.28.10.1      matt 		for (char *cp = argv[i]; *cp; cp++) {
    284   1.28.10.1      matt 			int howto;
    285         1.1    simonb 			/* Ignore superfluous '-', if there is one */
    286         1.1    simonb 			if (*cp == '-')
    287         1.1    simonb 				continue;
    288         1.1    simonb 
    289         1.1    simonb 			howto = 0;
    290         1.1    simonb 			BOOT_FLAG(*cp, howto);
    291         1.1    simonb 			if (! howto)
    292         1.1    simonb 				printf("bootflag '%c' not recognised\n", *cp);
    293         1.1    simonb 			else
    294         1.1    simonb 				boothowto |= howto;
    295         1.1    simonb 		}
    296         1.1    simonb 	}
    297   1.28.10.1      matt #endif
    298         1.1    simonb 
    299         1.1    simonb 	/*
    300         1.1    simonb 	 * Load the rest of the available pages into the VM system.
    301         1.1    simonb 	 */
    302   1.28.10.3      matt 	mips_page_physload(MIPS_KSEG0_START, (vaddr_t)kernend,
    303   1.28.10.3      matt 	    mem_clusters, mem_cluster_cnt, NULL, 0);
    304         1.1    simonb 
    305         1.1    simonb 	/*
    306         1.1    simonb 	 * Initialize error message buffer (at end of core).
    307         1.1    simonb 	 */
    308         1.1    simonb 	mips_init_msgbuf();
    309         1.1    simonb 
    310         1.1    simonb 	pmap_bootstrap();
    311         1.1    simonb 
    312         1.1    simonb 	/*
    313         1.1    simonb 	 * Allocate space for proc0's USPACE.
    314         1.1    simonb 	 */
    315   1.28.10.3      matt 	mips_init_lwp0_uarea();
    316         1.1    simonb 
    317         1.1    simonb 	/*
    318         1.1    simonb 	 * Initialize debuggers, and break into them, if appropriate.
    319         1.1    simonb 	 */
    320        1.10     ragge #if NKSYMS || defined(DDB) || defined(LKM)
    321        1.10     ragge 	ksyms_init(0, 0, 0);
    322         1.1    simonb #endif
    323         1.1    simonb 
    324        1.10     ragge #if defined(DDB)
    325         1.1    simonb 	if (boothowto & RB_KDB)
    326         1.1    simonb 		Debugger();
    327         1.1    simonb #endif
    328   1.28.10.5      matt 
    329   1.28.10.5      matt #ifdef MULTIPROCESSOR
    330   1.28.10.5      matt 	/*
    331   1.28.10.6       snj 	 * We can never be running on more than one processor but we can dream.
    332   1.28.10.5      matt 	 */
    333   1.28.10.5      matt 	mips_fixup_exceptions(mips_fixup_zero_relative);
    334   1.28.10.5      matt #endif
    335         1.1    simonb }
    336         1.1    simonb 
    337         1.1    simonb void
    338         1.1    simonb consinit(void)
    339         1.1    simonb {
    340         1.1    simonb 
    341         1.1    simonb 	/*
    342         1.1    simonb 	 * Everything related to console initialization is done
    343         1.1    simonb 	 * in mach_init().
    344         1.1    simonb 	 */
    345         1.1    simonb }
    346         1.1    simonb 
    347         1.1    simonb /*
    348         1.1    simonb  * Allocate memory for variable-sized tables,
    349         1.1    simonb  */
    350         1.1    simonb void
    351         1.1    simonb cpu_startup()
    352         1.1    simonb {
    353         1.1    simonb 	/*
    354   1.28.10.7      matt 	 * Do the common startup items.
    355         1.1    simonb 	 */
    356   1.28.10.7      matt 	cpu_startup_common();
    357         1.1    simonb 
    358         1.1    simonb 	/*
    359         1.1    simonb 	 * Virtual memory is bootstrapped -- notify the bus spaces
    360         1.1    simonb 	 * that memory allocation is now safe.
    361         1.1    simonb 	 */
    362         1.1    simonb 	malta_configuration.mc_mallocsafe = 1;
    363         1.1    simonb }
    364         1.1    simonb 
    365         1.1    simonb int	waittime = -1;
    366         1.1    simonb 
    367         1.1    simonb void
    368         1.1    simonb cpu_reboot(howto, bootstr)
    369         1.1    simonb 	int howto;
    370         1.1    simonb 	char *bootstr;
    371         1.1    simonb {
    372         1.1    simonb 
    373         1.1    simonb 	/* Take a snapshot before clobbering any registers. */
    374   1.28.10.9      matt 	savectx(lwp_getpcb(curlwp));
    375         1.1    simonb 
    376         1.1    simonb 	if (cold) {
    377         1.1    simonb 		howto |= RB_HALT;
    378         1.1    simonb 		goto haltsys;
    379         1.1    simonb 	}
    380         1.1    simonb 
    381         1.1    simonb 	/* If "always halt" was specified as a boot flag, obey. */
    382         1.1    simonb 	if (boothowto & RB_HALT)
    383         1.1    simonb 		howto |= RB_HALT;
    384         1.1    simonb 
    385         1.1    simonb 	boothowto = howto;
    386         1.1    simonb 	if ((howto & RB_NOSYNC) == 0 && (waittime < 0)) {
    387         1.1    simonb 		waittime = 0;
    388         1.1    simonb 		vfs_shutdown();
    389         1.1    simonb 
    390         1.1    simonb 		/*
    391         1.1    simonb 		 * If we've been adjusting the clock, the todr
    392         1.1    simonb 		 * will be out of synch; adjust it now.
    393         1.1    simonb 		 */
    394         1.1    simonb 		resettodr();
    395         1.1    simonb 	}
    396         1.1    simonb 
    397         1.1    simonb 	splhigh();
    398         1.1    simonb 
    399         1.1    simonb 	if (howto & RB_DUMP)
    400         1.1    simonb 		dumpsys();
    401         1.1    simonb 
    402         1.1    simonb haltsys:
    403         1.1    simonb 	doshutdownhooks();
    404         1.1    simonb 
    405         1.1    simonb 	if (howto & RB_HALT) {
    406         1.1    simonb 		printf("\n");
    407         1.1    simonb 		printf("The operating system has halted.\n");
    408         1.1    simonb 		printf("Please press any key to reboot.\n\n");
    409         1.1    simonb 		cnpollc(1);	/* For proper keyboard command handling */
    410         1.1    simonb 		cngetc();
    411         1.1    simonb 		cnpollc(0);
    412         1.1    simonb 	}
    413         1.1    simonb 
    414         1.1    simonb 	printf("%s\n\n", ((howto & RB_HALT) != 0) ? "halted." : "rebooting...");
    415         1.1    simonb 	yamon_exit(boothowto);
    416         1.1    simonb 	printf("Oops, back from yamon_exit()\n\nResetting...");
    417         1.1    simonb 
    418         1.1    simonb 	REGVAL(MALTA_SOFTRES) = MALTA_GORESET;
    419         1.1    simonb 
    420         1.1    simonb 	/*
    421         1.1    simonb 	 * Need a small delay here, otherwise we see the first few characters of
    422         1.1    simonb 	 * the warning below.
    423         1.1    simonb 	 */
    424         1.1    simonb 	delay(80000);
    425         1.1    simonb 
    426         1.1    simonb 	printf("WARNING: reset failed!\nSpinning...");
    427         1.1    simonb 
    428         1.1    simonb 	for (;;)
    429         1.1    simonb 		/* spin forever */ ;	/* XXX */
    430         1.1    simonb }
    431