Search code examples
ramvxworks

VxWorks: Access Main memory Region


I am migrating a code from Linux to Vxworks. The code requires opening physical/main memory and then map the physical to virtual memory using mmap.

In Linux, main memory is accessed by

fd = open("/dev/mem", O_RDONLY);

Can you please let me know how this can be accomplished in Vxworks.

Thanks in advance


Solution

  • It depends on which programming environment your migrated code will be running.

    For kernel mode, it is much easier as generally you can access everywhere in the system memory in read-only mode as long as its memory region is mapped in the page table. No special API is needed in your code to access the memory.

    For user mode (aka Real Time Process, only available starting from VxWorks 6.0), things are a little bit complicated. You need write a pair of code blocks, with one operating in the kernel mode while the other one in the user mode. Please refer to the comment block in the VxWorks source codes for a code example @ vxworks-6.9/target/usr/src/os/mm/devMemLib.c (taking VxWorks 6.9 for example).