Deleted Added
sdiff udiff text old ( 82223 ) new ( 82749 )
full compact
1/*-
2 * Copyright (c) 1986, 1988, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 22 unchanged lines hidden (view full) ---

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)kern_shutdown.c 8.3 (Berkeley) 1/21/94
39 * $FreeBSD: head/sys/kern/kern_shutdown.c 82223 2001-08-23 20:32:21Z jhb $
40 */
41
42#include "opt_ddb.h"
43#include "opt_hw_wdog.h"
44#include "opt_panic.h"
45#include "opt_show_busybufs.h"
46
47#include <sys/param.h>

--- 78 unchanged lines hidden (view full) ---

126 EVENTHANDLER_REGISTER(shutdown_final, poweroff_wait, NULL, SHUTDOWN_PRI_FIRST);
127 EVENTHANDLER_REGISTER(shutdown_final, shutdown_halt, NULL, SHUTDOWN_PRI_LAST + 100);
128 EVENTHANDLER_REGISTER(shutdown_final, shutdown_panic, NULL, SHUTDOWN_PRI_LAST + 100);
129 EVENTHANDLER_REGISTER(shutdown_final, shutdown_reset, NULL, SHUTDOWN_PRI_LAST + 200);
130}
131
132SYSINIT(shutdown_conf, SI_SUB_INTRINSIC, SI_ORDER_ANY, shutdown_conf, NULL)
133
134/* ARGSUSED */
135
136/*
137 * The system call that results in a reboot
138 */
139int
140reboot(struct proc *p, struct reboot_args *uap)
141{
142 int error;
143
144 if ((error = suser(p)))
145 return (error);
146
147 boot(uap->opt);
148 return (0);
149}
150
151/*
152 * Called by events that want to shut down.. e.g <CTL><ALT><DEL> on a PC
153 */
154static int shutdown_howto = 0;
155
156void

--- 403 unchanged lines hidden (view full) ---

560#ifdef SMP
561static u_int panic_cpu = NOCPU;
562#endif
563
564/*
565 * Panic is called on unresolvable fatal errors. It prints "panic: mesg",
566 * and then reboots. If we are called twice, then we avoid trying to sync
567 * the disks as this often leads to recursive panics.
568 */
569void
570panic(const char *fmt, ...)
571{
572 int bootopt;
573 va_list ap;
574 static char buf[256];
575
576#ifdef SMP
577 /*
578 * We don't want multiple CPU's to panic at the same time, so we
579 * use panic_cpu as a simple spinlock. We have to keep checking
580 * panic_cpu if we are spinning in case the panic on the first
581 * CPU is canceled.
582 */
583 if (panic_cpu != PCPU_GET(cpuid))
584 while (atomic_cmpset_int(&panic_cpu, NOCPU,
585 PCPU_GET(cpuid)) == 0)
586 while (panic_cpu != NOCPU)
587 ; /* nothing */
588#endif
589
590 bootopt = RB_AUTOBOOT | RB_DUMP;
591 if (panicstr)
592 bootopt |= RB_NOSYNC;
593 else
594 panicstr = fmt;
595

--- 15 unchanged lines hidden (view full) ---

611 if (debugger_on_panic)
612 Debugger ("panic");
613#ifdef RESTARTABLE_PANICS
614 /* See if the user aborted the panic, in which case we continue. */
615 if (panicstr == NULL) {
616#ifdef SMP
617 atomic_store_rel_int(&panic_cpu, NOCPU);
618#endif
619 return;
620 }
621#endif
622#endif
623 boot(bootopt);
624}
625
626/*

--- 48 unchanged lines hidden ---