From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) by mx.groups.io with SMTP id smtpd.web08.1836.1662483770425426824 for ; Tue, 06 Sep 2022 10:02:50 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=doU/2OW/; spf=pass (domain: gmail.com, ip: 209.85.222.181, mailfrom: benjamin.doron00@gmail.com) Received: by mail-qk1-f181.google.com with SMTP id f4so8636471qkl.7 for ; Tue, 06 Sep 2022 10:02:50 -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=gL/zaok4cmW+GzR0LXux+Cu1KQmB8VUouyZWezHjsos=; b=doU/2OW/b9cyLV0BrjSb5qB/VM1sC9hSHdc/79eKDqfOgIfkuF0pKJw1iUGdTPuxeW 9BjhqpTCBVGu9Qm5OgZ1tujp6Zek9I+PhoxGiHXWhD5Sthc4s1x+xxwTA1lkfMERESeo m2BRTNXrIW++9bjQzvZWR3DfaTlu7AL2ZkmOMzxh0Yt3mb0EPqzaQFAgJl1Tp2EY/S70 WcrtiPlqV328XO4XSqeGfz/GFfyFaCpEzjy4y0YMj74h2MWNQvqAplMvQ8ivaNKIL8ik qbIG9O7utVh7kW7uH0hpycMYznMJSQYdflxCP2zt5Oxr7ikQCMQNcZyUaIhx5efqVuYz lYuw== 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=gL/zaok4cmW+GzR0LXux+Cu1KQmB8VUouyZWezHjsos=; b=WtLflGFT2mfKAgCRJXENPIYlfI2G8QabXPfnrlKzyzDeFQnzp2kCOfUxJcEWNzt8sy Oc5JZZITi84NFqviOghWRas1XTp0OvZQPS/kBQDt+kLtSOiAGPX/ZSgDbWk5S7vN0c00 C9hqi1GAFcMiHLZVqW4eAwrhDbqbTcFBo7fHJGy5maSIWhxygn7FJloU7Ii2llKdmbu0 kfJ9uydGjMuCnK9doA3BssUN2/ehSxwWWlQcoDD1v806T4kFOouhpvZGa5TAMKFHIT7R RRvf8Xk/E1bP3NUbb+EjaahZgNtALMXz5aELAVFijqn0GnS1nMMg31awdjrbP2e1/2b/ 2WCA== X-Gm-Message-State: ACgBeo0YYO0heYkax526l4MoWbRu6V0tSz4WP4SEs4IiMqObaD+bqE5S KD+2zhesWfkOrxl1WExQAubyleaX5umlww== X-Google-Smtp-Source: AA6agR61C5/ZMbXQ23uEr7oT9suAp2x96M2+BQhG76l2xh7wvfTcIJwqH5P9tEpwLe1W50oEOmTxMg== X-Received: by 2002:a05:620a:bc6:b0:6bc:644b:8e94 with SMTP id s6-20020a05620a0bc600b006bc644b8e94mr36147313qki.321.1662483769052; Tue, 06 Sep 2022 10:02:49 -0700 (PDT) Return-Path: Received: from aturtleortwo-benjamindomain.. ([2607:f2c0:e98c:e:46bc:db07:bbf3:df6d]) by smtp.gmail.com with ESMTPSA id bi13-20020a05620a318d00b006b59f02224asm10895809qkb.60.2022.09.06.10.02.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 10:02:48 -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-devel][edk2-platforms][PATCH v2 5/6] MinPlatformPkg: Implement working S3 resume Date: Tue, 6 Sep 2022 13:02:27 -0400 Message-Id: <0e97006ee5e35e8399bd8fe1b463664c301c5644.1662483691.git.benjamin.doron00@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: References: 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 | 2 + 4 files changed, 74 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..160f02650a8c 100644 --- a/Platform/Intel/MinPlatformPkg/Include/Fdf/CorePostMemoryInclude.fdf +++ b/Platform/Intel/MinPlatformPkg/Include/Fdf/CorePostMemoryInclude.fdf @@ -6,3 +6,5 @@ # SPDX-License-Identifier: BSD-2-Clause-Patent=0D #=0D ##=0D +=0D + INF MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/Firmwar= ePerformancePei.inf=0D --=20 2.37.2