VirtualBox

Changeset 27009 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Mar 4, 2010 10:49:38 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
58318
Message:

r0drv/solaris/memobj-r0drv-solaris: fixed max PHYS address requirements and some cleanup.

File:
1 edited

Legend:

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

    r27003 r27009  
    4545#include "internal/memobj.h"
    4646
    47 
    4847/*******************************************************************************
    4948*   Structures and Typedefs                                                    *
     
    117116int rtR0MemObjNativeAllocPage(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable)
    118117{
    119     /* Create the object */
     118    /* Create the object. */
    120119    PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_PAGE, NULL, cb);
    121120    if (!pMemSolaris)
     
    146145
    147146    /* Allocate physically low page-aligned memory. */
    148     caddr_t virtAddr;
    149     uint64_t phys = (unsigned)0xffffffff;
    150     virtAddr = vbi_lowmem_alloc(phys, cb);
     147    uint64_t physAddr = _4G - 1;
     148    caddr_t virtAddr  = vbi_lowmem_alloc(physAddr, cb);
    151149    if (virtAddr == NULL)
    152150    {
     
    164162{
    165163    NOREF(fExecutable);
    166     return rtR0MemObjNativeAllocPhys(ppMem, cb, (uint64_t)0xffffffff /* highest address */, PAGE_SIZE /* alignment */);
     164    return rtR0MemObjNativeAllocPhys(ppMem, cb, NIL_RTHCPHYS, PAGE_SIZE /* alignment */);
    167165}
    168166
     
    176174
    177175    if (PhysHighest == NIL_RTHCPHYS)
    178         PhysHighest = (uint64_t)0xffffffff;
     176        PhysHighest = UINT64_MAX - 1;
    179177
    180178    /* Allocate physically non-contiguous page-aligned memory. */
    181     caddr_t virtAddr;
    182     uint64_t phys = PhysHighest;
    183     virtAddr = vbi_phys_alloc(&phys, cb, PAGE_SIZE, 0 /* non-contiguous */);
    184     if (virtAddr == NULL)
    185     {
    186         rtR0MemObjDelete(&pMemSolaris->Core);
    187         return VERR_NO_MEMORY;
    188     }
    189     Assert(phys < (uint64_t)1 << 32);
     179    uint64_t physAddr = PhysHighest;
     180    caddr_t virtAddr  = vbi_phys_alloc(&physAddr, cb, PAGE_SIZE, 0 /* non-contiguous */);
     181    if (RT_UNLIKELY(virtAddr == NULL))
     182    {
     183        rtR0MemObjDelete(&pMemSolaris->Core);
     184        return VERR_NO_MEMORY;
     185    }
     186    Assert(physAddr < UINT64_MAX);
    190187    pMemSolaris->Core.pv = virtAddr;
    191     pMemSolaris->Core.u.Phys.PhysBase = phys;
     188    pMemSolaris->Core.u.Phys.PhysBase = physAddr;
    192189    pMemSolaris->Core.u.Phys.fAllocated = true;
    193190    pMemSolaris->pvHandle = NULL;
     
    209206        return VERR_NOT_SUPPORTED;
    210207
    211     if (PhysHighest == NIL_RTHCPHYS)
    212         PhysHighest = (uint64_t)0xffffffff;
    213 
    214208     PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_CONT, NULL, cb);
    215209     if (!pMemSolaris)
    216210         return VERR_NO_MEMORY;
    217211
     212    if (PhysHighest == NIL_RTHCPHYS)
     213        PhysHighest = UINT64_MAX - 1;
     214
    218215     /* Allocate physically contiguous memory aligned as specified. */
    219      caddr_t virtAddr;
    220      uint64_t phys = PhysHighest;
    221      virtAddr = vbi_phys_alloc(&phys, cb, uAlignment, 1 /* contiguous */);
    222      if (virtAddr == NULL)
     216     uint64_t physAddr = PhysHighest;
     217     caddr_t  virtAddr = vbi_phys_alloc(&physAddr, cb, uAlignment, 1 /* contiguous */);
     218     if (RT_UNLIKELY(virtAddr == NULL))
    223219     {
    224220         rtR0MemObjDelete(&pMemSolaris->Core);
    225221         return VERR_NO_CONT_MEMORY;
    226222     }
    227      Assert(phys < (uint64_t)1 << 32);
     223     Assert(physAddr < UINT64_MAX);
    228224     pMemSolaris->Core.pv = virtAddr;
    229      pMemSolaris->Core.u.Cont.Phys = phys;
     225     pMemSolaris->Core.u.Cont.Phys = physAddr;
    230226     pMemSolaris->pvHandle = NULL;
    231227     *ppMem = &pMemSolaris->Core;
     
    236232int rtR0MemObjNativeEnterPhys(PPRTR0MEMOBJINTERNAL ppMem, RTHCPHYS Phys, size_t cb)
    237233{
    238     /* Create the object */
     234    /* Create the object. */
    239235    PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_PHYS, NULL, cb);
    240236    if (!pMemSolaris)
    241237        return VERR_NO_MEMORY;
    242238
    243     /* There is no allocation here, it needs to be mapped somewhere first */
     239    /* There is no allocation here, it needs to be mapped somewhere first. */
    244240    pMemSolaris->Core.u.Phys.fAllocated = false;
    245241    pMemSolaris->Core.u.Phys.PhysBase = Phys;
     
    318314    void               *pv;
    319315
     316    /* Create the object. */
     317    pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_RES_VIRT, pv, cb);
     318    if (!pMemSolaris)
     319        return VERR_NO_MEMORY;
     320
    320321    /*
    321322     * Use xalloc.
     
    323324    pv = vmem_xalloc(heap_arena, cb, uAlignment, 0 /*phase*/, 0 /*nocross*/,
    324325                     NULL /*minaddr*/, NULL /*maxaddr*/, VM_SLEEP);
    325     if (!pv)
    326         return VERR_NO_MEMORY;
    327     pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_RES_VIRT, pv, cb);
    328     if (!pMemSolaris)
    329     {
    330         vmem_xfree(heap_arena, pv, cb);
     326    if (RT_UNLIKELY(!pv))
     327    {
     328        rtR0MemObjDelete(&pMemSolaris->Core);
    331329        return VERR_NO_MEMORY;
    332330    }
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