From 09fc7dbb9498cc7d56a7427fcacb4e77b47e87e5 Mon Sep 17 00:00:00 2001 From: Star Zeng Date: Wed, 12 Nov 2014 03:30:11 +0000 Subject: EdkCompatibilityPkg: Add UEFI memory and SMRAM profile support. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng Reviewed-by: Jiewen Yao git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16336 6f19259b-4bc3-4df7-8a09-765794883524 --- .../BootScriptSaveOnS3SaveStateThunk.inf | 9 +++- .../BootScriptSaveOnS3SaveStateThunk/ScriptSave.c | 51 +++++++++++++++++++++- .../BootScriptSaveOnS3SaveStateThunk/ScriptSave.h | 6 ++- 3 files changed, 63 insertions(+), 3 deletions(-) (limited to 'EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk') diff --git a/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/BootScriptSaveOnS3SaveStateThunk.inf b/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/BootScriptSaveOnS3SaveStateThunk.inf index e449308d44..def1ff0beb 100644 --- a/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/BootScriptSaveOnS3SaveStateThunk.inf +++ b/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/BootScriptSaveOnS3SaveStateThunk.inf @@ -4,7 +4,7 @@ # Intel's Framework Boot Script Save Protocol is replaced by S3 Save State Protocol in PI. # This module produces Framework Boot Script Save protocol by consuming PI S3 Save State protocol # -# Copyright (c) 2010, Intel Corporation. All rights reserved.
+# Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -62,13 +62,20 @@ PcdLib DxeServicesLib CacheMaintenanceLib + BaseMemoryLib + DevicePathLib + UefiLib [Protocols] gEfiBootScriptSaveProtocolGuid ## PRODUCES gEfiS3SaveStateProtocolGuid ## CONSUMES +[Guids] + gEdkiiMemoryProfileGuid + [Pcd] gEfiEdkCompatibilityPkgTokenSpaceGuid.BootScriptThunkDataPtr + gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfilePropertyMask [Depex] gEfiS3SaveStateProtocolGuid diff --git a/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/ScriptSave.c b/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/ScriptSave.c index 84881ea6f5..4d1013caf0 100644 --- a/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/ScriptSave.c +++ b/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/ScriptSave.c @@ -2,7 +2,7 @@ Implementation for S3 Boot Script Save thunk driver. This thunk driver consumes PI S3SaveState protocol to produce framework S3BootScriptSave Protocol - Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.
+ Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -791,6 +791,47 @@ BootScriptCloseTable ( return EFI_UNSUPPORTED; } +/** + Register image to memory profile. + + @param FileName File name of the image. + @param ImageBase Image base address. + @param ImageSize Image size. + @param FileType File type of the image. + +**/ +VOID +RegisterMemoryProfileImage ( + IN EFI_GUID *FileName, + IN PHYSICAL_ADDRESS ImageBase, + IN UINT64 ImageSize, + IN EFI_FV_FILETYPE FileType + ) +{ + EFI_STATUS Status; + EDKII_MEMORY_PROFILE_PROTOCOL *ProfileProtocol; + MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FilePath; + UINT8 TempBuffer[sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH) + sizeof (EFI_DEVICE_PATH_PROTOCOL)]; + + if ((PcdGet8 (PcdMemoryProfilePropertyMask) & BIT0) != 0) { + + FilePath = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)TempBuffer; + Status = gBS->LocateProtocol (&gEdkiiMemoryProfileGuid, NULL, (VOID **) &ProfileProtocol); + if (!EFI_ERROR (Status)) { + EfiInitializeFwVolDevicepathNode (FilePath, FileName); + SetDevicePathEndNode (FilePath + 1); + + Status = ProfileProtocol->RegisterImage ( + ProfileProtocol, + (EFI_DEVICE_PATH_PROTOCOL *) FilePath, + ImageBase, + ImageSize, + FileType + ); + } + } +} + /** This routine is entry point of ScriptSave driver. @@ -893,6 +934,14 @@ InitializeScriptSaveOnS3SaveState ( // Flush the instruction cache so the image data is written before we execute it // InvalidateInstructionCacheRange ((VOID *)(UINTN)ImageContext.ImageAddress, (UINTN)ImageContext.ImageSize); + + RegisterMemoryProfileImage ( + &gEfiCallerIdGuid, + ImageContext.ImageAddress, + ImageContext.ImageSize, + EFI_FV_FILETYPE_DRIVER + ); + Status = ((EFI_IMAGE_ENTRY_POINT)(UINTN)(ImageContext.EntryPoint)) (NewImageHandle, SystemTable); ASSERT_EFI_ERROR (Status); diff --git a/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/ScriptSave.h b/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/ScriptSave.h index b98e83a214..cac7b0b85c 100644 --- a/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/ScriptSave.h +++ b/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/ScriptSave.h @@ -1,7 +1,7 @@ /** @file Header file for S3 Boot Script Saver thunk driver. - Copyright (c) 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -28,8 +28,12 @@ #include #include #include +#include +#include +#include #include +#include #include -- cgit v1.2.3