Changeset 39744 in vbox for trunk/src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c
- Timestamp:
- Jan 10, 2012 6:15:04 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c
r39657 r39744 45 45 #include "internal/memobj.h" 46 46 47 47 48 /******************************************************************************* 48 49 * Structures and Typedefs * … … 62 63 MALLOC_DEFINE(M_IPRTMOBJ, "iprtmobj", "IPRT - R0MemObj"); 63 64 65 64 66 /** 65 67 * Gets the virtual memory map the specified object is mapped into. … … 112 114 case RTR0MEMOBJTYPE_LOW: 113 115 case RTR0MEMOBJTYPE_CONT: 114 {115 116 rc = vm_map_remove(kernel_map, 116 117 (vm_offset_t)pMemFreeBSD->Core.pv, … … 118 119 AssertMsg(rc == KERN_SUCCESS, ("%#x", rc)); 119 120 break; 120 }121 121 122 122 case RTR0MEMOBJTYPE_LOCK: … … 223 223 static int rtR0MemObjFreeBSDPhysAllocHelper(vm_object_t pObject, u_long cPages, 224 224 vm_paddr_t VmPhysAddrHigh, u_long uAlignment, 225 bool fContiguous, bool fWire )225 bool fContiguous, bool fWire, int rcNoMem) 226 226 { 227 227 if (fContiguous) … … 230 230 uAlignment, fWire) != NULL) 231 231 return VINF_SUCCESS; 232 else 233 return VERR_NO_MEMORY; 232 return rcNoMem; 234 233 } 235 234 … … 252 251 } 253 252 VM_OBJECT_UNLOCK(pObject); 254 return VERR_NO_MEMORY;253 return rcNoMem; 255 254 } 256 255 } … … 259 258 260 259 static int rtR0MemObjFreeBSDAllocHelper(PRTR0MEMOBJFREEBSD pMemFreeBSD, bool fExecutable, 261 vm_paddr_t VmPhysAddrHigh, bool fContiguous )260 vm_paddr_t VmPhysAddrHigh, bool fContiguous, int rcNoMem) 262 261 { 263 262 int rc; … … 275 274 { 276 275 rc = rtR0MemObjFreeBSDPhysAllocHelper(pMemFreeBSD->pObject, cPages, 277 VmPhysAddrHigh, PAGE_SIZE, fContiguous, false); 278 if (RT_SUCCESS(rc)) { 276 VmPhysAddrHigh, PAGE_SIZE, fContiguous, 277 false, rcNoMem); 278 if (RT_SUCCESS(rc)) 279 { 279 280 vm_map_wire(kernel_map, MapAddress, MapAddress + pMemFreeBSD->Core.cb, 280 281 VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES); … … 287 288 vm_map_remove(kernel_map, MapAddress, MapAddress + pMemFreeBSD->Core.cb); 288 289 } 289 rc = VERR_NO_MEMORY; /** @todo fix translation (borrow from darwin) */290 rc = rcNoMem; /** @todo fix translation (borrow from darwin) */ 290 291 291 292 vm_object_deallocate(pMemFreeBSD->pObject); … … 300 301 return VERR_NO_MEMORY; 301 302 302 int rc = rtR0MemObjFreeBSDAllocHelper(pMemFreeBSD, fExecutable, ~(vm_paddr_t)0, false );303 int rc = rtR0MemObjFreeBSDAllocHelper(pMemFreeBSD, fExecutable, ~(vm_paddr_t)0, false, VERR_NO_MEMORY); 303 304 if (RT_FAILURE(rc)) 304 305 { … … 319 320 return VERR_NO_MEMORY; 320 321 321 int rc = rtR0MemObjFreeBSDAllocHelper(pMemFreeBSD, fExecutable, _4G, false );322 int rc = rtR0MemObjFreeBSDAllocHelper(pMemFreeBSD, fExecutable, _4G, false, VERR_NO_LOW_MEMORY); 322 323 if (RT_FAILURE(rc)) 323 324 { … … 338 339 return VERR_NO_MEMORY; 339 340 340 int rc = rtR0MemObjFreeBSDAllocHelper(pMemFreeBSD, fExecutable, _4G, true );341 int rc = rtR0MemObjFreeBSDAllocHelper(pMemFreeBSD, fExecutable, _4G, true, VERR_NO_CONT_MEMORY); 341 342 if (RT_FAILURE(rc)) 342 343 { … … 354 355 size_t cb, 355 356 RTHCPHYS PhysHighest, size_t uAlignment, 356 bool fContiguous )357 bool fContiguous, int rcNoMem) 357 358 { 358 359 uint32_t cPages = atop(cb); … … 373 374 374 375 int rc = rtR0MemObjFreeBSDPhysAllocHelper(pMemFreeBSD->pObject, cPages, VmPhysAddrHigh, 375 uAlignment, fContiguous, true); 376 377 if (RT_FAILURE(rc)) { 378 vm_object_deallocate(pMemFreeBSD->pObject); 379 rtR0MemObjDelete(&pMemFreeBSD->Core); 380 } 381 else 376 uAlignment, fContiguous, true, rcNoMem); 377 if (RT_SUCCESS(rc)) 382 378 { 383 379 if (fContiguous) … … 392 388 *ppMem = &pMemFreeBSD->Core; 393 389 } 390 else 391 { 392 vm_object_deallocate(pMemFreeBSD->pObject); 393 rtR0MemObjDelete(&pMemFreeBSD->Core); 394 } 394 395 395 396 return rc; … … 399 400 DECLHIDDEN(int) rtR0MemObjNativeAllocPhys(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest, size_t uAlignment) 400 401 { 401 return rtR0MemObjFreeBSDAllocPhysPages(ppMem, RTR0MEMOBJTYPE_PHYS, cb, PhysHighest, uAlignment, true );402 return rtR0MemObjFreeBSDAllocPhysPages(ppMem, RTR0MEMOBJTYPE_PHYS, cb, PhysHighest, uAlignment, true, VERR_NO_MEMORY); 402 403 } 403 404 … … 405 406 DECLHIDDEN(int) rtR0MemObjNativeAllocPhysNC(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest) 406 407 { 407 return rtR0MemObjFreeBSDAllocPhysPages(ppMem, RTR0MEMOBJTYPE_PHYS_NC, cb, PhysHighest, PAGE_SIZE, false );408 return rtR0MemObjFreeBSDAllocPhysPages(ppMem, RTR0MEMOBJTYPE_PHYS_NC, cb, PhysHighest, PAGE_SIZE, false, VERR_NO_PHYS_MEMORY); 408 409 } 409 410 … … 497 498 * The pvFixed address range must be within the VM space when specified. 498 499 */ 499 if ( pvFixed != (void *)-1500 if ( pvFixed != (void *)-1 500 501 && ( (vm_offset_t)pvFixed < vm_map_min(pMap) 501 502 || (vm_offset_t)pvFixed + cb > vm_map_max(pMap)))
Note:
See TracChangeset
for help on using the changeset viewer.