summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/cmd_vboot_twostop.c28
-rw-r--r--include/chromeos/fmap.h1
-rw-r--r--lib/chromeos/fdt_decode.c11
3 files changed, 32 insertions, 8 deletions
diff --git a/common/cmd_vboot_twostop.c b/common/cmd_vboot_twostop.c
index bf19763d0f2..8659b66b3a1 100644
--- a/common/cmd_vboot_twostop.c
+++ b/common/cmd_vboot_twostop.c
@@ -661,9 +661,11 @@ twostop_main_firmware(struct twostop_fmap *fmap, void *gbb,
}
/**
- * Get address of the gbb and cdata, and optionally verify them.
+ * Get address of the cdata (and gbb, if not mapping SPI flash directly), and
+ * optionally verify them.
*
- * @param gbb returns pointer to GBB
+ * @param gbb returns pointer to GBB when SPI flash is not mapped directly.
+ * Contains pointer to gbb otherwise.
* @param cdata returns pointer to crossystem data
* @param verify 1 to verify data, 0 to skip this step
* @return 0 if ok, -1 on error
@@ -676,11 +678,18 @@ static int setup_gbb_and_cdata(void **gbb, crossystem_data_t **cdata,
#ifndef CONFIG_HARDWARE_MAPPED_SPI
*gbb = fdt_decode_chromeos_alloc_region(gd->blob,
"google-binary-block", &size);
+
+ if (!*gbb) {
+ VBDEBUG(PREFIX "google-binary-block missing "
+ "from fdt, or malloc failed\n");
+ return -1;
+ }
+
#endif
*cdata = fdt_decode_chromeos_alloc_region(gd->blob, "cros-system-data",
&size);
- if (!*gbb || !*cdata) {
- VBDEBUG(PREFIX "google-binary-block/cros-system-data missing "
+ if (!*cdata) {
+ VBDEBUG(PREFIX "cros-system-data missing "
"from fdt, or malloc failed\n");
return -1;
}
@@ -695,7 +704,7 @@ static int setup_gbb_and_cdata(void **gbb, crossystem_data_t **cdata,
}
if (verify && gbb_check_integrity(*gbb)) {
- VBDEBUG(PREFIX "invalid gbb\n");
+ VBDEBUG(PREFIX "invalid gbb at %p\n", *gbb);
return -1;
}
return 0;
@@ -778,15 +787,18 @@ twostop_readwrite_main_firmware(void)
crossystem_data_t *cdata;
void *gbb;
- if (setup_gbb_and_cdata(&gbb, &cdata, 1))
- return VB_SELECT_ERROR;
-
if (fdt_decode_twostop_fmap(gd->blob, &fmap)) {
VBDEBUG(PREFIX "failed to decode fmap\n");
return VB_SELECT_ERROR;
}
dump_fmap(&fmap);
+#ifdef CONFIG_HARDWARE_MAPPED_SPI
+ gbb = (void *) (fmap.readonly.gbb.offset + fmap.flash_base);
+#endif
+ if (setup_gbb_and_cdata(&gbb, &cdata, 1))
+ return VB_SELECT_ERROR;
+
/*
* VbSelectAndLoadKernel() assumes the TPM interface has already been
* initialized by VbSelectFirmware(). Since we haven't called
diff --git a/include/chromeos/fmap.h b/include/chromeos/fmap.h
index 13eb3d80bb6..2d6cd90376d 100644
--- a/include/chromeos/fmap.h
+++ b/include/chromeos/fmap.h
@@ -40,6 +40,7 @@ struct twostop_fmap {
struct fmap_firmware_entry readwrite_a;
struct fmap_firmware_entry readwrite_b;
+ u32 flash_base;
};
void dump_fmap(struct twostop_fmap *config);
diff --git a/lib/chromeos/fdt_decode.c b/lib/chromeos/fdt_decode.c
index 3be76643d29..f3ff3fe2e1f 100644
--- a/lib/chromeos/fdt_decode.c
+++ b/lib/chromeos/fdt_decode.c
@@ -125,6 +125,8 @@ int fdt_decode_twostop_fmap(const void *blob, struct twostop_fmap *config)
{
int fmap_offset;
int err;
+ uint32_t *property;
+ int length;
fmap_offset = fdt_node_offset_by_compatible(blob, -1,
"chromeos,flashmap");
@@ -132,6 +134,15 @@ int fdt_decode_twostop_fmap(const void *blob, struct twostop_fmap *config)
VBDEBUG(PREFIX "chromeos,flashmap node is missing\n");
return fmap_offset;
}
+
+ property = (uint32_t *)fdt_getprop(blob, fmap_offset, "reg", &length);
+ if (!property || (length != 8)) {
+ VBDEBUG(PREFIX "Flashmap node missing the `reg' property\n");
+ return -FDT_ERR_MISSING;
+ }
+
+ config->flash_base = fdt32_to_cpu(property[0]);
+
err = decode_firmware_entry(blob, fmap_offset, "rw-a",
&config->readwrite_a);
err |= decode_firmware_entry(blob, fmap_offset, "rw-b",