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