public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [patch] allow ports to override bootelf behavior
  2007-08-13 15:50 [U-Boot-Users] [Patch] Disable icache before call the first line of kernel in do_bootelf() Wolfgang Denk
@ 2008-02-01 15:44 ` Mike Frysinger
  2008-04-13 22:01   ` Wolfgang Denk
  0 siblings, 1 reply; 7+ messages in thread
From: Mike Frysinger @ 2008-02-01 15:44 UTC (permalink / raw)
  To: u-boot

This splits the dcache logic out of do_bootelf into a dedicated weak function
called do_bootelf_exec.  This way ports can control the behavior before
executing an ELF image however they like.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
diff --git a/common/cmd_elf.c b/common/cmd_elf.c
index 2eb7453..5689e2c 100644
--- a/common/cmd_elf.c
+++ b/common/cmd_elf.c
@@ -30,6 +30,31 @@ DECLARE_GLOBAL_DATA_PTR;
 int valid_elf_image (unsigned long addr);
 unsigned long load_elf_image (unsigned long addr);
 
+__attribute__((weak))
+unsigned long do_bootelf_exec (ulong (*entry)(int, char *[]), int argc, char *argv[])
+{
+	unsigned long ret;
+
+	/*
+	 * QNX images require the data cache is disabled.
+	 * Data cache is already flushed, so just turn it off.
+	 */
+	int dcache = dcache_status ();
+	if (dcache)
+		dcache_disable ();
+
+	/*
+	 * pass address parameter as argv[0] (aka command name),
+	 * and all remaining args
+	 */
+	ret = entry (argc, argv);
+
+	if (dcache)
+		dcache_enable ();
+
+	return ret;
+}
+
 /* ======================================================================
  * Interpreter command to boot an arbitrary ELF image from memory.
  * ====================================================================== */
@@ -53,18 +78,7 @@ int do_bootelf (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
 	printf ("## Starting application at 0x%08lx ...\n", addr);
 
-	/*
-	 * QNX images require the data cache is disabled.
-	 * Data cache is already flushed, so just turn it off.
-	 */
-	if (dcache_status ())
-		dcache_disable ();
-
-	/*
-	 * pass address parameter as argv[0] (aka command name),
-	 * and all remaining args
-	 */
-	rc = ((ulong (*)(int, char *[])) addr) (--argc, &argv[1]);
+	rc = do_bootelf_exec ((void *)addr, argc - 1, argv + 1);
 	if (rc != 0)
 		rcode = 1;
 

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [U-Boot-Users] [patch] allow ports to override bootelf behavior
  2008-02-01 15:44 ` [U-Boot-Users] [patch] allow ports to override bootelf behavior Mike Frysinger
@ 2008-04-13 22:01   ` Wolfgang Denk
  0 siblings, 0 replies; 7+ messages in thread
From: Wolfgang Denk @ 2008-04-13 22:01 UTC (permalink / raw)
  To: u-boot

In message <200802011045.00200.vapier@gentoo.org> you wrote:
> This splits the dcache logic out of do_bootelf into a dedicated weak function
> called do_bootelf_exec.  This way ports can control the behavior before
> executing an ELF image however they like.
> 
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
> ---
> diff --git a/common/cmd_elf.c b/common/cmd_elf.c

This doesn't fit current code any moe. Please rebase and resubmit.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Even if you aren't in doubt, consider the mental welfare of the  per-
son who has to maintain the code after you, and who will probably put
parens in the wrong place.          - Larry Wall in the perl man page

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot-Users] [PATCH] allow ports to override bootelf behavior
@ 2008-04-13 23:42 Mike Frysinger
  2008-04-13 23:42 ` [U-Boot-Users] [PATCH] allow ports to override go behavior Mike Frysinger
  2008-04-18  7:54 ` [U-Boot-Users] [PATCH] allow ports to override bootelf behavior Wolfgang Denk
  0 siblings, 2 replies; 7+ messages in thread
From: Mike Frysinger @ 2008-04-13 23:42 UTC (permalink / raw)
  To: u-boot

Change the bootelf setup function into a dedicated weak function called
do_bootelf_exec.  This way ports can control the behavior however they
like before/after calling the ELF entry point.
---
 common/cmd_elf.c |   33 +++++++++++++++++++++------------
 1 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/common/cmd_elf.c b/common/cmd_elf.c
index 4683554..62e5e76 100644
--- a/common/cmd_elf.c
+++ b/common/cmd_elf.c
@@ -27,23 +27,34 @@ DECLARE_GLOBAL_DATA_PTR;
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 #endif
 
