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