From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web11.352.1628635995705264471 for ; Tue, 10 Aug 2021 15:53:16 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: nathaniel.l.desimone@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10072"; a="213156575" X-IronPort-AV: E=Sophos;i="5.84,310,1620716400"; d="scan'208";a="213156575" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Aug 2021 15:53:13 -0700 X-IronPort-AV: E=Sophos;i="5.84,310,1620716400"; d="scan'208";a="516015668" Received: from nldesimo-desk1.amr.corp.intel.com ([10.209.11.68]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Aug 2021 15:53:13 -0700 From: "Nate DeSimone" To: devel@edk2.groups.io Cc: Chasel Chiu , Michael Kubacki , Benjamin Doron Subject: [edk2-platforms] [PATCH V1] KabylakeOpenBoardPkg: Add MMIO Base/Length to SA GNVS Date: Tue, 10 Aug 2021 15:53:09 -0700 Message-Id: <20210810225309.27112-1-nathaniel.l.desimone@intel.com> X-Mailer: git-send-email 2.27.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The SA GNVS Area contains fields for the MMIO region base address and length. This implements code to populate those fields. The MMIO Base/Length are used by ASL at runtime and must be populated for normal system operation. Cc: Chasel Chiu Cc: Michael Kubacki Cc: Benjamin Doron Signed-off-by: Nate DeSimone --- .../Acpi/BoardAcpiDxe/AcpiGnvsInit.c | 57 ++++++++++++++++++- .../Acpi/BoardAcpiDxe/BoardAcpiDxe.inf | 12 +++- 2 files changed, 63 insertions(+), 6 deletions(-) diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Acpi/BoardAcpiDxe/AcpiGnvsInit.c b/Platform/Intel/KabylakeOpenBoardPkg/Acpi/BoardAcpiDxe/AcpiGnvsInit.c index 0d9d217e38..b09b92f2e6 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/Acpi/BoardAcpiDxe/AcpiGnvsInit.c +++ b/Platform/Intel/KabylakeOpenBoardPkg/Acpi/BoardAcpiDxe/AcpiGnvsInit.c @@ -1,7 +1,7 @@ /** @file Acpi Gnvs Init Library. -Copyright (c) 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -11,11 +11,51 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include #include #include #include #include +#include + +/** + A protocol callback which updates MMIO Base and Length in SA GNVS area + + @param[in] Event - The triggered event. + @param[in] Context - Context for this event. + +**/ +VOID +UpdateSaGnvsForMmioResourceBaseLength ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + SYSTEM_AGENT_GLOBAL_NVS_AREA_PROTOCOL *SaGlobalNvsAreaProtocol; + + Status = gBS->LocateProtocol (&gSaGlobalNvsAreaProtocolGuid, NULL, (VOID **) &SaGlobalNvsAreaProtocol); + if (Status != EFI_SUCCESS) { + return; + } + gBS->CloseEvent (Event); + + // + // Configure MMIO Base/Length. This logic is only valid for platforms that use PciHostBridgeLibSimple. + // + DEBUG ((DEBUG_INFO, "[BoardAcpiDxe] Update SA GNVS Area.\n")); + SaGlobalNvsAreaProtocol->Area->Mmio32Base = PcdGet32 (PcdPciReservedMemBase); + if (PcdGet32 (PcdPciReservedMemLimit) != 0) { + SaGlobalNvsAreaProtocol->Area->Mmio32Length = PcdGet32 (PcdPciReservedMemLimit) - PcdGet32 (PcdPciReservedMemBase) + 1; + } else { + SaGlobalNvsAreaProtocol->Area->Mmio32Length = ((UINT32) PcdGet64 (PcdPciExpressBaseAddress)) - PcdGet32 (PcdPciReservedMemBase); + } + if (PcdGet64 (PcdPciReservedMemAbove4GBLimit) > PcdGet64 (PcdPciReservedMemAbove4GBBase)) { + SaGlobalNvsAreaProtocol->Area->Mmio64Base = PcdGet64 (PcdPciReservedMemAbove4GBBase); + SaGlobalNvsAreaProtocol->Area->Mmio64Length = PcdGet64 (PcdPciReservedMemAbove4GBLimit) - PcdGet64 (PcdPciReservedMemAbove4GBBase) + 1; + } +} /** @brief @@ -39,6 +79,7 @@ AcpiGnvsInit ( EFI_MP_SERVICES_PROTOCOL *MpService; UINTN NumberOfCPUs; UINTN NumberOfEnabledCPUs; + VOID *SaGlobalNvsRegistration; Pages = EFI_SIZE_TO_PAGES (sizeof (EFI_GLOBAL_NVS_AREA)); Address = 0xffffffff; // allocate address below 4G. @@ -53,7 +94,7 @@ AcpiGnvsInit ( if (EFI_ERROR(Status)) { return Status; } - + // // Locate the MP services protocol // Find the MP Protocol. This is an MP platform, so MP protocol must be there. @@ -90,6 +131,16 @@ AcpiGnvsInit ( GNVS->Area->PL1LimitCS = 0; GNVS->Area->PL1LimitCSValue = 4500; + // + // Update SA GNVS with MMIO Base/Length + // + EfiCreateProtocolNotifyEvent ( + &gSaGlobalNvsAreaProtocolGuid, + TPL_CALLBACK, + UpdateSaGnvsForMmioResourceBaseLength, + NULL, + &SaGlobalNvsRegistration + ); + return EFI_SUCCESS; } - diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Acpi/BoardAcpiDxe/BoardAcpiDxe.inf b/Platform/Intel/KabylakeOpenBoardPkg/Acpi/BoardAcpiDxe/BoardAcpiDxe.inf index 7d2e105e54..5d3d4c3a2b 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/Acpi/BoardAcpiDxe/BoardAcpiDxe.inf +++ b/Platform/Intel/KabylakeOpenBoardPkg/Acpi/BoardAcpiDxe/BoardAcpiDxe.inf @@ -1,7 +1,7 @@ ### @file # Component information file for AcpiPlatform module # -# Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -38,6 +38,7 @@ PcdLib UefiBootServicesTableLib UefiRuntimeServicesTableLib + UefiLib BaseMemoryLib HobLib AslUpdateLib @@ -48,8 +49,15 @@ gEfiFirmwareVolume2ProtocolGuid ## CONSUMES gEfiMpServiceProtocolGuid ## CONSUMES gEfiGlobalNvsAreaProtocolGuid + gSaGlobalNvsAreaProtocolGuid ## CONSUMES [Pcd] + gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress + gMinPlatformPkgTokenSpaceGuid.PcdPciReservedMemBase + gMinPlatformPkgTokenSpaceGuid.PcdPciReservedMemLimit + gMinPlatformPkgTokenSpaceGuid.PcdPciReservedMemAbove4GBBase + gMinPlatformPkgTokenSpaceGuid.PcdPciReservedMemAbove4GBLimit + gKabylakeOpenBoardPkgTokenSpaceGuid.PcdAcpiGnvsAddress gKabylakeOpenBoardPkgTokenSpaceGuid.PcdAcpiSleepState @@ -65,5 +73,3 @@ gEfiPciRootBridgeIoProtocolGuid AND gEfiVariableArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid - - -- 2.27.0.windows.1