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

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