${WORKSPACE}/MdeModulePkg/Universal/FirmwareVolume/FaultTolerantWriteLite/Dxe/FtwLite.inf\r
#${WORKSPACE}/MdeModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.inf\r
${WORKSPACE}/MdeModulePkg/Bus/Pci/AtapiPassThru/Dxe/AtapiPassThru.inf\r
- ${WORKSPACE}/MdeModulePkg/Universal/WatchDogTimerDxe/WatchDogTimer.inf
\ No newline at end of file
+ ${WORKSPACE}/MdeModulePkg/Universal/WatchDogTimerDxe/WatchDogTimer.inf\r
+ #${WORKSPACE}/MdeModulePkg/Universal/VariablePei/Variable.inf
\ No newline at end of file
--- /dev/null
+/**@file\r
+ Variable Machine Type\r
+ \r
+Copyright (c) 2006 - 2007 Intel Corporation. <BR>\r
+All rights reserved. This program and the accompanying materials \r
+are licensed and made available under the terms and conditions of the BSD License \r
+which accompanies this distribution. The full text of the license may be found at \r
+http://opensource.org/licenses/bsd-license.php \r
+ \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+**/\r
+\r
+#ifndef _VAR_MACHINE_H\r
+#define _VAR_MACHINE_H\r
+\r
+\r
+#endif\r
--- /dev/null
+/**@file\r
+ Variable Machine Type\r
+\r
+Copyright (c) 2006 - 2007 Intel Corporation. <BR>\r
+All rights reserved. This program and the accompanying materials \r
+are licensed and made available under the terms and conditions of the BSD License \r
+which accompanies this distribution. The full text of the license may be found at \r
+http://opensource.org/licenses/bsd-license.php \r
+ \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+**/\r
+\r
+#ifndef _VAR_MACHINE_H\r
+#define _VAR_MACHINE_H\r
+\r
+\r
+#endif\r
--- /dev/null
+/**@file\r
+ Variable Machine Type\r
+ \r
+Copyright (c) 2006 - 2007 Intel Corporation. <BR>\r
+All rights reserved. This program and the accompanying materials \r
+are licensed and made available under the terms and conditions of the BSD License \r
+which accompanies this distribution. The full text of the license may be found at \r
+http://opensource.org/licenses/bsd-license.php \r
+ \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+**/\r
+\r
+#ifndef _VAR_MACHINE_H\r
+#define _VAR_MACHINE_H\r
+\r
+\r
+#endif\r
--- /dev/null
+/** @file\r
+ Variable worker functions.\r
+\r
+ Copyright (c) 2006, Intel Corporation<BR>\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiPei.h>\r
+\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Ppi/ReadOnlyVariable.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/DebugLib.h>\r
+#include <Library/PeimEntryPoint.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+\r
+#include <Variable.h>\r
+\r
+\r
+/**\r
+ Get one variable by the index count.\r
+\r
+ @param IndexTable The pointer to variable index table.\r
+ @param Count The index count of variable in index table.\r
+\r
+ @return The pointer to variable header indexed by count.\r
+\r
+**/\r
+VARIABLE_HEADER *\r
+GetVariableByIndex (\r
+ IN VARIABLE_INDEX_TABLE *IndexTable,\r
+ IN UINT32 Count\r
+ )\r
+{\r
+ return (VARIABLE_HEADER *) (UINTN) ((((UINT32)IndexTable->Index[Count]) << 2) + ((UINT32)(UINTN)IndexTable->StartPtr & 0xFFFC0000) );\r
+}\r
+\r
+/**\r
+ Record Variable in VariableIndex HOB.\r
+\r
+ Record Variable in VariableIndex HOB and update the length of variable index table.\r
+\r
+ @param IndexTable The pointer to variable index table.\r
+ @param Variable The pointer to the variable that will be recorded.\r
+\r
+ @retval VOID\r
+\r
+**/\r
+VOID\r
+VariableIndexTableUpdate (\r
+ IN OUT VARIABLE_INDEX_TABLE *IndexTable,\r
+ IN VARIABLE_HEADER *Variable\r
+ )\r
+{\r
+ IndexTable->Index[IndexTable->Length++] = (UINT16) (((UINT32)(UINTN) Variable) >> 2);\r
+\r
+ return;\r
+}\r
+\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006 - 2007 Intel Corporation. <BR>\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Module Name:\r
+\r
+ Variable.c\r
+\r
+Abstract:\r
+\r
+ Framework PEIM to provide the Variable functionality\r
+\r
+--*/\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiPei.h>\r
+\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Ppi/ReadOnlyVariable.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/DebugLib.h>\r
+#include <Library/PeimEntryPoint.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+\r
+\r
+#include <Variable.h>\r
+\r
+//\r
+// Module globals\r
+//\r
+static EFI_PEI_READ_ONLY_VARIABLE_PPI mVariablePpi = {\r
+ PeiGetVariable,\r
+ PeiGetNextVariableName\r
+};\r
+\r
+static EFI_PEI_PPI_DESCRIPTOR mPpiListVariable = {\r
+ (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+ &gEfiPeiReadOnlyVariablePpiGuid,\r
+ &mVariablePpi\r
+};\r
+\r
+EFI_GUID mEfiVariableIndexTableGuid = EFI_VARIABLE_INDEX_TABLE_GUID;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeimInitializeVariableServices (\r
+ IN EFI_FFS_FILE_HEADER *FfsHeader,\r
+ IN EFI_PEI_SERVICES **PeiServices\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Provide the functionality of the variable services.\r
+\r
+Arguments:\r
+\r
+ FfsHeadher - The FFS file header\r
+ PeiServices - General purpose services available to every PEIM.\r
+\r
+Returns:\r
+\r
+ Status - EFI_SUCCESS if the interface could be successfully\r
+ installed\r
+\r
+--*/\r
+{\r
+ //\r
+ // Publish the variable capability to other modules\r
+ //\r
+ return (**PeiServices).InstallPpi (PeiServices, &mPpiListVariable);\r
+\r
+}\r
+\r
+STATIC\r
+VARIABLE_HEADER *\r
+GetNextVariablePtr (\r
+ IN VARIABLE_HEADER *Variable\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ This code checks if variable header is valid or not.\r
+\r
+Arguments:\r
+ Variable Pointer to the Variable Header.\r
+\r
+Returns:\r
+ TRUE Variable header is valid.\r
+ FALSE Variable header is not valid.\r
+\r
+--*/\r
+{\r
+ return (VARIABLE_HEADER *) ((UINTN) GET_VARIABLE_DATA_PTR (Variable) + Variable->DataSize + GET_PAD_SIZE (Variable->DataSize));\r
+}\r
+\r
+STATIC\r
+BOOLEAN\r
+EFIAPI\r
+IsValidVariableHeader (\r
+ IN VARIABLE_HEADER *Variable\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ This code checks if variable header is valid or not.\r
+\r
+Arguments:\r
+ Variable Pointer to the Variable Header.\r
+\r
+Returns:\r
+ TRUE Variable header is valid.\r
+ FALSE Variable header is not valid.\r
+\r
+--*/\r
+{\r
+ if (Variable == NULL ||\r
+ Variable->StartId != VARIABLE_DATA ||\r
+ (sizeof (VARIABLE_HEADER) + Variable->DataSize + Variable->NameSize) > MAX_VARIABLE_SIZE\r
+ ) {\r
+ return FALSE;\r
+ }\r
+\r
+ return TRUE;\r
+}\r
+\r
+STATIC\r
+VARIABLE_STORE_STATUS\r
+EFIAPI\r
+GetVariableStoreStatus (\r
+ IN VARIABLE_STORE_HEADER *VarStoreHeader\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ This code gets the pointer to the variable name.\r
+\r
+Arguments:\r
+\r
+ VarStoreHeader Pointer to the Variable Store Header.\r
+\r
+Returns:\r
+\r
+ EfiRaw Variable store is raw\r
+ EfiValid Variable store is valid\r
+ EfiInvalid Variable store is invalid\r
+\r
+--*/\r
+{\r
+ if (VarStoreHeader->Signature == VARIABLE_STORE_SIGNATURE &&\r
+ VarStoreHeader->Format == VARIABLE_STORE_FORMATTED &&\r
+ VarStoreHeader->State == VARIABLE_STORE_HEALTHY\r
+ ) {\r
+\r
+ return EfiValid;\r
+ }\r
+\r
+ if (VarStoreHeader->Signature == 0xffffffff &&\r
+ VarStoreHeader->Size == 0xffffffff &&\r
+ VarStoreHeader->Format == 0xff &&\r
+ VarStoreHeader->State == 0xff\r
+ ) {\r
+\r
+ return EfiRaw;\r
+ } else {\r
+ return EfiInvalid;\r
+ }\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+CompareWithValidVariable (\r
+ IN VARIABLE_HEADER *Variable,\r
+ IN CHAR16 *VariableName,\r
+ IN EFI_GUID *VendorGuid,\r
+ OUT VARIABLE_POINTER_TRACK *PtrTrack\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ This function compares a variable with variable entries in database\r
+\r
+Arguments:\r
+\r
+ Variable - Pointer to the variable in our database\r
+ VariableName - Name of the variable to compare to 'Variable'\r
+ VendorGuid - GUID of the variable to compare to 'Variable'\r
+ PtrTrack - Variable Track Pointer structure that contains\r
+ Variable Information.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - Found match variable\r
+ EFI_NOT_FOUND - Variable not found\r
+\r
+--*/\r
+{\r
+ if (VariableName[0] == 0) {\r
+ PtrTrack->CurrPtr = Variable;\r
+ return EFI_SUCCESS;\r
+ } else {\r
+ //\r
+ // Don't use CompareGuid function here for performance reasons.\r
+ // Instead we compare the GUID a UINT32 at a time and branch\r
+ // on the first failed comparison.\r
+ //\r
+ if ((((INT32 *) VendorGuid)[0] == ((INT32 *) &Variable->VendorGuid)[0]) &&\r
+ (((INT32 *) VendorGuid)[1] == ((INT32 *) &Variable->VendorGuid)[1]) &&\r
+ (((INT32 *) VendorGuid)[2] == ((INT32 *) &Variable->VendorGuid)[2]) &&\r
+ (((INT32 *) VendorGuid)[3] == ((INT32 *) &Variable->VendorGuid)[3])\r
+ ) {\r
+ if (!CompareMem (VariableName, GET_VARIABLE_NAME_PTR (Variable), Variable->NameSize)) {\r
+ PtrTrack->CurrPtr = Variable;\r
+ return EFI_SUCCESS;\r
+ }\r
+ }\r
+ }\r
+\r
+ return EFI_NOT_FOUND;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+FindVariable (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN CHAR16 *VariableName,\r
+ IN EFI_GUID *VendorGuid,\r
+ OUT VARIABLE_POINTER_TRACK *PtrTrack\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ This code finds variable in storage blocks (Non-Volatile)\r
+\r
+Arguments:\r
+\r
+ PeiServices - General purpose services available to every PEIM.\r
+ VariableName - Name of the variable to be found\r
+ VendorGuid - Vendor GUID to be found.\r
+ PtrTrack - Variable Track Pointer structure that contains\r
+ Variable Information.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - Variable found successfully\r
+ EFI_NOT_FOUND - Variable not found\r
+ EFI_INVALID_PARAMETER - Invalid variable name\r
+\r
+--*/\r
+{\r
+ EFI_HOB_GUID_TYPE *GuidHob;\r
+ VARIABLE_STORE_HEADER *VariableStoreHeader;\r
+ VARIABLE_HEADER *Variable;\r
+ VARIABLE_HEADER *MaxIndex;\r
+ VARIABLE_INDEX_TABLE *IndexTable;\r
+ UINT32 Count;\r
+ UINT8 *VariableBase;\r
+\r
+ if (VariableName != 0 && VendorGuid == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+ //\r
+ // No Variable Address equals zero, so 0 as initial value is safe.\r
+ //\r
+ MaxIndex = 0;\r
+\r
+ GuidHob = GetFirstGuidHob (&mEfiVariableIndexTableGuid);\r
+ if (GuidHob == NULL) {\r
+ IndexTable = BuildGuidHob (&mEfiVariableIndexTableGuid, sizeof (VARIABLE_INDEX_TABLE));\r
+ IndexTable->Length = 0;\r
+ IndexTable->StartPtr = NULL;\r
+ IndexTable->EndPtr = NULL;\r
+ IndexTable->GoneThrough = 0;\r
+ } else {\r
+ IndexTable = GET_GUID_HOB_DATA (GuidHob);\r
+ for (Count = 0; Count < IndexTable->Length; Count++)\r
+ {\r
+ MaxIndex = GetVariableByIndex (IndexTable, Count);\r
+\r
+ if (CompareWithValidVariable (MaxIndex, VariableName, VendorGuid, PtrTrack) == EFI_SUCCESS) {\r
+ PtrTrack->StartPtr = IndexTable->StartPtr;\r
+ PtrTrack->EndPtr = IndexTable->EndPtr;\r
+\r
+ return EFI_SUCCESS;\r
+ }\r
+ }\r
+\r
+ if (IndexTable->GoneThrough) {\r
+ return EFI_NOT_FOUND;\r
+ }\r
+ }\r
+ //\r
+ // If not found in HOB, then let's start from the MaxIndex we've found.\r
+ //\r
+ if (MaxIndex != NULL) {\r
+ Variable = GetNextVariablePtr (MaxIndex);\r
+ } else {\r
+ if (IndexTable->StartPtr || IndexTable->EndPtr) {\r
+ Variable = IndexTable->StartPtr;\r
+ } else {\r
+ VariableBase = (UINT8 *) (UINTN) PcdGet32 (PcdFlashNvStorageVariableBase);\r
+ VariableStoreHeader = (VARIABLE_STORE_HEADER *) (VariableBase + \\r
+ ((EFI_FIRMWARE_VOLUME_HEADER *) (VariableBase)) -> HeaderLength);\r
+\r
+ if (GetVariableStoreStatus (VariableStoreHeader) != EfiValid) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ if (~VariableStoreHeader->Size == 0) {\r
+ return EFI_NOT_FOUND;\r
+ }\r
+ //\r
+ // Find the variable by walk through non-volatile variable store\r
+ //\r
+ IndexTable->StartPtr = (VARIABLE_HEADER *) (VariableStoreHeader + 1);\r
+ IndexTable->EndPtr = (VARIABLE_HEADER *) ((UINTN) VariableStoreHeader + VariableStoreHeader->Size);\r
+\r
+ //\r
+ // Start Pointers for the variable.\r
+ // Actual Data Pointer where data can be written.\r
+ //\r
+ Variable = IndexTable->StartPtr;\r
+ }\r
+ }\r
+ //\r
+ // Find the variable by walk through non-volatile variable store\r
+ //\r
+ PtrTrack->StartPtr = IndexTable->StartPtr;\r
+ PtrTrack->EndPtr = IndexTable->EndPtr;\r
+\r
+ while (IsValidVariableHeader (Variable) && (Variable <= IndexTable->EndPtr)) {\r
+ if (Variable->State == VAR_ADDED) {\r
+ //\r
+ // Record Variable in VariableIndex HOB\r
+ //\r
+ if (IndexTable->Length < VARIABLE_INDEX_TABLE_VOLUME)\r
+ {\r
+ VariableIndexTableUpdate (IndexTable, Variable);\r
+ }\r
+\r
+ if (CompareWithValidVariable (Variable, VariableName, VendorGuid, PtrTrack) == EFI_SUCCESS) {\r
+ return EFI_SUCCESS;\r
+ }\r
+ }\r
+\r
+ Variable = GetNextVariablePtr (Variable);\r
+ }\r
+ //\r
+ // If gone through the VariableStore, that means we never find in Firmware any more.\r
+ //\r
+ if (IndexTable->Length < VARIABLE_INDEX_TABLE_VOLUME) {\r
+ IndexTable->GoneThrough = 1;\r
+ }\r
+\r
+ PtrTrack->CurrPtr = NULL;\r
+\r
+ return EFI_NOT_FOUND;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiGetVariable (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN CHAR16 *VariableName,\r
+ IN EFI_GUID * VendorGuid,\r
+ OUT UINT32 *Attributes OPTIONAL,\r
+ IN OUT UINTN *DataSize,\r
+ OUT VOID *Data\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Provide the read variable functionality of the variable services.\r
+\r
+Arguments:\r
+\r
+ PeiServices - General purpose services available to every PEIM.\r
+\r
+ VariableName - The variable name\r
+\r
+ VendorGuid - The vendor's GUID\r
+\r
+ Attributes - Pointer to the attribute\r
+\r
+ DataSize - Size of data\r
+\r
+ Data - Pointer to data\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - The interface could be successfully installed\r
+\r
+ EFI_NOT_FOUND - The variable could not be discovered\r
+\r
+ EFI_BUFFER_TOO_SMALL - The caller buffer is not large enough\r
+\r
+--*/\r
+{\r
+ VARIABLE_POINTER_TRACK Variable;\r
+ UINTN VarDataSize;\r
+ EFI_STATUS Status;\r
+\r
+ if (VariableName == NULL || VendorGuid == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+ //\r
+ // Find existing variable\r
+ //\r
+ Status = FindVariable (PeiServices, VariableName, VendorGuid, &Variable);\r
+\r
+ if (Variable.CurrPtr == NULL || Status != EFI_SUCCESS) {\r
+ return Status;\r
+ }\r
+ //\r
+ // Get data size\r
+ //\r
+ VarDataSize = Variable.CurrPtr->DataSize;\r
+ if (*DataSize >= VarDataSize) {\r
+ (*PeiServices)->CopyMem (Data, GET_VARIABLE_DATA_PTR (Variable.CurrPtr), VarDataSize);\r
+\r
+ if (Attributes != NULL) {\r
+ *Attributes = Variable.CurrPtr->Attributes;\r
+ }\r
+\r
+ *DataSize = VarDataSize;\r
+ return EFI_SUCCESS;\r
+ } else {\r
+ *DataSize = VarDataSize;\r
+ return EFI_BUFFER_TOO_SMALL;\r
+ }\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiGetNextVariableName (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN OUT UINTN *VariableNameSize,\r
+ IN OUT CHAR16 *VariableName,\r
+ IN OUT EFI_GUID *VendorGuid\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Provide the get next variable functionality of the variable services.\r
+\r
+Arguments:\r
+\r
+ PeiServices - General purpose services available to every PEIM.\r
+ VariabvleNameSize - The variable name's size.\r
+ VariableName - A pointer to the variable's name.\r
+ VendorGuid - A pointer to the EFI_GUID structure.\r
+\r
+ VariableNameSize - Size of the variable name\r
+\r
+ VariableName - The variable name\r
+\r
+ VendorGuid - The vendor's GUID\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - The interface could be successfully installed\r
+\r
+ EFI_NOT_FOUND - The variable could not be discovered\r
+\r
+--*/\r
+{\r
+ VARIABLE_POINTER_TRACK Variable;\r
+ UINTN VarNameSize;\r
+ EFI_STATUS Status;\r
+\r
+ if (VariableName == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ Status = FindVariable (PeiServices, VariableName, VendorGuid, &Variable);\r
+\r
+ if (Variable.CurrPtr == NULL || Status != EFI_SUCCESS) {\r
+ return Status;\r
+ }\r
+\r
+ if (VariableName[0] != 0) {\r
+ //\r
+ // If variable name is not NULL, get next variable\r
+ //\r
+ Variable.CurrPtr = GetNextVariablePtr (Variable.CurrPtr);\r
+ }\r
+\r
+ while (!(Variable.CurrPtr >= Variable.EndPtr || Variable.CurrPtr == NULL)) {\r
+ if (IsValidVariableHeader (Variable.CurrPtr)) {\r
+ if (Variable.CurrPtr->State == VAR_ADDED) {\r
+ VarNameSize = (UINTN) Variable.CurrPtr->NameSize;\r
+ if (VarNameSize <= *VariableNameSize) {\r
+ (*PeiServices)->CopyMem (VariableName, GET_VARIABLE_NAME_PTR (Variable.CurrPtr), VarNameSize);\r
+\r
+ (*PeiServices)->CopyMem (VendorGuid, &Variable.CurrPtr->VendorGuid, sizeof (EFI_GUID));\r
+\r
+ Status = EFI_SUCCESS;\r
+ } else {\r
+ Status = EFI_BUFFER_TOO_SMALL;\r
+ }\r
+\r
+ *VariableNameSize = VarNameSize;\r
+ return Status;\r
+ //\r
+ // Variable is found\r
+ //\r
+ } else {\r
+ Variable.CurrPtr = GetNextVariablePtr (Variable.CurrPtr);\r
+ }\r
+ } else {\r
+ break;\r
+ }\r
+ }\r
+\r
+ return EFI_NOT_FOUND;\r
+}\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation \r
+All rights reserved. This program and the accompanying materials \r
+are licensed and made available under the terms and conditions of the BSD License \r
+which accompanies this distribution. The full text of the license may be found at \r
+http://opensource.org/licenses/bsd-license.php \r
+ \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+Module Name:\r
+\r
+ Variable.dxs\r
+\r
+Abstract:\r
+\r
+ Dependency expression file for Variable PEIM.\r
+\r
+--*/ \r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include <PeimDepex.h>\r
+\r
+DEPENDENCY_START\r
+ TRUE\r
+DEPENDENCY_END\r
+\r
+\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006 - 2007, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+ Variable.h\r
+\r
+Abstract:\r
+\r
+ Tiano PEIM to provide the variable functionality\r
+\r
+--*/\r
+\r
+#ifndef _PEI_VARIABLE_H\r
+#define _PEI_VARIABLE_H\r
+\r
+//\r
+// BugBug: We need relcate the head file.\r
+//\r
+#include <Common/Variable.h>\r
+#include <VarMachine.h>\r
+\r
+//\r
+// Define GET_PAD_SIZE to optimize compiler\r
+//\r
+#if ((ALIGNMENT == 0) || (ALIGNMENT == 1))\r
+#define GET_PAD_SIZE(a) (0)\r
+#else\r
+#define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1))\r
+#endif\r
+\r
+#define GET_VARIABLE_NAME_PTR(a) (CHAR16 *) ((UINTN) (a) + sizeof (VARIABLE_HEADER))\r
+\r
+#define GET_VARIABLE_DATA_PTR(a) \\r
+ (UINT8 *) ((UINTN) GET_VARIABLE_NAME_PTR (a) + (a)->NameSize + GET_PAD_SIZE ((a)->NameSize))\r
+\r
+typedef struct {\r
+ VARIABLE_HEADER *CurrPtr;\r
+ VARIABLE_HEADER *EndPtr;\r
+ VARIABLE_HEADER *StartPtr;\r
+} VARIABLE_POINTER_TRACK;\r
+\r
+#define VARIABLE_INDEX_TABLE_VOLUME 122\r
+\r
+#define EFI_VARIABLE_INDEX_TABLE_GUID \\r
+ { 0x8cfdb8c8, 0xd6b2, 0x40f3, { 0x8e, 0x97, 0x02, 0x30, 0x7c, 0xc9, 0x8b, 0x7c } }\r
+\r
+typedef struct {\r
+ UINT16 Length;\r
+ UINT16 GoneThrough;\r
+ VARIABLE_HEADER *EndPtr;\r
+ VARIABLE_HEADER *StartPtr;\r
+ UINT16 Index[VARIABLE_INDEX_TABLE_VOLUME];\r
+} VARIABLE_INDEX_TABLE;\r
+\r
+\r
+//\r
+// Functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+PeimInitializeVariableServices (\r
+ IN EFI_FFS_FILE_HEADER *FfsHeader,\r
+ IN EFI_PEI_SERVICES **PeiServices\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ TODO: Add function description\r
+\r
+Arguments:\r
+\r
+ FfsHeader - TODO: add argument description\r
+ PeiServices - TODO: add argument description\r
+\r
+Returns:\r
+\r
+ TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiGetVariable (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN CHAR16 *VariableName,\r
+ IN EFI_GUID * VendorGuid,\r
+ OUT UINT32 *Attributes OPTIONAL,\r
+ IN OUT UINTN *DataSize,\r
+ OUT VOID *Data\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ TODO: Add function description\r
+\r
+Arguments:\r
+\r
+ PeiServices - TODO: add argument description\r
+ VariableName - TODO: add argument description\r
+ VendorGuid - TODO: add argument description\r
+ Attributes - TODO: add argument description\r
+ DataSize - TODO: add argument description\r
+ Data - TODO: add argument description\r
+\r
+Returns:\r
+\r
+ TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiGetNextVariableName (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN OUT UINTN *VariableNameSize,\r
+ IN OUT CHAR16 *VariableName,\r
+ IN OUT EFI_GUID *VendorGuid\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ TODO: Add function description\r
+\r
+Arguments:\r
+\r
+ PeiServices - TODO: add argument description\r
+ VariableNameSize - TODO: add argument description\r
+ VariableName - TODO: add argument description\r
+ VendorGuid - TODO: add argument description\r
+\r
+Returns:\r
+\r
+ TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+/**\r
+ Get one variable by the index count.\r
+\r
+ @param IndexTable The pointer to variable index table.\r
+ @param Count The index count of variable in index table.\r
+\r
+ @return The pointer to variable header indexed by count.\r
+\r
+**/\r
+VARIABLE_HEADER *\r
+GetVariableByIndex (\r
+ IN VARIABLE_INDEX_TABLE *IndexTable,\r
+ IN UINT32 Count\r
+ );\r
+\r
+/**\r
+ Record Variable in VariableIndex HOB.\r
+\r
+ Record Variable in VariableIndex HOB and update the length of variable index table.\r
+\r
+ @param IndexTable The pointer to variable index table.\r
+ @param Variable The pointer to the variable that will be recorded.\r
+\r
+ @retval VOID\r
+\r
+**/\r
+VOID\r
+VariableIndexTableUpdate (\r
+ IN OUT VARIABLE_INDEX_TABLE *IndexTable,\r
+ IN VARIABLE_HEADER *Variable\r
+ );\r
+\r
+#endif // _PEI_VARIABLE_H\r
--- /dev/null
+#/** @file\r
+# Component description file for PeiVariable module.\r
+#\r
+# Framework PEIM to provide the Variable functionality.\r
+# Copyright (c) 2006 - 2007, Intel Corporation\r
+#\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = PeiVariable\r
+ FILE_GUID = 34C8C28F-B61C-45a2-8F2E-89E46BECC63B\r
+ MODULE_TYPE = PEIM\r
+ VERSION_STRING = 1.0\r
+ EDK_RELEASE_VERSION = 0x00020000\r
+ EFI_SPECIFICATION_VERSION = 0x00020000\r
+\r
+ ENTRY_POINT = PeimInitializeVariableServices\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+ Variable.dxs\r
+ Variable.c\r
+ Variable.h\r
+\r
+[Sources.Ia32]\r
+ Ia32/VarMachine.h\r
+ VariableWorker.c\r
+\r
+[Sources.X64]\r
+ x64/VarMachine.h\r
+ VariableWorker.c\r
+\r
+[Sources.IPF]\r
+ Ipf/VarMachine.h\r
+ Ipf/VariableWorker.c\r
+\r
+[Sources.EBC]\r
+ Ebc/VarMachine.h\r
+ VariableWorker.c\r
+\r
+\r
+################################################################################\r
+#\r
+# Includes Section - list of Include locations that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Includes]\r
+ $(WORKSPACE)/MdePkg/Include/Library\r
+ \r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+ MdeModulePkg/MdeModulePkg.dec\r
+ MdePkg/MdePkg.dec\r
+ IntelFrameworkPkg/IntelFrameworkPkg.dec\r
+\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+# this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+ BaseMemoryLib\r
+ PcdLib\r
+ HobLib\r
+ PeimEntryPoint\r
+ DebugLib\r
+\r
+\r
+################################################################################\r
+#\r
+# PPI C Name Section - list of PPI and PPI Notify C Names that this module\r
+# uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Ppis]\r
+ gEfiPeiReadOnlyVariablePpiGuid # PPI ALWAYS_CONSUMED\r
+\r
+\r
+################################################################################\r
+#\r
+# Pcd DYNAMIC - list of PCDs that this module is coded for.\r
+#\r
+################################################################################\r
+\r
+[PcdsDynamic.common]\r
+ PcdFlashNvStorageVariableBase|gEfiGenericPlatformTokenSpaceGuid\r
+\r
+[depex]\r
+ TRUE\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+ <MsaHeader>\r
+ <ModuleName>PeiVariable</ModuleName>\r
+ <ModuleType>PEIM</ModuleType>\r
+ <GuidValue>34C8C28F-B61C-45a2-8F2E-89E46BECC63B</GuidValue>\r
+ <Version>1.0</Version>\r
+ <Abstract>Component description file for PeiVariable module.</Abstract>\r
+ <Description>Framework PEIM to provide the Variable functionality.</Description>\r
+ <Copyright>Copyright (c) 2006 - 2007, Intel Corporation</Copyright>\r
+ <License>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
+ 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.</License>\r
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>\r
+ </MsaHeader>\r
+ <ModuleDefinitions>\r
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+ <BinaryModule>false</BinaryModule>\r
+ <OutputFileBasename>PeiVariable</OutputFileBasename>\r
+ </ModuleDefinitions>\r
+ <LibraryClassDefinitions>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>DebugLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>PeimEntryPoint</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>HobLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>PcdLib</Keyword>\r
+ </LibraryClass>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>BaseMemoryLib</Keyword>\r
+ </LibraryClass>\r
+ </LibraryClassDefinitions>\r
+ <SourceFiles>\r
+ <Filename>Variable.h</Filename>\r
+ <Filename>Variable.c</Filename>\r
+ <Filename>Variable.dxs</Filename>\r
+ <Filename SupArchList="IA32 X64 EBC">VariableWorker.c</Filename>\r
+ <Filename SupArchList="IPF">Ipf/VariableWorker.c</Filename>\r
+ <Filename SupArchList="IA32">Ia32/VarMachine.h</Filename>\r
+ <Filename SupArchList="EBC">Ebc/VarMachine.h</Filename>\r
+ <Filename SupArchList="X64">x64/VarMachine.h</Filename>\r
+ <Filename SupArchList="IPF">Ipf/VarMachine.h</Filename>\r
+ </SourceFiles>\r
+ <PackageDependencies>\r
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+ <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+ </PackageDependencies>\r
+ <PPIs>\r
+ <Ppi Usage="ALWAYS_CONSUMED">\r
+ <PpiCName>gEfiPeiReadOnlyVariablePpiGuid</PpiCName>\r
+ </Ppi>\r
+ </PPIs>\r
+ <Externs>\r
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+ <Extern>\r
+ <ModuleEntryPoint>PeimInitializeVariableServices</ModuleEntryPoint>\r
+ </Extern>\r
+ </Externs>\r
+ <PcdCoded>\r
+ <PcdEntry PcdItemType="DYNAMIC">\r
+ <C_Name>PcdFlashNvStorageVariableBase</C_Name>\r
+ <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>\r
+ <HelpText>The driver gets the Variable store base address from this PCD. This base address point to
+ an EFI_FIRMWARE_VOLUMN_HEADER struct.</HelpText>\r
+ </PcdEntry>\r
+ </PcdCoded>\r
+</ModuleSurfaceArea>
\ No newline at end of file
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+ VariableWorker.c\r
+\r
+Abstract:\r
+\r
+ Framework PEIM to provide the Variable functionality\r
+\r
+--*/\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiPei.h>\r
+\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Ppi/ReadOnlyVariable.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/DebugLib.h>\r
+#include <Library/PeimEntryPoint.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+\r
+\r
+#include <Variable.h>\r
+\r
+/**\r
+ Get one variable by the index count.\r
+\r
+ @param IndexTable The pointer to variable index table.\r
+ @param Count The index count of variable in index table.\r
+\r
+ @return The pointer to variable header indexed by count.\r
+\r
+**/\r
+VARIABLE_HEADER *\r
+GetVariableByIndex (\r
+ IN VARIABLE_INDEX_TABLE *IndexTable,\r
+ IN UINT32 Count\r
+ )\r
+{\r
+ return (VARIABLE_HEADER *) (UINTN) (IndexTable->Index[Count] + ((UINTN) IndexTable->StartPtr & 0xFFFF0000));\r
+}\r
+\r
+/**\r
+ Record Variable in VariableIndex HOB.\r
+\r
+ Record Variable in VariableIndex HOB and update the length of variable index table.\r
+\r
+ @param IndexTable The pointer to variable index table.\r
+ @param Variable The pointer to the variable that will be recorded.\r
+\r
+ @retval VOID\r
+\r
+**/\r
+VOID\r
+VariableIndexTableUpdate (\r
+ IN OUT VARIABLE_INDEX_TABLE *IndexTable,\r
+ IN VARIABLE_HEADER *Variable\r
+ )\r
+{\r
+ IndexTable->Index[IndexTable->Length++] = (UINT16) (UINTN) Variable;\r
+\r
+ return;\r
+}\r
+\r
--- /dev/null
+/**@file\r
+ Variable Machine Type\r
+ \r
+Copyright (c) 2006 - 2007 Intel Corporation. <BR>\r
+All rights reserved. This program and the accompanying materials \r
+are licensed and made available under the terms and conditions of the BSD License \r
+which accompanies this distribution. The full text of the license may be found at \r
+http://opensource.org/licenses/bsd-license.php \r
+ \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+**/\r
+\r
+#ifndef _VAR_MACHINE_H\r
+#define _VAR_MACHINE_H\r
+\r
+\r
+#endif\r
${WORKSPACE}/MdeModulePkg/Universal/FirmwareVolume/FaultTolerantWriteLite/Dxe/FtwLite.inf\r
#${WORKSPACE}/MdeModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.inf\r
${WORKSPACE}/MdeModulePkg/Bus/Pci/AtapiPassThru/Dxe/AtapiPassThru.inf\r
- ${WORKSPACE}/MdeModulePkg/Universal/WatchDogTimerDxe/WatchDogTimer.inf
\ No newline at end of file
+ ${WORKSPACE}/MdeModulePkg/Universal/WatchDogTimerDxe/WatchDogTimer.inf\r
+ #${WORKSPACE}/MdeModulePkg/Universal/VariablePei/Variable.inf
\ No newline at end of file