]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c
OvmfPkg: Apply uncrustify changes
[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 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 **/
25 EFI_STATUS
26 EFIAPI
27 ConnectNvVarsToFileSystem (
28 IN EFI_HANDLE FsHandle
29 )
30 {
31 EFI_STATUS Status;
32
33 //
34 // We might fail to load the variable, since the file system initially
35 // will not have the NvVars file.
36 //
37 LoadNvVarsFromFs (FsHandle);
38
39 //
40 // We must be able to save the variables successfully to the file system
41 // to have connected successfully.
42 //
43 Status = SaveNvVarsToFs (FsHandle);
44 if (!EFI_ERROR (Status)) {
45 mNvVarsFileLibFsHandle = FsHandle;
46 }
47
48 return Status;
49 }
50
51 /**
52 Update non-volatile variables stored on the file system.
53
54 @return The EFI_STATUS while attempting to update the variable on
55 the connected file system.
56 @retval EFI_SUCCESS - The non-volatile variables were saved to the disk
57 @retval EFI_NOT_STARTED - A file system has not been connected
58
59 **/
60 EFI_STATUS
61 EFIAPI
62 UpdateNvVarsOnFileSystem (
63 )
64 {
65 if (mNvVarsFileLibFsHandle == NULL) {
66 //
67 // A file system had not been connected to the library.
68 //
69 return EFI_NOT_STARTED;
70 } else {
71 return SaveNvVarsToFs (mNvVarsFileLibFsHandle);
72 }
73 }