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

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