summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>1996-08-19 20:07:07 +0000
committerjulian <julian@FreeBSD.org>1996-08-19 20:07:07 +0000
commit65b6e7181bc8bde1918c94186c38543764663453 (patch)
treed4294827ff886d20438cfade654560e1d181c7e2 /sys
parentc663bae3b71b62dea313426b5c2729c15e305f38 (diff)
downloadFreeBSD-src-65b6e7181bc8bde1918c94186c38543764663453.zip
FreeBSD-src-65b6e7181bc8bde1918c94186c38543764663453.tar.gz
Collect all the functioons concerned with rebooting into one place
also add the at_shutdown callout list, and change the one user of the present (broken) method (the vn driver) to use the new scheme.
Diffstat (limited to 'sys')
-rw-r--r--sys/amd64/amd64/machdep.c166
-rw-r--r--sys/dev/vn/vn.c11
-rw-r--r--sys/i386/i386/machdep.c166
-rw-r--r--sys/kern/kern_shutdown.c3
-rw-r--r--sys/kern/kern_xxx.c56
-rw-r--r--sys/kern/subr_prf.c57
6 files changed, 22 insertions, 437 deletions
diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c
index 7e43259..6d5a23b 100644
--- a/sys/amd64/amd64/machdep.c
+++ b/sys/amd64/amd64/machdep.c
@@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
- * $Id: machdep.c,v 1.196 1996/08/11 17:41:24 davidg Exp $
+ * $Id: machdep.c,v 1.198 1996/08/12 20:03:16 wollman Exp $
*/
#include "npx.h"
@@ -130,10 +130,6 @@ static void cpu_startup __P((void *));
SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL)
-#ifndef PANIC_REBOOT_WAIT_TIME
-#define PANIC_REBOOT_WAIT_TIME 15 /* default to 15 seconds */
-#endif
-
#ifdef BOUNCE_BUFFERS
extern char *bouncememory;
extern int maxbkva;
@@ -184,7 +180,6 @@ vm_offset_t phys_avail[10];
/* must be 2 less so 0 0 can signal end of chunks */
#define PHYS_AVAIL_ARRAY_END ((sizeof(phys_avail) / sizeof(vm_offset_t)) - 2)
-static void dumpsys __P((void));
static void setup_netisrs __P((struct linker_set *)); /* XXX declare elsewhere */
static vm_offset_t buffer_sva, buffer_eva;
@@ -682,164 +677,15 @@ sigreturn(p, uap, retval)
return(EJUSTRETURN);
}
-static int waittime = -1;
-static struct pcb dumppcb;
-
-__dead void
-boot(howto)
- int howto;
-{
- if (!cold && (howto & RB_NOSYNC) == 0 && waittime < 0) {
- register struct buf *bp;
- int iter, nbusy;
-
- waittime = 0;
- printf("\nsyncing disks... ");
-
- sync(&proc0, NULL, NULL);
-
- for (iter = 0; iter < 20; iter++) {
- nbusy = 0;
- for (bp = &buf[nbuf]; --bp >= buf; ) {
- if ((bp->b_flags & (B_BUSY | B_INVAL)) == B_BUSY) {
- nbusy++;
- }
- }
- if (nbusy == 0)
- break;
- printf("%d ", nbusy);
- DELAY(40000 * iter);
- }
- if (nbusy) {
- /*
- * Failed to sync all blocks. Indicate this and don't
- * unmount filesystems (thus forcing an fsck on reboot).
- */
- printf("giving up\n");
-#ifdef SHOW_BUSYBUFS
- nbusy = 0;
- for (bp = &buf[nbuf]; --bp >= buf; ) {
- if ((bp->b_flags & (B_BUSY | B_INVAL)) == B_BUSY) {
- nbusy++;
- printf("%d: dev:%08x, flags:%08x, blkno:%d, lblkno:%d\n", nbusy, bp->b_dev, bp->b_flags, bp->b_blkno, bp->b_lblkno);
- }
- }
- DELAY(5000000); /* 5 seconds */
-#endif
- } else {
- printf("done\n");
- /*
- * Unmount filesystems
- */
- if (panicstr == 0)
- vfs_unmountall();
- }
- DELAY(100000); /* wait for console output to finish */
- dev_shutdownall(FALSE);
- }
- splhigh();
- if (howto & RB_HALT) {
- printf("\n");
- printf("The operating system has halted.\n");
- printf("Please press any key to reboot.\n\n");
- cngetc();
- } else {
- if (howto & RB_DUMP) {
- if (!cold) {
- savectx(&dumppcb);
- dumppcb.pcb_cr3 = rcr3();
- dumpsys();
- }
-
- if (PANIC_REBOOT_WAIT_TIME != 0) {
- if (PANIC_REBOOT_WAIT_TIME != -1) {
- int loop;
- printf("Automatic reboot in %d seconds - press a key on the console to abort\n",
- PANIC_REBOOT_WAIT_TIME);
- for (loop = PANIC_REBOOT_WAIT_TIME * 10; loop > 0; --loop) {
- DELAY(1000 * 100); /* 1/10th second */
- if (cncheckc()) /* Did user type a key? */
- break;
- }
- if (!loop)
- goto die;
- }
- } else { /* zero time specified - reboot NOW */
- goto die;
- }
- printf("--> Press a key on the console to reboot <--\n");
- cngetc();
- }
- }
-die:
- printf("Rebooting...\n");
- DELAY(1000000); /* wait 1 sec for printf's to complete and be read */
- cpu_reset();
- for(;;) ;
- /* NOTREACHED */
-}
-
/*
- * Magic number for savecore
- *
- * exported (symorder) and used at least by savecore(8)
+ * Machine depdnetnt boot() routine
*
+ * I haven't seen anything too put here yet
+ * Possibly some stuff might be grafted back here from boot()
*/
-static u_long const dumpmag = 0x8fca0101UL;
-
-static int dumpsize = 0; /* also for savecore */
-
-static int dodump = 1;
-SYSCTL_INT(_machdep, OID_AUTO, do_dump, CTLFLAG_RW, &dodump, 0, "");
-
-/*
- * Doadump comes here after turning off memory management and
- * getting on the dump stack, either when called above, or by
- * the auto-restart code.
- */
-static void
-dumpsys()
+void
+cpu_boot(int howto)
{
-
- if (!dodump)
- return;
- if (dumpdev == NODEV)
- return;
- if ((minor(dumpdev)&07) != 1)
- return;
- if (!(bdevsw[major(dumpdev)]))
- return;
- if (!(bdevsw[major(dumpdev)]->d_dump))
- return;
- dumpsize = Maxmem;
- printf("\ndumping to dev %lx, offset %ld\n", dumpdev, dumplo);
- printf("dump ");
- switch ((*bdevsw[major(dumpdev)]->d_dump)(dumpdev)) {
-
- case ENXIO:
- printf("device bad\n");
- break;
-
- case EFAULT:
- printf("device not ready\n");
- break;
-
- case EINVAL:
- printf("area improper\n");
- break;
-
- case EIO:
- printf("i/o error\n");
- break;
-
- case EINTR:
- printf("aborted from console\n");
- break;
-
- default:
- printf("succeeded\n");
- break;
- }
}
/*
diff --git a/sys/dev/vn/vn.c b/sys/dev/vn/vn.c
index 652918e..ba0d56b 100644
--- a/sys/dev/vn/vn.c
+++ b/sys/dev/vn/vn.c
@@ -38,7 +38,7 @@
* from: Utah Hdr: vn.c 1.13 94/04/02
*
* from: @(#)vn.c 8.6 (Berkeley) 4/1/94
- * $Id: vn.c,v 1.36 1996/03/28 15:25:43 bde Exp $
+ * $Id: vn.c,v 1.37 1996/07/23 21:51:26 phk Exp $
*/
/*
@@ -149,7 +149,7 @@ static u_long vn_options;
static void vniodone (struct buf *bp);
static int vnsetcred (struct vn_softc *vn, struct ucred *cred);
-static void vnshutdown (void);
+static void vnshutdown (int ,void *);
static void vnclear (struct vn_softc *vn);
static int
@@ -563,7 +563,7 @@ vnsetcred(struct vn_softc *vn, struct ucred *cred)
}
void
-vnshutdown()
+vnshutdown(int howto, void *ignored)
{
int i;
@@ -572,8 +572,6 @@ vnshutdown()
vnclear(vn_softc[i]);
}
-TEXT_SET(cleanup_set, vnshutdown);
-
void
vnclear(struct vn_softc *vn)
{
@@ -624,6 +622,9 @@ vn_drvinit(void *unused)
if( ! vn_devsw_installed ) {
bdevsw_add_generic(BDEV_MAJOR,CDEV_MAJOR, &vn_bdevsw);
vn_devsw_installed = 1;
+ if(at_shutdown(&vnshutdown,NULL) {
+ printf("vn: could not install shutdown hook\n");
+ }
#ifdef DEVFS
for (unit = 0; unit < NVN; unit++) {
vn = vn_softc[unit];
diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c
index 7e43259..6d5a23b 100644
--- a/sys/i386/i386/machdep.c
+++ b/sys/i386/i386/machdep.c
@@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
- * $Id: machdep.c,v 1.196 1996/08/11 17:41:24 davidg Exp $
+ * $Id: machdep.c,v 1.198 1996/08/12 20:03:16 wollman Exp $
*/
#include "npx.h"
@@ -130,10 +130,6 @@ static void cpu_startup __P((void *));
SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL)
-#ifndef PANIC_REBOOT_WAIT_TIME
-#define PANIC_REBOOT_WAIT_TIME 15 /* default to 15 seconds */
-#endif
-
#ifdef BOUNCE_BUFFERS
extern char *bouncememory;
extern int maxbkva;
@@ -184,7 +180,6 @@ vm_offset_t phys_avail[10];
/* must be 2 less so 0 0 can signal end of chunks */
#define PHYS_AVAIL_ARRAY_END ((sizeof(phys_avail) / sizeof(vm_offset_t)) - 2)
-static void dumpsys __P((void));
static void setup_netisrs __P((struct linker_set *)); /* XXX declare elsewhere */
static vm_offset_t buffer_sva, buffer_eva;
@@ -682,164 +677,15 @@ sigreturn(p, uap, retval)
return(EJUSTRETURN);
}
-static int waittime = -1;
-static struct pcb dumppcb;
-
-__dead void
-boot(howto)
- int howto;
-{
- if (!cold && (howto & RB_NOSYNC) == 0 && waittime < 0) {
- register struct buf *bp;
- int iter, nbusy;
-
- waittime = 0;
- printf("\nsyncing disks... ");
-
- sync(&proc0, NULL, NULL);
-
- for (iter = 0; iter < 20; iter++) {
- nbusy = 0;
- for (bp = &buf[nbuf]; --bp >= buf; ) {
- if ((bp->b_flags & (B_BUSY | B_INVAL)) == B_BUSY) {
- nbusy++;
- }
- }
- if (nbusy == 0)
- break;
- printf("%d ", nbusy);
- DELAY(40000 * iter);
- }
- if (nbusy) {
- /*
- * Failed to sync all blocks. Indicate this and don't
- * unmount filesystems (thus forcing an fsck on reboot).
- */
- printf("giving up\n");
-#ifdef SHOW_BUSYBUFS
- nbusy = 0;
- for (bp = &buf[nbuf]; --bp >= buf; ) {
- if ((bp->b_flags & (B_BUSY | B_INVAL)) == B_BUSY) {
- nbusy++;
- printf("%d: dev:%08x, flags:%08x, blkno:%d, lblkno:%d\n", nbusy, bp->b_dev, bp->b_flags, bp->b_blkno, bp->b_lblkno);
- }
- }
- DELAY(5000000); /* 5 seconds */
-#endif
- } else {
- printf("done\n");
- /*
- * Unmount filesystems
- */
- if (panicstr == 0)
- vfs_unmountall();
- }
- DELAY(100000); /* wait for console output to finish */
- dev_shutdownall(FALSE);
- }
- splhigh();
- if (howto & RB_HALT) {
- printf("\n");
- printf("The operating system has halted.\n");
- printf("Please press any key to reboot.\n\n");
- cngetc();
- } else {
- if (howto & RB_DUMP) {
- if (!cold) {
- savectx(&dumppcb);
- dumppcb.pcb_cr3 = rcr3();
- dumpsys();
- }
-
- if (PANIC_REBOOT_WAIT_TIME != 0) {
- if (PANIC_REBOOT_WAIT_TIME != -1) {
- int loop;
- printf("Automatic reboot in %d seconds - press a key on the console to abort\n",
- PANIC_REBOOT_WAIT_TIME);
- for (loop = PANIC_REBOOT_WAIT_TIME * 10; loop > 0; --loop) {
- DELAY(1000 * 100); /* 1/10th second */
- if (cncheckc()) /* Did user type a key? */
- break;
- }
- if (!loop)
- goto die;
- }
- } else { /* zero time specified - reboot NOW */
- goto die;
- }
- printf("--> Press a key on the console to reboot <--\n");
- cngetc();
- }
- }
-die:
- printf("Rebooting...\n");
- DELAY(1000000); /* wait 1 sec for printf's to complete and be read */
- cpu_reset();
- for(;;) ;
- /* NOTREACHED */
-}
-
/*
- * Magic number for savecore
- *
- * exported (symorder) and used at least by savecore(8)
+ * Machine depdnetnt boot() routine
*
+ * I haven't seen anything too put here yet
+ * Possibly some stuff might be grafted back here from boot()
*/
-static u_long const dumpmag = 0x8fca0101UL;
-
-static int dumpsize = 0; /* also for savecore */
-
-static int dodump = 1;
-SYSCTL_INT(_machdep, OID_AUTO, do_dump, CTLFLAG_RW, &dodump, 0, "");
-
-/*
- * Doadump comes here after turning off memory management and
- * getting on the dump stack, either when called above, or by
- * the auto-restart code.
- */
-static void
-dumpsys()
+void
+cpu_boot(int howto)
{
-
- if (!dodump)
- return;
- if (dumpdev == NODEV)
- return;
- if ((minor(dumpdev)&07) != 1)
- return;
- if (!(bdevsw[major(dumpdev)]))
- return;
- if (!(bdevsw[major(dumpdev)]->d_dump))
- return;
- dumpsize = Maxmem;
- printf("\ndumping to dev %lx, offset %ld\n", dumpdev, dumplo);
- printf("dump ");
- switch ((*bdevsw[major(dumpdev)]->d_dump)(dumpdev)) {
-
- case ENXIO:
- printf("device bad\n");
- break;
-
- case EFAULT:
- printf("device not ready\n");
- break;
-
- case EINVAL:
- printf("area improper\n");
- break;
-
- case EIO:
- printf("i/o error\n");
- break;
-
- case EINTR:
- printf("aborted from console\n");
- break;
-
- default:
- printf("succeeded\n");
- break;
- }
}
/*
diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c
index 1c217be..1ded33f 100644
--- a/sys/kern/kern_shutdown.c
+++ b/sys/kern/kern_shutdown.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_shutdown.c 8.3 (Berkeley) 1/21/94
- * $Id: subr_prf.c,v 1.37 1996/05/09 18:58:06 gpalmer Exp $
+ * $Id: kern_shutdown.c,v 1.1 1996/08/19 02:19:21 julian Exp $
*/
#include "opt_ddb.h"
@@ -276,6 +276,7 @@ boot(howto)
die:
printf("Rebooting...\n");
DELAY(1000000); /* wait 1 sec for printf's to complete and be read */
+ /* cpu_boot(howto); */ /* doesn't do anything at the moment */
cpu_reset();
for(;;) ;
/* NOTREACHED */
diff --git a/sys/kern/kern_xxx.c b/sys/kern/kern_xxx.c
index 173b33d..cb08c42 100644
--- a/sys/kern/kern_xxx.c
+++ b/sys/kern/kern_xxx.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)kern_xxx.c 8.2 (Berkeley) 11/14/93
- * $Id: kern_xxx.c,v 1.21 1995/12/02 18:58:50 bde Exp $
+ * $Id: kern_xxx.c,v 1.22 1995/12/06 23:37:12 bde Exp $
*/
#include <sys/param.h>
@@ -39,49 +39,9 @@
#include <sys/sysproto.h>
#include <sys/kernel.h>
#include <sys/proc.h>
-#include <sys/reboot.h>
#include <sys/sysctl.h>
#include <sys/utsname.h>
-#include <sys/signalvar.h>
-/* This implements a "TEXT_SET" for cleanup functions */
-static void dummy_cleanup __P((void));
-static void
-dummy_cleanup() {}
-TEXT_SET(cleanup_set, dummy_cleanup);
-
-typedef void (*cleanup_func_t)(void);
-extern const struct linker_set cleanup_set;
-static const cleanup_func_t *cleanups =
- (const cleanup_func_t *)&cleanup_set.ls_items[0];
-
-#ifndef _SYS_SYSPROTO_H_
-struct reboot_args {
- int opt;
-};
-#endif
-/* ARGSUSED */
-int
-reboot(p, uap, retval)
- struct proc *p;
- struct reboot_args *uap;
- int *retval;
-{
- int error;
-
- if ((error = suser(p->p_ucred, &p->p_acflag)))
- return (error);
-
- if (!uap->opt & RB_NOSYNC) {
- printf("\ncleaning up... ");
- while(*cleanups) {
- (**cleanups++)();
- }
- }
-
- boot(uap->opt);
- return (0);
-}
#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
@@ -180,20 +140,6 @@ oquota(p, uap, retval)
}
#endif /* COMPAT_43 */
-void
-shutdown_nice(void)
-{
- /* Send a signal to init(8) and have it shutdown the world */
- if (initproc != NULL) {
- psignal(initproc, SIGINT);
- } else {
- /* No init(8) running, so simply reboot */
- boot(RB_NOSYNC);
- }
- return;
-}
-
-
#ifndef _SYS_SYSPROTO_H_
struct uname_args {
struct utsname *name;
diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c
index b91c84e..bd6ff58 100644
--- a/sys/kern/subr_prf.c
+++ b/sys/kern/subr_prf.c
@@ -36,23 +36,19 @@
* SUCH DAMAGE.
*
* @(#)subr_prf.c 8.3 (Berkeley) 1/21/94
- * $Id: subr_prf.c,v 1.36 1996/05/08 04:28:51 gpalmer Exp $
+ * $Id: subr_prf.c,v 1.37 1996/05/09 18:58:06 gpalmer Exp $
*/
#include "opt_ddb.h"
#include <sys/param.h>
#include <sys/systm.h>
-#include <sys/reboot.h>
#include <sys/msgbuf.h>
#include <sys/proc.h>
-#include <sys/vnode.h>
#include <sys/tty.h>
#include <sys/tprintf.h>
#include <sys/syslog.h>
#include <sys/malloc.h>
-#include <sys/kernel.h>
-#include <sys/sysctl.h>
#include <machine/cons.h>
/*
@@ -61,17 +57,6 @@
*/
#include <machine/stdarg.h>
-#if defined(DDB)
-#ifdef DDB_UNATTENDED
- static int debugger_on_panic = 0;
-#else
- static int debugger_on_panic = 1;
-#endif
-
-SYSCTL_INT(_debug, OID_AUTO, debugger_on_panic, CTLFLAG_RW,
- &debugger_on_panic, 0, "");
-#endif
-
#define TOCONS 0x01
#define TOTTY 0x02
#define TOLOG 0x04
@@ -79,7 +64,6 @@ SYSCTL_INT(_debug, OID_AUTO, debugger_on_panic, CTLFLAG_RW,
struct tty *constty; /* pointer to console "window" tty */
static void (*v_putc)(int) = cnputc; /* routine to putc on virtual console */
-
static void logpri __P((int level));
static void msglogchar(int c, void *dummyarg);
struct putchar_arg {int flags; struct tty *tty; };
@@ -89,45 +73,6 @@ static char *ksprintn __P((u_long num, int base, int *len));
static int consintr = 1; /* Ok to handle console interrupts? */
/*
- * Variable panicstr contains argument to first call to panic; used as flag
- * to indicate that the kernel has already called panic.
- */
-const char *panicstr;
-
-/*
- * Panic is called on unresolvable fatal errors. It prints "panic: mesg",
- * and then reboots. If we are called twice, then we avoid trying to sync
- * the disks as this often leads to recursive panics.
- */
-#ifdef __GNUC__
-__dead /* panic() does not return */
-#endif
-void
-panic(const char *fmt, ...)
-{
- int bootopt;
- va_list ap;
-
- bootopt = RB_AUTOBOOT | RB_DUMP;
- if (panicstr)
- bootopt |= RB_NOSYNC;
- else
- panicstr = fmt;
-
- printf("panic: ");
- va_start(ap, fmt);
- vprintf(fmt, ap);
- va_end(ap);
- printf("\n");
-
-#if defined(DDB)
- if (debugger_on_panic)
- Debugger ("panic");
-#endif
- boot(bootopt);
-}
-
-/*
* Warn that a system table is full.
*/
void
OpenPOWER on IntegriCloud