EntryPoint.c 2.6 KB

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