]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/Bhyve/AcpiPlatformDxe/EntryPoint.c
OvmfPkg: Apply uncrustify changes
[mirror_edk2.git] / OvmfPkg / Bhyve / AcpiPlatformDxe / EntryPoint.c
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>
11 #include "AcpiPlatform.h"
12
13 STATIC
14 EFI_ACPI_TABLE_PROTOCOL *
15 FindAcpiTableProtocol (
16 VOID
17 )
18 {
19 EFI_STATUS Status;
20 EFI_ACPI_TABLE_PROTOCOL *AcpiTable;
21
22 Status = gBS->LocateProtocol (
23 &gEfiAcpiTableProtocolGuid,
24 NULL,
25 (VOID **)&AcpiTable
26 );
27 ASSERT_EFI_ERROR (Status);
28 return AcpiTable;
29 }
30
31 STATIC
32 VOID
33 EFIAPI
34 OnRootBridgesConnected (
35 IN EFI_EVENT Event,
36 IN VOID *Context
37 )
38 {
39 EFI_STATUS Status;
40
41 DEBUG ((
42 DEBUG_INFO,
43 "%a: root bridges have been connected, installing ACPI tables\n",
44 __FUNCTION__
45 ));
46 Status = InstallAcpiTables (FindAcpiTableProtocol ());
47 if (EFI_ERROR (Status)) {
48 DEBUG ((DEBUG_ERROR, "%a: InstallAcpiTables: %r\n", __FUNCTION__, Status));
49 }
50
51 gBS->CloseEvent (Event);
52 }
53
54 EFI_STATUS
55 EFIAPI
56 AcpiPlatformEntryPoint (
57 IN EFI_HANDLE ImageHandle,
58 IN EFI_SYSTEM_TABLE *SystemTable
59 )
60 {
61 EFI_STATUS Status;
62 EFI_EVENT RootBridgesConnected;
63
64 //
65 // If the platform doesn't support PCI, or PCI enumeration has been disabled,
66 // install the tables at once, and let the entry point's return code reflect
67 // the full functionality.
68 //
69 if (PcdGetBool (PcdPciDisableBusEnumeration)) {
70 DEBUG ((
71 DEBUG_INFO,
72 "%a: PCI or its enumeration disabled, installing "
73 "ACPI tables\n",
74 __FUNCTION__
75 ));
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 (
86 EVT_NOTIFY_SIGNAL,
87 TPL_CALLBACK,
88 OnRootBridgesConnected,
89 NULL /* Context */,
90 &gRootBridgesConnectedEventGroupGuid,
91 &RootBridgesConnected
92 );
93 if (!EFI_ERROR (Status)) {
94 DEBUG ((
95 DEBUG_INFO,
96 "%a: waiting for root bridges to be connected, registered callback\n",
97 __FUNCTION__
98 ));
99 }
100
101 return Status;
102 }