u-boot/common/spl/spl_onenand.c
Marek Vasut 04ce5427bd spl: Weed out CONFIG_SYS_TEXT_BASE usage
The SPL loaders assume that the CONFIG_SYS_TEXT_BASE memory location
is available and can be corrupted by loading ie. uImage or fitImage
headers there. Sometimes it could be beneficial to load the headers
elsewhere, ie. if CONFIG_SYS_TEXT_BASE is not yet writable while we
still want to parse the image headers in some local onchip memory to
ie. extract firmware from that image.

Add the possibility to override the location where the headers get
loaded by introducing new function, spl_get_load_buffer() which takes
two arguments -- offset from the CONFIG_SYS_TEXT_BASE and size of the
data that are to be loaded there -- and returns a valid buffer address
or hangs the system. The default behavior is the same as before, add
the offset to CONFIG_SYS_TEXT_BASE and return that address. User can
override the weak spl_get_load_buffer() function though.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
2018-09-25 21:48:43 -04:00

38 lines
1 KiB
C

// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2013
* ISEE 2007 SL - Enric Balletbo i Serra <eballetbo@iseebcn.com>
*
* Based on common/spl/spl_nand.c
* Copyright (C) 2011
* Corscience GmbH & Co. KG - Simon Schwarz <schwarz@corscience.de>
*/
#include <common.h>
#include <config.h>
#include <spl.h>
#include <asm/io.h>
#include <onenand_uboot.h>
static int spl_onenand_load_image(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev)
{
struct image_header *header;
int ret;
debug("spl: onenand\n");
header = spl_get_load_buffer(0, CONFIG_SYS_ONENAND_PAGE_SIZE);
/* Load u-boot */
onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS,
CONFIG_SYS_ONENAND_PAGE_SIZE, (void *)header);
ret = spl_parse_image_header(spl_image, header);
if (ret)
return ret;
onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS,
spl_image->size, (void *)spl_image->load_addr);
return 0;
}
/* Use priorty 1 so that Ubi can override this */
SPL_LOAD_IMAGE_METHOD("OneNAND", 1, BOOT_DEVICE_ONENAND,
spl_onenand_load_image);