]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c
OvmfPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / OvmfPkg / Library / NvVarsFileLib / NvVarsFileLib.c
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
13 EFI_HANDLE mNvVarsFileLibFsHandle = NULL;
14
15
16 /**
17 Attempts to connect the NvVarsFileLib to the specified file system.
18
19 @param[in] FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid instance
20
21 @return The EFI_STATUS while attempting to connect the NvVarsFileLib
22 to the file system instance.
23 @retval EFI_SUCCESS - The given file system was connected successfully
24
25 **/
26 EFI_STATUS
27 EFIAPI
28 ConnectNvVarsToFileSystem (
29 IN EFI_HANDLE FsHandle
30 )
31 {
32 EFI_STATUS Status;
33
34 //
35 // We might fail to load the variable, since the file system initially
36 // will not have the NvVars file.
37 //
38 LoadNvVarsFromFs (FsHandle);
39
40 //
41 // We must be able to save the variables successfully to the file system
42 // to have connected successfully.
43 //
44 Status = SaveNvVarsToFs (FsHandle);
45 if (!EFI_ERROR (Status)) {
46 mNvVarsFileLibFsHandle = FsHandle;
47 }
48
49 return Status;
50 }
51
52
53 /**
54 Update non-volatile variables stored on the file system.
55
56 @return The EFI_STATUS while attempting to update the variable on
57 the connected file system.
58 @retval EFI_SUCCESS - The non-volatile variables were saved to the disk
59 @retval EFI_NOT_STARTED - A file system has not been connected
60
61 **/
62 EFI_STATUS
63 EFIAPI
64 UpdateNvVarsOnFileSystem (
65 )
66 {
67 if (mNvVarsFileLibFsHandle == NULL) {
68 //
69 // A file system had not been connected to the library.
70 //
71 return EFI_NOT_STARTED;
72 } else {
73 return SaveNvVarsToFs (mNvVarsFileLibFsHandle);
74 }
75 }
76
77