Add VariablePei into IntelFrameworkModulePkg
[mirror_edk2.git] / IntelFrameworkModulePkg / 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 #include <Variable.h>
23
24 /**
25 Get one variable by the index count.
26
27 @param IndexTable The pointer to variable index table.
28 @param Count The index count of variable in index table.
29
30 @return The pointer to variable header indexed by count.
31
32 **/
33 VARIABLE_HEADER *
34 GetVariableByIndex (
35 IN VARIABLE_INDEX_TABLE *IndexTable,
36 IN UINT32 Count
37 )
38 {
39 return (VARIABLE_HEADER *) (UINTN) (IndexTable->Index[Count] + ((UINTN) IndexTable->StartPtr & 0xFFFF0000));
40 }
41
42 /**
43 Record Variable in VariableIndex HOB.
44
45 Record Variable in VariableIndex HOB and update the length of variable index table.
46
47 @param IndexTable The pointer to variable index table.
48 @param Variable The pointer to the variable that will be recorded.
49
50 @retval VOID
51
52 **/
53 VOID
54 VariableIndexTableUpdate (
55 IN OUT VARIABLE_INDEX_TABLE *IndexTable,
56 IN VARIABLE_HEADER *Variable
57 )
58 {
59 IndexTable->Index[IndexTable->Length++] = (UINT16) (UINTN) Variable;
60
61 return;
62 }
63