]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c
OvmfPkg/NvVarsFileLib: list "NvVarsFileLib.h" in the INF file
[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
5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include "NvVarsFileLib.h"\r
16#include <Library/DebugLib.h>\r
17#include <Library/NvVarsFileLib.h>\r
18\r
19EFI_HANDLE mNvVarsFileLibFsHandle = NULL;\r
20\r
21\r
22/**\r
23 Attempts to connect the NvVarsFileLib to the specified file system.\r
24\r
25 @param[in] FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid instance\r
26\r
27 @return The EFI_STATUS while attempting to connect the NvVarsFileLib\r
28 to the file system instance.\r
29 @retval EFI_SUCCESS - The given file system was connected successfully\r
30\r
31**/\r
32EFI_STATUS\r
33EFIAPI\r
34ConnectNvVarsToFileSystem (\r
35 IN EFI_HANDLE FsHandle\r
36 )\r
37{\r
38 EFI_STATUS Status;\r
39\r
40 //\r
41 // We might fail to load the variable, since the file system initially\r
42 // will not have the NvVars file.\r
43 //\r
44 LoadNvVarsFromFs (FsHandle);\r
45\r
46 //\r
47 // We must be able to save the variables successfully to the file system\r
48 // to have connected successfully.\r
49 //\r
50 Status = SaveNvVarsToFs (FsHandle);\r
51 if (!EFI_ERROR (Status)) {\r
52 mNvVarsFileLibFsHandle = FsHandle;\r
53 }\r
54\r
55 return Status;\r
56}\r
57\r
58\r
59/**\r
60 Update non-volatile variables stored on the file system.\r
61\r
62 @return The EFI_STATUS while attempting to update the variable on\r
63 the connected file system.\r
64 @retval EFI_SUCCESS - The non-volatile variables were saved to the disk\r
65 @retval EFI_NOT_STARTED - A file system has not been connected\r
66\r
67**/\r
68EFI_STATUS\r
69EFIAPI\r
70UpdateNvVarsOnFileSystem (\r
71 )\r
72{\r
73 if (mNvVarsFileLibFsHandle == NULL) {\r
74 //\r
75 // A file system had not been connected to the library.\r
76 //\r
77 return EFI_NOT_STARTED;\r
78 } else {\r
79 return SaveNvVarsToFs (mNvVarsFileLibFsHandle);\r
80 }\r
81}\r
82\r
83\r