2

Due to some requirements on speed, we need to some computation in-place on internal memory and then DMA the results of the computation to a external memory. The application runs on a TI DM355 processor which is based on ARM926EJ-S core and a set of TI periferals (EDMA, video accelerators etc).

How cleanly can this be done from the application? Is it as simple as mmap'ing the afore said internal memory address into a virtual space and doing the calculation?

Thanks

  • I would say this could be difficult.. will Linux even allow such explicit control of mmap? I think at the worst, you may have to get your feet a bit wet and write a kernel module. – Earlz Nov 19 '09 at 14:42

3 Answers3

3

You can mmap the /dev/mem device:

int mem_fd = open("/dev/mem", O_RDWR);
void *buffer = mmap(NULL, mem_segment_length, PROT_READ | PROT_WRITE, MAP_SHARED,
                    mem_fd, mem_segment_addr);
close(mem_fd);
/* buffer now points to your device's memory */
/* remember to call msync after writing to this to force changes to write back to
 * /dev/mem */

However, depending on your needs, this may not be sufficient. Another question on here has answers that go more in-depth, but you're probably better off doing this in a kernel module.

Community
  • 1
  • 1
Left For Archive
  • 2,626
  • 1
  • 18
  • 19
0

I'd think that this would require sone level of kernel and/or driver support. If you're using a Linux distribution that's specific to your platform, there may be something already provided. Check whatever documentation or sample code you might have.

I did find an article on how to actually do the mapping here:

http://www.simtec.co.uk/appnotes/AN0014/

this is for accessing GPIO registers, but the code should be the same for on-chip memory, with a different address. Of course, if something else is already using that space, you're going to crash if you just map it and start modifying it,so some more documentation digging is probably warranted. Do you have a kernel memory map for your system?

Mark Bessey
  • 19,598
  • 4
  • 47
  • 69
  • Thanks. I am using a custom rootfs and kernel. I will try out mmap. Thanks for the link. I have got a better understanding of it now. –  Nov 20 '09 at 06:04
0

Also, I remember that its possible to pin a page in memory. Correct me if I am wrong.

Boolean
  • 14,266
  • 30
  • 88
  • 129