开发者

Memory mapped device access in C / Embedded Linux [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical an开发者_StackOverflowd cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

I have a pxa270 processor kit running embedded Linux that has memory-mapped devices.

How can I store a value in those devices' external memory (if I know their physical address)?


As you've tagged this "embedded-linux", I'm going to assume that what you want to do is write to the memory of a memory mapped device.

There are a few approaches I can think of, but I'm not sure whether the first is possible in Linux:

  1. Use system calls to map the device's physical memory space into the virtual memory space of a running process

  2. Write to the virtual file /dev/mem

  3. Create a block device driver which handles your device's memory, and then perform (file) operations against its entry in /dev.

(Actually #1 and #2 together might work, using mmap() against /dev/mem so that you can use normal memory read and write ops instead of file operations).


You can simply declare a pointer of the type you require and assign the memory location to it. Then set your values as normal.

int *pointer_to_memory = (int *)address_of_external_memory;
*pointer_to_memory = value;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