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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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_autoboot.h>
  26. /**
  27. * EFI entry point
  28. *
  29. * @v image_handle Image handle
  30. * @v systab System table
  31. * @ret efirc EFI return status code
  32. */
  33. EFI_STATUS EFIAPI _efi_start ( EFI_HANDLE image_handle,
  34. EFI_SYSTEM_TABLE *systab ) {
  35. EFI_STATUS efirc;
  36. int rc;
  37. /* Initialise EFI environment */
  38. if ( ( efirc = efi_init ( image_handle, systab ) ) != 0 )
  39. goto err_init;
  40. /* Record autoboot device (if any) */
  41. efi_set_autoboot();
  42. /* Call to main() */
  43. if ( ( rc = main() ) != 0 ) {
  44. efirc = EFIRC ( rc );
  45. goto err_main;
  46. }
  47. err_main:
  48. efi_loaded_image->Unload ( image_handle );
  49. efi_driver_reconnect_all();
  50. err_init:
  51. return efirc;
  52. }
  53. /**
  54. * Probe EFI root bus
  55. *
  56. * @v rootdev EFI root device
  57. */
  58. static int efi_probe ( struct root_device *rootdev __unused ) {
  59. return efi_driver_connect_all();
  60. }
  61. /**
  62. * Remove EFI root bus
  63. *
  64. * @v rootdev EFI root device
  65. */
  66. static void efi_remove ( struct root_device *rootdev __unused ) {
  67. efi_driver_disconnect_all();
  68. }
  69. /** EFI root device driver */
  70. static struct root_driver efi_root_driver = {
  71. .probe = efi_probe,
  72. .remove = efi_remove,
  73. };
  74. /** EFI root device */
  75. struct root_device efi_root_device __root_device = {
  76. .dev = { .name = "EFI" },
  77. .driver = &efi_root_driver,
  78. };