From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web09.1518.1668225663457832422 for ; Fri, 11 Nov 2022 20:01:04 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=UnOmDgH7; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: ray.ni@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668225663; x=1699761663; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Dc0Q5wKsCjUcGzE+JXIXNMYix+QgnrwLf3yfh0JcnaI=; b=UnOmDgH7Oq7dKL0xxmDpqbZQyrGNN5H+SMuIcPFfBOKrLRzXIRM4Qej0 BU3Xw1FCFM48Sr50MS27a2n7cPdL360Pa3yy6LxiSoO1+xkiNUowL9jh9 TG8N6LnhHW+ZH1mOU1ui9cf8ybBb+5Xt67U78qtFd4eukmWzwYCllh8/0 CyA9vpRpItCiImgQRELQ1BeyNPxmMxk1Q0LLdfKxHzyc6oNOAyOP38yJc NbcxsHQ3kB3s7crOKRmitb4zutSVZR49hQJPEHlWqLN97nNN5pvACR/dg 0z53GwSABSivrsqkr/+9IeuMlVdkW9RhfIo1sIg13jhrzGP1YR39pIrPD g==; X-IronPort-AV: E=McAfee;i="6500,9779,10528"; a="373827651" X-IronPort-AV: E=Sophos;i="5.96,158,1665471600"; d="scan'208";a="373827651" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Nov 2022 20:01:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10528"; a="588725569" X-IronPort-AV: E=Sophos;i="5.96,158,1665471600"; d="scan'208";a="588725569" Received: from shwdeopenlab706.ccr.corp.intel.com ([10.239.56.10]) by orsmga003.jf.intel.com with ESMTP; 11 Nov 2022 20:00:47 -0800 From: "Ni, Ray" To: devel@edk2.groups.io Cc: Andrew Fish , Zhiguang Liu Subject: [PATCH 1/3] EmulatorPkg/WinHost: pre-allocate "physical" RAM Date: Sat, 12 Nov 2022 12:00:40 +0800 Message-Id: <20221112040042.741-2-ray.ni@intel.com> X-Mailer: git-send-email 2.37.2.windows.2 In-Reply-To: <20221112040042.741-1-ray.ni@intel.com> References: <20221112040042.741-1-ray.ni@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Move the "physical" RAM allocation from WinPeiAutoScan to main() entrypoint. This is to prepare the changes for "reset" support. Signed-off-by: Ray Ni Cc: Andrew Fish Cc: Zhiguang Liu --- EmulatorPkg/Win/Host/WinHost.c | 60 ++++++++++++++-------------------- 1 file changed, 25 insertions(+), 35 deletions(-) diff --git a/EmulatorPkg/Win/Host/WinHost.c b/EmulatorPkg/Win/Host/WinHost.c index 93247c5043..5b780ca8af 100644 --- a/EmulatorPkg/Win/Host/WinHost.c +++ b/EmulatorPkg/Win/Host/WinHost.c @@ -8,7 +8,7 @@ This code produces 128 K of temporary memory for the SEC stack by direct= ly=0D allocate memory space with ReadWrite and Execute attribute.=0D =0D -Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
=0D +Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
=0D (C) Copyright 2016-2020 Hewlett Packard Enterprise Development LP
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D **/=0D @@ -87,14 +87,6 @@ WinPeiAutoScan ( return EFI_UNSUPPORTED;=0D }=0D =0D - //=0D - // Allocate enough memory space for emulator=0D - //=0D - gSystemMemory[Index].Memory =3D (EFI_PHYSICAL_ADDRESS)(UINTN)VirtualAllo= c (NULL, (SIZE_T)(gSystemMemory[Index].Size), MEM_COMMIT, PAGE_EXECUTE_READ= WRITE);=0D - if (gSystemMemory[Index].Memory =3D=3D 0) {=0D - return EFI_OUT_OF_RESOURCES;=0D - }=0D -=0D *MemoryBase =3D gSystemMemory[Index].Memory;=0D *MemorySize =3D gSystemMemory[Index].Size;=0D =0D @@ -457,6 +449,30 @@ Returns: exit (1);=0D }=0D =0D + //=0D + // Allocate "physical" memory space for emulator. It will be reported ou= t later throuth MemoryAutoScan()=0D + //=0D + for (Index =3D 0, Done =3D FALSE; !Done; Index++) {=0D + ASSERT (Index < gSystemMemoryCount);=0D + gSystemMemory[Index].Size =3D ((UINT64)_wtoi (MemorySizeStr)) * ((UI= NT64)SIZE_1MB);=0D + gSystemMemory[Index].Memory =3D (EFI_PHYSICAL_ADDRESS)(UINTN)VirtualAl= loc (NULL, (SIZE_T)(gSystemMemory[Index].Size), MEM_COMMIT, PAGE_EXECUTE_RE= ADWRITE);=0D + if (gSystemMemory[Index].Memory =3D=3D 0) {=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D +=0D + //=0D + // Find the next region=0D + //=0D + for (Index1 =3D 0; MemorySizeStr[Index1] !=3D '!' && MemorySizeStr[Ind= ex1] !=3D 0; Index1++) {=0D + }=0D +=0D + if (MemorySizeStr[Index1] =3D=3D 0) {=0D + Done =3D TRUE;=0D + }=0D +=0D + MemorySizeStr =3D MemorySizeStr + Index1 + 1;=0D + }=0D +=0D //=0D // Allocate space for gSystemMemory Array=0D //=0D @@ -575,32 +591,6 @@ Returns: SecPrint ("\n\r");=0D }=0D =0D - //=0D - // Calculate memory regions and store the information in the gSystemMemo= ry=0D - // global for later use. The autosizing code will use this data to=0D - // map this memory into the SEC process memory space.=0D - //=0D - for (Index =3D 0, Done =3D FALSE; !Done; Index++) {=0D - //=0D - // Save the size of the memory and make a Unicode filename SystemMemor= y00, ...=0D - //=0D - gSystemMemory[Index].Size =3D ((UINT64)_wtoi (MemorySizeStr)) * ((UINT= 64)SIZE_1MB);=0D -=0D - //=0D - // Find the next region=0D - //=0D - for (Index1 =3D 0; MemorySizeStr[Index1] !=3D '!' && MemorySizeStr[Ind= ex1] !=3D 0; Index1++) {=0D - }=0D -=0D - if (MemorySizeStr[Index1] =3D=3D 0) {=0D - Done =3D TRUE;=0D - }=0D -=0D - MemorySizeStr =3D MemorySizeStr + Index1 + 1;=0D - }=0D -=0D - SecPrint ("\n\r");=0D -=0D //=0D // Hand off to SEC Core=0D //=0D --=20 2.37.2.windows.2