main.c

Go to the documentation of this file.
00001 /**************************************************************************
00002 gPXE -  Network Bootstrap Program
00003 
00004 Literature dealing with the network protocols:
00005         ARP - RFC826
00006         RARP - RFC903
00007         UDP - RFC768
00008         BOOTP - RFC951, RFC2132 (vendor extensions)
00009         DHCP - RFC2131, RFC2132 (options)
00010         TFTP - RFC1350, RFC2347 (options), RFC2348 (blocksize), RFC2349 (tsize)
00011         RPC - RFC1831, RFC1832 (XDR), RFC1833 (rpcbind/portmapper)
00012 
00013 **************************************************************************/
00014 
00015 FILE_LICENCE ( GPL2_OR_LATER );
00016 
00017 #include <stdio.h>
00018 #include <gpxe/init.h>
00019 #include <gpxe/features.h>
00020 #include <gpxe/shell.h>
00021 #include <gpxe/shell_banner.h>
00022 #include <gpxe/image.h>
00023 #include <usr/autoboot.h>
00024 #include <config/general.h>
00025 
00026 #define NORMAL  "\033[0m"
00027 #define BOLD    "\033[1m"
00028 #define CYAN    "\033[36m"
00029 
00030 /**
00031  * Main entry point
00032  *
00033  * @ret rc              Return status code
00034  */
00035 __asmcall int main ( void ) {
00036         struct feature *feature;
00037         struct image *image;
00038 
00039         /* Some devices take an unreasonably long time to initialise */
00040         printf ( PRODUCT_SHORT_NAME " initialising devices...\n" );
00041 
00042         initialise();
00043         startup();
00044 
00045         /*
00046          * Print welcome banner
00047          *
00048          *
00049          * If you wish to brand this build of gPXE, please do so by
00050          * defining the string PRODUCT_NAME in config/general.h.
00051          *
00052          * While nothing in the GPL prevents you from removing all
00053          * references to gPXE or http://etherboot.org, we prefer you
00054          * not to do so.
00055          *
00056          */
00057         printf ( NORMAL "\n\n" PRODUCT_NAME "\n" BOLD "gPXE " VERSION
00058                  NORMAL " -- Open Source Boot Firmware -- "
00059                  CYAN "http://etherboot.org" NORMAL "\n"
00060                  "Features:" );
00061         for_each_table_entry ( feature, FEATURES )
00062                 printf ( " %s", feature->name );
00063         printf ( "\n" );
00064 
00065         /* Prompt for shell */
00066         if ( shell_banner() ) {
00067                 /* User wants shell; just give them a shell */
00068                 shell();
00069         } else {
00070                 /* User doesn't want shell; load and execute the first
00071                  * image, or autoboot() if we have no images.  If
00072                  * booting fails for any reason, offer a second chance
00073                  * to enter the shell for diagnostics.
00074                  */
00075                 if ( have_images() ) {
00076                         for_each_image ( image ) {
00077                                 image_exec ( image );
00078                                 break;
00079                         }
00080                 } else {
00081                         autoboot();
00082                 }
00083 
00084                 if ( shell_banner() )
00085                         shell();
00086         }
00087 
00088         shutdown ( SHUTDOWN_EXIT | shutdown_exit_flags );
00089 
00090         return 0;
00091 }

Generated on Tue Apr 6 20:00:51 2010 for gPXE by  doxygen 1.5.7.1