efi_root_node.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. /* Device path to text protocol */
  47. &efi_guid_device_path_to_text_protocol,
  48. (void *)&efi_device_path_to_text,
  49. /* Device path utilities protocol */
  50. &efi_guid_device_path_utilities_protocol,
  51. (void *)&efi_device_path_utilities,
  52. #if CONFIG_IS_ENABLED(EFI_UNICODE_COLLATION_PROTOCOL)
  53. /* Unicode collation protocol */
  54. &efi_guid_unicode_collation_protocol,
  55. (void *)&efi_unicode_collation_protocol,
  56. #endif
  57. #if CONFIG_IS_ENABLED(EFI_LOADER_HII)
  58. /* HII string protocol */
  59. &efi_guid_hii_string_protocol,
  60. (void *)&efi_hii_string,
  61. /* HII database protocol */
  62. &efi_guid_hii_database_protocol,
  63. (void *)&efi_hii_database,
  64. /* HII configuration routing protocol */
  65. &efi_guid_hii_config_routing_protocol,
  66. (void *)&efi_hii_config_routing,
  67. #endif
  68. NULL));
  69. efi_root->type = EFI_OBJECT_TYPE_U_BOOT_FIRMWARE;
  70. return ret;
  71. }