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


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
U-Boot-Users mailing list
U-Boot-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/u-boot-users

Reply via email to