1ca987d46SWarner Losh /* 2ca987d46SWarner Losh * $NetBSD: panic.c,v 1.2 1997/03/22 01:48:36 thorpej Exp $ 3ca987d46SWarner Losh */ 4ca987d46SWarner Losh /*- 5ca987d46SWarner Losh * Copyright (c) 1996 6ca987d46SWarner Losh * Matthias Drochner. All rights reserved. 7ca987d46SWarner Losh * 8ca987d46SWarner Losh * Redistribution and use in source and binary forms, with or without 9ca987d46SWarner Losh * modification, are permitted provided that the following conditions 10ca987d46SWarner Losh * are met: 11ca987d46SWarner Losh * 1. Redistributions of source code must retain the above copyright 12ca987d46SWarner Losh * notice, this list of conditions and the following disclaimer. 13ca987d46SWarner Losh * 2. Redistributions in binary form must reproduce the above copyright 14ca987d46SWarner Losh * notice, this list of conditions and the following disclaimer in the 15ca987d46SWarner Losh * documentation and/or other materials provided with the distribution. 16ca987d46SWarner Losh * 3. All advertising materials mentioning features or use of this software 17ca987d46SWarner Losh * must display the following acknowledgement: 18ca987d46SWarner Losh * This product includes software developed for the NetBSD Project 19ca987d46SWarner Losh * by Matthias Drochner. 20ca987d46SWarner Losh * 4. The name of the author may not be used to endorse or promote products 21ca987d46SWarner Losh * derived from this software without specific prior written permission. 22ca987d46SWarner Losh * 23ca987d46SWarner Losh * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 24ca987d46SWarner Losh * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 25ca987d46SWarner Losh * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 26ca987d46SWarner Losh * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 27ca987d46SWarner Losh * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 28ca987d46SWarner Losh * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29ca987d46SWarner Losh * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30ca987d46SWarner Losh * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31ca987d46SWarner Losh * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 32ca987d46SWarner Losh * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33ca987d46SWarner Losh * 34ca987d46SWarner Losh */ 35ca987d46SWarner Losh 36ca987d46SWarner Losh #include <stand.h> 37ca987d46SWarner Losh #include <machine/stdarg.h> 38ca987d46SWarner Losh 39*86bb84d5SWarner Losh /* 40*86bb84d5SWarner Losh * Boot loaders and other standalone programs that wish to have a 41*86bb84d5SWarner Losh * different panic policy can provide their own panic_action rotuine. 42*86bb84d5SWarner Losh */ 43*86bb84d5SWarner Losh __weak_symbol void 44*86bb84d5SWarner Losh panic_action(void) 45*86bb84d5SWarner Losh { 46*86bb84d5SWarner Losh printf("--> Press a key on the console to reboot <--\n"); 47*86bb84d5SWarner Losh getchar(); 48*86bb84d5SWarner Losh printf("Rebooting...\n"); 49*86bb84d5SWarner Losh exit(1); 50*86bb84d5SWarner Losh } 51ca987d46SWarner Losh 52ca987d46SWarner Losh void 53ca987d46SWarner Losh panic(const char *fmt,...) 54ca987d46SWarner Losh { 55ca987d46SWarner Losh va_list ap; 56ca987d46SWarner Losh 57ca987d46SWarner Losh printf("panic: "); 58ca987d46SWarner Losh va_start(ap, fmt); 59ca987d46SWarner Losh vprintf(fmt, ap); 60ca987d46SWarner Losh va_end(ap); 61ca987d46SWarner Losh printf("\n"); 62*86bb84d5SWarner Losh panic_action(); 63ca987d46SWarner Losh } 64