1 | /* $Id: NvramStoreImpl.h 94514 2022-04-07 13:49:30Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox COM NVRAM store class implementation
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2021-2022 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef MAIN_INCLUDED_NvramStoreImpl_h
|
---|
19 | #define MAIN_INCLUDED_NvramStoreImpl_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | #include "NvramStoreWrap.h"
|
---|
25 | #include <VBox/vmm/pdmdrv.h>
|
---|
26 |
|
---|
27 | #ifdef VBOX_COM_INPROC
|
---|
28 | class Console;
|
---|
29 | #else
|
---|
30 | class GuestOSType;
|
---|
31 |
|
---|
32 | namespace settings
|
---|
33 | {
|
---|
34 | struct NvramSettings;
|
---|
35 | }
|
---|
36 | #endif
|
---|
37 |
|
---|
38 | class ATL_NO_VTABLE NvramStore :
|
---|
39 | public NvramStoreWrap
|
---|
40 | {
|
---|
41 | public:
|
---|
42 |
|
---|
43 | DECLARE_COMMON_CLASS_METHODS(NvramStore)
|
---|
44 |
|
---|
45 | HRESULT FinalConstruct();
|
---|
46 | void FinalRelease();
|
---|
47 |
|
---|
48 | // public initializer/uninitializer for internal purposes only
|
---|
49 | #ifdef VBOX_COM_INPROC
|
---|
50 | HRESULT init(Console *aParent, const com::Utf8Str &strNonVolatileStorageFile);
|
---|
51 | #else
|
---|
52 | HRESULT init(Machine *parent);
|
---|
53 | HRESULT init(Machine *parent, NvramStore *that);
|
---|
54 | HRESULT initCopy(Machine *parent, NvramStore *that);
|
---|
55 | #endif
|
---|
56 | void uninit();
|
---|
57 |
|
---|
58 | // public methods for internal purposes only
|
---|
59 | #ifndef VBOX_COM_INPROC
|
---|
60 | HRESULT i_loadSettings(const settings::NvramSettings &data);
|
---|
61 | HRESULT i_saveSettings(settings::NvramSettings &data);
|
---|
62 | #endif
|
---|
63 |
|
---|
64 | #ifdef VBOX_COM_INPROC
|
---|
65 | static const PDMDRVREG DrvReg;
|
---|
66 | #else
|
---|
67 | void i_rollback();
|
---|
68 | void i_commit();
|
---|
69 | void i_copyFrom(NvramStore *aThat);
|
---|
70 | HRESULT i_applyDefaults(GuestOSType *aOSType);
|
---|
71 | #endif
|
---|
72 |
|
---|
73 | com::Utf8Str i_getNonVolatileStorageFile();
|
---|
74 | void i_updateNonVolatileStorageFile(const com::Utf8Str &aNonVolatileStorageFile);
|
---|
75 |
|
---|
76 | int i_loadStore(const char *pszPath);
|
---|
77 | int i_saveStore(void);
|
---|
78 |
|
---|
79 | #ifndef VBOX_COM_INPROC
|
---|
80 | HRESULT i_retainUefiVarStore(PRTVFS phVfs, bool fReadonly);
|
---|
81 | HRESULT i_releaseUefiVarStore(RTVFS hVfs);
|
---|
82 | #endif
|
---|
83 |
|
---|
84 | private:
|
---|
85 |
|
---|
86 | // Wrapped NVRAM store properties
|
---|
87 | HRESULT getNonVolatileStorageFile(com::Utf8Str &aNonVolatileStorageFile);
|
---|
88 | HRESULT getUefiVariableStore(ComPtr<IUefiVariableStore> &aUefiVarStore);
|
---|
89 |
|
---|
90 | // Wrapped NVRAM store members
|
---|
91 | HRESULT initUefiVariableStore(ULONG aSize);
|
---|
92 |
|
---|
93 | int i_loadStoreFromTar(RTVFSFSSTREAM hVfsFssTar);
|
---|
94 | int i_saveStoreAsTar(const char *pszPath);
|
---|
95 |
|
---|
96 | #ifdef VBOX_COM_INPROC
|
---|
97 | static DECLCALLBACK(int) i_SsmSaveExec(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM);
|
---|
98 | static DECLCALLBACK(int) i_SsmLoadExec(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
|
---|
99 |
|
---|
100 | static DECLCALLBACK(int) i_nvramStoreQuerySize(PPDMIVFSCONNECTOR pInterface, const char *pszNamespace, const char *pszPath,
|
---|
101 | uint64_t *pcb);
|
---|
102 | static DECLCALLBACK(int) i_nvramStoreReadAll(PPDMIVFSCONNECTOR pInterface, const char *pszNamespace, const char *pszPath,
|
---|
103 | void *pvBuf, size_t cbRead);
|
---|
104 | static DECLCALLBACK(int) i_nvramStoreWriteAll(PPDMIVFSCONNECTOR pInterface, const char *pszNamespace, const char *pszPath,
|
---|
105 | const void *pvBuf, size_t cbWrite);
|
---|
106 | static DECLCALLBACK(int) i_nvramStoreDelete(PPDMIVFSCONNECTOR pInterface, const char *pszNamespace, const char *pszPath);
|
---|
107 | static DECLCALLBACK(void *) i_drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
|
---|
108 | static DECLCALLBACK(int) i_drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
|
---|
109 | static DECLCALLBACK(void) i_drvDestruct(PPDMDRVINS pDrvIns);
|
---|
110 | #endif
|
---|
111 |
|
---|
112 | struct Data; // opaque data struct, defined in NvramStoreImpl.cpp
|
---|
113 | Data *m;
|
---|
114 | };
|
---|
115 |
|
---|
116 | #endif /* !MAIN_INCLUDED_NvramStoreImpl_h */
|
---|
117 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|