Files
system76-coreboot/src/vendorcode/google/chromeos/verstub.c
Julius Werner ec5e5e0db2 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: Ifd2276417f2036cbe9c056f17e42f051bcd20e81
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: f1e2028e7ebceeb2d71ff366150a37564595e614
Original-Change-Id: I005506add4e8fcdb74db6d5e6cb2d4cb1bd3cda5
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/213370
Reviewed-on: http://review.coreboot.org/9283
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Tauner <stefan.tauner@gmx.at>
Reviewed-by: Aaron Durbin <adurbin@google.com>
2015-04-06 22:05:01 +02:00

97 lines
2.7 KiB
C

/*
* This file is part of the coreboot project.
*
* Copyright 2014 Google Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <arch/stages.h>
#include <cbfs.h>
#include <console/console.h>
#include <string.h>
#include "chromeos.h"
#include "symbols.h"
static struct vb2_working_data *init_vb2_working_data(void)
{
struct vb2_working_data *wd;
wd = vboot_get_working_data();
memset(wd, 0, _vboot2_work_size);
/* 8-byte alignment for ARMv7 */
wd->buffer = ALIGN_UP((uintptr_t)&wd[1], 8);
wd->buffer_size = _vboot2_work_size + (uintptr_t)wd
- (uintptr_t)wd->buffer;
return wd;
}
/**
* Verify a slot and jump to the next stage
*
* This could be either part of the (1) bootblock or the (2) verstage, depending
* on CONFIG_RETURN_FROM_VERSTAGE.
*
* 1) It jumps to the verstage and comes back, then, loads the romstage over the
* verstage space and exits to it. (note the cbfs cache is trashed on return
* from the verstage.)
*
* 2) We're already in the verstage. Verify firmware, then load the romstage and
* exits to it.
*/
void vboot2_verify_firmware(void)
{
void *entry;
struct vb2_working_data *wd;
wd = init_vb2_working_data();
#if CONFIG_RETURN_FROM_VERSTAGE
/* load verstage from RO */
entry = cbfs_load_stage(CBFS_DEFAULT_MEDIA,
CONFIG_CBFS_PREFIX "/verstage");
if (entry == (void *)-1)
die("failed to load verstage");
/* verify and select a slot */
stage_exit(entry);
#else
verstage_main();
#endif /* CONFIG_RETURN_FROM_VERSTAGE */
/* jump to the selected slot */
entry = NULL;
if (vboot_is_slot_selected(wd)) {
/* RW A or B */
struct vboot_region fw_main;
struct vboot_components *fw_info;
vb2_get_selected_region(wd, &fw_main);
fw_info = vboot_locate_components(&fw_main);
if (fw_info == NULL)
die("failed to locate firmware components\n");
entry = vboot_load_stage(CONFIG_VBOOT_ROMSTAGE_INDEX,
&fw_main, fw_info);
} else if (vboot_is_readonly_path(wd)) {
/* RO */
entry = cbfs_load_stage(CBFS_DEFAULT_MEDIA,
CONFIG_CBFS_PREFIX "/romstage");
}
if (entry != NULL && entry != (void *)-1)
stage_exit(entry);
die("failed to exit from stage\n");
}