summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/cmd_vbexport_test.c10
-rw-r--r--common/cmd_vboot_twostop.c73
-rw-r--r--include/chromeos/fdt_decode.h17
-rw-r--r--lib/chromeos/boot_kernel.c17
-rw-r--r--lib/chromeos/fdt_decode.c12
5 files changed, 96 insertions, 33 deletions
diff --git a/common/cmd_vbexport_test.c b/common/cmd_vbexport_test.c
index fc198e96df..b2cb5aa87f 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 265692eff4..0088e72fef 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
diff --git a/include/chromeos/fdt_decode.h b/include/chromeos/fdt_decode.h
index dcb98cbbf1..96def9a1e9 100644
--- a/include/chromeos/fdt_decode.h
+++ b/include/chromeos/fdt_decode.h
@@ -26,4 +26,21 @@ int fdt_decode_twostop_fmap(const void *fdt, struct twostop_fmap *config);
*/
int fdt_decode_chromeos_config_has_prop(const void *fdt, const char *name);
+/**
+ * Look up a property in chromeos-config which contains a memory region
+ * address and size. Then return a pointer to this address. if the address
+ * is zero, it is allocated with malloc() instead.
+ *
+ * The property must hold one address with a length. This is only tested on
+ * 32-bit machines.
+ *
+ * @param blob FDT blob
+ * @param node node to examine
+ * @param prop_name name of property to find
+ * @param size returns size of region
+ * @return pointer to region, or NULL if property not found/malloc failed
+ */
+void *fdt_decode_chromeos_alloc_region(const void *blob,
+ const char *prop_name, size_t *size);
+
#endif /* CHROMEOS_FDT_DECODE_H_ */
diff --git a/lib/chromeos/boot_kernel.c b/lib/chromeos/boot_kernel.c
index 4fb08ee67b..2012bea6f3 100644
--- a/lib/chromeos/boot_kernel.c
+++ b/lib/chromeos/boot_kernel.c
@@ -200,17 +200,6 @@ static int update_cmdline(char *src, int devnum, int partnum, uint8_t *guid,
return 0;
}
-/* TODO Copy from tegra2-common.h so that coreboot can be built */
-#ifndef QUOTE
-/*
- * QUOTE(m) will evaluate to a string version of the value of the macro m
- * passed in. The extra level of indirection here is to first evaluate the
- * macro m before applying the quoting operator.
- */
-#define QUOTE_(m) #m
-#define QUOTE(m) QUOTE_(m)
-#endif
-
int boot_kernel(VbSelectAndLoadKernelParams *kparams, crossystem_data_t *cdata)
{
/* sizeof(CHROMEOS_BOOTARGS) reserves extra 1 byte */
@@ -223,9 +212,11 @@ int boot_kernel(VbSelectAndLoadKernelParams *kparams, crossystem_data_t *cdata)
struct boot_params *params;
#else
/* Chrome OS kernel has to be loaded at fixed location */
- char *argv[] = { "bootm", QUOTE(CHROMEOS_KERNEL_LOADADDR) };
+ char address[20];
+ char *argv[] = { "bootm", address };
+
+ sprintf(address, "%p", kparams->kernel_buffer);
#endif
- assert(kparams->kernel_buffer == (void *)CHROMEOS_KERNEL_LOADADDR);
strcpy(cmdline_buf, CHROMEOS_BOOTARGS);
diff --git a/lib/chromeos/fdt_decode.c b/lib/chromeos/fdt_decode.c
index 9c42364209..203b10605e 100644
--- a/lib/chromeos/fdt_decode.c
+++ b/lib/chromeos/fdt_decode.c
@@ -13,6 +13,7 @@
#include <chromeos/common.h>
#include <chromeos/fdt_decode.h>
#include <chromeos/fmap.h>
+#include <fdt_decode.h>
#include <linux/string.h>
#define PREFIX "chromeos/fdt_decode: "
@@ -150,3 +151,14 @@ int fdt_decode_chromeos_config_has_prop(const void *blob, const char *name)
return fdt_get_property(blob, nodeoffset, name, &len) != NULL;
}
+
+void *fdt_decode_chromeos_alloc_region(const void *blob,
+ const char *prop_name, size_t *size)
+{
+ int node = fdt_path_offset(blob, "/chromeos-config");
+
+ if (node < 0)
+ return NULL;
+
+ return fdt_decode_alloc_region(blob, node, prop_name, size);
+}