Browse Source

Separated out (and tidied up) shell banner code

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
4919646fb9
2 changed files with 77 additions and 0 deletions
  1. 65
    0
      src/hci/shell_banner.c
  2. 12
    0
      src/include/gpxe/shell_banner.h

+ 65
- 0
src/hci/shell_banner.c View File

@@ -0,0 +1,65 @@
1
+/*
2
+ * Copyright (C) 2006 Michael Brown <mbrown@fensystems.co.uk>.
3
+ *
4
+ * This program is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU General Public License as
6
+ * published by the Free Software Foundation; either version 2 of the
7
+ * License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful, but
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
+ * General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program; if not, write to the Free Software
16
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
+ */
18
+
19
+#include <console.h>
20
+#include <latch.h>
21
+#include <gpxe/shell_banner.h>
22
+
23
+/** @file
24
+ *
25
+ * Shell startup banner
26
+ *
27
+ */
28
+
29
+#define BANNER_TIMEOUT ( 2 * TICKS_PER_SEC )
30
+
31
+#define NORMAL	"\033[0m"
32
+#define BOLD	"\033[1m"
33
+#define CYAN	"\033[36m"
34
+
35
+/**
36
+ * Print shell banner and prompt for shell entry
37
+ *
38
+ * @ret	enter_shell		User wants to enter shell
39
+ */
40
+int shell_banner ( void ) {
41
+	unsigned long timeout = ( currticks() + BANNER_TIMEOUT );
42
+	int key;
43
+	int enter_shell = 0;
44
+
45
+	/* Print welcome banner */
46
+	printf ( "\n\n\n" BOLD "gPXE " VERSION
47
+		 NORMAL " -- Open Source Boot Firmware -- "
48
+		 CYAN "http://etherboot.org" NORMAL "\n"
49
+		 "Press Ctrl-B for the gPXE command line..." );
50
+
51
+	/* Wait for key */
52
+	while ( currticks() < timeout ) {
53
+		if ( iskey() ) {
54
+			key = getchar();
55
+			if ( key == 0x02 /* Ctrl-B */ )
56
+				enter_shell = 1;
57
+			break;
58
+		}
59
+	}
60
+
61
+	/* Clear the "Press Ctrl-B" line */
62
+	printf ( "\r                                         \r" );
63
+
64
+	return enter_shell;
65
+}

+ 12
- 0
src/include/gpxe/shell_banner.h View File

@@ -0,0 +1,12 @@
1
+#ifndef _GPXE_SHELL_BANNER_H
2
+#define _GPXE_SHELL_BANNER_H
3
+
4
+/** @file
5
+ *
6
+ * Shell startup banner
7
+ *
8
+ */
9
+
10
+extern int shell_banner ( void );
11
+
12
+#endif /* _GPXE_SHELL_BANNER_H */

Loading…
Cancel
Save