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.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. NFS - RFC1094, RFC1813 (v3, useful for clarifications, not implemented)
  12. IGMP - RFC1112
  13. **************************************************************************/
  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. static struct feature features[0] __table_start ( struct feature, features );
  26. static struct feature features_end[0] __table_end ( struct feature, features );
  27. /**
  28. * Main entry point
  29. *
  30. * @ret rc Return status code
  31. */
  32. __asmcall int main ( void ) {
  33. struct feature *feature;
  34. struct image *image;
  35. /* Some devices take an unreasonably long time to initialise */
  36. printf ( PRODUCT_SHORT_NAME " initialising devices...\n" );
  37. initialise();
  38. startup();
  39. /*
  40. * Print welcome banner
  41. *
  42. *
  43. * If you wish to brand this build of gPXE, please do so by
  44. * defining the string PRODUCT_NAME in config/general.h.
  45. *
  46. * While nothing in the GPL prevents you from removing all
  47. * references to gPXE or http://etherboot.org, we prefer you
  48. * not to do so.
  49. *
  50. */
  51. printf ( NORMAL "\n\n" PRODUCT_NAME "\n" BOLD "gPXE " VERSION
  52. NORMAL " -- Open Source Boot Firmware -- "
  53. CYAN "http://etherboot.org" NORMAL "\n"
  54. "Features:" );
  55. for ( feature = features ; feature < features_end ; feature++ )
  56. printf ( " %s", feature->name );
  57. printf ( "\n" );
  58. /* Prompt for shell */
  59. if ( shell_banner() ) {
  60. /* User wants shell; just give them a shell */
  61. shell();
  62. } else {
  63. /* User doesn't want shell; load and execute the first
  64. * image, or autoboot() if we have no images. If
  65. * booting fails for any reason, offer a second chance
  66. * to enter the shell for diagnostics.
  67. */
  68. if ( have_images() ) {
  69. for_each_image ( image ) {
  70. image_exec ( image );
  71. break;
  72. }
  73. } else {
  74. autoboot();
  75. }
  76. if ( shell_banner() )
  77. shell();
  78. }
  79. shutdown ( SHUTDOWN_EXIT | shutdown_exit_flags );
  80. return 0;
  81. }