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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. If booting fails (i.e. if the image
  65. * returns, or fails to execute), offer a second
  66. * chance to enter the shell for diagnostics.
  67. */
  68. for_each_image ( image ) {
  69. image_exec ( image );
  70. break;
  71. }
  72. if ( shell_banner() )
  73. shell();
  74. }
  75. shutdown ( SHUTDOWN_EXIT | shutdown_exit_flags );
  76. return 0;
  77. }