diff options
author | Aaron Durbin <adurbin@chromium.org> | 2014-03-20 14:28:17 -0500 |
---|---|---|
committer | Marc Jones <marc.jones@se-eng.com> | 2014-12-09 18:41:00 +0100 |
commit | 30974bc2f5f4764425e69256782cca03b290c4f4 (patch) | |
tree | 43643987aeb0056ce5e5e154f464e856dc352919 /src/vendorcode/google/chromeos/vboot_handoff.c | |
parent | f72f9e7c14a2a5df92c30a3ec88d15b9aca30b1e (diff) |
vboot: allow for non-memory-mapped VBOOT regions
Depending on the platform the underlying regions vboot requires
may not be accessible through a memory-mapped interface. Allow
for non-memory-mapped regions by providing a region request
abstraction. There is then only a few touch points in the code to
provide compile-time decision making no how to obtain a region.
For the vblocks a temporary area is allocated from cbmem. They
are then read from the SPI into the temporarily buffer.
BUG=chrome-os-partner:27094
BRANCH=None
TEST=Built and booted a rambi with vboot verification.
Original-Change-Id: I828a7c36387a8eb573c5a0dd020fe9abad03d902
Original-Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/190924
Original-Reviewed-by: Hung-Te Lin <hungte@chromium.org>
(cherry picked from commit aee0280bbfe110eae88aa297b433c1038c6fe8a3)
Signed-off-by: Marc Jones <marc.jones@se-eng.com>
Change-Id: Ia020d1eebad753da950342656cd11b84e9a85376
Reviewed-on: http://review.coreboot.org/7709
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Diffstat (limited to 'src/vendorcode/google/chromeos/vboot_handoff.c')
-rw-r--r-- | src/vendorcode/google/chromeos/vboot_handoff.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/vendorcode/google/chromeos/vboot_handoff.c b/src/vendorcode/google/chromeos/vboot_handoff.c index 937b2e31c0..c3c5a138d7 100644 --- a/src/vendorcode/google/chromeos/vboot_handoff.c +++ b/src/vendorcode/google/chromeos/vboot_handoff.c @@ -18,8 +18,10 @@ */ #include <stddef.h> +#include <string.h> #include "chromeos.h" #include <boot/coreboot_tables.h> +#include <cbfs.h> #include <cbmem.h> #include <console/console.h> #include <payload_loader.h> @@ -52,6 +54,33 @@ int vboot_enable_recovery(void) return !!(vbho->init_params.out_flags & VB_INIT_OUT_ENABLE_RECOVERY); } +void *vboot_get_region(uintptr_t offset_addr, size_t size, void *dest) +{ + if (IS_ENABLED(CONFIG_SPI_FLASH_MEMORY_MAPPED)) { + if (dest != NULL) + return memcpy(dest, (void *)offset_addr, size); + else + return (void *)offset_addr; + } else { + struct cbfs_media default_media, *media = &default_media; + void *cache; + + init_default_cbfs_media(media); + media->open(media); + if (dest != NULL) { + cache = dest; + if (media->read(media, dest, offset_addr, size) != size) + cache = NULL; + } else { + cache = media->map(media, offset_addr, size); + if (cache == CBFS_MEDIA_INVALID_MAP_ADDRESS) + cache = NULL; + } + media->close(media); + return cache; + } +} + static void *vboot_get_payload(size_t *len) { struct vboot_handoff *vboot_handoff; |