| 1478 | | AssertMsg(i <= RT_ELEMENTS(pSet->aEntries), ("%#x (%u)\n", i, i)); |
|---|
| 1479 | | pSet->cEntries = PGMMAPSET_CLOSED; |
|---|
| 1480 | | |
|---|
| 1481 | | /* release any pages we're referencing. */ |
|---|
| 1482 | | if (i != 0 && RT_LIKELY(i <= RT_ELEMENTS(pSet->aEntries))) |
|---|
| 1483 | | { |
|---|
| 1484 | | PPGMR0DYNMAP pThis = g_pPGMR0DynMap; |
|---|
| 1485 | | RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; |
|---|
| 1486 | | RTSpinlockAcquire(pThis->hSpinlock, &Tmp); |
|---|
| 1487 | | |
|---|
| 1488 | | while (i-- > 0) |
|---|
| 1489 | | { |
|---|
| 1490 | | uint32_t iPage = pSet->aEntries[i].iPage; |
|---|
| 1491 | | Assert(iPage < pThis->cPages); |
|---|
| 1492 | | int32_t cRefs = pSet->aEntries[i].cRefs; |
|---|
| 1493 | | Assert(cRefs > 0); |
|---|
| 1494 | | pgmR0DynMapReleasePageLocked(pThis, iPage, cRefs); |
|---|
| 1495 | | |
|---|
| 1496 | | pSet->aEntries[i].iPage = UINT16_MAX; |
|---|
| 1497 | | pSet->aEntries[i].cRefs = 0; |
|---|
| 1498 | | } |
|---|
| 1499 | | |
|---|
| 1500 | | Assert(pThis->cLoad <= pThis->cPages - pThis->cGuardPages); |
|---|
| 1501 | | RTSpinlockRelease(pThis->hSpinlock, &Tmp); |
|---|
| | 1485 | if (i != PGMMAPSET_CLOSED) |
|---|
| | 1486 | { |
|---|
| | 1487 | /* |
|---|
| | 1488 | * Close the set |
|---|
| | 1489 | */ |
|---|
| | 1490 | AssertMsg(i <= RT_ELEMENTS(pSet->aEntries), ("%#x (%u)\n", i, i)); |
|---|
| | 1491 | pSet->cEntries = PGMMAPSET_CLOSED; |
|---|
| | 1492 | |
|---|
| | 1493 | /* |
|---|
| | 1494 | * Release any pages it's referencing. |
|---|
| | 1495 | */ |
|---|
| | 1496 | if (i != 0 && RT_LIKELY(i <= RT_ELEMENTS(pSet->aEntries))) |
|---|
| | 1497 | { |
|---|
| | 1498 | PPGMR0DYNMAP pThis = g_pPGMR0DynMap; |
|---|
| | 1499 | RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; |
|---|
| | 1500 | RTSpinlockAcquire(pThis->hSpinlock, &Tmp); |
|---|
| | 1501 | |
|---|
| | 1502 | while (i-- > 0) |
|---|
| | 1503 | { |
|---|
| | 1504 | uint32_t iPage = pSet->aEntries[i].iPage; |
|---|
| | 1505 | Assert(iPage < pThis->cPages); |
|---|
| | 1506 | int32_t cRefs = pSet->aEntries[i].cRefs; |
|---|
| | 1507 | Assert(cRefs > 0); |
|---|
| | 1508 | pgmR0DynMapReleasePageLocked(pThis, iPage, cRefs); |
|---|
| | 1509 | |
|---|
| | 1510 | pSet->aEntries[i].iPage = UINT16_MAX; |
|---|
| | 1511 | pSet->aEntries[i].cRefs = 0; |
|---|
| | 1512 | } |
|---|
| | 1513 | |
|---|
| | 1514 | Assert(pThis->cLoad <= pThis->cPages - pThis->cGuardPages); |
|---|
| | 1515 | RTSpinlockRelease(pThis->hSpinlock, &Tmp); |
|---|
| | 1516 | } |
|---|