Commit graph

12 commits

Author SHA1 Message Date
Julius Werner
f1e2028e7e New mechanism to define SRAM/memory map with automatic bounds checking
This patch creates a new mechanism to define the static memory layout
(primarily in SRAM) for a given board, superseding the brittle mass of
Kconfigs that we were using before. The core part is a memlayout.ld file
in the mainboard directory (although boards are expected to just include
the SoC default in most cases), which is the primary linker script for
all stages (though not rmodules for now). It uses preprocessor macros
from <memlayout.h> to form a different valid linker script for all
stages while looking like a declarative, boilerplate-free map of memory
addresses to the programmer. Linker asserts will automatically guarantee
that the defined regions cannot overlap. Stages are defined with a
maximum size that will be enforced by the linker. The file serves to
both define and document the memory layout, so that the documentation
cannot go missing or out of date.

The mechanism is implemented for all boards in the ARM, ARM64 and MIPS
architectures, and should be extended onto all systems using SRAM in the
future. The CAR/XIP environment on x86 has very different requirements
and the layout is generally not as static, so it will stay like it is
and be unaffected by this patch (save for aligning some symbol names for
consistency and sharing the new common ramstage linker script include).

BUG=None
TEST=Booted normally and in recovery mode, checked suspend/resume and
the CBMEM console on Falco, Blaze (both normal and vboot2), Pinky and
Pit. Compiled Ryu, Storm and Urara, manually compared the disassemblies
with ToT and looked for red flags.

Change-Id: I005506add4e8fcdb74db6d5e6cb2d4cb1bd3cda5
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/213370
2014-10-03 09:09:36 +00:00
Furquan Shaikh
fd43067047 rmodule: Align module_params to 8-byte
Required for arm64 platforms: rmodules used for arm64 require module_params and
rodata to be placed at 8-byte boundary in order to avoid unaligned access.

BUG=chrome-os-partner:30785
BRANCH=None
TEST=Compiles successfully and address verified during boot

Change-Id: I4820efad2b408ebd3930943f7771805a7bbb62e9
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://chromium-review.googlesource.com/216374
Tested-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Commit-Queue: Furquan Shaikh <furquan@chromium.org>
2014-09-11 19:59:58 +00:00
Furquan Shaikh
b9bb51c240 rmodule: Fix rmodule.ld for 64-bit
Fix the alignment for 64-bit systems

BUG=chrome-os-partner:31615
BRANCH=None
TEST=Compiles successfully and rmodule load and run for arm64 works fine

Change-Id: I7fcb1683d760b96307759b7d44d8770dd49a02e3
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://chromium-review.googlesource.com/214326
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Tested-by: Furquan Shaikh <furquan@chromium.org>
Commit-Queue: Aaron Durbin <adurbin@chromium.org>
2014-08-28 01:14:24 +00:00
Furquan Shaikh
d9558852c4 coreboot: Rename coreboot_ram stage to ramstage
Patch to rename coreboot_ram stage to ramstage. This is done in order to provide
consistency with other stage names(bootblock, romstage) and to allow any
Makefile rule generalization. (Required for patches to be submitted later)

CQ-DEPEND=CL:195101
BUG=None
BRANCH=None
TEST=Compiled successfully for all boards under mainboard/google/. Image booted
successfully on link board

Change-Id: I3e2495fc6a5cc91695ae04ffb438dd4ac265be64
Reviewed-on: https://chromium-review.googlesource.com/195059
Tested-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
Commit-Queue: Furquan Shaikh <furquan@chromium.org>
2014-05-07 23:30:23 +00:00
Ronald G. Minnich
5d262f8dd4 rmodules: add support for rmodtool
The following patches were taken from upstreamed and
massaged to work in our repo. The patches are squashed
together.

http://review.coreboot.org/5120
http://review.coreboot.org/5364
http://review.coreboot.org/5365
http://review.coreboot.org/5366
http://review.coreboot.org/5367
http://review.coreboot.org/5368
http://review.coreboot.org/5369
http://review.coreboot.org/5370
http://review.coreboot.org/5371
http://review.coreboot.org/5372
http://review.coreboot.org/5384
http://review.coreboot.org/5373
http://review.coreboot.org/5374
http://review.coreboot.org/5375
http://review.coreboot.org/5376
http://review.coreboot.org/5377
http://review.coreboot.org/5363
http://review.coreboot.org/5378
http://review.coreboot.org/5379
http://review.coreboot.org/5407

BUG=chrome-os-partner:27094
BRANCH=None
CQ-DEPEND=CL:*157856
TEST=Built and booted rambi with these set of patches.

