From nobody Wed Dec 25 05:25:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.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 1511857177817491.96955997793464; Tue, 28 Nov 2017 00:19:37 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 3E8CE220D4C1F; Tue, 28 Nov 2017 00:15:12 -0800 (PST) Received: from mail-lf0-x244.google.com (mail-lf0-x244.google.com [IPv6:2a00:1450:4010:c07::244]) (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 CB7042034A794 for ; Tue, 28 Nov 2017 00:15:10 -0800 (PST) Received: by mail-lf0-x244.google.com with SMTP id x68so35967705lff.0 for ; Tue, 28 Nov 2017 00:19:33 -0800 (PST) Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id j85sm79732lfh.53.2017.11.28.00.19.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Nov 2017 00:19:30 -0800 (PST) X-Original-To: edk2-devel@lists.01.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; Received-SPF: None (no SPF record) identity=mailfrom; client-ip=2a00:1450:4010:c07::244; helo=mail-lf0-x244.google.com; envelope-from=mw@semihalf.com; receiver=edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sh+zpDaf8hZLjL+yWVlPN+f9yJEMf/6VbQW/QuShxjo=; b=UmEken4xcLvtgjmHOu2rtZHfhNwUp4tqOvvwYvOGgWtjmmJHI4+kxYBC/AkR4f0mis KC8lumFxMQ5j45r88JdAJgFNjwalge74p+kiZFJgSks+x4YnMIBAqWIc0UabUhWppO5S 34YeOnfBoBtYQnRjdE2nnbx5i1+IXciKK2nl6hYBAJ8WsufbMLpSVMQXFpZSB1hhPA9g eC+paUJqmis0t0q7dRSDggsAEo3l+OVMYwIb5lHgAkSzlF04TzxtfXM+eBa5L5NXi2YL hffe+bW2gn8xqNB/jYvvR0IETWap+8FP8YGjwZrLItyZeY1YtEAm3F50oN5hWY2dcnkE ruhQ== 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:in-reply-to :references; bh=sh+zpDaf8hZLjL+yWVlPN+f9yJEMf/6VbQW/QuShxjo=; b=m5+DnPaxqif4fGa2nQl0BBj88M37Kghfl3irCL/NFg07hrAeRvOY0RHKpFXQeoqut/ 0ukUDS4Cfn7/M/nEVc6B8Z809wLp0Ygd6LA2wm0M1y7ID6R8Wv1Up5VUTNzv/YvLYEeG sCr/AbtaNwUHFQgaBdiSf86d5WQ0vlBZXS4C3ssGej28YDrfdFfoSYyoiYA7iAGjW734 2ozKqLTF8NjJbDHbP4ZAIuhO1YSMTRQVQnQTQe8rtAhynwDGq5uiJEI3LGEbbINeL89Q iMbirOMNnfmZH/wi8AxJqnHxcBxUryIpCjXyU22ZRRVUk3Lphlu/ykOOzjk49P+ljCig s6Yw== X-Gm-Message-State: AJaThX4A/aTfkD7eA7W5nCk7oTVY3qccgRManm4IT/GiQ6YosXJMLevJ ULQU7eobBcTQDWC33BpsUDWGbrKXXDc= X-Google-Smtp-Source: AGs4zMa3JNvwvwWApBc5QDVj/iwIF7KMlc1b2ja96mG/fcNjQAZBnKbUf3lRGyD8UVsXWWBqfQd+iA== X-Received: by 10.25.157.143 with SMTP id g137mr3436857lfe.6.1511857171782; Tue, 28 Nov 2017 00:19:31 -0800 (PST) From: Marcin Wojtas To: edk2-devel@lists.01.org Date: Tue, 28 Nov 2017 09:19:11 +0100 Message-Id: <1511857153-9266-3-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511857153-9266-1-git-send-email-mw@semihalf.com> References: <1511857153-9266-1-git-send-email-mw@semihalf.com> Subject: [edk2] [platforms: PATCH v3 2/4] Marvell/Drivers: MvSpiFlash: Enable using driver in RT 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: jinghua@marvell.com, ard.biesheuvel@linaro.org, leif.lindholm@linaro.org, nadavh@marvell.com, neta@marvell.com, kostap@marvell.com 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" This patch applies necessary modifications, which allow to use MvSpiFlash driver in variable support as a runtime service. Its type is modified to DXE_RUNTIME_DRIVER, as well as an event is created, which converts the pointers to the SpiMasterProtocol and its routines. In order to ensure proper execution of the MvFvbDxe driver, configure initialization order with Depex entry. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marcin Wojtas Reviewed-by: Leif Lindholm --- Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c | 58 +++++++++++++++++= +-- Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.h | 1 + Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.inf | 11 +++- Platform/Marvell/Marvell.dec | 2 + 4 files changed, 66 insertions(+), 6 deletions(-) diff --git a/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c b/Platform/M= arvell/Drivers/Spi/Devices/MvSpiFlash.c index 456d9f9..6886d01 100755 --- a/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c +++ b/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c @@ -33,6 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMA= GE. **************************************************************************= *****/ #include "MvSpiFlash.h" =20 +STATIC EFI_EVENT mMvSpiFlashVirtualAddrChangeEvent; MARVELL_SPI_MASTER_PROTOCOL *SpiMasterProtocol; SPI_FLASH_INSTANCE *mSpiFlashInstance; =20 @@ -503,6 +504,33 @@ MvSpiFlashInitProtocol ( return EFI_SUCCESS; } =20 +/** + Fixup internal data so that EFI can be call in virtual mode. + Call the passed in Child Notify event and convert any pointers in + lib to virtual mode. + + @param[in] Event The Event that is being processed + @param[in] Context Event Context +**/ +STATIC +VOID +EFIAPI +MvSpiFlashVirtualNotifyEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + // + // Convert SpiMasterProtocol callbacks in MvSpiFlashErase and + // MvSpiFlashWrite required by runtime variable support. + // + EfiConvertPointer (0x0, (VOID**)&SpiMasterProtocol->ReadWrite); + EfiConvertPointer (0x0, (VOID**)&SpiMasterProtocol->Transfer); + EfiConvertPointer (0x0, (VOID**)&SpiMasterProtocol); + + return; +} + EFI_STATUS EFIAPI MvSpiFlashEntryPoint ( @@ -522,8 +550,7 @@ MvSpiFlashEntryPoint ( return EFI_DEVICE_ERROR; } =20 - mSpiFlashInstance =3D AllocateZeroPool (sizeof (SPI_FLASH_INSTANCE)); - + mSpiFlashInstance =3D AllocateRuntimeZeroPool (sizeof (SPI_FLASH_INSTANC= E)); if (mSpiFlashInstance =3D=3D NULL) { DEBUG((DEBUG_ERROR, "SpiFlash: Cannot allocate memory\n")); return EFI_OUT_OF_RESOURCES; @@ -540,10 +567,33 @@ MvSpiFlashEntryPoint ( NULL ); if (EFI_ERROR (Status)) { - FreePool (mSpiFlashInstance); DEBUG((DEBUG_ERROR, "SpiFlash: Cannot install SPI flash protocol\n")); - return EFI_DEVICE_ERROR; + goto ErrorInstallProto; + } + + // + // Register for the virtual address change event + // + Status =3D gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, + TPL_NOTIFY, + MvSpiFlashVirtualNotifyEvent, + NULL, + &gEfiEventVirtualAddressChangeGuid, + &mMvSpiFlashVirtualAddrChangeEvent); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Failed to register VA change event\n", __FUN= CTION__)); + goto ErrorCreateEvent; } =20 return EFI_SUCCESS; + +ErrorCreateEvent: + gBS->UninstallMultipleProtocolInterfaces (&mSpiFlashInstance->Handle, + &gMarvellSpiFlashProtocolGuid, + NULL); + +ErrorInstallProto: + FreePool (mSpiFlashInstance); + + return EFI_SUCCESS; } diff --git a/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.h b/Platform/M= arvell/Drivers/Spi/Devices/MvSpiFlash.h index f09ff50..f69c562 100755 --- a/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.h +++ b/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.h @@ -42,6 +42,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMA= GE. #include #include #include +#include =20 #include #include diff --git a/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.inf b/Platform= /Marvell/Drivers/Spi/Devices/MvSpiFlash.inf index 6587f69..c6bbe5e 100644 --- a/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.inf +++ b/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.inf @@ -33,7 +33,7 @@ INF_VERSION =3D 0x00010005 BASE_NAME =3D SpiFlashDxe FILE_GUID =3D 49d7fb74-306d-42bd-94c8-c0c54b181dd7 - MODULE_TYPE =3D DXE_DRIVER + MODULE_TYPE =3D DXE_RUNTIME_DRIVER VERSION_STRING =3D 1.0 ENTRY_POINT =3D MvSpiFlashEntryPoint =20 @@ -54,10 +54,17 @@ UefiLib DebugLib MemoryAllocationLib + UefiRuntimeLib + +[Guids] + gEfiEventVirtualAddressChangeGuid =20 [Protocols] gMarvellSpiMasterProtocolGuid gMarvellSpiFlashProtocolGuid =20 [Depex] - TRUE + # + # MvSpiFlashDxe must be loaded prior to variables driver MvFvbDxe + # + BEFORE gMarvellFvbDxeGuid diff --git a/Platform/Marvell/Marvell.dec b/Platform/Marvell/Marvell.dec index 6aa2a8d..e40771b 100644 --- a/Platform/Marvell/Marvell.dec +++ b/Platform/Marvell/Marvell.dec @@ -56,6 +56,8 @@ gShellFUpdateHiiGuid =3D { 0x9b5d2176, 0x590a, 0x49db, { 0x89, 0x5d, 0x4= a, 0x70, 0xfe, 0xad, 0xbe, 0x24 } } gShellSfHiiGuid =3D { 0x03a67756, 0x8cde, 0x4638, { 0x82, 0x34, 0x4a, 0x= 0f, 0x6d, 0x58, 0x81, 0x39 } } =20 + gMarvellFvbDxeGuid =3D { 0x42903750, 0x7e61, 0x4aaf, { 0x83, 0x29, 0xbf,= 0x42, 0x36, 0x4e, 0x24, 0x85 } } + [Protocols] # installed as a protocol by PlatInitDxe to force ordering between DXE d= rivers # that depend on the lowlevel platform initialization having been comple= ted --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel