Changeset 43157 in vbox
- Timestamp:
- Sep 4, 2012 9:00:28 AM (12 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/DevOVMF.cpp
r43146 r43157 56 56 #include <Common/PiFirmwareVolume.h> 57 57 #include <Common/PiFirmwareFile.h> 58 59 #define EFI_SSM_VERSION 1 58 60 /******************************************************************************* 59 61 * Structures and Typedefs * … … 61 63 typedef struct { 62 64 RTLISTNODE List; 65 int idxVariable; 63 66 RTUUID uuid; 64 67 char szVariableName[EFI_VARIABLE_NAME_MAX]; … … 70 73 71 74 typedef PEFIVAR *PPEFIVAR; 75 76 typedef struct { 77 EFIVAROP enmOp; 78 uint32_t u32Status; 79 uint32_t idxOpBuffer; 80 EFIVAR OperationVarOp; 81 int cNvramVaraibles; 82 int iNvramLastIndex; 83 RTLISTANCHOR NvramVariableList; 84 int idxCurrentVar; 85 PEFIVAR pCurrentVarOp; 86 } NVRAMDESC; 72 87 73 88 typedef struct DEVEFI … … 141 156 uint32_t u32UgaHorisontal; 142 157 uint32_t u32UgaVertical; 143 struct { 144 EFIVAROP enmOp; 145 uint32_t u32Status; 146 uint32_t idxOpBuffer; 147 EFIVAR OperationVarOp; 148 int cNvramVaraibles; 149 RTLISTANCHOR NvramVariableList; 150 PEFIVAR pCurrentVarOp; 151 } NVRAM; 158 NVRAMDESC NVRAM; 152 159 struct { 153 160 PPDMIBASE pDrvBase; … … 158 165 typedef DEVEFI *PDEVEFI; 159 166 167 static SSMFIELD const g_aEfiNvramDescField[] = 168 { 169 SSMFIELD_ENTRY (NVRAMDESC, enmOp), 170 SSMFIELD_ENTRY (NVRAMDESC, u32Status), 171 SSMFIELD_ENTRY (NVRAMDESC, idxOpBuffer), 172 SSMFIELD_ENTRY (NVRAMDESC, OperationVarOp), 173 SSMFIELD_ENTRY (NVRAMDESC, cNvramVaraibles), 174 SSMFIELD_ENTRY (NVRAMDESC, iNvramLastIndex), 175 SSMFIELD_ENTRY_IGNORE (NVRAMDESC, NvramVariableList), 176 SSMFIELD_ENTRY (NVRAMDESC, idxCurrentVar), 177 SSMFIELD_ENTRY_IGNORE (NVRAMDESC, pCurrentVarOp), 178 SSMFIELD_ENTRY_TERM() 179 }; 180 181 static SSMFIELD const g_aEfiVariableDescFields[] = 182 { 183 SSMFIELD_ENTRY_IGNORE (EFIVAR, List), 184 SSMFIELD_ENTRY (EFIVAR, idxVariable), 185 SSMFIELD_ENTRY (EFIVAR, uuid), 186 SSMFIELD_ENTRY (EFIVAR, szVariableName), 187 SSMFIELD_ENTRY (EFIVAR, cbVariableName), 188 SSMFIELD_ENTRY (EFIVAR, au8Value), 189 SSMFIELD_ENTRY (EFIVAR, cbValue), 190 SSMFIELD_ENTRY (EFIVAR, u32Attribute), 191 SSMFIELD_ENTRY_TERM() 192 }; 193 160 194 /** 161 195 * Write to CMOS memory. … … 169 203 int rc = PDMDevHlpCMOSWrite(pDevIns, off, u32Val); 170 204 AssertRC(rc); 205 } 206 207 DECLINLINE(void) nvramFlushDeviceVariableList(PDEVEFI pThis) 208 { 209 PEFIVAR pEfiVar = NULL; 210 while (!RTListIsEmpty(&pThis->NVRAM.NvramVariableList)) 211 { 212 pEfiVar = RTListNodeGetNext(&pThis->NVRAM.NvramVariableList, EFIVAR, List); 213 RTListNodeRemove(&pEfiVar->List); 214 RTMemFree(pEfiVar); 215 } 171 216 } 172 217 … … 340 385 return *((uint8_t*)&value+pThis->iInfoPosition); 341 386 } 387 388 static DECLCALLBACK(int) efiSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 389 { 390 int rc = VINF_SUCCESS; 391 PEFIVAR pEfiVar = NULL; 392 LogFlowFuncEnter(); 393 PDEVEFI pThis = PDMINS_2_DATA(pDevIns, PDEVEFI); 394 SSMR3PutStructEx(pSSM, &pThis->NVRAM, sizeof(NVRAMDESC), 0, g_aEfiNvramDescField, NULL); 395 SSMR3PutStructEx(pSSM, &pThis->NVRAM.OperationVarOp, sizeof(EFIVAR), 0, g_aEfiVariableDescFields, NULL); 396 RTListForEach((PRTLISTNODE)&pThis->NVRAM.NvramVariableList, pEfiVar, EFIVAR, List) 397 { 398 SSMR3PutStructEx(pSSM, pEfiVar, sizeof(EFIVAR), 0, g_aEfiVariableDescFields, NULL); 399 } 400 LogFlowFuncLeaveRC(rc); 401 return rc; 402 } 403 404 static DECLCALLBACK(int) efiLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 405 { 406 int rc = VINF_SUCCESS; 407 NOREF(uPass); 408 LogFlowFunc(("ENTER: uVersion:%d, uPass:%d\n", uVersion, uPass)); 409 PDEVEFI pThis = PDMINS_2_DATA(pDevIns, PDEVEFI); 410 if (uPass != SSM_PASS_FINAL) 411 return rc; 412 /* we should clean up the loaded values */ 413 nvramFlushDeviceVariableList(pThis); 414 if (uVersion == 1) 415 { 416 SSMR3GetStructEx(pSSM, &pThis->NVRAM, sizeof(NVRAMDESC), 0, g_aEfiNvramDescField, NULL); 417 SSMR3GetStructEx(pSSM, &pThis->NVRAM.OperationVarOp, sizeof(EFIVAR), 0, g_aEfiVariableDescFields, NULL); 418 int idxVariable = 0; 419 Assert(RTListIsEmpty(&pThis->NVRAM.NvramVariableList)); 420 RTListInit(&pThis->NVRAM.NvramVariableList); 421 for (idxVariable = 0; idxVariable < pThis->NVRAM.cNvramVaraibles; ++idxVariable) 422 { 423 PEFIVAR pEfiVar = (PEFIVAR)RTMemAllocZ(sizeof(EFIVAR)); 424 AssertPtrReturn(pEfiVar, VERR_NO_MEMORY); 425 SSMR3GetStructEx(pSSM, pEfiVar, sizeof(EFIVAR), 0, g_aEfiVariableDescFields, NULL); 426 RTListInit(&pEfiVar->List); 427 RTListAppend(&pThis->NVRAM.NvramVariableList, &pEfiVar->List); 428 if (pThis->NVRAM.idxCurrentVar == pEfiVar->idxVariable) 429 pThis->NVRAM.pCurrentVarOp = pEfiVar; 430 } 431 } 432 LogFlowFuncLeaveRC(rc); 433 return rc; 434 } 435 436 #if 0 437 static DECLCALLBACK(int) efiLoadDone(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 438 { 439 int rc = VINF_SUCCESS; 440 PDEVEFI pThis = PDMINS_2_DATA(pDevIns, PDEVEFI); 441 LogFlowFuncEnter(); 442 if (RTListIsEmpty(&pThis->NVRAM.NvramVariableList)) 443 nvramLoad(pThis); 444 LogFlowFuncLeaveRC(rc); 445 return rc; 446 } 447 #endif 342 448 343 449 /** … … 598 704 pThis->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_OK; 599 705 pThis->NVRAM.pCurrentVarOp = pEfiVar; 706 pThis->NVRAM.idxCurrentVar = pEfiVar->idxVariable; 600 707 LogFlowFunc(("OperationVar: au8Value:%.*Rhxs\n", 601 708 pThis->NVRAM.OperationVarOp.cbValue, … … 663 770 pThis->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_OK; 664 771 pThis->NVRAM.cNvramVaraibles++; 772 pEfiVar->idxVariable = pThis->NVRAM.iNvramLastIndex; 773 pThis->NVRAM.iNvramLastIndex++; 665 774 } 666 775 } … … 825 934 PDEVEFI pThis = PDMINS_2_DATA(pDevIns, PDEVEFI); 826 935 nvramStore(pThis); 827 PEFIVAR pEfiVar = NULL; 828 while (!RTListIsEmpty(&pThis->NVRAM.NvramVariableList)) 829 { 830 pEfiVar = RTListNodeGetNext(&pThis->NVRAM.NvramVariableList, EFIVAR, List); 831 RTListNodeRemove(&pEfiVar->List); 832 RTMemFree(pEfiVar); 833 } 936 nvramFlushDeviceVariableList(pThis); 834 937 835 938 /* … … 1196 1299 /* NVRAM processing */ 1197 1300 pThis->Lun0.IBase.pfnQueryInterface = devEfi_pfnQueryInterface; 1301 1302 #if 0 1303 rc = PDMDevHlpSSMRegisterEx(pDevIns, EFI_SSM_VERSION, sizeof(*pThis), NULL /*pszBefore*/, 1304 NULL /*pfnLivePrep*/, NULL /*pfnLiveExec*/, NULL /*pfnLiveDone*/, 1305 NULL /*pfnSavePrep*/, efiSaveExec, NULL /*pfnSaveDone*/, 1306 NULL /*pfnLoadPrep*/, efiLoadExec, efiLoadDone); 1307 #else 1308 rc = PDMDevHlpSSMRegister(pDevIns, EFI_SSM_VERSION, sizeof(*pThis), efiSaveExec, efiLoadExec); 1309 #endif 1310 AssertRCReturn(rc, rc); 1311 1198 1312 rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThis->Lun0.IBase, &pThis->Lun0.pDrvBase, "NvramStorage"); 1199 1313 if (RT_FAILURE(rc)) … … 1203 1317 AssertPtrReturn(pThis->Lun0.pNvramDown, VERR_PDM_MISSING_INTERFACE_BELOW); 1204 1318 1319 nvramLoad(pThis); 1205 1320 /* 1206 1321 * Get boot args. -
trunk/src/VBox/Main/src-client/Nvram.cpp
r43142 r43157 179 179 RTUuidFromStr(pVendorUuid, Utf8Str(bstrValue).c_str()); 180 180 181 #if 0 181 182 RT_ZERO(szExtraDataKey); 182 183 RTStrPrintf(szExtraDataKey, 256, "VBoxInternal/Devices/efi/0/LUN#0/Config/NVRAM/%d/VariableValueLength", idxVariable); 183 184 hrc = pThis->pNvram->getParent()->machine()->GetExtraData(Bstr(szExtraDataKey).raw(), bstrValue.asOutParam()); 184 185 *pcbValue = Utf8Str(bstrValue).toUInt32(); 186 #endif 185 187 186 188 RT_ZERO(szExtraDataKey);
Note:
See TracChangeset
for help on using the changeset viewer.