Remove package dependency of IntelFrameworkPkg
[mirror_edk2.git] / MdeModulePkg / Universal / VariablePei / Ipf / VariableWorker.c
1 /** @file
2 Variable worker functions.
3
4 Copyright (c) 2006, Intel Corporation<BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14 //
15 // The package level header files this module uses
16 //
17 #include <PiPei.h>
18
19 //
20 // The protocols, PPI and GUID defintions for this module
21 //
22 #include <Ppi/ReadOnlyVariable.h>
23 //
24 // The Library classes this module consumes
25 //
26 #include <Library/DebugLib.h>
27 #include <Library/PeimEntryPoint.h>
28 #include <Library/HobLib.h>
29 #include <Library/PcdLib.h>
30 #include <Library/BaseMemoryLib.h>
31
32 #include <Variable.h>
33
34
35 /**
36 Get one variable by the index count.
37
38 @param IndexTable The pointer to variable index table.
39 @param Count The index count of variable in index table.
40
41 @return The pointer to variable header indexed by count.
42
43 **/
44 VARIABLE_HEADER *
45 GetVariableByIndex (
46 IN VARIABLE_INDEX_TABLE *IndexTable,
47 IN UINT32 Count
48 )
49 {
50 return (VARIABLE_HEADER *) (UINTN) ((((UINT32)IndexTable->Index[Count]) << 2) + ((UINT32)(UINTN)IndexTable->StartPtr & 0xFFFC0000) );
51 }
52
53 /**
54 Record Variable in VariableIndex HOB.
55
56 Record Variable in VariableIndex HOB and update the length of variable index table.
57
58 @param IndexTable The pointer to variable index table.
59 @param Variable The pointer to the variable that will be recorded.
60
61 @retval VOID
62
63 **/
64 VOID
65 VariableIndexTableUpdate (
66 IN OUT VARIABLE_INDEX_TABLE *IndexTable,
67 IN VARIABLE_HEADER *Variable
68 )
69 {
70 IndexTable->Index[IndexTable->Length++] = (UINT16) (((UINT32)(UINTN) Variable) >> 2);
71
72 return;
73 }
74