-static inline void bootelf_setup(int argc, char *argv[])
+int valid_elf_image (unsigned long addr);
+unsigned long load_elf_image (unsigned long addr);
+
+/* Allow ports to override the default behavior */
+__attribute__((weak))
+unsigned long do_bootelf_exec (ulong (*entry)(int, char *[]), int argc, char *argv[])
 {
+	unsigned long ret;
+
 	/*
 	 * QNX images require the data cache is disabled.
 	 * Data cache is already flushed, so just turn it off.
 	 */
-	if (dcache_status ())
+	int dcache = dcache_status ();
+	if (dcache)
 		dcache_disable ();
 
-#ifdef CONFIG_BLACKFIN
-	if (icache_status ())
-		icache_disable ();
-#endif
-}
+	/*
+	 * pass address parameter as argv[0] (aka command name),
+	 * and all remaining args
+	 */
+	ret = entry (argc, argv);
 
-int valid_elf_image (unsigned long addr);
-unsigned long load_elf_image (unsigned long addr);
+	if (dcache)
+		dcache_enable ();
+
+	return ret;
+}
 
 /* ======================================================================
  * Interpreter command to boot an arbitrary ELF image from memory.
@@ -68,13 +79,11 @@ int do_bootelf (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
 	printf ("## Starting application at 0x%08lx ...\n", addr);
 
-	bootelf_setup(argc, argv);
-
 	/*
 	 * pass address parameter as argv[0] (aka command name),
 	 * and all remaining args
 	 */
-	rc = ((ulong (*)(int, char *[])) addr) (--argc, &argv[1]);
+	rc = do_bootelf_exec ((void *)addr, argc - 1, argv + 1);
 	if (rc != 0)
 		rcode = 1;
 
-- 
1.5.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [U-Boot-Users] [PATCH] allow ports to override go behavior
  2008-04-13 23:42 [U-Boot-Users] [PATCH] allow ports to override bootelf behavior Mike Frysinger
@ 2008-04-13 23:42 ` Mike Frysinger
  2008-04-18  7:54   ` Wolfgang Denk
  2008-04-18  7:54 ` [U-Boot-Users] [PATCH] allow ports to override bootelf behavior Wolfgang Denk
  1 sibling, 1 reply; 7+ messages in thread
From: Mike Frysinger @ 2008-04-13 23:42 UTC (permalink / raw)
  To: u-boot

Split the arch-specific logic out of the common go code and into a dedicated
weak function called do_go_exec() that lives in cpu directories.  This will
need review from i386/nios people to make sure I didn't break them.
---
 common/cmd_boot.c |   33 +++++----------------------------
 lib_i386/board.c  |    8 ++++++++
 lib_nios/board.c  |   10 ++++++++++
 3 files changed, 23 insertions(+), 28 deletions(-)

diff --git a/common/cmd_boot.c b/common/cmd_boot.c
index 9d4f026..d83f5af 100644
--- a/common/cmd_boot.c
+++ b/common/cmd_boot.c
@@ -28,25 +28,11 @@
 #include <command.h>
 #include <net.h>
 
-#if defined(CONFIG_I386)
-DECLARE_GLOBAL_DATA_PTR;
-#endif
-
-static inline void go_setup(int argc, char *argv[])
+/* Allow ports to override the default behavior */
+__attribute__((weak))
+unsigned long do_go_exec (ulong (*entry)(int, char *[]), int argc, char *argv[])
 {
-#if defined(CONFIG_I386)
-	/*
-	 * x86 does not use a dedicated register to pass the pointer
-	 * to the global_data
-	 */
-	argv[0] = (char *)gd;
-
-#elif defined(CONFIG_BLACKFIN)
-	if (dcache_status ())
-		dcache_disable ();
-	if (icache_status ())
-		icache_disable ();
-#endif
+	return entry (argc, argv);
 }
 
 int do_go (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
@@ -63,20 +49,11 @@ int do_go (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
 	printf ("## Starting application at 0x%08lX ...\n", addr);
 
-	go_setup(argc, argv);
-
-#if defined(CONFIG_NIOS)
-	/*
-	 * Nios function pointers are address >> 1
-	 */
-	addr >>= 1;
-#endif
-
 	/*
 	 * pass address parameter as argv[0] (aka command name),
 	 * and all remaining args
 	 */
-	rc = ((ulong (*)(int, char *[]))addr) (--argc, &argv[1]);
+	rc = do_go_exec ((void *)addr, argc - 1, argv + 1);
 	if (rc != 0) rcode = 1;
 
 	printf ("## Application terminated, rc = 0x%lX\n", rc);
diff --git a/lib_i386/board.c b/lib_i386/board.c
index 47fbab4..22191e6 100644
--- a/lib_i386/board.c
+++ b/lib_i386/board.c
@@ -421,3 +421,11 @@ void hang (void)
 	puts ("### ERROR ### Please RESET the board ###\n");
 	for (;;);
 }
+
+unsigned long do_go_exec (ulong (*entry)(int, char *[]), int argc, char *argv[])
+{
+	/*
+	 * Nios function pointers are address >> 1
+	 */
+	return (entry >> 1) (argc, argv);
+}
diff --git a/lib_nios/board.c b/lib_nios/board.c
index 0a0d2e3..cdaf753 100644
--- a/lib_nios/board.c
+++ b/lib_nios/board.c
@@ -190,3 +190,13 @@ void hang (void)
 	puts("### ERROR ### Please reset board ###\n");
 	for (;;);
 }
+
+unsigned long do_go_exec (ulong (*entry)(int, char *[]), int argc, char *argv[])
+{
+	/*
+	 * x86 does not use a dedicated register to pass the pointer
+	 * to the global_data
+	 */
+	argv[-1] = (char *)gd;
+	return entry (argc, argv);
+}
-- 
1.5.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [U-Boot-Users] [PATCH] allow ports to override go behavior
  2008-04-13 23:42 ` [U-Boot-Users] [PATCH] allow ports to override go behavior Mike Frysinger
