Changeset 1614 in vbox
- Timestamp:
- Mar 21, 2007 8:42:28 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/recompiler/new/VBoxRecompiler.c
r1613 r1614 87 87 static DECLCALLBACK(int) remR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version); 88 88 static void remR3StateUpdate(PVM pVM); 89 90 #ifdef PGM_DYNAMIC_RAM_ALLOC 91 DECLINLINE(target_ulong) remR3HCVirt2GCPhysInlined(PVM pVM, void *addr); 92 DECLINLINE(void *) remR3GCPhys2HCVirtInlined(PVM pVM, target_ulong addr); 93 #endif 94 89 95 static uint32_t remR3MMIOReadU8(void *pvVM, target_phys_addr_t GCPhys); 90 96 static uint32_t remR3MMIOReadU16(void *pvVM, target_phys_addr_t GCPhys); … … 117 123 static STAMPROFILEADV gStatRawCheck; 118 124 static STAMPROFILEADV gStatMemRead; 125 static STAMPROFILEADV gStatMemWrite; 126 #ifndef REM_PHYS_ADDR_IN_TLB 119 127 static STAMPROFILEADV gStatMemReadHCPtr; 120 static STAMPROFILEADV gStatMemWrite;121 128 static STAMPROFILEADV gStatMemWriteHCPtr; 129 #endif 130 #ifdef PGM_DYNAMIC_RAM_ALLOC 131 static STAMPROFILE gStatGCPhys2HCVirt; 132 static STAMPROFILE gStatHCVirt2GCPhys; 133 #endif 122 134 static STAMCOUNTER gStatRefuseTFInhibit; 123 135 static STAMCOUNTER gStatRefuseVM86; … … 301 313 pVM->rem.s.u32PendingInterrupt = REM_NO_PENDING_IRQ; 302 314 303 #ifdef DEBUG_bird304 //cpu_breakpoint_insert(&pVM->rem.s.Env, some-address);305 #endif306 307 315 /* 308 316 * Register ram types. … … 352 360 STAM_REG(pVM, &gStatRawCheck, STAMTYPE_PROFILE, "/PROF/REM/RawCheck", STAMUNIT_TICKS_PER_CALL, "Profiling timer scheduling."); 353 361 STAM_REG(pVM, &gStatMemRead, STAMTYPE_PROFILE, "/PROF/REM/MemRead", STAMUNIT_TICKS_PER_CALL, "Profiling memory access."); 362 STAM_REG(pVM, &gStatMemWrite, STAMTYPE_PROFILE, "/PROF/REM/MemWrite", STAMUNIT_TICKS_PER_CALL, "Profiling memory access."); 363 #ifndef REM_PHYS_ADDR_IN_TLB 354 364 STAM_REG(pVM, &gStatMemReadHCPtr, STAMTYPE_PROFILE, "/PROF/REM/MemReadHCPtr", STAMUNIT_TICKS_PER_CALL, "Profiling memory access."); 355 STAM_REG(pVM, &gStatMemWrite, STAMTYPE_PROFILE, "/PROF/REM/MemWrite", STAMUNIT_TICKS_PER_CALL, "Profiling memory access.");356 365 STAM_REG(pVM, &gStatMemWriteHCPtr, STAMTYPE_PROFILE, "/PROF/REM/MemWriteHCPtr", STAMUNIT_TICKS_PER_CALL, "Profiling memory access."); 366 #endif 367 #ifdef PGM_DYNAMIC_RAM_ALLOC 368 STAM_REG(pVM, &gStatHCVirt2GCPhys, STAMTYPE_PROFILE, "/PROF/REM/HCVirt2GCPhys", STAMUNIT_TICKS_PER_CALL, "Profiling memory convertion."); 369 STAM_REG(pVM, &gStatGCPhys2HCVirt, STAMTYPE_PROFILE, "/PROF/REM/GCPhys2HCVirt", STAMUNIT_TICKS_PER_CALL, "Profiling memory convertion."); 370 #endif 357 371 358 372 STAM_REG(pVM, &gStatRefuseTFInhibit, STAMTYPE_COUNTER, "/REM/Refuse/TFInibit", STAMUNIT_OCCURENCES, "Raw mode refused because of TF or irq inhibit"); … … 834 848 * right way in will cause serious trouble if a longjmp was attempted.) 835 849 */ 836 #ifdef DEBUG_bird850 # ifdef DEBUG_bird 837 851 remR3DisasInstr(&pVM->rem.s.Env, 1, "REMR3EmulateInstruction"); 838 #endif852 # endif 839 853 int cTimesMax = 16384; 840 854 uint32_t eip = pVM->rem.s.Env.eip; … … 1400 1414 phys_addr = virt_addr + addend; 1401 1415 # elif defined(PGM_DYNAMIC_RAM_ALLOC) 1402 phys_addr = remR3HCVirt2GCPhys (env, (void *)(virt_addr + addend));1416 phys_addr = remR3HCVirt2GCPhysInlined(env->pVM, (void *)(virt_addr + addend)); 1403 1417 # else 1404 1418 phys_addr = virt_addr - (uintptr_t)phys_ram_base + addend; … … 2666 2680 #ifdef PGM_DYNAMIC_RAM_ALLOC 2667 2681 # ifndef REM_PHYS_ADDR_IN_TLB 2682 #if 0 2683 static const uint8_t gabZeroPage[PAGE_SIZE]; 2684 #endif 2685 2668 2686 /** 2669 2687 * Convert GC physical address to HC virt … … 2673 2691 * @param addr The physical address. 2674 2692 */ 2675 void *remR3GCPhys2HCVirt(void *env, target_ulong addr) 2676 { 2677 PVM pVM = ((CPUState *)env)->pVM; 2693 DECLINLINE(void *) remR3GCPhys2HCVirtInlined(PVM pVM, target_ulong addr) 2694 { 2678 2695 uint32_t i; 2679 2696 void *pv; 2697 STAM_PROFILE_START(&gStatGCPhys2HCVirt, a); 2698 2699 #if 1 2680 2700 /* lookup in pVM->rem.s.aPhysReg array first (for ROM range(s) inside the guest's RAM) */ 2681 2701 for (i = 0; i < pVM->rem.s.cPhysRegistrations; i++) 2682 2702 { 2683 uint32_toff = addr - pVM->rem.s.aPhysReg[i].GCPhys;2703 RTGCPHYS off = addr - pVM->rem.s.aPhysReg[i].GCPhys; 2684 2704 if (off < pVM->rem.s.aPhysReg[i].cb) 2685 2705 { 2686 Log(("remR3GCPhys2HCVirt: %x -> %x\n", addr, pVM->rem.s.aPhysReg[i].HCVirt + off)); 2687 return (void *)(pVM->rem.s.aPhysReg[i].HCVirt + off); 2706 pv = (void *)(pVM->rem.s.aPhysReg[i].HCVirt + off); 2707 Log(("remR3GCPhys2HCVirt: %x -> %x\n", addr, pv)); 2708 STAM_PROFILE_STOP(&gStatGCPhys2HCVirt, a); 2709 return pv; 2688 2710 } 2689 2711 } 2690 2712 AssertMsg(addr < phys_ram_size, ("remR3GCPhys2HCVirt: unknown physical address %x\n", addr)); 2691 Log(("remR3GCPhys2HCVirt: %x -> %x\n", addr, pVM->rem.s.paGCPhysToHCVirt[addr >> PGM_DYNAMIC_CHUNK_SHIFT] + (addr & PGM_DYNAMIC_CHUNK_OFFSET_MASK))); 2692 return (void *)(pVM->rem.s.paGCPhysToHCVirt[addr >> PGM_DYNAMIC_CHUNK_SHIFT] + (addr & PGM_DYNAMIC_CHUNK_OFFSET_MASK)); 2713 pv = (void *)(pVM->rem.s.paGCPhysToHCVirt[addr >> PGM_DYNAMIC_CHUNK_SHIFT] + (addr & PGM_DYNAMIC_CHUNK_OFFSET_MASK)); 2714 Log(("remR3GCPhys2HCVirt: %x -> %x\n", addr, pv)); 2715 #else 2716 /** @todo figure out why this is faster than the above code. */ 2717 int rc = PGMPhysGCPhys2HCPtr(pVM, addr & X86_PTE_PAE_PG_MASK, PAGE_SIZE, &pv); 2718 if (RT_FAILURE(rc)) 2719 { 2720 AssertMsgFailed(("remR3GCPhys2HCVirt: unknown physical address %x\n", addr)); 2721 pv = gabZeroPage; 2722 } 2723 pv = (void *)((uintptr_t)pv | (addr & PAGE_OFFSET_MASK)); 2724 #endif 2725 return pv; 2693 2726 } 2694 2727 … … 2701 2734 * @param addr The physical address. 2702 2735 */ 2703 target_ulong remR3HCVirt2GCPhys(void *env, void *addr) 2704 { 2705 PVM pVM = ((CPUState *)env)->pVM; 2736 DECLINLINE(target_ulong) remR3HCVirt2GCPhysInlined(PVM pVM, void *addr) 2737 { 2706 2738 RTHCUINTPTR HCVirt = (RTHCUINTPTR)addr; 2707 2739 uint32_t idx = (HCVirt >> PGM_DYNAMIC_CHUNK_SHIFT); 2708 2740 RTHCUINTPTR off; 2709 2741 RTUINT i; 2742 target_ulong GCPhys; 2710 2743 2711 2744 off = HCVirt - pVM->rem.s.paHCVirtToGCPhys[idx].pChunk1; … … 2714 2747 && off < PGM_DYNAMIC_CHUNK_SIZE) 2715 2748 { 2716 Log2(("remR3HCVirt2GCPhys %x -> %x\n", addr, pVM->rem.s.paHCVirtToGCPhys[idx].GCPhys1 + off)); 2717 return pVM->rem.s.paHCVirtToGCPhys[idx].GCPhys1 + off; 2749 GCPhys = pVM->rem.s.paHCVirtToGCPhys[idx].GCPhys1 + off; 2750 Log2(("remR3HCVirt2GCPhys %x -> %x\n", addr, GCPhys)); 2751 return GCPhys; 2718 2752 } 2719 2753 … … 2722 2756 && off < PGM_DYNAMIC_CHUNK_SIZE) 2723 2757 { 2724 Log2(("remR3HCVirt2GCPhys %x -> %x\n", addr, pVM->rem.s.paHCVirtToGCPhys[idx].GCPhys2 + off)); 2725 return pVM->rem.s.paHCVirtToGCPhys[idx].GCPhys2 + off; 2758 GCPhys = pVM->rem.s.paHCVirtToGCPhys[idx].GCPhys2 + off; 2759 Log2(("remR3HCVirt2GCPhys %x -> %x\n", addr, GCPhys)); 2760 return GCPhys; 2726 2761 } 2727 2762 … … 2732 2767 if (off < pVM->rem.s.aPhysReg[i].cb) 2733 2768 { 2734 Log2(("remR3HCVirt2GCPhys %x -> %x\n", addr, pVM->rem.s.aPhysReg[i].GCPhys + off)); 2735 return pVM->rem.s.aPhysReg[i].GCPhys + off; 2769 GCPhys = pVM->rem.s.aPhysReg[i].GCPhys + off; 2770 Log2(("remR3HCVirt2GCPhys %x -> %x\n", addr, GCPhys)); 2771 return GCPhys; 2736 2772 } 2737 2773 } … … 2739 2775 return 0; 2740 2776 } 2777 2778 /** 2779 * Convert GC physical address to HC virt 2780 * 2781 * @returns The HC virt address corresponding to addr. 2782 * @param env The cpu environment. 2783 * @param addr The physical address. 2784 */ 2785 void *remR3GCPhys2HCVirt(void *env, target_ulong addr) 2786 { 2787 PVM pVM = ((CPUState *)env)->pVM; 2788 void *pv; 2789 STAM_PROFILE_START(&gStatGCPhys2HCVirt, a); 2790 pv = remR3GCPhys2HCVirtInlined(pVM, addr); 2791 STAM_PROFILE_STOP(&gStatGCPhys2HCVirt, a); 2792 return pv; 2793 } 2794 2795 2796 /** 2797 * Convert GC physical address to HC virt 2798 * 2799 * @returns The HC virt address corresponding to addr. 2800 * @param env The cpu environment. 2801 * @param addr The physical address. 2802 */ 2803 target_ulong remR3HCVirt2GCPhys(void *env, void *addr) 2804 { 2805 PVM pVM = ((CPUState *)env)->pVM; 2806 target_ulong GCPhys; 2807 STAM_PROFILE_START(&gStatHCVirt2GCPhys, a); 2808 GCPhys = remR3HCVirt2GCPhysInlined(pVM, addr); 2809 STAM_PROFILE_STOP(&gStatHCVirt2GCPhys, a); 2810 return GCPhys; 2811 } 2812 2741 2813 # endif /* !REM_PHYS_ADDR_IN_TLB */ 2742 2814 … … 2936 3008 cpu_register_physical_memory(GCPhys, cb, GCPhys); 2937 3009 #elif defined(PGM_DYNAMIC_RAM_ALLOC) 2938 Assert(remR3HCVirt2GCPhys (cpu_single_env, pvHCPtr) < MMR3PhysGetRamSize(pVM));3010 Assert(remR3HCVirt2GCPhysInlined(pVM, pvHCPtr) < MMR3PhysGetRamSize(pVM)); 2939 3011 cpu_register_physical_memory(GCPhys, cb, GCPhys); 2940 3012 #else … … 2989 3061 cpu_register_physical_memory(GCPhysOld, cb, GCPhysOld); 2990 3062 #elif defined(PGM_DYNAMIC_RAM_ALLOC) 2991 Assert(remR3HCVirt2GCPhys (cpu_single_env, pvHCPtr) < MMR3PhysGetRamSize(pVM));3063 Assert(remR3HCVirt2GCPhysInlined(pVM, pvHCPtr) < MMR3PhysGetRamSize(pVM)); 2992 3064 cpu_register_physical_memory(GCPhysOld, cb, GCPhysOld); 2993 3065 #else … … 3221 3293 VBOX_CHECK_ADDR(DstGCPhys); 3222 3294 PGMPhysWrite(cpu_single_env->pVM, DstGCPhys, pvSrc, cb); 3223 STAM_PROFILE_ADV_STOP(&gStatMemWrite HCPtr, a);3295 STAM_PROFILE_ADV_STOP(&gStatMemWrite, a); 3224 3296 } 3225 3297 … … 3233 3305 void remR3PhysWriteU8(RTGCPHYS DstGCPhys, uint8_t val) 3234 3306 { 3235 STAM_PROFILE_ADV_START(&gStatMemWrite HCPtr, a);3307 STAM_PROFILE_ADV_START(&gStatMemWrite, a); 3236 3308 VBOX_CHECK_ADDR(DstGCPhys); 3237 3309 PGMR3PhysWriteByte(cpu_single_env->pVM, DstGCPhys, val); 3238 STAM_PROFILE_ADV_STOP(&gStatMemWrite HCPtr, a);3310 STAM_PROFILE_ADV_STOP(&gStatMemWrite, a); 3239 3311 } 3240 3312 … … 3248 3320 void remR3PhysWriteU16(RTGCPHYS DstGCPhys, uint16_t val) 3249 3321 { 3250 STAM_PROFILE_ADV_START(&gStatMemWrite HCPtr, a);3322 STAM_PROFILE_ADV_START(&gStatMemWrite, a); 3251 3323 VBOX_CHECK_ADDR(DstGCPhys); 3252 3324 PGMR3PhysWriteWord(cpu_single_env->pVM, DstGCPhys, val); 3253 STAM_PROFILE_ADV_STOP(&gStatMemWrite HCPtr, a);3325 STAM_PROFILE_ADV_STOP(&gStatMemWrite, a); 3254 3326 } 3255 3327 … … 3263 3335 void remR3PhysWriteU32(RTGCPHYS DstGCPhys, uint32_t val) 3264 3336 { 3265 STAM_PROFILE_ADV_START(&gStatMemWrite HCPtr, a);3337 STAM_PROFILE_ADV_START(&gStatMemWrite, a); 3266 3338 VBOX_CHECK_ADDR(DstGCPhys); 3267 3339 PGMR3PhysWriteDword(cpu_single_env->pVM, DstGCPhys, val); 3268 STAM_PROFILE_ADV_STOP(&gStatMemWrite HCPtr, a);3340 STAM_PROFILE_ADV_STOP(&gStatMemWrite, a); 3269 3341 } 3270 3342 … … 3278 3350 void remR3PhysWriteU64(RTGCPHYS DstGCPhys, uint64_t val) 3279 3351 { 3280 STAM_PROFILE_ADV_START(&gStatMemWrite HCPtr, a);3352 STAM_PROFILE_ADV_START(&gStatMemWrite, a); 3281 3353 VBOX_CHECK_ADDR(DstGCPhys); 3282 3354 PGMR3PhysWriteDword(cpu_single_env->pVM, DstGCPhys, (uint32_t)val); /** @todo add U64 interface. */ 3283 3355 PGMR3PhysWriteDword(cpu_single_env->pVM, DstGCPhys + 4, val >> 32); 3284 STAM_PROFILE_ADV_STOP(&gStatMemWrite HCPtr, a);3356 STAM_PROFILE_ADV_STOP(&gStatMemWrite, a); 3285 3357 } 3286 3358 … … 3305 3377 /** @todo This is rather ugly, but there's no other way when we don't wish to touch *many* other files. */ 3306 3378 #ifdef PGM_DYNAMIC_RAM_ALLOC 3307 uintptr_t off = remR3HCVirt2GCPhys (cpu_single_env, pbSrcPhys);3379 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys); 3308 3380 #else 3309 3381 uintptr_t off = pbSrcPhys - phys_ram_base; … … 3337 3409 */ 3338 3410 #ifdef PGM_DYNAMIC_RAM_ALLOC 3339 uintptr_t off = remR3HCVirt2GCPhys (cpu_single_env, pbSrcPhys);3411 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys); 3340 3412 #else 3341 3413 uintptr_t off = pbSrcPhys - phys_ram_base; … … 3370 3442 */ 3371 3443 #ifdef PGM_DYNAMIC_RAM_ALLOC 3372 uintptr_t off = remR3HCVirt2GCPhys (cpu_single_env, pbSrcPhys);3444 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys); 3373 3445 #else 3374 3446 uintptr_t off = pbSrcPhys - phys_ram_base; … … 3403 3475 */ 3404 3476 #ifdef PGM_DYNAMIC_RAM_ALLOC 3405 uintptr_t off = remR3HCVirt2GCPhys (cpu_single_env, pbSrcPhys);3477 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys); 3406 3478 #else 3407 3479 uintptr_t off = pbSrcPhys - phys_ram_base; … … 3437 3509 /** @todo This is rather ugly, but there's no other way when we don't wish to touch *many* other files. */ 3438 3510 #ifdef PGM_DYNAMIC_RAM_ALLOC 3439 uintptr_t off = remR3HCVirt2GCPhys (cpu_single_env, pbSrcPhys);3511 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys); 3440 3512 #else 3441 3513 uintptr_t off = pbSrcPhys - phys_ram_base; … … 3470 3542 */ 3471 3543 #ifdef PGM_DYNAMIC_RAM_ALLOC 3472 uintptr_t off = remR3HCVirt2GCPhys (cpu_single_env, pbSrcPhys);3544 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys); 3473 3545 #else 3474 3546 uintptr_t off = pbSrcPhys - phys_ram_base; … … 3503 3575 */ 3504 3576 #ifdef PGM_DYNAMIC_RAM_ALLOC 3505 uintptr_t off = remR3HCVirt2GCPhys (cpu_single_env, pbSrcPhys);3577 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys); 3506 3578 #else 3507 3579 uintptr_t off = pbSrcPhys - phys_ram_base; … … 3536 3608 */ 3537 3609 #ifdef PGM_DYNAMIC_RAM_ALLOC 3538 uintptr_t off = remR3HCVirt2GCPhys (cpu_single_env, pbSrcPhys);3610 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys); 3539 3611 #else 3540 3612 uintptr_t off = pbSrcPhys - phys_ram_base; … … 3568 3640 */ 3569 3641 #ifdef PGM_DYNAMIC_RAM_ALLOC 3570 uintptr_t off = remR3HCVirt2GCPhys (cpu_single_env, pbDstPhys);3642 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbDstPhys); 3571 3643 #else 3572 3644 uintptr_t off = pbDstPhys - phys_ram_base; … … 3593 3665 */ 3594 3666 #ifdef PGM_DYNAMIC_RAM_ALLOC 3595 uintptr_t off = remR3HCVirt2GCPhys (cpu_single_env, pbDstPhys);3667 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbDstPhys); 3596 3668 #else 3597 3669 uintptr_t off = pbDstPhys - phys_ram_base; … … 3618 3690 */ 3619 3691 #ifdef PGM_DYNAMIC_RAM_ALLOC 3620 uintptr_t off = remR3HCVirt2GCPhys (cpu_single_env, pbDstPhys);3692 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbDstPhys); 3621 3693 #else 3622 3694 uintptr_t off = pbDstPhys - phys_ram_base; … … 3643 3715 */ 3644 3716 #ifdef PGM_DYNAMIC_RAM_ALLOC 3645 uintptr_t off = remR3HCVirt2GCPhys (cpu_single_env, pbDstPhys);3717 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbDstPhys); 3646 3718 #else 3647 3719 uintptr_t off = pbDstPhys - phys_ram_base; … … 3668 3740 */ 3669 3741 #ifdef PGM_DYNAMIC_RAM_ALLOC 3670 uintptr_t off = remR3HCVirt2GCPhys (cpu_single_env, pbDstPhys);3742 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbDstPhys); 3671 3743 #else 3672 3744 uintptr_t off = pbDstPhys - phys_ram_base;
Note:
See TracChangeset
for help on using the changeset viewer.