summaryrefslogtreecommitdiff
path: root/Vlv2TbltDevicePkg/SaveMemoryConfig
diff options
context:
space:
mode:
authorDavid Wei <david.wei@intel.com>2015-01-12 09:37:20 +0000
committerzwei4 <zwei4@Edk2>2015-01-12 09:37:20 +0000
commit3cbfba02fef9dae07a041fdbf2e89611d72d6f90 (patch)
tree0b3bf0783124d38a191e09736492c0141aa36c15 /Vlv2TbltDevicePkg/SaveMemoryConfig
parent6f785cfcc304c48ec04e542ee429df95e7b51bc5 (diff)
downloadedk2-platforms-3cbfba02fef9dae07a041fdbf2e89611d72d6f90.tar.xz
Upload BSD-licensed Vlv2TbltDevicePkg and Vlv2DeviceRefCodePkg to
https://svn.code.sf.net/p/edk2/code/trunk/edk2/, which are for MinnowBoard MAX open source project. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: David Wei <david.wei@intel.com> Reviewed-by: Mike Wu <mike.wu@intel.com> Reviewed-by: Hot Tian <hot.tian@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16599 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Vlv2TbltDevicePkg/SaveMemoryConfig')
-rw-r--r--Vlv2TbltDevicePkg/SaveMemoryConfig/SaveMemoryConfig.c187
-rw-r--r--Vlv2TbltDevicePkg/SaveMemoryConfig/SaveMemoryConfig.h72
-rw-r--r--Vlv2TbltDevicePkg/SaveMemoryConfig/SaveMemoryConfig.inf66
3 files changed, 325 insertions, 0 deletions
diff --git a/Vlv2TbltDevicePkg/SaveMemoryConfig/SaveMemoryConfig.c b/Vlv2TbltDevicePkg/SaveMemoryConfig/SaveMemoryConfig.c
new file mode 100644
index 0000000000..dd3e5dc656
--- /dev/null
+++ b/Vlv2TbltDevicePkg/SaveMemoryConfig/SaveMemoryConfig.c
@@ -0,0 +1,187 @@
+/**
+ Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
+ 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
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SaveMemoryConfig.c
+
+Abstract:
+ This is the driver that locates the MemoryConfigurationData HOB, if it
+ exists, and saves the data to nvRAM.
+
+
+
+--*/
+
+#include "SaveMemoryConfig.h"
+
+CHAR16 EfiMemoryConfigVariable[] = L"MemoryConfig";
+
+
+EFI_STATUS
+EFIAPI
+SaveMemoryConfigEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+ Routine Description:
+ This is the standard EFI driver point that detects whether there is a
+ MemoryConfigurationData HOB and, if so, saves its data to nvRAM.
+
+ Arguments:
+ ImageHandle - Handle for the image of this driver
+ SystemTable - Pointer to the EFI System Table
+
+ Returns:
+ EFI_SUCCESS - if the data is successfully saved or there was no data
+ EFI_NOT_FOUND - if the HOB list could not be located.
+ EFI_UNLOAD_IMAGE - It is not success
+
+--*/
+{
+ EFI_STATUS Status=EFI_SUCCESS;
+ VOID *MemHobData;
+ VOID *VariableData;
+ UINTN BufferSize;
+ BOOLEAN MfgMode;
+ EFI_PLATFORM_SETUP_ID *BootModeBuffer;
+ EFI_PLATFORM_INFO_HOB *PlatformInfoHobPtr;
+ MEM_INFO_PROTOCOL *MemInfoProtocol;
+ EFI_HANDLE Handle;
+ UINT8 Channel, Slot;
+ VOID *GuidHob;
+
+ VariableData = NULL;
+ MfgMode = FALSE;
+ Handle = NULL;
+ BootModeBuffer = NULL;
+ MemHobData = NULL;
+ PlatformInfoHobPtr = NULL;
+ BufferSize = 0;
+
+ //
+ // Get Platform Info HOB
+ //
+ GuidHob = GetFirstGuidHob (&gEfiPlatformInfoGuid);
+ if (GuidHob == NULL) {
+ Status = EFI_NOT_FOUND;
+ }
+ ASSERT_EFI_ERROR (Status);
+
+ PlatformInfoHobPtr = GET_GUID_HOB_DATA (GuidHob);
+
+ //
+ // Get the BootMode guid hob
+ //
+ GuidHob = GetFirstGuidHob (&gEfiPlatformBootModeGuid);
+ if (GuidHob == NULL) {
+ Status = EFI_NOT_FOUND;
+ }
+ ASSERT_EFI_ERROR (Status);
+
+ BootModeBuffer = GET_GUID_HOB_DATA (GuidHob);
+
+
+ //
+ // Check whether in Manufacturing Mode
+ //
+ if (BootModeBuffer) {
+ if ( !CompareMem ( //EfiCompareMem
+ &BootModeBuffer->SetupName,
+ MANUFACTURE_SETUP_NAME,
+ StrSize (MANUFACTURE_SETUP_NAME) //EfiStrSize
+ ) ) {
+ MfgMode = TRUE;
+ }
+ }
+
+ if (MfgMode) {
+ //
+ // Don't save Memory Configuration in Manufacturing Mode. Clear memory configuration.
+ //
+ Status = gRT->SetVariable (
+ EfiMemoryConfigVariable,
+ &gEfiVlv2VariableGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ 0,
+ NULL
+ );
+ } else {
+
+ MemInfoProtocol = (MEM_INFO_PROTOCOL*)AllocateZeroPool(sizeof(MEM_INFO_PROTOCOL));
+ if (PlatformInfoHobPtr != NULL) {
+ MemInfoProtocol->MemInfoData.memSize = 0;
+ for (Channel = 0; Channel < CH_NUM; Channel ++){
+ for (Slot = 0; Slot < DIMM_NUM; Slot ++){
+ MemInfoProtocol->MemInfoData.dimmSize[Slot + (Channel * DIMM_NUM)] = PlatformInfoHobPtr->MemData.DimmSize[Slot];
+ }
+ }
+ MemInfoProtocol->MemInfoData.memSize = PlatformInfoHobPtr->MemData.MemSize;
+ MemInfoProtocol->MemInfoData.EccSupport = PlatformInfoHobPtr->MemData.EccSupport;
+ MemInfoProtocol->MemInfoData.ddrFreq = PlatformInfoHobPtr->MemData.DdrFreq;
+ MemInfoProtocol->MemInfoData.ddrType = PlatformInfoHobPtr->MemData.DdrType;
+ if (MemInfoProtocol->MemInfoData.memSize == 0){
+ //
+ // We hardcode if MRC didn't fill these info in
+ //
+ MemInfoProtocol->MemInfoData.memSize = 0x800; //per 1MB
+ MemInfoProtocol->MemInfoData.dimmSize[0] = 0x800;
+ MemInfoProtocol->MemInfoData.dimmSize[1] = 0;
+ MemInfoProtocol->MemInfoData.EccSupport = FALSE;
+ MemInfoProtocol->MemInfoData.ddrType = 5; //DDRType_LPDDR3
+ }
+
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &Handle,
+ &gMemInfoProtocolGuid,
+ MemInfoProtocol,
+ NULL
+ );
+ }
+
+ Status = EFI_SUCCESS;
+ if (BOOT_WITH_MINIMAL_CONFIGURATION != GetBootModeHob()){
+ //
+ // Get the Memory Config guid hob
+ //
+ GuidHob = GetFirstGuidHob (&gEfiMemoryConfigDataGuid);
+ if (GuidHob == NULL) {
+ Status = EFI_NOT_FOUND;
+ }
+ ASSERT_EFI_ERROR (Status);
+
+ MemHobData = GET_GUID_HOB_DATA (GuidHob);
+ BufferSize = GET_GUID_HOB_DATA_SIZE (GuidHob);
+
+ Status = gRT->GetVariable (
+ EfiMemoryConfigVariable,
+ &gEfiVlv2VariableGuid,
+ NULL,
+ &BufferSize,
+ VariableData
+ );
+ if (EFI_ERROR(Status) && (MemHobData != NULL)) {
+ Status = gRT->SetVariable (
+ EfiMemoryConfigVariable,
+ &gEfiVlv2VariableGuid,
+ (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS),
+ BufferSize,
+ MemHobData
+ );
+ }
+ }
+
+ } // if-else MfgMode
+
+ return EFI_SUCCESS;
+}
diff --git a/Vlv2TbltDevicePkg/SaveMemoryConfig/SaveMemoryConfig.h b/Vlv2TbltDevicePkg/SaveMemoryConfig/SaveMemoryConfig.h
new file mode 100644
index 0000000000..80e7376e44
--- /dev/null
+++ b/Vlv2TbltDevicePkg/SaveMemoryConfig/SaveMemoryConfig.h
@@ -0,0 +1,72 @@
+/**
+ Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
+ 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
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SaveMemoryConfig.h
+
+Abstract:
+
+ Header file for Save Previous Memory Configuration Driver.
+
+
+
+--*/
+
+
+#ifndef _SAVE_MEMORY_CONFIG_DRIVER_H
+#define _SAVE_MEMORY_CONFIG_DRIVER_H
+
+#include "Protocol/SetupMode.h"
+#include "Guid/PlatformInfo.h"
+#include "Library/HobLib.h"
+#include "Library/DebugLib.h"
+#include "Library/UefiBootServicesTableLib.h"
+#include "Library/BaseMemoryLib.h"
+#include "PlatformBootMode.h"
+#include "Library/BaseLib.h"
+#include "Library/UefiRuntimeServicesTableLib.h"
+#include "Guid/GlobalVariable.h"
+#include "Library/UefiLib.h"
+#include "Guid/HobList.h"
+#include "Guid/MemoryConfigData.h"
+#include "Protocol/MemInfo.h"
+#include "Library/MemoryAllocationLib.h"
+#include <Guid/Vlv2Variable.h>
+
+//
+// Prototypes
+//
+EFI_STATUS
+EFIAPI
+SaveMemoryConfigEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+ Routine Description:
+ This is the standard EFI driver point that detects whether there is a
+ MemoryConfigurationData HOB and, if so, saves its data to nvRAM.
+
+ Arguments:
+ ImageHandle - Handle for the image of this driver
+ SystemTable - Pointer to the EFI System Table
+
+ Returns:
+ EFI_SUCCESS - if the data is successfully saved or there was no data
+ EFI_NOT_FOUND - if the HOB list could not be located.
+ EFI_UNLOAD_IMAGE - It is not success
+
+--*/
+;
+
+#endif
diff --git a/Vlv2TbltDevicePkg/SaveMemoryConfig/SaveMemoryConfig.inf b/Vlv2TbltDevicePkg/SaveMemoryConfig/SaveMemoryConfig.inf
new file mode 100644
index 0000000000..bea0ca7acc
--- /dev/null
+++ b/Vlv2TbltDevicePkg/SaveMemoryConfig/SaveMemoryConfig.inf
@@ -0,0 +1,66 @@
+#/*++
+#
+# Copyright (c) 1999 - 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 that accompanies this distribution.
+# The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php.
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#
+#
+#
+# Module Name:
+#
+# SaveMemoryConfig.inf
+#
+# Abstract:
+#
+#
+--*/
+
+[defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = SaveMemoryConfig
+ FILE_GUID = E0ECBEC9-B193-4351-A488-36A655F22F9F
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = SaveMemoryConfigEntryPoint
+
+[sources.common]
+ SaveMemoryConfig.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ Vlv2TbltDevicePkg/PlatformPkg.dec
+ Vlv2DeviceRefCodePkg/Vlv2DeviceRefCodePkg.dec
+
+[LibraryClasses]
+ UefiDriverEntryPoint
+ UefiBootServicesTableLib
+ HobLib
+ DebugLib
+ UefiRuntimeServicesTableLib
+ UefiLib
+ BaseLib
+
+[Protocols]
+ gMemInfoProtocolGuid
+
+[Guids]
+ gEfiMemoryConfigDataGuid
+ gEfiPlatformInfoGuid
+ gEfiPlatformBootModeGuid
+ gEfiVlv2VariableGuid
+ #gEfiHobListGuid
+ #gEfiPlatformInfoGuid
+ #gEfiPlatformBootModeGuid
+ #gEfiGlobalVariableGuid
+ #gEfiMemoryConfigDataGuid
+
+[Depex]
+ gEfiVariableArchProtocolGuid AND
+ gEfiVariableWriteArchProtocolGuid