1 /************************************************************************** 2 gPXE - Network Bootstrap Program 3 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) 12 13 **************************************************************************/ 14 15 FILE_LICENCE ( GPL2_OR_LATER ); 16 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> 25 26 #define NORMAL "\033[0m" 27 #define BOLD "\033[1m" 28 #define CYAN "\033[36m" 29 30 /** 31 * Main entry point 32 * 33 * @ret rc Return status code 34 */ 35 __asmcall int main ( void ) { 36 struct feature *feature; 37 struct image *image; 38 39 /* Some devices take an unreasonably long time to initialise */ 40 printf ( PRODUCT_SHORT_NAME " initialising devices...\n" ); 41 42 initialise(); 43 startup(); 44 45 /* 46 * Print welcome banner 47 * 48 * 49 * If you wish to brand this build of gPXE, please do so by 50 * defining the string PRODUCT_NAME in config/general.h. 51 * 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. 55 * 56 */ 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" ); 64 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. 74 */ 75 if ( have_images() ) { 76 for_each_image ( image ) { 77 image_exec ( image ); 78 break; 79 } 80 } else { 81 autoboot(); 82 } 83 84 if ( shell_banner() ) 85 shell(); 86 } 87 88 shutdown ( SHUTDOWN_EXIT | shutdown_exit_flags ); 89 90 return 0; 91 } 92