From nobody Fri Dec 27 18:17:14 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; dkim=fail spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 149909003715581.7936848825492; Mon, 3 Jul 2017 06:53:57 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 021CC21A00AC2; Mon, 3 Jul 2017 06:52:18 -0700 (PDT) Received: from mail-wr0-x231.google.com (mail-wr0-x231.google.com [IPv6:2a00:1450:400c:c0c::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3D05621CF3B79 for ; Mon, 3 Jul 2017 06:52:16 -0700 (PDT) Received: by mail-wr0-x231.google.com with SMTP id r103so234960276wrb.0 for ; Mon, 03 Jul 2017 06:53:53 -0700 (PDT) Received: from localhost.localdomain ([154.151.196.199]) by smtp.gmail.com with ESMTPSA id f21sm20936635wra.5.2017.07.03.06.53.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Jul 2017 06:53:50 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=1Ieei2mr+qkd7RBSs1r8gRVJz315ss6AXD6fMDPcgVo=; b=NATIJT3zvXvBpMKbdHaFcGnfhqcE4Gkc9EONaYVKkfNVZWoGvjxslkl8AcT7N0GBQf s21oL/lG4Q6CEGiGLpnNL+/ATKkeMIGAcpym59n/2YtgZedhB8Yh6q3xmWL7FVqRYLcg avqpSchb/+g5VUIIKAncS8qU12OSZCSVwUkfg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=1Ieei2mr+qkd7RBSs1r8gRVJz315ss6AXD6fMDPcgVo=; b=cwoxoR94T1qEjguODbhdvpXx2fRcU9oifO5B0BwCGV8aaI5ep8tGL9Kx2tPUoNRq/v wvKx/fYCnFBum9Q+Svt+sQWcrlAm/B++FkFUY3XHMqiM6FXmSmPE4cIe3MZXDCZBgAV2 I89XKAqV483h8P030a9sguEH4kG9tWHJ/pZ59KR6Ol8uD6iiBPgqS33RCL4lGESbcSXN yYVZ/32ehBZAY3evmZdblMK5lrqe2W9TpAqf67wlIRr1jZB5+QC9i8fxENXe+RaqTI5A M1u1STwAhylajVDeWfbHr6nO+jvXHM1/jDtwUfVhfUIyhuji2gGA4IFUXT965l+wCqG0 x7ZA== X-Gm-Message-State: AKS2vOwXajC2Egdw3nNoN7R4N/Ncv+hBC4qfPv7oRXr2luM6Rv6torFQ rZaSReYLumO9VMlU76rg7Q== X-Received: by 10.223.135.210 with SMTP id c18mr32262105wrc.109.1499090031666; Mon, 03 Jul 2017 06:53:51 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, lersek@redhat.com Date: Mon, 3 Jul 2017 14:53:45 +0100 Message-Id: <20170703135345.28703-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 Subject: [edk2] [PATCH] ArmVirtPkg: switch to generic ResetSystemRuntimeDxe X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" For obscure reasons, ARM platforms use a different implementation of the ResetSystem() runtime service call than other platforms. So let's switch all ArmVirtPkg platforms to the generic version instead. Given that all platforms use an implementation of EfiResetSystemLib [as consumed by the ResetRuntimeDxe in EmbeddedPkg that we are replacing] which is unlikely to be depended upon by out of tree platforms, let's simply modify this library into an implementation of ResetSystemLib instead [which is what the generic driver in MdeModulePkg consumes] This does mean we need to update all clients at the same time, which is why all changes are part of the same patch. As before, warm reset and platform specific reset are mapped onto cold reset (which is the only thing PSCI implements, at least the version we depend on). The new library function EnterS3WithImmediateWake() is left unimplemented, as permitted by the ResetSystemLib library class. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel Reviewed-by: Laszlo Ersek Reviewed-by: Leif Lindholm --- Note: this a no-whitespace diff ArmVirtPkg/ArmVirt.dsc.inc = | 2 +- ArmVirtPkg/ArmVirtQemu.dsc = | 2 +- ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc = | 2 +- ArmVirtPkg/ArmVirtQemuKernel.dsc = | 2 +- ArmVirtPkg/ArmVirtXen.dsc = | 2 +- ArmVirtPkg/ArmVirtXen.fdf = | 2 +- ArmVirtPkg/Library/ArmVirtPsciResetSystemLib/ArmVirtPsciResetSystemLib.c = | 125 +++++++++++++------- ArmVirtPkg/Library/ArmVirtPsciResetSystemLib/ArmVirtPsciResetSystemLib.inf= | 4 +- 8 files changed, 89 insertions(+), 52 deletions(-) diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc index 5bf537635488..0b9b457b5619 100644 --- a/ArmVirtPkg/ArmVirt.dsc.inc +++ b/ArmVirtPkg/ArmVirt.dsc.inc @@ -101,7 +101,7 @@ [LibraryClasses.common] =20 PlatformPeiLib|ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.inf MemoryInitPeiLib|ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemor= yInitPeiLib.inf - EfiResetSystemLib|ArmVirtPkg/Library/ArmVirtPsciResetSystemLib/ArmVirtPs= ciResetSystemLib.inf + ResetSystemLib|ArmVirtPkg/Library/ArmVirtPsciResetSystemLib/ArmVirtPsciR= esetSystemLib.inf =20 # ARM PL031 RTC Driver RealTimeClockLib|ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealT= imeClockLib.inf diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc index 10de57a4149e..e23a6d17bc44 100644 --- a/ArmVirtPkg/ArmVirtQemu.dsc +++ b/ArmVirtPkg/ArmVirtQemu.dsc @@ -266,7 +266,7 @@ [Components.common] MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntim= eDxe.inf - EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf + MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf { NULL|ArmVirtPkg/Library/ArmVirtPL031FdtClientLib/ArmVirtPL031FdtClie= ntLib.inf diff --git a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc b/ArmVirtPkg/ArmVirtQemuF= vMain.fdf.inc index ba2e7157cf2c..237b2d03a714 100644 --- a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc +++ b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc @@ -63,7 +63,7 @@ [FV.FvMain] INF SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConf= igDxe.inf !endif INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRu= ntimeDxe.inf - INF EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf + INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.i= nf INF EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf INF EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKerne= l.dsc index 93ccb6df37e1..aa01debfda69 100644 --- a/ArmVirtPkg/ArmVirtQemuKernel.dsc +++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc @@ -257,7 +257,7 @@ [Components.common] MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntim= eDxe.inf - EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf + MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf { NULL|ArmVirtPkg/Library/ArmVirtPL031FdtClientLib/ArmVirtPL031FdtClie= ntLib.inf diff --git a/ArmVirtPkg/ArmVirtXen.dsc b/ArmVirtPkg/ArmVirtXen.dsc index f832b3fb64f4..eb37137f271e 100644 --- a/ArmVirtPkg/ArmVirtXen.dsc +++ b/ArmVirtPkg/ArmVirtXen.dsc @@ -167,7 +167,7 @@ [Components.common] MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf =20 MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntim= eDxe.inf - EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf + MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf =20 diff --git a/ArmVirtPkg/ArmVirtXen.fdf b/ArmVirtPkg/ArmVirtXen.fdf index b591818f0b42..67fde73e696d 100644 --- a/ArmVirtPkg/ArmVirtXen.fdf +++ b/ArmVirtPkg/ArmVirtXen.fdf @@ -140,7 +140,7 @@ [FV.FvMain] INF MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.= inf =20 INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRu= ntimeDxe.inf - INF EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf + INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.i= nf INF EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf INF EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf diff --git a/ArmVirtPkg/Library/ArmVirtPsciResetSystemLib/ArmVirtPsciResetS= ystemLib.c b/ArmVirtPkg/Library/ArmVirtPsciResetSystemLib/ArmVirtPsciResetS= ystemLib.c index b94d1b0090c6..4b0db206e920 100644 --- a/ArmVirtPkg/Library/ArmVirtPsciResetSystemLib/ArmVirtPsciResetSystemLi= b.c +++ b/ArmVirtPkg/Library/ArmVirtPsciResetSystemLib/ArmVirtPsciResetSystemLi= b.c @@ -23,7 +23,7 @@ =20 #include #include -#include +#include #include #include #include @@ -67,49 +67,75 @@ ArmPsciResetSystemLibConstructor ( } =20 /** - Resets the entire platform. - - @param ResetType The type of reset to perform. - @param ResetStatus The status code for the reset. - @param DataSize The size, in bytes, of WatchdogData. - @param ResetData For a ResetType of EfiResetCold, EfiResetW= arm, or - EfiResetShutdown the data buffer starts wi= th a Null-terminated - Unicode string, optionally followed by add= itional binary data. + This function causes a system-wide reset (cold reset), in which + all circuitry within the system returns to its initial state. This type = of reset + is asynchronous to system operation and operates without regard to + cycle boundaries. =20 + If this function returns, it means that the system does not support cold= reset. **/ -EFI_STATUS +VOID EFIAPI -LibResetSystem ( - IN EFI_RESET_TYPE ResetType, - IN EFI_STATUS ResetStatus, - IN UINTN DataSize, - IN CHAR16 *ResetData OPTIONAL +ResetCold ( + VOID ) { ARM_SMC_ARGS ArmSmcArgs; ARM_HVC_ARGS ArmHvcArgs; =20 - switch (ResetType) { - - case EfiResetPlatformSpecific: - // Map the platform specific reset as reboot - case EfiResetWarm: - // Map a warm reset into a cold reset - case EfiResetCold: // Send a PSCI 0.2 SYSTEM_RESET command ArmSmcArgs.Arg0 =3D ARM_SMC_ID_PSCI_SYSTEM_RESET; ArmHvcArgs.Arg0 =3D ARM_SMC_ID_PSCI_SYSTEM_RESET; + + switch (mArmPsciMethod) { + case 1: + ArmCallHvc (&ArmHvcArgs); break; - case EfiResetShutdown: - // Send a PSCI 0.2 SYSTEM_OFF command - ArmSmcArgs.Arg0 =3D ARM_SMC_ID_PSCI_SYSTEM_OFF; - ArmHvcArgs.Arg0 =3D ARM_SMC_ID_PSCI_SYSTEM_OFF; + + case 2: + ArmCallSmc (&ArmSmcArgs); break; + default: - ASSERT (FALSE); - return EFI_UNSUPPORTED; + DEBUG ((EFI_D_ERROR, "%a: no PSCI method defined\n", __FUNCTION__)); + } +} + +/** + This function causes a system-wide initialization (warm reset), in which= all processors + are set to their initial state. Pending cycles are not corrupted. + + If this function returns, it means that the system does not support warm= reset. +**/ +VOID +EFIAPI +ResetWarm ( + VOID + ) +{ + // Map a warm reset into a cold reset + ResetCold (); } =20 +/** + This function causes the system to enter a power state equivalent + to the ACPI G2/S5 or G3 states. + + If this function returns, it means that the system does not support shut= down reset. +**/ +VOID +EFIAPI +ResetShutdown ( + VOID + ) +{ + ARM_SMC_ARGS ArmSmcArgs; + ARM_HVC_ARGS ArmHvcArgs; + + // Send a PSCI 0.2 SYSTEM_OFF command + ArmSmcArgs.Arg0 =3D ARM_SMC_ID_PSCI_SYSTEM_OFF; + ArmHvcArgs.Arg0 =3D ARM_SMC_ID_PSCI_SYSTEM_OFF; + switch (mArmPsciMethod) { case 1: ArmCallHvc (&ArmHvcArgs); @@ -121,30 +147,41 @@ LibResetSystem ( =20 default: DEBUG ((EFI_D_ERROR, "%a: no PSCI method defined\n", __FUNCTION__)); - return EFI_UNSUPPORTED; } - - // We should never be here - DEBUG ((EFI_D_ERROR, "%a: PSCI Reset failed\n", __FUNCTION__)); - CpuDeadLoop (); - return EFI_UNSUPPORTED; } =20 /** - Initialize any infrastructure required for LibResetSystem () to function. + This function causes the system to enter S3 and then wake up immediately. =20 - @param ImageHandle The firmware allocated handle for the EFI image. - @param SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. + If this function returns, it means that the system does not support S3 f= eature. +**/ +VOID +EFIAPI +EnterS3WithImmediateWake ( + VOID + ) +{ + // not implemented +} =20 +/** + This function causes a systemwide reset. The exact type of the reset is + defined by the EFI_GUID that follows the Null-terminated Unicode string = passed + into ResetData. If the platform does not recognize the EFI_GUID in Reset= Data + the platform must pick a supported reset type to perform.The platform may + optionally log the parameters from any non-normal reset that occurs. + + @param[in] DataSize The size, in bytes, of ResetData. + @param[in] ResetData The data buffer starts with a Null-terminated str= ing, + followed by the EFI_GUID. **/ -EFI_STATUS +VOID EFIAPI -LibInitializeResetSystem ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable +ResetPlatformSpecific ( + IN UINTN DataSize, + IN VOID *ResetData ) { - return EFI_SUCCESS; + // Map the platform specific reset as reboot + ResetCold (); } diff --git a/ArmVirtPkg/Library/ArmVirtPsciResetSystemLib/ArmVirtPsciResetS= ystemLib.inf b/ArmVirtPkg/Library/ArmVirtPsciResetSystemLib/ArmVirtPsciRese= tSystemLib.inf index 9dc515aee52b..f28aed3fb1c2 100644 --- a/ArmVirtPkg/Library/ArmVirtPsciResetSystemLib/ArmVirtPsciResetSystemLi= b.inf +++ b/ArmVirtPkg/Library/ArmVirtPsciResetSystemLib/ArmVirtPsciResetSystemLi= b.inf @@ -20,7 +20,7 @@ [Defines] FILE_GUID =3D c81d76ed-66fa-44a3-ac4a-f163120187a9 MODULE_TYPE =3D BASE VERSION_STRING =3D 1.0 - LIBRARY_CLASS =3D EfiResetSystemLib|DXE_DRIVER DXE_RUNT= IME_DRIVER + LIBRARY_CLASS =3D ResetSystemLib|DXE_DRIVER DXE_RUNTIME= _DRIVER CONSTRUCTOR =3D ArmPsciResetSystemLibConstructor =20 [Sources] @@ -29,8 +29,8 @@ [Sources] [Packages] ArmPkg/ArmPkg.dec ArmVirtPkg/ArmVirtPkg.dec + MdeModulePkg/MdeModulePkg.dec MdePkg/MdePkg.dec - EmbeddedPkg/EmbeddedPkg.dec =20 [LibraryClasses] ArmSmcLib --=20 2.9.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel