1 | /** @file
|
---|
2 | Entry point of OVMF ACPI Platform Driver
|
---|
3 |
|
---|
4 | Copyright (C) 2015, Red Hat, Inc.
|
---|
5 | Copyright (c) 2008 - 2015, Intel Corporation. All rights reserved.<BR>
|
---|
6 |
|
---|
7 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
8 | **/
|
---|
9 |
|
---|
10 | #include <Guid/RootBridgesConnectedEventGroup.h> // gRootBridgesConnectedEve...
|
---|
11 | #include <Library/DebugLib.h> // DEBUG()
|
---|
12 | #include <Library/PcdLib.h> // PcdGetBool()
|
---|
13 | #include <Library/UefiBootServicesTableLib.h> // gBS
|
---|
14 | #include <Protocol/AcpiTable.h> // EFI_ACPI_TABLE_PROTOCOL
|
---|
15 |
|
---|
16 | #include "AcpiPlatform.h"
|
---|
17 |
|
---|
18 | STATIC
|
---|
19 | EFI_ACPI_TABLE_PROTOCOL *
|
---|
20 | FindAcpiTableProtocol (
|
---|
21 | VOID
|
---|
22 | )
|
---|
23 | {
|
---|
24 | EFI_STATUS Status;
|
---|
25 | EFI_ACPI_TABLE_PROTOCOL *AcpiTable;
|
---|
26 |
|
---|
27 | Status = gBS->LocateProtocol (
|
---|
28 | &gEfiAcpiTableProtocolGuid,
|
---|
29 | NULL,
|
---|
30 | (VOID **)&AcpiTable
|
---|
31 | );
|
---|
32 | ASSERT_EFI_ERROR (Status);
|
---|
33 | return AcpiTable;
|
---|
34 | }
|
---|
35 |
|
---|
36 | STATIC
|
---|
37 | VOID
|
---|
38 | EFIAPI
|
---|
39 | OnRootBridgesConnected (
|
---|
40 | IN EFI_EVENT Event,
|
---|
41 | IN VOID *Context
|
---|
42 | )
|
---|
43 | {
|
---|
44 | EFI_STATUS Status;
|
---|
45 |
|
---|
46 | DEBUG ((
|
---|
47 | DEBUG_INFO,
|
---|
48 | "%a: root bridges have been connected, installing ACPI tables\n",
|
---|
49 | __func__
|
---|
50 | ));
|
---|
51 | Status = InstallAcpiTables (FindAcpiTableProtocol ());
|
---|
52 | if (EFI_ERROR (Status)) {
|
---|
53 | DEBUG ((DEBUG_ERROR, "%a: InstallAcpiTables: %r\n", __func__, Status));
|
---|
54 | }
|
---|
55 |
|
---|
56 | gBS->CloseEvent (Event);
|
---|
57 | }
|
---|
58 |
|
---|
59 | EFI_STATUS
|
---|
60 | EFIAPI
|
---|
61 | AcpiPlatformEntryPoint (
|
---|
62 | IN EFI_HANDLE ImageHandle,
|
---|
63 | IN EFI_SYSTEM_TABLE *SystemTable
|
---|
64 | )
|
---|
65 | {
|
---|
66 | EFI_STATUS Status;
|
---|
67 | EFI_EVENT RootBridgesConnected;
|
---|
68 |
|
---|
69 | //
|
---|
70 | // If the platform doesn't support PCI, or PCI enumeration has been disabled,
|
---|
71 | // install the tables at once, and let the entry point's return code reflect
|
---|
72 | // the full functionality.
|
---|
73 | //
|
---|
74 | if (PcdGetBool (PcdPciDisableBusEnumeration)) {
|
---|
75 | DEBUG ((
|
---|
76 | DEBUG_INFO,
|
---|
77 | "%a: PCI or its enumeration disabled, installing "
|
---|
78 | "ACPI tables\n",
|
---|
79 | __func__
|
---|
80 | ));
|
---|
81 | return InstallAcpiTables (FindAcpiTableProtocol ());
|
---|
82 | }
|
---|
83 |
|
---|
84 | //
|
---|
85 | // Otherwise, delay installing the ACPI tables until root bridges are
|
---|
86 | // connected. The entry point's return status will only reflect the callback
|
---|
87 | // setup. (Note that we're a DXE_DRIVER; our entry point function is invoked
|
---|
88 | // strictly before BDS is entered and can connect the root bridges.)
|
---|
89 | //
|
---|
90 | Status = gBS->CreateEventEx (
|
---|
91 | EVT_NOTIFY_SIGNAL,
|
---|
92 | TPL_CALLBACK,
|
---|
93 | OnRootBridgesConnected,
|
---|
94 | NULL /* Context */,
|
---|
95 | &gRootBridgesConnectedEventGroupGuid,
|
---|
96 | &RootBridgesConnected
|
---|
97 | );
|
---|
98 | if (!EFI_ERROR (Status)) {
|
---|
99 | DEBUG ((
|
---|
100 | DEBUG_INFO,
|
---|
101 | "%a: waiting for root bridges to be connected, registered callback\n",
|
---|
102 | __func__
|
---|
103 | ));
|
---|
104 | }
|
---|
105 |
|
---|
106 | return Status;
|
---|
107 | }
|
---|