VirtualBox

Changeset 14824 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Nov 30, 2008 7:52:59 AM (16 years ago)
Author:
vboxsync
Message:

IPRT: RTR0MemObjMapKernelEx for mapping a portion of a memory object into ring-0. Only implemented on darwin (where I had to switch back to use I/O kit to wire memory instead of vm_map_wire).

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/include/internal/memobj.h

    r8245 r14824  
    380380 *
    381381 * @returns IPRT status code.
     382 * @retval  VERR_NOT_SUPPORTED see RTR0MemObjMapKernelEx.
     383 *
    382384 * @param   ppMem           Where to store the ring-0 memory object handle of the mapping object.
    383385 * @param   pMemToMap       The object to be map.
     
    385387 * @param   uAlignment      The alignment of the reserved memory; PAGE_SIZE, _2M or _4M.
    386388 * @param   fProt           Combination of RTMEM_PROT_* flags (except RTMEM_PROT_NONE).
    387  */
    388 int rtR0MemObjNativeMapKernel(PPRTR0MEMOBJINTERNAL ppMem, PRTR0MEMOBJINTERNAL pMemToMap, void *pvFixed, size_t uAlignment, unsigned fProt);
     389 * @param   offSub          Where in the object to start mapping. If non-zero
     390 *                          the value must be page aligned and cbSub must be
     391 *                          non-zero as well.
     392 * @param   cbSub           The size of the part of the object to be mapped. If
     393 *                          zero the entire object is mapped. The value must be
     394 *                          page aligned.
     395 */
     396int rtR0MemObjNativeMapKernel(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, void *pvFixed, size_t uAlignment,
     397                              unsigned fProt, size_t offSub, size_t cbSub);
    389398
    390399/**
  • trunk/src/VBox/Runtime/r0drv/darwin/memobj-r0drv-darwin.cpp

    r13839 r14824  
    4444#include "internal/memobj.h"
    4545
    46 #define USE_VM_MAP_WIRE
     46/*#define USE_VM_MAP_WIRE - may re-enable later when non-mapped allocations are added. */
    4747
    4848
     
    542542
    543543
    544 int rtR0MemObjNativeMapKernel(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, void *pvFixed, size_t uAlignment, unsigned fProt)
     544int rtR0MemObjNativeMapKernel(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, void *pvFixed, size_t uAlignment,
     545                              unsigned fProt, size_t offSub, size_t cbSub)
    545546{
    546547    /*
     
    549550    int rc = VERR_INVALID_PARAMETER;
    550551    PRTR0MEMOBJDARWIN pMemToMapDarwin = (PRTR0MEMOBJDARWIN)pMemToMap;
     552printf("rtR0MemObjNativeMapKernel: pMemDesc=%p\n", pMemToMapDarwin->pMemDesc);
    551553    if (pMemToMapDarwin->pMemDesc)
    552554    {
    553555        IOMemoryMap *pMemMap = pMemToMapDarwin->pMemDesc->map(kernel_task, kIOMapAnywhere,
    554                                                               kIOMapAnywhere | kIOMapDefaultCache);
     556                                                              kIOMapAnywhere | kIOMapDefaultCache,
     557                                                              offSub, cbSub);
    555558        if (pMemMap)
    556559        {
  • trunk/src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c

    r8245 r14824  
    468468
    469469
    470 int rtR0MemObjNativeMapKernel(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, void *pvFixed, size_t uAlignment, unsigned fProt)
    471 {
     470int rtR0MemObjNativeMapKernel(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, void *pvFixed, size_t uAlignment,
     471                              unsigned fProt, size_t offSub, size_t cbSub)
     472{
     473    AssertMsgReturn(!offSub && !cbSub, ("%#x %#x\n", offSub, cbSub), VERR_NOT_SUPPORTED);
    472474    AssertMsgReturn(pvFixed == (void *)-1, ("%p\n", pvFixed), VERR_NOT_SUPPORTED);
    473475
  • trunk/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c

    r13994 r14824  
    940940
    941941
    942 int rtR0MemObjNativeMapKernel(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, void *pvFixed, size_t uAlignment, unsigned fProt)
     942int rtR0MemObjNativeMapKernel(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, void *pvFixed, size_t uAlignment,
     943                              unsigned fProt, size_t offSub, size_t cbSub)
    943944{
    944945    int rc = VERR_NO_MEMORY;
     
    947948
    948949    /* Fail if requested to do something we can't. */
     950    AssertMsgReturn(!offSub && !cbSub, ("%#x %#x\n", offSub, cbSub), VERR_NOT_SUPPORTED);
    949951    AssertMsgReturn(pvFixed == (void *)-1, ("%p\n", pvFixed), VERR_NOT_SUPPORTED);
    950952    AssertMsgReturn(uAlignment <= PAGE_SIZE, ("%#x\n", uAlignment), VERR_NOT_SUPPORTED);
  • trunk/src/VBox/Runtime/r0drv/memobj-r0drv.cpp

    r14518 r14824  
    670670RTR0DECL(int) RTR0MemObjMapKernel(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, void *pvFixed, size_t uAlignment, unsigned fProt)
    671671{
     672    return RTR0MemObjMapKernelEx(pMemObj, MemObjToMap, pvFixed, uAlignment, fProt, 0, 0);
     673}
     674
     675
     676/**
     677 * Maps a memory object into kernel virtual address space.
     678 *
     679 * The ability to map subsections of the object into kernel space is currently
     680 * not implemented on all platforms. All/Most of platforms supports mapping the
     681 * whole object into  kernel space.
     682 *
     683 * @returns IPRT status code.
     684 * @retval  VERR_NOT_SUPPORTED if it's not possible to map a subsection of a
     685 *          memory object on this platform. When you hit this, try implement it.
     686 *
     687 * @param   pMemObj         Where to store the ring-0 memory object handle of the mapping object.
     688 * @param   MemObjToMap     The object to be map.
     689 * @param   pvFixed         Requested address. (void *)-1 means any address. This must match the alignment.
     690 * @param   uAlignment      The alignment of the reserved memory.
     691 *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
     692 * @param   fProt           Combination of RTMEM_PROT_* flags (except RTMEM_PROT_NONE).
     693 * @param   offSub          Where in the object to start mapping. If non-zero
     694 *                          the value must be page aligned and cbSub must be
     695 *                          non-zero as well.
     696 * @param   cbSub           The size of the part of the object to be mapped. If
     697 *                          zero the entire object is mapped. The value must be
     698 *                          page aligned.
     699 */
     700RTR0DECL(int) RTR0MemObjMapKernelEx(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, void *pvFixed, size_t uAlignment,
     701                                    unsigned fProt, size_t offSub, size_t cbSub)
     702{
    672703    PRTR0MEMOBJINTERNAL pMemToMap;
    673704    PRTR0MEMOBJINTERNAL pNew;
     
    690721    AssertReturn(fProt != RTMEM_PROT_NONE, VERR_INVALID_PARAMETER);
    691722    AssertReturn(!(fProt & ~(RTMEM_PROT_READ | RTMEM_PROT_WRITE | RTMEM_PROT_EXEC)), VERR_INVALID_PARAMETER);
    692 
     723    AssertReturn(!(offSub & PAGE_OFFSET_MASK), VERR_INVALID_PARAMETER);
     724    AssertReturn(offSub < pMemToMap->cb, VERR_INVALID_PARAMETER);
     725    AssertReturn(!(cbSub & PAGE_OFFSET_MASK), VERR_INVALID_PARAMETER);
     726    AssertReturn(cbSub <= pMemToMap->cb, VERR_INVALID_PARAMETER);
     727    AssertReturn((!offSub && !cbSub) || (offSub + cbSub) <= pMemToMap->cb, VERR_INVALID_PARAMETER);
     728
     729    /* adjust the request to simplify the native code. */
     730    if (offSub == 0 && cbSub == pMemToMap->cb)
     731        cbSub = 0;
    693732
    694733    /* do the mapping. */
    695     rc = rtR0MemObjNativeMapKernel(&pNew, pMemToMap, pvFixed, uAlignment, fProt);
     734    rc = rtR0MemObjNativeMapKernel(&pNew, pMemToMap, pvFixed, uAlignment, fProt, offSub, cbSub);
    696735    if (RT_SUCCESS(rc))
    697736    {
  • trunk/src/VBox/Runtime/r0drv/nt/memobj-r0drv-nt.cpp

    r8245 r14824  
    746746
    747747
    748 int rtR0MemObjNativeMapKernel(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, void *pvFixed, size_t uAlignment, unsigned fProt)
    749 {
     748int rtR0MemObjNativeMapKernel(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, void *pvFixed, size_t uAlignment,
     749                              unsigned fProt, size_t offSub, size_t cbSub)
     750{
     751    AssertMsgReturn(!offSub && !cbSub, ("%#x %#x\n", offSub, cbSub), VERR_NOT_SUPPORTED);
    750752    return rtR0MemObjNtMap(ppMem, pMemToMap, pvFixed, uAlignment, fProt, NIL_RTR0PROCESS);
    751753}
  • trunk/src/VBox/Runtime/r0drv/os2/memobj-r0drv-os2.cpp

    r13839 r14824  
    304304
    305305
    306 int rtR0MemObjNativeMapKernel(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, void *pvFixed, size_t uAlignment, unsigned fProt)
    307 {
     306int rtR0MemObjNativeMapKernel(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, void *pvFixed, size_t uAlignment,
     307                              unsigned fProt, size_t offSub, size_t cbSub)
     308{
     309    AssertMsgReturn(!offSub && !cbSub, ("%#x %#x\n", offSub, cbSub), VERR_NOT_SUPPORTED);
    308310    AssertMsgReturn(pvFixed == (void *)-1, ("%p\n", pvFixed), VERR_NOT_SUPPORTED);
    309311
  • trunk/src/VBox/Runtime/r0drv/solaris/memobj-r0drv-solaris.c

    r13839 r14824  
    320320}
    321321
    322 int rtR0MemObjNativeMapKernel(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, void *pvFixed, size_t uAlignment, unsigned fProt)
     322int rtR0MemObjNativeMapKernel(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, void *pvFixed, size_t uAlignment,
     323                              unsigned fProt, size_t offSub, size_t cbSub)
    323324{
    324325    /* @todo rtR0MemObjNativeMapKernel / Solaris - Should be fairly simple alloc kernel memory and memload it. */
  • trunk/src/VBox/Runtime/r0drv/solaris/vbi/memobj-r0drv-solaris.c

    r13839 r14824  
    254254}
    255255
    256 int rtR0MemObjNativeMapKernel(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, void *pvFixed, size_t uAlignment, unsigned fProt)
     256int rtR0MemObjNativeMapKernel(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, void *pvFixed, size_t uAlignment,
     257                              unsigned fProt, size_t offSub, size_t cbSub)
    257258{
    258259    /* @todo rtR0MemObjNativeMapKernel / Solaris - Should be fairly simple alloc kernel memory and memload it. */
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