<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On 30 March 2013 15:25, Krzysztof Halasa <span dir="ltr"><<a href="mailto:khc@pm.waw.pl" target="_blank">khc@pm.waw.pl</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Signed-off-by: Krzysztof Hałasa <<a href="mailto:khc@pm.waw.pl">khc@pm.waw.pl</a>><br>

<br>
--- a/arch/arm/cpu/start.c<br>
+++ b/arch/arm/cpu/start.c<br>
@@ -58,7 +58,6 @@ static noinline __noreturn void __start(uint32_t membase, uint32_t memsize,<br>
        endmem -= STACK_SIZE; /* Stack */<br>
<br>
        if (IS_ENABLED(CONFIG_MMU_EARLY)) {<br>
-<br>
                endmem &= ~0x3fff;<br>
                endmem -= SZ_16K; /* ttb */</blockquote><div><br></div><div style>This is a formatting change not functional change. Please, move it to a separate patch.</div><div> </div><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
 </blockquote><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
@@ -66,6 +65,9 @@ static noinline __noreturn void __start(uint32_t membase, uint32_t memsize,<br>
                        mmu_early_enable(membase, memsize, endmem);<br>
        }<br>
<br>
+#ifdef CONFIG_MEMORY_LAYOUT_ALTERNATE<br>
+               malloc_end = endmem;<br>
+#else<br>
        if ((unsigned long)_text > membase + memsize ||<br>
                        (unsigned long)_text < membase)<br>
                /*<br>
@@ -76,15 +78,21 @@ static noinline __noreturn void __start(uint32_t membase, uint32_t memsize,<br>
                malloc_end = endmem;<br>
        else<br>
                malloc_end = (unsigned long)_text;<br>
+#endif<br>
<br>
        /*<br>
         * Maximum malloc space is the Kconfig value if given<br>
         * or 64MB.<br>
         */<br>
        if (MALLOC_SIZE > 0) {<br>
-               malloc_start = malloc_end - MALLOC_SIZE;<br>
-               if (malloc_start < membase)<br>
+               if (malloc_end > membase + MALLOC_SIZE)<br>
+                       malloc_start = malloc_end - MALLOC_SIZE;<br>
+               else<br>
                        malloc_start = membase;<br>
+               if (malloc_start < (unsigned long)_end &&<br>
+                   malloc_end > (unsigned long)_text)<br>
+                       /* malloc area follows text */<br>
+                       malloc_start = (unsigned long)_end;<br>
        } else {<br>
                malloc_start = malloc_end - (malloc_end - membase) / 2;<br>
                if (malloc_end - malloc_start > SZ_64M)<br>
--- a/common/Kconfig<br>
+++ b/common/Kconfig<br>
@@ -161,7 +161,7 @@ choice<br>
 config MEMORY_LAYOUT_DEFAULT<br>
        bool "use default memory layout"<br>
        help<br>
-         select this option to use bareboxs standard memory layout:<br>
+         select this option to use barebox's standard memory layout:<br>
<br></blockquote><div style><br></div><div style>This is a "fix typo" change. Please, move it to a separate patch.</div><div style><br></div><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

          stack<br>
          -----<br>
@@ -169,6 +169,17 @@ config MEMORY_LAYOUT_DEFAULT<br>
          -----<br>
          TEXT_BASE<br>
<br>
+config MEMORY_LAYOUT_ALTERNATE<br>
+       bool "use alternate memory layout"<br>
+       help<br>
+         select this option to use barebox's alternate memory layout:<br>
+<br>
+         TEXT_BASE<br>
+         -----<br>
+         malloc heap<br>
+         -----<br>
+         stack<br>
+<br>
 config MEMORY_LAYOUT_FIXED<br>
        bool "manually assign a memory layout"<br>
        help<br>
<br>
_______________________________________________<br>
barebox mailing list<br>
<a href="mailto:barebox@lists.infradead.org">barebox@lists.infradead.org</a><br>
<a href="http://lists.infradead.org/mailman/listinfo/barebox" target="_blank">http://lists.infradead.org/mailman/listinfo/barebox</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Best regards,<br>  Antony Pavlov
</div></div>