Re: mmap for I/O access
- From: Juergen Beisert <jbeisert@xxxxxxxxxxxx>
- Date: Sun, 20 Jan 2008 13:08:53 +0100
Geronimo W. Christ Esq wrote:
Robert Scott wrote:
Not necessarily. The I/O defined at 0x56000000 includes some 32-bit and
some
16-bit registers, and even some 8-bit ones. And the documentation gives
all the
addresses in terms of byte addresses. So if I want to make my code look
like it corresponds exactly with the documentation, then I want address
arithmetic to
work on bytes. The variable mptr is never used directly in my
application. I use it in macros, like:
#define gpb_DAT (*(short int*)(mptr+0x14))
In your situation, I like to use a struct with the __packed__ attribute
(as supported by GCC and other compilers). This lets you see registers
of different sizes directly by accessing members of a struct. But the
outcome is much the same.
Using structures yes, but don't use the __packed__ attribute. This could
change the way the compiler generates code to access the members in it (for
example bytewise access on larger members that are not aligned for this
type of architecture).
Best way for maintenance would be to create a few inline functions with the
access width in their name like in8, out8, in16, out16 aso. that are
working with simple address offsets. Its also more portable, because some
architectures do some kind of access optimization (reordering) in
background so the volatile attribute does not help this case.
JB
.
- References:
- Re: mmap for I/O access
- From: Albert van der Horst
- Re: mmap for I/O access
- From: Geronimo W. Christ Esq
- Re: mmap for I/O access
- Prev by Date: Re: mmap for I/O access
- Next by Date: Linux Vs vxWorks
- Previous by thread: Re: mmap for I/O access
- Next by thread: Question on ethernet controller
- Index(es):
Relevant Pages
|
|