Changeset 6626 in vbox
- Timestamp:
- Jan 30, 2008 7:33:55 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 27687
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/mm.h
r6546 r6626 218 218 * @{ */ 219 219 220 /** 221 * Converts a ring-0 host context address in the Hypervisor memory region to a ring-3 host context address. 222 * 223 * @returns ring-3 host context address. 224 * @param pVM The VM to operate on. 225 * @param R0Ptr The ring-0 host context address. 226 * You'll be damned if this is not in the HMA! :-) 227 * @thread The Emulation Thread. 228 */ 229 MMDECL(RTR3PTR) MMHyperR0ToR3(PVM pVM, RTR0PTR R0Ptr); 230 231 /** 232 * Converts a ring-0 host context address in the Hypervisor memory region to a guest context address. 233 * 234 * @returns guest context address. 235 * @param pVM The VM to operate on. 236 * @param R0Ptr The ring-0 host context address. 237 * You'll be damned if this is not in the HMA! :-) 238 * @thread The Emulation Thread. 239 */ 240 MMDECL(RTGCPTR) MMHyperR0ToGC(PVM pVM, RTR0PTR R0Ptr); 241 242 /** 243 * Converts a ring-0 host context address in the Hypervisor memory region to a current context address. 244 * 245 * @returns current context address. 246 * @param pVM The VM to operate on. 247 * @param R0Ptr The ring-0 host context address. 248 * You'll be damned if this is not in the HMA! :-) 249 * @thread The Emulation Thread. 250 */ 220 MMDECL(RTR3PTR) MMHyperR0ToR3(PVM pVM, RTR0PTR R0Ptr); 221 MMDECL(RTGCPTR) MMHyperR0ToGC(PVM pVM, RTR0PTR R0Ptr); 251 222 #ifndef IN_RING0 252 MMDECL(void *) MMHyperR0ToCC(PVM pVM, RTR0PTR R0Ptr); 253 #endif 254 255 256 /** 257 * Converts a ring-3 host context address in the Hypervisor memory region to a ring-0 host context address. 258 * 259 * @returns ring-0 host context address. 260 * @param pVM The VM to operate on. 261 * @param R3Ptr The ring-3 host context address. 262 * You'll be damned if this is not in the HMA! :-) 263 * @thread The Emulation Thread. 264 */ 265 MMDECL(RTR0PTR) MMHyperR3ToR0(PVM pVM, RTR3PTR R3Ptr); 266 267 /** 268 * Converts a ring-3 host context address in the Hypervisor memory region to a guest context address. 269 * 270 * @returns guest context address. 271 * @param pVM The VM to operate on. 272 * @param R3Ptr The ring-3 host context address. 273 * You'll be damned if this is not in the HMA! :-) 274 * @thread The Emulation Thread. 275 */ 276 MMDECL(RTGCPTR) MMHyperR3ToGC(PVM pVM, RTR3PTR R3Ptr); 277 278 /** 279 * Converts a ring-3 host context address in the Hypervisor memory region to a current context address. 280 * 281 * @returns current context address. 282 * @param pVM The VM to operate on. 283 * @param R3Ptr The ring-3 host context address. 284 * You'll be damned if this is not in the HMA! :-) 285 * @thread The Emulation Thread. 286 */ 223 MMDECL(void *) MMHyperR0ToCC(PVM pVM, RTR0PTR R0Ptr); 224 #endif 225 MMDECL(RTR0PTR) MMHyperR3ToR0(PVM pVM, RTR3PTR R3Ptr); 226 MMDECL(RTGCPTR) MMHyperR3ToGC(PVM pVM, RTR3PTR R3Ptr); 227 MMDECL(RTR3PTR) MMHyperGCToR3(PVM pVM, RTGCPTR GCPtr); 228 MMDECL(RTR0PTR) MMHyperGCToR0(PVM pVM, RTGCPTR GCPtr); 229 287 230 #ifndef IN_RING3 288 MMDECL(void *) MMHyperR3ToCC(PVM pVM, RTR3PTR R3Ptr);289 #else 290 DECLINLINE(void *) MMHyperR3ToCC(PVM pVM, RTR3PTR R3Ptr)231 MMDECL(void *) MMHyperR3ToCC(PVM pVM, RTR3PTR R3Ptr); 232 #else 233 DECLINLINE(void *) MMHyperR3ToCC(PVM pVM, RTR3PTR R3Ptr) 291 234 { 292 235 NOREF(pVM); … … 296 239 297 240 298 /**299 * Converts a guest context address in the Hypervisor memory region to a ring-3 context address.300 *301 * @returns ring-3 host context address.302 * @param pVM The VM to operate on.303 * @param GCPtr The guest context address.304 * You'll be damned if this is not in the HMA! :-)305 * @thread The Emulation Thread.306 */307 MMDECL(RTR3PTR) MMHyperGCToR3(PVM pVM, RTGCPTR GCPtr);308 309 /**310 * Converts a guest context address in the Hypervisor memory region to a ring-0 host context address.311 *312 * @returns ring-0 host context address.313 * @param pVM The VM to operate on.314 * @param GCPtr The guest context address.315 * You'll be damned if this is not in the HMA! :-)316 * @thread The Emulation Thread.317 */318 MMDECL(RTR0PTR) MMHyperGCToR0(PVM pVM, RTGCPTR GCPtr);319 320 /**321 * Converts a guest context address in the Hypervisor memory region to a current context address.322 *323 * @returns current context address.324 * @param pVM The VM to operate on.325 * @param GCPtr The guest host context address.326 * You'll be damned if this is not in the HMA! :-)327 * @thread The Emulation Thread.328 */329 241 #ifndef IN_GC 330 MMDECL(void *) MMHyperGCToCC(PVM pVM, RTGCPTR GCPtr);331 #else 332 DECLINLINE(void *) MMHyperGCToCC(PVM pVM, RTGCPTR GCPtr)242 MMDECL(void *) MMHyperGCToCC(PVM pVM, RTGCPTR GCPtr); 243 #else 244 DECLINLINE(void *) MMHyperGCToCC(PVM pVM, RTGCPTR GCPtr) 333 245 { 334 246 NOREF(pVM); … … 337 249 #endif 338 250 339 340 341 /**342 * Converts a current context address in the Hypervisor memory region to a ring-3 host context address.343 *344 * @returns ring-3 host context address.345 * @param pVM The VM to operate on.346 * @param pv The current context address.347 * You'll be damned if this is not in the HMA! :-)348 * @thread The Emulation Thread.349 */350 251 #ifndef IN_RING3 351 MMDECL(RTR3PTR) MMHyperCCToR3(PVM pVM, void *pv);252 MMDECL(RTR3PTR) MMHyperCCToR3(PVM pVM, void *pv); 352 253 #else 353 254 DECLINLINE(RTR3PTR) MMHyperCCToR3(PVM pVM, void *pv) … … 358 259 #endif 359 260 360 /**361 * Converts a current context address in the Hypervisor memory region to a ring-0 host context address.362 *363 * @returns ring-0 host context address.364 * @param pVM The VM to operate on.365 * @param pv The current context address.366 * You'll be damned if this is not in the HMA! :-)367 * @thread The Emulation Thread.368 */369 261 #ifndef IN_RING0 370 MMDECL(RTR0PTR) MMHyperCCToR0(PVM pVM, void *pv);262 MMDECL(RTR0PTR) MMHyperCCToR0(PVM pVM, void *pv); 371 263 #else 372 264 DECLINLINE(RTR0PTR) MMHyperCCToR0(PVM pVM, void *pv) … … 377 269 #endif 378 270 379 /**380 * Converts a current context address in the Hypervisor memory region to a guest context address.381 *382 * @returns guest context address.383 * @param pVM The VM to operate on.384 * @param pv The current context address.385 * You'll be damned if this is not in the HMA! :-)386 * @thread The Emulation Thread.387 */388 271 #ifndef IN_GC 389 MMDECL(RTGCPTR) MMHyperCCToGC(PVM pVM, void *pv);272 MMDECL(RTGCPTR) MMHyperCCToGC(PVM pVM, void *pv); 390 273 #else 391 274 DECLINLINE(RTGCPTR) MMHyperCCToGC(PVM pVM, void *pv) … … 397 280 398 281 399 400 /**401 * Converts a current context address in the Hypervisor memory region to a HC address.402 * The memory must have been allocated with MMHyperAlloc().403 *404 * @returns HC address.405 * @param pVM The VM to operate on.406 * @param Ptr The current context address.407 * @thread The Emulation Thread.408 * @deprecated409 */410 282 #ifdef IN_GC 411 MMDECL(RTHCPTR) MMHyper2HC(PVM pVM, uintptr_t Ptr);283 MMDECL(RTHCPTR) MMHyper2HC(PVM pVM, uintptr_t Ptr); 412 284 #else 413 285 DECLINLINE(RTHCPTR) MMHyper2HC(PVM pVM, uintptr_t Ptr) … … 418 290 #endif 419 291 420 /**421 * Converts a current context address in the Hypervisor memory region to a GC address.422 * The memory must have been allocated with MMHyperAlloc().423 *424 * @returns HC address.425 * @param pVM The VM to operate on.426 * @param Ptr The current context address.427 * @thread The Emulation Thread.428 */429 292 #ifndef IN_GC 430 MMDECL(RTGCPTR) MMHyper2GC(PVM pVM, uintptr_t Ptr);293 MMDECL(RTGCPTR) MMHyper2GC(PVM pVM, uintptr_t Ptr); 431 294 #else 432 295 DECLINLINE(RTGCPTR) MMHyper2GC(PVM pVM, uintptr_t Ptr) … … 437 300 #endif 438 301 439 /** 440 * Converts a HC address in the Hypervisor memory region to a GC address. 441 * The memory must have been allocated with MMGCHyperAlloc() or MMR3HyperAlloc(). 442 * 443 * @returns GC address. 444 * @param pVM The VM to operate on. 445 * @param HCPtr The host context address. 446 * You'll be damned if this is not in the HMA! :-) 447 * @thread The Emulation Thread. 448 * @deprecated 449 */ 450 MMDECL(RTGCPTR) MMHyperHC2GC(PVM pVM, RTHCPTR HCPtr); 451 452 /** 453 * Converts a GC address in the Hypervisor memory region to a HC address. 454 * The memory must have been allocated with MMGCHyperAlloc() or MMR3HyperAlloc(). 455 * 456 * @returns HC address. 457 * @param pVM The VM to operate on. 458 * @param GCPtr The guest context address. 459 * You'll be damned if this is not in the HMA! :-) 460 * @thread The Emulation Thread. 461 * @deprecated 462 */ 463 MMDECL(RTHCPTR) MMHyperGC2HC(PVM pVM, RTGCPTR GCPtr); 464 465 466 /** 467 * Allocates memory in the Hypervisor (GC VMM) area. 468 * The returned memory is of course zeroed. 469 * 470 * @returns VBox status code. 471 * @param pVM The VM to operate on. 472 * @param cb Number of bytes to allocate. 473 * @param uAlignment Required memory alignment in bytes. 474 * Values are 0,8,16,32 and PAGE_SIZE. 475 * 0 -> default alignment, i.e. 8 bytes. 476 * @param enmTag The statistics tag. 477 * @param ppv Where to store the address to the allocated 478 * memory. 479 * @remark This is assumed not to be used at times when serialization is required. 480 */ 481 MMDECL(int) MMHyperAlloc(PVM pVM, size_t cb, uint32_t uAlignment, MMTAG enmTag, void **ppv); 482 483 /** 484 * Free memory allocated using MMHyperAlloc(). 485 * 486 * It's not possible to free memory which is page aligned! 487 * 488 * @returns VBox status code. 489 * @param pVM The VM to operate on. 490 * @param pv The memory to free. 491 * @remark Try avoid freeing hyper memory. 492 * @thread The Emulation Thread. 493 */ 494 MMDECL(int) MMHyperFree(PVM pVM, void *pv); 495 302 MMDECL(RTGCPTR) MMHyperHC2GC(PVM pVM, RTHCPTR HCPtr); 303 MMDECL(RTHCPTR) MMHyperGC2HC(PVM pVM, RTGCPTR GCPtr); 304 MMDECL(int) MMHyperAlloc(PVM pVM, size_t cb, uint32_t uAlignment, MMTAG enmTag, void **ppv); 305 MMDECL(int) MMHyperFree(PVM pVM, void *pv); 496 306 #ifdef DEBUG 497 /** 498 * Dumps the hypervisor heap to Log. 499 * @param pVM VM Handle. 500 * @thread The Emulation Thread. 501 */ 502 MMDECL(void) MMHyperHeapDump(PVM pVM); 503 #endif 504 505 /** 506 * Query the amount of free memory in the hypervisor heap. 507 * 508 * @returns Number of free bytes in the hypervisor heap. 509 * @thread Any. 510 */ 511 MMDECL(size_t) MMHyperHeapGetFreeSize(PVM pVM); 512 513 /** 514 * Query the size the hypervisor heap. 515 * 516 * @returns The size of the hypervisor heap in bytes. 517 * @thread Any. 518 */ 519 MMDECL(size_t) MMHyperHeapGetSize(PVM pVM); 520 521 522 /** 523 * Query the address and size the hypervisor memory area. 524 * 525 * @returns Base address of the hypervisor area. 526 * @param pVM VM Handle. 527 * @param pcb Where to store the size of the hypervisor area. (out) 528 * @thread Any. 529 */ 530 MMDECL(RTGCPTR) MMHyperGetArea(PVM pVM, size_t *pcb); 531 532 /** 533 * Checks if an address is within the hypervisor memory area. 534 * 535 * @returns true if inside. 536 * @returns false if outside. 537 * @param pVM VM handle. 538 * @param GCPtr The pointer to check. 539 * @thread The Emulation Thread. 540 */ 541 MMDECL(bool) MMHyperIsInsideArea(PVM pVM, RTGCPTR GCPtr); 542 543 /** 544 * Convert a page in the page pool to a HC physical address. 545 * This works for pages allocated by MMR3PageAlloc(), MMR3PageAllocPhys() 546 * and MMR3PageAllocLow(). 547 * 548 * @returns Physical address for the specified page table. 549 * @param pVM VM handle. 550 * @param pvPage Page which physical address we query. 551 * @thread The Emulation Thread. 552 */ 553 MMDECL(RTHCPHYS) MMPage2Phys(PVM pVM, void *pvPage); 554 555 /** 556 * Convert physical address of a page to a HC virtual address. 557 * This works for pages allocated by MMR3PageAlloc(), MMR3PageAllocPhys() 558 * and MMR3PageAllocLow(). 559 * 560 * @returns Pointer to the page at that physical address. 561 * @param pVM VM handle. 562 * @param HCPhysPage The physical address of a page. 563 * @thread The Emulation Thread. 564 */ 565 MMDECL(void *) MMPagePhys2Page(PVM pVM, RTHCPHYS HCPhysPage); 566 567 568 /** 569 * Convert physical address of a page to a HC virtual address. 570 * This works for pages allocated by MMR3PageAlloc(), MMR3PageAllocPhys() 571 * and MMR3PageAllocLow(). 572 * 573 * @returns VBox status code. 574 * @param pVM VM handle. 575 * @param HCPhysPage The physical address of a page. 576 * @param ppvPage Where to store the address corresponding to HCPhysPage. 577 * @thread The Emulation Thread. 578 */ 579 MMDECL(int) MMPagePhys2PageEx(PVM pVM, RTHCPHYS HCPhysPage, void **ppvPage); 580 581 582 /** 583 * Try convert physical address of a page to a HC virtual address. 584 * This works for pages allocated by MMR3PageAlloc(), MMR3PageAllocPhys() 585 * and MMR3PageAllocLow(). 586 * 587 * @returns VBox status code. 588 * @param pVM VM handle. 589 * @param HCPhysPage The physical address of a page. 590 * @param ppvPage Where to store the address corresponding to HCPhysPage. 591 * @thread The Emulation Thread. 592 */ 593 MMDECL(int) MMPagePhys2PageTry(PVM pVM, RTHCPHYS HCPhysPage, void **ppvPage); 594 595 /** 596 * Convert GC physical address to HC virtual address. 597 * 598 * @returns HC virtual address. 599 * @param pVM VM Handle 600 * @param GCPhys Guest context physical address. 601 * @param cbRange Physical range 602 * @thread The Emulation Thread. 603 * @deprecated 604 */ 605 MMDECL(void *) MMPhysGCPhys2HCVirt(PVM pVM, RTGCPHYS GCPhys, RTUINT cbRange); 307 MMDECL(void) MMHyperHeapDump(PVM pVM); 308 #endif 309 MMDECL(size_t) MMHyperHeapGetFreeSize(PVM pVM); 310 MMDECL(size_t) MMHyperHeapGetSize(PVM pVM); 311 MMDECL(RTGCPTR) MMHyperGetArea(PVM pVM, size_t *pcb); 312 MMDECL(bool) MMHyperIsInsideArea(PVM pVM, RTGCPTR GCPtr); 313 314 315 MMDECL(RTHCPHYS) MMPage2Phys(PVM pVM, void *pvPage); 316 MMDECL(void *) MMPagePhys2Page(PVM pVM, RTHCPHYS HCPhysPage); 317 MMDECL(int) MMPagePhys2PageEx(PVM pVM, RTHCPHYS HCPhysPage, void **ppvPage); 318 MMDECL(int) MMPagePhys2PageTry(PVM pVM, RTHCPHYS HCPhysPage, void **ppvPage); 319 MMDECL(void *) MMPhysGCPhys2HCVirt(PVM pVM, RTGCPHYS GCPhys, RTUINT cbRange); 606 320 607 321 … … 626 340 */ 627 341 628 /** 629 * Initialization of MM (save anything depending on PGM). 630 * 631 * @returns VBox status code. 632 * @param pVM The VM to operate on. 633 * @thread The Emulation Thread. 634 */ 635 MMR3DECL(int) MMR3Init(PVM pVM); 636 637 /** 638 * Initializes the MM parts which depends on PGM being initialized. 639 * 640 * @returns VBox status code. 641 * @param pVM The VM to operate on. 642 * @thread The Emulation Thread. 643 */ 644 MMR3DECL(int) MMR3InitPaging(PVM pVM); 645 646 /** 647 * Finalizes the HMA mapping. 648 * 649 * This is called later during init, most (all) HMA allocations should be done 650 * by the time this function is called. 651 * 652 * @returns VBox status. 653 */ 654 MMR3DECL(int) MMR3HyperInitFinalize(PVM pVM); 655 656 /** 657 * Terminates the MM. 658 * 659 * Termination means cleaning up and freeing all resources, 660 * the VM it self is at this point powered off or suspended. 661 * 662 * @returns VBox status code. 663 * @param pVM The VM to operate on. 664 * @thread The Emulation Thread. 665 */ 666 MMR3DECL(int) MMR3Term(PVM pVM); 667 668 /** 669 * Reset notification. 670 * 671 * MM will reload shadow ROMs into RAM at this point and make 672 * the ROM writable. 673 * 674 * @param pVM The VM handle. 675 */ 676 MMR3DECL(void) MMR3Reset(PVM pVM); 677 678 /** 679 * Convert HC Physical address to HC Virtual address. 680 * 681 * @returns VBox status. 682 * @param pVM VM handle. 683 * @param HCPhys The host context virtual address. 684 * @param ppv Where to store the resulting address. 685 * @thread The Emulation Thread. 686 */ 687 MMR3DECL(int) MMR3HCPhys2HCVirt(PVM pVM, RTHCPHYS HCPhys, void **ppv); 688 689 /** 690 * Read memory from GC virtual address using the current guest CR3. 691 * 692 * @returns VBox status. 693 * @param pVM VM handle. 694 * @param pvDst Destination address (HC of course). 695 * @param GCPtr GC virtual address. 696 * @param cb Number of bytes to read. 697 * @thread The Emulation Thread. 698 */ 699 MMR3DECL(int) MMR3ReadGCVirt(PVM pVM, void *pvDst, RTGCPTR GCPtr, size_t cb); 700 701 /** 702 * Write to memory at GC virtual address translated using the current guest CR3. 703 * 704 * @returns VBox status. 705 * @param pVM VM handle. 706 * @param GCPtrDst GC virtual address. 707 * @param pvSrc The source address (HC of course). 708 * @param cb Number of bytes to read. 709 */ 710 MMR3DECL(int) MMR3WriteGCVirt(PVM pVM, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb); 342 MMR3DECL(int) MMR3Init(PVM pVM); 343 MMR3DECL(int) MMR3InitPaging(PVM pVM); 344 MMR3DECL(int) MMR3HyperInitFinalize(PVM pVM); 345 MMR3DECL(int) MMR3Term(PVM pVM); 346 MMR3DECL(void) MMR3Reset(PVM pVM); 347 MMR3DECL(int) MMR3IncreaseBaseReservation(PVM pVM, uint64_t cAddBasePages); 348 MMR3DECL(int) MMR3IncreateFixedReservation(PVM pVM, uint32_t cAddFixedPages); 349 MMR3DECL(int) MMR3UpdateShadowReservation(PVM pVM, uint32_t cShadowPages); 350 351 MMR3DECL(int) MMR3HCPhys2HCVirt(PVM pVM, RTHCPHYS HCPhys, void **ppv); 352 MMR3DECL(int) MMR3ReadGCVirt(PVM pVM, void *pvDst, RTGCPTR GCPtr, size_t cb); 353 MMR3DECL(int) MMR3WriteGCVirt(PVM pVM, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb); 711 354 712 355 … … 714 357 * @ingroup grp_mm_r3 715 358 * @{ */ 716 /** 717 * Allocates memory in the Hypervisor (GC VMM) area which never will 718 * be freed and don't have any offset based relation to other heap blocks. 719 * 720 * The latter means that two blocks allocated by this API will not have the 721 * same relative position to each other in GC and HC. In short, never use 722 * this API for allocating nodes for an offset based AVL tree! 723 * 724 * The returned memory is of course zeroed. 725 * 726 * @returns VBox status code. 727 * @param pVM The VM to operate on. 728 * @param cb Number of bytes to allocate. 729 * @param uAlignment Required memory alignment in bytes. 730 * Values are 0,8,16,32 and PAGE_SIZE. 731 * 0 -> default alignment, i.e. 8 bytes. 732 * @param enmTag The statistics tag. 733 * @param ppv Where to store the address to the allocated 734 * memory. 735 * @remark This is assumed not to be used at times when serialization is required. 736 */ 737 MMDECL(int) MMR3HyperAllocOnceNoRel(PVM pVM, size_t cb, uint32_t uAlignment, MMTAG enmTag, void **ppv); 738 739 /** 740 * Maps contiguous HC physical memory into the hypervisor region in the GC. 741 * 742 * @return VBox status code. 743 * 744 * @param pVM VM handle. 745 * @param pvHC Host context address of the memory. Must be page aligned! 746 * @param HCPhys Host context physical address of the memory to be mapped. Must be page aligned! 747 * @param cb Size of the memory. Will be rounded up to nearest page. 748 * @param pszDesc Description. 749 * @param pGCPtr Where to store the GC address. 750 * @thread The Emulation Thread. 751 */ 752 MMR3DECL(int) MMR3HyperMapHCPhys(PVM pVM, void *pvHC, RTHCPHYS HCPhys, size_t cb, const char *pszDesc, PRTGCPTR pGCPtr); 753 754 /** 755 * Maps contiguous GC physical memory into the hypervisor region in the GC. 756 * 757 * @return VBox status code. 758 * 759 * @param pVM VM handle. 760 * @param GCPhys Guest context physical address of the memory to be mapped. Must be page aligned! 761 * @param cb Size of the memory. Will be rounded up to nearest page. 762 * @param pszDesc Mapping description. 763 * @param pGCPtr Where to store the GC address. 764 * @thread The Emulation Thread. 765 */ 766 MMR3DECL(int) MMR3HyperMapGCPhys(PVM pVM, RTGCPHYS GCPhys, size_t cb, const char *pszDesc, PRTGCPTR pGCPtr); 767 768 /** 769 * Locks and Maps HC virtual memory into the hypervisor region in the GC. 770 * 771 * @return VBox status code. 772 * 773 * @param pVM VM handle. 774 * @param pvHC Host context address of the memory (may be not page aligned). 775 * @param cb Size of the memory. Will be rounded up to nearest page. 776 * @param fFree Set this if MM is responsible for freeing the memory using SUPPageFree. 777 * @param pszDesc Mapping description. 778 * @param pGCPtr Where to store the GC address corresponding to pvHC. 779 * @thread The Emulation Thread. 780 */ 781 MMR3DECL(int) MMR3HyperMapHCRam(PVM pVM, void *pvHC, size_t cb, bool fFree, const char *pszDesc, PRTGCPTR pGCPtr); 782 783 /** 784 * Maps locked R3 virtual memory into the hypervisor region in the GC. 785 * 786 * @return VBox status code. 787 * 788 * @param pVM VM handle. 789 * @param pvR3 The ring-3 address of the memory, must be page aligned. 790 * @param pvR0 The ring-0 address of the memory, must be page aligned. (optional) 791 * @param cPages The number of pages. 792 * @param paPages The page descriptors. 793 * @param pszDesc Mapping description. 794 * @param pGCPtr Where to store the GC address corresponding to pvHC. 795 */ 796 MMR3DECL(int) MMR3HyperMapPages(PVM pVM, void *pvR3, RTR0PTR pvR0, size_t cPages, PCSUPPAGE paPages, const char *pszDesc, PRTGCPTR pGCPtr); 797 798 /** 799 * Reserves a hypervisor memory area. 800 * Most frequent usage is fence pages and dynamically mappings like the guest PD and PDPTR. 801 * 802 * @return VBox status code. 803 * 804 * @param pVM VM handle. 805 * @param cb Size of the memory. Will be rounded up to nearest page. 806 * @param pszDesc Mapping description. 807 * @param pGCPtr Where to store the assigned GC address. Optional. 808 * @thread The Emulation Thread. 809 */ 810 MMR3DECL(int) MMR3HyperReserve(PVM pVM, unsigned cb, const char *pszDesc, PRTGCPTR pGCPtr); 811 812 813 /** 814 * Convert hypervisor HC virtual address to HC physical address. 815 * 816 * @returns HC physical address. 817 * @param pVM VM Handle 818 * @param pvHC Host context physical address. 819 * @thread The Emulation Thread. 820 */ 821 MMR3DECL(RTHCPHYS) MMR3HyperHCVirt2HCPhys(PVM pVM, void *pvHC); 822 /** 823 * Convert hypervisor HC virtual address to HC physical address. 824 * 825 * @returns HC physical address. 826 * @param pVM VM Handle 827 * @param pvHC Host context physical address. 828 * @param pHCPhys Where to store the HC physical address. 829 * @thread The Emulation Thread. 830 */ 831 MMR3DECL(int) MMR3HyperHCVirt2HCPhysEx(PVM pVM, void *pvHC, PRTHCPHYS pHCPhys); 832 /** 833 * Convert hypervisor HC physical address to HC virtual address. 834 * 835 * @returns HC virtual address. 836 * @param pVM VM Handle 837 * @param HCPhys Host context physical address. 838 * @thread The Emulation Thread. 839 */ 840 MMR3DECL(void *) MMR3HyperHCPhys2HCVirt(PVM pVM, RTHCPHYS HCPhys); 841 /** 842 * Convert hypervisor HC physical address to HC virtual address. 843 * 844 * @returns VBox status. 845 * @param pVM VM Handle 846 * @param HCPhys Host context physical address. 847 * @param ppv Where to store the HC virtual address. 848 * @thread The Emulation Thread. 849 */ 850 MMR3DECL(int) MMR3HyperHCPhys2HCVirtEx(PVM pVM, RTHCPHYS HCPhys, void **ppv); 851 852 /** 853 * Read hypervisor memory from GC virtual address. 854 * 855 * @returns VBox status. 856 * @param pVM VM handle. 857 * @param pvDst Destination address (HC of course). 858 * @param GCPtr GC virtual address. 859 * @param cb Number of bytes to read. 860 * @thread The Emulation Thread. 861 */ 862 MMR3DECL(int) MMR3HyperReadGCVirt(PVM pVM, void *pvDst, RTGCPTR GCPtr, size_t cb); 863 359 MMDECL(int) MMR3HyperAllocOnceNoRel(PVM pVM, size_t cb, uint32_t uAlignment, MMTAG enmTag, void **ppv); 360 MMR3DECL(int) MMR3HyperMapHCPhys(PVM pVM, void *pvHC, RTHCPHYS HCPhys, size_t cb, const char *pszDesc, PRTGCPTR pGCPtr); 361 MMR3DECL(int) MMR3HyperMapGCPhys(PVM pVM, RTGCPHYS GCPhys, size_t cb, const char *pszDesc, PRTGCPTR pGCPtr); 362 MMR3DECL(int) MMR3HyperMapHCRam(PVM pVM, void *pvHC, size_t cb, bool fFree, const char *pszDesc, PRTGCPTR pGCPtr); 363 MMR3DECL(int) MMR3HyperMapPages(PVM pVM, void *pvR3, RTR0PTR pvR0, size_t cPages, PCSUPPAGE paPages, const char *pszDesc, PRTGCPTR pGCPtr); 364 MMR3DECL(int) MMR3HyperReserve(PVM pVM, unsigned cb, const char *pszDesc, PRTGCPTR pGCPtr); 365 MMR3DECL(RTHCPHYS) MMR3HyperHCVirt2HCPhys(PVM pVM, void *pvHC); 366 MMR3DECL(int) MMR3HyperHCVirt2HCPhysEx(PVM pVM, void *pvHC, PRTHCPHYS pHCPhys); 367 MMR3DECL(void *) MMR3HyperHCPhys2HCVirt(PVM pVM, RTHCPHYS HCPhys); 368 MMR3DECL(int) MMR3HyperHCPhys2HCVirtEx(PVM pVM, RTHCPHYS HCPhys, void **ppv); 369 MMR3DECL(int) MMR3HyperReadGCVirt(PVM pVM, void *pvDst, RTGCPTR GCPtr, size_t cb); 864 370 /** @} */ 865 371 … … 868 374 * @ingroup grp_mm_r3 869 375 * @{ */ 870 871 /** 872 * Register externally allocated RAM for the virtual machine. 873 * 874 * The memory registered with the VM thru this interface must not be freed 875 * before the virtual machine has been destroyed. Bad things may happen... :-) 876 * 877 * @return VBox status code. 878 * @param pVM VM handle. 879 * @param pvRam Virtual address of the guest's physical memory range Must be page aligned. 880 * @param GCPhys The physical address the ram shall be registered at. 881 * @param cb Size of the memory. Must be page aligend. 882 * @param fFlags Flags of the MM_RAM_FLAGS_* defines. 883 * @param pszDesc Description of the memory. 884 * @thread The Emulation Thread. 885 * 886 * @todo This will only be used for registering MMIO2 memory from devices. So, rename it. 887 */ 888 MMR3DECL(int) MMR3PhysRegister(PVM pVM, void *pvRam, RTGCPHYS GCPhys, unsigned cb, unsigned fFlags, const char *pszDesc); 889 376 MMR3DECL(int) MMR3PhysRegister(PVM pVM, void *pvRam, RTGCPHYS GCPhys, unsigned cb, unsigned fFlags, const char *pszDesc); 890 377 #ifndef VBOX_WITH_NEW_PHYS_CODE 891 /** 892 * Register externally allocated RAM for the virtual machine. 893 * 894 * The memory registered with the VM thru this interface must not be freed 895 * before the virtual machine has been destroyed. Bad things may happen... :-) 896 * 897 * @return VBox status code. 898 * @param pVM VM handle. 899 * @param pvRam Virtual address of the guest's physical memory range Must be page aligned. 900 * @param GCPhys The physical address the ram shall be registered at. 901 * @param cb Size of the memory. Must be page aligend. 902 * @param fFlags Flags of the MM_RAM_FLAGS_* defines. 903 * @param enmType Physical range type (MM_PHYS_TYPE_*) 904 * @param pszDesc Description of the memory. 905 * @thread The Emulation Thread. 906 * @todo update this description. 907 * @deprecated For the old dynamic allocation code only. Will be removed with VBOX_WITH_NEW_PHYS_CODE. 908 */ 909 MMR3DECL(int) MMR3PhysRegisterEx(PVM pVM, void *pvRam, RTGCPHYS GCPhys, unsigned cb, unsigned fFlags, MMPHYSREG enmType, const char *pszDesc); 910 #endif /* !VBOX_WITH_NEW_PHYS_CODE */ 911 912 /** 913 * Register previously registered externally allocated RAM for the virtual machine. 914 * 915 * Use this only for MMIO ranges or the guest will become very confused. 916 * The memory registered with the VM thru this interface must not be freed 917 * before the virtual machine has been destroyed. Bad things may happen... :-) 918 * 919 * @return VBox status code. 920 * @param pVM VM handle. 921 * @param GCPhysOld The physical address the ram was registered at. 922 * @param GCPhysNew The physical address the ram shall be registered at. 923 * @param cb Size of the memory. Must be page aligend. 924 * @thread The Emulation Thread. 925 */ 926 MMR3DECL(int) MMR3PhysRelocate(PVM pVM, RTGCPHYS GCPhysOld, RTGCPHYS GCPhysNew, unsigned cb); 927 928 /** 929 * Register a ROM (BIOS) region. 930 * 931 * It goes without saying that this is read-only memory. The memory region must be 932 * in unassigned memory. I.e. from the top of the address space or on the PC in 933 * the 0xa0000-0xfffff range. 934 * 935 * @returns VBox status. 936 * @param pVM VM Handle. 937 * @param pDevIns The device instance owning the ROM region. 938 * @param GCPhys First physical address in the range. 939 * Must be page aligned! 940 * @param cbRange The size of the range (in bytes). 941 * Must be page aligned! 942 * @param pvBinary Pointer to the binary data backing the ROM image. 943 * This must be cbRange bytes big. 944 * It will be copied and doesn't have to stick around. 945 * It will be copied and doesn't have to stick around if fShadow is clear. 946 * @param fShadow Whether to emulate ROM shadowing. This involves leaving 947 * the ROM writable for a while during the POST and refreshing 948 * it at reset. When this flag is set, the memory pointed to by 949 * pvBinary has to stick around for the lifespan of the VM. 950 * @param pszDesc Pointer to description string. This must not be freed. 951 * @remark There is no way to remove the rom, automatically on device cleanup or 952 * manually from the device yet. At present I doubt we need such features... 953 * @thread The Emulation Thread. 954 */ 955 MMR3DECL(int) MMR3PhysRomRegister(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTUINT cbRange, const void *pvBinary, bool fShadow, const char *pszDesc); 956 957 /** 958 * Write-protects a shadow ROM range. 959 * 960 * This is called late in the POST for shadow ROM ranges. 961 * 962 * @returns VBox status code. 963 * @param pVM The VM handle. 964 * @param GCPhys Start of the registered shadow ROM range 965 * @param cbRange The length of the registered shadow ROM range. 966 * This can be NULL (not sure about the BIOS interface yet). 967 */ 968 MMR3DECL(int) MMR3PhysRomProtect(PVM pVM, RTGCPHYS GCPhys, RTUINT cbRange); 969 970 /** 971 * Reserve physical address space for ROM and MMIO ranges. 972 * 973 * @returns VBox status code. 974 * @param pVM VM Handle. 975 * @param GCPhys Start physical address. 976 * @param cbRange The size of the range. 977 * @param pszDesc Description string. 978 * @thread The Emulation Thread. 979 */ 980 MMR3DECL(int) MMR3PhysReserve(PVM pVM, RTGCPHYS GCPhys, RTUINT cbRange, const char *pszDesc); 981 982 /** 983 * Get the size of the base RAM. 984 * This usually means the size of the first contigous block of physical memory. 985 * 986 * @returns 987 * @param pVM 988 * @thread Any. 989 */ 990 MMR3DECL(uint64_t) MMR3PhysGetRamSize(PVM pVM); 991 992 378 MMR3DECL(int) MMR3PhysRegisterEx(PVM pVM, void *pvRam, RTGCPHYS GCPhys, unsigned cb, unsigned fFlags, MMPHYSREG enmType, const char *pszDesc); 379 #endif 380 MMR3DECL(int) MMR3PhysRelocate(PVM pVM, RTGCPHYS GCPhysOld, RTGCPHYS GCPhysNew, unsigned cb); 381 MMR3DECL(int) MMR3PhysRomRegister(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTUINT cbRange, const void *pvBinary, bool fShadow, const char *pszDesc); 382 MMR3DECL(int) MMR3PhysRomProtect(PVM pVM, RTGCPHYS GCPhys, RTUINT cbRange); 383 MMR3DECL(int) MMR3PhysReserve(PVM pVM, RTGCPHYS GCPhys, RTUINT cbRange, const char *pszDesc); 384 MMR3DECL(uint64_t) MMR3PhysGetRamSize(PVM pVM); 993 385 /** @} */ 994 386 … … 997 389 * @ingroup grp_mm_r3 998 390 * @{ */ 999 /** 1000 * Allocates a page from the page pool. 1001 * 1002 * This function may returns pages which has physical addresses any 1003 * where. If you require a page to be within the first 4GB of physical 1004 * memory, use MMR3PageAllocLow(). 1005 * 1006 * @returns Pointer to the allocated page page. 1007 * @returns NULL on failure. 1008 * @param pVM VM handle. 1009 * @thread The Emulation Thread. 1010 */ 1011 MMR3DECL(void *) MMR3PageAlloc(PVM pVM); 1012 1013 /** 1014 * Allocates a page from the page pool and return its physical address. 1015 * 1016 * This function may returns pages which has physical addresses any 1017 * where. If you require a page to be within the first 4GB of physical 1018 * memory, use MMR3PageAllocLow(). 1019 * 1020 * @returns Pointer to the allocated page page. 1021 * @returns NIL_RTHCPHYS on failure. 1022 * @param pVM VM handle. 1023 * @thread The Emulation Thread. 1024 */ 1025 MMR3DECL(RTHCPHYS) MMR3PageAllocPhys(PVM pVM); 1026 1027 /** 1028 * Frees a page allocated from the page pool by MMR3PageAlloc() and MMR3PageAllocPhys(). 1029 * 1030 * @param pVM VM handle. 1031 * @param pvPage Pointer to the page. 1032 * @thread The Emulation Thread. 1033 */ 1034 MMR3DECL(void) MMR3PageFree(PVM pVM, void *pvPage); 1035 1036 /** 1037 * Allocates a page from the low page pool. 1038 * 1039 * @returns Pointer to the allocated page. 1040 * @returns NULL on failure. 1041 * @param pVM VM handle. 1042 * @thread The Emulation Thread. 1043 */ 1044 MMR3DECL(void *) MMR3PageAllocLow(PVM pVM); 1045 1046 /** 1047 * Frees a page allocated from the page pool by MMR3PageAllocLow(). 1048 * 1049 * @param pVM VM handle. 1050 * @param pvPage Pointer to the page. 1051 * @thread The Emulation Thread. 1052 */ 1053 MMR3DECL(void) MMR3PageFreeLow(PVM pVM, void *pvPage); 1054 1055 /** 1056 * Free a page allocated from the page pool by physical address. 1057 * This works for pages allocated by MMR3PageAlloc(), MMR3PageAllocPhys() 1058 * and MMR3PageAllocLow(). 1059 * 1060 * @param pVM VM handle. 1061 * @param HCPhysPage The physical address of the page to be freed. 1062 * @thread The Emulation Thread. 1063 */ 1064 MMR3DECL(void) MMR3PageFreeByPhys(PVM pVM, RTHCPHYS HCPhysPage); 1065 1066 /** 1067 * Gets the HC pointer to the dummy page. 1068 * 1069 * The dummy page is used as a place holder to prevent potential bugs 1070 * from doing really bad things to the system. 1071 * 1072 * @returns Pointer to the dummy page. 1073 * @param pVM VM handle. 1074 * @thread The Emulation Thread. 1075 */ 1076 MMR3DECL(void *) MMR3PageDummyHCPtr(PVM pVM); 1077 1078 /** 1079 * Gets the HC Phys to the dummy page. 1080 * 1081 * The dummy page is used as a place holder to prevent potential bugs 1082 * from doing really bad things to the system. 1083 * 1084 * @returns Pointer to the dummy page. 1085 * @param pVM VM handle. 1086 * @thread The Emulation Thread. 1087 */ 1088 MMR3DECL(RTHCPHYS) MMR3PageDummyHCPhys(PVM pVM); 1089 1090 1091 #if 1 /* these are temporary wrappers and will be removed soon */ 1092 /** 1093 * Allocates a Page Table. 1094 * 1095 * @returns Pointer to page table. 1096 * @returns NULL on failure. 1097 * @param pVM VM handle. 1098 * @deprecated Use MMR3PageAlloc(). 1099 */ 1100 DECLINLINE(PVBOXPT) MMR3PTAlloc(PVM pVM) 1101 { 1102 return (PVBOXPT)MMR3PageAlloc(pVM); 1103 } 1104 1105 /** 1106 * Free a Page Table. 1107 * 1108 * @param pVM VM handle. 1109 * @param pPT Pointer to the page table as returned by MMR3PTAlloc(). 1110 * @deprecated Use MMR3PageFree(). 1111 */ 1112 DECLINLINE(void) MMR3PTFree(PVM pVM, PVBOXPT pPT) 1113 { 1114 MMR3PageFree(pVM, pPT); 1115 } 1116 1117 /** 1118 * Free a Page Table by physical address. 1119 * 1120 * @param pVM VM handle. 1121 * @param HCPhysPT The physical address of the page table to be freed. 1122 * @deprecated Use MMR3PageFreeByPhys(). 1123 */ 1124 DECLINLINE(void) MMR3PTFreeByPhys(PVM pVM, RTHCPHYS HCPhysPT) 1125 { 1126 MMR3PageFreeByPhys(pVM, HCPhysPT); 1127 } 1128 1129 /** 1130 * Convert a Page Table address to a HC physical address. 1131 * 1132 * @returns Physical address for the specified page table. 1133 * @param pVM VM handle. 1134 * @param pPT Page table which physical address we query. 1135 * @deprecated Use MMR3Page2Phys(). 1136 */ 1137 DECLINLINE(RTHCPHYS) MMR3PT2Phys(PVM pVM, PVBOXPT pPT) 1138 { 1139 return MMPage2Phys(pVM, pPT); 1140 } 1141 1142 /** 1143 * Convert a physical address to a page table address 1144 * 1145 * @returns Pointer to the page table at that physical address. 1146 * @param pVM VM handle. 1147 * @param PhysPT Page table which physical address we query. 1148 * @deprecated Use MMR3PagePhys2Page(). 1149 */ 1150 DECLINLINE(PVBOXPT) MMR3Phys2PT(PVM pVM, RTHCPHYS PhysPT) 1151 { 1152 return (PVBOXPT)MMPagePhys2Page(pVM, PhysPT); 1153 } 1154 1155 /** 1156 * Allocate a Page Directory. 1157 * 1158 * @returns Pointer to the page directory. 1159 * @returns NULL on failure. 1160 * @param pVM VM handle. 1161 * @deprecated Use MMR3PageAlloc(). 1162 */ 1163 DECLINLINE(PVBOXPD) MMR3PDAlloc(PVM pVM) 1164 { 1165 return (PVBOXPD)MMR3PageAlloc(pVM); 1166 } 1167 1168 /** 1169 * Free a Page Directory. 1170 * 1171 * @param pVM VM handle. 1172 * @param pPD Pointer to the page directory allocated by MMR3PDAlloc(). 1173 * @deprecated Use MMR3PageFree(). 1174 */ 1175 DECLINLINE(void) MMR3PDFree(PVM pVM, PVBOXPD pPD) 1176 { 1177 MMR3PageFree(pVM, pPD); 1178 } 1179 1180 /** 1181 * Convert a Page Directory address to a physical address. 1182 * 1183 * @returns Physical address for the specified page directory. 1184 * @param pVM VM handle. 1185 * @param pPD Page directory which physical address we query. 1186 * Allocated by MMR3PDAlloc(). 1187 * @deprecated Use MMR3Page2Phys(). 1188 */ 1189 DECLINLINE(RTHCPHYS) MMR3PD2Phys(PVM pVM, PVBOXPD pPD) 1190 { 1191 return MMPage2Phys(pVM, pPD); 1192 } 1193 1194 /** 1195 * Convert a physical address to a page directory address 1196 * 1197 * @returns Pointer to the page directory at that physical address. 1198 * @param pVM VM handle. 1199 * @param PhysPD Physical address of page directory. 1200 * Allocated by MMR3PDAlloc(). 1201 * @deprecated Use MMR3PageAlloc(). 1202 */ 1203 DECLINLINE(PVBOXPD) MMR3Phys2PD(PVM pVM, RTHCPHYS PhysPD) 1204 { 1205 return (PVBOXPD)MMPagePhys2Page(pVM, PhysPD); 1206 } 1207 1208 /** @deprecated */ 1209 DECLINLINE(void *) MMR3DummyPageHCPtr(PVM pVM) { return MMR3PageDummyHCPtr(pVM); } 1210 /** @deprecated */ 1211 DECLINLINE(RTHCPHYS) MMR3DummyPageHCPhys(PVM pVM) { return MMR3PageDummyHCPhys(pVM); } 1212 1213 #endif /* will be removed */ 1214 391 MMR3DECL(void *) MMR3PageAlloc(PVM pVM); 392 MMR3DECL(RTHCPHYS) MMR3PageAllocPhys(PVM pVM); 393 MMR3DECL(void) MMR3PageFree(PVM pVM, void *pvPage); 394 MMR3DECL(void *) MMR3PageAllocLow(PVM pVM); 395 MMR3DECL(void) MMR3PageFreeLow(PVM pVM, void *pvPage); 396 MMR3DECL(void) MMR3PageFreeByPhys(PVM pVM, RTHCPHYS HCPhysPage); 397 MMR3DECL(void *) MMR3PageDummyHCPtr(PVM pVM); 398 MMR3DECL(RTHCPHYS) MMR3PageDummyHCPhys(PVM pVM); 1215 399 /** @} */ 1216 400 … … 1219 403 * @ingroup grp_mm_r3 1220 404 * @{ */ 1221 1222 /** 1223 * Allocate memory associating it with the VM for collective cleanup. 1224 * 1225 * The memory will be allocated from the default heap but a header 1226 * is added in which we keep track of which VM it belongs to and chain 1227 * all the allocations together so they can be freed in a one go. 1228 * 1229 * This interface is typically used for memory block which will not be 1230 * freed during the life of the VM. 1231 * 1232 * @returns Pointer to allocated memory. 1233 * @param pVM VM handle. 1234 * @param enmTag Statistics tag. Statistics are collected on a per tag 1235 * basis in addition to a global one. Thus we can easily 1236 * identify how memory is used by the VM. 1237 * @param cbSize Size of the block. 1238 * @thread Any thread. 1239 */ 1240 MMR3DECL(void *) MMR3HeapAlloc(PVM pVM, MMTAG enmTag, size_t cbSize); 1241 1242 /** 1243 * Same as MMR3HeapAlloc(). 1244 * 1245 * 1246 * @returns Pointer to allocated memory. 1247 * @param pVM VM handle. 1248 * @param enmTag Statistics tag. Statistics are collected on a per tag 1249 * basis in addition to a global one. Thus we can easily 1250 * identify how memory is used by the VM. 1251 * @param cbSize Size of the block. 1252 * @param ppv Where to store the pointer to the allocated memory on success. 1253 * @thread Any thread. 1254 */ 1255 MMR3DECL(int) MMR3HeapAllocEx(PVM pVM, MMTAG enmTag, size_t cbSize, void **ppv); 1256 1257 /** 1258 * Same as MMR3HeapAlloc() only the memory is zeroed. 1259 * 1260 * 1261 * @returns Pointer to allocated memory. 1262 * @param pVM VM handle. 1263 * @param enmTag Statistics tag. Statistics are collected on a per tag 1264 * basis in addition to a global one. Thus we can easily 1265 * identify how memory is used by the VM. 1266 * @param cbSize Size of the block. 1267 * @thread Any thread. 1268 */ 1269 MMR3DECL(void *) MMR3HeapAllocZ(PVM pVM, MMTAG enmTag, size_t cbSize); 1270 1271 /** 1272 * Same as MMR3HeapAllocZ(). 1273 * 1274 * 1275 * @returns Pointer to allocated memory. 1276 * @param pVM VM handle. 1277 * @param enmTag Statistics tag. Statistics are collected on a per tag 1278 * basis in addition to a global one. Thus we can easily 1279 * identify how memory is used by the VM. 1280 * @param cbSize Size of the block. 1281 * @param ppv Where to store the pointer to the allocated memory on success. 1282 * @thread Any thread. 1283 */ 1284 MMR3DECL(int) MMR3HeapAllocZEx(PVM pVM, MMTAG enmTag, size_t cbSize, void **ppv); 1285 1286 /** 1287 * Reallocate memory allocated with MMR3HeapAlloc() or MMR3HeapRealloc(). 1288 * 1289 * @returns Pointer to reallocated memory. 1290 * @param pv Pointer to the memory block to reallocate. 1291 * Must not be NULL! 1292 * @param cbNewSize New block size. 1293 * @thread Any thread. 1294 */ 1295 MMR3DECL(void *) MMR3HeapRealloc(void *pv, size_t cbNewSize); 1296 1297 /** 1298 * Duplicates the specified string. 1299 * 1300 * @returns Pointer to the duplicate. 1301 * @returns NULL on failure or when input NULL. 1302 * @param pVM The VM handle. 1303 * @param enmTag Statistics tag. Statistics are collected on a per tag 1304 * basis in addition to a global one. Thus we can easily 1305 * identify how memory is used by the VM. 1306 * @param psz The string to duplicate. NULL is allowed. 1307 */ 1308 MMR3DECL(char *) MMR3HeapStrDup(PVM pVM, MMTAG enmTag, const char *psz); 1309 1310 /** 1311 * Releases memory allocated with MMR3HeapAlloc() or MMR3HeapRealloc(). 1312 * 1313 * @param pv Pointer to the memory block to free. 1314 * @thread Any thread. 1315 */ 1316 MMR3DECL(void) MMR3HeapFree(void *pv); 1317 1318 /** @} */ 1319 1320 /** @} */ 1321 #endif 405 MMR3DECL(void *) MMR3HeapAlloc(PVM pVM, MMTAG enmTag, size_t cbSize); 406 MMR3DECL(int) MMR3HeapAllocEx(PVM pVM, MMTAG enmTag, size_t cbSize, void **ppv); 407 MMR3DECL(void *) MMR3HeapAllocZ(PVM pVM, MMTAG enmTag, size_t cbSize); 408 MMR3DECL(int) MMR3HeapAllocZEx(PVM pVM, MMTAG enmTag, size_t cbSize, void **ppv); 409 MMR3DECL(void *) MMR3HeapRealloc(void *pv, size_t cbNewSize); 410 MMR3DECL(char *) MMR3HeapStrDup(PVM pVM, MMTAG enmTag, const char *psz); 411 MMR3DECL(void) MMR3HeapFree(void *pv); 412 /** @} */ 413 414 /** @} */ 415 #endif /* IN_RING3 */ 1322 416 1323 417 … … 1329 423 */ 1330 424 1331 /** 1332 * Install MMGCRam Hypervisor page fault handler for normal working 1333 * of MMGCRamRead and MMGCRamWrite calls. 1334 * This handler will be automatically removed at page fault. 1335 * In other case it must be removed by MMGCRamDeregisterTrapHandler call. 1336 * 1337 * @param pVM VM handle. 1338 */ 1339 MMGCDECL(void) MMGCRamRegisterTrapHandler(PVM pVM); 1340 1341 /** 1342 * Remove MMGCRam Hypervisor page fault handler. 1343 * See description of MMGCRamRegisterTrapHandler call. 1344 * 1345 * @param pVM VM handle. 1346 */ 1347 MMGCDECL(void) MMGCRamDeregisterTrapHandler(PVM pVM); 1348 1349 /** 1350 * Read data in guest context with \#PF control. 1351 * MMRamGC page fault handler must be installed prior this call for safe operation. 1352 * Use MMGCRamRegisterTrapHandler() call for this task. 1353 * 1354 * @returns VBox status. 1355 * @param pDst Where to store the readed data. 1356 * @param pSrc Pointer to the data to read. 1357 * @param cb Size of data to read, only 1/2/4/8 is valid. 1358 */ 1359 MMGCDECL(int) MMGCRamReadNoTrapHandler(void *pDst, void *pSrc, size_t cb); 1360 1361 /** 1362 * Write data in guest context with \#PF control. 1363 * MMRamGC page fault handler must be installed prior this call for safe operation. 1364 * Use MMGCRamRegisterTrapHandler() call for this task. 1365 * 1366 * @returns VBox status. 1367 * @param pDst Where to write the data. 1368 * @param pSrc Pointer to the data to write. 1369 * @param cb Size of data to write, only 1/2/4 is valid. 1370 */ 1371 MMGCDECL(int) MMGCRamWriteNoTrapHandler(void *pDst, void *pSrc, size_t cb); 1372 1373 /** 1374 * Read data in guest context with \#PF control. 1375 * 1376 * @returns VBox status. 1377 * @param pVM The VM handle. 1378 * @param pDst Where to store the readed data. 1379 * @param pSrc Pointer to the data to read. 1380 * @param cb Size of data to read, only 1/2/4/8 is valid. 1381 */ 1382 MMGCDECL(int) MMGCRamRead(PVM pVM, void *pDst, void *pSrc, size_t cb); 1383 1384 /** 1385 * Write data in guest context with \#PF control. 1386 * 1387 * @returns VBox status. 1388 * @param pVM The VM handle. 1389 * @param pDst Where to write the data. 1390 * @param pSrc Pointer to the data to write. 1391 * @param cb Size of data to write, only 1/2/4 is valid. 1392 */ 1393 MMGCDECL(int) MMGCRamWrite(PVM pVM, void *pDst, void *pSrc, size_t cb); 1394 1395 /** @} */ 1396 #endif 425 MMGCDECL(void) MMGCRamRegisterTrapHandler(PVM pVM); 426 MMGCDECL(void) MMGCRamDeregisterTrapHandler(PVM pVM); 427 MMGCDECL(int) MMGCRamReadNoTrapHandler(void *pDst, void *pSrc, size_t cb); 428 MMGCDECL(int) MMGCRamWriteNoTrapHandler(void *pDst, void *pSrc, size_t cb); 429 MMGCDECL(int) MMGCRamRead(PVM pVM, void *pDst, void *pSrc, size_t cb); 430 MMGCDECL(int) MMGCRamWrite(PVM pVM, void *pDst, void *pSrc, size_t cb); 431 432 /** @} */ 433 #endif /* IN_GC */ 1397 434 1398 435 /** @} */
Note:
See TracChangeset
for help on using the changeset viewer.