VirtualBox

Changeset 27037 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 4, 2010 2:43:59 PM (15 years ago)
Author:
vboxsync
Message:

r0drv/solaris/memobj-r0drv-solaris: some cleanup.

File:
1 edited

Legend:

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

    r27009 r27037  
    312312{
    313313    PRTR0MEMOBJSOLARIS  pMemSolaris;
    314     void               *pv;
    315 
    316     /* Create the object. */
    317     pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_RES_VIRT, pv, cb);
    318     if (!pMemSolaris)
    319         return VERR_NO_MEMORY;
    320314
    321315    /*
    322316     * Use xalloc.
    323317     */
    324     pv = vmem_xalloc(heap_arena, cb, uAlignment, 0 /*phase*/, 0 /*nocross*/,
     318    void *pv = vmem_xalloc(heap_arena, cb, uAlignment, 0 /*phase*/, 0 /*nocross*/,
    325319                     NULL /*minaddr*/, NULL /*maxaddr*/, VM_SLEEP);
    326320    if (RT_UNLIKELY(!pv))
    327     {
    328         rtR0MemObjDelete(&pMemSolaris->Core);
     321        return VERR_NO_MEMORY;
     322
     323    /* Create the object. */
     324    pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_RES_VIRT, pv, cb);
     325    if (!pMemSolaris)
     326    {
     327        LogRel(("rtR0MemObjNativeReserveKernel failed to alloc memory object.\n"));
     328        vmem_xfree(heap_arena, pv, cb);
    329329        return VERR_NO_MEMORY;
    330330    }
     
    357357
    358358    PRTR0MEMOBJSOLARIS pMemToMapSolaris = (PRTR0MEMOBJSOLARIS)pMemToMap;
    359     size_t size = pMemToMapSolaris->Core.cb;
    360     void *pv = pMemToMapSolaris->Core.pv;
    361     pgcnt_t cPages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
    362     pgcnt_t iPage;
    363     uint64_t *paddrs;
    364     caddr_t addr;
    365     int rc;
     359    size_t cb        = pMemToMapSolaris->Core.cb;
     360    void *pv         = pMemToMapSolaris->Core.pv;
     361    pgcnt_t cPages   = (cb + PAGE_SIZE - 1) >> PAGE_SHIFT;
    366362
    367363    /* Create the mapping object */
    368     PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_MAPPING, pv, size);
    369     if (!pMemSolaris)
    370         return VERR_NO_MEMORY;
    371 
    372     paddrs = kmem_zalloc(sizeof(uint64_t) * cPages, KM_SLEEP);
    373     for (iPage = 0; iPage < cPages; iPage++)
    374     {
    375         paddrs[iPage] = vbi_va_to_pa(pv);
    376         if (paddrs[iPage] == -(uint64_t)1)
     364    PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_MAPPING, pv, cb);
     365    if (!pMemSolaris)
     366        return VERR_NO_MEMORY;
     367
     368    uint64_t *paPhysAddrs = kmem_zalloc(sizeof(uint64_t) * cPages, KM_SLEEP);
     369    for (pgcnt_t iPage = 0; iPage < cPages; iPage++)
     370    {
     371        paPhysAddrs[iPage] = vbi_va_to_pa(pv);
     372        if (RT_UNLIKELY(paPhysAddrs[iPage] == -(uint64_t)1))
    377373        {
    378374            LogRel(("rtR0MemObjNativeMapUser: no page to map.\n"));
    379             kmem_free(paddrs, sizeof(uint64_t) * cPages);
     375            kmem_free(paPhysAddrs, sizeof(uint64_t) * cPages);
    380376            rtR0MemObjDelete(&pMemSolaris->Core);
    381377            return VERR_MAP_FAILED;
     
    384380    }
    385381
    386     rc = vbi_user_map(&addr, fProt, paddrs, size);
     382    caddr_t virtAddr = NULL;
     383    int rc = vbi_user_map(&virtAddr, fProt, paPhysAddrs, cb);
    387384    if (rc != 0)
    388385    {
    389386        LogRel(("rtR0MemObjNativeMapUser: vbi mapping failure.\n"));
    390         kmem_free(paddrs, sizeof(uint64_t) * cPages);
     387        kmem_free(paPhysAddrs, sizeof(uint64_t) * cPages);
    391388        rtR0MemObjDelete(&pMemSolaris->Core);
    392389        return VERR_MAP_FAILED;
     
    396393
    397394    pMemSolaris->Core.u.Mapping.R0Process = (RTR0PROCESS)vbi_proc();
    398     pMemSolaris->Core.pv = addr;
    399     *ppMem = &pMemSolaris->Core;
    400     kmem_free(paddrs, sizeof(uint64_t) * cPages);
     395    pMemSolaris->Core.pv = virtAddr;
     396    *ppMem = &pMemSolaris->Core;
     397    kmem_free(paPhysAddrs, sizeof(uint64_t) * cPages);
    401398    return rc;
    402399}
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