summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/Kconfig2
-rw-r--r--common/board_f.c2
-rw-r--r--common/board_r.c1
-rw-r--r--common/bootstage.c53
-rw-r--r--common/fdt_support.c2
-rw-r--r--common/spl/Kconfig8
-rw-r--r--common/spl/spl.c23
-rw-r--r--common/spl/spl_nor.c5
-rw-r--r--common/splash.c4
9 files changed, 73 insertions, 27 deletions
diff --git a/common/Kconfig b/common/Kconfig
index 28d5e9a0cc..d9ecf79e0a 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -764,7 +764,7 @@ config SPL_LOG_CONSOLE
line number are omitted.
config TPL_LOG_CONSOLE
- bool "Allow log output to the console in SPL"
+ bool "Allow log output to the console in TPL"
depends on TPL_LOG
default y
help
diff --git a/common/board_f.c b/common/board_f.c
index 591f18f391..e3591cbaeb 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -588,6 +588,7 @@ static int reserve_stacks(void)
static int reserve_bloblist(void)
{
#ifdef CONFIG_BLOBLIST
+ gd->start_addr_sp &= ~0xf;
gd->start_addr_sp -= CONFIG_BLOBLIST_SIZE;
gd->new_bloblist = map_sysmem(gd->start_addr_sp, CONFIG_BLOBLIST_SIZE);
#endif
@@ -695,6 +696,7 @@ static int reloc_bootstage(void)
gd->bootstage, gd->new_bootstage, size);
memcpy(gd->new_bootstage, gd->bootstage, size);
gd->bootstage = gd->new_bootstage;
+ bootstage_relocate();
}
#endif
diff --git a/common/board_r.c b/common/board_r.c
index d6fb5047a2..c1ecb06b74 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -670,7 +670,6 @@ static init_fnc_t init_sequence_r[] = {
#ifdef CONFIG_SYS_NONCACHED_MEMORY
initr_noncached,
#endif
- bootstage_relocate,
#ifdef CONFIG_OF_LIVE
initr_of_live,
#endif
diff --git a/common/bootstage.c b/common/bootstage.c
index 56ef91ad85..e8b7bbf81a 100644
--- a/common/bootstage.c
+++ b/common/bootstage.c
@@ -10,9 +10,10 @@
*/
#include <common.h>
-#include <linux/libfdt.h>
#include <malloc.h>
+#include <spl.h>
#include <linux/compiler.h>
+#include <linux/libfdt.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -41,24 +42,34 @@ enum {
};
struct bootstage_hdr {
- uint32_t version; /* BOOTSTAGE_VERSION */
- uint32_t count; /* Number of records */
- uint32_t size; /* Total data size (non-zero if valid) */
- uint32_t magic; /* Unused */
+ u32 version; /* BOOTSTAGE_VERSION */
+ u32 count; /* Number of records */
+ u32 size; /* Total data size (non-zero if valid) */
+ u32 magic; /* Magic number */
+ u32 next_id; /* Next ID to use for bootstage */
};
int bootstage_relocate(void)
{
struct bootstage_data *data = gd->bootstage;
int i;
+ char *ptr;
+
+ /* Figure out where to relocate the strings to */
+ ptr = (char *)(data + 1);
/*
* Duplicate all strings. They may point to an old location in the
* program .text section that can eventually get trashed.
*/
debug("Relocating %d records\n", data->rec_count);
- for (i = 0; i < data->rec_count; i++)
- data->record[i].name = strdup(data->record[i].name);
+ for (i = 0; i < data->rec_count; i++) {
+ const char *from = data->record[i].name;
+
+ strcpy(ptr, from);
+ data->record[i].name = ptr;
+ ptr += strlen(ptr) + 1;
+ }
return 0;
}
@@ -372,7 +383,6 @@ int bootstage_stash(void *base, int size)
const struct bootstage_record *rec;
char buf[20];
char *ptr = base, *end = ptr + size;
- uint32_t count;
int i;
if (hdr + 1 > (struct bootstage_hdr *)end) {
@@ -383,21 +393,15 @@ int bootstage_stash(void *base, int size)
/* Write an arbitrary version number */
hdr->version = BOOTSTAGE_VERSION;
- /* Count the number of records, and write that value first */
- for (rec = data->record, i = count = 0; i < data->rec_count;
- i++, rec++) {
- if (rec->id != 0)
- count++;
- }
- hdr->count = count;
+ hdr->count = data->rec_count;
hdr->size = 0;
hdr->magic = BOOTSTAGE_MAGIC;
+ hdr->next_id = data->next_id;
ptr += sizeof(*hdr);
/* Write the records, silently stopping when we run out of space */
- for (rec = data->record, i = 0; i < data->rec_count; i++, rec++) {
+ for (rec = data->record, i = 0; i < data->rec_count; i++, rec++)
append_data(&ptr, end, rec, sizeof(*rec));
- }
/* Write the name strings */
for (rec = data->record, i = 0; i < data->rec_count; i++, rec++) {
@@ -478,6 +482,8 @@ int bootstage_unstash(const void *base, int size)
for (rec = data->record + data->next_id, i = 0; i < hdr->count;
i++, rec++) {
rec->name = ptr;
+ if (spl_phase() == PHASE_SPL)
+ rec->name = strdup(ptr);
/* Assume no data corruption here */
ptr += strlen(ptr) + 1;
@@ -485,6 +491,7 @@ int bootstage_unstash(const void *base, int size)
/* Mark the records as read */
data->rec_count += hdr->count;
+ data->next_id = hdr->next_id;
debug("Unstashed %d records\n", hdr->count);
return 0;
@@ -492,7 +499,17 @@ int bootstage_unstash(const void *base, int size)
int bootstage_get_size(void)
{
- return sizeof(struct bootstage_data);
+ struct bootstage_data *data = gd->bootstage;
+ struct bootstage_record *rec;
+ int size;
+ int i;
+
+ size = sizeof(struct bootstage_data);
+ for (rec = data->record, i = 0; i < data->rec_count;
+ i++, rec++)
+ size += strlen(rec->name) + 1;
+
+ return size;
}
int bootstage_init(bool first)
diff --git a/common/fdt_support.c b/common/fdt_support.c
index baf7924ff6..6834399039 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -1566,7 +1566,7 @@ static int fdt_read_prop(const fdt32_t *prop, int prop_len, int cell_off,
uint64_t *val, int cells)
{
const fdt32_t *prop32 = &prop[cell_off];
- const fdt64_t *prop64 = (const fdt64_t *)&prop[cell_off];
+ const unaligned_fdt64_t *prop64 = (const fdt64_t *)&prop[cell_off];
if ((cell_off + cells) > prop_len)
return -FDT_ERR_NOSPACE;
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 86d7edfee1..c661809923 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -1232,6 +1232,14 @@ config TPL
if TPL
+config TPL_SIZE_LIMIT
+ hex "Maximum size of TPL image"
+ depends on TPL
+ default 0
+ help
+ Specifies the maximum length of the U-Boot TPL image.
+ If this value is zero, it is ignored.
+
config TPL_HANDOFF
bool "Pass hand-off information from TPL to SPL and U-Boot proper"
depends on HANDOFF && TPL_BLOBLIST
diff --git a/common/spl/spl.c b/common/spl/spl.c
index a9d3e847af..f1ad8dc9da 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -18,6 +18,7 @@
#include <version.h>
#include <image.h>
#include <malloc.h>
+#include <mapmem.h>
#include <dm/root.h>
#include <linux/compiler.h>
#include <fdt_support.h>
@@ -396,13 +397,25 @@ static int spl_common_init(bool setup_malloc)
gd->malloc_ptr = 0;
}
#endif
- ret = bootstage_init(true);
+ ret = bootstage_init(u_boot_first_phase());
if (ret) {
debug("%s: Failed to set up bootstage: ret=%d\n", __func__,
ret);
return ret;
}
- bootstage_mark_name(BOOTSTAGE_ID_START_SPL, "spl");
+#ifdef CONFIG_BOOTSTAGE_STASH
+ if (!u_boot_first_phase()) {
+ const void *stash = map_sysmem(CONFIG_BOOTSTAGE_STASH_ADDR,
+ CONFIG_BOOTSTAGE_STASH_SIZE);
+
+ ret = bootstage_unstash(stash, CONFIG_BOOTSTAGE_STASH_SIZE);
+ if (ret)
+ debug("%s: Failed to unstash bootstage: ret=%d\n",
+ __func__, ret);
+ }
+#endif /* CONFIG_BOOTSTAGE_STASH */
+ bootstage_mark_name(spl_phase() == PHASE_TPL ? BOOTSTAGE_ID_START_TPL :
+ BOOTSTAGE_ID_START_SPL, SPL_TPL_NAME);
#if CONFIG_IS_ENABLED(LOG)
ret = log_init();
if (ret) {
@@ -418,7 +431,8 @@ static int spl_common_init(bool setup_malloc)
}
}
if (CONFIG_IS_ENABLED(DM)) {
- bootstage_start(BOOTSTATE_ID_ACCUM_DM_SPL, "dm_spl");
+ bootstage_start(BOOTSTATE_ID_ACCUM_DM_SPL,
+ spl_phase() == PHASE_TPL ? "dm tpl" : "dm_spl");
/* With CONFIG_SPL_OF_PLATDATA, bring in all devices */
ret = dm_init_and_scan(!CONFIG_IS_ENABLED(OF_PLATDATA));
bootstage_accum(BOOTSTATE_ID_ACCUM_DM_SPL);
@@ -704,8 +718,9 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
debug("SPL malloc() used 0x%lx bytes (%ld KB)\n", gd->malloc_ptr,
gd->malloc_ptr / 1024);
#endif
+ bootstage_mark_name(spl_phase() == PHASE_TPL ? BOOTSTAGE_ID_END_TPL :
+ BOOTSTAGE_ID_END_SPL, "end " SPL_TPL_NAME);
#ifdef CONFIG_BOOTSTAGE_STASH
- bootstage_mark_name(BOOTSTAGE_ID_END_SPL, "end_spl");
ret = bootstage_stash((void *)CONFIG_BOOTSTAGE_STASH_ADDR,
CONFIG_BOOTSTAGE_STASH_SIZE);
if (ret)
diff --git a/common/spl/spl_nor.c b/common/spl/spl_nor.c
index 7df708de9b..b1e79b9ded 100644
--- a/common/spl/spl_nor.c
+++ b/common/spl/spl_nor.c
@@ -51,6 +51,11 @@ static int spl_nor_load_image(struct spl_image_info *spl_image,
CONFIG_SYS_OS_BASE,
(void *)header);
+#if defined CONFIG_SYS_SPL_ARGS_ADDR && defined CONFIG_CMD_SPL_NOR_OFS
+ memcpy((void *)CONFIG_SYS_SPL_ARGS_ADDR,
+ (void *)CONFIG_CMD_SPL_NOR_OFS,
+ CONFIG_CMD_SPL_WRITE_SIZE);
+#endif
return ret;
}
#endif
diff --git a/common/splash.c b/common/splash.c
index 0bcedbb0ba..e7d847726d 100644
--- a/common/splash.c
+++ b/common/splash.c
@@ -144,8 +144,6 @@ void splash_display_banner(void)
vidconsole_put_string(dev, buf);
vidconsole_position_cursor(dev, 0, row);
}
-#else
-static inline void splash_display_banner(void) { }
#endif /* CONFIG_DM_VIDEO && !CONFIG_HIDE_LOGO_VERSION */
/*
@@ -177,7 +175,9 @@ int splash_display(void)
if (x || y)
goto end;
+#if defined(CONFIG_DM_VIDEO) && !defined(CONFIG_HIDE_LOGO_VERSION)
splash_display_banner();
+#endif
end:
return ret;
}