]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/VariablePei/Ipf/VariableWorker.c
Add variablePei module into MdeModulePkg.
[mirror_edk2.git] / MdeModulePkg / Universal / VariablePei / Ipf / VariableWorker.c
diff --git a/MdeModulePkg/Universal/VariablePei/Ipf/VariableWorker.c b/MdeModulePkg/Universal/VariablePei/Ipf/VariableWorker.c
new file mode 100644 (file)
index 0000000..912aab1
--- /dev/null
@@ -0,0 +1,74 @@
+/** @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