29 IN BOOLEAN ReadingFile,
40 Status =
gBS->HandleProtocol (
42 &gEfiSimpleFileSystemProtocolGuid,
45 if (EFI_ERROR (Status)) {
52 Status = Fs->OpenVolume (Fs, &Root);
53 if (EFI_ERROR (Status)) {
67 EFI_FILE_MODE_CREATE |
136 return EFI_INVALID_PARAMETER;
144 return EFI_INVALID_PARAMETER;
184 UINTN ActualReadSize;
187 ActualReadSize = ReadSize;
189 if (FileContents !=
NULL) {
195 if (EFI_ERROR (Status) || (ActualReadSize != ReadSize)) {
225 if (EFI_ERROR (Status)) {
226 DEBUG ((DEBUG_INFO,
"FsAccess.c: Could not open NV Variables file on this file system\n"));
233 return EFI_UNSUPPORTED;
237 if (FileContents ==
NULL) {
239 return EFI_UNSUPPORTED;
244 "FsAccess.c: Read %Lu bytes from NV Variables file\n",
249 &SerializedVariables,
282 Size =
sizeof (VarData);
286 &gEfiSimpleFileSystemProtocolGuid,
288 EFI_VARIABLE_BOOTSERVICE_ACCESS |
289 EFI_VARIABLE_RUNTIME_ACCESS,
313 DEBUG ((DEBUG_INFO,
"FsAccess.c: LoadNvVarsFromFs\n"));
324 Size =
sizeof (VarData);
326 Status =
gRT->GetVariable (
328 &gEfiSimpleFileSystemProtocolGuid,
334 DEBUG ((DEBUG_INFO,
"NV Variables were already loaded\n"));
335 return EFI_ALREADY_STARTED;
342 if (EFI_ERROR (Status)) {
343 DEBUG ((DEBUG_INFO,
"Error while restoring NV variable data\n"));
356 "FsAccess.c: Read NV Variables file (size=%Lu)\n",
366IterateVariablesCallbackAddAllNvVariables (
368 IN CHAR16 *VariableName,
370 IN UINT32 Attributes,
413 UINTN VariableDataSize;
417 SerializedVariables =
NULL;
420 if (EFI_ERROR (Status)) {
425 IterateVariablesCallbackAddAllNvVariables,
426 (VOID *)SerializedVariables
428 if (EFI_ERROR (Status)) {
433 VariableDataSize = 0;
441 if (VariableData ==
NULL) {
442 Status = EFI_OUT_OF_RESOURCES;
454 if (EFI_ERROR (Status)) {
462 if (EFI_ERROR (Status)) {
463 DEBUG ((DEBUG_INFO,
"FsAccess.c: Unable to open file to saved NV Variables\n"));
471 if (EFI_ERROR (Status)) {
476 WriteSize = VariableDataSize;
478 if (EFI_ERROR (Status)) {
484 if (!EFI_ERROR (Status)) {
492 DEBUG ((DEBUG_INFO,
"Saved NV Variables to NvVars file\n"));
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS EFIAPI FileHandleSetInfo(IN EFI_FILE_HANDLE FileHandle, IN CONST EFI_FILE_INFO *FileInfo)
EFI_FILE_INFO *EFIAPI FileHandleGetInfo(IN EFI_FILE_HANDLE FileHandle)
EFI_STATUS EFIAPI FileHandleClose(IN EFI_FILE_HANDLE FileHandle)
EFI_STATUS EFIAPI FileHandleWrite(IN EFI_FILE_HANDLE FileHandle, IN OUT UINTN *BufferSize, IN VOID *Buffer)
EFI_STATUS EFIAPI FileHandleRead(IN EFI_FILE_HANDLE FileHandle, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
VOID * FileHandleReadToNewBuffer(IN EFI_FILE_HANDLE FileHandle, IN UINTN ReadSize)
EFI_STATUS FileHandleEmpty(IN EFI_FILE_HANDLE File)
STATIC VOID SetNvVarsVariable(VOID)
VOID NvVarsFileReadCheckup(IN EFI_FILE_HANDLE File, OUT BOOLEAN *Exists, OUT UINTN *Size)
EFI_STATUS GetNvVarsFile(IN EFI_HANDLE FsHandle, IN BOOLEAN ReadingFile, OUT EFI_FILE_HANDLE *NvVarsFile)
EFI_STATUS LoadNvVarsFromFs(EFI_HANDLE FsHandle)
EFI_STATUS SaveNvVarsToFs(EFI_HANDLE FsHandle)
EFI_STATUS ReadNvVarsFile(IN EFI_HANDLE FsHandle)
RETURN_STATUS EFIAPI SerializeVariablesIterateSystemVariables(IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction, IN VOID *Context)
RETURN_STATUS EFIAPI SerializeVariablesFreeInstance(IN EFI_HANDLE Handle)
RETURN_STATUS EFIAPI SerializeVariablesNewInstanceFromBuffer(OUT EFI_HANDLE *Handle, IN VOID *Buffer, IN UINTN Size)
RETURN_STATUS EFIAPI SerializeVariablesAddVariable(IN EFI_HANDLE Handle, IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN UINT32 Attributes, IN UINTN DataSize, IN VOID *Data)
RETURN_STATUS EFIAPI SerializeVariablesToBuffer(IN EFI_HANDLE Handle, OUT VOID *Buffer, IN OUT UINTN *Size)
RETURN_STATUS EFIAPI SerializeVariablesNewInstance(OUT EFI_HANDLE *Handle)
RETURN_STATUS EFIAPI SerializeVariablesSetSerializedVariables(IN EFI_HANDLE Handle)
EFI_RUNTIME_SERVICES * gRT
#define RETURN_BUFFER_TOO_SMALL
#define RETURN_ERROR(StatusCode)
#define DEBUG(Expression)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
EFI_FILE_INFO * FileInfo(IN EFI_FILE_HANDLE FHand)
#define EFI_VARIABLE_NON_VOLATILE