From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZlZY6-0000Tl-PF for barebox@lists.infradead.org; Mon, 12 Oct 2015 09:37:43 +0000 Date: Mon, 12 Oct 2015 11:37:19 +0200 From: Sascha Hauer Message-ID: <20151012093719.GQ7858@pengutronix.de> References: <1444589021-12727-1-git-send-email-andrew.smirnov@gmail.com> <1444589021-12727-4-git-send-email-andrew.smirnov@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1444589021-12727-4-git-send-email-andrew.smirnov@gmail.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: Re: [PATCH 4/8] arm/cpu: Avoid multiple definitions of barebox_arm_entry To: Andrey Smirnov Cc: barebox@lists.infradead.org On Sun, Oct 11, 2015 at 11:43:37AM -0700, Andrey Smirnov wrote: > All versions of barebox_arm_entry (in uncompress.c, start.c and > start-pbl.c) appera to be doing exacty the same thing. So move the > definition into a separate file and use IS_ENABLED macro to avoid > re-definition. > > Signed-off-by: Andrey Smirnov > --- > arch/arm/cpu/Makefile | 4 ++-- > arch/arm/cpu/entry.c | 37 ++++++++++++++++++++++++++++++++++++ > arch/arm/cpu/entry.h | 48 +++++++++++++++++++++++++++++++++++++++++++++++ > arch/arm/cpu/start-pbl.c | 29 +--------------------------- > arch/arm/cpu/start.c | 27 +------------------------- > arch/arm/cpu/uncompress.c | 16 +--------------- > 6 files changed, 90 insertions(+), 71 deletions(-) > create mode 100644 arch/arm/cpu/entry.c > create mode 100644 arch/arm/cpu/entry.h > > diff --git a/arch/arm/cpu/Makefile b/arch/arm/cpu/Makefile > index fb3929c..418bcab 100644 > --- a/arch/arm/cpu/Makefile > +++ b/arch/arm/cpu/Makefile > @@ -1,7 +1,7 @@ > obj-y += cpu.o > obj-$(CONFIG_ARM_EXCEPTIONS) += exceptions.o > obj-$(CONFIG_ARM_EXCEPTIONS) += interrupts.o > -obj-y += start.o setupc.o > +obj-y += start.o setupc.o entry.o > > # > # Any variants can be called as start-armxyz.S > @@ -23,7 +23,7 @@ AFLAGS_pbl-cache-armv7.o :=-Wa,-march=armv7-a > pbl-$(CONFIG_CPU_32v7) += cache-armv7.o > obj-$(CONFIG_CACHE_L2X0) += cache-l2x0.o > > -pbl-y += setupc.o > +pbl-y += setupc.o entry.o > pbl-$(CONFIG_PBL_SINGLE_IMAGE) += start-pbl.o > pbl-$(CONFIG_PBL_MULTI_IMAGES) += uncompress.o > > diff --git a/arch/arm/cpu/entry.c b/arch/arm/cpu/entry.c > new file mode 100644 > index 0000000..adc4aec > --- /dev/null > +++ b/arch/arm/cpu/entry.c > @@ -0,0 +1,37 @@ > +#include > +#include > + > +#include "entry.h" > + > +/* > + * Main ARM entry point. Call this with the memory region you can > + * spare for barebox. This doesn't necessarily have to be the full > + * SDRAM. The currently running binary can be inside or outside of > + * this region. TEXT_BASE can be inside or outside of this > + * region. boarddata will be preserved and can be accessed later with > + * barebox_arm_boarddata(). > + * > + * -> membase + memsize > + * STACK_SIZE - stack > + * 16KiB, aligned to 16KiB - First level page table if early MMU support > + * is enabled > + * 128KiB - early memory space > + * -> maximum end of barebox binary > + * > + * Usually a TEXT_BASE of 1MiB below your lowest possible end of memory should > + * be fine. > + */ > + > +void __naked __noreturn barebox_arm_entry(unsigned long membase, > + unsigned long memsize, void *boarddata) > +{ > + arm_setup_stack(membase + memsize - 16); > + arm_early_mmu_cache_invalidate(); > + > + if (IS_ENABLED(CONFIG_PBL_MULTI_IMAGES)) > + uncompress_start_payload(membase, memsize, boarddata); > + else if (IS_ENABLED(CONFIG_PBL_SINGLE_IMAGE)) > + __barebox_arm_entry(membase, memsize, boarddata); > + else > + __start(membase, memsize, boarddata); > +} I like the idea but I think to be exported the __barebox_arm_entry and __start functions should get a more meaningful name. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox