Changeset 17537 in vbox for trunk/src/recompiler_new
- Timestamp:
- Mar 8, 2009 5:22:28 AM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 43971
- Location:
- trunk/src/recompiler_new
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/recompiler_new/VBoxREM.def
r17251 r17537 24 24 EXPORTS 25 25 REMR3Init 26 REMR3InitFinalize 26 27 REMR3Term 27 28 REMR3Reset -
trunk/src/recompiler_new/VBoxREMWrapper.cpp
r17530 r17537 333 333 * @{ */ 334 334 static DECLCALLBACKPTR(int, pfnREMR3Init)(PVM); 335 static DECLCALLBACKPTR(int, pfnREMR3InitFinalize)(PVM); 335 336 static DECLCALLBACKPTR(int, pfnREMR3Term)(PVM); 336 337 static DECLCALLBACKPTR(void, pfnREMR3Reset)(PVM); … … 346 347 static DECLCALLBACKPTR(void, pfnREMR3ReplayInvalidatedPages)(PVM); 347 348 static DECLCALLBACKPTR(void, pfnREMR3ReplayHandlerNotifications)(PVM pVM); 348 static DECLCALLBACKPTR(void, pfnREMR3NotifyPhysRamRegister)(PVM, RTGCPHYS, RT UINT, unsigned);349 static DECLCALLBACKPTR(void, pfnREMR3NotifyPhysRamRegister)(PVM, RTGCPHYS, RTGCPHYS, unsigned); 349 350 #ifndef VBOX_WITH_NEW_PHYS_CODE 350 351 static DECLCALLBACKPTR(void, pfnREMR3NotifyPhysRamChunkRegister)(PVM, RTGCPHYS, RTUINT, RTHCUINTPTR, unsigned); … … 400 401 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL }, 401 402 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL }, 402 { REMPARMDESC_FLAGS_ INT, sizeof(RTUINT), NULL },403 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL }, 403 404 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL }, 404 405 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL } … … 558 559 { REMPARMDESC_FLAGS_INT, sizeof(char *), NULL } 559 560 }; 560 561 561 static const REMPARMDESC g_aArgsDBGFR3Info[] = 562 562 { … … 798 798 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL }, 799 799 { REMPARMDESC_FLAGS_INT, sizeof(uint64_t), NULL } 800 };801 static const REMPARMDESC g_aArgsPGMR3DbgR3Ptr2GCPhys[] =802 {803 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },804 { REMPARMDESC_FLAGS_INT, sizeof(void*), NULL },805 { REMPARMDESC_FLAGS_INT, sizeof(PRTGCPHYS), NULL }806 800 }; 807 801 static const REMPARMDESC g_aArgsRTMemRealloc[] = … … 1024 1018 */ 1025 1019 static const REMFNDESC g_aExports[] = 1026 { /* pszName, (void *)pv, pParams, cParams, fFlags, cb, pvWrapper. */1020 { /* pszName, (void *)pv, pParams, cParams, fFlags, cb, pvWrapper. */ 1027 1021 { "REMR3Init", (void *)&pfnREMR3Init, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1022 { "REMR3InitFinalize", (void *)&pfnREMR3InitFinalize, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1028 1023 { "REMR3Term", (void *)&pfnREMR3Term, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1029 1024 { "REMR3Reset", (void *)&pfnREMR3Reset, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL }, … … 1144 1139 { "PGMR3PhysWriteU32", (void *)(uintptr_t)&PGMR3PhysWriteU32, &g_aArgsPGMR3PhysWriteU32[0], RT_ELEMENTS(g_aArgsPGMR3PhysWriteU32), REMFNDESC_FLAGS_RET_VOID, 0, NULL }, 1145 1140 { "PGMR3PhysWriteU64", (void *)(uintptr_t)&PGMR3PhysWriteU64, &g_aArgsPGMR3PhysWriteU64[0], RT_ELEMENTS(g_aArgsPGMR3PhysWriteU32), REMFNDESC_FLAGS_RET_VOID, 0, NULL }, 1146 { "PGMR3DbgR3Ptr2GCPhys", (void *)(uintptr_t)&PGMR3DbgR3Ptr2GCPhys, &g_aArgsPGMR3DbgR3Ptr2GCPhys[0], RT_ELEMENTS(g_aArgsPGMR3DbgR3Ptr2GCPhys), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },1147 1141 { "PGMR3PhysTlbGCPhys2Ptr", (void *)(uintptr_t)&PGMR3PhysTlbGCPhys2Ptr, &g_aArgsPGMR3PhysTlbGCPhys2Ptr[0], RT_ELEMENTS(g_aArgsPGMR3PhysTlbGCPhys2Ptr), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1148 1142 { "SSMR3GetGCPtr", (void *)(uintptr_t)&SSMR3GetGCPtr, &g_aArgsSSMR3GetGCPtr[0], RT_ELEMENTS(g_aArgsSSMR3GetGCPtr), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, … … 1198 1192 { "RTLogPrintf", (void *)(uintptr_t)&RTLogPrintf, &g_aArgsRTLogPrintf[0], RT_ELEMENTS(g_aArgsRTLogPrintf), REMFNDESC_FLAGS_RET_VOID, 0, NULL }, 1199 1193 { "RTMemAlloc", (void *)(uintptr_t)&RTMemAlloc, &g_aArgsSIZE_T[0], RT_ELEMENTS(g_aArgsSIZE_T), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL }, 1200 { "RTMemAllocZ", (void *)(uintptr_t)&RTMemAllocZ, 1201 { "RTMemRealloc", (void *)(uintptr_t)&RTMemRealloc, &g_aArgsRTMemRealloc[0], RT_ELEMENTS(g_aArgsRTMemRealloc),REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL },1194 { "RTMemAllocZ", (void *)(uintptr_t)&RTMemAllocZ, &g_aArgsSIZE_T[0], RT_ELEMENTS(g_aArgsSIZE_T), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL }, 1195 { "RTMemRealloc", (void *)(uintptr_t)&RTMemRealloc, &g_aArgsRTMemRealloc[0], RT_ELEMENTS(g_aArgsRTMemRealloc), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL }, 1202 1196 { "RTMemExecAlloc", (void *)(uintptr_t)&RTMemExecAlloc, &g_aArgsSIZE_T[0], RT_ELEMENTS(g_aArgsSIZE_T), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL }, 1203 1204 1197 { "RTMemExecFree", (void *)(uintptr_t)&RTMemExecFree, &g_aArgsPTR[0], RT_ELEMENTS(g_aArgsPTR), REMFNDESC_FLAGS_RET_VOID, 0, NULL }, 1205 1198 { "RTMemFree", (void *)(uintptr_t)&RTMemFree, &g_aArgsPTR[0], RT_ELEMENTS(g_aArgsPTR), REMFNDESC_FLAGS_RET_VOID, 0, NULL }, … … 2025 2018 } 2026 2019 2020 REMR3DECL(int) REMR3InitFinalize(PVM pVM) 2021 { 2022 #ifndef USE_REM_STUBS 2023 Assert(VALID_PTR(pfnREMR3InitFinalize)); 2024 return pfnREMR3InitFinalize(pVM); 2025 #endif 2026 } 2027 2027 2028 REMR3DECL(int) REMR3Term(PVM pVM) 2028 2029 { … … 2166 2167 } 2167 2168 2168 REMR3DECL(void) REMR3NotifyPhysRamRegister(PVM pVM, RTGCPHYS GCPhys, RT UINTcb, unsigned fFlags)2169 REMR3DECL(void) REMR3NotifyPhysRamRegister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, unsigned fFlags) 2169 2170 { 2170 2171 #ifndef USE_REM_STUBS -
trunk/src/recompiler_new/VBoxRecompiler.c
r17459 r17537 90 90 static DECLCALLBACK(int) remR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version); 91 91 static void remR3StateUpdate(PVM pVM); 92 static int remR3InitPhysRamSizeAndDirtyMap(PVM pVM, bool fGuarded); 92 93 93 94 static uint32_t remR3MMIOReadU8(void *pvVM, target_phys_addr_t GCPhys); … … 258 259 Assert(!testmath()); 259 260 #endif 261 260 262 /* 261 263 * Init some internal data members. … … 396 398 #endif 397 399 400 return rc; 401 } 402 403 404 /** 405 * Finalizes the REM initialization. 406 * 407 * This is called after all components, devices and drivers has 408 * been initialized. Its main purpose it to finish the RAM related 409 * initialization. 410 * 411 * @returns VBox status code. 412 * 413 * @param pVM The VM handle. 414 */ 415 REMR3DECL(int) REMR3InitFinalize(PVM pVM) 416 { 417 int rc; 418 419 /* 420 * Ram size & dirty bit map. 421 */ 422 Assert(!pVM->rem.s.fGCPhysLastRamFixed); 423 pVM->rem.s.fGCPhysLastRamFixed = true; 424 #ifdef RT_STRICT 425 rc = remR3InitPhysRamSizeAndDirtyMap(pVM, true /* fGuarded */); 426 #else 427 rc = remR3InitPhysRamSizeAndDirtyMap(pVM, false /* fGuarded */); 428 #endif 429 return rc; 430 } 431 432 433 /** 434 * Initializes phys_ram_size, phys_ram_dirty and phys_ram_dirty_size. 435 * 436 * @returns VBox status code. 437 * @param pVM The VM handle. 438 * @param fGuarded Whether to guard the map. 439 */ 440 static int remR3InitPhysRamSizeAndDirtyMap(PVM pVM, bool fGuarded) 441 { 442 int rc = VINF_SUCCESS; 443 RTGCPHYS cb; 444 445 cb = pVM->rem.s.GCPhysLastRam + 1; 446 AssertLogRelMsgReturn(cb > pVM->rem.s.GCPhysLastRam, 447 ("GCPhysLastRam=%RGp - out of range\n", pVM->rem.s.GCPhysLastRam), 448 VERR_OUT_OF_RANGE); 449 phys_ram_size = cb; 450 phys_ram_dirty_size = cb >> PAGE_SHIFT; 451 AssertMsg(((RTGCPHYS)phys_ram_dirty_size << PAGE_SHIFT) == cb, ("%RGp\n", cb)); 452 453 if (!fGuarded) 454 { 455 phys_ram_dirty = MMR3HeapAlloc(pVM, MM_TAG_REM, phys_ram_dirty_size); 456 AssertLogRelMsgReturn(phys_ram_dirty, ("Failed to allocate %u bytes of dirty page map bytes\n", phys_ram_dirty_size), VERR_NO_MEMORY); 457 } 458 else 459 { 460 /* 461 * Fill it up the nearest 4GB RAM and leave at least _64KB of guard after it. 462 */ 463 uint32_t cbBitmapAligned = RT_ALIGN_32(phys_ram_dirty_size, PAGE_SIZE); 464 uint32_t cbBitmapFull = RT_ALIGN_32(phys_ram_dirty_size, (_4G >> PAGE_SHIFT)); 465 if (cbBitmapFull == cbBitmapAligned) 466 cbBitmapFull += _4G >> PAGE_SHIFT; 467 else if (cbBitmapFull - cbBitmapAligned < _64K) 468 cbBitmapFull += _64K; 469 470 phys_ram_dirty = RTMemPageAlloc(cbBitmapFull); 471 AssertLogRelMsgReturn(phys_ram_dirty, ("Failed to allocate %u bytes of dirty page map bytes\n", cbBitmapFull), VERR_NO_MEMORY); 472 473 rc = RTMemProtect(phys_ram_dirty + cbBitmapAligned, cbBitmapFull - cbBitmapAligned, RTMEM_PROT_NONE); 474 if (RT_FAILURE(rc)) 475 { 476 RTMemPageFree(phys_ram_dirty); 477 AssertLogRelRCReturn(rc, rc); 478 } 479 480 phys_ram_dirty += cbBitmapAligned - phys_ram_dirty_size; 481 } 482 483 /* initialize it. */ 484 memset(phys_ram_dirty, 0xff, phys_ram_dirty_size); 398 485 return rc; 399 486 } … … 1573 1660 * 1574 1661 * @param pVM VM Handle. 1575 * @param fFlushTBs Flush all translation blocks before executing code1576 1662 * 1577 1663 * @remark The caller has to check for important FFs before calling REMR3Run. REMR3State will … … 1712 1798 pVM->rem.s.Env.hflags &= ~(HF_LMA_MASK | HF_CS64_MASK); 1713 1799 #endif 1714 1715 1800 1716 1801 /* … … 2637 2722 * @param fFlags Flags of the MM_RAM_FLAGS_* defines. 2638 2723 */ 2639 REMR3DECL(void) REMR3NotifyPhysRamRegister(PVM pVM, RTGCPHYS GCPhys, RTUINT cb, unsigned fFlags) 2640 { 2641 uint32_t cbBitmap; 2642 int rc; 2643 Log(("REMR3NotifyPhysRamRegister: GCPhys=%RGp cb=%d fFlags=%d\n", GCPhys, cb, fFlags)); 2724 REMR3DECL(void) REMR3NotifyPhysRamRegister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, unsigned fFlags) 2725 { 2726 Log(("REMR3NotifyPhysRamRegister: GCPhys=%RGp cb=%RGp fFlags=%d\n", GCPhys, cb, fFlags)); 2644 2727 VM_ASSERT_EMT(pVM); 2645 2728 … … 2652 2735 2653 2736 /* 2654 * Base ram? 2655 */ 2656 if (!GCPhys) 2657 { 2658 phys_ram_size = cb; 2659 phys_ram_dirty_size = cb >> PAGE_SHIFT; 2660 #ifndef VBOX_STRICT 2661 phys_ram_dirty = MMR3HeapAlloc(pVM, MM_TAG_REM, phys_ram_dirty_size); 2662 AssertReleaseMsg(phys_ram_dirty, ("failed to allocate %d bytes of dirty bytes\n", phys_ram_dirty_size)); 2663 #else /* VBOX_STRICT: allocate a full map and make the out of bounds pages invalid. */ 2664 phys_ram_dirty = RTMemPageAlloc(_4G >> PAGE_SHIFT); 2665 AssertReleaseMsg(phys_ram_dirty, ("failed to allocate %d bytes of dirty bytes\n", _4G >> PAGE_SHIFT)); 2666 cbBitmap = RT_ALIGN_32(phys_ram_dirty_size, PAGE_SIZE); 2667 rc = RTMemProtect(phys_ram_dirty + cbBitmap, (_4G >> PAGE_SHIFT) - cbBitmap, RTMEM_PROT_NONE); 2668 AssertRC(rc); 2669 phys_ram_dirty += cbBitmap - phys_ram_dirty_size; 2670 #endif 2671 memset(phys_ram_dirty, 0xff, phys_ram_dirty_size); 2737 * Base ram? Update GCPhysLastRam. 2738 */ 2739 if (!GCPhys) /** @todo add a flag for identifying MMIO2 memory here (new phys code)*/ 2740 { 2741 if (GCPhys + (cb - 1) > pVM->rem.s.GCPhysLastRam) 2742 { 2743 AssertReleaseMsg(!pVM->rem.s.fGCPhysLastRamFixed, ("GCPhys=%RGp cb=%RGp\n", GCPhys, cb)); 2744 pVM->rem.s.GCPhysLastRam = GCPhys + (cb - 1); 2745 } 2672 2746 } 2673 2747
Note:
See TracChangeset
for help on using the changeset viewer.