Changeset 2364 in vbox
- Timestamp:
- Apr 26, 2007 6:49:27 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/src/recompiler/new/VBoxRecompiler.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/recompiler/new/VBoxRecompiler.c
r2223 r2364 3392 3392 * ROM is accessed this way, even if it's not part of the RAM. 3393 3393 */ 3394 #ifdef PGM_DYNAMIC_RAM_ALLOC 3395 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys); 3396 #else 3397 uintptr_t off = pbSrcPhys - phys_ram_base; 3398 #endif 3399 PGMPhysRead(cpu_single_env->pVM, (RTGCPHYS)off, pvDst, cb); 3400 STAM_PROFILE_ADV_STOP(&gStatMemReadHCPtr, a); 3401 } 3402 3403 3404 /** 3405 * Read guest RAM and ROM, unsigned 8-bit. 3406 * 3407 * @param pbSrcPhys The source address. Relative to guest RAM. 3408 */ 3409 uint8_t remR3PhysReadHCPtrU8(uint8_t *pbSrcPhys) 3410 { 3411 uint8_t val; 3412 3413 STAM_PROFILE_ADV_START(&gStatMemReadHCPtr, a); 3414 3415 /* 3416 * Calc the physical address ('off') and check that it's within the RAM. 3417 * ROM is accessed this way, even if it's not part of the RAM. 3418 */ 3419 #ifdef PGM_DYNAMIC_RAM_ALLOC 3420 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys); 3421 #else 3422 uintptr_t off = pbSrcPhys - phys_ram_base; 3423 #endif 3424 val = PGMR3PhysReadByte(cpu_single_env->pVM, (RTGCPHYS)off); 3425 STAM_PROFILE_ADV_STOP(&gStatMemReadHCPtr, a); 3426 return val; 3427 } 3428 3429 3430 /** 3431 * Read guest RAM and ROM, signed 8-bit. 3432 * 3433 * @param pbSrcPhys The source address. Relative to guest RAM. 3434 */ 3435 int8_t remR3PhysReadHCPtrS8(uint8_t *pbSrcPhys) 3436 { 3437 int8_t val; 3438 3439 STAM_PROFILE_ADV_START(&gStatMemReadHCPtr, a); 3440 3441 /* 3442 * Calc the physical address ('off') and check that it's within the RAM. 3443 * ROM is accessed this way, even if it's not part of the RAM. 3444 */ 3445 #ifdef PGM_DYNAMIC_RAM_ALLOC 3446 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys); 3447 #else 3448 uintptr_t off = pbSrcPhys - phys_ram_base; 3449 #endif 3450 val = PGMR3PhysReadByte(cpu_single_env->pVM, (RTGCPHYS)off); 3451 STAM_PROFILE_ADV_STOP(&gStatMemReadHCPtr, a); 3452 return val; 3453 } 3454 3455 3456 /** 3457 * Read guest RAM and ROM, unsigned 16-bit. 3458 * 3459 * @param pbSrcPhys The source address. Relative to guest RAM. 3460 */ 3461 uint16_t remR3PhysReadHCPtrU16(uint8_t *pbSrcPhys) 3462 { 3463 uint16_t val; 3464 3465 STAM_PROFILE_ADV_START(&gStatMemReadHCPtr, a); 3466 3467 /* 3468 * Calc the physical address ('off') and check that it's within the RAM. 3469 * ROM is accessed this way, even if it's not part of the RAM. 3470 */ 3471 #ifdef PGM_DYNAMIC_RAM_ALLOC 3472 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys); 3473 #else 3474 uintptr_t off = pbSrcPhys - phys_ram_base; 3475 #endif 3476 val = PGMR3PhysReadWord(cpu_single_env->pVM, (RTGCPHYS)off); 3477 STAM_PROFILE_ADV_STOP(&gStatMemReadHCPtr, a); 3478 return val; 3479 } 3480 3481 3482 /** 3483 * Read guest RAM and ROM, signed 16-bit. 3484 * 3485 * @param pbSrcPhys The source address. Relative to guest RAM. 3486 */ 3487 int16_t remR3PhysReadHCPtrS16(uint8_t *pbSrcPhys) 3488 { 3489 int16_t val; 3490 3491 STAM_PROFILE_ADV_START(&gStatMemReadHCPtr, a); 3492 3493 /* 3494 * Calc the physical address ('off') and check that it's within the RAM. 3495 * ROM is accessed this way, even if it's not part of the RAM. 3496 */ 3394 3497 /** @todo This is rather ugly, but there's no other way when we don't wish to touch *many* other files. */ 3395 3498 #ifdef PGM_DYNAMIC_RAM_ALLOC … … 3398 3501 uintptr_t off = pbSrcPhys - phys_ram_base; 3399 3502 #endif 3400 if (off < (uintptr_t)phys_ram_size) 3401 PGMPhysRead(cpu_single_env->pVM, (RTGCPHYS)off, pvDst, cb); 3402 else 3403 { 3404 /* ROM range outside physical RAM, HC address passed directly */ 3405 Log4(("remR3PhysRead ROM: %p\n", pbSrcPhys)); 3406 memcpy(pvDst, pbSrcPhys, cb); 3407 } 3503 val = PGMR3PhysReadWord(cpu_single_env->pVM, (RTGCPHYS)off); 3408 3504 STAM_PROFILE_ADV_STOP(&gStatMemReadHCPtr, a); 3409 } 3410 3411 3412 /** 3413 * Read guest RAM and ROM, unsigned 8-bit. 3505 return val; 3506 } 3507 3508 3509 /** 3510 * Read guest RAM and ROM, unsigned 32-bit. 3414 3511 * 3415 3512 * @param pbSrcPhys The source address. Relative to guest RAM. 3416 3513 */ 3417 uint 8_t remR3PhysReadHCPtrU8(uint8_t *pbSrcPhys)3418 { 3419 uint 8_t val;3514 uint32_t remR3PhysReadHCPtrU32(uint8_t *pbSrcPhys) 3515 { 3516 uint32_t val; 3420 3517 3421 3518 STAM_PROFILE_ADV_START(&gStatMemReadHCPtr, a); … … 3430 3527 uintptr_t off = pbSrcPhys - phys_ram_base; 3431 3528 #endif 3432 if (off < (uintptr_t)phys_ram_size) 3433 val = PGMR3PhysReadByte(cpu_single_env->pVM, (RTGCPHYS)off); 3434 else 3435 { 3436 /* ROM range outside physical RAM, HC address passed directly */ 3437 Log4(("remR3PhysReadU8 ROM: %p\n", pbSrcPhys)); 3438 val = *pbSrcPhys; 3439 } 3529 val = PGMR3PhysReadDword(cpu_single_env->pVM, (RTGCPHYS)off); 3440 3530 STAM_PROFILE_ADV_STOP(&gStatMemReadHCPtr, a); 3441 3531 return val; … … 3444 3534 3445 3535 /** 3446 * Read guest RAM and ROM, signed 8-bit.3536 * Read guest RAM and ROM, signed 32-bit. 3447 3537 * 3448 3538 * @param pbSrcPhys The source address. Relative to guest RAM. 3449 3539 */ 3450 int 8_t remR3PhysReadHCPtrS8(uint8_t *pbSrcPhys)3451 { 3452 int 8_t val;3540 int32_t remR3PhysReadHCPtrS32(uint8_t *pbSrcPhys) 3541 { 3542 int32_t val; 3453 3543 3454 3544 STAM_PROFILE_ADV_START(&gStatMemReadHCPtr, a); … … 3463 3553 uintptr_t off = pbSrcPhys - phys_ram_base; 3464 3554 #endif 3465 if (off < (uintptr_t)phys_ram_size) 3466 val = PGMR3PhysReadByte(cpu_single_env->pVM, (RTGCPHYS)off); 3467 else 3468 { 3469 /* ROM range outside physical RAM, HC address passed directly */ 3470 Log4(("remR3PhysReadS8 ROM: %p\n", pbSrcPhys)); 3471 val = *(int8_t *)pbSrcPhys; 3472 } 3555 val = PGMR3PhysReadDword(cpu_single_env->pVM, (RTGCPHYS)off); 3473 3556 STAM_PROFILE_ADV_STOP(&gStatMemReadHCPtr, a); 3474 3557 return val; … … 3477 3560 3478 3561 /** 3479 * Read guest RAM and ROM, unsigned 16-bit.3562 * Read guest RAM and ROM, unsigned 64-bit. 3480 3563 * 3481 3564 * @param pbSrcPhys The source address. Relative to guest RAM. 3482 3565 */ 3483 uint 16_t remR3PhysReadHCPtrU16(uint8_t *pbSrcPhys)3484 { 3485 uint 16_t val;3566 uint64_t remR3PhysReadHCPtrU64(uint8_t *pbSrcPhys) 3567 { 3568 uint64_t val; 3486 3569 3487 3570 STAM_PROFILE_ADV_START(&gStatMemReadHCPtr, a); … … 3496 3579 uintptr_t off = pbSrcPhys - phys_ram_base; 3497 3580 #endif 3498 if (off < (uintptr_t)phys_ram_size) 3499 val = PGMR3PhysReadWord(cpu_single_env->pVM, (RTGCPHYS)off); 3500 else 3501 { 3502 /* ROM range outside physical RAM, HC address passed directly */ 3503 Log4(("remR3PhysReadU16 ROM: %p\n", pbSrcPhys)); 3504 val = *(uint16_t *)pbSrcPhys; 3505 } 3506 STAM_PROFILE_ADV_STOP(&gStatMemReadHCPtr, a); 3507 return val; 3508 } 3509 3510 3511 /** 3512 * Read guest RAM and ROM, signed 16-bit. 3513 * 3514 * @param pbSrcPhys The source address. Relative to guest RAM. 3515 */ 3516 int16_t remR3PhysReadHCPtrS16(uint8_t *pbSrcPhys) 3517 { 3518 int16_t val; 3519 3520 STAM_PROFILE_ADV_START(&gStatMemReadHCPtr, a); 3521 3522 /* 3523 * Calc the physical address ('off') and check that it's within the RAM. 3524 * ROM is accessed this way, even if it's not part of the RAM. 3525 */ 3526 /** @todo This is rather ugly, but there's no other way when we don't wish to touch *many* other files. */ 3527 #ifdef PGM_DYNAMIC_RAM_ALLOC 3528 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys); 3529 #else 3530 uintptr_t off = pbSrcPhys - phys_ram_base; 3531 #endif 3532 if (off < (uintptr_t)phys_ram_size) 3533 val = PGMR3PhysReadWord(cpu_single_env->pVM, (RTGCPHYS)off); 3534 else 3535 { 3536 /* ROM range outside physical RAM, HC address passed directly */ 3537 Log4(("remR3PhysReadS16 ROM: %p\n", pbSrcPhys)); 3538 val = *(int16_t *)pbSrcPhys; 3539 } 3540 STAM_PROFILE_ADV_STOP(&gStatMemReadHCPtr, a); 3541 return val; 3542 } 3543 3544 3545 /** 3546 * Read guest RAM and ROM, unsigned 32-bit. 3547 * 3548 * @param pbSrcPhys The source address. Relative to guest RAM. 3549 */ 3550 uint32_t remR3PhysReadHCPtrU32(uint8_t *pbSrcPhys) 3551 { 3552 uint32_t val; 3553 3554 STAM_PROFILE_ADV_START(&gStatMemReadHCPtr, a); 3555 3556 /* 3557 * Calc the physical address ('off') and check that it's within the RAM. 3558 * ROM is accessed this way, even if it's not part of the RAM. 3559 */ 3560 #ifdef PGM_DYNAMIC_RAM_ALLOC 3561 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys); 3562 #else 3563 uintptr_t off = pbSrcPhys - phys_ram_base; 3564 #endif 3565 if (off < (uintptr_t)phys_ram_size) 3566 val = PGMR3PhysReadDword(cpu_single_env->pVM, (RTGCPHYS)off); 3567 else 3568 { 3569 /* ROM range outside physical RAM, HC address passed directly */ 3570 Log4(("remR3PhysReadU32 ROM: %p\n", pbSrcPhys)); 3571 val = *(uint32_t *)pbSrcPhys; 3572 } 3573 STAM_PROFILE_ADV_STOP(&gStatMemReadHCPtr, a); 3574 return val; 3575 } 3576 3577 3578 /** 3579 * Read guest RAM and ROM, signed 32-bit. 3580 * 3581 * @param pbSrcPhys The source address. Relative to guest RAM. 3582 */ 3583 int32_t remR3PhysReadHCPtrS32(uint8_t *pbSrcPhys) 3584 { 3585 int32_t val; 3586 3587 STAM_PROFILE_ADV_START(&gStatMemReadHCPtr, a); 3588 3589 /* 3590 * Calc the physical address ('off') and check that it's within the RAM. 3591 * ROM is accessed this way, even if it's not part of the RAM. 3592 */ 3593 #ifdef PGM_DYNAMIC_RAM_ALLOC 3594 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys); 3595 #else 3596 uintptr_t off = pbSrcPhys - phys_ram_base; 3597 #endif 3598 if (off < (uintptr_t)phys_ram_size) 3599 val = PGMR3PhysReadDword(cpu_single_env->pVM, (RTGCPHYS)off); 3600 else 3601 { 3602 /* ROM range outside physical RAM, HC address passed directly */ 3603 Log4(("remR3PhysReadS32 ROM: %p\n", pbSrcPhys)); 3604 val = *(int32_t *)pbSrcPhys; 3605 } 3606 STAM_PROFILE_ADV_STOP(&gStatMemReadHCPtr, a); 3607 return val; 3608 } 3609 3610 3611 /** 3612 * Read guest RAM and ROM, unsigned 64-bit. 3613 * 3614 * @param pbSrcPhys The source address. Relative to guest RAM. 3615 */ 3616 uint64_t remR3PhysReadHCPtrU64(uint8_t *pbSrcPhys) 3617 { 3618 uint64_t val; 3619 3620 STAM_PROFILE_ADV_START(&gStatMemReadHCPtr, a); 3621 3622 /* 3623 * Calc the physical address ('off') and check that it's within the RAM. 3624 * ROM is accessed this way, even if it's not part of the RAM. 3625 */ 3626 #ifdef PGM_DYNAMIC_RAM_ALLOC 3627 uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys); 3628 #else 3629 uintptr_t off = pbSrcPhys - phys_ram_base; 3630 #endif 3631 if (off < (uintptr_t)phys_ram_size) 3632 val = PGMR3PhysReadDword(cpu_single_env->pVM, (RTGCPHYS)off) 3633 | ((uint64_t)PGMR3PhysReadDword(cpu_single_env->pVM, (RTGCPHYS)off + 4) << 32); /** @todo fix me! */ 3634 else 3635 { 3636 /* ROM range outside physical RAM, HC address passed directly */ 3637 Log4(("remR3PhysReadU64 ROM: %p\n", pbSrcPhys)); 3638 val = *(uint32_t *)pbSrcPhys; 3639 } 3581 val = PGMR3PhysReadDword(cpu_single_env->pVM, (RTGCPHYS)off) 3582 | ((uint64_t)PGMR3PhysReadDword(cpu_single_env->pVM, (RTGCPHYS)off + 4) << 32); /** @todo fix me! */ 3640 3583 STAM_PROFILE_ADV_STOP(&gStatMemReadHCPtr, a); 3641 3584 return val; … … 3661 3604 uintptr_t off = pbDstPhys - phys_ram_base; 3662 3605 #endif 3663 if (off < (uintptr_t)phys_ram_size) 3664 PGMPhysWrite(cpu_single_env->pVM, (RTGCPHYS)off, pvSrc, cb); 3665 else 3666 AssertMsgFailed(("pbDstPhys=%p off=%p cb=%d\n", pbDstPhys, off, cb)); 3606 PGMPhysWrite(cpu_single_env->pVM, (RTGCPHYS)off, pvSrc, cb); 3667 3607 STAM_PROFILE_ADV_STOP(&gStatMemWriteHCPtr, a); 3668 3608 } … … 3686 3626 uintptr_t off = pbDstPhys - phys_ram_base; 3687 3627 #endif 3688 if (off < (uintptr_t)phys_ram_size) 3689 PGMR3PhysWriteByte(cpu_single_env->pVM, (RTGCPHYS)off, val); 3690 else 3691 AssertMsgFailed(("pbDstPhys=%p off=%p cb=%d\n", pbDstPhys, off, 1)); 3628 PGMR3PhysWriteByte(cpu_single_env->pVM, (RTGCPHYS)off, val); 3692 3629 STAM_PROFILE_ADV_STOP(&gStatMemWriteHCPtr, a); 3693 3630 } … … 3711 3648 uintptr_t off = pbDstPhys - phys_ram_base; 3712 3649 #endif 3713 if (off < (uintptr_t)phys_ram_size) 3714 PGMR3PhysWriteWord(cpu_single_env->pVM, (RTGCPHYS)off, val); 3715 else 3716 AssertMsgFailed(("pbDstPhys=%p off=%p cb=%d\n", pbDstPhys, off, 2)); 3650 PGMR3PhysWriteWord(cpu_single_env->pVM, (RTGCPHYS)off, val); 3717 3651 STAM_PROFILE_ADV_STOP(&gStatMemWriteHCPtr, a); 3718 3652 } … … 3736 3670 uintptr_t off = pbDstPhys - phys_ram_base; 3737 3671 #endif 3738 if (off < (uintptr_t)phys_ram_size) 3739 PGMR3PhysWriteDword(cpu_single_env->pVM, (RTGCPHYS)off, val); 3740 else 3741 AssertMsgFailed(("pbDstPhys=%p off=%p cb=%d\n", pbDstPhys, off, 4)); 3672 PGMR3PhysWriteDword(cpu_single_env->pVM, (RTGCPHYS)off, val); 3742 3673 STAM_PROFILE_ADV_STOP(&gStatMemWriteHCPtr, a); 3743 3674 } … … 3761 3692 uintptr_t off = pbDstPhys - phys_ram_base; 3762 3693 #endif 3763 if (off < (uintptr_t)phys_ram_size) 3764 { 3765 PGMR3PhysWriteDword(cpu_single_env->pVM, (RTGCPHYS)off, (uint32_t)val); /** @todo add U64 interface. */ 3766 PGMR3PhysWriteDword(cpu_single_env->pVM, (RTGCPHYS)off + 4, val >> 32); 3767 } 3768 else 3769 AssertMsgFailed(("pbDstPhys=%p off=%p cb=%d\n", pbDstPhys, off, 4)); 3694 PGMR3PhysWriteDword(cpu_single_env->pVM, (RTGCPHYS)off, (uint32_t)val); /** @todo add U64 interface. */ 3695 PGMR3PhysWriteDword(cpu_single_env->pVM, (RTGCPHYS)off + 4, val >> 32); 3770 3696 STAM_PROFILE_ADV_STOP(&gStatMemWriteHCPtr, a); 3771 3697 }
Note:
See TracChangeset
for help on using the changeset viewer.

