aboutsummaryrefslogtreecommitdiff
path: root/common/spl
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2022-09-30 15:52:10 -0400
committerTom Rini <trini@konsulko.com>2022-09-30 15:52:10 -0400
commit6ee6e15975cad3c99fad3a66223f3fd9287a369b (patch)
tree2a1798758c85d3010640cf6bacb1ad7caaa29133 /common/spl
parent01c88e3dcd667281cf3aa6f6b47f90900177aff9 (diff)
parentdb1ef1e12b993275e09f116ebc3d23d675c7e28c (diff)
Merge branch '2022-09-29-dm-core-support-multiple-device-trees-in-ofnode' into next
To quote the author: At present the ofnode interface is somewhat limited, in that it cannot access the device tree provided by the OS, only the one used by U-Boot itself (assuming these are separate). This prevents using ofnode functions to handle device tree fixups, i.e. ft_board_setup() and the like. The ofnode interface was introduced to allow a consistent API to access the device tree, whether a flat tree or a live tree (OF_LIVE) is in use. With the flat tree, adding nodes and properties at the start of the tree (as often happens when writing to the /chosen node) requires copying a lot of data for each operation. With live tree, such operations are quite a bit faster, since there is no memory copying required. This has to be weighed against the required memory allocation with OF_LIVE, as well as the cost of unflattening and flattening the device tree which U-Boot is running. This series enables support for access to multiple device trees with the ofnode interface. This is already available to some extent with OF_LIVE, but some of the ofnode functions need changes to allow the tree to be specified. The mechanism works by using the top 1-4 bits of the device tree offset. The sign bit is not affected, since negative values must be supported. With this implemented, it becomes possible to use the ofnode interface to do device tree fixups. The only current user is the EVT_FT_FIXUP event. This has two main benefits: - ofnode can now be used everywhere, in preference to the libfdt calls - live tree can eventually be used everywhere, with potential speed improvements when larger number of fixups are used This series is only a step along the way. Firstly, while it is possible to access the 'fix-up' tree using OF_LIVE, most of the fixup functions use flat tree directly, rather than the ofnode interface. These need to be updated. Also the tree must be flattened again before it is passed to the OS. This is not currently implemented. With OFNODE_MULTI_TREE disabled this has almost no effect on code size: around 4 bytes if EVENT is enabled, 0 if not. With the feature enabled, the increase is around 700 bytes, e.g. on venice2: $ buildman -b ofn2a venice2 -sS --step 0 Summary of 2 commits for 1 boards (1 thread, 64 jobs per thread) 01: image: Drop some other #ifdefs in image-board.c arm: w+ venice2 48: wip arm: (for 1/1 boards) all +668.0 text +668.0 This size increase is not too bad, considering the extra functionality, but is too large to enable everywhere. So for now this features needs to be opt-in only, based on EVENT.
Diffstat (limited to 'common/spl')
-rw-r--r--common/spl/spl.c10
-rw-r--r--common/spl/spl_ext.c4
-rw-r--r--common/spl/spl_fat.c6
-rw-r--r--common/spl/spl_legacy.c8
-rw-r--r--common/spl/spl_mmc.c4
-rw-r--r--common/spl/spl_nand.c4
-rw-r--r--common/spl/spl_net.c2
-rw-r--r--common/spl/spl_nor.c8
-rw-r--r--common/spl/spl_onenand.c2
-rw-r--r--common/spl/spl_ram.c8
-rw-r--r--common/spl/spl_sata.c2
-rw-r--r--common/spl/spl_semihosting.c4
-rw-r--r--common/spl/spl_spi.c6
-rw-r--r--common/spl/spl_ubi.c4
-rw-r--r--common/spl/spl_xip.c2
-rw-r--r--common/spl/spl_ymodem.c14
16 files changed, 44 insertions, 44 deletions
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 828f72f30b..752b5b247c 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -227,7 +227,7 @@ __weak void spl_board_prepare_for_boot(void)
/* Nothing to do! */
}
-__weak struct image_header *spl_get_load_buffer(ssize_t offset, size_t size)
+__weak struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size)
{
return map_sysmem(CONFIG_SYS_TEXT_BASE + offset, 0);
}
@@ -258,9 +258,9 @@ void spl_set_header_raw_uboot(struct spl_image_info *spl_image)
#if CONFIG_IS_ENABLED(LOAD_FIT_FULL)
/* Parse and load full fitImage in SPL */
static int spl_load_fit_image(struct spl_image_info *spl_image,
- const struct image_header *header)
+ const struct legacy_img_hdr *header)
{
- bootm_headers_t images;
+ struct bootm_headers images;
const char *fit_uname_config = NULL;
uintptr_t fdt_hack;
const char *uname;
@@ -359,7 +359,7 @@ __weak int spl_parse_board_header(struct spl_image_info *spl_image,
}
__weak int spl_parse_legacy_header(struct spl_image_info *spl_image,
- const struct image_header *header)
+ const struct legacy_img_hdr *header)
{
/* LEGACY image not supported */
debug("Legacy boot image support not enabled, proceeding to other boot methods\n");
@@ -368,7 +368,7 @@ __weak int spl_parse_legacy_header(struct spl_image_info *spl_image,
int spl_parse_image_header(struct spl_image_info *spl_image,
const struct spl_boot_device *bootdev,
- const struct image_header *header)
+ const struct legacy_img_hdr *header)
{
#if CONFIG_IS_ENABLED(LOAD_FIT_FULL)
int ret = spl_load_fit_image(spl_image, header);
diff --git a/common/spl/spl_ext.c b/common/spl/spl_ext.c
index ebd914c492..f117c630bf 100644
--- a/common/spl/spl_ext.c
+++ b/common/spl/spl_ext.c
@@ -15,7 +15,7 @@ int spl_load_image_ext(struct spl_image_info *spl_image,
const char *filename)
{
s32 err;
- struct image_header *header;
+ struct legacy_img_hdr *header;
loff_t filelen, actlen;
struct disk_partition part_info = {};
@@ -41,7 +41,7 @@ int spl_load_image_ext(struct spl_image_info *spl_image,
puts("spl: ext4fs_open failed\n");
goto end;
}
- err = ext4fs_read((char *)header, 0, sizeof(struct image_header), &actlen);
+ err = ext4fs_read((char *)header, 0, sizeof(struct legacy_img_hdr), &actlen);
if (err < 0) {
puts("spl: ext4fs_read failed\n");
goto end;
diff --git a/common/spl/spl_fat.c b/common/spl/spl_fat.c
index 5b270541fc..f8a5b80a3b 100644
--- a/common/spl/spl_fat.c
+++ b/common/spl/spl_fat.c
@@ -60,7 +60,7 @@ int spl_load_image_fat(struct spl_image_info *spl_image,
const char *filename)
{
int err;
- struct image_header *header;
+ struct legacy_img_hdr *header;
err = spl_register_fat_device(block_dev, partition);
if (err)
@@ -68,7 +68,7 @@ int spl_load_image_fat(struct spl_image_info *spl_image,
header = spl_get_load_buffer(-sizeof(*header), sizeof(*header));
- err = file_fat_read(filename, header, sizeof(struct image_header));
+ err = file_fat_read(filename, header, sizeof(struct legacy_img_hdr));
if (err <= 0)
goto end;
@@ -78,7 +78,7 @@ int spl_load_image_fat(struct spl_image_info *spl_image,
if (err <= 0)
goto end;
err = spl_parse_image_header(spl_image, bootdev,
- (struct image_header *)CONFIG_SYS_LOAD_ADDR);
+ (struct legacy_img_hdr *)CONFIG_SYS_LOAD_ADDR);
if (err == -EAGAIN)
return err;
if (err == 0)
diff --git a/common/spl/spl_legacy.c b/common/spl/spl_legacy.c
index ae8731c782..b3624dfbb7 100644
--- a/common/spl/spl_legacy.c
+++ b/common/spl/spl_legacy.c
@@ -16,9 +16,9 @@
#define LZMA_LEN (1 << 20)
int spl_parse_legacy_header(struct spl_image_info *spl_image,
- const struct image_header *header)
+ const struct legacy_img_hdr *header)
{
- u32 header_size = sizeof(struct image_header);
+ u32 header_size = sizeof(struct legacy_img_hdr);
/* check uImage header CRC */
if (IS_ENABLED(CONFIG_SPL_LEGACY_IMAGE_CRC_CHECK) &&
@@ -67,7 +67,7 @@ int spl_parse_legacy_header(struct spl_image_info *spl_image,
* following switch/case statement in spl_load_legacy_img() away due to
* Dead Code Elimination.
*/
-static inline int spl_image_get_comp(const struct image_header *hdr)
+static inline int spl_image_get_comp(const struct legacy_img_hdr *hdr)
{
if (IS_ENABLED(CONFIG_SPL_LZMA))
return image_get_comp(hdr);
@@ -81,7 +81,7 @@ int spl_load_legacy_img(struct spl_image_info *spl_image,
{
__maybe_unused SizeT lzma_len;
__maybe_unused void *src;
- struct image_header hdr;
+ struct legacy_img_hdr hdr;
ulong dataptr;
int ret;
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index 23a395e63d..e4135b2048 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -20,7 +20,7 @@
static int mmc_load_legacy(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev,
struct mmc *mmc,
- ulong sector, struct image_header *header)
+ ulong sector, struct legacy_img_hdr *header)
{
u32 image_offset_sectors;
u32 image_size_sectors;
@@ -83,7 +83,7 @@ int mmc_load_image_raw_sector(struct spl_image_info *spl_image,
struct mmc *mmc, unsigned long sector)
{
unsigned long count;
- struct image_header *header;
+ struct legacy_img_hdr *header;
struct blk_desc *bd = mmc_get_blk_desc(mmc);
int ret = 0;
diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c
index 7b7579a2df..a16738818c 100644
--- a/common/spl/spl_nand.c
+++ b/common/spl/spl_nand.c
@@ -78,7 +78,7 @@ struct mtd_info * __weak nand_get_mtd(void)
static int spl_nand_load_element(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev,
- int offset, struct image_header *header)
+ int offset, struct legacy_img_hdr *header)
{
struct mtd_info *mtd = nand_get_mtd();
int bl_len = mtd ? mtd->writesize : 1;
@@ -133,7 +133,7 @@ static int spl_nand_load_image(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev)
{
int err;
- struct image_header *header;
+ struct legacy_img_hdr *header;
int *src __attribute__((unused));
int *dst __attribute__((unused));
diff --git a/common/spl/spl_net.c b/common/spl/spl_net.c
index a853e6aead..b2c901b554 100644
--- a/common/spl/spl_net.c
+++ b/common/spl/spl_net.c
@@ -28,7 +28,7 @@ static ulong spl_net_load_read(struct spl_load_info *load, ulong sector,
static int spl_net_load_image(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev)
{
- struct image_header *header = (struct image_header *)image_load_addr;
+ struct legacy_img_hdr *header = (struct legacy_img_hdr *)image_load_addr;
int rv;
env_init();
diff --git a/common/spl/spl_nor.c b/common/spl/spl_nor.c
index 7986e930d2..281c6136f5 100644
--- a/common/spl/spl_nor.c
+++ b/common/spl/spl_nor.c
@@ -26,7 +26,7 @@ unsigned long __weak spl_nor_get_uboot_base(void)
static int spl_nor_load_image(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev)
{
- __maybe_unused const struct image_header *header;
+ __maybe_unused const struct legacy_img_hdr *header;
__maybe_unused struct spl_load_info load;
/*
@@ -41,7 +41,7 @@ static int spl_nor_load_image(struct spl_image_info *spl_image,
* Load Linux from its location in NOR flash to its defined
* location in SDRAM
*/
- header = (const struct image_header *)CONFIG_SYS_OS_BASE;
+ header = (const struct legacy_img_hdr *)CONFIG_SYS_OS_BASE;
#ifdef CONFIG_SPL_LOAD_FIT
if (image_get_magic(header) == FDT_MAGIC) {
int ret;
@@ -72,7 +72,7 @@ static int spl_nor_load_image(struct spl_image_info *spl_image,
memcpy((void *)spl_image->load_addr,
(void *)(CONFIG_SYS_OS_BASE +
- sizeof(struct image_header)),
+ sizeof(struct legacy_img_hdr)),
spl_image->size);
#ifdef CONFIG_SYS_SPL_ARGS_ADDR
spl_image->arg = (void *)CONFIG_SYS_SPL_ARGS_ADDR;
@@ -92,7 +92,7 @@ static int spl_nor_load_image(struct spl_image_info *spl_image,
* defined location in SDRAM
*/
#ifdef CONFIG_SPL_LOAD_FIT
- header = (const struct image_header *)spl_nor_get_uboot_base();
+ header = (const struct legacy_img_hdr *)spl_nor_get_uboot_base();
if (image_get_magic(header) == FDT_MAGIC) {
debug("Found FIT format U-Boot\n");
load.bl_len = 1;
diff --git a/common/spl/spl_onenand.c b/common/spl/spl_onenand.c
index f80769a027..53a8c6de89 100644
--- a/common/spl/spl_onenand.c
+++ b/common/spl/spl_onenand.c
@@ -18,7 +18,7 @@
static int spl_onenand_load_image(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev)
{
- struct image_header *header;
+ struct legacy_img_hdr *header;
int ret;
debug("spl: onenand\n");
diff --git a/common/spl/spl_ram.c b/common/spl/spl_ram.c
index d64710878c..2b1ac19152 100644
--- a/common/spl/spl_ram.c
+++ b/common/spl/spl_ram.c
@@ -41,9 +41,9 @@ static ulong spl_ram_load_read(struct spl_load_info *load, ulong sector,
static int spl_ram_load_image(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev)
{
- struct image_header *header;
+ struct legacy_img_hdr *header;
- header = (struct image_header *)CONFIG_SPL_LOAD_FIT_ADDRESS;
+ header = (struct legacy_img_hdr *)CONFIG_SPL_LOAD_FIT_ADDRESS;
if (CONFIG_IS_ENABLED(IMAGE_PRE_LOAD)) {
unsigned long addr = (unsigned long)header;
@@ -53,7 +53,7 @@ static int spl_ram_load_image(struct spl_image_info *spl_image,
return ret;
addr += image_load_offset;
- header = (struct image_header *)addr;
+ header = (struct legacy_img_hdr *)addr;
}
#if CONFIG_IS_ENABLED(DFU)
@@ -87,7 +87,7 @@ static int spl_ram_load_image(struct spl_image_info *spl_image,
u_boot_pos = (ulong)spl_get_load_buffer(-sizeof(*header),
sizeof(*header));
}
- header = (struct image_header *)map_sysmem(u_boot_pos, 0);
+ header = (struct legacy_img_hdr *)map_sysmem(u_boot_pos, 0);
spl_parse_image_header(spl_image, bootdev, header);
}
diff --git a/common/spl/spl_sata.c b/common/spl/spl_sata.c
index 6c36f2ca66..9ae0273068 100644
--- a/common/spl/spl_sata.c
+++ b/common/spl/spl_sata.c
@@ -30,7 +30,7 @@ static int spl_sata_load_image_raw(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev,
struct blk_desc *stor_dev, unsigned long sector)
{
- struct image_header *header;
+ struct legacy_img_hdr *header;
unsigned long count;
u32 image_size_sectors;
u32 image_offset_sectors;
diff --git a/common/spl/spl_semihosting.c b/common/spl/spl_semihosting.c
index df6aeb2951..5b5e842a11 100644
--- a/common/spl/spl_semihosting.c
+++ b/common/spl/spl_semihosting.c
@@ -27,7 +27,7 @@ static int spl_smh_load_image(struct spl_image_info *spl_image,
const char *filename = CONFIG_SPL_FS_LOAD_PAYLOAD_NAME;
int ret;
long fd, len;
- struct image_header *header =
+ struct legacy_img_hdr *header =
spl_get_load_buffer(-sizeof(*header), sizeof(*header));
fd = smh_open(filename, MODE_READ | MODE_BINARY);
@@ -43,7 +43,7 @@ static int spl_smh_load_image(struct spl_image_info *spl_image,
}
len = ret;
- ret = smh_read_full(fd, header, sizeof(struct image_header));
+ ret = smh_read_full(fd, header, sizeof(struct legacy_img_hdr));
if (ret) {
log_debug("could not read image header: %d\n", ret);
goto out;
diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c
index d959ad1145..da6742416e 100644
--- a/common/spl/spl_spi.c
+++ b/common/spl/spl_spi.c
@@ -26,7 +26,7 @@
static int spi_load_image_os(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev,
struct spi_flash *flash,
- struct image_header *header)
+ struct legacy_img_hdr *header)
{
int err;
@@ -92,7 +92,7 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
int err = 0;
unsigned int payload_offs;
struct spi_flash *flash;
- struct image_header *header;
+ struct legacy_img_hdr *header;
unsigned int sf_bus = spl_spi_boot_bus();
unsigned int sf_cs = spl_spi_boot_cs();
@@ -139,7 +139,7 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
if (err)
return err;
err = spl_parse_image_header(spl_image, bootdev,
- (struct image_header *)CONFIG_SYS_LOAD_ADDR);
+ (struct legacy_img_hdr *)CONFIG_SYS_LOAD_ADDR);
} else if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
image_get_magic(header) == FDT_MAGIC) {
struct spl_load_info load;
diff --git a/common/spl/spl_ubi.c b/common/spl/spl_ubi.c
index bdf5cc4c38..fb804f0208 100644
--- a/common/spl/spl_ubi.c
+++ b/common/spl/spl_ubi.c
@@ -15,7 +15,7 @@
int spl_ubi_load_image(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev)
{
- struct image_header *header;
+ struct legacy_img_hdr *header;
struct ubispl_info info;
struct ubispl_load volumes[2];
int ret = 1;
@@ -54,7 +54,7 @@ int spl_ubi_load_image(struct spl_image_info *spl_image,
ret = ubispl_load_volumes(&info, volumes, 2);
if (!ret) {
- header = (struct image_header *)volumes[0].load_addr;
+ header = (struct legacy_img_hdr *)volumes[0].load_addr;
spl_parse_image_header(spl_image, bootdev, header);
puts("Linux loaded.\n");
goto out;
diff --git a/common/spl/spl_xip.c b/common/spl/spl_xip.c
index e9a40b0ec7..1258d85e63 100644
--- a/common/spl/spl_xip.c
+++ b/common/spl/spl_xip.c
@@ -25,6 +25,6 @@ static int spl_xip(struct spl_image_info *spl_image,
}
#endif
return(spl_parse_image_header(spl_image, bootdev,
- (const struct image_header *)CONFIG_SYS_UBOOT_BASE));
+ (const struct legacy_img_hdr *)CONFIG_SYS_UBOOT_BASE));
}
SPL_LOAD_IMAGE_METHOD("XIP", 0, BOOT_DEVICE_XIP, spl_xip);
diff --git a/common/spl/spl_ymodem.c b/common/spl/spl_ymodem.c
index fdd5261042..038b443845 100644
--- a/common/spl/spl_ymodem.c
+++ b/common/spl/spl_ymodem.c
@@ -96,7 +96,7 @@ int spl_ymodem_load_image(struct spl_image_info *spl_image,
int ret;
connection_info_t info;
char buf[BUF_SIZE];
- struct image_header *ih = NULL;
+ struct legacy_img_hdr *ih = NULL;
ulong addr = 0;
info.mode = xyzModem_ymodem;
@@ -111,9 +111,9 @@ int spl_ymodem_load_image(struct spl_image_info *spl_image,
goto end_stream;
if (IS_ENABLED(CONFIG_SPL_LOAD_FIT_FULL) &&
- image_get_magic((struct image_header *)buf) == FDT_MAGIC) {
+ image_get_magic((struct legacy_img_hdr *)buf) == FDT_MAGIC) {
addr = CONFIG_SYS_LOAD_ADDR;
- ih = (struct image_header *)addr;
+ ih = (struct legacy_img_hdr *)addr;
memcpy((void *)addr, buf, res);
size += res;
@@ -129,7 +129,7 @@ int spl_ymodem_load_image(struct spl_image_info *spl_image,
if (ret)
return ret;
} else if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
- image_get_magic((struct image_header *)buf) == FDT_MAGIC) {
+ image_get_magic((struct legacy_img_hdr *)buf) == FDT_MAGIC) {
struct spl_load_info load;
struct ymodem_fit_info info;
@@ -147,7 +147,7 @@ int spl_ymodem_load_image(struct spl_image_info *spl_image,
while ((res = xyzModem_stream_read(buf, BUF_SIZE, &err)) > 0)
size += res;
} else {
- ih = (struct image_header *)buf;
+ ih = (struct legacy_img_hdr *)buf;
ret = spl_parse_image_header(spl_image, bootdev, ih);
if (ret)
goto end_stream;
@@ -158,7 +158,7 @@ int spl_ymodem_load_image(struct spl_image_info *spl_image,
#endif
addr = spl_image->load_addr;
memcpy((void *)addr, buf, res);
- ih = (struct image_header *)addr;
+ ih = (struct legacy_img_hdr *)addr;
size += res;
addr += res;
@@ -177,7 +177,7 @@ end_stream:
#ifdef CONFIG_SPL_GZIP
if (!(IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
- image_get_magic((struct image_header *)buf) == FDT_MAGIC) &&
+ image_get_magic((struct legacy_img_hdr *)buf) == FDT_MAGIC) &&
(ih->ih_comp == IH_COMP_GZIP)) {
if (gunzip((void *)(spl_image->load_addr + sizeof(*ih)),
CONFIG_SYS_BOOTM_LEN,