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