efi_root_node.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Root node for system services
  4. *
  5. * Copyright (c) 2018 Heinrich Schuchardt
  6. */
  7. #include <common.h>
  8. #include <malloc.h>
  9. #include <efi_dt_fixup.h>
  10. #include <efi_loader.h>
  11. const efi_guid_t efi_u_boot_guid = U_BOOT_GUID;
  12. efi_handle_t efi_root = NULL;
  13. struct efi_root_dp {
  14. struct efi_device_path_vendor vendor;
  15. struct efi_device_path end;
  16. } __packed;
  17. /**
  18. * efi_root_node_register() - create root node
  19. *
  20. * Create the root node on which we install all protocols that are
  21. * not related to a loaded image or a driver.
  22. *
  23. * Return: status code
  24. */
  25. efi_status_t efi_root_node_register(void)
  26. {
  27. efi_status_t ret;
  28. struct efi_root_dp *dp;
  29. /* Create device path protocol */
  30. dp = calloc(1, sizeof(*dp));
  31. if (!dp)
  32. return EFI_OUT_OF_RESOURCES;
  33. /* Fill vendor node */
  34. dp->vendor.dp.type = DEVICE_PATH_TYPE_HARDWARE_DEVICE;
  35. dp->vendor.dp.sub_type = DEVICE_PATH_SUB_TYPE_VENDOR;
  36. dp->vendor.dp.length = sizeof(struct efi_device_path_vendor);
  37. dp->vendor.guid = efi_u_boot_guid;
  38. /* Fill end node */
  39. dp->end.type = DEVICE_PATH_TYPE_END;
  40. dp->end.sub_type = DEVICE_PATH_SUB_TYPE_END;
  41. dp->end.length = sizeof(struct efi_device_path);
  42. /* Create root node and install protocols */
  43. ret = EFI_CALL(efi_install_multiple_protocol_interfaces
  44. (&efi_root,
  45. /* Device path protocol */
  46. &efi_guid_device_path, dp,
  47. #if CONFIG_IS_ENABLED(EFI_DEVICE_PATH_TO_TEXT)
  48. /* Device path to text protocol */
  49. &efi_guid_device_path_to_text_protocol,
  50. (void *)&efi_device_path_to_text,
  51. #endif
  52. /* Device path utilities protocol */
  53. &efi_guid_device_path_utilities_protocol,
  54. (void *)&efi_device_path_utilities,
  55. #if !CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE)
  56. /* Device-tree fix-up protocol */
  57. &efi_guid_dt_fixup_protocol,
  58. (void *)&efi_dt_fixup_prot,
  59. #endif
  60. #if CONFIG_IS_ENABLED(EFI_UNICODE_COLLATION_PROTOCOL2)
  61. #if CONFIG_IS_ENABLED(EFI_UNICODE_COLLATION_PROTOCOL)
  62. /* Deprecated Unicode collation protocol */
  63. &efi_guid_unicode_collation_protocol,
  64. (void *)&efi_unicode_collation_protocol,
  65. #endif
  66. /* Current Unicode collation protocol */
  67. &efi_guid_unicode_collation_protocol2,
  68. (void *)&efi_unicode_collation_protocol2,
  69. #endif
  70. #if CONFIG_IS_ENABLED(EFI_LOADER_HII)
  71. /* HII string protocol */
  72. &efi_guid_hii_string_protocol,
  73. (void *)&efi_hii_string,
  74. /* HII database protocol */
  75. &efi_guid_hii_database_protocol,
  76. (void *)&efi_hii_database,
  77. #endif
  78. NULL));
  79. efi_root->type = EFI_OBJECT_TYPE_U_BOOT_FIRMWARE;
  80. return ret;
  81. }