VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c@ 108793

Last change on this file since 108793 was 101291, checked in by vboxsync, 19 months ago

EFI/FirmwareNew: Make edk2-stable202308 build on all supported platforms (using gcc at least, msvc not tested yet), bugref:4643

  • Property svn:eol-style set to native
File size: 1.9 KB
Line 
1/** @file
2 Save Non-Volatile Variables to a file system.
3
4 Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7**/
8
9#include "NvVarsFileLib.h"
10#include <Library/DebugLib.h>
11#include <Library/NvVarsFileLib.h>
12
13EFI_HANDLE mNvVarsFileLibFsHandle = NULL;
14
15/**
16 Attempts to connect the NvVarsFileLib to the specified file system.
17
18 @param[in] FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid instance
19
20 @return The EFI_STATUS while attempting to connect the NvVarsFileLib
21 to the file system instance.
22 @retval EFI_SUCCESS - The given file system was connected successfully
23
24**/
25EFI_STATUS
26EFIAPI
27ConnectNvVarsToFileSystem (
28 IN EFI_HANDLE FsHandle
29 )
30{
31 EFI_STATUS Status;
32
33 if (FeaturePcdGet (PcdSecureBootSupported) ||
34 FeaturePcdGet (PcdBootRestrictToFirmware))
35 {
36 return EFI_UNSUPPORTED;
37 }
38
39 //
40 // We might fail to load the variable, since the file system initially
41 // will not have the NvVars file.
42 //
43 LoadNvVarsFromFs (FsHandle);
44
45 //
46 // We must be able to save the variables successfully to the file system
47 // to have connected successfully.
48 //
49 Status = SaveNvVarsToFs (FsHandle);
50 if (!EFI_ERROR (Status)) {
51 mNvVarsFileLibFsHandle = FsHandle;
52 }
53
54 return Status;
55}
56
57/**
58 Update non-volatile variables stored on the file system.
59
60 @return The EFI_STATUS while attempting to update the variable on
61 the connected file system.
62 @retval EFI_SUCCESS - The non-volatile variables were saved to the disk
63 @retval EFI_NOT_STARTED - A file system has not been connected
64
65**/
66EFI_STATUS
67EFIAPI
68UpdateNvVarsOnFileSystem (
69 )
70{
71 if (mNvVarsFileLibFsHandle == NULL) {
72 //
73 // A file system had not been connected to the library.
74 //
75 return EFI_NOT_STARTED;
76 } else {
77 return SaveNvVarsToFs (mNvVarsFileLibFsHandle);
78 }
79}
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette