VirtualBox

Changeset 2364 in vbox


Ignore:
Timestamp:
Apr 26, 2007 6:49:27 PM (17 years ago)
Author:
vboxsync
Message:

The Read/Write function has to deal with non-ram memory as well (like VGA).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/recompiler/new/VBoxRecompiler.c

    r2223 r2364  
    33923392     * ROM is accessed this way, even if it's not part of the RAM.
    33933393     */
     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 */
     3409uint8_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 */
     3435int8_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 */
     3461uint16_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 */
     3487int16_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     */
    33943497    /** @todo This is rather ugly, but there's no other way when we don't wish to touch *many* other files. */
    33953498#ifdef PGM_DYNAMIC_RAM_ALLOC
     
    33983501    uintptr_t off = pbSrcPhys - phys_ram_base;
    33993502#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);
    34083504    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.
    34143511 *
    34153512 * @param   pbSrcPhys       The source address. Relative to guest RAM.
    34163513 */
    3417 uint8_t remR3PhysReadHCPtrU8(uint8_t *pbSrcPhys)
    3418 {
    3419     uint8_t val;
     3514uint32_t remR3PhysReadHCPtrU32(uint8_t *pbSrcPhys)
     3515{
     3516    uint32_t val;
    34203517
    34213518    STAM_PROFILE_ADV_START(&gStatMemReadHCPtr, a);
     
    34303527    uintptr_t off = pbSrcPhys - phys_ram_base;
    34313528#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);
    34403530    STAM_PROFILE_ADV_STOP(&gStatMemReadHCPtr, a);
    34413531    return val;
     
    34443534
    34453535/**
    3446  * Read guest RAM and ROM, signed 8-bit.
     3536 * Read guest RAM and ROM, signed 32-bit.
    34473537 *
    34483538 * @param   pbSrcPhys       The source address. Relative to guest RAM.
    34493539 */
    3450 int8_t remR3PhysReadHCPtrS8(uint8_t *pbSrcPhys)
    3451 {
    3452     int8_t val;
     3540int32_t remR3PhysReadHCPtrS32(uint8_t *pbSrcPhys)
     3541{
     3542    int32_t val;
    34533543
    34543544    STAM_PROFILE_ADV_START(&gStatMemReadHCPtr, a);
     
    34633553    uintptr_t off = pbSrcPhys - phys_ram_base;
    34643554#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);
    34733556    STAM_PROFILE_ADV_STOP(&gStatMemReadHCPtr, a);
    34743557    return val;
     
    34773560
    34783561/**
    3479  * Read guest RAM and ROM, unsigned 16-bit.
     3562 * Read guest RAM and ROM, unsigned 64-bit.
    34803563 *
    34813564 * @param   pbSrcPhys       The source address. Relative to guest RAM.
    34823565 */
    3483 uint16_t remR3PhysReadHCPtrU16(uint8_t *pbSrcPhys)
    3484 {
    3485     uint16_t val;
     3566uint64_t remR3PhysReadHCPtrU64(uint8_t *pbSrcPhys)
     3567{
     3568    uint64_t val;
    34863569
    34873570    STAM_PROFILE_ADV_START(&gStatMemReadHCPtr, a);
     
    34963579    uintptr_t off = pbSrcPhys - phys_ram_base;
    34973580#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! */
    36403583    STAM_PROFILE_ADV_STOP(&gStatMemReadHCPtr, a);
    36413584    return val;
     
    36613604    uintptr_t off = pbDstPhys - phys_ram_base;
    36623605#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);
    36673607    STAM_PROFILE_ADV_STOP(&gStatMemWriteHCPtr, a);
    36683608}
     
    36863626    uintptr_t off = pbDstPhys - phys_ram_base;
    36873627#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);
    36923629    STAM_PROFILE_ADV_STOP(&gStatMemWriteHCPtr, a);
    36933630}
     
    37113648    uintptr_t off = pbDstPhys - phys_ram_base;
    37123649#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);
    37173651    STAM_PROFILE_ADV_STOP(&gStatMemWriteHCPtr, a);
    37183652}
     
    37363670    uintptr_t off = pbDstPhys - phys_ram_base;
    37373671#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);
    37423673    STAM_PROFILE_ADV_STOP(&gStatMemWriteHCPtr, a);
    37433674}
     
    37613692    uintptr_t off = pbDstPhys - phys_ram_base;
    37623693#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);
    37703696    STAM_PROFILE_ADV_STOP(&gStatMemWriteHCPtr, a);
    37713697}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette