VirtualBox

Ignore:
Timestamp:
Jan 10, 2012 6:15:04 PM (13 years ago)
Author:
vboxsync
Message:

rtr0memobj: Status code adjustments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c

    r39657 r39744  
    4545#include "internal/memobj.h"
    4646
     47
    4748/*******************************************************************************
    4849*   Structures and Typedefs                                                    *
     
    6263MALLOC_DEFINE(M_IPRTMOBJ, "iprtmobj", "IPRT - R0MemObj");
    6364
     65
    6466/**
    6567 * Gets the virtual memory map the specified object is mapped into.
     
    112114        case RTR0MEMOBJTYPE_LOW:
    113115        case RTR0MEMOBJTYPE_CONT:
    114         {
    115116            rc = vm_map_remove(kernel_map,
    116117                                (vm_offset_t)pMemFreeBSD->Core.pv,
     
    118119            AssertMsg(rc == KERN_SUCCESS, ("%#x", rc));
    119120            break;
    120         }
    121121
    122122        case RTR0MEMOBJTYPE_LOCK:
     
    223223static int rtR0MemObjFreeBSDPhysAllocHelper(vm_object_t pObject, u_long cPages,
    224224                                            vm_paddr_t VmPhysAddrHigh, u_long uAlignment,
    225                                             bool fContiguous, bool fWire)
     225                                            bool fContiguous, bool fWire, int rcNoMem)
    226226{
    227227    if (fContiguous)
     
    230230                                                   uAlignment, fWire) != NULL)
    231231            return VINF_SUCCESS;
    232         else
    233             return VERR_NO_MEMORY;
     232        return rcNoMem;
    234233    }
    235234
     
    252251            }
    253252            VM_OBJECT_UNLOCK(pObject);
    254             return VERR_NO_MEMORY;
     253            return rcNoMem;
    255254        }
    256255    }
     
    259258
    260259static int rtR0MemObjFreeBSDAllocHelper(PRTR0MEMOBJFREEBSD pMemFreeBSD, bool fExecutable,
    261                                         vm_paddr_t VmPhysAddrHigh, bool fContiguous)
     260                                        vm_paddr_t VmPhysAddrHigh, bool fContiguous, int rcNoMem)
    262261{
    263262    int rc;
     
    275274    {
    276275        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        {
    279280            vm_map_wire(kernel_map, MapAddress, MapAddress + pMemFreeBSD->Core.cb,
    280281                        VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES);
     
    287288        vm_map_remove(kernel_map, MapAddress, MapAddress + pMemFreeBSD->Core.cb);
    288289    }
    289     rc = VERR_NO_MEMORY; /** @todo fix translation (borrow from darwin) */
     290    rc = rcNoMem; /** @todo fix translation (borrow from darwin) */
    290291
    291292    vm_object_deallocate(pMemFreeBSD->pObject);
     
    300301        return VERR_NO_MEMORY;
    301302
    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);
    303304    if (RT_FAILURE(rc))
    304305    {
     
    319320        return VERR_NO_MEMORY;
    320321
    321     int rc = rtR0MemObjFreeBSDAllocHelper(pMemFreeBSD, fExecutable, _4G, false);
     322    int rc = rtR0MemObjFreeBSDAllocHelper(pMemFreeBSD, fExecutable, _4G, false, VERR_NO_LOW_MEMORY);
    322323    if (RT_FAILURE(rc))
    323324    {
     
    338339        return VERR_NO_MEMORY;
    339340
    340     int rc = rtR0MemObjFreeBSDAllocHelper(pMemFreeBSD, fExecutable, _4G, true);
     341    int rc = rtR0MemObjFreeBSDAllocHelper(pMemFreeBSD, fExecutable, _4G, true, VERR_NO_CONT_MEMORY);
    341342    if (RT_FAILURE(rc))
    342343    {
     
    354355                                           size_t cb,
    355356                                           RTHCPHYS PhysHighest, size_t uAlignment,
    356                                            bool fContiguous)
     357                                           bool fContiguous, int rcNoMem)
    357358{
    358359    uint32_t   cPages = atop(cb);
     
    373374
    374375    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))
    382378    {
    383379        if (fContiguous)
     
    392388        *ppMem = &pMemFreeBSD->Core;
    393389    }
     390    else
     391    {
     392        vm_object_deallocate(pMemFreeBSD->pObject);
     393        rtR0MemObjDelete(&pMemFreeBSD->Core);
     394    }
    394395
    395396    return rc;
     
    399400DECLHIDDEN(int) rtR0MemObjNativeAllocPhys(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest, size_t uAlignment)
    400401{
    401     return rtR0MemObjFreeBSDAllocPhysPages(ppMem, RTR0MEMOBJTYPE_PHYS, cb, PhysHighest, uAlignment, true);
     402    return rtR0MemObjFreeBSDAllocPhysPages(ppMem, RTR0MEMOBJTYPE_PHYS, cb, PhysHighest, uAlignment, true, VERR_NO_MEMORY);
    402403}
    403404
     
    405406DECLHIDDEN(int) rtR0MemObjNativeAllocPhysNC(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest)
    406407{
    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);
    408409}
    409410
     
    497498     * The pvFixed address range must be within the VM space when specified.
    498499     */
    499     if (pvFixed != (void *)-1
     500    if (   pvFixed != (void *)-1
    500501        && (    (vm_offset_t)pvFixed      < vm_map_min(pMap)
    501502            ||  (vm_offset_t)pvFixed + cb > vm_map_max(pMap)))
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette