From b383d6c05e2587a7b3ea13855e4161bacb64feb9 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 22 May 2017 05:05:25 -0600 Subject: bootstage: Convert to use malloc() At present bootstage uses the data section of the image to store its information. There are a few problems with this: - It does not work on all boards (e.g. those which run from flash before relocation) - Allocated strings still point back to the pre-relocation data after relocation Now that U-Boot has a pre-relocation malloc() we can use this instead, with a pointer to the data in global_data. Update bootstage to do this and set up an init routine to allocate the memory. Now that we have a real init function, we can drop the fake 'reset' record and add a normal one instead. Note that part of the problem with allocated strings remains. They are reallocated but this will only work where pre-relocation memory is accessible after relocation. Signed-off-by: Simon Glass --- include/asm-generic/global_data.h | 3 +++ include/bootstage.h | 13 +++++++++++++ 2 files changed, 16 insertions(+) (limited to 'include') diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index e6f905110e3..8b3229e5b8d 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -110,6 +110,9 @@ typedef struct global_data { ulong video_top; /* Top of video frame buffer area */ ulong video_bottom; /* Bottom of video frame buffer area */ #endif +#ifdef CONFIG_BOOTSTAGE + struct bootstage_data *bootstage; /* Bootstage information */ +#endif } gd_t; #endif diff --git a/include/bootstage.h b/include/bootstage.h index 6ee923c2ebd..e1aec1b549c 100644 --- a/include/bootstage.h +++ b/include/bootstage.h @@ -331,6 +331,14 @@ int bootstage_stash(void *base, int size); */ int bootstage_unstash(void *base, int size); +/** + * bootstage_init() - Prepare bootstage for use + * + * @first: true if this is the first time bootstage is set up. This causes it + * to add a 'reset' record with a time of 0. + */ +int bootstage_init(bool first); + #else static inline ulong bootstage_add_record(enum bootstage_id id, const char *name, int flags, ulong mark) @@ -391,6 +399,11 @@ static inline int bootstage_unstash(void *base, int size) { return 0; /* Pretend to succeed */ } + +static inline int bootstage_init(bool first) +{ + return 0; +} #endif /* CONFIG_BOOTSTAGE */ /* Helper macro for adding a bootstage to a line of code */ -- cgit v1.3.1