mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Pinco Pallino <pinco.doublec.pallino@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: reset and addresses
Date: Mon, 13 Jun 2011 11:25:11 +0200	[thread overview]
Message-ID: <20110613092511.GZ23771@pengutronix.de> (raw)
In-Reply-To: <BANLkTiny8AFTWDyP_BqMJWrc=bf5aKBePw@mail.gmail.com>

Hi Pinco,

On Sat, Jun 11, 2011 at 06:55:04PM +0200, Pinco Pallino wrote:
> Hi,
> I was trying to understand the initialization code for the ARM
> architecture, but there is something troubling me about addresses and
> relocation.
> 
> 1) As far as I understood from linker script (barebox.lds.S) and start
> file (start.c), the barebox binary file is created to be allocated in
> RAM, properly setting TEXT_BASE. For example, for at91rm9200 TEXT_BASE
> is set to 0x23f00000 (ARM region). Here is also .text_entry section
> with the exception vector table, so the link address of the reset
> routine is actually 0x23f00000. Now the runtime address of the reset
> routine has to be 0x00000000. How is this achieved? I mean,  where is
> the information saying that the code in the ELF at 0x23f00000, has to
> be runtime at address 0x00000000? In general how can I know where is
> my code is being executed runtime?

It is executed where you copy and start it.

> BTW, is for this reason in the guide you claim "Code running
> immediately after reset runs at an address it is not linked to:
> "runtime address != link address""?

Yes. The startup code is position independent. It can be executed
anywhere in memory. The startup code copies the barebox image to
the correct address and jumps there.

> 
> 2) Why should I relocate the exception table as seen in
> at91rm9200_lowlevel_init.c? Is this done in case barebox is being
> executed by another bootloader?

Arm expects the exception table to be at 0x0. In order for exceptions
to be trapped correctly we have to copy the exception table there. Most
Arm SoCs do not have RAM at this address, so we use the MMU to map a
page of SDRAM there.

> 
> 3) Why do we set the SP to STACK_BASE + STACK_SIZE - 16 and not just STACK_BASE?

The upper space is reserved for the exception stack.

> 
> I'm aware that these are quite noob questions and I apologize, but
> there is no other place  to ask.

These are no noob questions at all.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      reply	other threads:[~2011-06-13  9:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-11 16:55 Pinco Pallino
2011-06-13  9:25 ` Sascha Hauer [this message]

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=20110613092511.GZ23771@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=pinco.doublec.pallino@gmail.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