VirtualBox

Changeset 78120 in vbox for trunk/src/VBox/Runtime/r0drv


Ignore:
Timestamp:
Apr 12, 2019 1:20:50 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
130012
Message:

IPRT: Started adding a RTR0MemObjMapUserEx function that takes offSub and cbSub. bugref:9217

Location:
trunk/src/VBox/Runtime/r0drv
Files:
9 edited

Legend:

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

    r76553 r78120  
    893893    if (uAlignment > PAGE_SIZE)
    894894        return VERR_NOT_SUPPORTED;
     895    Assert(!offSub || cbSub);
    895896
    896897    IPRT_DARWIN_SAVE_EFL_AC();
     
    959960                         */
    960961                        PRTR0MEMOBJDARWIN pMemDarwin = (PRTR0MEMOBJDARWIN)rtR0MemObjNew(sizeof(*pMemDarwin), RTR0MEMOBJTYPE_MAPPING,
    961                                                                                         pv, cbSub);
     962                                                                                        pv, cbSub ? cbSub : pMemToMap->cb);
    962963                        if (pMemDarwin)
    963964                        {
     
    995996
    996997DECLHIDDEN(int) rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, RTR3PTR R3PtrFixed, size_t uAlignment,
    997                                         unsigned fProt, RTR0PROCESS R0Process)
     998                                        unsigned fProt, RTR0PROCESS R0Process, size_t offSub, size_t cbSub)
    998999{
    9991000    RT_NOREF(fProt);
     
    10051006    if (uAlignment > PAGE_SIZE)
    10061007        return VERR_NOT_SUPPORTED;
     1008    Assert(!offSub || cbSub);
    10071009
    10081010    IPRT_DARWIN_SAVE_EFL_AC();
     
    10191021                                                                              0,
    10201022                                                                              kIOMapAnywhere | kIOMapDefaultCache,
    1021                                                                               0 /* offset */,
    1022                                                                               0 /* length */);
     1023                                                                              offSub,
     1024                                                                              cbSub);
    10231025#else
    10241026        IOMemoryMap *pMemMap = pMemToMapDarwin->pMemDesc->map((task_t)R0Process,
    10251027                                                              0,
    1026                                                               kIOMapAnywhere | kIOMapDefaultCache);
     1028                                                              kIOMapAnywhere | kIOMapDefaultCache,
     1029                                                              offSub,
     1030                                                              cbSub);
    10271031#endif
    10281032        if (pMemMap)
     
    10361040                 */
    10371041                PRTR0MEMOBJDARWIN pMemDarwin = (PRTR0MEMOBJDARWIN)rtR0MemObjNew(sizeof(*pMemDarwin), RTR0MEMOBJTYPE_MAPPING,
    1038                                                                                 pv, pMemToMapDarwin->Core.cb);
     1042                                                                                pv, cbSub ? cbSub : pMemToMap->cb);
    10391043                if (pMemDarwin)
    10401044                {
  • trunk/src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c

    r77131 r78120  
    651651    if (uAlignment > PAGE_SIZE)
    652652        return VERR_NOT_SUPPORTED;
     653    Assert(!offSub || cbSub);
    653654
    654655    int                rc;
     
    711712
    712713DECLHIDDEN(int) rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, RTR3PTR R3PtrFixed, size_t uAlignment,
    713                                         unsigned fProt, RTR0PROCESS R0Process)
     714                                        unsigned fProt, RTR0PROCESS R0Process, size_t offSub, size_t cbSub)
    714715{
    715716    /*
     
    719720    if (uAlignment > PAGE_SIZE)
    720721        return VERR_NOT_SUPPORTED;
     722    Assert(!offSub || cbSub);
    721723
    722724    int                rc;
     
    748750        AddrR3 = (vm_offset_t)R3PtrFixed;
    749751
     752    if (cbSub == 0)
     753        cbSub = pMemToMap->cb - offSub;
     754
    750755    /* Insert the pObject in the map. */
    751756    vm_object_reference(pMemToMapFreeBSD->pObject);
    752757    rc = vm_map_find(pProcMap,              /* Map to insert the object in */
    753758                     pMemToMapFreeBSD->pObject, /* Object to map */
    754                      0,                     /* Start offset in the object */
     759                     offSub,                /* Start offset in the object */
    755760                     &AddrR3,               /* Start address IN/OUT */
    756                      pMemToMap->cb,         /* Size of the mapping */
     761                     cbSub,                 /* Size of the mapping */
    757762#if __FreeBSD_version >= 1000055
    758763                     0,                     /* Upper bound of the mapping */
  • trunk/src/VBox/Runtime/r0drv/haiku/memobj-r0drv-haiku.c

    r76553 r78120  
    478478
    479479int rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, RTR3PTR R3PtrFixed, size_t uAlignment,
    480                             unsigned fProt, RTR0PROCESS R0Process)
     480                            unsigned fProt, RTR0PROCESS R0Process, size_t offSub, size_t cbSub)
    481481{
    482482#if 0
     
    487487    AssertMsgReturn(R3PtrFixed == (RTR3PTR)-1, ("%p\n", R3PtrFixed), VERR_NOT_SUPPORTED);
    488488    if (uAlignment > PAGE_SIZE)
    489     return VERR_NOT_SUPPORTED;
     489        return VERR_NOT_SUPPORTED;
     490    AssertMsgReturn(!offSub && !cbSub, ("%#zx %#zx\n", offSub, cbSub), VERR_NOT_SUPPORTED); /** @todo implement sub maps */
    490491
    491492    int                rc;
  • trunk/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c

    r77730 r78120  
    15301530
    15311531
    1532 DECLHIDDEN(int) rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, RTR3PTR R3PtrFixed,
    1533                                         size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process)
     1532DECLHIDDEN(int) rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, RTR3PTR R3PtrFixed, size_t uAlignment,
     1533                                        unsigned fProt, RTR0PROCESS R0Process, size_t offSub, size_t cbSub)
    15341534{
    15351535    struct task_struct *pTask        = rtR0ProcessToLinuxTask(R0Process);
     
    15501550    if (uAlignment > PAGE_SIZE)
    15511551        return VERR_NOT_SUPPORTED;
     1552    AssertMsgReturn(!offSub && !cbSub, ("%#zx %#zx\n", offSub, cbSub), VERR_NOT_SUPPORTED); /** @todo implement sub maps */
    15521553
    15531554#ifdef VBOX_USE_PAE_HACK
  • trunk/src/VBox/Runtime/r0drv/memobj-r0drv.cpp

    r76553 r78120  
    730730                                   size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process, const char *pszTag)
    731731{
     732    return RTR0MemObjMapUserExTag(pMemObj, MemObjToMap, R3PtrFixed, uAlignment, fProt, R0Process, 0, 0, pszTag);
     733}
     734RT_EXPORT_SYMBOL(RTR0MemObjMapUserTag);
     735
     736
     737RTR0DECL(int) RTR0MemObjMapUserExTag(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, RTR3PTR R3PtrFixed, size_t uAlignment,
     738                                     unsigned fProt, RTR0PROCESS R0Process, size_t offSub, size_t cbSub, const char *pszTag)
     739{
    732740    /* sanity checks. */
    733741    PRTR0MEMOBJINTERNAL pMemToMap;
     
    749757    AssertReturn(fProt != RTMEM_PROT_NONE, VERR_INVALID_PARAMETER);
    750758    AssertReturn(!(fProt & ~(RTMEM_PROT_READ | RTMEM_PROT_WRITE | RTMEM_PROT_EXEC)), VERR_INVALID_PARAMETER);
     759    AssertReturn(!(offSub & PAGE_OFFSET_MASK), VERR_INVALID_PARAMETER);
     760    AssertReturn(offSub < pMemToMap->cb, VERR_INVALID_PARAMETER);
     761    AssertReturn(!(cbSub & PAGE_OFFSET_MASK), VERR_INVALID_PARAMETER);
     762    AssertReturn(cbSub <= pMemToMap->cb, VERR_INVALID_PARAMETER);
     763    AssertReturn((!offSub && !cbSub) || (offSub + cbSub) <= pMemToMap->cb, VERR_INVALID_PARAMETER);
    751764    if (R0Process == NIL_RTR0PROCESS)
    752765        R0Process = RTR0ProcHandleSelf();
     
    755768    RT_NOREF_PV(pszTag);
    756769
     770    /* adjust the request to simplify the native code. */
     771    if (offSub == 0 && cbSub == pMemToMap->cb)
     772        cbSub = 0;
     773
    757774    /* do the mapping. */
    758     rc = rtR0MemObjNativeMapUser(&pNew, pMemToMap, R3PtrFixed, uAlignment, fProt, R0Process);
     775    rc = rtR0MemObjNativeMapUser(&pNew, pMemToMap, R3PtrFixed, uAlignment, fProt, R0Process, offSub, cbSub);
    759776    if (RT_SUCCESS(rc))
    760777    {
     
    776793    return rc;
    777794}
    778 RT_EXPORT_SYMBOL(RTR0MemObjMapUserTag);
     795RT_EXPORT_SYMBOL(RTR0MemObjMapUserExTag);
    779796
    780797
  • trunk/src/VBox/Runtime/r0drv/netbsd/memobj-r0drv-netbsd.c

    r77120 r78120  
    499499
    500500DECLHIDDEN(int) rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, RTR3PTR R3PtrFixed, size_t uAlignment,
    501                                         unsigned fProt, RTR0PROCESS R0Process)
     501                                        unsigned fProt, RTR0PROCESS R0Process, size_t offSub, size_t cbSub)
    502502{
    503503    printf("NativeMapUser\n");
  • trunk/src/VBox/Runtime/r0drv/nt/memobj-r0drv-nt.cpp

    r76553 r78120  
    835835
    836836
    837 DECLHIDDEN(int) rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, RTR3PTR R3PtrFixed,
    838                                         size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process)
     837DECLHIDDEN(int) rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, RTR3PTR R3PtrFixed, size_t uAlignment,
     838                                        unsigned fProt, RTR0PROCESS R0Process, size_t offSub, size_t cbSub)
    839839{
    840840    AssertReturn(R0Process == RTR0ProcHandleSelf(), VERR_NOT_SUPPORTED);
     841    AssertMsgReturn(!offSub && !cbSub, ("%#zx %#zx\n", offSub, cbSub), VERR_NOT_SUPPORTED); /** @todo implement sub maps */
    841842    return rtR0MemObjNtMap(ppMem, pMemToMap, (void *)R3PtrFixed, uAlignment, fProt, R0Process);
    842843}
  • trunk/src/VBox/Runtime/r0drv/os2/memobj-r0drv-os2.cpp

    r77120 r78120  
    428428
    429429
    430 DECLHIDDEN(int) rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, RTR3PTR R3PtrFixed, size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process)
     430DECLHIDDEN(int) rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, RTR3PTR R3PtrFixed, size_t uAlignment,
     431                                        unsigned fProt, RTR0PROCESS R0Process, size_t offSub, size_t cbSub)
    431432{
    432433    AssertMsgReturn(R0Process == RTR0ProcHandleSelf(), ("%p != %p\n", R0Process, RTR0ProcHandleSelf()), VERR_NOT_SUPPORTED);
     
    434435    if (uAlignment > PAGE_SIZE)
    435436        return VERR_NOT_SUPPORTED;
     437    AssertMsgReturn(!offSub && !cbSub, ("%#zx %#zx\n", offSub, cbSub), VERR_NOT_SUPPORTED); /** @todo implement sub maps */
    436438
    437439    int rc;
  • trunk/src/VBox/Runtime/r0drv/solaris/memobj-r0drv-solaris.c

    r76553 r78120  
    10121012
    10131013DECLHIDDEN(int) rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, PRTR0MEMOBJINTERNAL pMemToMap, RTR3PTR R3PtrFixed,
    1014                                         size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process)
     1014                                        size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process, size_t offSub, size_t cbSub)
    10151015{
    10161016    /*
     
    10211021    if (uAlignment != PAGE_SIZE)
    10221022        return VERR_NOT_SUPPORTED;
     1023    AssertMsgReturn(!offSub && !cbSub, ("%#zx %#zx\n", offSub, cbSub), VERR_NOT_SUPPORTED); /** @todo implement sub maps */
    10231024
    10241025    /*
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