VirtualBox

忽略:
時間撮記:
2008-8-5 下午10:32:11 (16 年 以前)
作者:
vboxsync
訊息:

VMM: raw-mode context (RC) changes for the MHyperXXToYY APIs.

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/VMM/VMMAll/MMAll.cpp

    r9212 r11150  
    120120
    121121/**
    122  * Lookup a guest context address.
     122 * Lookup a raw-mode context address.
    123123 *
    124124 * @returns Pointer to the corresponding lookup record.
    125125 * @returns NULL on failure.
    126126 * @param   pVM     The VM handle.
    127  * @param   GCPtr   The guest context address to lookup.
     127 * @param   RCPtr   The raw-mode context address to lookup.
    128128 * @param   poff    Where to store the offset into the HMA memory chunk.
    129129 */
    130 DECLINLINE(PMMLOOKUPHYPER) mmHyperLookupGC(PVM pVM, RTGCPTR GCPtr, uint32_t *poff)
     130DECLINLINE(PMMLOOKUPHYPER) mmHyperLookupRC(PVM pVM, RTRCPTR RCPtr, uint32_t *poff)
    131131{
    132132    /** @todo cache last lookup this stuff ain't cheap! */
    133     unsigned        offGC = (RTGCUINTPTR)GCPtr - (RTGCUINTPTR)pVM->mm.s.pvHyperAreaGC;
     133    unsigned        offRC = (RTRCUINTPTR)RCPtr - (RTGCUINTPTR)pVM->mm.s.pvHyperAreaGC;
    134134    PMMLOOKUPHYPER  pLookup = (PMMLOOKUPHYPER)((char*)CTXSUFF(pVM->mm.s.pHyperHeap) + pVM->mm.s.offLookupHyper);
    135135    for (;;)
    136136    {
    137         const uint32_t off = offGC - pLookup->off;
     137        const uint32_t off = offRC - pLookup->off;
    138138        if (off < pLookup->cb)
    139139        {
     
    157157    }
    158158
    159     AssertMsgFailed(("GCPtr=%p is not inside the hypervisor memory area!\n", GCPtr));
     159    AssertMsgFailed(("GCPtr=%p is not inside the hypervisor memory area!\n", RCPtr));
    160160    return NULL;
    161161}
     
    174174{
    175175#ifdef IN_GC
    176     return mmHyperLookupGC(pVM, (RTGCPTR)pv, poff);
     176    return mmHyperLookupRC(pVM, (RTRCPTR)pv, poff);
    177177#elif defined(IN_RING0)
    178178    return mmHyperLookupR0(pVM, pv, poff);
     
    230230
    231231/**
     232 * Calculate the raw-mode context address of an offset into the HMA memory chunk.
     233 *
     234 * @returns the raw-mode context base address.
     235 * @param   pVM         The the VM handle.
     236 * @param   pLookup     The HMA lookup record.
     237 * @param   off         The offset into the HMA memory chunk.
     238 */
     239DECLINLINE(RTRCPTR) mmHyperLookupCalcRC(PVM pVM, PMMLOOKUPHYPER pLookup, uint32_t off)
     240{
     241    return (RTRCPTR)((RTGCUINTPTR)pVM->mm.s.pvHyperAreaGC + pLookup->off + off);
     242}
     243
     244
     245/**
    232246 * Calculate the guest context address of an offset into the HMA memory chunk.
    233247 *
     
    237251 * @param   off         The offset into the HMA memory chunk.
    238252 */
    239 DECLINLINE(RTGCPTR) mmHyperLookupCalcGC(PVM pVM, PMMLOOKUPHYPER pLookup, uint32_t off)
    240 {
    241     return (RTGCPTR)((RTGCUINTPTR)pVM->mm.s.pvHyperAreaGC + pLookup->off + off);
    242 }
    243 
    244 
    245 /**
    246  * Calculate the guest context address of an offset into the HMA memory chunk.
    247  *
    248  * @returns the guest context base address.
    249  * @param   pVM         The the VM handle.
    250  * @param   pLookup     The HMA lookup record.
    251  * @param   off         The offset into the HMA memory chunk.
    252  */
    253253DECLINLINE(void *) mmHyperLookupCalcCC(PVM pVM, PMMLOOKUPHYPER pLookup, uint32_t off)
    254254{
    255255#ifdef IN_GC
    256     return (void *)mmHyperLookupCalcGC(pVM, pLookup, off);
     256    return (void *)mmHyperLookupCalcRC(pVM, pLookup, off);
    257257#elif defined(IN_RING0)
    258258    return mmHyperLookupCalcR0(pLookup, off);
     
    283283
    284284/**
    285  * Converts a ring-0 host context address in the Hypervisor memory region to a guest context address.
    286  *
    287  * @returns guest context address.
     285 * Converts a ring-0 host context address in the Hypervisor memory region to a raw-mode context address.
     286 *
     287 * @returns raw-mode context address.
    288288 * @param   pVM         The VM to operate on.
    289289 * @param   R0Ptr       The ring-0 host context address.
     
    291291 * @thread  The Emulation Thread.
    292292 */
    293 MMDECL(RTGCPTR) MMHyperR0ToGC(PVM pVM, RTR0PTR R0Ptr)
     293MMDECL(RTRCPTR) MMHyperR0ToRC(PVM pVM, RTR0PTR R0Ptr)
    294294{
    295295    uint32_t off;
    296296    PMMLOOKUPHYPER pLookup = mmHyperLookupR0(pVM, R0Ptr, &off);
    297297    if (pLookup)
    298         return mmHyperLookupCalcGC(pVM, pLookup, off);
    299     return NIL_RTGCPTR;
     298        return mmHyperLookupCalcRC(pVM, pLookup, off);
     299    return NIL_RTRCPTR;
    300300}
    301301
     
    351351 * @thread  The Emulation Thread.
    352352 */
    353 MMDECL(RTGCPTR) MMHyperR3ToGC(PVM pVM, RTR3PTR R3Ptr)
     353MMDECL(RTRCPTR) MMHyperR3ToRC(PVM pVM, RTR3PTR R3Ptr)
    354354{
    355355    uint32_t off;
    356356    PMMLOOKUPHYPER pLookup = mmHyperLookupR3(pVM, R3Ptr, &off);
    357357    if (pLookup)
    358         return mmHyperLookupCalcGC(pVM, pLookup, off);
     358        return mmHyperLookupCalcRC(pVM, pLookup, off);
    359359    AssertMsgFailed(("R3Ptr=%p is not inside the hypervisor memory area!\n", R3Ptr));
    360     return NIL_RTGCPTR;
     360    return NIL_RTRCPTR;
    361361}
    362362
     
    384384
    385385/**
    386  * Converts a guest context address in the Hypervisor memory region to a ring-3 context address.
     386 * Converts a raw-mode context address in the Hypervisor memory region to a ring-3 context address.
    387387 *
    388388 * @returns ring-3 host context address.
    389389 * @param   pVM         The VM to operate on.
    390  * @param   GCPtr       The guest context address.
    391  *                      You'll be damned if this is not in the HMA! :-)
    392  * @thread  The Emulation Thread.
    393  */
    394 MMDECL(RTR3PTR) MMHyperGCToR3(PVM pVM, RTGCPTR GCPtr)
    395 {
    396     uint32_t off;
    397     PMMLOOKUPHYPER pLookup = mmHyperLookupGC(pVM, GCPtr, &off);
     390 * @param   GCPtr       The raw-mode context address.
     391 *                      You'll be damned if this is not in the HMA! :-)
     392 * @thread  The Emulation Thread.
     393 */
     394MMDECL(RTR3PTR) MMHyperRCToR3(PVM pVM, RTRCPTR RCPtr)
     395{
     396    uint32_t off;
     397    PMMLOOKUPHYPER pLookup = mmHyperLookupRC(pVM, RCPtr, &off);
    398398    if (pLookup)
    399399        return mmHyperLookupCalcR3(pLookup, off);
     
    403403
    404404/**
    405  * Converts a guest context address in the Hypervisor memory region to a ring-0 host context address.
     405 * Converts a raw-mode context address in the Hypervisor memory region to a ring-0 host context address.
    406406 *
    407407 * @returns ring-0 host context address.
    408408 * @param   pVM         The VM to operate on.
    409  * @param   GCPtr       The guest context address.
    410  *                      You'll be damned if this is not in the HMA! :-)
    411  * @thread  The Emulation Thread.
    412  */
    413 MMDECL(RTR0PTR) MMHyperGCToR0(PVM pVM, RTGCPTR GCPtr)
    414 {
    415     uint32_t off;
    416     PMMLOOKUPHYPER pLookup = mmHyperLookupGC(pVM, GCPtr, &off);
     409 * @param   RCPtr       The raw-mode context address.
     410 *                      You'll be damned if this is not in the HMA! :-)
     411 * @thread  The Emulation Thread.
     412 */
     413MMDECL(RTR0PTR) MMHyperRCToR0(PVM pVM, RTRCPTR RCPtr)
     414{
     415    uint32_t off;
     416    PMMLOOKUPHYPER pLookup = mmHyperLookupRC(pVM, RCPtr, &off);
    417417    if (pLookup)
    418418        return mmHyperLookupCalcR0(pLookup, off);
     
    422422
    423423/**
    424  * Converts a guest context address in the Hypervisor memory region to a current context address.
     424 * Converts a raw-mode context address in the Hypervisor memory region to a current context address.
    425425 *
    426426 * @returns current context address.
    427427 * @param   pVM         The VM to operate on.
    428  * @param   GCPtr       The guest host context address.
     428 * @param   RCPtr       The raw-mode host context address.
    429429 *                      You'll be damned if this is not in the HMA! :-)
    430430 * @thread  The Emulation Thread.
    431431 */
    432432#ifndef IN_GC
    433 MMDECL(void *) MMHyperGCToCC(PVM pVM, RTGCPTR GCPtr)
    434 {
    435     uint32_t off;
    436     PMMLOOKUPHYPER pLookup = mmHyperLookupGC(pVM, GCPtr, &off);
     433MMDECL(void *) MMHyperRCToCC(PVM pVM, RTRCPTR RCPtr)
     434{
     435    uint32_t off;
     436    PMMLOOKUPHYPER pLookup = mmHyperLookupRC(pVM, RCPtr, &off);
    437437    if (pLookup)
    438438        return mmHyperLookupCalcCC(pVM, pLookup, off);
     
    485485
    486486/**
    487  * Converts a current context address in the Hypervisor memory region to a guest context address.
     487 * Converts a current context address in the Hypervisor memory region to a raw-mode context address.
    488488 *
    489489 * @returns guest context address.
     
    494494 */
    495495#ifndef IN_GC
    496 MMDECL(RCPTRTYPE(void *)) MMHyperCCToGC(PVM pVM, void *pv)
     496MMDECL(RTRCPTR) MMHyperCCToRC(PVM pVM, void *pv)
    497497{
    498498    uint32_t off;
    499499    PMMLOOKUPHYPER pLookup = mmHyperLookupCC(pVM, pv, &off);
    500500    if (pLookup)
    501         return mmHyperLookupCalcGC(pVM, pLookup, off);
    502     return NIL_RTGCPTR;
     501        return mmHyperLookupCalcRC(pVM, pLookup, off);
     502    return NIL_RTRCPTR;
    503503}
    504504#endif
     
    516516 * @deprecated
    517517 */
    518 MMDECL(RCPTRTYPE(void *)) MMHyperHC2GC(PVM pVM, RTHCPTR HCPtr)
     518MMDECL(RTRCPTR) MMHyperHC2GC(PVM pVM, RTHCPTR HCPtr)
    519519{
    520520    PMMLOOKUPHYPER  pLookup = (PMMLOOKUPHYPER)((char*)CTXSUFF(pVM->mm.s.pHyperHeap) + pVM->mm.s.offLookupHyper);
     
    527527                unsigned    off = (RTHCUINTPTR)HCPtr - (RTHCUINTPTR)pLookup->u.Locked.pvHC;
    528528                if (off < pLookup->cb)
    529                     return (RCPTRTYPE(void *))((RTGCUINTPTR)pVM->mm.s.pvHyperAreaGC + pLookup->off + off);
     529                    return (RTRCPTR)((RTGCUINTPTR)pVM->mm.s.pvHyperAreaGC + pLookup->off + off);
    530530                break;
    531531            }
     
    535535                unsigned    off = (RTHCUINTPTR)HCPtr - (RTHCUINTPTR)pLookup->u.HCPhys.pvHC;
    536536                if (off < pLookup->cb)
    537                     return (RCPTRTYPE(void *))((RTGCUINTPTR)pVM->mm.s.pvHyperAreaGC + pLookup->off + off);
     537                    return (RTRCPTR)((RTGCUINTPTR)pVM->mm.s.pvHyperAreaGC + pLookup->off + off);
    538538                break;
    539539            }
     
    556556
    557557    AssertMsgFailed(("HCPtr=%p is not inside the hypervisor memory area!\n", HCPtr));
    558     return (RCPTRTYPE(void *))0;
    559 }
    560 
    561 
    562 /**
    563  * Converts a GC address in the Hypervisor memory region to a HC address.
     558    return NIL_RTRCPTR;
     559}
     560
     561
     562/**
     563 * Converts a RC address in the Hypervisor memory region to a HC address.
    564564 * The memory must have been allocated with MMHyperAlloc().
    565565 *
    566566 * @returns HC address.
    567567 * @param   pVM         The VM to operate on.
    568  * @param   GCPtr       The guest context address.
     568 * @param   RCPtr       The raw-mode context address.
    569569 *                      You'll be damed if this is not in the hypervisor region! :-)
    570570 * @deprecated
    571571 */
    572 MMDECL(RTHCPTR) MMHyperGC2HC(PVM pVM, RCPTRTYPE(void *) GCPtr)
    573 {
    574     unsigned        offGC = (RTGCUINTPTR)GCPtr - (RTGCUINTPTR)pVM->mm.s.pvHyperAreaGC;
     572MMDECL(RTHCPTR) MMHyperRC2HC(PVM pVM, RTRCPTR RCPtr)
     573{
     574    unsigned        offRC = (RTRCUINTPTR)RCPtr - (RTGCUINTPTR)pVM->mm.s.pvHyperAreaGC;
    575575    PMMLOOKUPHYPER  pLookup = (PMMLOOKUPHYPER)((char*)CTXSUFF(pVM->mm.s.pHyperHeap) + pVM->mm.s.offLookupHyper);
    576576    for (;;)
    577577    {
    578         unsigned off = offGC - pLookup->off;
     578        unsigned off = offRC - pLookup->off;
    579579        if (off < pLookup->cb)
    580580        {
     
    598598    }
    599599
    600     AssertMsgFailed(("GCPtr=%p is not inside the hypervisor memory area!\n", GCPtr));
     600    AssertMsgFailed(("RCPtr=%p is not inside the hypervisor memory area!\n", RCPtr));
    601601    return (RTHCPTR)0;
    602602}
    603603
    604 
    605 #ifdef IN_GC
    606 /**
    607  * Converts a current context address in the Hypervisor memory region to a HC address.
    608  * The memory must have been allocated with MMGCHyperAlloc() or MMR3HyperAlloc().
    609  *
    610  * @returns HC address.
    611  * @param   pVM         The VM to operate on.
    612  * @param   Ptr         The current context address.
    613  * @deprecated
    614  */
    615 MMDECL(RTHCPTR) MMHyper2HC(PVM pVM, uintptr_t Ptr)
    616 {
    617     return MMHyperGC2HC(pVM, (RCPTRTYPE(void *))Ptr);
    618 }
    619 
    620 #else /* !IN_GC */
    621 
    622 /**
    623  * Converts a current context address in the Hypervisor memory region to a GC address.
    624  * The memory must have been allocated with MMHyperAlloc().
    625  *
    626  * @returns HC address.
    627  * @param   pVM         The VM to operate on.
    628  * @param   Ptr         The current context address.
    629  * @thread  The Emulation Thread.
    630  * @deprecated
    631  */
    632 MMDECL(RCPTRTYPE(void *)) MMHyper2GC(PVM pVM, uintptr_t Ptr)
    633 {
    634     return MMHyperHC2GC(pVM, (RTHCPTR)Ptr);
    635 }
    636 
    637 #endif /* !IN_GC */
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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