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