From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4001:c0b::22d; helo=mail-it0-x22d.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-it0-x22d.google.com (mail-it0-x22d.google.com [IPv6:2607:f8b0:4001:c0b::22d]) (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 D02D020349DAA for ; Mon, 13 Nov 2017 04:05:43 -0800 (PST) Received: by mail-it0-x22d.google.com with SMTP id b5so2782948itc.3 for ; Mon, 13 Nov 2017 04:09:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=SbOZSUB5Fql0PcmaVizfzjf01uz3ebLN9MQUvoax+0c=; b=hehNG1C86Q6PhX2Q/roVP6QZ5g1ugeTY+CH8z1xOTE5auEheoCSnGNGxt76jz4pOxb Pk68ItY7MK92PFZnR5cslSK6c3F7pocy3HWC0wTCHDQm+ELXOs/JvsxblmHE/C3k7vHH LwloTu/0IPRN7WS0uEJkgWDC0/95tmI4KSOGI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=SbOZSUB5Fql0PcmaVizfzjf01uz3ebLN9MQUvoax+0c=; b=Qrs6crcMN7DqbkmVQko3y1RERybbi2DmwOp4Yuy5FR30hDRv807JUSQtbTcqxWt/rv qsj5vIJ3A83djNSsp26e60Vj6EapN8VaJY9lO6BtF4UOda9C/f3Eu6iArK3posTjMD4p v9FqOtyApxsO0tJCoY6dlmEQ3q4Cxw255VTY58N58MA9FOleig7O+1EadMlUP/7xPkWX IUNc1n27RTbKXWLnN8KoGdYN79Xl2NdfNC69+BD7DOB4o038zU0VNihgJT8xfbQZUli9 kZz4jI0Hj4HREwX4iNRCmrguKMO2h+ZAv+aKwDdJF/2s7wrOqcwwuDMfnl+VORhq1216 ch3Q== X-Gm-Message-State: AJaThX70+vbFJHH9/wJt2tyjgBE6hA1dMDcy+cGXF9EMA5n7GcerY1Uq /+w0K59vVB3DsLkbfz/3Rk5w4EXCvSDnBW8KPV4sLg== X-Google-Smtp-Source: AGs4zMZmth2r/gBzSST9IdUiuo+47rZIiFU/iUmaUnIGlTNq2niQEj++YCZ7a3N+MquD9m6RmB9bAyohyEPouySTdxY= X-Received: by 10.36.31.212 with SMTP id d203mr9674718itd.48.1510574989004; Mon, 13 Nov 2017 04:09:49 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.104.20 with HTTP; Mon, 13 Nov 2017 04:09:48 -0800 (PST) In-Reply-To: <1510065736-9394-3-git-send-email-meenakshi.aggarwal@nxp.com> References: <1510065736-9394-1-git-send-email-meenakshi.aggarwal@nxp.com> <1510065736-9394-3-git-send-email-meenakshi.aggarwal@nxp.com> From: Ard Biesheuvel Date: Mon, 13 Nov 2017 12:09:48 +0000 Message-ID: To: Meenakshi Aggarwal Cc: Leif Lindholm , "Kinney, Michael D" , "edk2-devel@lists.01.org" , Udit Kumar , Varun Sethi Subject: Re: [PATCH 02/10] Platform/NXP: Add support for system reset library 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: , X-List-Received-Date: Mon, 13 Nov 2017 12:05:44 -0000 Content-Type: text/plain; charset="UTF-8" On 7 November 2017 at 14:42, Meenakshi Aggarwal wrote: > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Meenakshi Aggarwal > --- > .../NXP/Library/ResetSystemLib/ResetSystemLib.c | 96 ++++++++++++++++++++++ > .../NXP/Library/ResetSystemLib/ResetSystemLib.inf | 33 ++++++++ > 2 files changed, 129 insertions(+) > create mode 100644 Platform/NXP/Library/ResetSystemLib/ResetSystemLib.c > create mode 100644 Platform/NXP/Library/ResetSystemLib/ResetSystemLib.inf > Please drop this patch, and move your platform to MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf, using ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.inf as your ResetSystemLib implementation. > diff --git a/Platform/NXP/Library/ResetSystemLib/ResetSystemLib.c b/Platform/NXP/Library/ResetSystemLib/ResetSystemLib.c > new file mode 100644 > index 0000000..897324a > --- /dev/null > +++ b/Platform/NXP/Library/ResetSystemLib/ResetSystemLib.c > @@ -0,0 +1,96 @@ > +/** ResetSystemLib.c > + Do a generic Cold Reset > + > + Based on Reset system library implementation in > + BeagleBoardPkg/Library/ResetSystemLib/ResetSystemLib.c > + > + Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.
> + Copyright (c) 2016, Freescale Semiconductor, Inc. All rights reserved. > + Copyright 2017 NXP > + > + 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. > + > +**/ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +/** > + 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, EfiResetWarm, or > + EfiResetShutdown the data buffer starts with a Null-terminated > + Unicode string, optionally followed by additional binary data. > +**/ > +EFI_STATUS > +EFIAPI > +LibResetSystem ( > + IN EFI_RESET_TYPE ResetType, > + IN EFI_STATUS ResetStatus, > + IN UINTN DataSize, > + IN CHAR16 *ResetData OPTIONAL > + ) > +{ > + ARM_SMC_ARGS ArmSmcArgs; > + > + switch (ResetType) { > + case EfiResetPlatformSpecific: > + case EfiResetWarm: > + // Map a warm reset into a cold reset > + case EfiResetCold: > + // Send a PSCI 0.2 SYSTEM_RESET command > + ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_RESET; > + break; > + case EfiResetShutdown: > + // Send a PSCI 0.2 SYSTEM_OFF command > + ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_OFF; > + break; > + default: > + ASSERT (FALSE); > + return EFI_UNSUPPORTED; > + } > + > + ArmCallSmc (&ArmSmcArgs); > + > + // We should never be here > + DEBUG ((DEBUG_VERBOSE, "%a: PSCI failed in performing %d\n", > + __FUNCTION__, ArmSmcArgs.Arg0)); > + > + CpuDeadLoop (); > + return EFI_UNSUPPORTED; > +} > + > +/** > + Initialize any infrastructure required for LibResetSystem () to function. > + > + @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. > + > +**/ > +EFI_STATUS > +EFIAPI > +LibInitializeResetSystem ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + return EFI_SUCCESS; > +} > diff --git a/Platform/NXP/Library/ResetSystemLib/ResetSystemLib.inf b/Platform/NXP/Library/ResetSystemLib/ResetSystemLib.inf > new file mode 100644 > index 0000000..c57fff8 > --- /dev/null > +++ b/Platform/NXP/Library/ResetSystemLib/ResetSystemLib.inf > @@ -0,0 +1,33 @@ > +# @ResetSystemLib.inf > +# Reset System lib to make it easy to port new platforms > +# > +# Copyright (c) 2016, Freescale Semiconductor, Inc. All rights reserved. > +# Copyright 2017 NXP > +# > +# 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. > +# > +# > + > +[Defines] > + INF_VERSION = 0x00010005 > + BASE_NAME = ResetSystemLib > + FILE_GUID = 781371a2-3fdd-41d4-96a1-7b34cbc9e895 > + MODULE_TYPE = BASE > + VERSION_STRING = 1.0 > + LIBRARY_CLASS = EfiResetSystemLib > + > +[Sources.common] > + ResetSystemLib.c > + > +[Packages] > + ArmPkg/ArmPkg.dec > + MdePkg/MdePkg.dec > + > +[LibraryClasses] > + ArmSmcLib > + BaseLib > -- > 1.9.1 >