Changeset 6839 in vbox
- Timestamp:
- Feb 7, 2008 10:12:59 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
include/VBox/gmm.h (modified) (1 diff)
-
src/VBox/VMM/GMM.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/gmm.h
r6836 r6839 386 386 GMMR3DECL(int) GMMR3AllocatePagesPerform(PVM pVM, PGMMALLOCATEPAGESREQ pReq); 387 387 GMMR3DECL(void) GMMR3AllocatePagesCleanup(PGMMALLOCATEPAGESREQ pReq); 388 GMMR3DECL(int) GMMR3FreePagesPrepare(PVM pVM, PGMMFREEPAGESREQ *ppReq, uint32_t cPages, GMMACCOUNT enmAccount); 389 GMMR3DECL(int) GMMR3FreePagesPerform(PVM pVM, PGMMFREEPAGESREQ pReq); 390 GMMR3DECL(void) GMMR3FreePagesCleanup(PGMMFREEPAGESREQ pReq); 391 GMMR3DECL(void) GMMR3FreeAllocatedPages(PVM pVM, GMMALLOCATEPAGESREQ const *pAllocReq); 388 392 GMMR3DECL(int) GMMR3DeflatedBalloon(PVM pVM, uint32_t cPages); 389 393 GMMR3DECL(int) GMMR3MapUnmapChunk(PVM pVM, uint32_t idChunkMap, uint32_t idChunkUnmap, PRTR3PTR ppvR3); -
trunk/src/VBox/VMM/GMM.cpp
r6836 r6839 65 65 /** 66 66 * Prepares a GMMR0AllocatePages request. 67 * 68 * @returns VINF_SUCCESS or VERR_NO_TMP_MEMORY. 69 * @param pVM Pointer to the shared VM structure. 70 * @param[out] ppReq Where to store the pointer to the request packet. 71 * @param cPages The number of pages that's to be allocated. 72 * @param enmAccount The account to charge. 67 73 */ 68 74 GMMR3DECL(int) GMMR3AllocatePagesPrepare(PVM pVM, PGMMALLOCATEPAGESREQ *ppReq, uint32_t cPages, GMMACCOUNT enmAccount) … … 130 136 131 137 132 #if 0 /* impractical */ 133 GMMR3DECL(int) GMMR3FreePages(PVM pVM, uint32_t cPages, PGMMFREEPAGEDESC paPages, GMMACCOUNT enmAccount) 134 { 135 GMMFREEPAGESREQ Req; 136 Req.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; 137 Req.Hdr.cbReq = sizeof(Req); 138 139 return SUPCallVMMR0Ex(pVM->pVMR0, VMMR0_DO_GMM_FREE_PAGES, 0, &Req.Hdr); 140 } 141 #endif 138 /** 139 * Prepares a GMMR0FreePages request. 140 * 141 * @returns VINF_SUCCESS or VERR_NO_TMP_MEMORY. 142 * @param pVM Pointer to the shared VM structure. 143 * @param[out] ppReq Where to store the pointer to the request packet. 144 * @param cPages The number of pages that's to be freed. 145 * @param enmAccount The account to charge. 146 */ 147 GMMR3DECL(int) GMMR3FreePagesPrepare(PVM pVM, PGMMFREEPAGESREQ *ppReq, uint32_t cPages, GMMACCOUNT enmAccount) 148 { 149 uint32_t cb = RT_OFFSETOF(GMMFREEPAGESREQ, aPages[cPages]); 150 PGMMFREEPAGESREQ pReq = (PGMMFREEPAGESREQ)RTMemTmpAllocZ(cb); 151 if (!pReq) 152 return VERR_NO_TMP_MEMORY; 153 154 pReq->Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; 155 pReq->Hdr.cbReq = cb; 156 pReq->enmAccount = enmAccount; 157 pReq->cPages = cPages; 158 NOREF(pVM); 159 return VINF_SUCCESS; 160 } 161 162 163 /** 164 * Performs a GMMR0FreePages request. 165 * This will call VMSetError on failure. 166 * 167 * @returns VBox status code. 168 * @param pVM Pointer to the shared VM structure. 169 * @param pReq Pointer to the request (returned by GMMR3FreePagesPrepare). 170 */ 171 GMMR3DECL(int) GMMR3FreePagesPerform(PVM pVM, PGMMFREEPAGESREQ pReq) 172 { 173 int rc = SUPCallVMMR0Ex(pVM->pVMR0, VMMR0_DO_GMM_FREE_PAGES, 0, &pReq->Hdr); 174 if (RT_SUCCESS(rc)) 175 return rc; 176 AssertRC(rc); 177 return VMSetError(pVM, rc, RT_SRC_POS, 178 N_("GMMR0FreePages failed to free %u pages"), 179 pReq->cPages); 180 } 181 182 183 /** 184 * Cleans up a GMMR0FreePages request. 185 * @param pReq Pointer to the request (returned by GMMR3FreePagesPrepare). 186 */ 187 GMMR3DECL(void) GMMR3FreePagesCleanup(PGMMFREEPAGESREQ pReq) 188 { 189 RTMemTmpFree(pReq); 190 } 191 192 193 /** 194 * Frees allocated pages, for bailing out on failure. 195 * 196 * This will not call VMSetError on failure but will use AssertLogRel instead. 197 * 198 * @param pVM Pointer to the shared VM structure. 199 * @param pAllocReq The allocation request to undo. 200 */ 201 GMMR3DECL(void) GMMR3FreeAllocatedPages(PVM pVM, GMMALLOCATEPAGESREQ const *pAllocReq) 202 { 203 uint32_t cb = RT_OFFSETOF(GMMFREEPAGESREQ, aPages[pAllocReq->cPages]); 204 PGMMFREEPAGESREQ pReq = (PGMMFREEPAGESREQ)RTMemTmpAllocZ(cb); 205 AssertLogRelReturnVoid(pReq); 206 207 pReq->Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; 208 pReq->Hdr.cbReq = cb; 209 pReq->enmAccount = pAllocReq->enmAccount; 210 pReq->cPages = pAllocReq->cPages; 211 uint32_t iPage = pAllocReq->cPages; 212 while (iPage-- > 0) 213 { 214 Assert(pAllocReq->aPages[iPage].idPage != NIL_GMM_PAGEID); 215 pReq->aPages[iPage].idPage = pAllocReq->aPages[iPage].idPage; 216 } 217 218 int rc = SUPCallVMMR0Ex(pVM->pVMR0, VMMR0_DO_GMM_FREE_PAGES, 0, &pReq->Hdr); 219 AssertLogRelRC(rc); 220 221 RTMemTmpFree(pReq); 222 } 142 223 143 224
Note:
See TracChangeset
for help on using the changeset viewer.

