You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.c 2.2KB

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