[U-Boot,v2,05/10] bootstage: Store the next ID in the stash
diff mbox series

Message ID 20191021232652.132164-6-sjg@chromium.org
State Accepted
Delegated to: Simon Glass
Headers show
Series
  • bootstage: TPL and SPL improvements
Related show

Commit Message

Simon Glass Oct. 21, 2019, 11:26 p.m. UTC
When stashing bootstage info, store the next ID so that it can be used
when the stash is restored. This avoids the ID starting at zero and
potentially overwriting existing entries.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2: None

 common/bootstage.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Comments

Simon Glass Oct. 29, 2019, 11:21 p.m. UTC | #1
When stashing bootstage info, store the next ID so that it can be used
when the stash is restored. This avoids the ID starting at zero and
potentially overwriting existing entries.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2: None

 common/bootstage.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Applied to u-boot-dm, thanks!

Patch
diff mbox series

diff --git a/common/bootstage.c b/common/bootstage.c
index 56ef91ad859..257dc5d402f 100644
--- a/common/bootstage.c
+++ b/common/bootstage.c
@@ -41,10 +41,11 @@  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)
@@ -392,6 +393,7 @@  int bootstage_stash(void *base, int size)
 	hdr->count = 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 */
@@ -485,6 +487,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;