summaryrefslogtreecommitdiff
path: root/src/vendorcode/google/chromeos
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2014-09-12 09:59:46 -0700
committerAaron Durbin <adurbin@google.com>2015-03-24 14:48:22 +0100
commit1bbac3fd248ad7c91511d12c74b61c239ba3aa9f (patch)
treec303d7309e703b9ee869dc255b09ade120690ee9 /src/vendorcode/google/chromeos
parentefddcfbb52cd328ad2eb86d88cd306ac30294109 (diff)
vboot2: Make struct vb2_working_data cpu architecture agnostic
this allows vb2_working_data to be accessed from stages running on different cpu architectures. BUG=none TEST=Built firmware for Blaze with USE=+/-vboot2. Ran faft on Blaze. BRANCH=none Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Original-Change-Id: Ife2844637af8bf9e0d032a50fb516d98b8f80497 Original-Reviewed-on: https://chromium-review.googlesource.com/217835 Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org> Original-Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Original-Tested-by: Daisuke Nojiri <dnojiri@chromium.org> (cherry picked from commit 2b36749bc5a761003f00b7a0d17edb1629245b88) Change-Id: Idc10f23ed2927717f5308f0112aa8113a683010e Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/8882 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'src/vendorcode/google/chromeos')
-rw-r--r--src/vendorcode/google/chromeos/chromeos.c13
-rw-r--r--src/vendorcode/google/chromeos/chromeos.h40
-rw-r--r--src/vendorcode/google/chromeos/vboot_handoff.c7
-rw-r--r--src/vendorcode/google/chromeos/verstage.c8
-rw-r--r--src/vendorcode/google/chromeos/verstub.c10
5 files changed, 49 insertions, 29 deletions
diff --git a/src/vendorcode/google/chromeos/chromeos.c b/src/vendorcode/google/chromeos/chromeos.c
index d2f62d7da7..bd72e77e6c 100644
--- a/src/vendorcode/google/chromeos/chromeos.c
+++ b/src/vendorcode/google/chromeos/chromeos.c
@@ -223,7 +223,7 @@ void *vboot_load_stage(int stage_index,
struct vboot_components *fw_info)
{
struct cbfs_stage *stage;
- uint32_t fc_addr;
+ uintptr_t fc_addr;
uint32_t fc_size;
if (stage_index >= fw_info->num_components) {
@@ -267,18 +267,9 @@ struct vb2_working_data * const vboot_get_working_data(void)
return (struct vb2_working_data *)CONFIG_VBOOT_WORK_BUFFER_ADDRESS;
}
-int vboot_is_slot_selected(struct vb2_working_data *wd)
-{
- return wd->selected_region.size > 0;
-}
-
-int vboot_is_readonly_path(struct vb2_working_data *wd)
-{
- return wd->selected_region.size == 0;
-}
-
void vboot_reboot(void)
{
hard_reset();
}
+
#endif
diff --git a/src/vendorcode/google/chromeos/chromeos.h b/src/vendorcode/google/chromeos/chromeos.h
index 14e0b10d18..0d8da8feaf 100644
--- a/src/vendorcode/google/chromeos/chromeos.h
+++ b/src/vendorcode/google/chromeos/chromeos.h
@@ -130,20 +130,42 @@ void vboot_reboot(void);
/*
* this is placed at the start of the vboot work buffer. selected_region is used
* for the verstage to return the location of the selected slot. buffer is used
- * by the vboot2 core.
- *
- * TODO: Make the sizes of the struct and its members independent of cpu
- * architectures as it crosses stage boundaries.
+ * by the vboot2 core. Keep the struct cpu architecture agnostic as it crosses
+ * stage boundaries.
*/
struct vb2_working_data {
- struct vboot_region selected_region;
- size_t buffer_size;
- uint8_t *buffer;
+ uint32_t selected_region_offset;
+ uint32_t selected_region_size;
+ uint64_t buffer_size;
+ uint64_t buffer;
};
struct vb2_working_data * const vboot_get_working_data(void);
-int vboot_is_slot_selected(struct vb2_working_data *wd);
-int vboot_is_readonly_path(struct vb2_working_data *wd);
+
+static inline void vb2_get_selected_region(struct vb2_working_data *wd,
+ struct vboot_region *region)
+{
+ region->offset_addr = wd->selected_region_offset;
+ region->size = wd->selected_region_size;
+}
+
+static inline void vb2_set_selected_region(struct vb2_working_data *wd,
+ struct vboot_region *region)
+{
+ wd->selected_region_offset = region->offset_addr;
+ wd->selected_region_size = region->size;
+}
+
+static inline int vboot_is_slot_selected(struct vb2_working_data *wd)
+{
+ return wd->selected_region_size > 0;
+}
+
+static inline int vboot_is_readonly_path(struct vb2_working_data *wd)
+{
+ return wd->selected_region_size == 0;
+}
+
#endif /* CONFIG_VBOOT2_VERIFY_FIRMWARE */
#endif
diff --git a/src/vendorcode/google/chromeos/vboot_handoff.c b/src/vendorcode/google/chromeos/vboot_handoff.c
index ae3096aee2..f929a59a29 100644
--- a/src/vendorcode/google/chromeos/vboot_handoff.c
+++ b/src/vendorcode/google/chromeos/vboot_handoff.c
@@ -143,9 +143,10 @@ void *vboot_load_ramstage(void)
{
struct vboot_handoff *vh;
struct vb2_shared_data *sd;
+ struct vboot_region fw_main;
struct vb2_working_data *wd = vboot_get_working_data();
- sd = (struct vb2_shared_data *)wd->buffer;
+ sd = (struct vb2_shared_data *)(uintptr_t)wd->buffer;
sd->workbuf_hash_offset = 0;
sd->workbuf_hash_size = 0;
@@ -167,5 +168,7 @@ void *vboot_load_ramstage(void)
printk(BIOS_INFO,
"loading ramstage from Slot %c\n", sd->fw_slot ? 'B' : 'A');
- return load_ramstage(vh, &wd->selected_region);
+ vb2_get_selected_region(wd, &fw_main);
+
+ return load_ramstage(vh, &fw_main);
}
diff --git a/src/vendorcode/google/chromeos/verstage.c b/src/vendorcode/google/chromeos/verstage.c
index 4970124b04..1b42bb6830 100644
--- a/src/vendorcode/google/chromeos/verstage.c
+++ b/src/vendorcode/google/chromeos/verstage.c
@@ -173,12 +173,13 @@ void verstage_main(void)
#endif /* CONFIG_RETURN_FROM_VERSTAGE */
{
struct vb2_context ctx;
+ struct vboot_region fw_main;
struct vb2_working_data *wd = vboot_get_working_data();
int rv;
/* Set up context and work buffer */
memset(&ctx, 0, sizeof(ctx));
- ctx.workbuf = wd->buffer;
+ ctx.workbuf = (uint8_t *)(uintptr_t)wd->buffer;
ctx.workbuf_size = wd->buffer_size;
/* Read nvdata from a non-volatile storage */
@@ -225,11 +226,11 @@ void verstage_main(void)
}
printk(BIOS_INFO, "Phase 4\n");
- rv = locate_firmware(&ctx, &wd->selected_region);
+ rv = locate_firmware(&ctx, &fw_main);
if (rv)
die("Failed to read FMAP to locate firmware");
- rv = hash_body(&ctx, &wd->selected_region);
+ rv = hash_body(&ctx, &fw_main);
save_if_needed(&ctx);
if (rv) {
printk(BIOS_INFO, "Reboot requested (%x)\n", rv);
@@ -246,4 +247,5 @@ void verstage_main(void)
}
printk(BIOS_INFO, "Slot %c is selected\n", is_slot_a(&ctx) ? 'A' : 'B');
+ vb2_set_selected_region(wd, &fw_main);
}
diff --git a/src/vendorcode/google/chromeos/verstub.c b/src/vendorcode/google/chromeos/verstub.c
index 5df1777bb2..a4ed77f96b 100644
--- a/src/vendorcode/google/chromeos/verstub.c
+++ b/src/vendorcode/google/chromeos/verstub.c
@@ -30,7 +30,7 @@ static struct vb2_working_data *init_vb2_working_data(void)
wd = vboot_get_working_data();
memset(wd, 0, CONFIG_VBOOT_WORK_BUFFER_SIZE);
/* 8-byte alignment for ARMv7 */
- wd->buffer = (uint8_t *)ALIGN_UP((uintptr_t)&wd[1], 8);
+ wd->buffer = ALIGN_UP((uintptr_t)&wd[1], 8);
wd->buffer_size = CONFIG_VBOOT_WORK_BUFFER_SIZE + (uintptr_t)wd
- (uintptr_t)wd->buffer;
@@ -74,12 +74,14 @@ void vboot2_verify_firmware(void)
entry = NULL;
if (vboot_is_slot_selected(wd)) {
/* RW A or B */
- struct vboot_components *fw_info =
- vboot_locate_components(&wd->selected_region);
+ 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,
- &wd->selected_region, fw_info);
+ &fw_main, fw_info);
} else if (vboot_is_readonly_path(wd)) {
/* RO */
entry = cbfs_load_stage(CBFS_DEFAULT_MEDIA,