Просмотр исходного кода

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

tags/v0.9.4
Michael Brown 16 лет назад
Родитель
Сommit
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
 
14
 
15
 **************************************************************************/
15
 **************************************************************************/
16
 
16
 
17
+#include <stdio.h>
17
 #include <gpxe/init.h>
18
 #include <gpxe/init.h>
19
+#include <gpxe/features.h>
18
 #include <gpxe/shell.h>
20
 #include <gpxe/shell.h>
19
 #include <gpxe/shell_banner.h>
21
 #include <gpxe/shell_banner.h>
20
 #include <usr/autoboot.h>
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
  * Main entry point
32
  * Main entry point
24
  *
33
  *
25
  * @ret rc		Return status code
34
  * @ret rc		Return status code
26
  */
35
  */
27
 __cdecl int main ( void ) {
36
 __cdecl int main ( void ) {
37
+	struct feature *feature;
28
 
38
 
29
 	initialise();
39
 	initialise();
30
 	startup();
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
 		shell();
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
 		autoboot();
60
 		autoboot();
36
-	
61
+		if ( shell_banner() )
62
+			shell();
63
+	}
64
+
37
 	shutdown();
65
 	shutdown();
38
 
66
 
39
 	return 0;
67
 	return 0;

+ 1
- 18
src/hci/shell_banner.c Просмотреть файл

18
 
18
 
19
 #include <stdio.h>
19
 #include <stdio.h>
20
 #include <console.h>
20
 #include <console.h>
21
-#include <gpxe/features.h>
22
 #include <gpxe/timer.h>
21
 #include <gpxe/timer.h>
23
 #include <gpxe/shell_banner.h>
22
 #include <gpxe/shell_banner.h>
24
 
23
 
30
 
29
 
31
 #define BANNER_TIMEOUT ( 2 * TICKS_PER_SEC )
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
  * Print shell banner and prompt for shell entry
33
  * Print shell banner and prompt for shell entry
42
  *
34
  *
44
  */
36
  */
45
 int shell_banner ( void ) {
37
 int shell_banner ( void ) {
46
 	unsigned long timeout = ( currticks() + BANNER_TIMEOUT );
38
 	unsigned long timeout = ( currticks() + BANNER_TIMEOUT );
47
-	struct feature *feature;
48
-	int key;
49
 	int enter_shell = 0;
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
 	printf ( "\nPress Ctrl-B for the gPXE command line..." );
42
 	printf ( "\nPress Ctrl-B for the gPXE command line..." );
60
 
43
 
61
 	/* Wait for key */
44
 	/* Wait for key */

Загрузка…
Отмена
Сохранить