public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
From: "colorant" <colorant@163.com>
To: David Brownell <david-b@pacbell.net>,
	linux-omap-open-source@linux.omap.com
Subject: Re: Question About __REG32 marco
Date: Wed, 21 Nov 2007 08:40:03 +0800	[thread overview]
Message-ID: <007d01c82bd7$0e1d8dc0$16110a0a@LongCheer.net> (raw)
In-Reply-To: 200711201326.06148.david-b@pacbell.net

[-- Attachment #1: Type: text/plain, Size: 2023 bytes --]

Hi Dave

> 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.
> 

Yes, I can see that from the obj-code. Thanks.

> 
>>     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...)
> 

This is what I am puzzled, since the index is just 1K, the following definition :

typedef struct { volatile u32 offset[4096]; } __regbase32;

shouldn't be:

 typedef struct { volatile u32 offset[1024]; } __regbase32; ?

Raymond


[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



  reply	other threads:[~2007-11-21  0:40 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
2007-11-21  0:40   ` colorant [this message]
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='007d01c82bd7$0e1d8dc0$16110a0a@LongCheer.net' \
    --to=colorant@163.com \
    --cc=david-b@pacbell.net \
    --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