From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) by mx.groups.io with SMTP id smtpd.web11.1284.1663002827717951297 for ; Mon, 12 Sep 2022 10:13:47 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ceP2330Z; spf=pass (domain: gmail.com, ip: 209.85.222.173, mailfrom: benjamin.doron00@gmail.com) Received: by mail-qk1-f173.google.com with SMTP id d15so6510050qka.9 for ; Mon, 12 Sep 2022 10:13:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=lotXRgOum/GZuBIjExk+LO4/6IsHiSP+N1A9FEqbYhM=; b=ceP2330Zx88lmmRftaTZfqr4otXKzC5obC5ushVPfQsshMLSCDU7OA79f6YZNJCUqs oghzpo8ho405Xm9lLMf4E2MSKy60ZeR5l3rfRedQThhtkf0DXUN4k02LheU4jBPuly+v f4BKqwPJ07xCjFO/7vAFnjIZYcLJo8RwkLLNFxvgamS2vxKu78irQ6F9T3bbLG+NGnUv qVVHfWl6JJi9ahk9BRkjZ4DyeEungbeXrb3weX/YrRnFi9olcQ6Eyj4mMYQxi/sT09BP E6V4LOBAVc7z+W5CXoni7BqcW4Qa5/3LGTZFbLuFz9WrqKiAusPU3GSZM6+7HlVEQSac lnkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=lotXRgOum/GZuBIjExk+LO4/6IsHiSP+N1A9FEqbYhM=; b=D2wN+9IYDzERb2kQ5/IjSzrYf3H9XLpx6EQnm2HiQxQkmousKwqaEBpwL4WV+GUqFH j2zoouIXhKuXPw/x8nL/fHwolU6llBRP857fjQ1Gu79kv/xhOEXQidH2gwtUtJNn/r01 BeyJAs72NhSl+5q4Kp49lebPKqClhBuFX2RroXCf+we5artyNxtOnr4FLCB9PWsPlObD pOFekJfUornWG0iRlP48TF0pPHjPpvEi/dzr9EIEoEZvpMX/EX6RATVhB4a2UaloH6up 3CmG7NyWqiPyP3wHUBQHJJRJYUDoXoUroeN1kqwm7wasOvErLlQ6g7vRlVbxZr8mjMdf oqnA== X-Gm-Message-State: ACgBeo19MlUyuQEgP7xb2JgqT9R975bWhZ/2J5kTHsyLGzQ9/BA77wlI bTrQE1QJ3C649SXHMdFSkbleCYYkvWI= X-Google-Smtp-Source: AA6agR68lDeClu3mazkDyVRk6FWUl0QW559Xr6wvEap8G5YypeQcxnNVnIjQcOj45b2OGuCLQZ+RHA== X-Received: by 2002:a05:620a:15a1:b0:6cc:f925:7c89 with SMTP id f1-20020a05620a15a100b006ccf9257c89mr11487462qkk.319.1663002826619; Mon, 12 Sep 2022 10:13:46 -0700 (PDT) Return-Path: Received: from aturtleortwo-benjamindomain.. ([2607:f2c0:e98c:e:579e:d875:fc8f:d092]) by smtp.gmail.com with ESMTPSA id s5-20020ac87585000000b00346414a0ca1sm6863540qtq.1.2022.09.12.10.13.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 10:13:46 -0700 (PDT) From: "Benjamin Doron" To: devel@edk2.groups.io Cc: Chasel Chiu , Nate DeSimone , Ankit Sinha , Isaac Oram , Liming Gao , Eric Dong Subject: [edk2-platforms][PATCH v3 3/4] MinPlatformPkg: Implement working S3 resume Date: Mon, 12 Sep 2022 13:12:49 -0400 Message-Id: <20220912171250.1515536-4-benjamin.doron00@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220912171250.1515536-1-benjamin.doron00@gmail.com> References: <20220912171250.1515536-1-benjamin.doron00@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Consume S3 resume memory allocation on resume flow. Also, include complementary FirmwarePerformanceDataTablePei module in MinPlatform FV for S3 resume performance measurement. Cc: Chasel Chiu Cc: Nate DeSimone Cc: Ankit Sinha Cc: Isaac Oram Cc: Liming Gao Cc: Eric Dong Signed-off-by: Benjamin Doron --- .../FspWrapperHobProcessLib.c | 69 ++++++++++++++++++- .../PeiFspWrapperHobProcessLib.inf | 2 + .../Include/Dsc/CorePeiInclude.dsc | 2 + .../Include/Fdf/CorePostMemoryInclude.fdf | 4 ++ 4 files changed, 76 insertions(+), 1 deletion(-) diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/PeiFspWrapper= HobProcessLib/FspWrapperHobProcessLib.c b/Platform/Intel/MinPlatformPkg/Fsp= Wrapper/Library/PeiFspWrapperHobProcessLib/FspWrapperHobProcessLib.c index 7ee4d3a31c49..9bd6fe6290c5 100644 --- a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/PeiFspWrapperHobProc= essLib/FspWrapperHobProcessLib.c +++ b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/PeiFspWrapperHobProc= essLib/FspWrapperHobProcessLib.c @@ -16,14 +16,17 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include =0D #include =0D #include =0D +#include =0D #include =0D #include =0D #include =0D #include =0D #include =0D #include =0D +#include =0D =0D #include =0D +#include =0D =0D //=0D // Additional pages are used by DXE memory manager.=0D @@ -130,6 +133,55 @@ GetPeiMemSize ( return MinSize + Size + PEI_ADDITIONAL_MEMORY_SIZE;=0D }=0D =0D +/**=0D + Get S3 PEI memory information.=0D +=0D + @note At this point, memory is ready, and PeiServices are available to u= se.=0D + Platform can get some data from SMRAM directly.=0D +=0D + @param[out] S3PeiMemSize PEI memory size to be installed in S3 phase.=0D + @param[out] S3PeiMemBase PEI memory base to be installed in S3 phase.=0D +=0D + @return If S3 PEI memory information is got successfully.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +GetS3MemoryInfo (=0D + OUT UINT64 *S3PeiMemSize,=0D + OUT EFI_PHYSICAL_ADDRESS *S3PeiMemBase=0D + )=0D +{=0D + EFI_STATUS Status;=0D + EFI_PEI_READ_ONLY_VARIABLE2_PPI *VariablePpi;=0D + UINTN DataSize;=0D + ACPI_S3_MEMORY S3MemoryInfo;=0D +=0D + *S3PeiMemBase =3D 0;=0D + *S3PeiMemSize =3D 0;=0D +=0D + Status =3D PeiServicesLocatePpi (&gEfiPeiReadOnlyVariable2PpiGuid, 0, NU= LL, (VOID **) &VariablePpi);=0D + ASSERT_EFI_ERROR (Status);=0D +=0D + DataSize =3D sizeof (S3MemoryInfo);=0D + Status =3D VariablePpi->GetVariable (=0D + VariablePpi,=0D + ACPI_S3_MEMORY_NV_NAME,=0D + &gEfiAcpiVariableGuid,=0D + NULL,=0D + &DataSize,=0D + &S3MemoryInfo=0D + );=0D + ASSERT_EFI_ERROR (Status);=0D +=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + *S3PeiMemBase =3D S3MemoryInfo.S3PeiMemBase;=0D + *S3PeiMemSize =3D S3MemoryInfo.S3PeiMemSize;=0D + return EFI_SUCCESS;=0D +}=0D +=0D /**=0D Post FSP-M HOB process for Memory Resource Descriptor.=0D =0D @@ -280,7 +332,7 @@ PostFspmHobProcess ( 0x1000=0D );=0D =0D -=0D + if (BootMode !=3D BOOT_ON_S3_RESUME) {=0D //=0D // Capsule mode=0D //=0D @@ -337,7 +389,22 @@ PostFspmHobProcess ( if (Capsule !=3D NULL) {=0D Status =3D Capsule->CreateState ((EFI_PEI_SERVICES **)PeiServices, C= apsuleBuffer, CapsuleBufferLength);=0D }=0D + } else {=0D + Status =3D GetS3MemoryInfo (&PeiMemSize, &PeiMemBase);=0D + ASSERT_EFI_ERROR (Status);=0D =0D + DEBUG ((DEBUG_INFO, "S3 resume PeiMemBase : 0x%08x\n", PeiMemBa= se));=0D + DEBUG ((DEBUG_INFO, "S3 resume PeiMemSize : 0x%08x\n", PeiMemSi= ze));=0D +=0D + //=0D + // Install efi memory=0D + //=0D + Status =3D PeiServicesInstallPeiMemory (=0D + PeiMemBase,=0D + PeiMemSize=0D + );=0D + ASSERT_EFI_ERROR (Status);=0D + }=0D =0D //=0D // Create a memory allocation HOB at fixed location for MP Services PPI = AP wait loop.=0D diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/PeiFspWrapper= HobProcessLib/PeiFspWrapperHobProcessLib.inf b/Platform/Intel/MinPlatformPk= g/FspWrapper/Library/PeiFspWrapperHobProcessLib/PeiFspWrapperHobProcessLib.= inf index b846e7af1d2d..e2aac36bf018 100644 --- a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/PeiFspWrapperHobProc= essLib/PeiFspWrapperHobProcessLib.inf +++ b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/PeiFspWrapperHobProc= essLib/PeiFspWrapperHobProcessLib.inf @@ -75,7 +75,9 @@ gZeroGuid=0D gEfiGraphicsInfoHobGuid=0D gEfiGraphicsDeviceInfoHobGuid=0D + gEfiAcpiVariableGuid=0D =0D [Ppis]=0D gEfiPeiCapsulePpiGuid ## CONSUMES=0D + gEfiPeiReadOnlyVariable2PpiGuid ## CONSUMES=0D gEdkiiSiliconInitializedPpiGuid ## PRODUCES=0D diff --git a/Platform/Intel/MinPlatformPkg/Include/Dsc/CorePeiInclude.dsc b= /Platform/Intel/MinPlatformPkg/Include/Dsc/CorePeiInclude.dsc index 08e50cac075f..f271fb26b189 100644 --- a/Platform/Intel/MinPlatformPkg/Include/Dsc/CorePeiInclude.dsc +++ b/Platform/Intel/MinPlatformPkg/Include/Dsc/CorePeiInclude.dsc @@ -41,3 +41,5 @@ NULL|SecurityPkg/Library/HashInstanceLibSha256/HashInstanceLibSha256= .inf=0D }=0D !endif=0D +=0D + MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerf= ormancePei.inf=0D diff --git a/Platform/Intel/MinPlatformPkg/Include/Fdf/CorePostMemoryInclud= e.fdf b/Platform/Intel/MinPlatformPkg/Include/Fdf/CorePostMemoryInclude.fdf index 3c2716d6728a..3edc239e5264 100644 --- a/Platform/Intel/MinPlatformPkg/Include/Fdf/CorePostMemoryInclude.fdf +++ b/Platform/Intel/MinPlatformPkg/Include/Fdf/CorePostMemoryInclude.fdf @@ -6,3 +6,7 @@ # SPDX-License-Identifier: BSD-2-Clause-Patent=0D #=0D ##=0D +=0D +!if gMinPlatformPkgTokenSpaceGuid.PcdBootToShellOnly =3D=3D FALSE=0D + INF MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/Firmwar= ePerformancePei.inf=0D +!endif=0D --=20 2.37.2