]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
bootstage: Copy bootstage strings post-relocation
authorDoug Anderson <dianders@chromium.org>
Wed, 17 Apr 2013 16:13:41 +0000 (16:13 +0000)
committerSimon Glass <sjg@chromium.org>
Mon, 13 May 2013 20:33:21 +0000 (13:33 -0700)
Any pointers to name strings that were passed to bootstage_mark_name()
pre-relocation should be copied post-relocation so that they don't get
trashed as the original location of U-Boot is re-used for other
purposes.

This change introduces a new API call that should be called from
board_init_r() after malloc has been initted on any board that uses
bootstage.

Signed-off-by: Doug Anderson <dianders@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
common/bootstage.c
include/bootstage.h

index a1e09394cc5ba7818dae77893c1c2175b5b7bdb3..15afa24c44bb5a60cab358f9fbf67d10668b73db 100644 (file)
@@ -56,6 +56,21 @@ struct bootstage_hdr {
        uint32_t magic;         /* Unused */
 };
 
+int bootstage_relocate(void)
+{
+       int i;
+
+       /*
+        * Duplicate all strings.  They may point to an old location in the
+        * program .text section that can eventually get trashed.
+        */
+       for (i = 0; i < BOOTSTAGE_ID_COUNT; i++)
+               if (record[i].name)
+                       record[i].name = strdup(record[i].name);
+
+       return 0;
+}
+
 ulong bootstage_add_record(enum bootstage_id id, const char *name,
                           int flags, ulong mark)
 {
index bdda76849fb63441c264b9474ca8d71084561a13..c8235e8ed6ad10a0c7a551b785201d735be290b2 100644 (file)
@@ -236,6 +236,16 @@ void show_boot_progress(int val);
 #if defined(CONFIG_BOOTSTAGE) && !defined(CONFIG_SPL_BUILD)
 /* This is the full bootstage implementation */
 
+/**
+ * Relocate existing bootstage records
+ *
+ * Call this after relocation has happened and after malloc has been initted.
+ * We need to copy any pointers in bootstage records that were added pre-
+ * relocation, since memory can be overritten later.
+ * @return Always returns 0, to indicate success
+ */
+int bootstage_relocate(void);
+
 /**
  * Add a new bootstage record
  *
@@ -326,6 +336,11 @@ static inline ulong bootstage_add_record(enum bootstage_id id,
  * and won't even do that unless CONFIG_SHOW_BOOT_PROGRESS is defined
  */
 
+static inline int bootstage_relocate(void)
+{
+       return 0;
+}
+
 static inline ulong bootstage_mark(enum bootstage_id id)
 {
        show_boot_progress(id);