]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/AcpiPlatformDxe/EntryPoint.c
MdeModulePkg/Bds: Support booting from remote file system.
[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
7 This program and the accompanying materials are licensed and made available\r
8 under the terms and conditions of the BSD License which accompanies this\r
9 distribution. The full text of the license may be found at\r
10 http://opensource.org/licenses/bsd-license.php\r
11\r
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
13 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14**/\r
15\r
818bc86a 16#include <Protocol/PciEnumerationComplete.h>\r
04951644
LE
17#include "AcpiPlatform.h"\r
18\r
19STATIC\r
20EFI_ACPI_TABLE_PROTOCOL *\r
21FindAcpiTableProtocol (\r
22 VOID\r
23 )\r
24{\r
25 EFI_STATUS Status;\r
26 EFI_ACPI_TABLE_PROTOCOL *AcpiTable;\r
27\r
28 Status = gBS->LocateProtocol (\r
29 &gEfiAcpiTableProtocolGuid,\r
30 NULL,\r
31 (VOID**)&AcpiTable\r
32 );\r
33 ASSERT_EFI_ERROR (Status);\r
34 return AcpiTable;\r
35}\r
36\r
818bc86a
LE
37\r
38STATIC\r
39VOID\r
40EFIAPI\r
41OnPciEnumerated (\r
42 IN EFI_EVENT Event,\r
43 IN VOID *Context\r
44 )\r
45{\r
46 EFI_STATUS Status;\r
47\r
48 DEBUG ((EFI_D_INFO, "%a: PCI enumeration complete, installing ACPI tables\n",\r
49 __FUNCTION__));\r
50 Status = InstallAcpiTables (FindAcpiTableProtocol ());\r
51 if (EFI_ERROR (Status)) {\r
52 DEBUG ((EFI_D_ERROR, "%a: InstallAcpiTables: %r\n", __FUNCTION__, Status));\r
53 }\r
54 gBS->CloseEvent (Event);\r
55}\r
56\r
57\r
04951644
LE
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
818bc86a
LE
66 VOID *Interface;\r
67 EFI_EVENT PciEnumerated;\r
68 VOID *Registration;\r
69\r
70 //\r
71 // If the platform doesn't support PCI, or PCI enumeration has been disabled,\r
72 // install the tables at once, and let the entry point's return code reflect\r
73 // the full functionality.\r
74 //\r
75 if (PcdGetBool (PcdPciDisableBusEnumeration)) {\r
76 DEBUG ((EFI_D_INFO, "%a: PCI or its enumeration disabled, installing "\r
77 "ACPI tables\n", __FUNCTION__));\r
78 return InstallAcpiTables (FindAcpiTableProtocol ());\r
79 }\r
80\r
81 //\r
82 // Similarly, if PCI enumeration has already completed, install the tables\r
83 // immediately.\r
84 //\r
85 Status = gBS->LocateProtocol (&gEfiPciEnumerationCompleteProtocolGuid,\r
86 NULL /* Registration */, &Interface);\r
87 if (!EFI_ERROR (Status)) {\r
88 DEBUG ((EFI_D_INFO, "%a: PCI enumeration already complete, "\r
89 "installing ACPI tables\n", __FUNCTION__));\r
90 return InstallAcpiTables (FindAcpiTableProtocol ());\r
91 }\r
92 ASSERT (Status == EFI_NOT_FOUND);\r
93\r
94 //\r
95 // Otherwise, delay installing the ACPI tables until PCI enumeration\r
96 // completes. The entry point's return status will only reflect the callback\r
97 // setup.\r
98 //\r
99 Status = gBS->CreateEvent (EVT_NOTIFY_SIGNAL, TPL_CALLBACK, OnPciEnumerated,\r
100 NULL /* Context */, &PciEnumerated);\r
101 if (EFI_ERROR (Status)) {\r
102 return Status;\r
103 }\r
104\r
105 Status = gBS->RegisterProtocolNotify (\r
106 &gEfiPciEnumerationCompleteProtocolGuid, PciEnumerated,\r
107 &Registration);\r
108 if (EFI_ERROR (Status)) {\r
109 gBS->CloseEvent (PciEnumerated);\r
110 } else {\r
111 DEBUG ((EFI_D_INFO, "%a: PCI enumeration pending, registered callback\n",\r
112 __FUNCTION__));\r
113 }\r
04951644 114\r
04951644
LE
115 return Status;\r
116}\r