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) 2017, Red Hat, Inc.
|
---|
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/UefiBootServicesTableLib.h>
|
---|
15 |
|
---|
16 | EFI_STATUS
|
---|
17 | EFIAPI
|
---|
18 | XenPlatformHasAcpiDt (
|
---|
19 | IN EFI_HANDLE ImageHandle,
|
---|
20 | IN EFI_SYSTEM_TABLE *SystemTable
|
---|
21 | )
|
---|
22 | {
|
---|
23 | EFI_STATUS Status;
|
---|
24 |
|
---|
25 | //
|
---|
26 | // If we fail to install any of the necessary protocols below, the OS will be
|
---|
27 | // unbootable anyway (due to lacking hardware description), so tolerate no
|
---|
28 | // errors here.
|
---|
29 | //
|
---|
30 | // Always make ACPI available on 64-bit systems.
|
---|
31 | //
|
---|
32 | if (MAX_UINTN == MAX_UINT64) {
|
---|
33 | Status = gBS->InstallProtocolInterface (
|
---|
34 | &ImageHandle,
|
---|
35 | &gEdkiiPlatformHasAcpiGuid,
|
---|
36 | EFI_NATIVE_INTERFACE,
|
---|
37 | NULL
|
---|
38 | );
|
---|
39 | if (EFI_ERROR (Status)) {
|
---|
40 | goto Failed;
|
---|
41 | }
|
---|
42 | }
|
---|
43 |
|
---|
44 | //
|
---|
45 | // Expose the Device Tree unconditionally.
|
---|
46 | //
|
---|
47 | Status = gBS->InstallProtocolInterface (
|
---|
48 | &ImageHandle,
|
---|
49 | &gEdkiiPlatformHasDeviceTreeGuid,
|
---|
50 | EFI_NATIVE_INTERFACE,
|
---|
51 | NULL
|
---|
52 | );
|
---|
53 | if (EFI_ERROR (Status)) {
|
---|
54 | goto Failed;
|
---|
55 | }
|
---|
56 |
|
---|
57 | return Status;
|
---|
58 |
|
---|
59 | Failed:
|
---|
60 | ASSERT_EFI_ERROR (Status);
|
---|
61 | CpuDeadLoop ();
|
---|
62 | //
|
---|
63 | // Keep compilers happy.
|
---|
64 | //
|
---|
65 | return Status;
|
---|
66 | }
|
---|