From nobody Fri Apr 19 08:48:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+96320+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+96320+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1668225665; cv=none; d=zohomail.com; s=zohoarc; b=QyZdcxzEFgY7iPlPbrrdP4WB0ro9iEa60uTUNjOB30a3GNCHnq8Ebn1wXCKAkjZLITbYSgXwAJetkFH8yuXftERC/X4xLfCVhxWdlqV1Ah19cWz6M4VzhVNxBHEqmyTAuceh1EEcdoqb8ZdONPVhvXl/RTN5chHqgQs5ZS97ikk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668225665; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=EyIKhDZHfvwClaYqh8n9lL4UL7RFOpKIW9VB4GAjByQ=; b=D2WTlk1Q40OAGiJ693wS1vU7jAy0vMGGfJYjmGAy7FQePwkt/QMQe28iHn6AumIz3dxrgQYA/Gls5hpqC2M+Jx9bbcoK80Jpbc+IMmIQ2/4gLGW7NDLNrPGItbIS8CfW188+zpZIrg9eJIUTX0eZP33XSw6/xsLxYskNIpaBSAM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+96320+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1668225665288517.6708881285399; Fri, 11 Nov 2022 20:01:05 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id bxA0YY1788612xfWmq0wA26A; Fri, 11 Nov 2022 20:01:05 -0800 X-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 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" X-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" X-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: [edk2-devel] [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> In-Reply-To: <20221112040042.741-1-ray.ni@intel.com> References: <20221112040042.741-1-ray.ni@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ray.ni@intel.com X-Gm-Message-State: P49Zjvbqgk6VvSLeOPoE6H7ax1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1668225665; bh=VKJt/4eM0jvn/PwIZAOP02PM7BATDxVxfnXUSM/S5OA=; h=Cc:Date:From:Reply-To:Subject:To; b=OxHadDS5dmKwmtU2I15MhaKCHN4++hDCR+27TK6oWFS6Vykk7zxWxmqPpNdGq3kNi/8 FytghqFU0tC36Rm7N1aMLwyhVbjC45zB+wuTjm96WzClU5HF04EPqcBEN2ZQuaZZHutxJ MYZ1JugcsMAVrr7Jlc9ad+SRCLHOJC1ERAQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1668225666569100005 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: 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 allocate memory space with ReadWrite and Execute attribute. =20 -Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
(C) Copyright 2016-2020 Hewlett Packard Enterprise Development LP
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -87,14 +87,6 @@ WinPeiAutoScan ( return EFI_UNSUPPORTED; } =20 - // - // Allocate enough memory space for emulator - // - gSystemMemory[Index].Memory =3D (EFI_PHYSICAL_ADDRESS)(UINTN)VirtualAllo= c (NULL, (SIZE_T)(gSystemMemory[Index].Size), MEM_COMMIT, PAGE_EXECUTE_READ= WRITE); - if (gSystemMemory[Index].Memory =3D=3D 0) { - return EFI_OUT_OF_RESOURCES; - } - *MemoryBase =3D gSystemMemory[Index].Memory; *MemorySize =3D gSystemMemory[Index].Size; =20 @@ -457,6 +449,30 @@ Returns: exit (1); } =20 + // + // Allocate "physical" memory space for emulator. It will be reported ou= t later throuth MemoryAutoScan() + // + for (Index =3D 0, Done =3D FALSE; !Done; Index++) { + ASSERT (Index < gSystemMemoryCount); + gSystemMemory[Index].Size =3D ((UINT64)_wtoi (MemorySizeStr)) * ((UI= NT64)SIZE_1MB); + gSystemMemory[Index].Memory =3D (EFI_PHYSICAL_ADDRESS)(UINTN)VirtualAl= loc (NULL, (SIZE_T)(gSystemMemory[Index].Size), MEM_COMMIT, PAGE_EXECUTE_RE= ADWRITE); + if (gSystemMemory[Index].Memory =3D=3D 0) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Find the next region + // + for (Index1 =3D 0; MemorySizeStr[Index1] !=3D '!' && MemorySizeStr[Ind= ex1] !=3D 0; Index1++) { + } + + if (MemorySizeStr[Index1] =3D=3D 0) { + Done =3D TRUE; + } + + MemorySizeStr =3D MemorySizeStr + Index1 + 1; + } + // // Allocate space for gSystemMemory Array // @@ -575,32 +591,6 @@ Returns: SecPrint ("\n\r"); } =20 - // - // Calculate memory regions and store the information in the gSystemMemo= ry - // global for later use. The autosizing code will use this data to - // map this memory into the SEC process memory space. - // - for (Index =3D 0, Done =3D FALSE; !Done; Index++) { - // - // Save the size of the memory and make a Unicode filename SystemMemor= y00, ... - // - gSystemMemory[Index].Size =3D ((UINT64)_wtoi (MemorySizeStr)) * ((UINT= 64)SIZE_1MB); - - // - // Find the next region - // - for (Index1 =3D 0; MemorySizeStr[Index1] !=3D '!' && MemorySizeStr[Ind= ex1] !=3D 0; Index1++) { - } - - if (MemorySizeStr[Index1] =3D=3D 0) { - Done =3D TRUE; - } - - MemorySizeStr =3D MemorySizeStr + Index1 + 1; - } - - SecPrint ("\n\r"); - // // Hand off to SEC Core // --=20 2.37.2.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#96320): https://edk2.groups.io/g/devel/message/96320 Mute This Topic: https://groups.io/mt/94974520/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 08:48:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+96319+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+96319+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1668225664; cv=none; d=zohomail.com; s=zohoarc; b=dx/WFC9yxenTkKuGoTJqjAkDAZVYsu+3B2/xWfGvDH/IrSvMyDKb8+VffTT7GVLitQp6Q0Z5A1zF7aFbsKul+1WgqnyS3nMam/BDYqmqvzpejL/+cGfbzDoSQYZ/eoZdbJpcsdUklqOYDAWZEwqp4XPQaaUePSgIyjiJ94tuPrA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668225664; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=/+uBlhlYcWRKF4LIP5cdltNVv08prerSNxf6k8BI3Gg=; b=oJVajV+tPF1znJn4kf3MmNANc33rItqlngH4zVH7co0GgmLoA3VfCG3hZtNiD0+b1jr/5iYRT9DGq6VJjJ+ETCNvAF4uguEJCRKMYXMx/VIXmTnkVXzF/ab+iRtqQjB4qLL4XZ4d3f+MJxJsWIBlepvtN40rtlToC6Rz0T1McdM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+96319+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1668225664819555.7823668305765; Fri, 11 Nov 2022 20:01:04 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id uWxvYY1788612xBrVmYO88Co; Fri, 11 Nov 2022 20:01:04 -0800 X-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:03 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10528"; a="373827652" X-IronPort-AV: E=Sophos;i="5.96,158,1665471600"; d="scan'208";a="373827652" X-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="588725574" X-IronPort-AV: E=Sophos;i="5.96,158,1665471600"; d="scan'208";a="588725574" X-Received: from shwdeopenlab706.ccr.corp.intel.com ([10.239.56.10]) by orsmga003.jf.intel.com with ESMTP; 11 Nov 2022 20:00:48 -0800 From: "Ni, Ray" To: devel@edk2.groups.io Cc: Zhiguang Liu Subject: [edk2-devel] [PATCH 2/3] EmulatorPkg/WinHost: XIP for SEC and PEI_CORE Date: Sat, 12 Nov 2022 12:00:41 +0800 Message-Id: <20221112040042.741-3-ray.ni@intel.com> In-Reply-To: <20221112040042.741-1-ray.ni@intel.com> References: <20221112040042.741-1-ray.ni@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ray.ni@intel.com X-Gm-Message-State: UMd2gD3QMIZRQxYAnhEL7WILx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1668225664; bh=/GLJUkPiUP2JklOrPoV31GAoV4E9R5ssrfL+9l3Hc+k=; h=Cc:Date:From:Reply-To:Subject:To; b=oktqXdmokFhpE202lXfY4IqmywECNwhcZUsCMV+1/E7wKS3rSXoC/oT/RfQZEJZEZCM Krv4F0ZcyHDbjLyLf/y1/HDXxPKkwlN0EY7ShF/rQs5F57se+x1HW4NKqa0zqtMzJd33f W3vvB64QiEXCcycHF+3LILWT09Uxs2plhcc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1668225666566100004 Content-Type: text/plain; charset="utf-8" In EmulatorPkg/Win, SEC and PEI_CORE are loaded to memory allocated through VirtualAlloc. Though the corresponding DLL files are loaded and the entry points in DLL files are executed. The loading to memory allocated through VirtualAlloc is for the case when the DLL files can not be loaded. Actually some PEIMs like PcdPeim which are loaded before "physical" RAM is discovered, they are executing in the original location (FV) like XIP module in real platform. The SEC and PEI_CORE can follow the same mechanism. So, the VirtualAlloc call is removed. This is to prepare the "reset" support to avoid additional OS memory consumption when reset happens. Signed-off-by: Ray Ni Cc: Zhiguang Liu Cc: Andrew Fish --- EmulatorPkg/Win/Host/WinHost.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/EmulatorPkg/Win/Host/WinHost.c b/EmulatorPkg/Win/Host/WinHost.c index 5b780ca8af..9b10290ff3 100644 --- a/EmulatorPkg/Win/Host/WinHost.c +++ b/EmulatorPkg/Win/Host/WinHost.c @@ -718,19 +718,9 @@ SecPeCoffGetEntryPoint ( } =20 // - // Allocate space in NT (not emulator) memory with ReadWrite and Execute= attribute. - // Extra space is for alignment + // XIP for SEC and PEI_CORE // - ImageContext.ImageAddress =3D (EFI_PHYSICAL_ADDRESS)(UINTN)VirtualAlloc = (NULL, (SIZE_T)(ImageContext.ImageSize + (ImageContext.SectionAlignment * 2= )), MEM_COMMIT, PAGE_EXECUTE_READWRITE); - if (ImageContext.ImageAddress =3D=3D 0) { - return EFI_OUT_OF_RESOURCES; - } - - // - // Align buffer on section boundary - // - ImageContext.ImageAddress +=3D ImageContext.SectionAlignment - 1; - ImageContext.ImageAddress &=3D ~((EFI_PHYSICAL_ADDRESS)ImageContext.Sect= ionAlignment - 1); + ImageContext.ImageAddress =3D (EFI_PHYSICAL_ADDRESS)(UINTN)Pe32Data; =20 Status =3D PeCoffLoaderLoadImage (&ImageContext); if (EFI_ERROR (Status)) { --=20 2.37.2.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#96319): https://edk2.groups.io/g/devel/message/96319 Mute This Topic: https://groups.io/mt/94974519/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 08:48:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+96321+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+96321+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1668225666; cv=none; d=zohomail.com; s=zohoarc; b=Cjr5j8YXIt/yL1Jj0v1tHi2mLgj4Y3TDulWxXnh90dKZwpIwyKc9lg47Esa36YTR1kwyFXBpzTYgr7NfnYUvVSg8gsstnuevOsV74iMm+07BWhCBC5giL1aA3f4tDrF+DzbuTNfWd+qZJKMjZkgu+HpRdE8jx1jjuiVfFZ2/ft4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668225666; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=z8Lj+XYvhnqk45nPigYXO412hZs6rvywNWHhQRGxMUw=; b=TQWSTMXvMC56FomCobt9M6eICL8Ku0P9HyD+TeadJFtdNzRKcG2oTXiBWS4hm3xIyyYXK4a6nDIGYRv5/GI8DAZstlXMjSqwaU1xgQMfJwoH/dmh7FU78Ud2FccqzHor0CprNyg1bMYBwlbG0uHN3evRh8S1I7SzutF3F+JbScc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+96321+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1668225666464808.4383209525502; Fri, 11 Nov 2022 20:01:06 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id sSBjYY1788612xwFrVTiAb4o; Fri, 11 Nov 2022 20:01:05 -0800 X-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 X-IronPort-AV: E=McAfee;i="6500,9779,10528"; a="373827653" X-IronPort-AV: E=Sophos;i="5.96,158,1665471600"; d="scan'208";a="373827653" X-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="588725581" X-IronPort-AV: E=Sophos;i="5.96,158,1665471600"; d="scan'208";a="588725581" X-Received: from shwdeopenlab706.ccr.corp.intel.com ([10.239.56.10]) by orsmga003.jf.intel.com with ESMTP; 11 Nov 2022 20:00:49 -0800 From: "Ni, Ray" To: devel@edk2.groups.io Cc: Andrew Fish , Zhiguang Liu Subject: [edk2-devel] [PATCH 3/3] EmulatorPkg/WinHost: Add Reset2 PPI Date: Sat, 12 Nov 2022 12:00:42 +0800 Message-Id: <20221112040042.741-4-ray.ni@intel.com> In-Reply-To: <20221112040042.741-1-ray.ni@intel.com> References: <20221112040042.741-1-ray.ni@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ray.ni@intel.com X-Gm-Message-State: e8iCt1Q7GyOqHGDPwguxi4gux1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1668225665; bh=u3b3/sUUYJhNgDCz6YvQaKQvt/GWT90423+IBEoTbZw=; h=Cc:Date:From:Reply-To:Subject:To; b=UoToEXrsNyiJBarNbReY9Skgy6eWU3bqI2+Zq8POJBE7anuyubcPVu7RT+TUFVcC50z mY5DURZ7JiGkyVNlpqSMHRyBGJt4ZvQ5ItewPbVJRuUUOh0HT84VuI2SyhosdXfW3OFKC DVrcXFiCLjxgo3N3jiZc4GXch5KIAaW6jY4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1668225668539100015 Content-Type: text/plain; charset="utf-8" When shutdown is requested, WinHost exits. Otherwise, WinHost re-runs from SEC. Tested no extra memory consumption with multiple resets in PEI. Signed-off-by: Ray Ni Cc: Andrew Fish Cc: Zhiguang Liu Reviewed-by: Zhiguang Liu --- EmulatorPkg/Win/Host/WinHost.c | 75 ++++++++++++++++++++++++++++---- EmulatorPkg/Win/Host/WinHost.h | 3 +- EmulatorPkg/Win/Host/WinHost.inf | 3 +- 3 files changed, 71 insertions(+), 10 deletions(-) diff --git a/EmulatorPkg/Win/Host/WinHost.c b/EmulatorPkg/Win/Host/WinHost.c index 9b10290ff3..32b6922307 100644 --- a/EmulatorPkg/Win/Host/WinHost.c +++ b/EmulatorPkg/Win/Host/WinHost.c @@ -56,6 +56,14 @@ NT_FD_INFO *gFdInfo; UINTN gSystemMemoryCount =3D 0; NT_SYSTEM_MEMORY *gSystemMemory; =20 +BASE_LIBRARY_JUMP_BUFFER mResetJumpBuffer; +CHAR8 *mResetTypeStr[] =3D { + "EfiResetCold", + "EfiResetWarm", + "EfiResetShutdown", + "EfiResetPlatformSpecific" +}; + /*++ =20 Routine Description: @@ -196,6 +204,45 @@ SecPrint ( ); } =20 +/** + Resets the entire platform. + + @param[in] ResetType The type of reset to perform. + @param[in] ResetStatus The status code for the reset. + @param[in] DataSize The size, in bytes, of ResetData. + @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm,= or EfiResetShutdown + the data buffer starts with a Null-terminated = string, optionally + followed by additional binary data. The string= is a description + that the caller may use to further indicate th= e reason for the + system reset. + +**/ +VOID +EFIAPI +WinReset ( + IN EFI_RESET_TYPE ResetType, + IN EFI_STATUS ResetStatus, + IN UINTN DataSize, + IN VOID *ResetData OPTIONAL + ) +{ + ASSERT (ResetType <=3D EfiResetPlatformSpecific); + SecPrint (" Emu ResetSystem is called: ResetType =3D %s\n", mResetTypeS= tr[ResetType]); + + if (ResetType =3D=3D EfiResetShutdown) { + exit (0); + } else { + // + // Jump back to SetJump with jump code =3D ResetType + 1 + // + LongJump (&mResetJumpBuffer, ResetType + 1); + } +} + +EFI_PEI_RESET2_PPI mEmuReset2Ppi =3D { + WinReset +}; + /*++ =20 Routine Description: @@ -388,6 +435,7 @@ Returns: UINTN ProcessAffinityMask; UINTN SystemAffinityMask; INT32 LowBit; + UINTN ResetJumpCode; =20 // // Enable the privilege so that RTC driver can successfully run SetTime() @@ -430,6 +478,7 @@ Returns: // PPIs pased into PEI_CORE // AddThunkPpi (EFI_PEI_PPI_DESCRIPTOR_PPI, &gEmuThunkPpiGuid, &mSecEmuThun= kPpi); + AddThunkPpi (EFI_PEI_PPI_DESCRIPTOR_PPI, &gEfiPeiReset2PpiGuid, &mEmuRes= et2Ppi); =20 // // Emulator Bus Driver Thunks @@ -500,14 +549,6 @@ Returns: exit (1); } =20 - SetMem32 (TemporaryRam, TemporaryRamSize, PcdGet32 (PcdInitValueInTempSt= ack)); - - SecPrint ( - " OS Emulator passing in %u KB of temp RAM at 0x%08lx to SEC\n\r", - TemporaryRamSize / SIZE_1KB, - TemporaryRam - ); - // // If enabled use the magic page to communicate between modules // This replaces the PI PeiServicesTable pointer mechanism that @@ -591,6 +632,24 @@ Returns: SecPrint ("\n\r"); } =20 + ResetJumpCode =3D SetJump (&mResetJumpBuffer); + + // + // Do not clear memory content for warm reset. + // + if (ResetJumpCode !=3D EfiResetWarm + 1) { + SecPrint (" OS Emulator clearing temp RAM and physical RAM (to be dis= covered later)......\n\r"); + SetMem32 (TemporaryRam, TemporaryRamSize, PcdGet32 (PcdInitValueInTemp= Stack)); + for (Index =3D 0; Index < gSystemMemoryCount; Index++) { + SetMem32 ((VOID *)(UINTN)gSystemMemory[Index].Memory, gSystemMemory[= Index].Size, PcdGet32 (PcdInitValueInTempStack)); + } + } + + SecPrint ( + " OS Emulator passing in %u KB of temp RAM at 0x%08lx to SEC\n\r", + TemporaryRamSize / SIZE_1KB, + TemporaryRam + ); // // Hand off to SEC Core // diff --git a/EmulatorPkg/Win/Host/WinHost.h b/EmulatorPkg/Win/Host/WinHost.h index 49d42d1ad8..a9a21007e3 100644 --- a/EmulatorPkg/Win/Host/WinHost.h +++ b/EmulatorPkg/Win/Host/WinHost.h @@ -1,6 +1,6 @@ /**@file =20 -Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
(C) Copyright 2020 Hewlett Packard Enterprise Development LP
SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -26,6 +26,7 @@ Abstract: #include #include #include +#include #include #include =20 diff --git a/EmulatorPkg/Win/Host/WinHost.inf b/EmulatorPkg/Win/Host/WinHos= t.inf index 2030ac0847..b61901fae2 100644 --- a/EmulatorPkg/Win/Host/WinHost.inf +++ b/EmulatorPkg/Win/Host/WinHost.inf @@ -2,7 +2,7 @@ # Entry Point of Win Emulator # # Main executable file of Win Emulator that loads Sec core after initializ= ation finished. -# Copyright (c) 2008 - 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2008 - 2022, Intel Corporation. All rights reserved.
# Portions copyright (c) 2008 - 2011, Apple Inc. All rights reserved.
# (C) Copyright 2020 Hewlett Packard Enterprise Development LP
# @@ -58,6 +58,7 @@ =20 [Ppis] gEmuThunkPpiGuid + gEfiPeiReset2PpiGuid =20 [Protocols] gEmuIoThunkProtocolGuid --=20 2.37.2.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#96321): https://edk2.groups.io/g/devel/message/96321 Mute This Topic: https://groups.io/mt/94974521/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-