From patchwork Wed Jul 5 09:42:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 107054 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp550404qge; Wed, 5 Jul 2017 02:43:08 -0700 (PDT) X-Received: by 10.200.47.114 with SMTP id k47mr27882773qta.18.1499247788339; Wed, 05 Jul 2017 02:43:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499247788; cv=none; d=google.com; s=arc-20160816; b=i/GaJBhs/Qod6zAxz+GuBw+ggE+tmbPBljNoDqynCBOQlKA2hG8Vl03PLcscHcnmv4 Z0tgIyAtJLwYGbqmS/5hTZn0Hg35XsjABNghq2XwZ4KfVH7YOVxPOu1eAy1VLaeQpq7/ MTiJZ4t9bes2JTEPftTJ0CZL3D4EfDJuP7fBsKN7+lxlh1OhiPjwcPoy0wnIz0PKWt4z NAAQJrqjPtynGg6takOaKg2/+XpeQOwmMIc9lDiWQ6k90tJXjlPRi4cjkCCel3aBn0hl a1pc8tT+aFZggck0Rk6lcaveHSD1CZqwXm5geU7C3ZKGGs/2BPCw/Pg8AHwJve5a28rQ MNLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:delivered-to :arc-authentication-results; bh=S6gRW9bLF7E2BD/XGWtc6j2unGgwZ7EoNl/K1sKI4lg=; b=TU0OHJzL50I3bVsjCeTV7TBcKFuMX/pP4SrQ8FBKjtAeXygS12ge7l4ioz5b4DJvhj mB/4V4g7K2WbSQ9GTxlju2IKgAZvg7z8GjbZ3E53YadDZVUgeqVkFZw+dHhjb8M66MDv D5/kbkOJDe5cpewLKlv0yC39p1hExglowWYGsV1aavBK17c93CytvCQm+bvTNAw8l3Nu UovEBQR/xX8ny6/gSQAcm/O7CLFPzt9egViOAnvPiYVeTwmR/TOW2LRAH6RZwdnMrJOc m1kBL7UTnApoaN4BY2oiOvr8s28OMtaL3QwgrXbCp/MMq5MCzIXIPHT4EgtsW1QZ1ByD KLag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linaro-uefi-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=linaro-uefi-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id b37si21018310qkh.267.2017.07.05.02.43.07; Wed, 05 Jul 2017 02:43:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linaro-uefi-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linaro-uefi-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=linaro-uefi-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id A4DB260C5E; Wed, 5 Jul 2017 09:43:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 66D4560C51; Wed, 5 Jul 2017 09:43:01 +0000 (UTC) X-Original-To: linaro-uefi@lists.linaro.org Delivered-To: linaro-uefi@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 36EF560C53; Wed, 5 Jul 2017 09:42:59 +0000 (UTC) Received: from mail-wm0-f45.google.com (mail-wm0-f45.google.com [74.125.82.45]) by lists.linaro.org (Postfix) with ESMTPS id 9163260C32 for ; Wed, 5 Jul 2017 09:42:57 +0000 (UTC) Received: by mail-wm0-f45.google.com with SMTP id 62so217052270wmw.1 for ; Wed, 05 Jul 2017 02:42:57 -0700 (PDT) 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=s4IYENXkPUqtK+wgsderzi5Y7E/4eB6Li11o1e/dO68=; b=MtAmM9gdkhByqUyTqXvmpqO80Kg8+/fkDqStCXnxq+R2gJBE+XdennVhcUcqxsOa7E Tnj5FUeeEoaX1bqOVU2O6Weaf+JfmUUUhBUHk2+p1XzoJOpKiyS2zREe8Pp9kHxHTfaC aNyH+B1PJ8aRM7+P4ROtebDLoU4SXshfVWIqabx04PCKd7D6m7KQxDzK6knk+BP/e+M4 WnWQYpqDXPuffYVq6d0Hpw0vYBovgRm+u6uLEaWlQg09T49byXZeQk9juiCgMXDdoP8m Jdx6b775pKGDAEDGKHg26PBgPeHtM5WlxrIwY/2TIH7BOh7K15/jf8Zpr/2sxL++KHcX w+0w== X-Gm-Message-State: AKS2vOxG8ouH6z0JxVfDsDb5VU8gVWneEco/i+TP5qs4+6wDklQBsUg5 rDHcUd1rGjJ7OgvngeIhM9tD X-Received: by 10.28.174.80 with SMTP id x77mr21029952wme.73.1499247776225; Wed, 05 Jul 2017 02:42:56 -0700 (PDT) Received: from localhost.localdomain ([154.145.144.206]) by smtp.gmail.com with ESMTPSA id 1sm24974534wmn.32.2017.07.05.02.42.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Jul 2017 02:42:55 -0700 (PDT) From: Ard Biesheuvel To: linaro-uefi@lists.linaro.org Date: Wed, 5 Jul 2017 10:42:50 +0100 Message-Id: <20170705094250.22848-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 Subject: [Linaro-uefi] [PATCH v2] Platforms/Marvell: switch to generic ResetSystemRuntimeDxe X-BeenThere: linaro-uefi@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "For discussions about Linaro-related UEFI development. Not a substitute for edk2-devel." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linaro-uefi-bounces@lists.linaro.org Sender: "Linaro-uefi" Switch to the generic implementation of the ResetSystem() runtime service call, which is preferred over the one in EmbeddedPkg. This involves selecting another DXE runtime driver, and given that the Marvell platforms support PSCI these days, we can drop the existing MvResetSystemLib entirely and switch to the shared PSCI based one. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel Tested-by: Marcin Wojtas --- v2: - switch to PSCI while we're at it. Platforms/Marvell/Armada/Armada.dsc.inc | 4 +- Platforms/Marvell/Armada/Armada70x0.fdf | 2 +- Platforms/Marvell/Library/ResetSystemLib/MvResetSystemLib.c | 159 -------------------- Platforms/Marvell/Library/ResetSystemLib/MvResetSystemLib.inf | 58 ------- 4 files changed, 3 insertions(+), 220 deletions(-) diff --git a/Platforms/Marvell/Armada/Armada.dsc.inc b/Platforms/Marvell/Armada/Armada.dsc.inc index 475fc6d05379..c30f39fc12dd 100644 --- a/Platforms/Marvell/Armada/Armada.dsc.inc +++ b/Platforms/Marvell/Armada/Armada.dsc.inc @@ -94,7 +94,7 @@ # Reset and Time libraries EfiTimeBaseLib|OpenPlatformPkg/Library/EfiTimeBaseLib/EfiTimeBaseLib.inf RealTimeClockLib|OpenPlatformPkg/Platforms/Marvell/Armada/Library/RealTimeClockLib/RealTimeClockLib.inf - EfiResetSystemLib|OpenPlatformPkg/Platforms/Marvell/Library/ResetSystemLib/MvResetSystemLib.inf + ResetSystemLib|ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.inf # Network support NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf @@ -416,7 +416,7 @@ MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.inf - EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf + MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf diff --git a/Platforms/Marvell/Armada/Armada70x0.fdf b/Platforms/Marvell/Armada/Armada70x0.fdf index 280b40be1d39..8091ea260261 100644 --- a/Platforms/Marvell/Armada/Armada70x0.fdf +++ b/Platforms/Marvell/Armada/Armada70x0.fdf @@ -99,7 +99,7 @@ FvNameGuid = 5eda4200-2c5f-43cb-9da3-0baf74b1b30c INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf INF MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf INF EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.inf - INF EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf + INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf INF EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf INF EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf INF OpenPlatformPkg/Drivers/I2c/MvI2cDxe/MvI2cDxe.inf diff --git a/Platforms/Marvell/Library/ResetSystemLib/MvResetSystemLib.c b/Platforms/Marvell/Library/ResetSystemLib/MvResetSystemLib.c deleted file mode 100644 index c0787aceac9c..000000000000 --- a/Platforms/Marvell/Library/ResetSystemLib/MvResetSystemLib.c +++ /dev/null @@ -1,159 +0,0 @@ -/******************************************************************************** -Copyright (C) 2016 Marvell International Ltd. - -Marvell BSD License Option - -If you received this File from Marvell, you may opt to use, redistribute and/or -modify this File under the following licensing terms. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Marvell nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ - - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -STATIC EFI_EVENT mResetSystemVirtualAddrChangeEvent; -STATIC UINT64 mAddress; - -STATIC -VOID -EFIAPI -LibResetSystemVirtualNotifyEvent ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - // - // Convert physical address to virtual address. - // - EfiConvertPointer (0x0, (VOID**)&mAddress); - return; -} - -/** - 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 VOID *ResetData OPTIONAL - ) -{ - UINT32 Data; - - switch (ResetType) { - case EfiResetCold: - case EfiResetWarm: - Data = MmioRead32 (mAddress); - Data &= ~PcdGet32 (PcdResetRegMask); - MmioWrite32 (mAddress, Data); - break; - case EfiResetShutdown: - // - // Currently there is no support for power-off platform - // - break; - default: - break; - } - - return EFI_DEVICE_ERROR; -} - -EFI_STATUS -EFIAPI -LibInitializeResetSystem ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - UINT64 Alignment; - EFI_STATUS Status; - - mAddress = PcdGet64 (PcdResetRegAddress); - - Alignment = ~(SIZE_64KB - 1); - // - // Add 64KB aligned and 64KB long memory space - // - Status = gDS->AddMemorySpace ( - EfiGcdMemoryTypeMemoryMappedIo, - mAddress & Alignment, SIZE_64KB, - EFI_MEMORY_UC | EFI_MEMORY_RUNTIME - ); - if (EFI_ERROR (Status)) { - ASSERT_EFI_ERROR (Status); - return Status; - } - - // - // Mark 64KB aligned and 64KB long memory space as runtime - // - Status = gDS->SetMemorySpaceAttributes (mAddress & Alignment, SIZE_64KB, - EFI_MEMORY_UC | EFI_MEMORY_RUNTIME); - if (EFI_ERROR (Status)) { - ASSERT_EFI_ERROR (Status); - return Status; - } - - // - // Register for the virtual address change event - // - Status = gBS->CreateEventEx ( - EVT_NOTIFY_SIGNAL, - TPL_NOTIFY, - LibResetSystemVirtualNotifyEvent, - NULL, - &gEfiEventVirtualAddressChangeGuid, - &mResetSystemVirtualAddrChangeEvent - ); - ASSERT_EFI_ERROR (Status); - - return Status; -} diff --git a/Platforms/Marvell/Library/ResetSystemLib/MvResetSystemLib.inf b/Platforms/Marvell/Library/ResetSystemLib/MvResetSystemLib.inf deleted file mode 100644 index 87fff5707909..000000000000 --- a/Platforms/Marvell/Library/ResetSystemLib/MvResetSystemLib.inf +++ /dev/null @@ -1,58 +0,0 @@ -# Copyright (C) 2016 Marvell International Ltd. -# -# Marvell BSD License Option -# -# If you received this File from Marvell, you may opt to use, redistribute and/or -# modify this File under the following licensing terms. -# Redistribution and use in source and binary forms, with or without modification, -# are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Marvell nor the names of its contributors may be -# used to endorse or promote products derived from this software without -# specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -[Defines] - INF_VERSION = 0x00010019 - BASE_NAME = Reset - FILE_GUID = 9d1373c0-6fac-432c-88e7-818744dc45d9 - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = EfiResetSystemLib - -[Sources.common] - MvResetSystemLib.c - -[Packages] - MdePkg/MdePkg.dec - OpenPlatformPkg/Platforms/Marvell/Marvell.dec - -[LibraryClasses] - DebugLib - DxeServicesTableLib - IoLib - UefiBootServicesTableLib - UefiLib - UefiRuntimeLib - -[Pcd] - gMarvellTokenSpaceGuid.PcdResetRegAddress - gMarvellTokenSpaceGuid.PcdResetRegMask