diff mbox

[Linaro-uefi,09/14] Platforms/AMD/Styx: move parking protocol handling to ACPI platform driver

Message ID 1462882313-7637-10-git-send-email-ard.biesheuvel@linaro.org
State New
Headers show

Commit Message

Ard Biesheuvel May 10, 2016, 12:11 p.m. UTC
Since ACPI is mandatory on ARM 64-bit servers while FDT support is optional,
it makes sense to move shared functionality to the ACPI driver. So move the
parking protocol code to AcpiPlatformDxe. This way, we can [conditionally]
remove FdtDxe from the build without affecting ACPI parking protocol
functionality.

Note that this requires the dispatch of FdtDxe to be strictly order after
the dispatch of ApciPlatformDxe, so update the FdtDxe Depex expression
as well.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 Platforms/AMD/Styx/AmdStyx.dec                                                                                                           |  3 +++
 Platforms/AMD/Styx/Drivers/AcpiPlatformDxe/AcpiPlatform.c                                                                                |  7 +++++++
 Platforms/AMD/Styx/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf                                                                           | 15 ++++++++++++++-
 Platforms/AMD/Styx/{OverdriveBoard/FdtDxe/AArch64/BdsLinuxLoader.c => Drivers/AcpiPlatformDxe/AcpiPlatformParkingProtocol.c}             | 13 +++++--------
 Platforms/AMD/Styx/Drivers/AcpiPlatformDxe/AcpiPlatformParkingProtocol.h                                                                 | 19 +++++++++++++++++++
 Platforms/AMD/Styx/{OverdriveBoard/FdtDxe/AArch64/BdsLinuxLoaderHelper.S => Drivers/AcpiPlatformDxe/AcpiPlatformParkingProtocolHelper.S} |  0
 Platforms/AMD/Styx/OverdriveBoard/FdtDxe/FdtDxe.c                                                                                        |  5 -----
 Platforms/AMD/Styx/OverdriveBoard/FdtDxe/FdtDxe.inf                                                                                      |  8 +-------
 8 files changed, 49 insertions(+), 21 deletions(-)
diff mbox

Patch

diff --git a/Platforms/AMD/Styx/AmdStyx.dec b/Platforms/AMD/Styx/AmdStyx.dec
index ad65fc9eaf8b..3bdb4f83f858 100644
--- a/Platforms/AMD/Styx/AmdStyx.dec
+++ b/Platforms/AMD/Styx/AmdStyx.dec
@@ -42,6 +42,9 @@ 
   gAmdStyxTokenSpaceGuid     = { 0x220d9653, 0x4a0e, 0x40bc, { 0xb3, 0x65, 0x2f, 0xbb, 0xa2, 0xd9, 0x03, 0x45 } }
   gAmdStyxMpCoreInfoGuid     = { 0x68efeabd, 0xcb77, 0x4aa5, { 0xbf, 0x0c, 0xa3, 0x31, 0xfc, 0xcf, 0x76, 0x66 } }
 
+  # used to manually order the dispatch of FdtDxe after AcpiPlatformDxe
+  gAmdStyxAcpiPlatformDxeFileGuid = { 0xf229c831, 0x6a35, 0x440b, { 0x9c, 0x84, 0xdd, 0x3b, 0xc7, 0x1e, 0x38, 0x65 } }
+
 [PcdsDynamic]
   gAmdStyxTokenSpaceGuid.PcdSocCoreCount|1|UINT32|0x00000100
   gAmdStyxTokenSpaceGuid.PcdSocCpuId|1|UINT32|0x00000101
diff --git a/Platforms/AMD/Styx/Drivers/AcpiPlatformDxe/AcpiPlatform.c b/Platforms/AMD/Styx/Drivers/AcpiPlatformDxe/AcpiPlatform.c
index 36db0e2211f3..3b3d36eea007 100644
--- a/Platforms/AMD/Styx/Drivers/AcpiPlatformDxe/AcpiPlatform.c
+++ b/Platforms/AMD/Styx/Drivers/AcpiPlatformDxe/AcpiPlatform.c
@@ -26,6 +26,7 @@ 
 #include <Library/UefiBootServicesTableLib.h>
 #include <Library/DebugLib.h>
 
+#include <AcpiPlatformParkingProtocol.h>
 
 #define MAX_ACPI_TABLES    12
 
