Deleted Added
full compact
kern_shutdown.c (39522) kern_shutdown.c (40751)
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
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 * $Id: kern_shutdown.c,v 1.39 1998/09/15 08:49:52 gibbs Exp $
39 * $Id: kern_shutdown.c,v 1.40 1998/09/20 16:50:31 dt Exp $
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>

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

106
107/*
108 * callout list for things to do a shutdown
109 */
110typedef struct shutdown_list_element {
111 LIST_ENTRY(shutdown_list_element) links;
112 bootlist_fn function;
113 void *arg;
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>

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

106
107/*
108 * callout list for things to do a shutdown
109 */
110typedef struct shutdown_list_element {
111 LIST_ENTRY(shutdown_list_element) links;
112 bootlist_fn function;
113 void *arg;
114 int priority;
114} *sle_p;
115
116/*
117 * There are three shutdown lists. Some things need to be shut down
118 * earlier than others.
119 */
120LIST_HEAD(shutdown_list, shutdown_list_element);
121

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

270 dumpsys();
271 }
272
273 /* Now that we're going to really halt the system... */
274 LIST_FOREACH(ep, &shutdown_lists[SHUTDOWN_FINAL], links)
275 (*ep->function)(howto, ep->arg);
276
277 if (howto & RB_HALT) {
115} *sle_p;
116
117/*
118 * There are three shutdown lists. Some things need to be shut down
119 * earlier than others.
120 */
121LIST_HEAD(shutdown_list, shutdown_list_element);
122

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

271 dumpsys();
272 }
273
274 /* Now that we're going to really halt the system... */
275 LIST_FOREACH(ep, &shutdown_lists[SHUTDOWN_FINAL], links)
276 (*ep->function)(howto, ep->arg);
277
278 if (howto & RB_HALT) {
278 cpu_power_down();
279 printf("\n");
280 printf("The operating system has halted.\n");
281 printf("Please press any key to reboot.\n\n");
282 switch (cngetc()) {
283 case -1: /* No console, just die */
284 cpu_halt();
285 /* NOTREACHED */
286 default:

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

426#if defined(DDB)
427 if (debugger_on_panic)
428 Debugger ("panic");
429#endif
430 boot(bootopt);
431}
432
433/*
279 printf("\n");
280 printf("The operating system has halted.\n");
281 printf("Please press any key to reboot.\n\n");
282 switch (cngetc()) {
283 case -1: /* No console, just die */
284 cpu_halt();
285 /* NOTREACHED */
286 default:

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

426#if defined(DDB)
427 if (debugger_on_panic)
428 Debugger ("panic");
429#endif
430 boot(bootopt);
431}
432
433/*
434 * Two routines to handle adding/deleting items on the
434 * Three routines to handle adding/deleting items on the
435 * shutdown callout lists
436 *
437 * at_shutdown():
438 * Take the arguments given and put them onto the shutdown callout list.
439 * However first make sure that it's not already there.
440 * returns 0 on success.
441 */
442int
443at_shutdown(bootlist_fn function, void *arg, int queue)
444{
435 * shutdown callout lists
436 *
437 * at_shutdown():
438 * Take the arguments given and put them onto the shutdown callout list.
439 * However first make sure that it's not already there.
440 * returns 0 on success.
441 */
442int
443at_shutdown(bootlist_fn function, void *arg, int queue)
444{
445 sle_p ep;
445 return(at_shutdown_pri(function, arg, queue, SHUTDOWN_PRI_DEFAULT));
446}
446
447
448/*
449 * at_shutdown_pri():
450 * Take the arguments given and put them onto the shutdown callout list
451 * with the given execution priority.
452 * returns 0 on success.
453 */
454int
455at_shutdown_pri(bootlist_fn function, void *arg, int queue, int pri)
456{
457 sle_p ep, ip;
458
447 if (queue < SHUTDOWN_PRE_SYNC
448 || queue > SHUTDOWN_FINAL) {
449 printf("at_shutdown: bad exit callout queue %d specified\n",
450 queue);
451 return (EINVAL);
452 }
453 if (rm_at_shutdown(function, arg))
454 printf("at_shutdown: exit callout entry was already present\n");
455 ep = malloc(sizeof(*ep), M_TEMP, M_NOWAIT);
456 if (ep == NULL)
457 return (ENOMEM);
458 ep->function = function;
459 ep->arg = arg;
459 if (queue < SHUTDOWN_PRE_SYNC
460 || queue > SHUTDOWN_FINAL) {
461 printf("at_shutdown: bad exit callout queue %d specified\n",
462 queue);
463 return (EINVAL);
464 }
465 if (rm_at_shutdown(function, arg))
466 printf("at_shutdown: exit callout entry was already present\n");
467 ep = malloc(sizeof(*ep), M_TEMP, M_NOWAIT);
468 if (ep == NULL)
469 return (ENOMEM);
470 ep->function = function;
471 ep->arg = arg;
460 LIST_INSERT_HEAD(&shutdown_lists[queue], ep, links);
472 ep->priority = pri;
473
474 /* Sort into list of items on this queue */
475 ip = LIST_FIRST(&shutdown_lists[queue]);
476 if (ip == NULL) {
477 LIST_INSERT_HEAD(&shutdown_lists[queue], ep, links);
478 } else {
479 for (; LIST_NEXT(ip, links) != NULL; ip = LIST_NEXT(ip, links)) {
480 if (ep->priority < ip->priority) {
481 LIST_INSERT_BEFORE(ip, ep, links);
482 ep = NULL;
483 break;
484 }
485 }
486 if (ep != NULL)
487 LIST_INSERT_AFTER(ip, ep, links);
488 }
461 return (0);
462}
463
464/*
465 * Scan the exit callout lists for the given items and remove them.
466 * Returns the number of items removed.
467 */
468int

--- 18 unchanged lines hidden ---
489 return (0);
490}
491
492/*
493 * Scan the exit callout lists for the given items and remove them.
494 * Returns the number of items removed.
495 */
496int

--- 18 unchanged lines hidden ---