EntryPoint.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /** @file
  2. Entry point of OVMF ACPI Platform Driver
  3. Copyright (C) 2015, Red Hat, Inc.
  4. Copyright (c) 2008 - 2015, Intel Corporation. All rights reserved.<BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #include <Guid/RootBridgesConnectedEventGroup.h> // gRootBridgesConnectedEve...
  8. #include <Library/DebugLib.h> // DEBUG()
  9. #include <Library/PcdLib.h> // PcdGetBool()
  10. #include <Library/UefiBootServicesTableLib.h> // gBS
  11. #include <Protocol/AcpiTable.h> // EFI_ACPI_TABLE_PROTOCOL
  12. #include "AcpiPlatform.h"
  13. STATIC
  14. EFI_ACPI_TABLE_PROTOCOL *
  15. FindAcpiTableProtocol (
  16. VOID
  17. )
  18. {
  19. EFI_STATUS Status;
  20. EFI_ACPI_TABLE_PROTOCOL *AcpiTable;
  21. Status = gBS->LocateProtocol (
  22. &gEfiAcpiTableProtocolGuid,
  23. NULL,
  24. (VOID **)&AcpiTable
  25. );
  26. ASSERT_EFI_ERROR (Status);
  27. return AcpiTable;
  28. }
  29. STATIC
  30. VOID
  31. EFIAPI
  32. OnRootBridgesConnected (
  33. IN EFI_EVENT Event,
  34. IN VOID *Context
  35. )
  36. {
  37. EFI_STATUS Status;
  38. DEBUG ((
  39. DEBUG_INFO,
  40. "%a: root bridges have been connected, installing ACPI tables\n",
  41. __FUNCTION__
  42. ));
  43. Status = InstallAcpiTables (FindAcpiTableProtocol ());
  44. if (EFI_ERROR (Status)) {
  45. DEBUG ((DEBUG_ERROR, "%a: InstallAcpiTables: %r\n", __FUNCTION__, Status));
  46. }
  47. gBS->CloseEvent (Event);
  48. }
  49. EFI_STATUS
  50. EFIAPI
  51. AcpiPlatformEntryPoint (
  52. IN EFI_HANDLE ImageHandle,
  53. IN EFI_SYSTEM_TABLE *SystemTable
  54. )
  55. {
  56. EFI_STATUS Status;
  57. EFI_EVENT RootBridgesConnected;
  58. //
  59. // If the platform doesn't support PCI, or PCI enumeration has been disabled,
  60. // install the tables at once, and let the entry point's return code reflect
  61. // the full functionality.
  62. //
  63. if (PcdGetBool (PcdPciDisableBusEnumeration)) {
  64. DEBUG ((
  65. DEBUG_INFO,
  66. "%a: PCI or its enumeration disabled, installing "
  67. "ACPI tables\n",
  68. __FUNCTION__
  69. ));
  70. return InstallAcpiTables (FindAcpiTableProtocol ());
  71. }
  72. //
  73. // Otherwise, delay installing the ACPI tables until root bridges are
  74. // connected. The entry point's return status will only reflect the callback
  75. // setup. (Note that we're a DXE_DRIVER; our entry point function is invoked
  76. // strictly before BDS is entered and can connect the root bridges.)
  77. //
  78. Status = gBS->CreateEventEx (
  79. EVT_NOTIFY_SIGNAL,
  80. TPL_CALLBACK,
  81. OnRootBridgesConnected,
  82. NULL /* Context */,
  83. &gRootBridgesConnectedEventGroupGuid,
  84. &RootBridgesConnected
  85. );
  86. if (!EFI_ERROR (Status)) {
  87. DEBUG ((
  88. DEBUG_INFO,
  89. "%a: waiting for root bridges to be connected, registered callback\n",
  90. __FUNCTION__
  91. ));
  92. }
  93. return Status;
  94. }