]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/EmuVariableRuntimeDxe/Ipf/InitVariable.c
Add in EmuVariableRuntimeDxe
[mirror_edk2.git] / MdeModulePkg / Universal / EmuVariableRuntimeDxe / Ipf / InitVariable.c
1 /*++
2
3 Copyright (c) 2006 - 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 IpfVariable.c
15
16 Abstract:
17
18 Revision History
19
20 --*/
21
22 #include "Variable.h"
23 #include <IndustryStandard/Sal.h>
24
25 //
26 // Don't use module globals after the SetVirtualAddress map is signaled
27 //
28
29 STATIC
30 SAL_RETURN_REGS
31 EsalVariableCommonEntry (
32 IN UINT64 FunctionId,
33 IN UINT64 Arg2,
34 IN UINT64 Arg3,
35 IN UINT64 Arg4,
36 IN UINT64 Arg5,
37 IN UINT64 Arg6,
38 IN UINT64 Arg7,
39 IN UINT64 Arg8,
40 IN SAL_EXTENDED_SAL_PROC ExtendedSalProc,
41 IN BOOLEAN VirtualMode,
42 IN ESAL_VARIABLE_GLOBAL *Global
43 )
44 /*++
45
46 Routine Description:
47
48 Arguments:
49
50 Returns:
51
52 --*/
53 {
54 SAL_RETURN_REGS ReturnVal;
55
56 switch (FunctionId) {
57 case EsalGetVariable:
58 ReturnVal.Status = GetVariable (
59 (CHAR16 *) Arg2,
60 (EFI_GUID *) Arg3,
61 (UINT32 *) Arg4,
62 (UINTN *) Arg5,
63 (VOID *) Arg6,
64 &Global->VariableGlobal[VirtualMode],
65 Global->FvbInstance
66 );
67 return ReturnVal;
68
69 case EsalGetNextVariableName:
70 ReturnVal.Status = GetNextVariableName (
71 (UINTN *) Arg2,
72 (CHAR16 *) Arg3,
73 (EFI_GUID *) Arg4,
74 &Global->VariableGlobal[VirtualMode],
75 Global->FvbInstance
76 );
77 return ReturnVal;
78
79 case EsalSetVariable:
80 ReturnVal.Status = SetVariable (
81 (CHAR16 *) Arg2,
82 (EFI_GUID *) Arg3,
83 (UINT32) Arg4,
84 (UINTN) Arg5,
85 (VOID *) Arg6,
86 &Global->VariableGlobal[VirtualMode],
87 (UINTN *) &Global->VolatileLastVariableOffset,
88 (UINTN *) &Global->NonVolatileLastVariableOffset,
89 Global->FvbInstance
90 );
91 return ReturnVal;
92
93 case EsalQueryVariableInfo:
94 ReturnVal.Status = QueryVariableInfo (
95 (UINT32) Arg2,
96 (UINT64 *) Arg3,
97 (UINT64 *) Arg4,
98 (UINT64 *) Arg5,
99 &Global->VariableGlobal[VirtualMode],
100 Global->FvbInstance
101 );
102 return ReturnVal;
103
104 default:
105 ReturnVal.Status = EFI_SAL_INVALID_ARGUMENT;
106 return ReturnVal;
107 }
108 }
109
110
111 VOID
112 VariableClassAddressChangeEvent (
113 IN EFI_EVENT Event,
114 IN VOID *Context
115 )
116 /*++
117
118 Routine Description:
119
120 Arguments:
121
122 Returns:
123
124 --*/
125 {
126 CopyMem (
127 &mVariableModuleGlobal->VariableGlobal[Virtual],
128 &mVariableModuleGlobal->VariableGlobal[Physical],
129 sizeof (VARIABLE_GLOBAL)
130 );
131
132 EfiConvertPointer (
133 0x0,
134 (VOID **) &mVariableModuleGlobal->VariableGlobal[Virtual].NonVolatileVariableBase
135 );
136 EfiConvertPointer (
137 0x0,
138 (VOID **) &mVariableModuleGlobal->VariableGlobal[Virtual].VolatileVariableBase
139 );
140 EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal);
141 }
142
143 EFI_STATUS
144 VariableServiceInitialize (
145 IN EFI_HANDLE ImageHandle,
146 IN EFI_SYSTEM_TABLE *SystemTable
147 )
148 /*++
149
150 Routine Description:
151
152 Arguments:
153
154 Returns:
155
156 --*/
157 {
158 EFI_STATUS Status;
159
160 Status = VariableCommonInitialize (ImageHandle, SystemTable);
161 ASSERT_EFI_ERROR (Status);
162
163 //
164 // Register All the Functions with Extended Sal.
165 //
166 RegisterEsalClass (
167 &gEfiExtendedSalVariableServicesProtocolGuid,
168 mVariableModuleGlobal,
169 EsalVariableCommonEntry,
170 EsalGetVariable,
171 EsalVariableCommonEntry,
172 EsalGetNextVariableName,
173 EsalVariableCommonEntry,
174 EsalSetVariable,
175 EsalVariableCommonEntry,
176 EsalQueryVariableInfo,
177 NULL
178 );
179
180 return EFI_SUCCESS;
181 }