From: David Brownell <david-b@pacbell.net>
To: linux-omap-open-source@linux.omap.com
Cc: colorant <colorant@163.com>
Subject: Re: Question About __REG32 marco
Date: Tue, 20 Nov 2007 13:26:05 -0800 [thread overview]
Message-ID: <200711201326.06148.david-b@pacbell.net> (raw)
In-Reply-To: <005c01c82b61$ac9f1cf0$16110a0a@LongCheer.net>
On Tuesday 20 November 2007, colorant wrote:
>
> 1:
> Why this macro need to be defined in this way ? Why borther to use an array ?
> Can't we just use something like :
>
> *(volatile u32 *)(vaddr&~0x3) to get the value from vaddr with word align ?
It generalizes __REG2() from arch-pxa/hardware.h ... where,
as the comment notes, GCC would otherwise be incapable of
generating decent code. It's possible GCC code generation
has gotten smarter since then.
Note that such macros are supposed to be used only with
constant addresses, so code can treat registers as if they
were global variables. Some people dislike that style;
others find it more understandable than __raw_writel()
style accessors.
When it works right, driver code will have a register with
the base address of a controller, and all accesses to that
controller will use single word load/store instructions which
embed the offsets of the various registers being accessed
against that base register.
The main alternative addressing styles were notably larger
(I recall observing 1-2 KBytes per driver) and slower.
> 2:
> Why this offset array need to be 4096 in size ? shouldn't it be 1024 ?
> since it already point to a u32 value. and the >>2 make the macro never
> got chance to reach a index great than 1024 !
Look at the ARM instructions that are used. The address
range may be 4KBytes, but the values are 4 bytes each.
So the range of their indices is just 1K. (As implied
by the comments adjacent to those macro definitions, which
point out the use of LDR/STR for 8 and 32 bit values...)
That's the case for 32 bit values. For other value sizes,
the logic is necessarily a bit different.
- Dave
next prev parent reply other threads:[~2007-11-20 21:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-20 10:39 Question About __REG32 marco colorant
2007-11-20 14:54 ` Woodruff, Richard
2007-11-20 21:26 ` David Brownell [this message]
2007-11-21 0:40 ` colorant
2007-11-21 0:46 ` David Brownell
2007-11-21 5:18 ` colorant
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200711201326.06148.david-b@pacbell.net \
--to=david-b@pacbell.net \
--cc=colorant@163.com \
--cc=linux-omap-open-source@linux.omap.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox