Home | History | Annotate | Line # | Download | only in arm32
arm32_reboot.c revision 1.1
      1  1.1  matt /*	$NetBSD: arm32_reboot.c,v 1.1 2012/08/31 23:59:51 matt Exp $	*/
      2  1.1  matt 
      3  1.1  matt /*
      4  1.1  matt  * Copyright (c) 2002, 2003, 2005  Genetec Corporation.  All rights reserved.
      5  1.1  matt  * Written by Hiroyuki Bessho for Genetec Corporation.
      6  1.1  matt  *
      7  1.1  matt  * Redistribution and use in source and binary forms, with or without
      8  1.1  matt  * modification, are permitted provided that the following conditions
      9  1.1  matt  * are met:
     10  1.1  matt  * 1. Redistributions of source code must retain the above copyright
     11  1.1  matt  *    notice, this list of conditions and the following disclaimer.
     12  1.1  matt  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  matt  *    notice, this list of conditions and the following disclaimer in the
     14  1.1  matt  *    documentation and/or other materials provided with the distribution.
     15  1.1  matt  * 3. The name of Genetec Corporation may not be used to endorse or
     16  1.1  matt  *    promote products derived from this software without specific prior
     17  1.1  matt  *    written permission.
     18  1.1  matt  *
     19  1.1  matt  * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
     20  1.1  matt  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  1.1  matt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  1.1  matt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL GENETEC CORPORATION
     23  1.1  matt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  1.1  matt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  1.1  matt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  1.1  matt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  1.1  matt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  1.1  matt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  1.1  matt  * POSSIBILITY OF SUCH DAMAGE.
     30  1.1  matt  *
     31  1.1  matt  * Copyright (c) 2001 Wasabi Systems, Inc.
     32  1.1  matt  * All rights reserved.
     33  1.1  matt  *
     34  1.1  matt  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
     35  1.1  matt  *
     36  1.1  matt  * Redistribution and use in source and binary forms, with or without
     37  1.1  matt  * modification, are permitted provided that the following conditions
     38  1.1  matt  * are met:
     39  1.1  matt  * 1. Redistributions of source code must retain the above copyright
     40  1.1  matt  *    notice, this list of conditions and the following disclaimer.
     41  1.1  matt  * 2. Redistributions in binary form must reproduce the above copyright
     42  1.1  matt  *    notice, this list of conditions and the following disclaimer in the
     43  1.1  matt  *    documentation and/or other materials provided with the distribution.
     44  1.1  matt  * 3. All advertising materials mentioning features or use of this software
     45  1.1  matt  *    must display the following acknowledgement:
     46  1.1  matt  *	This product includes software developed for the NetBSD Project by
     47  1.1  matt  *	Wasabi Systems, Inc.
     48  1.1  matt  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
     49  1.1  matt  *    or promote products derived from this software without specific prior
     50  1.1  matt  *    written permission.
     51  1.1  matt  *
     52  1.1  matt  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
     53  1.1  matt  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     54  1.1  matt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     55  1.1  matt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
     56  1.1  matt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     57  1.1  matt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     58  1.1  matt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     59  1.1  matt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     60  1.1  matt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     61  1.1  matt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     62  1.1  matt  * POSSIBILITY OF SUCH DAMAGE.
     63  1.1  matt  *
     64  1.1  matt  * Copyright (c) 1997,1998 Mark Brinicombe.
     65  1.1  matt  * Copyright (c) 1997,1998 Causality Limited.
     66  1.1  matt  * All rights reserved.
     67  1.1  matt  *
     68  1.1  matt  * Redistribution and use in source and binary forms, with or without
     69  1.1  matt  * modification, are permitted provided that the following conditions
     70  1.1  matt  * are met:
     71  1.1  matt  * 1. Redistributions of source code must retain the above copyright
     72  1.1  matt  *    notice, this list of conditions and the following disclaimer.
     73  1.1  matt  * 2. Redistributions in binary form must reproduce the above copyright
     74  1.1  matt  *    notice, this list of conditions and the following disclaimer in the
     75  1.1  matt  *    documentation and/or other materials provided with the distribution.
     76  1.1  matt  * 3. All advertising materials mentioning features or use of this software
     77  1.1  matt  *    must display the following acknowledgement:
     78  1.1  matt  *	This product includes software developed by Mark Brinicombe
     79  1.1  matt  *	for the NetBSD Project.
     80  1.1  matt  * 4. The name of the company nor the name of the author may be used to
     81  1.1  matt  *    endorse or promote products derived from this software without specific
     82  1.1  matt  *    prior written permission.
     83  1.1  matt  *
     84  1.1  matt  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
     85  1.1  matt  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     86  1.1  matt  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     87  1.1  matt  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     88  1.1  matt  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     89  1.1  matt  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     90  1.1  matt  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     91  1.1  matt  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     92  1.1  matt  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     93  1.1  matt  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     94  1.1  matt  * SUCH DAMAGE.
     95  1.1  matt  *
     96  1.1  matt  * Copyright (c) 2007 Microsoft
     97  1.1  matt  * All rights reserved.
     98  1.1  matt  *
     99  1.1  matt  * Redistribution and use in source and binary forms, with or without
    100  1.1  matt  * modification, are permitted provided that the following conditions
    101  1.1  matt  * are met:
    102  1.1  matt  * 1. Redistributions of source code must retain the above copyright
    103  1.1  matt  *    notice, this list of conditions and the following disclaimer.
    104  1.1  matt  * 2. Redistributions in binary form must reproduce the above copyright
    105  1.1  matt  *    notice, this list of conditions and the following disclaimer in the
    106  1.1  matt  *    documentation and/or other materials provided with the distribution.
    107  1.1  matt  * 3. All advertising materials mentioning features or use of this software
    108  1.1  matt  *    must display the following acknowledgement:
    109  1.1  matt  *	This product includes software developed by Microsoft
    110  1.1  matt  *
    111  1.1  matt  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
    112  1.1  matt  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    113  1.1  matt  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    114  1.1  matt  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTERS BE LIABLE FOR ANY DIRECT,
    115  1.1  matt  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    116  1.1  matt  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    117  1.1  matt  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    118  1.1  matt  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    119  1.1  matt  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    120  1.1  matt  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    121  1.1  matt  * SUCH DAMAGE.
    122  1.1  matt  */
    123  1.1  matt 
    124  1.1  matt #include <sys/cdefs.h>
    125  1.1  matt __KERNEL_RCSID(0, "$NetBSD: arm32_reboot.c,v 1.1 2012/08/31 23:59:51 matt Exp $");
    126  1.1  matt 
    127  1.1  matt #include <sys/param.h>
    128  1.1  matt #include <sys/device.h>
    129  1.1  matt #include <sys/kernel.h>
    130  1.1  matt #include <sys/reboot.h>
    131  1.1  matt 
    132  1.1  matt #include <dev/cons.h>
    133  1.1  matt 
    134  1.1  matt #include <uvm/uvm_extern.h>
    135  1.1  matt 
    136  1.1  matt #include <arm/arm32/machdep.h>
    137  1.1  matt 
    138  1.1  matt void
    139  1.1  matt cpu_reboot(int howto, char *bootstr)
    140  1.1  matt {
    141  1.1  matt 
    142  1.1  matt 	/*
    143  1.1  matt 	 * If we are still cold then hit the air brakes
    144  1.1  matt 	 * and crash to earth fast
    145  1.1  matt 	 */
    146  1.1  matt 	if (cold) {
    147  1.1  matt 		doshutdownhooks();
    148  1.1  matt 		printf("The operating system has halted.\r\n");
    149  1.1  matt 		printf("Please press any key to reboot.\r\n");
    150  1.1  matt 		cngetc();
    151  1.1  matt 		printf("rebooting...\r\n");
    152  1.1  matt 		if (cpu_reset_address)
    153  1.1  matt 			(*cpu_reset_address)();
    154  1.1  matt 		cpu_reset();
    155  1.1  matt 	}
    156  1.1  matt 
    157  1.1  matt 	/*
    158  1.1  matt 	 * If RB_NOSYNC was not specified sync the discs.
    159  1.1  matt 	 * Note: Unless cold is set to 1 here, syslogd will die during the
    160  1.1  matt 	 * unmount.  It looks like syslogd is getting woken up only to find
    161  1.1  matt 	 * that it cannot page part of the binary in as the filesystem has
    162  1.1  matt 	 * been unmounted.
    163  1.1  matt 	 */
    164  1.1  matt 	if (!(howto & RB_NOSYNC))
    165  1.1  matt 		bootsync();
    166  1.1  matt 
    167  1.1  matt 	/* Say NO to interrupts */
    168  1.1  matt 	splhigh();
    169  1.1  matt 
    170  1.1  matt 	/* Do a dump if requested. */
    171  1.1  matt 	if ((howto & (RB_DUMP | RB_HALT)) == RB_DUMP)
    172  1.1  matt 		dumpsys();
    173  1.1  matt 
    174  1.1  matt 	/* Run any shutdown hooks */
    175  1.1  matt 	doshutdownhooks();
    176  1.1  matt 
    177  1.1  matt 	/* Make sure IRQ's are disabled */
    178  1.1  matt 	IRQdisable;
    179  1.1  matt 
    180  1.1  matt 	if (howto & RB_HALT) {
    181  1.1  matt 		printf("The operating system has halted.\r\n");
    182  1.1  matt 		printf("Please press any key to reboot.\r\n");
    183  1.1  matt 		cngetc();
    184  1.1  matt 	}
    185  1.1  matt 
    186  1.1  matt 	printf("rebooting...\r\n");
    187  1.1  matt 	if (cpu_reset_address)
    188  1.1  matt 		(*cpu_reset_address)();
    189  1.1  matt 	cpu_reset();
    190  1.1  matt 	/*NOTREACHED*/
    191  1.1  matt }
    192