
Arcom Embedded Linux Technical Manual Developing software for AEL
Common embedded software development tasks
Accessing the physical address space
When developing software for AEL, it is sometimes necessary to access the
processor’s physical address space from within your application. For example, you may
need to tweak memory mapped register settings within the CPU or to access some
external peripheral such as a GPIO pin.
A Linux application may only access the virtual address space that the Linux kernel has
created for it. This virtual address space normally does not contain mappings to the
physical regions that you want to use. An application can create a mapping to an
arbitrary physical address by opening the /dev/mem special device file, which provides
access to the entire physical address space, and then performing an mmap() operation
on the file handle.
For security reasons, the application must be running as root in order to do this.
Getting the specifics of this operation correct can be tricky, so we provide a library
(libdevmem) that handles this complexity for you. The library provides a number of
functions:
libdevmem_handle libdevmem_open(unsigned long base,
unsigned long length);
int libdevmem_close(libdevmem_handle handle);
TYPE
_t libdevmem_read_
TYPE
(libdevmem_handle handle,
unsigned long offset);
void libdevmem_write_
TYPE
(libdevmem_handle handle,
unsigned long offset,
TYPE
_t value);
© 2006 Arcom Issue G 47
Kommentare zu diesen Handbüchern