[contrib] Allow Network Protocol header to display in rom-o-matic
[gpxe.git] / src / core / main.c
blob36e6b02f9b4363f2b16c59774da0d0f8e440889b
1 /**************************************************************************
2 gPXE - Network Bootstrap Program
4 Literature dealing with the network protocols:
5 ARP - RFC826
6 RARP - RFC903
7 UDP - RFC768
8 BOOTP - RFC951, RFC2132 (vendor extensions)
9 DHCP - RFC2131, RFC2132 (options)
10 TFTP - RFC1350, RFC2347 (options), RFC2348 (blocksize), RFC2349 (tsize)
11 RPC - RFC1831, RFC1832 (XDR), RFC1833 (rpcbind/portmapper)
13 **************************************************************************/
15 FILE_LICENCE ( GPL2_OR_LATER );
17 #include <stdio.h>
18 #include <gpxe/init.h>
19 #include <gpxe/features.h>
20 #include <gpxe/shell.h>
21 #include <gpxe/shell_banner.h>
22 #include <gpxe/image.h>
23 #include <usr/autoboot.h>
24 #include <config/general.h>
26 #define NORMAL "\033[0m"
27 #define BOLD "\033[1m"
28 #define CYAN "\033[36m"
30 /**
31 * Main entry point
33 * @ret rc Return status code
35 __asmcall int main ( void ) {
36 struct feature *feature;
37 struct image *image;
39 /* Some devices take an unreasonably long time to initialise */
40 printf ( PRODUCT_SHORT_NAME " initialising devices..." );
41 initialise();
42 startup();
43 printf ( "ok\n" );
46 * Print welcome banner
49 * If you wish to brand this build of gPXE, please do so by
50 * defining the string PRODUCT_NAME in config/general.h.
52 * While nothing in the GPL prevents you from removing all
53 * references to gPXE or http://etherboot.org, we prefer you
54 * not to do so.
57 printf ( NORMAL "\n\n" PRODUCT_NAME "\n" BOLD "gPXE " VERSION
58 NORMAL " -- Open Source Boot Firmware -- "
59 CYAN "http://etherboot.org" NORMAL "\n"
60 "Features:" );
61 for_each_table_entry ( feature, FEATURES )
62 printf ( " %s", feature->name );
63 printf ( "\n" );
65 /* Prompt for shell */
66 if ( shell_banner() ) {
67 /* User wants shell; just give them a shell */
68 shell();
69 } else {
70 /* User doesn't want shell; load and execute the first
71 * image, or autoboot() if we have no images. If
72 * booting fails for any reason, offer a second chance
73 * to enter the shell for diagnostics.
75 if ( have_images() ) {
76 for_each_image ( image ) {
77 image_exec ( image );
78 break;
80 } else {
81 autoboot();
84 if ( shell_banner() )
85 shell();
88 shutdown ( SHUTDOWN_EXIT | shutdown_exit_flags );
90 return 0;