Changeset 6836 in vbox
- Timestamp:
- Feb 6, 2008 7:59:53 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 27955
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/gmm.h
r6800 r6836 250 250 251 251 252 GMMR3DECL(int) GMMR3InitialReservation(PVM pVM, uint64_t cBasePages, uint32_t cShadowPages, uint32_t cFixedPages,253 GMMOCPOLICY enmPolicy, GMMPRIORITY enmPriority);254 GMMR3DECL(int) GMMR3UpdateReservation(PVM pVM, uint64_t cBasePages, uint32_t cShadowPages, uint32_t cFixedPages);255 GMMR3DECL(int) GMMR3DeflatedBalloon(PVM pVM, uint32_t cPages);256 GMMR3DECL(int) GMMR3MapUnmapChunk(PVM pVM, uint32_t idChunkMap, uint32_t idChunkUnmap, PRTR3PTR ppvR3);257 GMMR3DECL(int) GMMR3SeedChunk(PVM pVM, RTR3PTR pvR3);258 259 260 252 261 253 /** … … 383 375 384 376 377 #ifdef IN_RING3 378 /** @defgroup grp_gmm_r3 The Global Memory Manager Ring-3 API Wrappers 379 * @ingroup grp_gmm 380 * @{ 381 */ 382 GMMR3DECL(int) GMMR3InitialReservation(PVM pVM, uint64_t cBasePages, uint32_t cShadowPages, uint32_t cFixedPages, 383 GMMOCPOLICY enmPolicy, GMMPRIORITY enmPriority); 384 GMMR3DECL(int) GMMR3UpdateReservation(PVM pVM, uint64_t cBasePages, uint32_t cShadowPages, uint32_t cFixedPages); 385 GMMR3DECL(int) GMMR3AllocatePagesPrepare(PVM pVM, PGMMALLOCATEPAGESREQ *ppReq, uint32_t cPages, GMMACCOUNT enmAccount); 386 GMMR3DECL(int) GMMR3AllocatePagesPerform(PVM pVM, PGMMALLOCATEPAGESREQ pReq); 387 GMMR3DECL(void) GMMR3AllocatePagesCleanup(PGMMALLOCATEPAGESREQ pReq); 388 GMMR3DECL(int) GMMR3DeflatedBalloon(PVM pVM, uint32_t cPages); 389 GMMR3DECL(int) GMMR3MapUnmapChunk(PVM pVM, uint32_t idChunkMap, uint32_t idChunkUnmap, PRTR3PTR ppvR3); 390 GMMR3DECL(int) GMMR3SeedChunk(PVM pVM, RTR3PTR pvR3); 385 391 /** @} */ 392 #endif /* IN_RING3 */ 393 394 /** @} */ 386 395 387 396 __END_DECLS -
trunk/src/VBox/VMM/GMM.cpp
r6581 r6836 25 25 #include <VBox/sup.h> 26 26 #include <VBox/err.h> 27 #include <VBox/param.h> 28 29 #include <iprt/mem.h> 27 30 28 31 … … 60 63 61 64 62 #if 0 /* impractical */ 63 GMMR3DECL(int) GMMR3AllocatePages(PVM pVM, uint32_t cPages, PGMMPAGEDESC paPages, GMMACCOUNT enmAccount) 65 /** 66 * Prepares a GMMR0AllocatePages request. 67 */ 68 GMMR3DECL(int) GMMR3AllocatePagesPrepare(PVM pVM, PGMMALLOCATEPAGESREQ *ppReq, uint32_t cPages, GMMACCOUNT enmAccount) 64 69 { 65 GMMALLOCATEPAGESREQ Req; 66 Req.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; 67 Req.Hdr.cbReq = sizeof(Req); 70 uint32_t cb = RT_OFFSETOF(GMMALLOCATEPAGESREQ, aPages[cPages]); 71 PGMMALLOCATEPAGESREQ pReq = (PGMMALLOCATEPAGESREQ)RTMemTmpAllocZ(cb); 72 if (!pReq) 73 return VERR_NO_TMP_MEMORY; 68 74 69 return SUPCallVMMR0Ex(pVM->pVMR0, VMMR0_DO_GMM_ALLOCATE_PAGES, 0, &Req.Hdr); 75 pReq->Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; 76 pReq->Hdr.cbReq = cb; 77 pReq->enmAccount = enmAccount; 78 pReq->cPages = cPages; 79 NOREF(pVM); 80 return VINF_SUCCESS; 70 81 } 71 #endif 82 83 84 /** 85 * Performs a GMMR0AllocatePages request. 86 * This will call VMSetError on failure. 87 * 88 * @returns VBox status code. 89 * @param pVM Pointer to the shared VM structure. 90 * @param pReq Pointer to the request (returned by GMMR3AllocatePagesPrepare). 91 */ 92 GMMR3DECL(int) GMMR3AllocatePagesPerform(PVM pVM, PGMMALLOCATEPAGESREQ pReq) 93 { 94 for (unsigned i = 0; ; i++) 95 { 96 int rc = SUPCallVMMR0Ex(pVM->pVMR0, VMMR0_DO_GMM_ALLOCATE_PAGES, 0, &pReq->Hdr); 97 if (RT_SUCCESS(rc)) 98 return rc; 99 if (rc != VERR_GMM_SEED_ME) 100 return VMSetError(pVM, rc, RT_SRC_POS, 101 N_("GMMR0AllocatePages failed to allocate %u pages"), 102 pReq->cPages); 103 Assert(i < pReq->cPages); 104 105 /* 106 * Seed another chunk. 107 */ 108 void *pvChunk; 109 rc = SUPPageAlloc(GMM_CHUNK_SIZE >> PAGE_SHIFT, &pvChunk); 110 if (VBOX_FAILURE(rc)) 111 return VMSetError(pVM, rc, RT_SRC_POS, 112 N_("Out of memory (SUPPageAlloc) seeding a %u pages allocation request"), 113 pReq->cPages); 114 115 rc = SUPCallVMMR0Ex(pVM->pVMR0, VMMR0_DO_GMM_SEED_CHUNK, (uintptr_t)pvChunk, NULL); 116 if (RT_FAILURE(rc)) 117 return VMSetError(pVM, rc, RT_SRC_POS, N_("GMM seeding failed")); 118 } 119 } 120 121 122 /** 123 * Cleans up a GMMR0AllocatePages request. 124 * @param pReq Pointer to the request (returned by GMMR3AllocatePagesPrepare). 125 */ 126 GMMR3DECL(void) GMMR3AllocatePagesCleanup(PGMMALLOCATEPAGESREQ pReq) 127 { 128 RTMemTmpFree(pReq); 129 } 72 130 73 131
Note:
See TracChangeset
for help on using the changeset viewer.