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