From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail-pb0-f53.google.com ([209.85.160.53]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UM0mH-0000kP-Se for barebox@lists.infradead.org; Sat, 30 Mar 2013 18:45:22 +0000 Received: by mail-pb0-f53.google.com with SMTP id un1so645518pbc.12 for ; Sat, 30 Mar 2013 11:45:20 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: Date: Sat, 30 Mar 2013 22:45:19 +0400 Message-ID: From: Antony Pavlov List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============6205620069136401647==" Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: Re: [PATCH] Implement ALTERNATE memory layout. To: Krzysztof Halasa Cc: barebox --===============6205620069136401647== Content-Type: multipart/alternative; boundary=047d7b10c7d522bf5f04d928ca6d --047d7b10c7d522bf5f04d928ca6d Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 30 March 2013 15:25, Krzysztof Halasa wrote: > Signed-off-by: Krzysztof Ha=C5=82asa > > --- a/arch/arm/cpu/start.c > +++ b/arch/arm/cpu/start.c > @@ -58,7 +58,6 @@ static noinline __noreturn void __start(uint32_t > membase, uint32_t memsize, > endmem -=3D STACK_SIZE; /* Stack */ > > if (IS_ENABLED(CONFIG_MMU_EARLY)) { > - > endmem &=3D ~0x3fff; > endmem -=3D SZ_16K; /* ttb */ This is a formatting change not functional change. Please, move it to a separate patch. > > @@ -66,6 +65,9 @@ static noinline __noreturn void __start(uint32_t > membase, uint32_t memsize, > mmu_early_enable(membase, memsize, endmem); > } > > +#ifdef CONFIG_MEMORY_LAYOUT_ALTERNATE > + malloc_end =3D endmem; > +#else > if ((unsigned long)_text > membase + memsize || > (unsigned long)_text < membase) > /* > @@ -76,15 +78,21 @@ static noinline __noreturn void __start(uint32_t > membase, uint32_t memsize, > malloc_end =3D endmem; > else > malloc_end =3D (unsigned long)_text; > +#endif > > /* > * Maximum malloc space is the Kconfig value if given > * or 64MB. > */ > if (MALLOC_SIZE > 0) { > - malloc_start =3D malloc_end - MALLOC_SIZE; > - if (malloc_start < membase) > + if (malloc_end > membase + MALLOC_SIZE) > + malloc_start =3D malloc_end - MALLOC_SIZE; > + else > malloc_start =3D membase; > + if (malloc_start < (unsigned long)_end && > + malloc_end > (unsigned long)_text) > + /* malloc area follows text */ > + malloc_start =3D (unsigned long)_end; > } else { > malloc_start =3D malloc_end - (malloc_end - membase) / 2; > if (malloc_end - malloc_start > SZ_64M) > --- a/common/Kconfig > +++ b/common/Kconfig > @@ -161,7 +161,7 @@ choice > config MEMORY_LAYOUT_DEFAULT > bool "use default memory layout" > help > - select this option to use bareboxs standard memory layout: > + select this option to use barebox's standard memory layout: > > This is a "fix typo" change. Please, move it to a separate patch. stack > ----- > @@ -169,6 +169,17 @@ config MEMORY_LAYOUT_DEFAULT > ----- > TEXT_BASE > > +config MEMORY_LAYOUT_ALTERNATE > + bool "use alternate memory layout" > + help > + select this option to use barebox's alternate memory layout: > + > + TEXT_BASE > + ----- > + malloc heap > + ----- > + stack > + > config MEMORY_LAYOUT_FIXED > bool "manually assign a memory layout" > help > > _______________________________________________ > barebox mailing list > barebox@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/barebox > --=20 Best regards, Antony Pavlov --047d7b10c7d522bf5f04d928ca6d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable



On 30 March 2013 15:25, Krzysztof Halasa <khc@pm.waw.pl>= wrote:
Signed-off-by: = Krzysztof Ha=C5=82asa <khc@pm.waw.pl>

--- a/arch/arm/cpu/start.c
+++ b/arch/arm/cpu/start.c
@@ -58,7 +58,6 @@ static noinline __noreturn void __start(uint32_t membase,= uint32_t memsize,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 endmem -=3D STACK_SIZE; /* Stack */

=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (IS_ENABLED(CONFIG_MMU_EARLY)) {
-
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 endmem &=3D ~0x= 3fff;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 endmem -=3D SZ_16K;= /* ttb */

=C2=A0

@@ -66,6 +65,9 @@ static noinline __noreturn void __start(uint32_t membase,= uint32_t memsize,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 mmu_early_enable(membase, memsize, endmem);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }

+#ifdef CONFIG_MEMORY_LAYOUT_ALTERNATE
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 malloc_end =3D endmem; +#else
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if ((unsigned long)_text > membase + memsize= ||
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 (unsigned long)_text < membase)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 /*
@@ -76,15 +78,21 @@ static noinline __noreturn void __start(uint32_t membas= e, uint32_t memsize,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 malloc_end =3D endm= em;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 else
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 malloc_end =3D (uns= igned long)_text;
+#endif

=C2=A0 =C2=A0 =C2=A0 =C2=A0 /*
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* Maximum malloc space is the Kconfig val= ue if given
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* or 64MB.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*/
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (MALLOC_SIZE > 0) {
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 malloc_start =3D malloc_= end - MALLOC_SIZE;
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (malloc_start < me= mbase)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (malloc_end > memb= ase + MALLOC_SIZE)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 malloc_start =3D malloc_end - MALLOC_SIZE;
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 else
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 malloc_start =3D membase;
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (malloc_start < (u= nsigned long)_end &&
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 malloc_end= > (unsigned long)_text)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 /* malloc area follows text */
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 malloc_start =3D (unsigned long)_end;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 } else {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 malloc_start =3D ma= lloc_end - (malloc_end - membase) / 2;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (malloc_end - ma= lloc_start > SZ_64M)
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -161,7 +161,7 @@ choice
=C2=A0config MEMORY_LAYOUT_DEFAULT
=C2=A0 =C2=A0 =C2=A0 =C2=A0 bool "use default memory layout"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 help
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 select this option to use bareboxs standard m= emory layout:
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 select this option to use barebox's stand= ard memory layout:



=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 stack
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 -----
@@ -169,6 +169,17 @@ config MEMORY_LAYOUT_DEFAULT
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 -----
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 TEXT_BASE

+config MEMORY_LAYOUT_ALTERNATE
+ =C2=A0 =C2=A0 =C2=A0 bool "use alternate memory layout"
+ =C2=A0 =C2=A0 =C2=A0 help
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 select this option to use barebox's alter= nate memory layout:
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 TEXT_BASE
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 -----
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 malloc heap
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 -----
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 stack
+
=C2=A0config MEMORY_LAYOUT_FIXED
=C2=A0 =C2=A0 =C2=A0 =C2=A0 bool "manually assign a memory layout"= ;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 help

_______________________________________________
barebox mailing list
barebox@lists.infradead.org<= /a>
http://lists.infradead.org/mailman/listinfo/barebox



--
Best regards= ,
=C2=A0 Antony Pavlov
--047d7b10c7d522bf5f04d928ca6d-- --===============6205620069136401647== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox --===============6205620069136401647==--