Split panic routine

Split panic routine so that the 'Hit Any Key to continue' behavior can
be overriden.

Sponsored by: Netflix
This commit is contained in:
Warner Losh 2018-01-26 17:13:00 +00:00
parent e23ae408c0
commit 86bb84d576
3 changed files with 16 additions and 9 deletions

View File

@ -102,7 +102,6 @@ static struct bios_smap smap;
static char *heap_next;
static char *heap_end;
void exit(int);
static void load(void);
static int parse_cmds(char *, int *);
static int dskread(void *, daddr_t, unsigned);
@ -365,6 +364,7 @@ main(void)
void
exit(int x)
{
while (1);
}
static void

View File

@ -39,7 +39,18 @@ __FBSDID("$FreeBSD$");
#include <stand.h>
#include <machine/stdarg.h>
extern void exit(int) __dead2;
/*
* Boot loaders and other standalone programs that wish to have a
* different panic policy can provide their own panic_action rotuine.
*/
__weak_symbol void
panic_action(void)
{
printf("--> Press a key on the console to reboot <--\n");
getchar();
printf("Rebooting...\n");
exit(1);
}
void
panic(const char *fmt,...)
@ -51,9 +62,5 @@ panic(const char *fmt,...)
vprintf(fmt, ap);
va_end(ap);
printf("\n");
printf("--> Press a key on the console to reboot <--\n");
getchar();
printf("Rebooting...\n");
exit(1);
panic_action();
}

View File

@ -368,7 +368,6 @@ static __inline quad_t qmin(quad_t a, quad_t b) { return (a < b ? a : b); }
static __inline u_long ulmax(u_long a, u_long b) { return (a > b ? a : b); }
static __inline u_long ulmin(u_long a, u_long b) { return (a < b ? a : b); }
/* null functions for device/filesystem switches (undocumented) */
extern int nodev(void);
extern int noioctl(struct open_file *, u_long, void *);
@ -387,13 +386,14 @@ extern int null_readdir(struct open_file *f, struct dirent *d);
* Machine dependent functions and data, must be provided or stubbed by
* the consumer
*/
extern void exit(int);
extern void exit(int) __dead2;
extern int getchar(void);
extern int ischar(void);
extern void putchar(int);
extern int devopen(struct open_file *, const char *, const char **);
extern int devclose(struct open_file *f);
extern void panic(const char *, ...) __dead2 __printflike(1, 2);
extern void panic_action(void) __weak_symbol __dead2;
extern time_t getsecs(void);
extern struct fs_ops *file_system[];
extern struct fs_ops *exclusive_file_system;