VirtualBox

Changeset 44619 in vbox


Ignore:
Timestamp:
Feb 10, 2013 8:26:28 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
83706
Message:

Nvram.cpp: Some refinements and fixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/Nvram.cpp

    r44591 r44619  
    6868
    6969
     70/*******************************************************************************
     71*   Defined Constants And Macros                                               *
     72*******************************************************************************/
     73/** The default NVRAM attribute value (non-volatile, boot servier access,
     74  runtime access). */
     75#define NVRAM_DEFAULT_ATTRIB        UINT32_C(0x7)
     76/** The CFGM overlay path of the NVRAM variables. */
     77#define NVRAM_CFGM_OVERLAY_PATH     "VBoxInternal/Devices/efi/0/LUN#0/Config/Vars"
     78
    7079/**
    7180 * Constructor/destructor
     
    111120    {
    112121        memcpy(pszStr, s_szPrefix, sizeof(s_szPrefix) - 1);
    113         int rc = RTBase64Encode(pvBuf, cbBuf, &pszStr[sizeof(s_szPrefix) - 1], cbBuf - sizeof(s_szPrefix) + 1, NULL);
     122        int rc = RTBase64Encode(pvBuf, cbBuf, &pszStr[sizeof(s_szPrefix) - 1], cbStr - sizeof(s_szPrefix) + 1, NULL);
    114123        if (RT_FAILURE(rc))
    115124        {
     
    135144        char    szExtraName[256];
    136145        size_t  offValueNm = RTStrPrintf(szExtraName, sizeof(szExtraName) - 16,
    137                                          "VBoxInternal/Devices/efi/0/LUN#0/Config/Vars/%4u/", idxVariable);
    138 
    139         char    szAttribs[32];
    140         RTStrPrintf(szAttribs, sizeof(szAttribs), "%#x", fAttributes);
     146                                         NVRAM_CFGM_OVERLAY_PATH "/%04u/", idxVariable);
    141147
    142148        char    szUuid[RTUUID_STR_LENGTH];
    143149        int rc2 = RTUuidToStr(pVendorUuid, szUuid, sizeof(szUuid)); AssertRC(rc2);
     150
     151        char    szAttribs[32];
     152        if (fAttributes != NVRAM_DEFAULT_ATTRIB)
     153            RTStrPrintf(szAttribs, sizeof(szAttribs), "%#x", fAttributes);
     154        else
     155            szAttribs[0] = '\0';
    144156
    145157        char   *pszValue = drvNvram_binaryToCfgmString(pbValue, cbValue);
     
    150162                "Name",     pszName,
    151163                "Uuid",     szUuid,
     164                "Value",    pszValue,
    152165                "Attribs",  szAttribs,
    153                 "Value",    pszValue,
    154166            };
    155167            for (unsigned i = 0; i < RT_ELEMENTS(apszTodo); i += 2)
    156168            {
     169                if (!apszTodo[i + 1][0])
     170                    continue;
     171
    157172                Assert(strlen(apszTodo[i]) < 16);
    158173                strcpy(szExtraName + offValueNm, apszTodo[i]);
     
    193208{
    194209    char   szExtraName[256];
    195     size_t offValue = RTStrPrintf(szExtraName, sizeof(szExtraName) - 16,
    196                                   "VBoxInternal/Devices/efi/0/LUN#0/Config/Vars/%s/", pszVarNodeNm);
    197     static const char *s_apszValueNames[] = { "Name", "Attribs", "Value" };
     210    size_t offValue = RTStrPrintf(szExtraName, sizeof(szExtraName) - 16, NVRAM_CFGM_OVERLAY_PATH "/%s/", pszVarNodeNm);
     211    static const char *s_apszValueNames[] = { "Name", "Uuid", "Value", "Attribs" };
    198212    for (unsigned i = 0; i < RT_ELEMENTS(s_apszValueNames); i++)
    199213    {
     
    257271    else
    258272    {
    259         pVarNode = CFGMR3GetFirstChild(pThis->pLastVarNode);
     273        pVarNode = CFGMR3GetFirstChild(pThis->pCfgVarRoot);
    260274        for (uint32_t i = 0; i < idxVariable && pVarNode; i++)
    261275            pVarNode = CFGMR3GetNextChild(pVarNode);
     
    281295    AssertRCReturn(rc, rc);
    282296
    283     rc = CFGMR3QueryU32(pVarNode, "Attribs", pfAttributes);
     297    rc = CFGMR3QueryU32Def(pVarNode, "Attribs", pfAttributes, NVRAM_DEFAULT_ATTRIB);
    284298    AssertRCReturn(rc, rc);
    285299
     
    290304    rc = CFGMR3QueryBytes(pVarNode, "Value", pbValue, cbValue);
    291305    AssertRCReturn(rc, rc);
     306    *pcbValue = cbValue;
    292307
    293308    return VINF_SUCCESS;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette