XenPlatformHasAcpiDtDxe.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /** @file
  2. Decide whether the firmware should expose an ACPI- and/or a Device Tree-based
  3. hardware description to the operating system.
  4. Copyright (c) 2017, Red Hat, Inc.
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #include <Guid/PlatformHasAcpi.h>
  8. #include <Guid/PlatformHasDeviceTree.h>
  9. #include <Library/BaseLib.h>
  10. #include <Library/DebugLib.h>
  11. #include <Library/UefiBootServicesTableLib.h>
  12. EFI_STATUS
  13. EFIAPI
  14. XenPlatformHasAcpiDt (
  15. IN EFI_HANDLE ImageHandle,
  16. IN EFI_SYSTEM_TABLE *SystemTable
  17. )
  18. {
  19. EFI_STATUS Status;
  20. //
  21. // If we fail to install any of the necessary protocols below, the OS will be
  22. // unbootable anyway (due to lacking hardware description), so tolerate no
  23. // errors here.
  24. //
  25. // Always make ACPI available on 64-bit systems.
  26. //
  27. if (MAX_UINTN == MAX_UINT64) {
  28. Status = gBS->InstallProtocolInterface (
  29. &ImageHandle,
  30. &gEdkiiPlatformHasAcpiGuid,
  31. EFI_NATIVE_INTERFACE,
  32. NULL
  33. );
  34. if (EFI_ERROR (Status)) {
  35. goto Failed;
  36. }
  37. }
  38. //
  39. // Expose the Device Tree unconditionally.
  40. //
  41. Status = gBS->InstallProtocolInterface (
  42. &ImageHandle,
  43. &gEdkiiPlatformHasDeviceTreeGuid,
  44. EFI_NATIVE_INTERFACE,
  45. NULL
  46. );
  47. if (EFI_ERROR (Status)) {
  48. goto Failed;
  49. }
  50. return Status;
  51. Failed:
  52. ASSERT_EFI_ERROR (Status);
  53. CpuDeadLoop ();
  54. //
  55. // Keep compilers happy.
  56. //
  57. return Status;
  58. }