summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2019-11-01 09:34:35 -0400
committerTom Rini <trini@konsulko.com>2019-11-01 09:34:35 -0400
commitbb1bb4bb5df9df4d3f07e39a632daaff79e4b77e (patch)
tree1ed8d0b3622961997a32cd648d5d1bd3de7a855a /common
parent82679624f9aa6d1be733c46f3555d5166b6f5b72 (diff)
parentd60ae4c59df55c08dc96202ff58fed21ab3afb7d (diff)
Merge tag 'dm-pull-29oct19' of git://git.denx.de/u-boot-dm
- Fix for patman with email addresses containing commas - Bootstage improvements for TPL, SPL - Various sandbox and dm improvements and fixes
Diffstat (limited to 'common')
-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/spl.c23
5 files changed, 57 insertions, 24 deletions
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/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)