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