linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: u.kleine-koenig@pengutronix.de (Uwe Kleine-König)
To: linux-arm-kernel@lists.infradead.org
Subject: defining ZRELADDR as PHYS_OFFSET + TEXT_OFFSET
Date: Fri, 5 Feb 2010 10:10:42 +0100	[thread overview]
Message-ID: <20100205091042.GA14059@pengutronix.de> (raw)
In-Reply-To: <20100205082652.GE21979@mvista.com>

Hello,

On Fri, Feb 05, 2010 at 03:26:52AM -0500, George G. Davis wrote:
> Hi,
> 
> On Mon, Feb 01, 2010 at 09:49:07AM +0100, Uwe Kleine-K?nig wrote:
> > Hallo George,
> > 
> > On Sun, Jan 31, 2010 at 08:24:25PM -0500, George G. Davis wrote:
> > > On Thu, Jan 28, 2010 at 12:15:23AM +0000, Russell King - ARM Linux wrote:
> > > > On Wed, Jan 27, 2010 at 11:12:28AM +0100, Uwe Kleine-K?nig wrote:
> > > > > Hello,
> > > > > 
> > > > > currently all platforms need to define zreladdr-y in
> > > > > arch/arm/mach-$mach/Makefile.boot and PHYS_OFFSET (in
> > > > > arch/arm/mach-$mach/include/mach/memory.h).
> > > > > 
> > > > > Constraints for these are:
> > > > > 
> > > > >  TEXTADDR = PAGE_OFFSET + TEXT_OFFSET
> > > > >  __virt_to_phys(virt) = virt - PAGE_OFFSET + PHYS_OFFSET (at least for
> > > > > 	"small" virtual addresses)
> > > > >  ZRELADDR = __virt_to_phys(TEXTADDR)
> > > > > 
> > > > > (The equallity for __virt_to_phys only holds "normaly" according to
> > > > > http://lists.arm.linux.org.uk/lurker/message/20010723.185051.94ce743c.en.html.
> > > > > In practice it holds for addresses of the first bank of RAM which is
> > > > > enough for the purposes of this mail.)
> > > > > 
> > > > > So we can deduce ZRELADDR = PHYS_OFFSET + TEXT_OFFSET.
> > > > > 
> > > > > Is there something I missed or is it possible to get rid of zreladdr-y
> > > > > in .../Makefile.boot and define it according to the equation above?
> > > > 
> > > > You'd need to find some way to get PHYS_OFFSET out of the C code
> > > > into the makefile.  With all sorts of stuff going on in various
> > > > platforms memory.h files, that doesn't look simple.
> > > 
> > > How about this?:
> > > 
> > > diff --git a/arch/arm/boot/Makefile b/arch/arm/boot/Makefile
> > > index 4a590f4..b79050e 100644
> > > --- a/arch/arm/boot/Makefile
> > > +++ b/arch/arm/boot/Makefile
> > > @@ -21,7 +21,7 @@ endif
> > >  #   ZRELADDR == virt_to_phys(PAGE_OFFSET + TEXT_OFFSET)
> > >  #   PARAMS_PHYS must be within 4MB of ZRELADDR
> > >  #   INITRD_PHYS must be in RAM
> > > -ZRELADDR    := $(zreladdr-y)
> > > +ZRELADDR    := $(shell printf "0x%08x" $$[`echo PHYS_OFFSET + $(TEXT_OFFSET)  | $(CPP) $(CPP_FLAGS) -D__ASSEMBLY__ -xc -include arch/arm/include/asm/memory.h - | tail -n 1`])
> > >  PARAMS_PHYS := $(params_phys-y)
> > >  INITRD_PHYS := $(initrd_phys-y)
> > hui!  Is this really robust?
> 
> Apologies for the delay, busy...
no problem.
 
> It can be but it is admittedly rather tricky to get the syntax right.  I've
> no idea how the above worked the first time I tried but it didn't upon
> further inspection.  I came up with this variation on the theme:
> 
> ZRELADDR     = $(shell $(CONFIG_SHELL) -c 'printf "0x%08x" $$[`echo PHYS_OFFSET + $(TEXT_OFFSET) | $(CPP) $(cpp_flags) -D__ASSEMBLY__ -xc -imacros asm/memory.h - 2>/dev/null | tail -1`]')
bash(1) has:

	*Arithmetic Expansion*
		[...] The format for arithmetic expansion is:

			$((expression))
	
		The old format $[expression] is  deprecated  and  will
		be  removed  upcoming versions of bash.

Anyhow I think this yields more trouble than it's worth.

Maybe better move PHYS_OFFSET into Makefile.boot or arch/arm/Makefile?
Or live with the redundancy?  Maybe some time in the future we don't
need ZRELADDR any more as it is calculated by zImage based on
PHYS_OFFSET.
 
Best regards
Uwe

-- 
Pengutronix e.K.                              | Uwe Kleine-K?nig            |
Industrial Linux Solutions                    | http://www.pengutronix.de/  |

  reply	other threads:[~2010-02-05  9:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-27 10:12 defining ZRELADDR as PHYS_OFFSET + TEXT_OFFSET Uwe Kleine-König
2010-01-28  0:15 ` Russell King - ARM Linux
2010-02-01  1:24   ` George G. Davis
2010-02-01  8:49     ` Uwe Kleine-König
2010-02-05  8:26       ` George G. Davis
2010-02-05  9:10         ` Uwe Kleine-König [this message]
2010-02-05 14:14           ` George G. Davis

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=20100205091042.GA14059@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).