]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/XenAcpiPlatformDxe/EntryPoint.c
OvmfPkg/XenAcpiPlatformDxe: create from AcpiPlatformDxe
[mirror_edk2.git] / OvmfPkg / XenAcpiPlatformDxe / EntryPoint.c
1 /** @file
2 Entry point of OVMF ACPI Platform Driver for Xen guests
3
4 Copyright (C) 2015-2021, 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
37 STATIC
38 VOID
39 EFIAPI
40 OnRootBridgesConnected (
41 IN EFI_EVENT Event,
42 IN VOID *Context
43 )
44 {
45 EFI_STATUS Status;
46
47 DEBUG ((DEBUG_INFO,
48 "%a: root bridges have been connected, installing ACPI tables\n",
49 __FUNCTION__));
50 Status = InstallAcpiTables (FindAcpiTableProtocol ());
51 if (EFI_ERROR (Status)) {
52 DEBUG ((DEBUG_ERROR, "%a: InstallAcpiTables: %r\n", __FUNCTION__, Status));
53 }
54 gBS->CloseEvent (Event);
55 }
56
57
58 EFI_STATUS
59 EFIAPI
60 AcpiPlatformEntryPoint (
61 IN EFI_HANDLE ImageHandle,
62 IN EFI_SYSTEM_TABLE *SystemTable
63 )
64 {
65 EFI_STATUS Status;
66 EFI_EVENT RootBridgesConnected;
67
68 //
69 // If the platform doesn't support PCI, or PCI enumeration has been disabled,
70 // install the tables at once, and let the entry point's return code reflect
71 // the full functionality.
72 //
73 if (PcdGetBool (PcdPciDisableBusEnumeration)) {
74 DEBUG ((DEBUG_INFO, "%a: PCI or its enumeration disabled, installing "
75 "ACPI tables\n", __FUNCTION__));
76 return InstallAcpiTables (FindAcpiTableProtocol ());
77 }
78
79 //
80 // Otherwise, delay installing the ACPI tables until root bridges are
81 // connected. The entry point's return status will only reflect the callback
82 // setup. (Note that we're a DXE_DRIVER; our entry point function is invoked
83 // strictly before BDS is entered and can connect the root bridges.)
84 //
85 Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_CALLBACK,
86 OnRootBridgesConnected, NULL /* Context */,
87 &gRootBridgesConnectedEventGroupGuid, &RootBridgesConnected);
88 if (!EFI_ERROR (Status)) {
89 DEBUG ((DEBUG_INFO,
90 "%a: waiting for root bridges to be connected, registered callback\n",
91 __FUNCTION__));
92 }
93
94 return Status;
95 }