Memory mapped device access in C / Embedded Linux [closed]
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:
Use system calls to map the device's physical memory space into the virtual memory space of a running process
Write to the virtual file
/dev/mem
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;
精彩评论