diff options
author | Simon Glass <sjg@chromium.org> | 2011-08-22 08:15:25 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2011-09-19 13:45:37 -0700 |
commit | 4fa99eb575d56552ae9a1252f56e0475e3848d53 (patch) | |
tree | 3a1cf082c7de319eb2383583d958cbf2ca4aac2d /common | |
parent | 2c49ec7f1be4ec51c39747805897f78626134470 (diff) |
fdt: Move Chrome OS memory areas to fdt
This moves the last remaining hard-coded CONFIG to the fdt.
BUG=chromium-os:17062
TEST=build for Seaboard
Change-Id: Ic152ce12a0f87211e4cc98eef15601f0703137b1
Reviewed-on: http://gerrit.chromium.org/gerrit/7642
Tested-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Che-Liang Chiou <clchiou@chromium.org>
Reviewed-by: Anton Staaf <robotboy@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/cmd_vbexport_test.c | 10 | ||||
-rw-r--r-- | common/cmd_vboot_twostop.c | 73 |
2 files changed, 63 insertions, 20 deletions
diff --git a/common/cmd_vbexport_test.c b/common/cmd_vbexport_test.c index fc198e96df6..b2cb5aa87fb 100644 --- a/common/cmd_vbexport_test.c +++ b/common/cmd_vbexport_test.c @@ -402,7 +402,15 @@ static uint8_t *read_gbb_from_firmware(void) void *fdt_ptr = (void *)gd->blob; firmware_storage_t file; struct twostop_fmap fmap; - void *gbb = (void *)GBB_ADDRESS; + void *gbb; + size_t size; + + gbb = fdt_decode_chromeos_alloc_region(gd->blob, + "google-binary-block", &size); + if (!gbb) { + VbExDebug("Failed to find gbb region!\n"); + return NULL; + } if (fdt_decode_twostop_fmap(fdt_ptr, &fmap)) { VbExDebug("Failed to load fmap config from fdt!\n"); diff --git a/common/cmd_vboot_twostop.c b/common/cmd_vboot_twostop.c index 265692eff42..0088e72fef3 100644 --- a/common/cmd_vboot_twostop.c +++ b/common/cmd_vboot_twostop.c @@ -524,6 +524,7 @@ twostop_main_firmware(struct twostop_fmap *fmap, void *gbb, VbError_t err; VbSelectAndLoadKernelParams kparams; VbCommonParams cparams; + size_t size; bootstage_mark(BOOTSTAGE_VBOOT_TWOSTOP_MAIN_FIRMWARE, "twostop_main_firmware"); @@ -532,8 +533,9 @@ twostop_main_firmware(struct twostop_fmap *fmap, void *gbb, return VB_SELECT_ERROR; } - kparams.kernel_buffer = (void *)CHROMEOS_KERNEL_LOADADDR; - kparams.kernel_buffer_size = CHROMEOS_KERNEL_BUFSIZE; + kparams.kernel_buffer = fdt_decode_chromeos_alloc_region(gd->blob, + "kernel", &size); + kparams.kernel_buffer_size = size; VBDEBUG(PREFIX "kparams:\n"); VBDEBUG(PREFIX "- kernel_buffer: : %p\n", kparams.kernel_buffer); @@ -571,19 +573,62 @@ twostop_main_firmware(struct twostop_fmap *fmap, void *gbb, return VB_SELECT_ERROR; } +/** + * Get address of the gbb and cdata, and optionally verify them. + * + * @param gbb returns pointer to GBB + * @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 + */ +static int setup_gbb_and_cdata(void **gbb, crossystem_data_t **cdata, + int verify) +{ + size_t size; + + *gbb = fdt_decode_chromeos_alloc_region(gd->blob, + "google-binary-block", &size); + *cdata = fdt_decode_chromeos_alloc_region(gd->blob, "cros-system-data", + &size); + if (!*gbb || !*cdata) { + VBDEBUG(PREFIX "google-binary-block/cros-system-data missing " + "from fdt, or malloc failed\n"); + return -1; + } + + /* + * TODO(clchiou): readwrite firmware should check version of the data + * blobs + */ + if (verify && crossystem_data_check_integrity(*cdata)) { + VBDEBUG(PREFIX "invalid crossystem data\n"); + return -1; + } + + if (verify && gbb_check_integrity(*gbb)) { + VBDEBUG(PREFIX "invalid gbb\n"); + return -1; + } + return 0; +} + static uint32_t twostop_boot(void) { struct twostop_fmap fmap; firmware_storage_t file; - crossystem_data_t *cdata = (crossystem_data_t *)CROSSYSTEM_DATA_ADDRESS; - void *gbb = (void *)GBB_ADDRESS; - void *vb_shared_data = cdata->vb_shared_data; + crossystem_data_t *cdata; + void *gbb; + void *vb_shared_data; void *fw_blob = NULL; uint32_t fw_size = 0; uint32_t selection; int boot_mode = FIRMWARE_TYPE_NORMAL; + if (setup_gbb_and_cdata(&gbb, &cdata, 0)) + return VB_SELECT_ERROR; + + vb_shared_data = cdata->vb_shared_data; if (twostop_init(&fmap, &file, gbb, cdata, vb_shared_data)) { VBDEBUG(PREFIX "failed to init twostop boot\n"); return VB_SELECT_ERROR; @@ -632,21 +677,11 @@ static uint32_t twostop_readwrite_main_firmware(void) { struct twostop_fmap fmap; - crossystem_data_t *cdata = (crossystem_data_t *)CROSSYSTEM_DATA_ADDRESS; - void *gbb = (void *)GBB_ADDRESS; - void *vb_shared_data = cdata->vb_shared_data; - - /* Newer readwrite firmware should check version of the data blobs */ + crossystem_data_t *cdata; + void *gbb; - if (crossystem_data_check_integrity(cdata)) { - VBDEBUG(PREFIX "invalid crossystem data\n"); - return VB_SELECT_ERROR; - } - - if (gbb_check_integrity(gbb)) { - VBDEBUG(PREFIX "invalid gbb\n"); + 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"); @@ -668,7 +703,7 @@ twostop_readwrite_main_firmware(void) /* TODO Now, initialize device that bootstub did not initialize */ - return twostop_main_firmware(&fmap, gbb, cdata, vb_shared_data); + return twostop_main_firmware(&fmap, gbb, cdata, cdata->vb_shared_data); } static int |