Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Mapping a memory region into process memory space

IMemSpace maps a memory region into the memory space of a process. If the region to be mapped is in the same process, the start address of the mapped region returned from MapRegion is the same as the starting virtual address of the region. If the region to be mapped is in a different process, the start address of the mapped region returned from MapRegion may be different than the starting virtual address of the region, with the latter being the address from the remote process. The virtual addresses of all processes are the same when all processes share the same virtual address space.

interface IMemSpace: IQI
{
   /*
   * Creates an IMemMap object that represents the mapping of a 
   * memory region into the address space of the calling process.
   *
   * @param piMemRegion1  The IMemRegion1 that needs to be mapped
   *                      into the invokisng process's address 
   *                      space.
   * @param ulPerms       Access permissions used to map this 
   *                      region, mapping of the region would fail
   *                      if the permissions requested is higher 
   *                      than what was used when region was 
   *                      created. 
   * @param ulMapSize     Pointer to the number of bytes of the 
   *                      region that need to be mapped.  
   * @param ppiMemMap     The memory map object created  
   * @param pulMapStart   Pointer to the start address of the 
   *                      mapped region  
   * @param pulMappedSize This points to the actual number of 
   *                      bytes mapped.  
   */

   AEEResult MapRegion(in IMemRegion1 piMemRegion1, 
                          in uint32 ulPerms,
                          in uint32 ulMapSize, 
                          rout IMemMap ppiMemMap, 
                          rout uint32 pulMapStart, 
                          rout uint32 pulMappedSize);

  /*
   * Translates from virtual to IMemRegion1
   * 
   * @param ulVirtAddr     Virtual address that needs to
                           be translated  
   * @param ulPerms        Permissions associated with the
                           region to be retrieved.  
   * @param pulSize        Valid extent after the virtual
                           address that is accessible with
                           the permissions passed in  
   * @param ppiMemRegion1  Pointer to IMemRegion1 interface
                           pointer
   */

   AEEResult TranslateVirtualToRegion(in uint32 ulVirtAddr,
                           in uint32 ulPerms,
                           rout uint32 pulSize,
                           rout IMemRegion1 ppiMemRegion1);
};

The following figure illustrates different memory region mapping scenarios. The shaded areas in the diagram are the areas to be mapped through IMemSpace_MapRegion(). Mapping must start from the beginning of the memory region to be mapped, with the size equal to or less than the size of the memory region to be mapped. Mapping from the middle of the memory region is not allowed. A memory region from one process can be mapped multiple times into other processes.