
When we copy code/data to the main memory, we may need to flush the cache if required by architecture. It uses the existing function flush_cache. Syntax is
flush <addr> <size>
The addr and size are given in hexadecimal. Like memory command, there is no sanity check for the parameters.
Signed-off-by: York Sun yorksun@freescale.com --- Change since v2: rename flush_cache to flush
README | 5 ++++- common/cmd_cache.c | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/README b/README index dc6b0b3..b2f80d6 100644 --- a/README +++ b/README @@ -809,6 +809,7 @@ The following options need to be configured: CONFIG_CMD_BSP * Board specific commands CONFIG_CMD_BOOTD bootd CONFIG_CMD_CACHE * icache, dcache + CONFIG_CMD_CACHE_FLUSH * flush cache by the address and range CONFIG_CMD_CONSOLE coninfo CONFIG_CMD_CRC32 * crc32 CONFIG_CMD_DATE * support for RTC, date/time... @@ -912,7 +913,9 @@ The following options need to be configured: 8260 (where accesses to the IMMR region must be uncached), and it cannot be disabled on all other systems where we (mis-) use the data cache to hold an - initial stack and some data. + initial stack and some data. The CONFIG_CMD_CACHE_FLUSH + macro enables flushing cache by the address and range to + maintain coherency if required by architecture.
XXX - this list needs to get updated! diff --git a/common/cmd_cache.c b/common/cmd_cache.c index 5512f92..c228e0c 100644 --- a/common/cmd_cache.c +++ b/common/cmd_cache.c @@ -120,3 +120,29 @@ U_BOOT_CMD( "[on, off, flush]\n" " - enable, disable, or flush data (writethrough) cache" ); + +#ifdef CONFIG_CMD_CACHE_FLUSH +int do_flush_cache(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + ulong addr, size; + + switch (argc) { + case 3: + addr = simple_strtoul(argv[1], NULL, 16); + size = simple_strtoul(argv[2], NULL, 16); + flush_cache(addr, size); + break; + default: + return cmd_usage(cmdtp); + } + return 0; + +} + +U_BOOT_CMD( + flush, 3, 0, do_flush_cache, + "flush cache for a range", + "<addr> <size>\n" + " - flush cache for specificed range" +); +#endif