public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Jerry Van Baren <gerald.vanbaren@ge.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] what's function of "absolute address" in these codes?
Date: Tue, 13 Nov 2007 08:06:36 -0500	[thread overview]
Message-ID: <4739A15C.3030705@ge.com> (raw)
In-Reply-To: <BAY133-DS2E9A90E34EA189EE11C7891800@phx.gbl>

xiangguo_li at hotmail.com wrote:
> //codes from start.S of 74xx_7xx  
>  
> =====================================================================
> START_GOT
>  ...
>  
>  . = EXC_OFF_SYS_RESET
>  .globl _start
> _start:
>  li r21, BOOTFLAG_COLD /* Normal Power-On: Boot from FLASH */
>  b boot_cold
>  sync
>  
> ...
>  
> boot_cold:
> boot_warm:
>  /* disable everything */
> ...
>        
>  /*
>   * Calculate absolute address in FLASH and jump there
>   *------------------------------------------------------*/
>  lis r3, CFG_MONITOR_BASE at h <mailto:CFG_MONITOR_BASE@h>
>  ori r3, r3, CFG_MONITOR_BASE at l <mailto:CFG_MONITOR_BASE@l>
>  addi r3, r3, in_flash - _start + EXC_OFF_SYS_RESET           //
>  mtlr r3                                                                                //move 
> contents in r3 to Link Register(LR)
>  blr                                                                                      //branch 
> to address in Link Register(LR)
>  
> in_flash:                                                                                //
>  /* let the C-code set up the rest   */
>  /*       */
>  /* Be careful to keep code relocatable !  */
>  /*------------------------------------------------------*/
>  
> ==========================================================================
> why not use "bl in_flash" or  simply comment these codes out?
> thank you.

Because the linked address of in_flash may not be where we want to have
our flash and where we need to execute code.  Typically on power up,
flash is mapped everywhere in memory, which means there are replicated
"copies" everywhere (e.g. if you have a 1MByte flash, your flash image
is replicated every 1MByte).  In the board configuration configuration,
EXC_OFF_SYS_RESET identifies which "copy" you want to execute from (your
runtime flash location, which is usually different from the start up
location) and the above start up code picks the "correct copy" and jumps
to it.

A little further on you will find code that does the memory map
configuration which sets up the flash runtime location (making all the
extra flash copies "disappear"), enables the RAM chip selects, etc.  If
the above start up code didn't jump to the correct "copy" of flash, the
memory map initialization code would unmap flash out from under itself
(your PC would be at in_flash+X rather than at
EXC_OFF_SYS_RESET+in_flash+X) and your processor would crash.

HTH,
gvb

      reply	other threads:[~2007-11-13 13:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-13 12:04 [U-Boot-Users] what's function of "absolute address" in these codes? xiangguo_li at hotmail.com
2007-11-13 13:06 ` Jerry Van Baren [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=4739A15C.3030705@ge.com \
    --to=gerald.vanbaren@ge.com \
    --cc=u-boot@lists.denx.de \
    /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