Re: mmap for I/O access



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
.



Relevant Pages

  • Re: [RFC-PATCH 1/5] unaligned: introduce common header
    ... aligned (as long as you can guarantee the struct alignment), ... there is no documented difference between packing all members and the ... The gcc documentation for packed is pretty short: ... On an architecture with struct alignment> 1 this will not work. ...
    (Linux-Kernel)
  • Re: Getting NASM from C
    ... > The registers are lined up and filling with the right numbers to make ... dword write; ... take a "subfunction number" in ebx. ... the "ultimate documentation". ...
    (alt.lang.asm)
  • How to keep documentation of control and status registers and VHDL code in sync
    ... and implementation of control and status registers in sync. ... documentation made it look interesting). ... Vregs solves this problem by creating VHDL and C-headers from HTML ...
    (comp.arch.fpga)
  • Re: Bribery & Desperation
    ... then you've got the registers from each ... We do have public liability insurance, but members of the public are ... from insurers if we could tell them who they were covering. ...
    (uk.rec.scouting)
  • Re: [PATCH 01/12] thinkpad_ec: New driver for ThinkPad embedded controller access
    ... registers which might be described in confidential/NDA'ed documentation, ... logically follows from the publicly available H8S documentation (see ... "0x1600") which is already given by the mainline hdaps driver. ...
    (Linux-Kernel)