summaryrefslogtreecommitdiffstats
path: root/src/core/main.c
blob: d58922617aca5a6c54c518af3b5e12ce48ef300e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**************************************************************************
gPXE -  Network Bootstrap Program

Literature dealing with the network protocols:
	ARP - RFC826
	RARP - RFC903
	UDP - RFC768
	BOOTP - RFC951, RFC2132 (vendor extensions)
	DHCP - RFC2131, RFC2132 (options)
	TFTP - RFC1350, RFC2347 (options), RFC2348 (blocksize), RFC2349 (tsize)
	RPC - RFC1831, RFC1832 (XDR), RFC1833 (rpcbind/portmapper)
	NFS - RFC1094, RFC1813 (v3, useful for clarifications, not implemented)
	IGMP - RFC1112

**************************************************************************/

#include <stdio.h>
#include <gpxe/init.h>
#include <gpxe/features.h>
#include <gpxe/shell.h>
#include <gpxe/shell_banner.h>
#include <usr/autoboot.h>

#define NORMAL	"\033[0m"
#define BOLD	"\033[1m"
#define CYAN	"\033[36m"

static struct feature features[0] __table_start ( struct feature, features );
static struct feature features_end[0] __table_end ( struct feature, features );

/**
 * Main entry point
 *
 * @ret rc		Return status code
 */
__cdecl int main ( void ) {
	struct feature *feature;

	initialise();
	startup();

	/* Print welcome banner */
	printf ( NORMAL "\n\n\n" BOLD "gPXE " VERSION
		 NORMAL " -- Open Source Boot Firmware -- "
		 CYAN "http://etherboot.org" NORMAL "\n"
		 "Features:" );
	for ( feature = features ; feature < features_end ; feature++ )
		printf ( " %s", feature->name );
	printf ( "\n" );

	/* Prompt for shell */
	if ( shell_banner() ) {
		/* User wants shell; just give them a shell */
		shell();
	} else {
		/* User doesn't want shell; try booting.  If booting
		 * fails, offer a second chance to enter the shell for
		 * diagnostics.
		 */
		autoboot();
		if ( shell_banner() )
			shell();
	}

	shutdown ( SHUTDOWN_EXIT | shutdown_exit_flags );

	return 0;
}