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

Dear Mike,

in message <200708131052.44472.vapier@gentoo.org> you wrote:
> 
> so using weak hooks is OK now ?  i think it'd be good to migrate all of the

It always has been OK - just nobody bothered to use it. [And I didn't
even know about it when I started working on PPCBoot.]

> ugly boote/bootm/etc... cruft to external weaks and let arches define their
> own

Yes, a few #ifdef's can be eliminated that way.

> > > int do_go (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
> > > {
> > >         ulong   addr, rc;
> > >         int     rcode = 0;
> > >
> > >         if (argc < 2) {
> > >                 printf ("Usage:\n%s\n", cmdtp->usage);
> > >                 return 1;
> > >         }
> > >
> > >         addr = simple_strtoul(argv[1], NULL, 16);
> > >         printf ("## Starting application at 0x%08lX ...\n", addr);
> > >
> > >         if (icache_status()){
> > >                icache_disable();
> > >         }
> > >         if (dcache_status()) {
> > >                dcache_disable();
> > >         }
> >
> > This is not in the official tree, and it will not make it  there.  It
> > will probably not even build for many boards.
> 
> it's called pseudo code ... of course code that has "..." in it wont build > :p

The only "..." I see was in the printf() format string, where it
doesn't hurt compilation.

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
Swap read error.  You lose your mind.

^ 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