Change-Id: I481352b23f6b60ff495c1a6bd3c21b52d817de3d
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/190921
Reviewed-by: Gabe Black <gabeblack@chromium.org>
2014-03-31 22:25:57 +00:00
Stefan Reinauer
5b3cdaed27 ARMv7: get rmodule support to compile
BRANCH=none
BUG=none
TEST=emerge-peach_pit chromeos-coreboot-peach_pit compiles
     successfully when CONFIG_VBOOT_VERIFY_FIRMWARE=y

Signed-off-by: Stefan Reinauer <reinauer@google.com>
Change-Id: I4a8f26d2e6ba92e4145022512d67e8a469fbba2f
Reviewed-on: https://chromium-review.googlesource.com/169372
Reviewed-by: David Hendrix <dhendrix@chromium.org>
2013-09-20 00:52:02 +00:00
Aaron Durbin
d9f0d0e455 BACKPORT: boot state: schedule static callbacks
Many of the boot state callbacks can be scheduled at compile time.
Therefore, provide a way for a compilation unit to inform the
boot state machine when its callbacks should be called. Each C
module can export the callbacks and their scheduling requirements
without changing the shared boot flow code.

Change-Id: I6a4102cb9fac3f7980c28169430251651fddeb30
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49741
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2013-05-01 14:30:00 -07:00
Aaron Durbin
6efa511677 BACKPORT: rmodule: put all code/data bits in one section
While debugging a crash it was discovered that ld was inserting
address space for sections that were empty depending on section
address boundaries. This led to the assumption breaking down that
on-disk payload (code/data bits) was contiguous with the address
space. When that assumption breaks down relocation updates change
the wrong memory. Fix this by making the rmodule.ld linker script
put all code/data bits into a payload section.

Change-Id: Iae9406efa97690c2ce11737688906dc071de5c7b
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49739
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2013-05-01 14:29:59 -07:00
Aaron Durbin
d23e292ef6 rmodule: align ld script with latest x86 ld script
The x86 linker script added a .textfirst section. In
order to properly link ramstage as a relocatable module
the .textfirst section needs to be included.

Also, the support for code coverage was added by including
the constructor section and symbols. Coverage has not been
tested as I suspect it might not work in a relocatable
environment without some tweaking. However, the section
and symbols are there if needed.

Change-Id: Ie1f6d987d6eb657ed4aa3a8918b2449dafaf9463
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: http://review.coreboot.org/2883
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2013-03-23 19:36:21 +01:00
Aaron Durbin
f7c6d489ae rmodule: add ramstage support
Coreboot's ramstage defines certain sections/symbols in its fixed
static linker script. It uses these sections/symbols for locating the
drivers as well as its own program information.  Add these sections
and symbols to the rmodule linker script so that ramstage can be
linked as an rmodule. These sections and symbols are a noop for other
rmodule-linked programs, but they are vital to the ramstage.

Also add a comment in coreboot_ram.ld to mirror any changes made there
to the rmodule linker script.

Change-Id: Ib9885a00e987aef0ee1ae34f1d73066e15bca9b1
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: http://review.coreboot.org/2786
Tested-by: build bot (Jenkins)
Reviewed-by: Marc Jones <marc.jones@se-eng.com>
2013-03-19 20:31:41 +01:00
Aaron Durbin
02fdf718a4 rmodule: include heap in bss section
By including the heap in the bss output section the size is accounted
for in a elf PT_LOAD segment. Without this change the heap wasn't being
put into a PT_LOAD segment. The result is a nop w.r.t. functionality,
but readelf and company will have proper MemSiz fields.

Change-Id: Ibfe9bb87603dcd4c5ff1c57c6af910bbba96b02b
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: http://review.coreboot.org/2750
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
2013-03-18 18:51:28 +01:00
Aaron Durbin
ad93552b86 lib: add rmodule support
A rmodule is short for relocation module. Relocaiton modules are
standalone programs. These programs are linked at address 0 as a shared
object with a special linker script that maintains the relocation
entries for the object. These modules can then be embedded as a raw
binary (objcopy -O binary) to be loaded at any location desired.

Initially, the only arch support is for x86. All comments below apply to
x86 specific properties.

The intial user of this support would be for SMM handlers since those
handlers sometimes need to be located at a dynamic address (e.g. TSEG
region).

The relocation entries are currently Elf32_Rel. They are 8 bytes large,
and the entries are not necessarily in sorted order. An future
optimization would be to have a tool convert the unsorted relocations
into just sorted offsets. This would reduce the size of the blob
produced after being processed. Essentialy, 8 bytes per relocation meta
entry would reduce to 4 bytes.

Change-Id: I2236dcb66e9d2b494ce2d1ae40777c62429057ef
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: http://review.coreboot.org/2692
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
2013-03-18 18:40:34 +01:00