VirtualBox

Changeset 218 in vbox


Ignore:
Timestamp:
Jan 22, 2007 12:35:39 AM (18 years ago)
Author:
vboxsync
Message:

An attempt at locking which doesn't seem to work very well..

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/darwin/memobj-r0drv-darwin.cpp

    r217 r218  
    6161    if (pMemDarwin->pMemDesc)
    6262    {
     63        if (pMemDarwin->Core.enmType == RTR0MEMOBJTYPE_LOCK)
     64            pMemDarwin->pMemDesc->complete();
    6365        pMemDarwin->pMemDesc->release();
    6466        pMemDarwin->pMemDesc = NULL;
     
    8890
    8991        case RTR0MEMOBJTYPE_LOCK:
    90             AssertMsgFailed(("RTR0MEMOBJTYPE_LOCK\n"));
    91             return VERR_INTERNAL_ERROR;
    9292            break;
    9393
     
    332332int rtR0MemObjNativeLockUser(PPRTR0MEMOBJINTERNAL ppMem, void *pv, size_t cb)
    333333{
    334     return VERR_NOT_IMPLEMENTED;
     334    Assert(current_task() != kernel_task);
     335    int rc = VERR_MEMOBJ_INIT_FAILED;
     336    IOMemoryDescriptor *pMemDesc = IOMemoryDescriptor::withAddress((vm_address_t)pv, cb, kIODirectionInOut, current_task());
     337    if (pMemDesc)
     338    {
     339        IOReturn IORet = pMemDesc->prepare(kIODirectionInOut);
     340        if (IORet == kIOReturnSuccess)
     341        {
     342            /*
     343             * Create the IPRT memory object.
     344             */
     345            PRTR0MEMOBJDARWIN pMemDarwin = (PRTR0MEMOBJDARWIN)rtR0MemObjNew(sizeof(*pMemDarwin), RTR0MEMOBJTYPE_LOCK, pv, cb);
     346            if (pMemDarwin)
     347            {
     348                pMemDarwin->Core.u.Lock.Process = (RTPROCESS)current_task();
     349                pMemDarwin->pMemDesc = pMemDesc;
     350                *ppMem = &pMemDarwin->Core;
     351                return VINF_SUCCESS;
     352            }
     353
     354            pMemDesc->complete();
     355            rc = VERR_NO_MEMORY;
     356        }
     357        else
     358            rc = VERR_LOCK_FAILED;
     359        pMemDesc->release();
     360    }
     361    return rc;
    335362}
    336363
     
    338365int rtR0MemObjNativeLockKernel(PPRTR0MEMOBJINTERNAL ppMem, void *pv, size_t cb)
    339366{
    340     return VERR_NOT_IMPLEMENTED;
     367    int rc = VERR_MEMOBJ_INIT_FAILED;
     368    IOMemoryDescriptor *pMemDesc = IOMemoryDescriptor::withAddress((vm_address_t)pv, cb, kIODirectionInOut, kernel_task);
     369    if (pMemDesc)
     370    {
     371        IOReturn IORet = pMemDesc->prepare(kIODirectionInOut);
     372        if (IORet == kIOReturnSuccess)
     373        {
     374            /*
     375             * Create the IPRT memory object.
     376             */
     377            PRTR0MEMOBJDARWIN pMemDarwin = (PRTR0MEMOBJDARWIN)rtR0MemObjNew(sizeof(*pMemDarwin), RTR0MEMOBJTYPE_LOCK, pv, cb);
     378            if (pMemDarwin)
     379            {
     380                pMemDarwin->Core.u.Lock.Process = NIL_RTPROCESS;
     381                pMemDarwin->pMemDesc = pMemDesc;
     382                *ppMem = &pMemDarwin->Core;
     383                return VINF_SUCCESS;
     384            }
     385
     386            pMemDesc->complete();
     387            rc = VERR_NO_MEMORY;
     388        }
     389        else
     390            rc = VERR_LOCK_FAILED;
     391        pMemDesc->release();
     392    }
     393    return rc;
    341394}
    342395
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