I know libmetal does it but I would like to bypass libmetal. I know that I should be able to reverse engineer how to do it by using the debugger to step through a libmetal example, but I am optimistic that the solution is simple enough that someone here will be generous enough to share it.
I expect that the core sequence of calls is:
1. shm_open()
2. ftruncate()
3. mmap
4. mlock()
Writing code that uses those calls to allocate virtual memory at the desired address is easy, but the virtual memory does not map to the desired physical memory.
In the call to shm_open, I believe I will need to pass the name of a pseudo-device, and that the pseudo-device will be related to my device tree entry:
shm0: shm@0 {
compatible = "shm_uio";
reg = <0x0 0x40B80000 0x0 0x80000>;
};
This results in a directory in the /sys/bus/... filesystem:
/sys/bus/platform/devices/40b80000.shm
But that path is clearly not the path that I need to pass to shm_open().
Can anyone clue me in?
Thanks
1. fd = open("/dev/mem", O_RDWR | O_SYNC) # instead of shm_open
2. virtAddress = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_LOCKED, fd, 0x40B80000)
3. close(fd)
4. mlock(virtAddress, size);
Note that 0x40B80000 is the address that I have reserved in the device tree as node shm@0. size is set to 0x80000, matching the size in shm@0.
You received this message because you are subscribed to a topic in the Google Groups "open-amp" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/open-amp/xh8gWvfiKZY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to open-amp+u...@googlegroups.com.