VirtualBox

Changeset 26430 in vbox


Ignore:
Timestamp:
Feb 11, 2010 2:23:01 PM (15 years ago)
Author:
vboxsync
Message:

Introducing RTR0MemObjAllocPhysEx

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/memobj.h

    r23610 r26430  
    191191
    192192/**
     193 * Allocates contiguous page aligned physical memory without (necessarily) any kernel mapping.
     194 *
     195 * @returns IPRT status code.
     196 * @param   pMemObj         Where to store the ring-0 memory object handle.
     197 * @param   cb              Number of bytes to allocate. This is rounded up to nearest page.
     198 * @param   PhysHighest     The highest permittable address (inclusive).
     199 *                          Pass NIL_RTHCPHYS if any address is acceptable.
     200 * @param   uAlignment      The alignment of the reserved memory.
     201 *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M, _4M and _1G.
     202 */
     203RTR0DECL(int) RTR0MemObjAllocPhysEx(PRTR0MEMOBJ pMemObj, size_t cb, RTHCPHYS PhysHighest, size_t uAlignment);
     204
     205/**
    193206 * Allocates non-contiguous page aligned physical memory without (necessarily) any kernel mapping.
    194207 *
  • trunk/src/VBox/HostDrivers/Support/SUPDrv.c

    r25744 r26430  
    191191    { "RTR0MemObjAllocPage",                    (void *)RTR0MemObjAllocPage },
    192192    { "RTR0MemObjAllocPhys",                    (void *)RTR0MemObjAllocPhys },
     193    { "RTR0MemObjAllocPhysEx",                  (void *)RTR0MemObjAllocPhysEx },
    193194    { "RTR0MemObjAllocPhysNC",                  (void *)RTR0MemObjAllocPhysNC },
    194195    { "RTR0MemObjAllocCont",                    (void *)RTR0MemObjAllocCont },
  • trunk/src/VBox/HostDrivers/Support/SUPDrvIOC.h

    r25528 r26430  
    197197 *          - Nothing.
    198198 */
    199 #define SUPDRV_IOC_VERSION                              0x00140000
     199#define SUPDRV_IOC_VERSION                              0x00140001
    200200
    201201/** SUP_IOCTL_COOKIE. */
  • trunk/src/VBox/HostDrivers/Support/SUPLib.cpp

    r25528 r26430  
    273273        CookieReq.u.In.u32ReqVersion = SUPDRV_IOC_VERSION;
    274274        const uint32_t uMinVersion = (SUPDRV_IOC_VERSION & 0xffff0000) == 0x00140000
    275                                    ?  0x00140000
     275                                   ?  0x00140001
    276276                                   :  SUPDRV_IOC_VERSION & 0xffff0000;
    277277        CookieReq.u.In.u32MinVersion = uMinVersion;
  • trunk/src/VBox/Runtime/r0drv/darwin/memobj-r0drv-darwin.cpp

    r23610 r26430  
    568568
    569569
    570 int rtR0MemObjNativeAllocPhys(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest)
    571 {
     570int rtR0MemObjNativeAllocPhys(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest, size_t uAlignment)
     571{
     572    /** @todo */
     573    if (    uAlignment != 0
     574        &&  uAlignment != PAGE_SIZE)
     575        return VERR_NOT_SUPPORTED;
     576
    572577    /*
    573578     * Translate the PhysHighest address into a mask.
  • trunk/src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c

    r23610 r26430  
    327327
    328328
    329 int rtR0MemObjNativeAllocPhys(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest)
     329int rtR0MemObjNativeAllocPhys(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest, size_t uAlignment)
    330330{
    331331    /** @todo check if there is a more appropriate API somewhere.. */
     332
     333    /** @todo */
     334    if (    uAlignment != 0
     335        &&  uAlignment != PAGE_SIZE)
     336        return VERR_NOT_SUPPORTED;
    332337
    333338    /* create the object. */
  • trunk/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c

    r23611 r26430  
    700700
    701701
    702 int rtR0MemObjNativeAllocPhys(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest)
    703 {
     702int rtR0MemObjNativeAllocPhys(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest, size_t uAlignment)
     703{
     704    /* @todo */
     705    if (    uAlignment != 0
     706        &&  uAlignment != PAGE_SIZE)
     707        return VERR_NOT_SUPPORTED;
     708
    704709    return rtR0MemObjLinuxAllocPhysSub(ppMem, RTR0MEMOBJTYPE_PHYS, cb, PhysHighest);
    705710}
  • trunk/src/VBox/Runtime/r0drv/memobj-r0drv.cpp

    r23610 r26430  
    583583
    584584    /* do the allocation. */
    585     return rtR0MemObjNativeAllocPhys(pMemObj, cbAligned, PhysHighest);
     585    return rtR0MemObjNativeAllocPhys(pMemObj, cbAligned, PhysHighest, PAGE_SIZE /* page aligned */);
    586586}
    587587RT_EXPORT_SYMBOL(RTR0MemObjAllocPhys);
     588
     589/**
     590 * Allocates contiguous page aligned physical memory without (necessarily) any kernel mapping.
     591 *
     592 * @returns IPRT status code.
     593 * @param   pMemObj         Where to store the ring-0 memory object handle.
     594 * @param   cb              Number of bytes to allocate. This is rounded up to nearest page.
     595 * @param   PhysHighest     The highest permittable address (inclusive).
     596 *                          Pass NIL_RTHCPHYS if any address is acceptable.
     597 * @param   uAlignment      The alignment of the physical memory to allocate.
     598 *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M, _4M and _1G.
     599 */
     600RTR0DECL(int) RTR0MemObjAllocPhysEx(PRTR0MEMOBJ pMemObj, size_t cb, RTHCPHYS PhysHighest, size_t uAlignment)
     601{
     602    /* sanity checks. */
     603    const size_t cbAligned = RT_ALIGN_Z(cb, PAGE_SIZE);
     604    AssertPtrReturn(pMemObj, VERR_INVALID_POINTER);
     605    *pMemObj = NIL_RTR0MEMOBJ;
     606    AssertReturn(cb > 0, VERR_INVALID_PARAMETER);
     607    AssertReturn(cb <= cbAligned, VERR_INVALID_PARAMETER);
     608    AssertReturn(PhysHighest >= cb, VERR_INVALID_PARAMETER);
     609    AssertReturn((    uAlignment == 0
     610                  ||  uAlignment == PAGE_SIZE
     611                  ||  uAlignment == _2M
     612                  ||  uAlignment == _4M
     613                  ||  uAlignment == _1G), VERR_INVALID_PARAMETER);
     614    RT_ASSERT_PREEMPTIBLE();
     615
     616    /* do the allocation. */
     617    return rtR0MemObjNativeAllocPhys(pMemObj, cbAligned, PhysHighest, uAlignment);
     618}
     619RT_EXPORT_SYMBOL(RTR0MemObjAllocPhysEx);
    588620
    589621
  • trunk/src/VBox/Runtime/r0drv/nt/memobj-r0drv-nt.cpp

    r23610 r26430  
    337337 * @param   fExecutable     Whether the mapping should be executable or not.
    338338 * @param   PhysHighest     The highest physical address for the pages in allocation.
     339 * @param   uAlignment      The alignment of the physical memory to allocate.
     340 *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M, _4M and _1G.
    339341 */
    340 static int rtR0MemObjNativeAllocContEx(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable, RTHCPHYS PhysHighest)
     342static int rtR0MemObjNativeAllocContEx(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable, RTHCPHYS PhysHighest, size_t uAlignment)
    341343{
    342344    AssertMsgReturn(cb <= _1G, ("%#x\n", cb), VERR_OUT_OF_RANGE); /* for safe size_t -> ULONG */
     345
     346    /* @todo */
     347    if (    uAlignment != 0
     348        &&  uAlignment != PAGE_SIZE)
     349        return VERR_NOT_SUPPORTED;
    343350
    344351    /*
     
    378385int rtR0MemObjNativeAllocCont(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable)
    379386{
    380     return rtR0MemObjNativeAllocContEx(ppMem, cb, fExecutable, _4G-1);
    381 }
    382 
    383 
    384 int rtR0MemObjNativeAllocPhys(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest)
     387    return rtR0MemObjNativeAllocContEx(ppMem, cb, fExecutable, _4G-1, PAGE_SIZE /* alignment */);
     388}
     389
     390
     391int rtR0MemObjNativeAllocPhys(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest, size_t uAlignment)
    385392{
    386393#ifndef IPRT_TARGET_NT4
     
    436443#endif /* !IPRT_TARGET_NT4 */
    437444
    438     return rtR0MemObjNativeAllocContEx(ppMem, cb, false, PhysHighest);
     445    return rtR0MemObjNativeAllocContEx(ppMem, cb, false, PhysHighest, uAlignment);
    439446}
    440447
  • trunk/src/VBox/Runtime/r0drv/os2/memobj-r0drv-os2.cpp

    r23610 r26430  
    195195
    196196
    197 int rtR0MemObjNativeAllocPhys(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest)
     197int rtR0MemObjNativeAllocPhys(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest, size_t uAlignment)
    198198{
    199199    AssertMsgReturn(PhysHighest >= 16 *_1M, ("PhysHigest=%RHp\n", PhysHighest), VERR_NOT_IMPLEMENTED);
     200
     201    /** @todo */
     202    if (    uAlignment != 0
     203        &&  uAlignment != PAGE_SIZE)
     204        return VERR_NOT_SUPPORTED;
    200205
    201206    /* create the object. */
  • trunk/src/VBox/Runtime/r0drv/solaris/vbi/memobj-r0drv-solaris.c

    r24426 r26430  
    192192
    193193
    194 int rtR0MemObjNativeAllocPhys(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest)
     194int rtR0MemObjNativeAllocPhys(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest, size_t uAlignment)
    195195{
    196196    AssertMsgReturn(PhysHighest >= 16 *_1M, ("PhysHigest=%RHp\n", PhysHighest), VERR_NOT_IMPLEMENTED);
     197
     198    /** @todo */
     199    if (    uAlignment != 0
     200        &&  uAlignment != PAGE_SIZE)
     201        return VERR_NOT_SUPPORTED;
    197202
    198203    return rtR0MemObjNativeAllocCont(ppMem, cb, false);
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