diff options
author | Che-Liang Chiou <clchiou@chromium.org> | 2011-07-26 22:10:16 +0800 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2011-08-29 10:59:13 -0700 |
commit | d62fd066dbf5af9d6f44ce1d2f7e75f563b4fa9a (patch) | |
tree | a9f554080cf2d03d9417685de61e4f1b62e7612e /lib/chromeos | |
parent | 2ac50b8b2d5e25f839e883be37671433c9f005cc (diff) |
CHROMIUM: factor out gbb loader functions
This patch also eliminates duplications of decoding fmap from the
device tree.
BUG=chromium-os:16542
TEST=make chromeos_seaboard_vboot_config && make
Change-Id: I0af75335be10823b8644c94f6fc9aac0304a2633
Reviewed-on: http://gerrit.chromium.org/gerrit/4745
Tested-by: Che-Liang Chiou <clchiou@chromium.org>
Reviewed-by: Tom Wai-Hong Tam <waihong@chromium.org>
Diffstat (limited to 'lib/chromeos')
-rw-r--r-- | lib/chromeos/Makefile | 1 | ||||
-rw-r--r-- | lib/chromeos/gbb.c | 72 |
2 files changed, 73 insertions, 0 deletions
diff --git a/lib/chromeos/Makefile b/lib/chromeos/Makefile index 751bc42df2..5ea2754740 100644 --- a/lib/chromeos/Makefile +++ b/lib/chromeos/Makefile @@ -16,6 +16,7 @@ COBJS-$(CONFIG_CHROMEOS) += boot_kernel.o COBJS-$(CONFIG_CHROMEOS) += crossystem_data.o COBJS-$(CONFIG_CHROMEOS) += fdt_decode.o COBJS-$(CONFIG_CHROMEOS) += firmware_storage_spi.o +COBJS-$(CONFIG_CHROMEOS) += gbb.o COBJS-$(CONFIG_CHROMEOS) += memory_wipe.o # TODO(sjg): This MMC code is not needed as yet, and needs slight changes diff --git a/lib/chromeos/gbb.c b/lib/chromeos/gbb.c new file mode 100644 index 0000000000..6f8c186528 --- /dev/null +++ b/lib/chromeos/gbb.c @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + */ + +#include <common.h> +#include <chromeos/common.h> +#include <chromeos/gbb.h> + +#include <gbb_header.h> + +#define PREFIX "gbb: " + +int gbb_init(void *gbb, firmware_storage_t *file, uint32_t gbb_offset) +{ + GoogleBinaryBlockHeader *gbbh = (GoogleBinaryBlockHeader *)gbb; + + if (file->read(file, gbb_offset, sizeof(*gbbh), gbbh)) { + VBDEBUG(PREFIX "failed to read GBB header\n"); + return 1; + } + + if (file->read(file, gbb_offset + gbbh->hwid_offset, + gbbh->hwid_size, + gbb + gbbh->hwid_offset)) { + VBDEBUG(PREFIX "failed to read hwid\n"); + return 1; + } + + if (file->read(file, gbb_offset + gbbh->rootkey_offset, + gbbh->rootkey_size, + gbb + gbbh->rootkey_offset)) { + VBDEBUG(PREFIX "failed to read root key\n"); + return 1; + } + + return 0; +} + +int gbb_read_bmp_block(void *gbb, firmware_storage_t *file, uint32_t gbb_offset) +{ + GoogleBinaryBlockHeader *gbbh = (GoogleBinaryBlockHeader *)gbb; + + if (file->read(file, gbb_offset + gbbh->bmpfv_offset, + gbbh->bmpfv_size, + gbb + gbbh->bmpfv_offset)) { + VBDEBUG(PREFIX "failed to read bmp block\n"); + return 1; + } + + return 0; +} + +int gbb_read_recovery_key(void *gbb, + firmware_storage_t *file, uint32_t gbb_offset) +{ + GoogleBinaryBlockHeader *gbbh = (GoogleBinaryBlockHeader *)gbb; + + if (file->read(file, gbb_offset + gbbh->recovery_key_offset, + gbbh->recovery_key_size, + gbb + gbbh->recovery_key_offset)) { + VBDEBUG(PREFIX "failed to read recovery key\n"); + return 1; + } + + return 0; +} |