public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] IXP425: make cmd_go handle caches correctly Part 1/1
@ 2008-12-04 21:09 Stefan Althoefer
  2008-12-15 23:18 ` Wolfgang Denk
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Althoefer @ 2008-12-04 21:09 UTC (permalink / raw)
  To: u-boot

[PATCH] IXP425: make cmd_go handle caches correctly

This patch adds icache_invalidate() and dcache_flush() to
cpu/ixp/cpu.c.

Also it adds do_go_exec() which is called from do_go().
This private implementation performs cache handling
before jumping into the code.

Without this cache handling, you will jump into stale
code if you download a program several times.


The patch is against "latest" u-boot git-repository

Please (still) be patient if style of submission or patches are
offending.

Signed-off-by: Stefan Althoefer <stefan.althoefer@web.de>
----

diff -uprN u-boot-orig//cpu/ixp/cpu.c u-boot/cpu/ixp/cpu.c
--- u-boot-orig//cpu/ixp/cpu.c	2008-12-02 17:25:31.000000000 +0100
+++ u-boot/cpu/ixp/cpu.c	2008-12-03 11:35:37.000000000 +0100
@@ -171,6 +207,22 @@ int icache_status (void)
 	return (i & 0x1000);
 }
 
+void icache_invalidate (void)
+{
+        register u32 i;
+
+        /* FIXME: Required to check if icache is enabled before we do this? */
+        
+        /* invalidate I-cache (i is ignored)*/
+	i = 0;
+        asm ("mcr p15, 0, %0, c7, c5, 0": :"r" (i));
+
+        /* cpwait */
+        asm ("mrc  p15,0,%0,c2,c0,0;\
+            mov  %0,%0;\
+            sub  pc,pc,#4" : : "r" (i) );
+}
+
 /* we will never enable dcache, because we have to setup MMU first */
 void dcache_enable (void)
 {
@@ -187,6 +239,11 @@ int dcache_status (void)
 	return 0;					/* always off */
 }
 
+void dcache_flush (void)
+{
+	return;
+}
+
 /* FIXME */
 /*
 void pci_init(void)
@@ -195,6 +252,17 @@ void pci_init(void)
 }
 */
 
+/* With IXP (and ARM generally) we need to handle caches to avoid
+   stale data. */
+unsigned long do_go_exec (ulong (*entry)(int, char *[]), int argc, char *argv[])
+{ 
+	dcache_flush();
+	icache_invalidate();
+
+        return entry (argc, argv);
+}
+
+
 #ifdef CONFIG_BOOTCOUNT_LIMIT
 
 void bootcount_store (ulong a)

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

end of thread, other threads:[~2009-01-04  7:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-04 21:09 [U-Boot] [PATCH] IXP425: make cmd_go handle caches correctly Part 1/1 Stefan Althoefer
2008-12-15 23:18 ` Wolfgang Denk
2008-12-16 23:11   ` Stefan Althoefer
2009-01-04  7:51     ` Jean-Christophe PLAGNIOL-VILLARD

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