From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by mx.groups.io with SMTP id smtpd.web11.19132.1681498720289713627 for ; Fri, 14 Apr 2023 11:58:43 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="signature has expired" header.i=@ventanamicro.com header.s=google header.b=ZEnWjCaD; spf=pass (domain: ventanamicro.com, ip: 209.85.214.181, mailfrom: tphan@ventanamicro.com) Received: by mail-pl1-f181.google.com with SMTP id y6so18156924plp.2 for ; Fri, 14 Apr 2023 11:58:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1681498722; x=1684090722; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Mn4VEBZxuAszbMkJYZmyi4EHpBFdPVrbp08AvxBDDJM=; b=ZEnWjCaDfy/nVG/VNGrDMJVChpDADEoukK+bKPICjgD1pMH6KntMcWmferRFcSu6Ah w4nMzgK+gptNrRS52CU1WPP7GuvPIQ6jgSwkSbXGZFeDD3s5yZO/jaLjmByCjsL/eI04 nVbFTF7VSRiSe/3y4ilBpf2eWl6iIpv9yWVC9qNQHH9FjzOuZ2nUmZTy4we35KhN4NIE NF+KhO9SK+zByZE4LZt4uQ28VWRZUVISMFANUTcdl15krxzSi4vt97+7VROo9cIReM7F 0G9A1MTc5hT+LYQdc+wrNsHJPbj0fqr0nxXny+ZRMxUVIKUQuPBXUbDuG5jyrzEyBUWU mY8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681498722; x=1684090722; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Mn4VEBZxuAszbMkJYZmyi4EHpBFdPVrbp08AvxBDDJM=; b=AOe2bFwurjp53P/k1EzK1fEoqHn5MBOzojid8RAIc8yZkO5vA2gzmhmuBw+w+sG6ze igJxXrTIQ+bYBtNPTFi4Q+fJ5Crrsg5jNgKE8YBWU7uqP69aCtaW4dNu3IK6eYgD3hAy IeqY0M9E7LSOBugJPaXk5z7+JXuIVNTPFkoNTEZDg3rGMPZDcM9L4BgXRhGCMcfYXCf9 9sVxTLeQeAF1lpkG7nw+j/wLm0zx5NyJmSmx8BzbJWMIfKhrGHMTzOGF8Za8f61flYW0 xiqInROyU76Gsy0w13MdrLtvAhJLgx76pLlJrX+drbstKkYoHM74Sh24SpwKoFgajG64 SBGQ== X-Gm-Message-State: AAQBX9cb51luPFli9D71/m3+BW6O4C0igPfP0bBxHyid2a603W6sFqZz raEOAvVTf/CZOsr0qnOnzoVj+jR10ArgmF2m6MbjiQ== X-Google-Smtp-Source: AKy350YnEqrC+F6J01gxAFs3WiHIYZKgDlh8flaPXKg/rkeqoljRR+cIie/K2HCFDJqSQ2aT9ThhgQ== X-Received: by 2002:a17:902:f707:b0:1a2:296:9355 with SMTP id h7-20020a170902f70700b001a202969355mr3818131plo.16.1681498722198; Fri, 14 Apr 2023 11:58:42 -0700 (PDT) Return-Path: Received: from localhost.localdomain (c-174-50-177-95.hsd1.ca.comcast.net. [174.50.177.95]) by smtp.gmail.com with ESMTPSA id g20-20020a170902869400b001a681d123a0sm3329760plo.297.2023.04.14.11.58.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 11:58:41 -0700 (PDT) From: "Tuan Phan" To: devel@edk2.groups.io Cc: michael.d.kinney@intel.com, gaoliming@byosoft.com.cn, zhiguang.liu@intel.com, sunilvl@ventanamicro.com, git@danielschaefer.me, andrei.warkentin@intel.com, Tuan Phan Subject: [PATCH v2 5/6] OvmfPkg/VirtNorFlashDxe: Not add memory space if it exists Date: Fri, 14 Apr 2023 11:58:14 -0700 Message-Id: <20230414185815.2994-6-tphan@ventanamicro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230414185815.2994-1-tphan@ventanamicro.com> References: <20230414185815.2994-1-tphan@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable The flash base address can be added to GCD before this driver run. So only add it if it has not been done. Signed-off-by: Tuan Phan --- OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c | 25 +++++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c b/OvmfPkg/VirtNorFla= shDxe/VirtNorFlashDxe.c index 6b9ef261335e..bbd1697a51dd 100644 --- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c +++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c @@ -372,10 +372,11 @@ NorFlashFvbInitialize ( IN NOR_FLASH_INSTANCE *Instance=0D )=0D {=0D - EFI_STATUS Status;=0D - UINT32 FvbNumLba;=0D - EFI_BOOT_MODE BootMode;=0D - UINTN RuntimeMmioRegionSize;=0D + EFI_STATUS Status;=0D + UINT32 FvbNumLba;=0D + EFI_BOOT_MODE BootMode;=0D + UINTN RuntimeMmioRegionSize;=0D + EFI_GCD_MEMORY_SPACE_DESCRIPTOR Desc;=0D =0D DEBUG ((DEBUG_BLKIO, "NorFlashFvbInitialize\n"));=0D ASSERT ((Instance !=3D NULL));=0D @@ -390,13 +391,19 @@ NorFlashFvbInitialize ( // is written as the base of the flash region (ie: Instance->Devic= eBaseAddress)=0D RuntimeMmioRegionSize =3D (Instance->RegionBaseAddress - Instance->Devic= eBaseAddress) + Instance->Size;=0D =0D - Status =3D gDS->AddMemorySpace (=0D - EfiGcdMemoryTypeMemoryMappedIo,=0D + Status =3D gDS->GetMemorySpaceDescriptor (=0D Instance->DeviceBaseAddress,=0D - RuntimeMmioRegionSize,=0D - EFI_MEMORY_UC | EFI_MEMORY_RUNTIME=0D + &Desc=0D );=0D - ASSERT_EFI_ERROR (Status);=0D + if (Status =3D=3D EFI_NOT_FOUND) {=0D + Status =3D gDS->AddMemorySpace (=0D + EfiGcdMemoryTypeMemoryMappedIo,=0D + Instance->DeviceBaseAddress,=0D + RuntimeMmioRegionSize,=0D + EFI_MEMORY_UC | EFI_MEMORY_RUNTIME=0D + );=0D + ASSERT_EFI_ERROR (Status);=0D + }=0D =0D Status =3D gDS->SetMemorySpaceAttributes (=0D Instance->DeviceBaseAddress,=0D --=20 2.25.1