@@ -55,6 +56,12 @@  AcpiPlatformEntryPoint (
   UINTN                     TableHandle;
   UINTN                     TableIndex;
 
+  // Move secondary cores to a Pen compliant with MP-Parking protocol
+  if (!FixedPcdGetBool (PcdPsciOsSupport) &&
+      FixedPcdGetBool (PcdTrustedFWSupport)) {
+    AmdStyxParkSecondaryCores();
+  }
+
   ZeroMem(AcpiTableList, sizeof(AcpiTableList));
 
   TableIndex = 0;
diff --git a/Platforms/AMD/Styx/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf b/Platforms/AMD/Styx/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf
index d78d7ef330d8..6a3d6ec0e949 100644
--- a/Platforms/AMD/Styx/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf
+++ b/Platforms/AMD/Styx/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf
@@ -28,10 +28,15 @@ 
 
 [Sources]
   AcpiPlatform.c
+  AcpiPlatformParkingProtocol.c
+
+[Sources.AARCH64]
+  AcpiPlatformParkingProtocolHelper.S
 
 [Packages]
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
+  AmdModulePkg/AmdModulePkg.dec
   OpenPlatformPkg/Platforms/AMD/Styx/AmdStyx.dec
 
 [LibraryClasses]
@@ -44,10 +49,18 @@ 
   UefiDriverEntryPoint
   AmdStyxHelperLib
   AmdStyxAcpiLib
+  ArmSmcLib
+  CacheMaintenanceLib
+
+[FixedPcd]
+  gAmdStyxTokenSpaceGuid.PcdParkingProtocolVersion
+  gAmdStyxTokenSpaceGuid.PcdParkingProtocolBase
+  gAmdStyxTokenSpaceGuid.PcdParkingProtocolSize
+  gAmdStyxTokenSpaceGuid.PcdPsciOsSupport
+  gAmdStyxTokenSpaceGuid.PcdTrustedFWSupport
 
 [Protocols]
   gEfiAcpiTableProtocolGuid                     # PROTOCOL ALWAYS_CONSUMED
 
 [Depex]
   gEfiAcpiTableProtocolGuid
-
diff --git a/Platforms/AMD/Styx/OverdriveBoard/FdtDxe/AArch64/BdsLinuxLoader.c b/Platforms/AMD/Styx/Drivers/AcpiPlatformDxe/AcpiPlatformParkingProtocol.c
similarity index 91%
rename from Platforms/AMD/Styx/OverdriveBoard/FdtDxe/AArch64/BdsLinuxLoader.c
rename to Platforms/AMD/Styx/Drivers/AcpiPlatformDxe/AcpiPlatformParkingProtocol.c
index 6e0519edd9da..be85f3f442f0 100644
--- a/Platforms/AMD/Styx/OverdriveBoard/FdtDxe/AArch64/BdsLinuxLoader.c
+++ b/Platforms/AMD/Styx/Drivers/AcpiPlatformDxe/AcpiPlatformParkingProtocol.c
@@ -2,6 +2,7 @@ 
 *
 *  Copyright (c) 2011-2014, ARM Limited. All rights reserved.<BR>
 *  Copyright (c) 2014 - 2015, AMD Inc. All rights reserved.<BR>
+*  Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
 *
 *  This program and the accompanying materials
 *  are licensed and made available under the terms and conditions of the BSD License
@@ -18,11 +19,11 @@ 
 
 **/
 
+#include <Base.h>
+#include <Library/ArmLib.h>
 #include <Library/ArmSmcLib.h>
 #include <Library/CacheMaintenanceLib.h>
 #include <Library/PcdLib.h>
-#include <Base.h>
-#include <BdsLib/BdsInternal.h>
 
 #include <Common/CoreState.h>
 #include <IndustryStandard/ArmStdSmc.h>
@@ -67,7 +68,7 @@  AmdStyxBringupSecondary (
 
 VOID
 EFIAPI
-AmdStyxParkSecondaryCores(
+AmdStyxParkSecondaryCores (
   VOID
   )
 {
@@ -104,11 +105,7 @@  AmdStyxParkSecondaryCores(
   // Reserve the memory as RuntimeServices
   Status = gBS->AllocatePages (AllocateAddress, EfiRuntimeServicesCode,
                                EFI_SIZE_TO_PAGES (MpParkingSize ), &MpParkingBase );
-  if (EFI_ERROR (Status)) {
-    Print (L"Warning: Failed to reserve memory for MP-Parking protocol at 0x%lX, Status = %r\n",
-          MpParkingBase, Status);
-    // Even if there is a risk of memory corruption we carry on
-  }
+  ASSERT_EFI_ERROR (Status);
 
   // Relocate the Pen code
   CopyMem ((VOID*)(PenBase), (VOID*)&SecondariesPenStart, PenSize);
diff --git a/Platforms/AMD/Styx/Drivers/AcpiPlatformDxe/AcpiPlatformParkingProtocol.h b/Platforms/AMD/Styx/Drivers/AcpiPlatformDxe/AcpiPlatformParkingProtocol.h
new file mode 100644
index 000000000000..fb79a803026d
--- /dev/null
+++ b/Platforms/AMD/Styx/Drivers/AcpiPlatformDxe/AcpiPlatformParkingProtocol.h
@@ -0,0 +1,19 @@ 
+/** @file
+*
+*  Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
+*
+*  This program and the accompanying materials
+*  are licensed and made available under the terms and conditions of the BSD License
+*  which accompanies this distribution.  The full text of the license may be found at
+*  http://opensource.org/licenses/bsd-license.php
+*
+*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+*
+**/
+
+VOID
+EFIAPI
+AmdStyxParkSecondaryCores (
+  VOID
+  );
diff --git a/Platforms/AMD/Styx/OverdriveBoard/FdtDxe/AArch64/BdsLinuxLoaderHelper.S b/Platforms/AMD/Styx/Drivers/AcpiPlatformDxe/AcpiPlatformParkingProtocolHelper.S
similarity index 100%
rename from Platforms/AMD/Styx/OverdriveBoard/FdtDxe/AArch64/BdsLinuxLoaderHelper.S
rename to Platforms/AMD/Styx/Drivers/AcpiPlatformDxe/AcpiPlatformParkingProtocolHelper.S
diff --git a/Platforms/AMD/Styx/OverdriveBoard/FdtDxe/FdtDxe.c b/Platforms/AMD/Styx/OverdriveBoard/FdtDxe/FdtDxe.c
index 08430730f6ca..58599e8e1714 100644
--- a/Platforms/AMD/Styx/OverdriveBoard/FdtDxe/FdtDxe.c
+++ b/Platforms/AMD/Styx/OverdriveBoard/FdtDxe/FdtDxe.c
@@ -117,11 +117,6 @@  FdtReadyToBoot (
   UINTN                         FdtBlobSize = 0;
   EFI_DEVICE_PATH               *FdtDevicePath;
 
-  // Move secondary cores to a Pen complaint with MP-Parking protocol
-  if (!FixedPcdGetBool (PcdPsciOsSupport) && FixedPcdGetBool (PcdTrustedFWSupport)) {
-    AmdStyxParkSecondaryCores();
-  }
-
   // Search for FDT blob in EFI partition
   Status = FdtOverrideDevicePath(L"fdt.dtb", &FdtDevicePath);
   if (!EFI_ERROR (Status)) {
diff --git a/Platforms/AMD/Styx/OverdriveBoard/FdtDxe/FdtDxe.inf b/Platforms/AMD/Styx/OverdriveBoard/FdtDxe/FdtDxe.inf
index 5653cac39b71..813324f6d308 100644
--- a/Platforms/AMD/Styx/OverdriveBoard/FdtDxe/FdtDxe.inf
+++ b/Platforms/AMD/Styx/OverdriveBoard/FdtDxe/FdtDxe.inf
@@ -32,10 +32,6 @@ 
   BdsLinuxFdt.c
   LinuxLoaderHelper.c
 
-[Sources.AARCH64]
-  AArch64/BdsLinuxLoader.c
-  AArch64/BdsLinuxLoaderHelper.S  | GCC
-
 [Packages]
   ArmPkg/ArmPkg.dec
   EmbeddedPkg/EmbeddedPkg.dec
@@ -78,8 +74,6 @@ 
   gArmTokenSpaceGuid.PcdArmLinuxFdtAlignment
   gAmdStyxTokenSpaceGuid.PcdPsciOsSupport
   gAmdStyxTokenSpaceGuid.PcdTrustedFWSupport
-  gAmdStyxTokenSpaceGuid.PcdParkingProtocolBase
-  gAmdStyxTokenSpaceGuid.PcdParkingProtocolSize
 
 [Depex]
-  TRUE
+  AFTER gAmdStyxAcpiPlatformDxeFileGuid