[U-Boot] [PATCH] common/dlmalloc: support reinit bin for fast reset

Macpaul Lin macpaul at andestech.com
Fri Dec 31 08:13:48 CET 2010


There are several way to reset the u-boot.
Some platform will use watchdog timeout to reset the system.
Some platfrom will jump to 0x0 to reload the u-boot.
Some platform will jump to CONFIG_SYS_TEXT_BASE to do fast reset.

This patch fixed the problem of static varible didn't cleared on
the platforms which "CONFIG_SKIP_LOWLEVEL_INIT" is enabled and do
software reset by simply jump to the address "CONFIG_SYS_TEXT_BASE".

This patch also introduce a new define named "CONFIG_FAST_RESET" for
developer to distinguish this method from other reset methods.

Signed-off-by: Macpaul Lin <macpaul at andestech.com>
---
 README            |   10 ++++++++++
 common/dlmalloc.c |   24 ++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/README b/README
index 1acf9a3..ec00294 100644
--- a/README
+++ b/README
@@ -2846,6 +2846,16 @@ Low Level (hardware related) configuration options:
                 other boot loader or by a debugger which performs
                 these initializations itself.
 
+- CONFIG_FAST_RESET
+		If both CONFIG_SKIP_LOWLEVEL_INIT and this varible is defined,
+		the system could use do fast software reset by simply reinit
+		dlmalloc module then jump to the starting address
+		"CONFIG_SYS_TEXT_BASE".
+
+		To use this feature, the extern function "reinit_malloc_pool()"
+		in dlmalloc.c should be called inside
+		reset_cpu(CONFIG_SYS_TEXT_BASE).
+
 - CONFIG_PRELOADER
 		Modifies the behaviour of start.S when compiling a loader
 		that is executed before the actual U-Boot. E.g. when
diff --git a/common/dlmalloc.c b/common/dlmalloc.c
index e9bab09..97849a5 100644
--- a/common/dlmalloc.c
+++ b/common/dlmalloc.c
@@ -3233,6 +3233,30 @@ int mALLOPt(param_number, value) int param_number; int value;
   }
 }
 
+#if defined(CONFIG_FAST_RESET) || defined(CONFIG_SKIP_LOWLEVEL_INIT)
+void reinit_bin()
+{
+	int i = 0;
+
+	av_[0] = 0;
+	av_[1] = 0;
+
+	for (i = 0; i < NAV ; i++) {
+		av_[i*2+2] = bin_at(i);
+		av_[i*2+2+1] = bin_at(i);
+	}
+}
+
+extern void reinit_malloc_pool()
+{
+	/* fast reset sbrk_base */
+	sbrk_base = (char *)(-1);
+
+	/* re-initial bin */
+	reinit_bin();
+}
+#endif
+
 /*
 
 History:
-- 
1.7.3.2



More information about the U-Boot mailing list