| 506 | | |
|---|
| 507 | | |
|---|
| 508 | | /** |
|---|
| 509 | | * Converts a HC address in the Hypervisor memory region to a GC address. |
|---|
| 510 | | * The memory must have been allocated with MMGCHyperAlloc() or MMR3HyperAlloc(). |
|---|
| 511 | | * |
|---|
| 512 | | * @returns GC address. |
|---|
| 513 | | * @param pVM The VM to operate on. |
|---|
| 514 | | * @param HCPtr The host context address. |
|---|
| 515 | | * You'll be damed if this is not in the hypervisor region! :-) |
|---|
| 516 | | * @deprecated |
|---|
| 517 | | */ |
|---|
| 518 | | MMDECL(RTRCPTR) MMHyperHC2GC(PVM pVM, RTHCPTR HCPtr) |
|---|
| 519 | | { |
|---|
| 520 | | PMMLOOKUPHYPER pLookup = (PMMLOOKUPHYPER)((char*)CTXSUFF(pVM->mm.s.pHyperHeap) + pVM->mm.s.offLookupHyper); |
|---|
| 521 | | for (;;) |
|---|
| 522 | | { |
|---|
| 523 | | switch (pLookup->enmType) |
|---|
| 524 | | { |
|---|
| 525 | | case MMLOOKUPHYPERTYPE_LOCKED: |
|---|
| 526 | | { |
|---|
| 527 | | unsigned off = (RTHCUINTPTR)HCPtr - (RTHCUINTPTR)pLookup->u.Locked.pvHC; |
|---|
| 528 | | if (off < pLookup->cb) |
|---|
| 529 | | return (RTRCPTR)((RTGCUINTPTR)pVM->mm.s.pvHyperAreaGC + pLookup->off + off); |
|---|
| 530 | | break; |
|---|
| 531 | | } |
|---|
| 532 | | |
|---|
| 533 | | case MMLOOKUPHYPERTYPE_HCPHYS: |
|---|
| 534 | | { |
|---|
| 535 | | unsigned off = (RTHCUINTPTR)HCPtr - (RTHCUINTPTR)pLookup->u.HCPhys.pvHC; |
|---|
| 536 | | if (off < pLookup->cb) |
|---|
| 537 | | return (RTRCPTR)((RTGCUINTPTR)pVM->mm.s.pvHyperAreaGC + pLookup->off + off); |
|---|
| 538 | | break; |
|---|
| 539 | | } |
|---|
| 540 | | |
|---|
| 541 | | case MMLOOKUPHYPERTYPE_GCPHYS: /* (for now we'll not allow these kind of conversions) */ |
|---|
| 542 | | case MMLOOKUPHYPERTYPE_MMIO2: |
|---|
| 543 | | case MMLOOKUPHYPERTYPE_DYNAMIC: |
|---|
| 544 | | break; |
|---|
| 545 | | |
|---|
| 546 | | default: |
|---|
| 547 | | AssertMsgFailed(("enmType=%d\n", pLookup->enmType)); |
|---|
| 548 | | break; |
|---|
| 549 | | } |
|---|
| 550 | | |
|---|
| 551 | | /* next */ |
|---|
| 552 | | if ((unsigned)pLookup->offNext == NIL_OFFSET) |
|---|
| 553 | | break; |
|---|
| 554 | | pLookup = (PMMLOOKUPHYPER)((char *)pLookup + pLookup->offNext); |
|---|
| 555 | | } |
|---|
| 556 | | |
|---|
| 557 | | AssertMsgFailed(("HCPtr=%p is not inside the hypervisor memory area!\n", HCPtr)); |
|---|
| 558 | | return NIL_RTRCPTR; |
|---|
| 559 | | } |
|---|
| 560 | | |
|---|
| 561 | | |
|---|
| 562 | | /** |
|---|
| 563 | | * Converts a RC address in the Hypervisor memory region to a HC address. |
|---|
| 564 | | * The memory must have been allocated with MMHyperAlloc(). |
|---|
| 565 | | * |
|---|
| 566 | | * @returns HC address. |
|---|
| 567 | | * @param pVM The VM to operate on. |
|---|
| 568 | | * @param RCPtr The raw-mode context address. |
|---|
| 569 | | * You'll be damed if this is not in the hypervisor region! :-) |
|---|
| 570 | | * @deprecated |
|---|
| 571 | | */ |
|---|
| 572 | | MMDECL(RTHCPTR) MMHyperRC2HC(PVM pVM, RTRCPTR RCPtr) |
|---|
| 573 | | { |
|---|
| 574 | | unsigned offRC = (RTRCUINTPTR)RCPtr - (RTGCUINTPTR)pVM->mm.s.pvHyperAreaGC; |
|---|
| 575 | | PMMLOOKUPHYPER pLookup = (PMMLOOKUPHYPER)((char*)CTXSUFF(pVM->mm.s.pHyperHeap) + pVM->mm.s.offLookupHyper); |
|---|
| 576 | | for (;;) |
|---|
| 577 | | { |
|---|
| 578 | | unsigned off = offRC - pLookup->off; |
|---|
| 579 | | if (off < pLookup->cb) |
|---|
| 580 | | { |
|---|
| 581 | | switch (pLookup->enmType) |
|---|
| 582 | | { |
|---|
| 583 | | case MMLOOKUPHYPERTYPE_LOCKED: |
|---|
| 584 | | return (RTHCPTR)((RTHCUINTPTR)pLookup->u.Locked.pvHC + off); |
|---|
| 585 | | case MMLOOKUPHYPERTYPE_HCPHYS: |
|---|
| 586 | | return (RTHCPTR)((RTHCUINTPTR)pLookup->u.HCPhys.pvHC + off); |
|---|
| 587 | | default: |
|---|
| 588 | | break; |
|---|
| 589 | | } |
|---|
| 590 | | AssertMsgFailed(("enmType=%d\n", pLookup->enmType)); |
|---|
| 591 | | return (RTHCPTR)0; |
|---|
| 592 | | } |
|---|
| 593 | | |
|---|
| 594 | | /* next */ |
|---|
| 595 | | if ((unsigned)pLookup->offNext == NIL_OFFSET) |
|---|
| 596 | | break; |
|---|
| 597 | | pLookup = (PMMLOOKUPHYPER)((char *)pLookup + pLookup->offNext); |
|---|
| 598 | | } |
|---|
| 599 | | |
|---|
| 600 | | AssertMsgFailed(("RCPtr=%p is not inside the hypervisor memory area!\n", RCPtr)); |
|---|
| 601 | | return (RTHCPTR)0; |
|---|
| 602 | | } |
|---|
| 603 | | |
|---|