Commit Graph

11 Commits

Author SHA1 Message Date
Tim Kientzle
2f37ec8b30 Initialize sym_count to 0.
This fixes a compiler warning introduced in r248121.
2013-03-30 16:33:16 +00:00
Ian Lepore
7554e820bb Attach the elf section headers to the loaded kernel as metadata, so
they can easily be used by later post-processing.  When searching for
a compiled-in fdt blob, use the section headers to get the size and
location of the .dynsym section to do a symbol search.

This fixes a problem where the search could overshoot the symbol
table and wander into the string table.  Sometimes that was harmless
and sometimes it lead to spurious panic messages about an offset
bigger than the module size.
2013-03-10 00:43:01 +00:00
Tim Kientzle
6d4a620eba Fix the bug I introduced in r247045.
After digging through more carefully, it looks like there's
no real need to have the DTB in the module directory.
So we can simplify a lot:  Just copy DTB into local heap
for "fdt addr" and U-Boot integration, drop all the extra
COPYIN() calls.

I've left one final COPYIN() to update the in-kernel DTB
for consistency with how this code used to work, but I'm
no longer convinced it's appropriate here.

I've also remove the mem_load_raw() utility that I added
to boot/common/module.c with r247045 since it's no longer
necessary.
2013-02-25 01:50:04 +00:00
Tim Kientzle
3bb97cef07 "fdt addr" gets run from loader.rc before the kernel is loaded.
This was broken by r247045 which tried to copy the FDT into the
module directory immediately.
Instead, store the address and arrange for the FDT to get
copied into the module directory later when the usual
FDT initialization runs.
2013-02-23 20:34:47 +00:00
Tim Kientzle
f87223581e Fix "fdt addr" to accept literal addresses rather than va offsets.
When initializing the fdt, query U-Boot as well.

With this change, it is now feasible to have U-Boot load
the FDT, ubldr will pull it from U-Boot and hand it to the
kernel.
2013-02-20 16:32:38 +00:00
Oleksandr Tymoshenko
ee9b837148 - Implement "fdt mres" sub-command that prints reserved memory regions
- Add "fdt addr" subcommand that lets you specify preloaded blob address
- Do not pre-initialize blob for "fdt addr"
- Do not try to load dtb every time fdt subcommand is issued,
    do it only once
- Change the way DTB is passed to kernel. With introduction of "fdt addr"
    actual blob address can be not virtual but physical or reside in
    area higher then 64Mb. ubldr should create copy of it in kernel area
    and pass pointer to this newly allocated buffer which is guaranteed to work
    in kernel after switching on MMU.
- Convert memreserv FDT info to "memreserv" property of root node
    FDT uses /memreserve/ data to notify OS about reserved memory areas.
    Technically it's not real property, it's just data blob, sequence
    of <start, size> pairs where both start and size are 64-bit integers.
    It doesn't fit nicely with OF API we use in kernel, so in order to unify
    thing ubldr converts this data to "memreserve" property using the same
    format for addresses and sizes as /memory node.
2012-11-30 03:15:50 +00:00
Tim Kientzle
c3a9b90973 Access the device tree blob via copyin/copyout.
The code previously assumed that copyin/copyout did no
address translation and that the device tree blob could
be manipulated in-place (with only a few adjustments for
the ELF loader offset).  This isn't possible on all platforms,
so the revised code uses copyout() to copy the device tree
blob into a heap-allocated buffer and then updates the
device tree with copyout().  This isn't ideal, since it
bloats the loader memory usage, but seems the only feasible
approach (short of rewriting all of the fdt manipulation
routines).
2012-05-17 04:04:48 +00:00
Tim Kientzle
9b1cb34ced Don't hang if there is no /cpus node in the device tree. 2012-05-11 04:18:39 +00:00
Rafal Jaworowski
4350d77706 Improve FDT handling in loader(8) and make it more robust.
o Fix buffer overflows when using a long property body in node paths.
o Fix loop end condition when iterating through the symbol table.
o Better error handling during node modification, better problem reporting.
o Eliminate build time warnings.

Submitted by:	Lukasz Wojcik
Obtained from:	Semihalf
MFC after:	1 week
2012-03-22 20:34:26 +00:00
Rafal Jaworowski
04296b6f18 Improve device tree blob (DTB) handling in loader(8).
Enable using the statically embedded blob from the kernel, if present. The KLD
loaded DTB takes precedence, but they are both recognized and handled in the
same way.

Submitted by:	Lukasz Wojcik
Obtained from:	Semihalf
MFC after:	1 week
2012-03-20 13:08:57 +00:00
Rafal Jaworowski
04cb90189b Initial loader(8) support for Flattened Device Tree.
o This is disabled by default for now, and can be enabled using WITH_FDT at
  build time.

o Tested with ARM and PowerPC.

Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
2010-05-25 15:21:39 +00:00