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