+++ /dev/null
-/** @file\r
-This is the driver that locates the MemoryConfigurationData HOB, if it\r
-exists, and saves the data to nvRAM.\r
-\r
-Copyright (c) 2013-2015 Intel Corporation.\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/HobLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-\r
-#include <Guid/MemoryConfigData.h>\r
-#include <Guid/DebugMask.h>\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-SaveMemoryConfigEntryPoint (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- )\r
-/*++\r
-\r
- Routine Description:\r
- This is the standard EFI driver point that detects whether there is a\r
- MemoryConfigurationData HOB and, if so, saves its data to nvRAM.\r
-\r
- Arguments:\r
- ImageHandle - Handle for the image of this driver\r
- SystemTable - Pointer to the EFI System Table\r
-\r
- Returns:\r
- EFI_SUCCESS - if the data is successfully saved or there was no data\r
- EFI_NOT_FOUND - if the HOB list could not be located.\r
- EFI_UNLOAD_IMAGE - It is not success\r
-\r
---*/\r
-{\r
- EFI_STATUS Status;\r
- VOID *HobList;\r
- EFI_HOB_GUID_TYPE *GuidHob;\r
- VOID *HobData;\r
- VOID *VariableData;\r
- UINTN DataSize;\r
- UINTN BufferSize;\r
-\r
- DataSize = 0;\r
- VariableData = NULL;\r
- GuidHob = NULL;\r
- HobList = NULL;\r
- HobData = NULL;\r
- Status = EFI_UNSUPPORTED;\r
-\r
- //\r
- // Get the HOB list. If it is not present, then ASSERT.\r
- //\r
- HobList = GetHobList ();\r
- ASSERT (HobList != NULL);\r
-\r
- //\r
- // Search for the Memory Configuration GUID HOB. If it is not present, then\r
- // there's nothing we can do. It may not exist on the update path.\r
- //\r
- GuidHob = GetNextGuidHob (&gEfiMemoryConfigDataGuid, HobList);\r
- if (GuidHob != NULL) {\r
- HobData = GET_GUID_HOB_DATA (GuidHob);\r
- DataSize = GET_GUID_HOB_DATA_SIZE (GuidHob);\r
- //\r
- // Use the HOB to save Memory Configuration Data\r
- //\r
- BufferSize = DataSize;\r
- VariableData = AllocatePool (BufferSize);\r
- ASSERT (VariableData != NULL);\r
- Status = gRT->GetVariable (\r
- EFI_MEMORY_CONFIG_DATA_NAME,\r
- &gEfiMemoryConfigDataGuid,\r
- NULL,\r
- &BufferSize,\r
- VariableData\r
- );\r
- if (Status == EFI_BUFFER_TOO_SMALL) {\r
- gBS->FreePool (VariableData);\r
- VariableData = AllocatePool (BufferSize);\r
- ASSERT (VariableData != NULL);\r
- Status = gRT->GetVariable (\r
- EFI_MEMORY_CONFIG_DATA_NAME,\r
- &gEfiMemoryConfigDataGuid,\r
- NULL,\r
- &BufferSize,\r
- VariableData\r
- );\r
- }\r
-\r
- if (EFI_ERROR(Status) || BufferSize != DataSize || CompareMem (HobData, VariableData, DataSize) != 0) {\r
- Status = gRT->SetVariable (\r
- EFI_MEMORY_CONFIG_DATA_NAME,\r
- &gEfiMemoryConfigDataGuid,\r
- (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS),\r
- DataSize,\r
- HobData\r
- );\r
- ASSERT((Status == EFI_SUCCESS) || (Status == EFI_OUT_OF_RESOURCES));\r
- }\r
-\r
- gBS->FreePool (VariableData);\r
- }\r
-\r
- //\r
- // This driver does not produce any protocol services, so always unload it.\r
- //\r
- return Status;\r
-}\r