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