Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 26 Jan 2018 17:13:00 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r328437 - in head/stand: i386/gptboot libsa
Message-ID:  <201801261713.w0QHD0Up082894@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Fri Jan 26 17:13:00 2018
New Revision: 328437
URL: https://svnweb.freebsd.org/changeset/base/328437

Log:
  Split panic routine
  
  Split panic routine so that the 'Hit Any Key to continue' behavior can
  be overriden.
  
  Sponsored by: Netflix

Modified:
  head/stand/i386/gptboot/gptboot.c
  head/stand/libsa/panic.c
  head/stand/libsa/stand.h

Modified: head/stand/i386/gptboot/gptboot.c
==============================================================================
--- head/stand/i386/gptboot/gptboot.c	Fri Jan 26 10:49:02 2018	(r328436)
+++ head/stand/i386/gptboot/gptboot.c	Fri Jan 26 17:13:00 2018	(r328437)
@@ -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

Modified: head/stand/libsa/panic.c
==============================================================================
--- head/stand/libsa/panic.c	Fri Jan 26 10:49:02 2018	(r328436)
+++ head/stand/libsa/panic.c	Fri Jan 26 17:13:00 2018	(r328437)
@@ -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();
 }

Modified: head/stand/libsa/stand.h
==============================================================================
--- head/stand/libsa/stand.h	Fri Jan 26 10:49:02 2018	(r328436)
+++ head/stand/libsa/stand.h	Fri Jan 26 17:13:00 2018	(r328437)
@@ -368,7 +368,6 @@ static __inline quad_t qmin(quad_t a, quad_t b) { retu
 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 di
  * 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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201801261713.w0QHD0Up082894>