Changeset 50518 in vbox for trunk/src/VBox/Devices/Graphics/HGSMI/HGSMIHost.cpp
- Timestamp:
- Feb 20, 2014 8:32:15 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/HGSMI/HGSMIHost.cpp
r50482 r50518 1327 1327 } 1328 1328 1329 static int hgsmiHostSaveMA(PSSMHANDLE pSSM, HGSMIMADATA *pMA) 1330 { 1331 int rc = SSMR3PutU32(pSSM, pMA->cBlocks); 1332 if (RT_SUCCESS(rc)) 1333 { 1334 HGSMIMABLOCK *pIter; 1335 RTListForEach(&pMA->listBlocks, pIter, HGSMIMABLOCK, nodeBlock) 1336 { 1337 SSMR3PutU32(pSSM, pIter->descriptor); 1338 } 1339 1340 rc = SSMR3PutU32(pSSM, pMA->cbMaxBlock); 1341 } 1342 1343 return rc; 1344 } 1345 1346 static int hgsmiHostLoadMA(PSSMHANDLE pSSM, uint32_t *pcBlocks, HGSMIOFFSET **ppaDescriptors, HGSMISIZE *pcbMaxBlock) 1347 { 1348 int rc = SSMR3GetU32(pSSM, pcBlocks); 1349 if (RT_SUCCESS(rc)) 1350 { 1351 HGSMIOFFSET *paDescriptors = NULL; 1352 if (*pcBlocks > 0) 1353 { 1354 paDescriptors = (HGSMIOFFSET *)RTMemAlloc(*pcBlocks * sizeof(HGSMIOFFSET)); 1355 if (paDescriptors) 1356 { 1357 uint32_t i; 1358 for (i = 0; i < *pcBlocks; ++i) 1359 { 1360 SSMR3GetU32(pSSM, &paDescriptors[i]); 1361 } 1362 } 1363 else 1364 { 1365 rc = VERR_NO_MEMORY; 1366 } 1367 } 1368 1369 if (RT_SUCCESS(rc)) 1370 { 1371 rc = SSMR3GetU32(pSSM, pcbMaxBlock); 1372 } 1373 1374 if (RT_SUCCESS(rc)) 1375 { 1376 *ppaDescriptors = paDescriptors; 1377 } 1378 else 1379 { 1380 RTMemFree(paDescriptors); 1381 } 1382 } 1383 1384 return rc; 1385 } 1386 1329 1387 int HGSMIHostSaveStateExec (PHGSMIINSTANCE pIns, PSSMHANDLE pSSM) 1330 1388 { … … 1332 1390 1333 1391 int rc; 1392 1393 SSMR3PutU32(pSSM, pIns->hostHeap.u32HeapType); 1334 1394 1335 1395 HGSMIOFFSET off = pIns->pHGFlags ? HGSMIPointerToOffset(&pIns->area, (const HGSMIBUFFERHEADER *)pIns->pHGFlags) : HGSMIOFFSET_VOID; 1336 1396 SSMR3PutU32 (pSSM, off); 1337 1397 1338 off = HGSMIHeapHandleLocationOffset(&pIns->hostHeap); 1398 off = pIns->hostHeap.u32HeapType == HGSMI_HEAP_TYPE_MA? 1399 0: 1400 HGSMIHeapHandleLocationOffset(&pIns->hostHeap); 1339 1401 rc = SSMR3PutU32 (pSSM, off); 1340 1402 if(off != HGSMIOFFSET_VOID) … … 1356 1418 hgsmiFIFOUnlock (pIns); 1357 1419 } 1420 1421 if (RT_SUCCESS(rc)) 1422 { 1423 if (pIns->hostHeap.u32HeapType == HGSMI_HEAP_TYPE_MA) 1424 { 1425 rc = hgsmiHostSaveMA(pSSM, &pIns->hostHeap.u.ma); 1426 } 1427 } 1358 1428 } 1359 1429 … … 1372 1442 int rc; 1373 1443 HGSMIOFFSET off; 1444 uint32_t u32HeapType = HGSMI_HEAP_TYPE_NULL; 1445 1446 if (u32Version >= VGA_SAVEDSTATE_VERSION_HGSMIMA) 1447 { 1448 rc = SSMR3GetU32(pSSM, &u32HeapType); 1449 AssertRCReturn(rc, rc); 1450 } 1451 1374 1452 rc = SSMR3GetU32(pSSM, &off); 1375 1453 AssertRCReturn(rc, rc); … … 1381 1459 if(off != HGSMIOFFSET_VOID) 1382 1460 { 1461 /* There is a saved heap. */ 1462 if (u32HeapType == HGSMI_HEAP_TYPE_NULL) 1463 { 1464 u32HeapType = u32Version > VGA_SAVEDSTATE_VERSION_HOST_HEAP? 1465 HGSMI_HEAP_TYPE_OFFSET: 1466 HGSMI_HEAP_TYPE_POINTER; 1467 } 1468 1383 1469 HGSMIOFFSET offHeap; 1384 1470 SSMR3GetU32(pSSM, &offHeap); … … 1388 1474 rc = SSMR3GetU64(pSSM, &oldMem); 1389 1475 AssertRCReturn(rc, rc); 1390 1391 rc = hgsmiHostHeapLock (pIns);1392 if (RT_SUCCESS (rc))1393 {1394 Assert(!pIns->hostHeap.cRefs);1395 pIns->hostHeap.cRefs = 0;1396 1397 rc = HGSMIHeapRelocate(&pIns->hostHeap,1398 u32Version > VGA_SAVEDSTATE_VERSION_HOST_HEAP?1399 HGSMI_HEAP_TYPE_OFFSET:1400 HGSMI_HEAP_TYPE_POINTER,1401 pIns->area.pu8Base+offHeap,1402 off,1403 uintptr_t(pIns->area.pu8Base) - uintptr_t(oldMem),1404 cbHeap,1405 offHeap,1406 &g_hgsmiEnv);1407 1408 hgsmiHostHeapUnlock (pIns);1409 }1410 1476 1411 1477 if (RT_SUCCESS(rc)) … … 1425 1491 1426 1492 hgsmiFIFOUnlock (pIns); 1493 } 1494 } 1495 1496 if (RT_SUCCESS(rc)) 1497 { 1498 if (u32HeapType == HGSMI_HEAP_TYPE_MA) 1499 { 1500 uint32_t cBlocks = 0; 1501 HGSMISIZE cbMaxBlock = 0; 1502 HGSMIOFFSET *paDescriptors = NULL; 1503 rc = hgsmiHostLoadMA(pSSM, &cBlocks, &paDescriptors, &cbMaxBlock); 1504 if (RT_SUCCESS(rc)) 1505 { 1506 rc = HGSMIHeapRestoreMA(&pIns->hostHeap, 1507 pIns->area.pu8Base+offHeap, 1508 cbHeap, 1509 offHeap, 1510 cBlocks, 1511 paDescriptors, 1512 cbMaxBlock, 1513 &g_hgsmiEnv); 1514 1515 RTMemFree(paDescriptors); 1516 } 1517 } 1518 else if ( u32HeapType == HGSMI_HEAP_TYPE_OFFSET 1519 || u32HeapType == HGSMI_HEAP_TYPE_POINTER) 1520 { 1521 rc = hgsmiHostHeapLock (pIns); 1522 if (RT_SUCCESS (rc)) 1523 { 1524 Assert(!pIns->hostHeap.cRefs); 1525 pIns->hostHeap.cRefs = 0; 1526 1527 rc = HGSMIHeapRelocate(&pIns->hostHeap, 1528 u32HeapType, 1529 pIns->area.pu8Base+offHeap, 1530 off, 1531 uintptr_t(pIns->area.pu8Base) - uintptr_t(oldMem), 1532 cbHeap, 1533 offHeap); 1534 1535 hgsmiHostHeapUnlock (pIns); 1536 } 1427 1537 } 1428 1538 } … … 1748 1858 #endif 1749 1859 1860 HGSMIHeapDestroy(&pIns->hostHeap); 1861 1750 1862 HGSMIHeapSetupUninitialized(&pIns->hostHeap); 1751 1863 … … 1759 1871 if (pIns) 1760 1872 { 1873 HGSMIHeapDestroy(&pIns->hostHeap); 1874 1761 1875 if (RTCritSectIsInitialized (&pIns->hostHeapCritSect)) 1762 1876 {
Note:
See TracChangeset
for help on using the changeset viewer.