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. Signed-off-by: Stefan Althoefer <stefan.althoe...@web.de> --- > > Coding style: please use TABs for indentation. > Sorry for the spaces. BTW: In function calls: Is the space between function name are opening bracket desired or not? Seems this is handled very inconsistent. -- Stefan cpu/ixp/cpu.c | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-) diff --git a/cpu/ixp/cpu.c b/cpu/ixp/cpu.c index 27872fb..9035d98 100644 --- a/cpu/ixp/cpu.c +++ b/cpu/ixp/cpu.c @@ -171,6 +171,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 +203,11 @@ int dcache_status (void) return 0; /* always off */ } +void dcache_flush (void) +{ + return; +} + /* FIXME */ /* void pci_init(void) @@ -195,6 +216,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) -- 1.5.6 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot