VirtualBox

Changeset 11150

Show
Ignore:
Timestamp:
08/06/08 00:32:11 (4 months ago)
Author:
vboxsync
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/include/VBox/mm.h

    r9212 r11150  
    213213 
    214214MMDECL(RTR3PTR)     MMHyperR0ToR3(PVM pVM, RTR0PTR R0Ptr); 
    215 MMDECL(RTGCPTR)     MMHyperR0ToGC(PVM pVM, RTR0PTR R0Ptr); 
     215MMDECL(RTRCPTR)     MMHyperR0ToRC(PVM pVM, RTR0PTR R0Ptr); 
     216#define MMHyperR0ToGC(pVM, pv) MMHyperR0ToRC(pVM, pv)       /**< @deprecated */ 
    216217#ifndef IN_RING0 
    217218MMDECL(void *)      MMHyperR0ToCC(PVM pVM, RTR0PTR R0Ptr); 
    218219#endif 
    219220MMDECL(RTR0PTR)     MMHyperR3ToR0(PVM pVM, RTR3PTR R3Ptr); 
    220 MMDECL(RTGCPTR)     MMHyperR3ToGC(PVM pVM, RTR3PTR R3Ptr); 
    221 MMDECL(RTR3PTR)     MMHyperGCToR3(PVM pVM, RTGCPTR GCPtr); 
    222 MMDECL(RTR0PTR)     MMHyperGCToR0(PVM pVM, RTGCPTR GCPtr); 
     221MMDECL(RTRCPTR)     MMHyperR3ToRC(PVM pVM, RTR3PTR R3Ptr); 
     222#define MMHyperR3ToGC(pVM, R3Ptr) MMHyperR3ToRC(pVM, R3Ptr) /**< @deprecated */ 
     223MMDECL(RTR3PTR)     MMHyperRCToR3(PVM pVM, RTRCPTR RCPtr); 
     224#define MMHyperGCToR3(pVM, RCPtr) MMHyperRCToR3(pVM, RCPtr) /**< @deprecated */ 
     225MMDECL(RTR0PTR)     MMHyperRCToR0(PVM pVM, RTRCPTR RCPtr); 
     226#define MMHyperGCToR0(pVM, RCPtr) MMHyperRCToR0(pVM, RCPtr) /**< @deprecated */ 
    223227 
    224228#ifndef IN_RING3 
     
    234238 
    235239#ifndef IN_GC 
    236 MMDECL(void *)      MMHyperGCToCC(PVM pVM, RTGCPTR GCPtr); 
    237 #else 
    238 DECLINLINE(void *)  MMHyperGCToCC(PVM pVM, RTGCPTR GCPtr) 
    239 
    240     NOREF(pVM); 
    241     return (void *)GCPtr; 
    242 
    243 #endif 
     240MMDECL(void *)      MMHyperRCToCC(PVM pVM, RTRCPTR RCPtr); 
     241#else 
     242DECLINLINE(void *)  MMHyperRCToCC(PVM pVM, RTRCPTR RCPtr) 
     243
     244    NOREF(pVM); 
     245    return (void *)RCPtr; 
     246
     247#endif 
     248#define MMHyperGCToCC(pVM, RCPtr) MMHyperRCToCC(pVM, RCPtr) 
    244249 
    245250#ifndef IN_RING3 
     
    284289#endif 
    285290 
    286 #ifndef IN_GC 
    287 MMDECL(RCPTRTYPE(void *))     MMHyper2GC(PVM pVM, uintptr_t Ptr); 
    288 #else 
    289 DECLINLINE(RCPTRTYPE(void *)) MMHyper2GC(PVM pVM, uintptr_t Ptr) 
    290 { 
    291     NOREF(pVM); 
    292     return (RCPTRTYPE(void *))Ptr; 
    293 } 
    294 #endif 
    295291 
    296292MMDECL(RCPTRTYPE(void *))     MMHyperHC2GC(PVM pVM, RTHCPTR HCPtr); 
  • 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 */ 

© 2008 Sun Microsystems, Inc.
ContactPrivacy policy