]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/AcpiPlatformDxe/EntryPoint.c
ShellPkg/for: Fix potential null pointer deference
[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
b6bc800d 16#include <Guid/RootBridgesConnectedEventGroup.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
b6bc800d 41OnRootBridgesConnected (\r
818bc86a
LE
42 IN EFI_EVENT Event,\r
43 IN VOID *Context\r
44 )\r
45{\r
46 EFI_STATUS Status;\r
47\r
b6bc800d
LE
48 DEBUG ((EFI_D_INFO,\r
49 "%a: root bridges have been connected, installing ACPI tables\n",\r
818bc86a
LE
50 __FUNCTION__));\r
51 Status = InstallAcpiTables (FindAcpiTableProtocol ());\r
52 if (EFI_ERROR (Status)) {\r
53 DEBUG ((EFI_D_ERROR, "%a: InstallAcpiTables: %r\n", __FUNCTION__, Status));\r
54 }\r
55 gBS->CloseEvent (Event);\r
56}\r
57\r
58\r
04951644
LE
59EFI_STATUS\r
60EFIAPI\r
61AcpiPlatformEntryPoint (\r
62 IN EFI_HANDLE ImageHandle,\r
63 IN EFI_SYSTEM_TABLE *SystemTable\r
64 )\r
65{\r
66 EFI_STATUS Status;\r
b6bc800d 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
75 DEBUG ((EFI_D_INFO, "%a: PCI or its enumeration disabled, installing "\r
76 "ACPI tables\n", __FUNCTION__));\r
77 return InstallAcpiTables (FindAcpiTableProtocol ());\r
78 }\r
79\r
80 //\r
b6bc800d
LE
81 // Otherwise, delay installing the ACPI tables until root bridges are\r
82 // connected. The entry point's return status will only reflect the callback\r
83 // setup. (Note that we're a DXE_DRIVER; our entry point function is invoked\r
84 // strictly before BDS is entered and can connect the root bridges.)\r
818bc86a 85 //\r
b6bc800d
LE
86 Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_CALLBACK,\r
87 OnRootBridgesConnected, NULL /* Context */,\r
88 &gRootBridgesConnectedEventGroupGuid, &RootBridgesConnected);\r
818bc86a 89 if (!EFI_ERROR (Status)) {\r
b6bc800d
LE
90 DEBUG ((EFI_D_INFO,\r
91 "%a: waiting for root bridges to be connected, registered callback\n",\r
818bc86a
LE
92 __FUNCTION__));\r
93 }\r
04951644 94\r
04951644
LE
95 return Status;\r
96}\r