diff options
author | Tom Wai-Hong Tam <waihong@chromium.org> | 2011-07-07 17:42:28 +0800 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2011-08-29 10:58:49 -0700 |
commit | 398d356b89b1677ccb342ccd91bbb46d10606644 (patch) | |
tree | 4ba78d75df0a020ac0583491bc1875aa082056cf | |
parent | 48fa3efa80ce7e0f556e918ece960fc8417b1de1 (diff) |
CHROMIUM: Separate the pre-boot FDT update part from load_kernel_helper library.
load_kernel_helper depends on old VBoot APIs. Make the pre-boot FDT update
part separted such that the new VBoot logic can reuse it.
BUG=chromium-os:17303
TEST=build chromeos_seaboard_onestop and chromeos_seaboard_vboot without error
Change-Id: I9d15b3074d8ee981cead2cf6b8b2aff2be4e4846
Reviewed-on: http://gerrit.chromium.org/gerrit/3841
Reviewed-by: Tom Wai-Hong Tam <waihong@chromium.org>
Tested-by: Tom Wai-Hong Tam <waihong@chromium.org>
-rw-r--r-- | include/chromeos/preboot_fdt_update.h | 29 | ||||
-rw-r--r-- | lib/chromeos/Makefile | 1 | ||||
-rw-r--r-- | lib/chromeos/load_kernel_helper.c | 27 | ||||
-rw-r--r-- | lib/chromeos/preboot_fdt_update.c | 44 |
4 files changed, 76 insertions, 25 deletions
diff --git a/include/chromeos/preboot_fdt_update.h b/include/chromeos/preboot_fdt_update.h new file mode 100644 index 0000000000..44510945d3 --- /dev/null +++ b/include/chromeos/preboot_fdt_update.h @@ -0,0 +1,29 @@ +/* + * 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. + */ + +/* + * This library does the last chance FDT update before booting to kernel. + * Currently we modify the FDT by embedding crossystem data. So before + * calling bootm(), set_crossystem_data() should be called. + */ + +#ifndef CHROMEOS_PREBOOT_FDT_UPDATE_H_ +#define CHROMEOS_PREBOOT_FDT_UPDATE_H_ + +#include <chromeos/crossystem_data.h> +#include <linux/types.h> + +/* Set the crossystem data pointer. It must be done before booting to kernel */ +void set_crossystem_data(crossystem_data_t *cdata); + +/* Update FDT. This function is called just before booting to kernel. */ +int fit_update_fdt_before_boot(char *fdt, ulong *new_size); + +#endif /* CHROMEOS_PREBOOT_FDT_UPDATE_H_ */ diff --git a/lib/chromeos/Makefile b/lib/chromeos/Makefile index f49cae40ba..00021dc9f6 100644 --- a/lib/chromeos/Makefile +++ b/lib/chromeos/Makefile @@ -20,6 +20,7 @@ COBJS-$(CONFIG_CHROMEOS) += firmware_storage_spi.o COBJS-$(CONFIG_CHROMEOS) += load_kernel_helper.o COBJS-$(CONFIG_CHROMEOS) += onestop.o COBJS-$(CONFIG_CHROMEOS) += os_storage.o +COBJS-$(CONFIG_CHROMEOS) += preboot_fdt_update.o COBJS-$(CONFIG_CHROMEOS) += tlcl_stub.o COBJS-$(CONFIG_CHROMEOS) += utility.o COBJS-$(CONFIG_CHROMEOS) += vboot_nvstorage_helper.o diff --git a/lib/chromeos/load_kernel_helper.c b/lib/chromeos/load_kernel_helper.c index e1e99070c9..78c6ba2859 100644 --- a/lib/chromeos/load_kernel_helper.c +++ b/lib/chromeos/load_kernel_helper.c @@ -12,6 +12,7 @@ #include <chromeos/common.h> #include <chromeos/crossystem_data.h> #include <chromeos/load_kernel_helper.h> +#include <chromeos/preboot_fdt_update.h> #include <chromeos/os_storage.h> #include <chromeos/vboot_nvstorage_helper.h> @@ -19,12 +20,6 @@ #define PREFIX "load_kernel_helper: " -/* - * boot_kernel_helper() uses a static global variable to communicate with - * fit_update_fdt_before_boot(). For more information, please see commit log. - */ -static crossystem_data_t *g_crossystem_data = NULL; - /* defined in common/cmd_bootm.c */ int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); @@ -298,7 +293,7 @@ static int boot_kernel_helper(struct os_storage *oss, LoadKernelParams *params, return LOAD_KERNEL_INVALID; } - g_crossystem_data = cdata; + set_crossystem_data(cdata); sprintf(load_address, "0x%p", params->kernel_buffer); do_bootm(NULL, 0, sizeof(argv)/sizeof(*argv), argv); @@ -334,21 +329,3 @@ int boot_kernel(struct os_storage *oss, uint64_t boot_flags, return status; } - -int fit_update_fdt_before_boot(char *fdt, ulong *new_size) -{ - uint32_t ns; - - if (!g_crossystem_data) { - VBDEBUG(PREFIX "warning: g_crossystem_data is NULL\n"); - return 1; - } - - if (crossystem_data_embed_into_fdt(g_crossystem_data, fdt, &ns)) { - VBDEBUG(PREFIX "crossystem_data_embed_into_fdt() failed\n"); - return 1; - } - - *new_size = ns; - return 0; -} diff --git a/lib/chromeos/preboot_fdt_update.c b/lib/chromeos/preboot_fdt_update.c new file mode 100644 index 0000000000..5780d45d36 --- /dev/null +++ b/lib/chromeos/preboot_fdt_update.c @@ -0,0 +1,44 @@ +/* + * 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/crossystem_data.h> + +#define PREFIX "preboot_fdt_update: " + +/* + * We uses a static variable to communicate with fit_update_fdt_before_boot(). + * For more information, please see commit log. + */ +static crossystem_data_t *g_crossystem_data = NULL; + +void set_crossystem_data(crossystem_data_t *cdata) +{ + g_crossystem_data = cdata; +} + +int fit_update_fdt_before_boot(char *fdt, ulong *new_size) +{ + uint32_t ns; + + if (!g_crossystem_data) { + VBDEBUG(PREFIX "warning: g_crossystem_data is NULL\n"); + return 1; + } + + if (crossystem_data_embed_into_fdt(g_crossystem_data, fdt, &ns)) { + VBDEBUG(PREFIX "crossystem_data_embed_into_fdt() failed\n"); + return 1; + } + + *new_size = ns; + return 0; +} |