Changeset 45024 in vbox for trunk/src/VBox
- Timestamp:
- Mar 13, 2013 3:58:02 PM (12 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/DevEFI.cpp
r44820 r45024 1383 1383 } 1384 1384 1385 /** 1386 * Reset notification. 1387 * 1388 * @returns VBox status. 1389 * @param pDevIns The device instance data. 1385 1386 /** 1387 * @interface_method_impl{PDMDEVREG,pfnMemSetup} 1388 */ 1389 static DECLCALLBACK(void) efiMemSetup(PPDMDEVINS pDevIns, PDMDEVMEMSETUPCTX enmCtx) 1390 { 1391 PDEVEFI pThis = PDMINS_2_DATA(pDevIns, PDEVEFI); 1392 1393 /* 1394 * Plan some structures in RAM. 1395 */ 1396 FwCommonPlantSmbiosAndDmiHdrs(pDevIns, pThis->cbDmiTables, pThis->cNumDmiTables); 1397 if (pThis->u8IOAPIC) 1398 FwCommonPlantMpsFloatPtr(pDevIns); 1399 1400 /* 1401 * Re-shadow the Firmware Volume and make it RAM/RAM. 1402 */ 1403 uint32_t cPages = RT_ALIGN_64(pThis->cbEfiRom, PAGE_SIZE) >> PAGE_SHIFT; 1404 RTGCPHYS GCPhys = pThis->GCLoadAddress; 1405 while (cPages > 0) 1406 { 1407 uint8_t abPage[PAGE_SIZE]; 1408 1409 /* Read the (original) ROM page and write it back to the RAM page. */ 1410 int rc = PDMDevHlpROMProtectShadow(pDevIns, GCPhys, PAGE_SIZE, PGMROMPROT_READ_ROM_WRITE_RAM); 1411 AssertLogRelRC(rc); 1412 1413 rc = PDMDevHlpPhysRead(pDevIns, GCPhys, abPage, PAGE_SIZE); 1414 AssertLogRelRC(rc); 1415 if (RT_FAILURE(rc)) 1416 memset(abPage, 0xcc, sizeof(abPage)); 1417 1418 rc = PDMDevHlpPhysWrite(pDevIns, GCPhys, abPage, PAGE_SIZE); 1419 AssertLogRelRC(rc); 1420 1421 /* Switch to the RAM/RAM mode. */ 1422 rc = PDMDevHlpROMProtectShadow(pDevIns, GCPhys, PAGE_SIZE, PGMROMPROT_READ_RAM_WRITE_RAM); 1423 AssertLogRelRC(rc); 1424 1425 /* Advance */ 1426 GCPhys += PAGE_SIZE; 1427 cPages--; 1428 } 1429 } 1430 1431 1432 /** 1433 * @interface_method_impl{PDMDEVREG,pfnReset} 1390 1434 */ 1391 1435 static DECLCALLBACK(void) efiReset(PPDMDEVINS pDevIns) 1392 1436 { 1393 1437 PDEVEFI pThis = PDMINS_2_DATA(pDevIns, PDEVEFI); 1394 int rc;1395 1438 1396 1439 LogFlow(("efiReset\n")); … … 1403 1446 pThis->iPanicMsg = 0; 1404 1447 pThis->szPanicMsg[0] = '\0'; 1405 1406 /* 1407 * Plan some structures in RAM. 1408 */ 1409 FwCommonPlantSmbiosAndDmiHdrs(pDevIns, pThis->cbDmiTables, pThis->cNumDmiTables); 1410 if (pThis->u8IOAPIC) 1411 FwCommonPlantMpsFloatPtr(pDevIns); 1412 1413 /* 1414 * Re-shadow the Firmware Volume and make it RAM/RAM. 1415 */ 1416 uint32_t cPages = RT_ALIGN_64(pThis->cbEfiRom, PAGE_SIZE) >> PAGE_SHIFT; 1417 RTGCPHYS GCPhys = pThis->GCLoadAddress; 1418 while (cPages > 0) 1419 { 1420 uint8_t abPage[PAGE_SIZE]; 1421 1422 /* Read the (original) ROM page and write it back to the RAM page. */ 1423 rc = PDMDevHlpROMProtectShadow(pDevIns, GCPhys, PAGE_SIZE, PGMROMPROT_READ_ROM_WRITE_RAM); 1424 AssertLogRelRC(rc); 1425 1426 rc = PDMDevHlpPhysRead(pDevIns, GCPhys, abPage, PAGE_SIZE); 1427 AssertLogRelRC(rc); 1428 if (RT_FAILURE(rc)) 1429 memset(abPage, 0xcc, sizeof(abPage)); 1430 1431 rc = PDMDevHlpPhysWrite(pDevIns, GCPhys, abPage, PAGE_SIZE); 1432 AssertLogRelRC(rc); 1433 1434 /* Switch to the RAM/RAM mode. */ 1435 rc = PDMDevHlpROMProtectShadow(pDevIns, GCPhys, PAGE_SIZE, PGMROMPROT_READ_RAM_WRITE_RAM); 1436 AssertLogRelRC(rc); 1437 1438 /* Advance */ 1439 GCPhys += PAGE_SIZE; 1440 cPages--; 1441 } 1442 } 1448 } 1449 1443 1450 1444 1451 /** … … 1687 1694 return rc; 1688 1695 } 1696 1689 1697 1690 1698 /** … … 1982 1990 /* pfnRelocate */ 1983 1991 NULL, 1984 /* pfn IOCtl*/1985 NULL,1992 /* pfnMemSetup */ 1993 efiMemSetup, 1986 1994 /* pfnPowerOn */ 1987 1995 NULL, -
trunk/src/VBox/Devices/PC/DevACPI.cpp
r44626 r45024 2805 2805 2806 2806 /** 2807 * @interface_method_impl{PDMDEVREG,pfnMemSetup} 2808 */ 2809 static DECLCALLBACK(void) acpiR3MemSetup(PPDMDEVINS pDevIns, PDMDEVMEMSETUPCTX enmCtx) 2810 { 2811 ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *); 2812 acpiR3PlantTables(pThis); 2813 } 2814 2815 /** 2807 2816 * @interface_method_impl{PDMDEVREG,pfnReset} 2808 2817 */ … … 2826 2835 /** @todo Should we really reset PM base? */ 2827 2836 acpiR3UpdatePmHandlers(pThis, PM_PORT_BASE); 2828 2829 acpiR3PlantTables(pThis);2830 2837 } 2831 2838 … … 3217 3224 * Plant ACPI tables. 3218 3225 */ 3226 /** @todo Part of this is redone by acpiR3MemSetup, we only need to init the 3227 * au8RSDPPage here. However, there should be no harm in doing it 3228 * twice, so the lazy bird is taking the quick way out for now. */ 3219 3229 RTGCPHYS32 GCPhysRsdp = apicR3FindRsdpSpace(); 3220 3230 if (!GCPhysRsdp) … … 3372 3382 /* pfnRelocate */ 3373 3383 acpiR3Relocate, 3374 /* pfn IOCtl*/3375 NULL,3384 /* pfnMemSetup */ 3385 acpiR3MemSetup, 3376 3386 /* pfnPowerOn */ 3377 3387 NULL, -
trunk/src/VBox/Devices/PC/DevPcBios.cpp
r44821 r45024 765 765 766 766 /** 767 * @interface_method_impl{PDMDEVREG,pfn Reset}768 */ 769 static DECLCALLBACK(void) pcbios Reset(PPDMDEVINS pDevIns)767 * @interface_method_impl{PDMDEVREG,pfnMemSetup} 768 */ 769 static DECLCALLBACK(void) pcbiosMemSetup(PPDMDEVINS pDevIns, PDMDEVMEMSETUPCTX enmCtx) 770 770 { 771 771 PDEVPCBIOS pThis = PDMINS_2_DATA(pDevIns, PDEVPCBIOS); 772 LogFlow(("pcbios Reset:\n"));772 LogFlow(("pcbiosMemSetup:\n")); 773 773 774 774 if (pThis->u8IOAPIC) … … 1423 1423 pThis->uBootDelay = 15; 1424 1424 1425 /*1426 * Call reset plant tables and shadow the PXE ROM.1427 */1428 pcbiosReset(pDevIns);1429 1430 1425 return VINF_SUCCESS; 1431 1426 } … … 1462 1457 NULL, 1463 1458 /* pfnIOCtl */ 1464 NULL,1459 pcbiosMemSetup, 1465 1460 /* pfnPowerOn */ 1466 1461 NULL, 1467 1462 /* pfnReset */ 1468 pcbiosReset,1463 NULL, 1469 1464 /* pfnSuspend */ 1470 1465 NULL, -
trunk/src/VBox/VMM/VMMR3/PDM.cpp
r44399 r45024 1507 1507 1508 1508 LogFlow(("PDMR3Reset: returns void\n")); 1509 } 1510 1511 1512 /** 1513 * This function will tell all the devices to setup up their memory structures 1514 * after VM construction and after VM reset. 1515 * 1516 * @param pVM Pointer to the VM. 1517 * @param fAtReset Indicates the context, after reset if @c true or after 1518 * construction if @c false. 1519 */ 1520 VMMR3_INT_DECL(void) PDMR3MemSetup(PVM pVM, bool fAtReset) 1521 { 1522 LogFlow(("PDMR3MemSetup: fAtReset=%RTbool\n", fAtReset)); 1523 PDMDEVMEMSETUPCTX const enmCtx = fAtReset ? PDMDEVMEMSETUPCTX_AFTER_RESET : PDMDEVMEMSETUPCTX_AFTER_CONSTRUCTION; 1524 1525 /* 1526 * Iterate thru the device instances and work the callback. 1527 */ 1528 for (PPDMDEVINS pDevIns = pVM->pdm.s.pDevInstances; pDevIns; pDevIns = pDevIns->Internal.s.pNextR3) 1529 if (pDevIns->pReg->pfnMemSetup) 1530 { 1531 PDMCritSectEnter(pDevIns->pCritSectRoR3, VERR_IGNORED); 1532 pDevIns->pReg->pfnMemSetup(pDevIns, enmCtx); 1533 PDMCritSectLeave(pDevIns->pCritSectRoR3); 1534 } 1535 1536 LogFlow(("PDMR3MemSetup: returns void\n")); 1509 1537 } 1510 1538 -
trunk/src/VBox/VMM/VMMR3/PGM.cpp
r44730 r45024 2503 2503 * @param pVM Pointer to the VM. 2504 2504 */ 2505 VMMR3 DECL(void) PGMR3Reset(PVM pVM)2505 VMMR3_INT_DECL(void) PGMR3Reset(PVM pVM) 2506 2506 { 2507 2507 int rc; … … 2581 2581 } 2582 2582 2583 /*2584 * Reset (zero) RAM and shadow ROM pages.2585 */2586 rc = pgmR3PhysRamReset(pVM);2587 if (RT_SUCCESS(rc))2588 rc = pgmR3PhysRomReset(pVM);2589 2590 2591 2583 pgmUnlock(pVM); 2592 2584 AssertReleaseRC(rc); 2585 } 2586 2587 2588 /** 2589 * Memory setup after VM construction or reset. 2590 * 2591 * @param pVM Pointer to the VM. 2592 * @param fAtReset Indicates the context, after reset if @c true or after 2593 * construction if @c false. 2594 */ 2595 VMMR3_INT_DECL(void) PGMR3MemSetup(PVM pVM, bool fAtReset) 2596 { 2597 if (fAtReset) 2598 { 2599 pgmLock(pVM); 2600 2601 int rc = pgmR3PhysRamZeroAll(pVM); AssertLogRelRC(rc); 2602 rc = pgmR3PhysRomReset(pVM); AssertLogRelRC(rc); 2603 2604 pgmUnlock(pVM); 2605 } 2593 2606 } 2594 2607 -
trunk/src/VBox/VMM/VMMR3/PGMPhys.cpp
r44528 r45024 1885 1885 1886 1886 /** 1887 * Resets (zeros) the RAM.1887 * Resets the physical memory state. 1888 1888 * 1889 1889 * ASSUMES that the caller owns the PGM lock. … … 1910 1910 pVM->pgm.s.cBalloonedPages = 0; 1911 1911 1912 return VINF_SUCCESS; 1913 } 1914 1915 1916 /** 1917 * Resets (zeros) the RAM after all devices and components have been reset. 1918 * 1919 * ASSUMES that the caller owns the PGM lock. 1920 * 1921 * @returns VBox status code. 1922 * @param pVM Pointer to the VM. 1923 */ 1924 int pgmR3PhysRamZeroAll(PVM pVM) 1925 { 1926 PGM_LOCK_ASSERT_OWNER(pVM); 1927 1912 1928 /* 1913 1929 * We batch up pages that should be freed instead of calling GMM for … … 1916 1932 uint32_t cPendingPages = 0; 1917 1933 PGMMFREEPAGESREQ pReq; 1918 rc = GMMR3FreePagesPrepare(pVM, &pReq, PGMPHYS_FREE_PAGE_BATCH_SIZE, GMMACCOUNT_BASE);1934 int rc = GMMR3FreePagesPrepare(pVM, &pReq, PGMPHYS_FREE_PAGE_BATCH_SIZE, GMMACCOUNT_BASE); 1919 1935 AssertLogRelRCReturn(rc, rc); 1920 1936 … … 2043 2059 } 2044 2060 GMMR3FreePagesCleanup(pReq); 2045 2046 2061 return VINF_SUCCESS; 2047 2062 } … … 3552 3567 3553 3568 /** 3554 * Called by PGMR3 Reset to reset the shadow, switch to the virgin,3555 * and verifythat the virgin part is untouched.3569 * Called by PGMR3MemSetup to reset the shadow, switch to the virgin, and verify 3570 * that the virgin part is untouched. 3556 3571 * 3557 3572 * This is done after the normal memory has been cleared. -
trunk/src/VBox/VMM/VMMR3/VM.cpp
r45006 r45024 964 964 #endif 965 965 if (RT_SUCCESS(rc)) 966 { 967 PGMR3MemSetup(pVM, false /*fAtReset*/); 968 PDMR3MemSetup(pVM, false /*fAtReset*/); 969 } 970 if (RT_SUCCESS(rc)) 966 971 rc = vmR3InitDoCompleted(pVM, VMINITCOMPLETED_RING3); 967 972 if (RT_SUCCESS(rc)) … … 2687 2692 PATMR3Reset(pVM); 2688 2693 CSAMR3Reset(pVM); 2689 PGMR3Reset(pVM); /* We clear VM RAM in PGMR3Reset. It's vital PDMR3Reset is executed2690 * _afterwards_. E.g. ACPI sets up RAM tables during init/reset. */2691 /** @todo PGMR3Reset should be called after PDMR3Reset really, because we'll trash OS <-> hardware2692 * communication structures residing in RAM when done in the other order. I.e. the device must be2693 * quiesced first, then we clear the memory and plan tables. Probably have to make these things2694 * explicit in some way, some memory setup pass or something.2695 * (Example: DevAHCI may assert if memory is zeroed before it has read the FIS.)2696 *2697 * @bugref{4467}2698 */2699 2694 PDMR3Reset(pVM); 2695 PGMR3Reset(pVM); 2700 2696 SELMR3Reset(pVM); 2701 2697 TRPMR3Reset(pVM); … … 2705 2701 IOMR3Reset(pVM); 2706 2702 CPUMR3Reset(pVM); 2707 }2708 if (pVCpu->idCpu == 0)2709 {2710 2703 TMR3Reset(pVM); 2711 2704 EMR3Reset(pVM); … … 2719 2712 DBGFR3Info(pVM->pUVM, "cpum", "verbose", NULL); 2720 2713 #endif 2714 2715 /* 2716 * Do memory setup. 2717 */ 2718 PGMR3MemSetup(pVM, true /*fAtReset*/); 2719 PDMR3MemSetup(pVM, true /*fAtReset*/); 2721 2720 2722 2721 /* -
trunk/src/VBox/VMM/include/PGMInternal.h
r44528 r45024 3961 3961 int pgmR3PhysRamReset(PVM pVM); 3962 3962 int pgmR3PhysRomReset(PVM pVM); 3963 int pgmR3PhysRamZeroAll(PVM pVM); 3963 3964 int pgmR3PhysChunkMap(PVM pVM, uint32_t idChunk, PPPGMCHUNKR3MAP ppChunk); 3964 3965 int pgmR3PhysRamTerm(PVM pVM);
Note:
See TracChangeset
for help on using the changeset viewer.