efi_root_node.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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_loader.h>
  10. const efi_guid_t efi_u_boot_guid = U_BOOT_GUID;
  11. efi_handle_t efi_root = NULL;
  12. struct efi_root_dp {
  13. struct efi_device_path_vendor vendor;
  14. struct efi_device_path end;
  15. } __packed;
  16. /**
  17. * efi_root_node_register() - create root node
  18. *
  19. * Create the root node on which we install all protocols that are
  20. * not related to a loaded image or a driver.
  21. *
  22. * Return: status code
  23. */
  24. efi_status_t efi_root_node_register(void)
  25. {
  26. efi_status_t ret;
  27. struct efi_root_dp *dp;
  28. /* Create device path protocol */
  29. dp = calloc(1, sizeof(*dp));
  30. if (!dp)
  31. return EFI_OUT_OF_RESOURCES;
  32. /* Fill vendor node */
  33. dp->vendor.dp.type = DEVICE_PATH_TYPE_HARDWARE_DEVICE;
  34. dp->vendor.dp.sub_type = DEVICE_PATH_SUB_TYPE_VENDOR;
  35. dp->vendor.dp.length = sizeof(struct efi_device_path_vendor);
  36. dp->vendor.guid = efi_u_boot_guid;
  37. /* Fill end node */
  38. dp->end.type = DEVICE_PATH_TYPE_END;
  39. dp->end.sub_type = DEVICE_PATH_SUB_TYPE_END;
  40. dp->end.length = sizeof(struct efi_device_path);
  41. /* Create root node and install protocols */
  42. ret = EFI_CALL(efi_install_multiple_protocol_interfaces
  43. (&efi_root,
  44. /* Device path protocol */
  45. &efi_guid_device_path, dp,
  46. #if CONFIG_IS_ENABLED(EFI_DEVICE_PATH_TO_TEXT)
  47. /* Device path to text protocol */
  48. &efi_guid_device_path_to_text_protocol,
  49. (void *)&efi_device_path_to_text,
  50. #endif
  51. /* Device path utilities protocol */
  52. &efi_guid_device_path_utilities_protocol,
  53. (void *)&efi_device_path_utilities,
  54. #if CONFIG_IS_ENABLED(EFI_UNICODE_COLLATION_PROTOCOL2)
  55. #if CONFIG_IS_ENABLED(EFI_UNICODE_COLLATION_PROTOCOL)
  56. /* Deprecated Unicode collation protocol */
  57. &efi_guid_unicode_collation_protocol,
  58. (void *)&efi_unicode_collation_protocol,
  59. #endif
  60. /* Current Unicode collation protocol */
  61. &efi_guid_unicode_collation_protocol2,
  62. (void *)&efi_unicode_collation_protocol2,
  63. #endif
  64. #if CONFIG_IS_ENABLED(EFI_LOADER_HII)
  65. /* HII string protocol */
  66. &efi_guid_hii_string_protocol,
  67. (void *)&efi_hii_string,
  68. /* HII database protocol */
  69. &efi_guid_hii_database_protocol,
  70. (void *)&efi_hii_database,
  71. /* HII configuration routing protocol */
  72. &efi_guid_hii_config_routing_protocol,
  73. (void *)&efi_hii_config_routing,
  74. #endif
  75. NULL));
  76. efi_root->type = EFI_OBJECT_TYPE_U_BOOT_FIRMWARE;
  77. return ret;
  78. }