KvmtoolPlatformDxe.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /** @file
  2. The KvmtoolPlatformDxe performs the platform specific initialization like:
  3. - It decides if the firmware should expose ACPI or Device Tree-based
  4. hardware description to the operating system.
  5. Copyright (c) 2018 - 2020, ARM Limited. All rights reserved.
  6. SPDX-License-Identifier: BSD-2-Clause-Patent
  7. **/
  8. #include <Guid/VariableFormat.h>
  9. #include <Library/BaseLib.h>
  10. #include <Library/DebugLib.h>
  11. #include <Library/UefiBootServicesTableLib.h>
  12. #include <Protocol/FdtClient.h>
  13. /** Decide if the firmware should expose ACPI tables or Device Tree and
  14. install the appropriate protocol interface.
  15. Note: This function is derived from "ArmVirtPkg/PlatformHasAcpiDtDxe",
  16. by dropping the word size check, and the fw_cfg check.
  17. @param [in] ImageHandle Handle for this image.
  18. @retval EFI_SUCCESS Success.
  19. @retval EFI_OUT_OF_RESOURCES There was not enough memory to install the
  20. protocols.
  21. @retval EFI_INVALID_PARAMETER A parameter is invalid.
  22. **/
  23. STATIC
  24. EFI_STATUS
  25. PlatformHasAcpiDt (
  26. IN EFI_HANDLE ImageHandle
  27. )
  28. {
  29. if (!PcdGetBool (PcdForceNoAcpi)) {
  30. // Expose ACPI tables
  31. return gBS->InstallProtocolInterface (
  32. &ImageHandle,
  33. &gEdkiiPlatformHasAcpiGuid,
  34. EFI_NATIVE_INTERFACE,
  35. NULL
  36. );
  37. }
  38. // Expose the Device Tree.
  39. return gBS->InstallProtocolInterface (
  40. &ImageHandle,
  41. &gEdkiiPlatformHasDeviceTreeGuid,
  42. EFI_NATIVE_INTERFACE,
  43. NULL
  44. );
  45. }
  46. /** Entry point for Kvmtool Platform Dxe
  47. @param [in] ImageHandle Handle for this image.
  48. @param [in] SystemTable Pointer to the EFI system table.
  49. @retval EFI_SUCCESS Success.
  50. @retval EFI_OUT_OF_RESOURCES There was not enough memory to install the
  51. protocols.
  52. @retval EFI_INVALID_PARAMETER A parameter is invalid.
  53. **/
  54. EFI_STATUS
  55. EFIAPI
  56. KvmtoolPlatformDxeEntryPoint (
  57. IN EFI_HANDLE ImageHandle,
  58. IN EFI_SYSTEM_TABLE *SystemTable
  59. )
  60. {
  61. EFI_STATUS Status;
  62. Status = PlatformHasAcpiDt (ImageHandle);
  63. ASSERT_EFI_ERROR (Status);
  64. return Status;
  65. }