2 Entrypoint of Extended SAL variable service module.
4 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
5 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
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.
16 #include "AuthService.h"
19 // Don't use module globals after the SetVirtualAddress map is signaled
21 EFI_EVENT mEfiVirtualNotifyEvent
;
24 Common entry for Extended SAL Variable Services Class.
26 This is the common entry of all functions of Extended SAL Variable Services Class.
28 @param[in] FunctionId The Function ID of member function in Extended SAL Variable Services Class.
29 @param[in] Arg2 The 2nd parameter for SAL procedure call.
30 @param[in] Arg3 The 3rd parameter for SAL procedure call.
31 @param[in] Arg4 The 4th parameter for SAL procedure call.
32 @param[in] Arg5 The 5th parameter for SAL procedure call.
33 @param[in] Arg6 The 6th parameter for SAL procedure call.
34 @param[in] Arg7 The 7th parameter for SAL procedure call.
35 @param[in] Arg8 The 8th parameter for SAL procedure call.
36 @param[in] VirtualMode The current calling mode for this function.
37 @param[in] Global The context of this Extended SAL Variable Services Class call.
39 @return The register of SAL.
44 EsalVariableCommonEntry (
53 IN BOOLEAN VirtualMode
,
54 IN ESAL_VARIABLE_GLOBAL
*Global
57 SAL_RETURN_REGS ReturnVal
;
64 case EsalGetVariableFunctionId
:
65 ReturnVal
.Status
= EsalGetVariable (
76 case EsalGetNextVariableNameFunctionId
:
77 ReturnVal
.Status
= EsalGetNextVariableName (
86 case EsalSetVariableFunctionId
:
87 ReturnVal
.Status
= EsalSetVariable (
98 case EsalQueryVariableInfoFunctionId
:
99 ReturnVal
.Status
= EsalQueryVariableInfo (
110 ReturnVal
.Status
= EFI_SAL_INVALID_ARGUMENT
;
116 Notification function of EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.
118 This is a notification function registered on EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.
119 It convers pointer to new virtual address.
121 @param[in] Event The event whose notification function is being invoked.
122 @param[in] Context The pointer to the notification function's context.
127 VariableClassAddressChangeEvent (
135 &mVariableModuleGlobal
->VariableGlobal
[Virtual
],
136 &mVariableModuleGlobal
->VariableGlobal
[Physical
],
137 sizeof (VARIABLE_GLOBAL
)
142 (VOID
**) &mVariableModuleGlobal
->VariableGlobal
[Virtual
].NonVolatileVariableBase
146 (VOID
**) &mVariableModuleGlobal
->VariableGlobal
[Virtual
].VolatileVariableBase
149 mVariableModuleGlobal
->PlatformLangCodes
[Virtual
] = mVariableModuleGlobal
->PlatformLangCodes
[Physical
];
150 EfiConvertPointer (0x0, (VOID
**) &mVariableModuleGlobal
->PlatformLangCodes
[Virtual
]);
152 mVariableModuleGlobal
->LangCodes
[Virtual
] = mVariableModuleGlobal
->LangCodes
[Physical
];
153 EfiConvertPointer (0x0, (VOID
**) &mVariableModuleGlobal
->LangCodes
[Virtual
]);
155 mVariableModuleGlobal
->PlatformLang
[Virtual
] = mVariableModuleGlobal
->PlatformLang
[Physical
];
156 EfiConvertPointer (0x0, (VOID
**) &mVariableModuleGlobal
->PlatformLang
[Virtual
]);
159 mVariableModuleGlobal
->VariableName
[Virtual
],
160 mVariableModuleGlobal
->VariableName
[Physical
],
161 sizeof (mVariableModuleGlobal
->VariableName
[Physical
])
163 for (Index
= 0; Index
< NUM_VAR_NAME
; Index
++) {
164 EfiConvertPointer (0x0, (VOID
**) &mVariableModuleGlobal
->VariableName
[Virtual
][Index
]);
167 mVariableModuleGlobal
->GlobalVariableGuid
[Virtual
] = &gEfiGlobalVariableGuid
;
168 EfiConvertPointer (0x0, (VOID
**) &mVariableModuleGlobal
->GlobalVariableGuid
[Virtual
]);
170 mVariableModuleGlobal
->AuthenticatedVariableGuid
[Virtual
] = &gEfiAuthenticatedVariableGuid
;
171 EfiConvertPointer (0x0, (VOID
**) &mVariableModuleGlobal
->AuthenticatedVariableGuid
[Virtual
]);
173 mVariableModuleGlobal
->CertRsa2048Sha256Guid
[Virtual
] = &gEfiCertRsa2048Sha256Guid
;
174 EfiConvertPointer (0x0, (VOID
**) &mVariableModuleGlobal
->CertRsa2048Sha256Guid
[Virtual
]);
176 mVariableModuleGlobal
->ImageSecurityDatabaseGuid
[Virtual
] = &gEfiImageSecurityDatabaseGuid
;
177 EfiConvertPointer (0x0, (VOID
**) &mVariableModuleGlobal
->ImageSecurityDatabaseGuid
[Virtual
]);
179 mVariableModuleGlobal
->HashContext
[Virtual
] = mVariableModuleGlobal
->HashContext
[Physical
];
180 EfiConvertPointer (0x0, (VOID
**) &mVariableModuleGlobal
->HashContext
[Virtual
]);
184 Entry point of Extended SAL Variable service module.
186 This function is the entry point of Extended SAL Variable service module.
187 It registers all functions of Extended SAL Variable class, initializes
188 variable store for non-volatile and volatile variables, and registers
189 notification function for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.
191 @param[in] ImageHandle The Image handle of this driver.
192 @param[in] SystemTable The pointer of EFI_SYSTEM_TABLE.
194 @retval EFI_SUCCESS Extended SAL Variable Services Class successfully registered.
199 VariableServiceInitialize (
200 IN EFI_HANDLE ImageHandle
,
201 IN EFI_SYSTEM_TABLE
*SystemTable
206 Status
= gBS
->CreateEventEx (
209 VariableClassAddressChangeEvent
,
211 &gEfiEventVirtualAddressChangeGuid
,
212 &mEfiVirtualNotifyEvent
215 ASSERT_EFI_ERROR (Status
);
217 Status
= VariableCommonInitialize (ImageHandle
, SystemTable
);
218 ASSERT_EFI_ERROR (Status
);
221 // Authenticated variable initialize
223 Status
= AutenticatedVariableServiceInitialize ();
224 ASSERT_EFI_ERROR (Status
);
229 // Register All the Functions with Extended SAL Variable Services Class
232 EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID_LO
,
233 EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID_HI
,
234 mVariableModuleGlobal
,
235 EsalVariableCommonEntry
,
236 EsalGetVariableFunctionId
,
237 EsalVariableCommonEntry
,
238 EsalGetNextVariableNameFunctionId
,
239 EsalVariableCommonEntry
,
240 EsalSetVariableFunctionId
,
241 EsalVariableCommonEntry
,
242 EsalQueryVariableInfoFunctionId
,