]> git.proxmox.com Git - mirror_edk2.git/blob - ArmVirtPkg/CloudHvPlatformHasAcpiDtDxe/CloudHvHasAcpiDtDxe.c
OvmfPkg/ResetVector: introduce SEV metadata descriptor for VMM use
[mirror_edk2.git] / ArmVirtPkg / CloudHvPlatformHasAcpiDtDxe / CloudHvHasAcpiDtDxe.c
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
5 Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
6
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8 **/
9
10 #include <Guid/PlatformHasAcpi.h>
11 #include <Guid/PlatformHasDeviceTree.h>
12 #include <Library/BaseLib.h>
13 #include <Library/DebugLib.h>
14 #include <Library/PcdLib.h>
15 #include <Library/UefiBootServicesTableLib.h>
16
17 /** Entry point for the Cloud Hypervisor PlatformHasAcpiDtDxe.
18
19 @param [in] ImageHandle Handle for this image.
20 @param [in] SystemTable Pointer to the EFI system table.
21
22 @return EFI_SUCCESS If ACPI or Device Tree based hardware
23 description protocol was installed.
24 @return EFI_INVALID_PARAMETER A parameter was invalid.
25 @return EFI_OUT_OF_RESOURCES Insufficient resources exist to complete
26 the request.
27 **/
28 EFI_STATUS
29 EFIAPI
30 PlatformHasAcpiDt (
31 IN EFI_HANDLE ImageHandle,
32 IN EFI_SYSTEM_TABLE *SystemTable
33 )
34 {
35 EFI_STATUS Status;
36
37 //
38 // If we fail to install any of the necessary protocols below, the OS will be
39 // unbootable anyway (due to lacking hardware description), so tolerate no
40 // errors here.
41 //
42 if ((MAX_UINTN == MAX_UINT64) &&
43 !PcdGetBool (PcdForceNoAcpi))
44 {
45 Status = gBS->InstallProtocolInterface (
46 &ImageHandle,
47 &gEdkiiPlatformHasAcpiGuid,
48 EFI_NATIVE_INTERFACE,
49 NULL
50 );
51 if (EFI_ERROR (Status)) {
52 goto Failed;
53 }
54
55 return Status;
56 }
57
58 //
59 // Expose the Device Tree otherwise.
60 //
61 Status = gBS->InstallProtocolInterface (
62 &ImageHandle,
63 &gEdkiiPlatformHasDeviceTreeGuid,
64 EFI_NATIVE_INTERFACE,
65 NULL
66 );
67 if (EFI_ERROR (Status)) {
68 goto Failed;
69 }
70
71 return Status;
72
73 Failed:
74 ASSERT_EFI_ERROR (Status);
75 CpuDeadLoop ();
76 //
77 // Keep compilers happy.
78 //
79 return Status;
80 }