public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] U-Boot proper(not SPL) relocate option
Date: Wed, 22 Nov 2017 11:27:35 +0100	[thread overview]
Message-ID: <20171122102735.B9D18120302@gemini.denx.de> (raw)
In-Reply-To: <fd0bb500-80c4-f317-cc18-f7aaf1344fd8@rock-chips.com>

Dear Kever Yang,

In message <fd0bb500-80c4-f317-cc18-f7aaf1344fd8@rock-chips.com> you wrote:
> 
> I can understand this feature, we always do dram_init_banks() first,
> then we relocate to 'known' area, then will be no risk to access memory.
> I believe there must be some historical reason for some kind of device,
> the relocate feature is a wonderful idea for it.

This is actuallyu not so much a feature needed to support some
specific device (in this case much simpler approahces would be
possible), but to support a whole set of features.  Unfortunately
these appear to get forgotten / ignored over time.

>      many other SoCs should be similar.
> - Without relocate we can save many step, some of our customer really
>      care much about the boot time duration.
>      * no need to relocate everything
>      * no need to copy all the code
>      * no need init the driver more than once

Please have a look at the README, section "Memory Management".
The reloaction is not done to any _fixed_ address, but the address
is actually computed at runtime, depending on a number features
enabled (at least this is how it used to be - appearently little of
this is tested on a regular base, so I would not be surprised if
things are broken today).

The basic idea was to reserve areas of memory at the top of RAM,
that would not be initialized / modified by U-Boot and Linux, not
even across a reset / warm boot.

This was used for exaple for:

- pRAM (Protected RAM) which could be used to store all kind of data
  (for example, using a pramfs [Protected and Persistent RAM
  Filesystem]) that could be kept across reboots of the OS.

- shared frame buffer / video memory. U-Boot and Linux would be able
  to initialize the video memory just once (in U-Boot) and then
  share it, maybe even across reboots.  especially, this would allow
  for a very early splash screen that gets passed (flicker free) to
  Linux until some Linux GUI takes over (much more difficult today).

- shared log buffer: U-Boot and Linux used to use the same syslog
  buffer mechanism, so you could share it between U-Boot and Linux.
  this allows for example to 
  * read the Linux kernel panic messages after reset in U-Boot; this
    is very useful when you bring up a new system and Linux crashes
    before it can display the log buffer on the console
  * pass U-Boot POST results on to Linux, so the application code
    can read and process these
  * process the system log of the previous run (especially after a
    panic) in Lunux after it rebootet.

etc.

There are a number of such features which require to reserve room at
the top of RAM, the size of which is calculatedat runtime, often
depending on user settable environment data.

All this cannot be done without relocation to a (dynmaically
computed) target address.


Yes, the code could be simpler and faster without that - but then,
you cut off a number of features.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The flow chart is a most thoroughly oversold piece of  program  docu-
mentation.              -- Frederick Brooks, "The Mythical Man Month"

  parent reply	other threads:[~2017-11-22 10:27 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-21  9:33 [U-Boot] U-Boot proper(not SPL) relocate option Kever Yang
2017-11-21 10:29 ` Lukasz Majewski
2017-11-22  1:59   ` Kever Yang
2017-11-22  7:29     ` Chris Packham
2017-11-22  8:47       ` Lukasz Majewski
2017-11-22  8:45     ` Lokesh Vutla
2017-11-22  8:51     ` Lukasz Majewski
2017-11-22 10:27     ` Wolfgang Denk [this message]
2017-11-25 22:34       ` Simon Glass
2017-11-25 23:31         ` Dr. Philipp Tomsich
2017-11-26 11:38           ` Simon Glass
2017-11-26 13:44             ` Dr. Philipp Tomsich
2017-11-26 13:49               ` Dr. Philipp Tomsich
2017-11-26 14:16             ` Masahiro Yamada
2017-11-27 13:21               ` Wolfgang Denk
2017-11-29 10:10                 ` Masahiro Yamada
2017-11-27 17:13               ` Simon Glass
2017-11-27 18:53                 ` Tom Rini
2017-11-28  9:53                 ` Lukasz Majewski
2017-11-28 11:30                   ` Peter Robinson
2017-11-29 10:11                 ` Masahiro Yamada
2017-11-29 10:48                   ` Joakim Tjernlund
2017-12-02  3:29                     ` Simon Glass
2017-11-27 18:52               ` Tom Rini
2017-11-26 14:04 ` Andreas Färber
  -- strict thread matches above, loose matches on Subject: below --
2017-11-21  9:38 Kever Yang

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=20171122102735.B9D18120302@gemini.denx.de \
    --to=wd@denx.de \
    --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