瀏覽代碼

[usr] Offer user a second chance to enter the shell on boot failure

tags/v0.9.4
Michael Brown 16 年之前
父節點
當前提交
978996cdae
共有 2 個檔案被更改,包括 32 行新增21 行删除
  1. 31
    3
      src/core/main.c
  2. 1
    18
      src/hci/shell_banner.c

+ 31
- 3
src/core/main.c 查看文件

@@ -14,26 +14,54 @@ Literature dealing with the network protocols:
14 14
 
15 15
 **************************************************************************/
16 16
 
17
+#include <stdio.h>
17 18
 #include <gpxe/init.h>
19
+#include <gpxe/features.h>
18 20
 #include <gpxe/shell.h>
19 21
 #include <gpxe/shell_banner.h>
20 22
 #include <usr/autoboot.h>
21 23
 
24
+#define NORMAL	"\033[0m"
25
+#define BOLD	"\033[1m"
26
+#define CYAN	"\033[36m"
27
+
28
+static struct feature features[0] __table_start ( struct feature, features );
29
+static struct feature features_end[0] __table_end ( struct feature, features );
30
+
22 31
 /**
23 32
  * Main entry point
24 33
  *
25 34
  * @ret rc		Return status code
26 35
  */
27 36
 __cdecl int main ( void ) {
37
+	struct feature *feature;
28 38
 
29 39
 	initialise();
30 40
 	startup();
31 41
 
32
-	if ( shell_banner() )
42
+	/* Print welcome banner */
43
+	printf ( NORMAL "\n\n\n" BOLD "gPXE " VERSION
44
+		 NORMAL " -- Open Source Boot Firmware -- "
45
+		 CYAN "http://etherboot.org" NORMAL "\n"
46
+		 "Features:" );
47
+	for ( feature = features ; feature < features_end ; feature++ )
48
+		printf ( " %s", feature->name );
49
+	printf ( "\n" );
50
+
51
+	/* Prompt for shell */
52
+	if ( shell_banner() ) {
53
+		/* User wants shell; just give them a shell */
33 54
 		shell();
34
-	else
55
+	} else {
56
+		/* User doesn't want shell; try booting.  If booting
57
+		 * fails, offer a second chance to enter the shell for
58
+		 * diagnostics.
59
+		 */
35 60
 		autoboot();
36
-	
61
+		if ( shell_banner() )
62
+			shell();
63
+	}
64
+
37 65
 	shutdown();
38 66
 
39 67
 	return 0;

+ 1
- 18
src/hci/shell_banner.c 查看文件

@@ -18,7 +18,6 @@
18 18
 
19 19
 #include <stdio.h>
20 20
 #include <console.h>
21
-#include <gpxe/features.h>
22 21
 #include <gpxe/timer.h>
23 22
 #include <gpxe/shell_banner.h>
24 23
 
@@ -30,13 +29,6 @@
30 29
 
31 30
 #define BANNER_TIMEOUT ( 2 * TICKS_PER_SEC )
32 31
 
33
-#define NORMAL	"\033[0m"
34
-#define BOLD	"\033[1m"
35
-#define CYAN	"\033[36m"
36
-
37
-static struct feature features[0] __table_start ( struct feature, features );
38
-static struct feature features_end[0] __table_end ( struct feature, features );
39
-
40 32
 /**
41 33
  * Print shell banner and prompt for shell entry
42 34
  *
@@ -44,18 +36,9 @@ static struct feature features_end[0] __table_end ( struct feature, features );
44 36
  */
45 37
 int shell_banner ( void ) {
46 38
 	unsigned long timeout = ( currticks() + BANNER_TIMEOUT );
47
-	struct feature *feature;
48
-	int key;
49 39
 	int enter_shell = 0;
40
+	int key;
50 41
 
51
-	/* Print welcome banner */
52
-	printf ( NORMAL "\n\n\n" BOLD "gPXE " VERSION
53
-		 NORMAL " -- Open Source Boot Firmware -- "
54
-		 CYAN "http://etherboot.org" NORMAL "\n"
55
-		 "Features:" );
56
-	for ( feature = features ; feature < features_end ; feature++ ) {
57
-		printf ( " %s", feature->name );
58
-	}
59 42
 	printf ( "\nPress Ctrl-B for the gPXE command line..." );
60 43
 
61 44
 	/* Wait for key */

Loading…
取消
儲存