Skip to content

Add a pre-relocation malloc() implementation

Tom Rini u-boot 2 versions – New

Get series with b4
b4 am 20140723134146.GD1847@bill-the-cat

Versions newest first · linked by author and title

  1. v3 Latest posting 2/20 of 9 patches 0 repliesNew
  2. v3 posting 1/21 of 9 patches 0 repliesSuperseded

Patches in v3 posting 2/2 No applies recorded yet

None of the 9 patches the cover letter announces are in this archive.

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [U-Boot] [PATCH v3 0/9] Add a pre-relocation malloc() implementation
Quoted 40 lines · Simon Glass

Hi,

Quoted 37 lines · Simon Glass

Hi Tom,

Quoted 22 lines · Tom Rini
Quoted 19 lines · Simon Glass

There has been talk on and off of a pre-relocation malloc() implementation. Driver model needs this so that it can work before relocation.

A previous implementation was sent in a v1 series.

This implementation works by allocating space on the stack. The benefit is that boards do not need to specify the address of the malloc() area, only the size. The down-side is that due to the way board_init_f() is called, architecture-specific code needs to be used to allocate the space.

No clever algorithms are used to allocate space, free() is a nop and realloc() is not supported. This fits well with the desire to avoid wasting space on bucket tables and the hassle of supporting BSS data before relocation. We don't expect 'churn' in the pre-relocation case - we just want to allocate small amounts of memory temporarily.

After relocation a new malloc() pool is created and the old one is lost, although pointers into it will survive the immediate process of relocation.

Quoted 8 lines
Quoted 3 lines

Implementations are provided for sandbox and arm (32-bit only).

A related change is made to the early init for each arch to make this work.

My concern without a fix right now is how to make use of this in SPL, when we're able to move SPL over to using still more generic code rather than re-inventing the board_init_{f,r} wheels, in the case where we init DRAM.

One option would be to split this new code out into a separate file, and have two malloc() implementations:

Quoted 8 lines
Quoted 2 lines

- big one - falls back to small one pre-relocation
- small one - used for SPL

I'm thinking of applying this to the dm repo now, except for the arm patches where I would like to get Albert's ack (so I'll wait a few more days).

Any objections?

I think we'll be OK. I checked over the callpath again on OMAP parts and we setup DDR prior to _main (in SPL) so we'll be fine.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140723/15273a2e/attachment.pgp>