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