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.

efiprefix.c 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * Copyright (C) 2009 Michael Brown <mbrown@fensystems.co.uk>.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  17. * 02110-1301, USA.
  18. */
  19. FILE_LICENCE ( GPL2_OR_LATER );
  20. #include <stdlib.h>
  21. #include <errno.h>
  22. #include <ipxe/device.h>
  23. #include <ipxe/efi/efi.h>
  24. #include <ipxe/efi/efi_driver.h>
  25. #include <ipxe/efi/efi_snp.h>
  26. #include <ipxe/efi/efi_autoboot.h>
  27. /**
  28. * EFI entry point
  29. *
  30. * @v image_handle Image handle
  31. * @v systab System table
  32. * @ret efirc EFI return status code
  33. */
  34. EFI_STATUS EFIAPI _efi_start ( EFI_HANDLE image_handle,
  35. EFI_SYSTEM_TABLE *systab ) {
  36. EFI_STATUS efirc;
  37. int rc;
  38. /* Initialise EFI environment */
  39. if ( ( efirc = efi_init ( image_handle, systab ) ) != 0 )
  40. goto err_init;
  41. /* Record autoboot device (if any) */
  42. efi_set_autoboot();
  43. /* Claim SNP devices for use by iPXE */
  44. efi_snp_claim();
  45. /* Call to main() */
  46. if ( ( rc = main() ) != 0 ) {
  47. efirc = EFIRC ( rc );
  48. goto err_main;
  49. }
  50. err_main:
  51. efi_snp_release();
  52. efi_loaded_image->Unload ( image_handle );
  53. efi_driver_reconnect_all();
  54. err_init:
  55. return efirc;
  56. }
  57. /**
  58. * Probe EFI root bus
  59. *
  60. * @v rootdev EFI root device
  61. */
  62. static int efi_probe ( struct root_device *rootdev __unused ) {
  63. return efi_driver_connect_all();
  64. }
  65. /**
  66. * Remove EFI root bus
  67. *
  68. * @v rootdev EFI root device
  69. */
  70. static void efi_remove ( struct root_device *rootdev __unused ) {
  71. efi_driver_disconnect_all();
  72. }
  73. /** EFI root device driver */
  74. static struct root_driver efi_root_driver = {
  75. .probe = efi_probe,
  76. .remove = efi_remove,
  77. };
  78. /** EFI root device */
  79. struct root_device efi_root_device __root_device = {
  80. .dev = { .name = "EFI" },
  81. .driver = &efi_root_driver,
  82. };