@ 2008-04-18  7:54   ` Wolfgang Denk
  0 siblings, 0 replies; 7+ messages in thread
From: Wolfgang Denk @ 2008-04-18  7:54 UTC (permalink / raw)
  To: u-boot

In message <1208130139-18440-2-git-send-email-vapier@gentoo.org> you wrote:
> Split the arch-specific logic out of the common go code and into a dedicated
> weak function called do_go_exec() that lives in cpu directories.  This will
> need review from i386/nios people to make sure I didn't break them.
> ---
>  common/cmd_boot.c |   33 +++++----------------------------
>  lib_i386/board.c  |    8 ++++++++
>  lib_nios/board.c  |   10 ++++++++++
>  3 files changed, 23 insertions(+), 28 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
In the bathtub of history the truth is harder to hold than the  soap,
and much more difficult to find ...     - Terry Pratchett, _Sourcery_

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot-Users] [PATCH] allow ports to override bootelf behavior
  2008-04-13 23:42 [U-Boot-Users] [PATCH] allow ports to override bootelf behavior Mike Frysinger
  2008-04-13 23:42 ` [U-Boot-Users] [PATCH] allow ports to override go behavior Mike Frysinger
@ 2008-04-18  7:54 ` Wolfgang Denk
  2008-04-18 14:49   ` Stefan Roese
  1 sibling, 1 reply; 7+ messages in thread
From: Wolfgang Denk @ 2008-04-18  7:54 UTC (permalink / raw)
  To: u-boot

In message <1208130139-18440-1-git-send-email-vapier@gentoo.org> you wrote:
> Change the bootelf setup function into a dedicated weak function called
> do_bootelf_exec.  This way ports can control the behavior however they
> like before/after calling the ELF entry point.
> ---
>  common/cmd_elf.c |   33 +++++++++++++++++++++------------
>  1 files changed, 21 insertions(+), 12 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Question: How does one get fresh air into a Russian church?
Answer:   One clicks on an icon, and a window opens!

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot-Users] [PATCH] allow ports to override bootelf behavior
  2008-04-18  7:54 ` [U-Boot-Users] [PATCH] allow ports to override bootelf behavior Wolfgang Denk
@ 2008-04-18 14:49   ` Stefan Roese
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Roese @ 2008-04-18 14:49 UTC (permalink / raw)
  To: u-boot

On Friday 18 April 2008, Wolfgang Denk wrote:
> In message <1208130139-18440-1-git-send-email-vapier@gentoo.org> you wrote:
> > Change the bootelf setup function into a dedicated weak function called
> > do_bootelf_exec.  This way ports can control the behavior however they
> > like before/after calling the ELF entry point.
> > ---
> >  common/cmd_elf.c |   33 +++++++++++++++++++++------------
> >  1 files changed, 21 insertions(+), 12 deletions(-)
>
> Applied, thanks.

Unfortunately this breaks all 440 ports using elf:

Configuring for sequoia board...
common/libcommon.a(cmd_elf.o): In function `do_bootelf_exec':
/home/stefan/git/u-boot/u-boot/common/cmd_elf.c:54: undefined reference to `dcache_enable'
make: *** [u-boot] Error 1
ppc_4xx-size: './u-boot': No such file

No dcache_enble() here currently. I'll send a patch to add
dcache_enable() to 440 in a short while. But this could affect
other platforms as well.

Best regards,
Stefan

=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-04-18 14:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-13 23:42 [U-Boot-Users] [PATCH] allow ports to override bootelf behavior Mike Frysinger
2008-04-13 23:42 ` [U-Boot-Users] [PATCH] allow ports to override go behavior Mike Frysinger
2008-04-18  7:54   ` Wolfgang Denk
2008-04-18  7:54 ` [U-Boot-Users] [PATCH] allow ports to override bootelf behavior Wolfgang Denk
2008-04-18 14:49   ` Stefan Roese
  -- strict thread matches above, loose matches on Subject: below --
2007-08-13 15:50 [U-Boot-Users] [Patch] Disable icache before call the first line of kernel in do_bootelf() Wolfgang Denk
2008-02-01 15:44 ` [U-Boot-Users] [patch] allow ports to override bootelf behavior Mike Frysinger
2008-04-13 22:01   ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox