Changeset 4535 in vbox
- Timestamp:
- Sep 5, 2007 2:20:59 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 24153
- Location:
- trunk/src/recompiler
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/recompiler/Makefile.kmk
r4071 r4535 50 50 $(PATH_$(REM_MOD))/opc.h 51 51 52 DEFS .amd64+= REM_PHYS_ADDR_IN_TLB52 DEFS += REM_PHYS_ADDR_IN_TLB 53 53 54 54 # -
trunk/src/recompiler/VBoxRecompiler.c
r4388 r4535 84 84 static void remR3StateUpdate(PVM pVM); 85 85 86 #if defined(PGM_DYNAMIC_RAM_ALLOC) && !defined(REM_PHYS_ADDR_IN_TLB)87 DECLINLINE(target_ulong) remR3HCVirt2GCPhysInlined(PVM pVM, void *addr);88 DECLINLINE(void *) remR3GCPhys2HCVirtInlined(PVM pVM, target_ulong addr);89 #endif90 91 86 static uint32_t remR3MMIOReadU8(void *pvVM, target_phys_addr_t GCPhys); 92 87 static uint32_t remR3MMIOReadU16(void *pvVM, target_phys_addr_t GCPhys); … … 120 115 static STAMPROFILEADV gStatMemRead; 121 116 static STAMPROFILEADV gStatMemWrite; 122 #ifndef REM_PHYS_ADDR_IN_TLB123 static STAMPROFILEADV gStatMemReadHCPtr;124 static STAMPROFILEADV gStatMemWriteHCPtr;125 #endif126 #ifdef PGM_DYNAMIC_RAM_ALLOC127 117 static STAMPROFILE gStatGCPhys2HCVirt; 128 118 static STAMPROFILE gStatHCVirt2GCPhys; 129 #endif130 119 static STAMCOUNTER gStatCpuGetTSC; 131 120 static STAMCOUNTER gStatRefuseTFInhibit; … … 360 349 STAM_REG(pVM, &gStatMemRead, STAMTYPE_PROFILE, "/PROF/REM/MemRead", STAMUNIT_TICKS_PER_CALL, "Profiling memory access."); 361 350 STAM_REG(pVM, &gStatMemWrite, STAMTYPE_PROFILE, "/PROF/REM/MemWrite", STAMUNIT_TICKS_PER_CALL, "Profiling memory access."); 362 #ifndef REM_PHYS_ADDR_IN_TLB363 STAM_REG(pVM, &gStatMemReadHCPtr, STAMTYPE_PROFILE, "/PROF/REM/MemReadHCPtr", STAMUNIT_TICKS_PER_CALL, "Profiling memory access.");364 STAM_REG(pVM, &gStatMemWriteHCPtr, STAMTYPE_PROFILE, "/PROF/REM/MemWriteHCPtr", STAMUNIT_TICKS_PER_CALL, "Profiling memory access.");365 #endif366 #ifdef PGM_DYNAMIC_RAM_ALLOC367 351 STAM_REG(pVM, &gStatHCVirt2GCPhys, STAMTYPE_PROFILE, "/PROF/REM/HCVirt2GCPhys", STAMUNIT_TICKS_PER_CALL, "Profiling memory convertion."); 368 352 STAM_REG(pVM, &gStatGCPhys2HCVirt, STAMTYPE_PROFILE, "/PROF/REM/GCPhys2HCVirt", STAMUNIT_TICKS_PER_CALL, "Profiling memory convertion."); 369 #endif370 353 371 354 STAM_REG(pVM, &gStatCpuGetTSC, STAMTYPE_COUNTER, "/REM/CpuGetTSC", STAMUNIT_OCCURENCES, "cpu_get_tsc calls"); … … 2470 2453 if (!GCPhys) 2471 2454 { 2472 #if !defined(PGM_DYNAMIC_RAM_ALLOC) && !defined(REM_PHYS_ADDR_IN_TLB)2473 AssertRelease(!phys_ram_base);2474 phys_ram_base = pvRam;2475 #endif2476 2455 phys_ram_size = cb; 2477 2456 phys_ram_dirty_size = cb >> PAGE_SHIFT; … … 2496 2475 pVM->rem.s.fIgnoreAll = true; 2497 2476 2498 #ifdef PGM_DYNAMIC_RAM_ALLOC2499 2477 if (!GCPhys) 2500 2478 cpu_register_physical_memory(GCPhys, cb, GCPhys | IO_MEM_RAM_MISSING); 2501 2479 else 2502 2480 { 2503 # ifndef REM_PHYS_ADDR_IN_TLB2504 uint32_t i;2505 # endif2506 2481 if (fFlags & MM_RAM_FLAGS_RESERVED) 2507 2482 cpu_register_physical_memory(GCPhys, cb, IO_MEM_UNASSIGNED); 2508 2483 else 2509 2484 cpu_register_physical_memory(GCPhys, cb, GCPhys); 2510 2511 # ifndef REM_PHYS_ADDR_IN_TLB 2512 AssertRelease(pVM->rem.s.cPhysRegistrations < REM_MAX_PHYS_REGISTRATIONS); 2513 for (i = 0; i < pVM->rem.s.cPhysRegistrations; i++) 2514 { 2515 if (pVM->rem.s.aPhysReg[i].GCPhys == GCPhys) 2516 { 2517 pVM->rem.s.aPhysReg[i].HCVirt = (RTHCUINTPTR)pvRam; 2518 pVM->rem.s.aPhysReg[i].cb = cb; 2519 break; 2520 } 2521 } 2522 if (i == pVM->rem.s.cPhysRegistrations) 2523 { 2524 pVM->rem.s.aPhysReg[i].GCPhys = GCPhys; 2525 pVM->rem.s.aPhysReg[i].HCVirt = (RTHCUINTPTR)pvRam; 2526 pVM->rem.s.aPhysReg[i].cb = cb; 2527 pVM->rem.s.cPhysRegistrations++; 2528 } 2529 # endif /* !REM_PHYS_ADDR_IN_TLB */ 2530 } 2531 #elif defined(REM_PHYS_ADDR_IN_TLB) 2532 cpu_register_physical_memory(GCPhys, cb, GCPhys | (fFlags & MM_RAM_FLAGS_RESERVED ? IO_MEM_UNASSIGNED : 0)); 2533 #else 2534 AssertRelease(phys_ram_base); 2535 cpu_register_physical_memory(GCPhys, cb, ((uintptr_t)pvRam - (uintptr_t)phys_ram_base) 2536 | (fFlags & MM_RAM_FLAGS_RESERVED ? IO_MEM_UNASSIGNED : 0)); 2537 #endif 2485 } 2538 2486 Assert(pVM->rem.s.fIgnoreAll); 2539 2487 pVM->rem.s.fIgnoreAll = false; … … 2552 2500 REMR3DECL(void) REMR3NotifyPhysRamChunkRegister(PVM pVM, RTGCPHYS GCPhys, RTUINT cb, RTHCUINTPTR pvRam, unsigned fFlags) 2553 2501 { 2554 #ifdef PGM_DYNAMIC_RAM_ALLOC2555 # ifndef REM_PHYS_ADDR_IN_TLB2556 uint32_t idx;2557 #endif2558 2559 2502 Log(("REMR3NotifyPhysRamChunkRegister: GCPhys=%VGp cb=%d pvRam=%p fFlags=%d\n", GCPhys, cb, pvRam, fFlags)); 2560 2503 VM_ASSERT_EMT(pVM); … … 2568 2511 Assert(cb == PGM_DYNAMIC_CHUNK_SIZE); 2569 2512 Assert(fFlags == 0 /* normal RAM */); 2570 2571 # ifndef REM_PHYS_ADDR_IN_TLB2572 if (!pVM->rem.s.paHCVirtToGCPhys)2573 {2574 uint32_t size = (_4G >> PGM_DYNAMIC_CHUNK_SHIFT) * sizeof(REMCHUNKINFO);2575 2576 Assert(phys_ram_size);2577 2578 pVM->rem.s.paHCVirtToGCPhys = (PREMCHUNKINFO)MMR3HeapAllocZ(pVM, MM_TAG_REM, size);2579 pVM->rem.s.paGCPhysToHCVirt = (RTHCPTR)MMR3HeapAllocZ(pVM, MM_TAG_REM, (phys_ram_size >> PGM_DYNAMIC_CHUNK_SHIFT)*sizeof(RTHCPTR));2580 }2581 pVM->rem.s.paGCPhysToHCVirt[GCPhys >> PGM_DYNAMIC_CHUNK_SHIFT] = pvRam;2582 2583 idx = (pvRam >> PGM_DYNAMIC_CHUNK_SHIFT);2584 if (!pVM->rem.s.paHCVirtToGCPhys[idx].pChunk1)2585 {2586 pVM->rem.s.paHCVirtToGCPhys[idx].pChunk1 = pvRam;2587 pVM->rem.s.paHCVirtToGCPhys[idx].GCPhys1 = GCPhys;2588 }2589 else2590 {2591 Assert(!pVM->rem.s.paHCVirtToGCPhys[idx].pChunk2);2592 pVM->rem.s.paHCVirtToGCPhys[idx].pChunk2 = pvRam;2593 pVM->rem.s.paHCVirtToGCPhys[idx].GCPhys2 = GCPhys;2594 }2595 /* Does the region spawn two chunks? */2596 if (pvRam & PGM_DYNAMIC_CHUNK_OFFSET_MASK)2597 {2598 if (!pVM->rem.s.paHCVirtToGCPhys[idx+1].pChunk1)2599 {2600 pVM->rem.s.paHCVirtToGCPhys[idx+1].pChunk1 = pvRam;2601 pVM->rem.s.paHCVirtToGCPhys[idx+1].GCPhys1 = GCPhys;2602 }2603 else2604 {2605 Assert(!pVM->rem.s.paHCVirtToGCPhys[idx+1].pChunk2);2606 pVM->rem.s.paHCVirtToGCPhys[idx+1].pChunk2 = pvRam;2607 pVM->rem.s.paHCVirtToGCPhys[idx+1].GCPhys2 = GCPhys;2608 }2609 }2610 # endif /* !REM_PHYS_ADDR_IN_TLB */2611 2612 2513 Assert(!pVM->rem.s.fIgnoreAll); 2613 2514 pVM->rem.s.fIgnoreAll = true; … … 2617 2518 Assert(pVM->rem.s.fIgnoreAll); 2618 2519 pVM->rem.s.fIgnoreAll = false; 2619 2620 #else 2621 AssertReleaseFailed(); 2622 #endif 2623 } 2624 2625 2626 #ifdef PGM_DYNAMIC_RAM_ALLOC 2627 # ifndef REM_PHYS_ADDR_IN_TLB 2628 #if 0 2629 static const uint8_t gabZeroPage[PAGE_SIZE]; 2630 #endif 2631 2632 /** 2633 * Convert GC physical address to HC virt 2634 * 2635 * @returns The HC virt address corresponding to addr. 2636 * @param env The cpu environment. 2637 * @param addr The physical address. 2638 */ 2639 DECLINLINE(void *) remR3GCPhys2HCVirtInlined(PVM pVM, target_ulong addr) 2640 { 2641 uint32_t i; 2642 void *pv; 2643 STAM_PROFILE_START(&gStatGCPhys2HCVirt, a); 2644 2645 #if 1 2646 /* lookup in pVM->rem.s.aPhysReg array first (for ROM range(s) inside the guest's RAM) */ 2647 for (i = 0; i < pVM->rem.s.cPhysRegistrations; i++) 2648 { 2649 RTGCPHYS off = addr - pVM->rem.s.aPhysReg[i].GCPhys; 2650 if (off < pVM->rem.s.aPhysReg[i].cb) 2651 { 2652 pv = (void *)(pVM->rem.s.aPhysReg[i].HCVirt + off); 2653 Log2(("remR3GCPhys2HCVirt: %x -> %x\n", addr, pv)); 2654 STAM_PROFILE_STOP(&gStatGCPhys2HCVirt, a); 2655 return pv; 2656 } 2657 } 2658 AssertMsg(addr < phys_ram_size, ("remR3GCPhys2HCVirt: unknown physical address %x\n", addr)); 2659 pv = (void *)(pVM->rem.s.paGCPhysToHCVirt[addr >> PGM_DYNAMIC_CHUNK_SHIFT] + (addr & PGM_DYNAMIC_CHUNK_OFFSET_MASK)); 2660 Log2(("remR3GCPhys2HCVirt: %x -> %x\n", addr, pv)); 2661 #else 2662 /** @todo figure out why this is faster than the above code. */ 2663 int rc = PGMPhysGCPhys2HCPtr(pVM, addr & X86_PTE_PAE_PG_MASK, PAGE_SIZE, &pv); 2664 if (RT_FAILURE(rc)) 2665 { 2666 AssertMsgFailed(("remR3GCPhys2HCVirt: unknown physical address %x\n", addr)); 2667 pv = gabZeroPage; 2668 } 2669 pv = (void *)((uintptr_t)pv | (addr & PAGE_OFFSET_MASK)); 2670 #endif 2671 return pv; 2672 } 2673 2674 2675 /** 2676 * Convert GC physical address to HC virt 2677 * 2678 * @returns The HC virt address corresponding to addr. 2679 * @param env The cpu environment. 2680 * @param addr The physical address. 2681 */ 2682 DECLINLINE(target_ulong) remR3HCVirt2GCPhysInlined(PVM pVM, void *addr) 2683 { 2684 RTHCUINTPTR HCVirt = (RTHCUINTPTR)addr; 2685 uint32_t idx = (HCVirt >> PGM_DYNAMIC_CHUNK_SHIFT); 2686 RTHCUINTPTR off; 2687 RTUINT i; 2688 target_ulong GCPhys; 2689 2690 off = HCVirt - pVM->rem.s.paHCVirtToGCPhys[idx].pChunk1; 2691 2692 if ( pVM->rem.s.paHCVirtToGCPhys[idx].pChunk1 2693 && off < PGM_DYNAMIC_CHUNK_SIZE) 2694 { 2695 GCPhys = pVM->rem.s.paHCVirtToGCPhys[idx].GCPhys1 + off; 2696 Log2(("remR3HCVirt2GCPhys %x -> %x\n", addr, GCPhys)); 2697 return GCPhys; 2698 } 2699 2700 off = HCVirt - pVM->rem.s.paHCVirtToGCPhys[idx].pChunk2; 2701 if ( pVM->rem.s.paHCVirtToGCPhys[idx].pChunk2 2702 && off < PGM_DYNAMIC_CHUNK_SIZE) 2703 { 2704 GCPhys = pVM->rem.s.paHCVirtToGCPhys[idx].GCPhys2 + off; 2705 Log2(("remR3HCVirt2GCPhys %x -> %x\n", addr, GCPhys)); 2706 return GCPhys; 2707 } 2708 2709 /* Must be externally registered RAM/ROM range */ 2710 for (i = 0; i < pVM->rem.s.cPhysRegistrations; i++) 2711 { 2712 uint32_t off = HCVirt - pVM->rem.s.aPhysReg[i].HCVirt; 2713 if (off < pVM->rem.s.aPhysReg[i].cb) 2714 { 2715 GCPhys = pVM->rem.s.aPhysReg[i].GCPhys + off; 2716 Log2(("remR3HCVirt2GCPhys %x -> %x\n", addr, GCPhys)); 2717 return GCPhys; 2718 } 2719 } 2720 AssertReleaseMsgFailed(("No translation for physical address %VHv???\n", addr)); 2721 return 0; 2722 } 2723 2724 /** 2725 * Convert GC physical address to HC virt 2726 * 2727 * @returns The HC virt address corresponding to addr. 2728 * @param env The cpu environment. 2729 * @param addr The physical address. 2730 */ 2731 void *remR3GCPhys2HCVirt(void *env, target_ulong addr) 2732 { 2733 PVM pVM = ((CPUState *)env)->pVM; 2734 void *pv; 2735 STAM_PROFILE_START(&gStatGCPhys2HCVirt, a); 2736 pv = remR3GCPhys2HCVirtInlined(pVM, addr); 2737 STAM_PROFILE_STOP(&gStatGCPhys2HCVirt, a); 2738 return pv; 2739 } 2740 2741 2742 /** 2743 * Convert GC physical address to HC virt 2744 * 2745 * @returns The HC virt address corresponding to addr. 2746 * @param env The cpu environment. 2747 * @param addr The physical address. 2748 */ 2749 target_ulong remR3HCVirt2GCPhys(void *env, void *addr) 2750 { 2751 PVM pVM = ((CPUState *)env)->pVM; 2752 target_ulong GCPhys; 2753 STAM_PROFILE_START(&gStatHCVirt2GCPhys, a); 2754 GCPhys = remR3HCVirt2GCPhysInlined(pVM, addr); 2755 STAM_PROFILE_STOP(&gStatHCVirt2GCPhys, a); 2756 return GCPhys; 2757 } 2758 2759 # endif /* !REM_PHYS_ADDR_IN_TLB */ 2520 } 2521 2760 2522 2761 2523 /** … … 2779 2541 AssertFatalFailed(); 2780 2542 } 2781 2782 #endif /* PGM_DYNAMIC_RAM_ALLOC */2783 2543 2784 2544 … … 2796 2556 REMR3DECL(void) REMR3NotifyPhysRomRegister(PVM pVM, RTGCPHYS GCPhys, RTUINT cb, void *pvCopy, bool fShadow) 2797 2557 { 2798 #if defined(PGM_DYNAMIC_RAM_ALLOC) && !defined(REM_PHYS_ADDR_IN_TLB)2799 uint32_t i;2800 #endif2801 2558 Log(("REMR3NotifyPhysRomRegister: GCPhys=%VGp cb=%d pvCopy=%p fShadow=%RTbool\n", GCPhys, cb, pvCopy, fShadow)); 2802 2559 VM_ASSERT_EMT(pVM); … … 2817 2574 pVM->rem.s.fIgnoreAll = true; 2818 2575 2819 #ifdef REM_PHYS_ADDR_IN_TLB2820 2576 cpu_register_physical_memory(GCPhys, cb, GCPhys | (fShadow ? 0 : IO_MEM_ROM)); 2821 #elif defined(PGM_DYNAMIC_RAM_ALLOC)2822 cpu_register_physical_memory(GCPhys, cb, GCPhys | (fShadow ? 0 : IO_MEM_ROM));2823 AssertRelease(pVM->rem.s.cPhysRegistrations < REM_MAX_PHYS_REGISTRATIONS);2824 for (i = 0; i < pVM->rem.s.cPhysRegistrations; i++)2825 {2826 if (pVM->rem.s.aPhysReg[i].GCPhys == GCPhys)2827 {2828 pVM->rem.s.aPhysReg[i].HCVirt = (RTHCUINTPTR)pvCopy;2829 pVM->rem.s.aPhysReg[i].cb = cb;2830 break;2831 }2832 }2833 if (i == pVM->rem.s.cPhysRegistrations)2834 {2835 pVM->rem.s.aPhysReg[i].GCPhys = GCPhys;2836 pVM->rem.s.aPhysReg[i].HCVirt = (RTHCUINTPTR)pvCopy;2837 pVM->rem.s.aPhysReg[i].cb = cb;2838 pVM->rem.s.cPhysRegistrations++;2839 }2840 #else2841 AssertRelease(phys_ram_base);2842 cpu_register_physical_memory(GCPhys, cb, ((uintptr_t)pvCopy - (uintptr_t)phys_ram_base) | (fShadow ? 0 : IO_MEM_ROM));2843 #endif2844 2577 2845 2578 Log2(("%.64Vhxd\n", (char *)pvCopy + cb - 64)); … … 2954 2687 Assert(cb == PAGE_SIZE); 2955 2688 Assert(RT_ALIGN_T(GCPhys, PAGE_SIZE, RTGCPHYS) == GCPhys); 2956 #ifdef REM_PHYS_ADDR_IN_TLB2957 2689 cpu_register_physical_memory(GCPhys, cb, GCPhys); 2958 #elif defined(PGM_DYNAMIC_RAM_ALLOC)2959 Assert(remR3HCVirt2GCPhysInlined(pVM, pvHCPtr) < MMR3PhysGetRamSize(pVM));2960 cpu_register_physical_memory(GCPhys, cb, GCPhys);2961 #else2962 Assert((uintptr_t)pvHCPtr - (uintptr_t)phys_ram_base < MMR3PhysGetRamSize(pVM));2963 cpu_register_physical_memory(GCPhys, cb, (uintptr_t)pvHCPtr - (uintptr_t)phys_ram_base);2964 #endif2965 2690 } 2966 2691 } … … 3007 2732 Assert(cb == PAGE_SIZE); 3008 2733 Assert(RT_ALIGN_T(GCPhysOld, PAGE_SIZE, RTGCPHYS) == GCPhysOld); 3009 #ifdef REM_PHYS_ADDR_IN_TLB3010 2734 cpu_register_physical_memory(GCPhysOld, cb, GCPhysOld); 3011 #elif defined(PGM_DYNAMIC_RAM_ALLOC)3012 Assert(remR3HCVirt2GCPhysInlined(pVM, pvHCPtr) < MMR3PhysGetRamSize(pVM));3013 cpu_register_physical_memory(GCPhysOld, cb, GCPhysOld);3014 #else3015 AssertMsg((uintptr_t)pvHCPtr - (uintptr_t)phys_ram_base < MMR3PhysGetRamSize(pVM),3016 ("pvHCPtr=%p phys_ram_base=%p size=%RX64 cb=%RGp\n", pvHCPtr, phys_ram_base, MMR3PhysGetRamSize(pVM), cb));3017 cpu_register_physical_memory(GCPhysOld, cb, (uintptr_t)pvHCPtr - (uintptr_t)phys_ram_base);3018 #endif3019 2735 } 3020 2736 … … 3305 3021 STAM_PROFILE_ADV_STOP(&gStatMemWrite, a); 3306 3022 } 3307 3308 3309 #ifndef REM_PHYS_ADDR_IN_TLB3310 3311 /**3312 * Read guest RAM and ROM.3313 *3314 * @param pbSrcPhys The source address. Relative to guest RAM.3315 * @param pvDst The destination address.3316 * @param cb Number of bytes3317 */3318 void remR3PhysReadHCPtr(uint8_t *pbSrcPhys, void *pvDst, unsigned cb)3319 {3320 STAM_PROFILE_ADV_START(&gStatMemReadHCPtr, a);3321 3322 /*3323 * Calc the physical address ('off') and check that it's within the RAM.3324 * ROM is accessed this way, even if it's not part of the RAM.3325 */3326 #ifdef PGM_DYNAMIC_RAM_ALLOC3327 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys);3328 #else3329 uintptr_t off = pbSrcPhys - phys_ram_base;3330 #endif3331 PGMPhysRead(cpu_single_env->pVM, (RTGCPHYS)off, pvDst, cb);3332 STAM_PROFILE_ADV_STOP(&gStatMemReadHCPtr, a);3333 }3334 3335 3336 /**3337 * Read guest RAM and ROM, unsigned 8-bit.3338 *3339 * @param pbSrcPhys The source address. Relative to guest RAM.3340 */3341 uint8_t remR3PhysReadHCPtrU8(uint8_t *pbSrcPhys)3342 {3343 uint8_t val;3344 3345 STAM_PROFILE_ADV_START(&gStatMemReadHCPtr, a);3346 3347 /*3348 * Calc the physical address ('off') and check that it's within the RAM.3349 * ROM is accessed this way, even if it's not part of the RAM.3350 */3351 #ifdef PGM_DYNAMIC_RAM_ALLOC3352 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys);3353 #else3354 uintptr_t off = pbSrcPhys - phys_ram_base;3355 #endif3356 val = PGMR3PhysReadByte(cpu_single_env->pVM, (RTGCPHYS)off);3357 STAM_PROFILE_ADV_STOP(&gStatMemReadHCPtr, a);3358 return val;3359 }3360 3361 3362 /**3363 * Read guest RAM and ROM, signed 8-bit.3364 *3365 * @param pbSrcPhys The source address. Relative to guest RAM.3366 */3367 int8_t remR3PhysReadHCPtrS8(uint8_t *pbSrcPhys)3368 {3369 int8_t val;3370 3371 STAM_PROFILE_ADV_START(&gStatMemReadHCPtr, a);3372 3373 /*3374 * Calc the physical address ('off') and check that it's within the RAM.3375 * ROM is accessed this way, even if it's not part of the RAM.3376 */3377 #ifdef PGM_DYNAMIC_RAM_ALLOC3378 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys);3379 #else3380 uintptr_t off = pbSrcPhys - phys_ram_base;3381 #endif3382 val = PGMR3PhysReadByte(cpu_single_env->pVM, (RTGCPHYS)off);3383 STAM_PROFILE_ADV_STOP(&gStatMemReadHCPtr, a);3384 return val;3385 }3386 3387 3388 /**3389 * Read guest RAM and ROM, unsigned 16-bit.3390 *3391 * @param pbSrcPhys The source address. Relative to guest RAM.3392 */3393 uint16_t remR3PhysReadHCPtrU16(uint8_t *pbSrcPhys)3394 {3395 uint16_t val;3396 3397 STAM_PROFILE_ADV_START(&gStatMemReadHCPtr, a);3398 3399 /*3400 * Calc the physical address ('off') and check that it's within the RAM.3401 * ROM is accessed this way, even if it's not part of the RAM.3402 */3403 #ifdef PGM_DYNAMIC_RAM_ALLOC3404 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys);3405 #else3406 uintptr_t off = pbSrcPhys - phys_ram_base;3407 #endif3408 val = PGMR3PhysReadWord(cpu_single_env->pVM, (RTGCPHYS)off);3409 STAM_PROFILE_ADV_STOP(&gStatMemReadHCPtr, a);3410 return val;3411 }3412 3413 3414 /**3415 * Read guest RAM and ROM, signed 16-bit.3416 *3417 * @param pbSrcPhys The source address. Relative to guest RAM.3418 */3419 int16_t remR3PhysReadHCPtrS16(uint8_t *pbSrcPhys)3420 {3421 int16_t val;3422 3423 STAM_PROFILE_ADV_START(&gStatMemReadHCPtr, a);3424 3425 /*3426 * Calc the physical address ('off') and check that it's within the RAM.3427 * ROM is accessed this way, even if it's not part of the RAM.3428 */3429 /** @todo This is rather ugly, but there's no other way when we don't wish to touch *many* other files. */3430 #ifdef PGM_DYNAMIC_RAM_ALLOC3431 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys);3432 #else3433 uintptr_t off = pbSrcPhys - phys_ram_base;3434 #endif3435 val = PGMR3PhysReadWord(cpu_single_env->pVM, (RTGCPHYS)off);3436 STAM_PROFILE_ADV_STOP(&gStatMemReadHCPtr, a);3437 return val;3438 }3439 3440 3441 /**3442 * Read guest RAM and ROM, unsigned 32-bit.3443 *3444 * @param pbSrcPhys The source address. Relative to guest RAM.3445 */3446 uint32_t remR3PhysReadHCPtrU32(uint8_t *pbSrcPhys)3447 {3448 uint32_t val;3449 3450 STAM_PROFILE_ADV_START(&gStatMemReadHCPtr, a);3451 3452 /*3453 * Calc the physical address ('off') and check that it's within the RAM.3454 * ROM is accessed this way, even if it's not part of the RAM.3455 */3456 #ifdef PGM_DYNAMIC_RAM_ALLOC3457 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys);3458 #else3459 uintptr_t off = pbSrcPhys - phys_ram_base;3460 #endif3461 val = PGMR3PhysReadDword(cpu_single_env->pVM, (RTGCPHYS)off);3462 STAM_PROFILE_ADV_STOP(&gStatMemReadHCPtr, a);3463 return val;3464 }3465 3466 3467 /**3468 * Read guest RAM and ROM, signed 32-bit.3469 *3470 * @param pbSrcPhys The source address. Relative to guest RAM.3471 */3472 int32_t remR3PhysReadHCPtrS32(uint8_t *pbSrcPhys)3473 {3474 int32_t val;3475 3476 STAM_PROFILE_ADV_START(&gStatMemReadHCPtr, a);3477 3478 /*3479 * Calc the physical address ('off') and check that it's within the RAM.3480 * ROM is accessed this way, even if it's not part of the RAM.3481 */3482 #ifdef PGM_DYNAMIC_RAM_ALLOC3483 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys);3484 #else3485 uintptr_t off = pbSrcPhys - phys_ram_base;3486 #endif3487 val = PGMR3PhysReadDword(cpu_single_env->pVM, (RTGCPHYS)off);3488 STAM_PROFILE_ADV_STOP(&gStatMemReadHCPtr, a);3489 return val;3490 }3491 3492 3493 /**3494 * Read guest RAM and ROM, unsigned 64-bit.3495 *3496 * @param pbSrcPhys The source address. Relative to guest RAM.3497 */3498 uint64_t remR3PhysReadHCPtrU64(uint8_t *pbSrcPhys)3499 {3500 uint64_t val;3501 3502 STAM_PROFILE_ADV_START(&gStatMemReadHCPtr, a);3503 3504 /*3505 * Calc the physical address ('off') and check that it's within the RAM.3506 * ROM is accessed this way, even if it's not part of the RAM.3507 */3508 #ifdef PGM_DYNAMIC_RAM_ALLOC3509 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys);3510 #else3511 uintptr_t off = pbSrcPhys - phys_ram_base;3512 #endif3513 val = PGMR3PhysReadDword(cpu_single_env->pVM, (RTGCPHYS)off)3514 | ((uint64_t)PGMR3PhysReadDword(cpu_single_env->pVM, (RTGCPHYS)off + 4) << 32); /** @todo fix me! */3515 STAM_PROFILE_ADV_STOP(&gStatMemReadHCPtr, a);3516 return val;3517 }3518 3519 3520 /**3521 * Write guest RAM.3522 *3523 * @param pbDstPhys The destination address. Relative to guest RAM.3524 * @param pvSrc The source address.3525 * @param cb Number of bytes to write3526 */3527 void remR3PhysWriteHCPtr(uint8_t *pbDstPhys, const void *pvSrc, unsigned cb)3528 {3529 STAM_PROFILE_ADV_START(&gStatMemWriteHCPtr, a);3530 /*3531 * Calc the physical address ('off') and check that it's within the RAM.3532 */3533 #ifdef PGM_DYNAMIC_RAM_ALLOC3534 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbDstPhys);3535 #else3536 uintptr_t off = pbDstPhys - phys_ram_base;3537 #endif3538 PGMPhysWrite(cpu_single_env->pVM, (RTGCPHYS)off, pvSrc, cb);3539 STAM_PROFILE_ADV_STOP(&gStatMemWriteHCPtr, a);3540 }3541 3542 3543 /**3544 * Write guest RAM, unsigned 8-bit.3545 *3546 * @param pbDstPhys The destination address. Relative to guest RAM.3547 * @param val Value3548 */3549 void remR3PhysWriteHCPtrU8(uint8_t *pbDstPhys, uint8_t val)3550 {3551 STAM_PROFILE_ADV_START(&gStatMemWriteHCPtr, a);3552 /*3553 * Calc the physical address ('off') and check that it's within the RAM.3554 */3555 #ifdef PGM_DYNAMIC_RAM_ALLOC3556 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbDstPhys);3557 #else3558 uintptr_t off = pbDstPhys - phys_ram_base;3559 #endif3560 PGMR3PhysWriteByte(cpu_single_env->pVM, (RTGCPHYS)off, val);3561 STAM_PROFILE_ADV_STOP(&gStatMemWriteHCPtr, a);3562 }3563 3564 3565 /**3566 * Write guest RAM, unsigned 16-bit.3567 *3568 * @param pbDstPhys The destination address. Relative to guest RAM.3569 * @param val Value3570 */3571 void remR3PhysWriteHCPtrU16(uint8_t *pbDstPhys, uint16_t val)3572 {3573 STAM_PROFILE_ADV_START(&gStatMemWriteHCPtr, a);3574 /*3575 * Calc the physical address ('off') and check that it's within the RAM.3576 */3577 #ifdef PGM_DYNAMIC_RAM_ALLOC3578 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbDstPhys);3579 #else3580 uintptr_t off = pbDstPhys - phys_ram_base;3581 #endif3582 PGMR3PhysWriteWord(cpu_single_env->pVM, (RTGCPHYS)off, val);3583 STAM_PROFILE_ADV_STOP(&gStatMemWriteHCPtr, a);3584 }3585 3586 3587 /**3588 * Write guest RAM, unsigned 32-bit.3589 *3590 * @param pbDstPhys The destination address. Relative to guest RAM.3591 * @param val Value3592 */3593 void remR3PhysWriteHCPtrU32(uint8_t *pbDstPhys, uint32_t val)3594 {3595 STAM_PROFILE_ADV_START(&gStatMemWriteHCPtr, a);3596 /*3597 * Calc the physical address ('off') and check that it's within the RAM.3598 */3599 #ifdef PGM_DYNAMIC_RAM_ALLOC3600 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbDstPhys);3601 #else3602 uintptr_t off = pbDstPhys - phys_ram_base;3603 #endif3604 PGMR3PhysWriteDword(cpu_single_env->pVM, (RTGCPHYS)off, val);3605 STAM_PROFILE_ADV_STOP(&gStatMemWriteHCPtr, a);3606 }3607 3608 3609 /**3610 * Write guest RAM, unsigned 64-bit.3611 *3612 * @param pbDstPhys The destination address. Relative to guest RAM.3613 * @param val Value3614 */3615 void remR3PhysWriteHCPtrU64(uint8_t *pbDstPhys, uint64_t val)3616 {3617 STAM_PROFILE_ADV_START(&gStatMemWriteHCPtr, a);3618 /*3619 * Calc the physical address ('off') and check that it's within the RAM.3620 */3621 #ifdef PGM_DYNAMIC_RAM_ALLOC3622 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbDstPhys);3623 #else3624 uintptr_t off = pbDstPhys - phys_ram_base;3625 #endif3626 PGMR3PhysWriteDword(cpu_single_env->pVM, (RTGCPHYS)off, (uint32_t)val); /** @todo add U64 interface. */3627 PGMR3PhysWriteDword(cpu_single_env->pVM, (RTGCPHYS)off + 4, val >> 32);3628 STAM_PROFILE_ADV_STOP(&gStatMemWriteHCPtr, a);3629 }3630 3631 #endif /* !REM_PHYS_ADDR_IN_TLB */3632 3633 3023 3634 3024 #undef LOG_GROUP -
trunk/src/recompiler/cpu-all.h
r3727 r4535 196 196 void remR3PhysWriteU64(RTGCPHYS DstGCPhys, uint64_t val); 197 197 198 #ifndef REM_PHYS_ADDR_IN_TLB199 void remR3PhysReadHCPtr(uint8_t *pbSrcPhys, void *pvDst, unsigned cb);200 uint8_t remR3PhysReadHCPtrU8(uint8_t *pbSrcPhys);201 int8_t remR3PhysReadHCPtrS8(uint8_t *pbSrcPhys);202 uint16_t remR3PhysReadHCPtrU16(uint8_t *pbSrcPhys);203 int16_t remR3PhysReadHCPtrS16(uint8_t *pbSrcPhys);204 uint32_t remR3PhysReadHCPtrU32(uint8_t *pbSrcPhys);205 int32_t remR3PhysReadHCPtrS32(uint8_t *pbSrcPhys);206 uint64_t remR3PhysReadHCPtrU64(uint8_t *pbSrcPhys);207 int64_t remR3PhysReadHCPtrS64(uint8_t *pbSrcPhys);208 void remR3PhysWriteHCPtr(uint8_t *pbDstPhys, const void *pvSrc, unsigned cb);209 void remR3PhysWriteHCPtrU8(uint8_t *pbDstPhys, uint8_t val);210 void remR3PhysWriteHCPtrU16(uint8_t *pbDstPhys, uint16_t val);211 void remR3PhysWriteHCPtrU32(uint8_t *pbDstPhys, uint32_t val);212 void remR3PhysWriteHCPtrU64(uint8_t *pbDstPhys, uint64_t val);213 #endif214 215 198 #ifdef PGM_DYNAMIC_RAM_ALLOC 216 # ifndef REM_PHYS_ADDR_IN_TLB217 void *remR3GCPhys2HCVirt(void *env, target_ulong addr);218 target_ulong remR3HCVirt2GCPhys(void *env, void *addr);219 # endif220 199 void remR3GrowDynRange(unsigned long physaddr); 221 200 #endif … … 228 207 static inline int ldub_p(void *ptr) 229 208 { 230 #ifdef REM_PHYS_ADDR_IN_TLB231 209 VBOX_CHECK_ADDR(ptr); 232 210 return remR3PhysReadU8((uintptr_t)ptr); 233 #else234 return remR3PhysReadHCPtrU8(ptr);235 #endif236 211 } 237 212 238 213 static inline int ldsb_p(void *ptr) 239 214 { 240 #ifdef REM_PHYS_ADDR_IN_TLB241 215 VBOX_CHECK_ADDR(ptr); 242 216 return remR3PhysReadS8((uintptr_t)ptr); 243 #else244 return remR3PhysReadHCPtrS8(ptr);245 #endif246 217 } 247 218 248 219 static inline void stb_p(void *ptr, int v) 249 220 { 250 #ifdef REM_PHYS_ADDR_IN_TLB251 221 VBOX_CHECK_ADDR(ptr); 252 222 remR3PhysWriteU8((uintptr_t)ptr, v); 253 #else254 remR3PhysWriteHCPtrU8(ptr, v);255 #endif256 223 } 257 224 258 225 static inline int lduw_le_p(void *ptr) 259 226 { 260 #ifdef REM_PHYS_ADDR_IN_TLB261 227 VBOX_CHECK_ADDR(ptr); 262 228 return remR3PhysReadU16((uintptr_t)ptr); 263 #else264 return remR3PhysReadHCPtrU16(ptr);265 #endif266 229 } 267 230 268 231 static inline int ldsw_le_p(void *ptr) 269 232 { 270 #ifdef REM_PHYS_ADDR_IN_TLB271 233 VBOX_CHECK_ADDR(ptr); 272 234 return remR3PhysReadS16((uintptr_t)ptr); 273 #else274 return remR3PhysReadHCPtrS16(ptr);275 #endif276 235 } 277 236 278 237 static inline void stw_le_p(void *ptr, int v) 279 238 { 280 #ifdef REM_PHYS_ADDR_IN_TLB281 239 VBOX_CHECK_ADDR(ptr); 282 240 remR3PhysWriteU16((uintptr_t)ptr, v); 283 #else284 remR3PhysWriteHCPtrU16(ptr, v);285 #endif286 241 } 287 242 288 243 static inline int ldl_le_p(void *ptr) 289 244 { 290 #ifdef REM_PHYS_ADDR_IN_TLB291 245 VBOX_CHECK_ADDR(ptr); 292 246 return remR3PhysReadU32((uintptr_t)ptr); 293 #else294 return remR3PhysReadHCPtrU32(ptr);295 #endif296 247 } 297 248 298 249 static inline void stl_le_p(void *ptr, int v) 299 250 { 300 #ifdef REM_PHYS_ADDR_IN_TLB301 251 VBOX_CHECK_ADDR(ptr); 302 252 remR3PhysWriteU32((uintptr_t)ptr, v); 303 #else304 remR3PhysWriteHCPtrU32(ptr, v);305 #endif306 253 } 307 254 308 255 static inline void stq_le_p(void *ptr, uint64_t v) 309 256 { 310 #ifdef REM_PHYS_ADDR_IN_TLB311 257 VBOX_CHECK_ADDR(ptr); 312 258 remR3PhysWriteU64((uintptr_t)ptr, v); 313 #else314 remR3PhysWriteHCPtrU64(ptr, v);315 #endif316 259 } 317 260 318 261 static inline uint64_t ldq_le_p(void *ptr) 319 262 { 320 #ifdef REM_PHYS_ADDR_IN_TLB321 263 VBOX_CHECK_ADDR(ptr); 322 264 return remR3PhysReadU64((uintptr_t)ptr); 323 #else324 return remR3PhysReadHCPtrU64(ptr);325 #endif326 265 } 327 266
Note:
See TracChangeset
for help on using the changeset viewer.