Training
×

Access to memory mapped devices

Access to a memory mapped device requires mapping its physical memory into the address space of the using INtime process.
 
To share this memory with other processes, either create a memory handle for the mapping and use it just like shared memory (see respective information on shared memory in chapter on IPC of the training) or do an additional mapping of the physical memory in the other process. The recommended option is to create a memory handle because this centralizes the mapping activities to one section of the sources and eases simulating/testing in cases where you do not yet have the device (because it may be in development or – for special cards – be short in supply). A memory handle – after respective ntxMapRtSharedMemory(Ex) calls - also allows direct access to the memory for a thread in Windows.
 
Once the mapping is no longer needed, use FreeRtMemory to delete the mapping and free the associated virtual memory.
 
The default caching strategy depends on which memory is being cached. Regular RAM is normally cached. Memory on a PCI card is not normally cached. You can control the caching of a mapping by using MapRtPhysicalMemoryEx. This caching type is not applied to the physical memory, but to the memory as accessed through the mapping returned from the call.