From nobody Sat Nov 2 12:30:11 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; 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 1490602147806360.8889233347453; Mon, 27 Mar 2017 01:09:07 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 8FA7920084749; Mon, 27 Mar 2017 01:08:58 -0700 (PDT) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id F3FD2203BEBF5 for ; Mon, 27 Mar 2017 01:08:54 -0700 (PDT) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Mar 2017 01:08:54 -0700 Received: from junghyun-mobl.amr.corp.intel.com (HELO jljusten-skl.amr.corp.intel.com) ([10.252.131.12]) by fmsmga005.fm.intel.com with ESMTP; 27 Mar 2017 01:08:54 -0700 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490602134; x=1522138134; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=Ie10hfnBul0g6TAkGa7VkphvgTkrKQDQjlzpXoaFmM4=; b=FM6MTTKXDDy0UJgMJxhHkY8yskWLeeCZFVpdbURs5fw/N4w7fXSglcuR taODvorYswYjijGncJnfCO/fIIy4Qg==; X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,229,1486454400"; d="scan'208";a="80948350" From: Jordan Justen To: edk2-devel@lists.01.org Date: Mon, 27 Mar 2017 01:05:37 -0700 Message-Id: <20170327080544.24748-6-jordan.l.justen@intel.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170327080544.24748-1-jordan.l.justen@intel.com> References: <20170327080544.24748-1-jordan.l.justen@intel.com> Subject: [edk2] [PATCH 05/12] OvmfPkg QemuFlash: Make QemuFlashDetected external 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: Jordan Justen , Laszlo Ersek MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" QemuFlashDetected is also changed to not use global variables. Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jordan Justen --- OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c | 29 +++++++++++++++++-= ---- OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.h | 14 +++++++++++ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c b/OvmfPkg/Q= emuFlashFvbServicesRuntimeDxe/QemuFlash.c index 68388048f3..90e7810733 100644 --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c +++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c @@ -16,6 +16,7 @@ #include #include #include +#include =20 #include "QemuFlash.h" =20 @@ -37,12 +38,25 @@ STATIC UINTN mFdBlockCount =3D 0; =20 STATIC volatile UINT8* +QemuFlashPtrEx ( + UINT8 *FlashBase, + UINTN BlockSize, + IN EFI_LBA Lba, + IN UINTN Offset + ) +{ + return FlashBase + ((UINTN)Lba * BlockSize) + Offset; +} + + +STATIC +volatile UINT8* QemuFlashPtr ( IN EFI_LBA Lba, IN UINTN Offset ) { - return mFlashBase + ((UINTN)Lba * mFdBlockSize) + Offset; + return QemuFlashPtrEx (mFlashBase, mFdBlockSize, Lba, Offset); } =20 =20 @@ -53,7 +67,6 @@ QemuFlashPtr ( @retval TRUE The QEMU flash device is present. =20 **/ -STATIC BOOLEAN QemuFlashDetected ( VOID @@ -66,11 +79,15 @@ QemuFlashDetected ( UINT8 OriginalUint8; UINT8 ProbeUint8; =20 + UINT8 *FlashBase =3D (UINT8*)(UINTN) PcdGet32 (PcdOvmfFdBaseAddress); + UINTN BlockSize =3D PcdGet32 (PcdOvmfFirmwareBlockSize); + ASSERT(PcdGet32 (PcdOvmfFirmwareFdSize) % BlockSize =3D=3D 0); + FlashDetected =3D FALSE; - Ptr =3D QemuFlashPtr (0, 0); + Ptr =3D QemuFlashPtrEx (FlashBase, BlockSize, 0, 0); =20 - for (Offset =3D 0; Offset < mFdBlockSize; Offset++) { - Ptr =3D QemuFlashPtr (0, Offset); + for (Offset =3D 0; Offset < BlockSize; Offset++) { + Ptr =3D QemuFlashPtrEx (FlashBase, BlockSize, 0, Offset); ProbeUint8 =3D *Ptr; if (ProbeUint8 !=3D CLEAR_STATUS_CMD && ProbeUint8 !=3D READ_STATUS_CMD && @@ -79,7 +96,7 @@ QemuFlashDetected ( } } =20 - if (Offset >=3D mFdBlockSize) { + if (Offset >=3D BlockSize) { DEBUG ((EFI_D_INFO, "QEMU Flash: Failed to find probe location\n")); return FALSE; } diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.h b/OvmfPkg/Q= emuFlashFvbServicesRuntimeDxe/QemuFlash.h index 4bd971b0d1..04f89364ab 100644 --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.h +++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.h @@ -19,6 +19,20 @@ extern UINT8 *mFlashBase; =20 /** + Detect if QEMU Flash is available and writable + + Note: This function does not use read or write global variables. + + @retval TRUE Flash is writable + +**/ +BOOLEAN +QemuFlashDetected ( + VOID + ); + + +/** Read from QEMU Flash =20 @param[in] Lba The starting logical block index to read from. --=20 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel