VirtualBox

Ignore:
Timestamp:
Aug 14, 2007 1:29:43 AM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
23614
Message:

Use size_t for the page index. Added API for querying the ring-3 address.

File:
1 edited

Legend:

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

    r4049 r4135  
    5555    /** The core structure. */
    5656    RTR0MEMOBJINTERNAL  Core;
    57     /** The VM object associated with the allocation. */   
     57    /** The VM object associated with the allocation. */
    5858    vm_object_t         pObject;
    5959    /** the VM object associated with the mapping.
     
    8383            {
    8484                rc = vm_map_remove(kernel_map,
    85                                    (vm_offset_t)pMemFreeBSD->Core.pv, 
     85                                   (vm_offset_t)pMemFreeBSD->Core.pv,
    8686                                   (vm_offset_t)pMemFreeBSD->Core.pv + pMemFreeBSD->Core.cb);
    8787                AssertMsg(rc == KERN_SUCCESS, ("%#x", rc));
     
    9393            {
    9494                rc = vm_map_remove(kernel_map,
    95                                    (vm_offset_t)pMemFreeBSD->Core.pv, 
     95                                   (vm_offset_t)pMemFreeBSD->Core.pv,
    9696                                   (vm_offset_t)pMemFreeBSD->Core.pv + pMemFreeBSD->Core.cb);
    9797                AssertMsg(rc == KERN_SUCCESS, ("%#x", rc));
     
    103103                {
    104104                    rc = vm_map_remove(kernel_map,
    105                                        (vm_offset_t)pMemFreeBSD->Core.pv, 
     105                                       (vm_offset_t)pMemFreeBSD->Core.pv,
    106106                                       (vm_offset_t)pMemFreeBSD->Core.pv + pMemFreeBSD->Core.cb);
    107107                    AssertMsg(rc == KERN_SUCCESS, ("%#x", rc));
     
    115115            if (pMemFreeBSD->Core.u.Lock.R0Process != NIL_RTR0PROCESS)
    116116                pMap = &((struct proc *)pMemFreeBSD->Core.u.Lock.R0Process)->p_vmspace->vm_map;
    117             rc = vm_map_unwire(pMap, 
    118                                (vm_offset_t)pMemFreeBSD->Core.pv, 
    119                                (vm_offset_t)pMemFreeBSD->Core.pv + pMemFreeBSD->Core.cb, 
     117            rc = vm_map_unwire(pMap,
     118                               (vm_offset_t)pMemFreeBSD->Core.pv,
     119                               (vm_offset_t)pMemFreeBSD->Core.pv + pMemFreeBSD->Core.cb,
    120120                               VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES);
    121121            AssertMsg(rc == KERN_SUCCESS, ("%#x", rc));
     
    129129                pMap = &((struct proc *)pMemFreeBSD->Core.u.Lock.R0Process)->p_vmspace->vm_map;
    130130            rc = vm_map_remove(pMap,
    131                                (vm_offset_t)pMemFreeBSD->Core.pv, 
     131                               (vm_offset_t)pMemFreeBSD->Core.pv,
    132132                               (vm_offset_t)pMemFreeBSD->Core.pv + pMemFreeBSD->Core.cb);
    133133            AssertMsg(rc == KERN_SUCCESS, ("%#x", rc));
    134134            break;
    135135        }
    136        
     136
    137137        case RTR0MEMOBJTYPE_MAPPING:
    138138        {
    139139            /** @todo Figure out mapping... */
    140140        }
    141            
    142         /* unused: */   
     141
     142        /* unused: */
    143143        case RTR0MEMOBJTYPE_LOW:
    144144        case RTR0MEMOBJTYPE_PHYS:
     
    147147            return VERR_INTERNAL_ERROR;
    148148    }
    149    
     149
    150150    Assert(!pMemFreeBSD->pMappingObject);
    151151
     
    162162    if (!pMemFreeBSD)
    163163        return VERR_NO_MEMORY;
    164    
    165     /* 
    166      * We've two options here both expressed nicely by how kld allocates 
    167      * memory for the module bits: 
    168      *      http://fxr.watson.org/fxr/source/kern/link_elf.c?v=RELENG62#L701 
     164
     165    /*
     166     * We've two options here both expressed nicely by how kld allocates
     167     * memory for the module bits:
     168     *      http://fxr.watson.org/fxr/source/kern/link_elf.c?v=RELENG62#L701
    169169     */
    170170#if 0
     
    183183    {
    184184        vm_offset_t MapAddress = vm_map_min(kernel_map);
    185         rc = vm_map_find(kernel_map,                    /* map */ 
     185        rc = vm_map_find(kernel_map,                    /* map */
    186186                         pMemFreeBSD->pObject,          /* object */
    187187                         0,                             /* offset */
     
    206206                return VINF_SUCCESS;
    207207            }
    208            
     208
    209209           vm_map_remove(kernel_map,
    210210                         MapAddress,
     
    218218        rc = VERR_NO_MEMORY;
    219219#endif
    220    
     220
    221221    rtR0MemObjDelete(&pMemFreeBSD->Core);
    222222    return rc;
     
    228228    /*
    229229     * Try a Alloc first and see if we get luck, if not try contigmalloc.
    230      * Might wish to try find our own pages or something later if this 
    231      * turns into a problemspot on AMD64 boxes. 
     230     * Might wish to try find our own pages or something later if this
     231     * turns into a problemspot on AMD64 boxes.
    232232     */
    233233    int rc = rtR0MemObjNativeAllocPage(ppMem, cb, fExecutable);
     
    271271        return VINF_SUCCESS;
    272272    }
    273    
     273
    274274    NOREF(fExecutable);
    275275    rtR0MemObjDelete(&pMemFreeBSD->Core);
     
    281281{
    282282    /** @todo check if there is a more appropriate API somewhere.. */
    283    
     283
    284284    /* create the object. */
    285285    PRTR0MEMOBJFREEBSD pMemFreeBSD = (PRTR0MEMOBJFREEBSD)rtR0MemObjNew(sizeof(*pMemFreeBSD), RTR0MEMOBJTYPE_CONT, NULL, cb);
     
    301301        return VINF_SUCCESS;
    302302    }
    303    
     303
    304304    rtR0MemObjDelete(&pMemFreeBSD->Core);
    305305    return VERR_NO_MEMORY;
     
    330330    if (!pMemFreeBSD)
    331331        return VERR_NO_MEMORY;
    332    
    333     /*
    334      * We could've used vslock here, but we don't wish to be subject to 
     332
     333    /*
     334     * We could've used vslock here, but we don't wish to be subject to
    335335     * resource usage restrictions, so we'll call vm_map_wire directly.
    336336     */
    337     rc = vm_map_wire(&((struct proc *)R0Process)->p_vmspace->vm_map, /* the map */ 
     337    rc = vm_map_wire(&((struct proc *)R0Process)->p_vmspace->vm_map, /* the map */
    338338                     (vm_offset_t)pv,                               /* start */
    339339                     (vm_offset_t)pv + cb,                          /* end */
     
    360360
    361361    /* lock the memory */
    362     rc = vm_map_wire(kernel_map,                                    /* the map */ 
     362    rc = vm_map_wire(kernel_map,                                    /* the map */
    363363                     (vm_offset_t)pv,                               /* start */
    364364                     (vm_offset_t)pv + cb,                          /* end */
     
    377377/**
    378378 * Worker for the two virtual address space reservers.
    379  * 
     379 *
    380380 * We're leaning on the examples provided by mmap and vm_mmap in vm_mmap.c here.
    381381 */
     
    383383{
    384384    int rc;
    385    
    386     /* 
     385
     386    /*
    387387     * The pvFixed address range must be within the VM space when specified.
    388388     */
     
    391391            ||  (vm_offset_t)pvFixed + cb > vm_map_max(pMap)))
    392392        return VERR_INVALID_PARAMETER;
    393    
    394     /* 
    395      * Create the object. 
     393
     394    /*
     395     * Create the object.
    396396     */
    397397    PRTR0MEMOBJFREEBSD pMemFreeBSD = (PRTR0MEMOBJFREEBSD)rtR0MemObjNew(sizeof(*pMemFreeBSD), RTR0MEMOBJTYPE_RES_VIRT, NULL, cb);
     
    412412                          MapAddress,
    413413                          MapAddress + cb);
    414                                
    415         rc = vm_map_find(pMap,                          /* map */ 
     414
     415        rc = vm_map_find(pMap,                          /* map */
    416416                         pMemFreeBSD->pObject,          /* object */
    417417                         0,                             /* offset */
     
    425425        {
    426426            if (R0Process != NIL_RTR0PROCESS)
    427             {   
     427            {
    428428                rc = vm_map_inherit(pMap,
    429429                                    MapAddress,
     
    444444    rtR0MemObjDelete(&pMemFreeBSD->Core);
    445445    return rc;
    446    
     446
    447447}
    448448
     
    465465
    466466/* Phys: see pmap_mapdev in i386/i386/pmap.c (http://fxr.watson.org/fxr/source/i386/i386/pmap.c?v=RELENG62#L2860) */
    467    
     467
    468468#if 0
    469469/** @todo finish the implementation. */
     
    515515     * Create a dummy mapping object for it.
    516516     *
    517      * All mappings are read/write/execute in OS/2 and there isn't 
     517     * All mappings are read/write/execute in OS/2 and there isn't
    518518     * any cache options, so sharing is ok. And the main memory object
    519519     * isn't actually freed until all the mappings have been freed up
     
    569569            }
    570570            break;
    571 #endif 
     571#endif
    572572            return VERR_NOT_SUPPORTED;
    573573
     
    620620
    621621
    622 RTHCPHYS rtR0MemObjNativeGetPagePhysAddr(PRTR0MEMOBJINTERNAL pMem, unsigned iPage)
     622RTHCPHYS rtR0MemObjNativeGetPagePhysAddr(PRTR0MEMOBJINTERNAL pMem, size_t iPage)
    623623{
    624624    PRTR0MEMOBJFREEBSD pMemFreeBSD = (PRTR0MEMOBJFREEBSD)pMem;
     
    633633                /* later */
    634634                return NIL_RTHCPHYS;
    635             } 
     635            }
    636636        }
    637637        case RTR0MEMOBJTYPE_PAGE:
     
    640640            return vtophys(pb);
    641641        }
    642            
     642
    643643        case RTR0MEMOBJTYPE_CONT:
    644644            return pMemFreeBSD->Core.u.Cont.Phys + (iPage << PAGE_SHIFT);
Note: See TracChangeset for help on using the changeset viewer.

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