[U-Boot] [RFC] command/cache: Add flush_cache command

York Sun yorksun at freescale.com
Tue Mar 19 21:29:52 CET 2013


When we need the copied code/data in the main memory, we can flush the
cache now. It uses the existing function flush_cache. Syntax is

flush_cache <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 at freescale.com>
---
 common/cmd_cache.c |   30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/common/cmd_cache.c b/common/cmd_cache.c
index 5512f92..93b7337 100644
--- a/common/cmd_cache.c
+++ b/common/cmd_cache.c
@@ -94,6 +94,29 @@ int do_dcache(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return 0;
 }
 
+void __weak flush_cache(ulong addr, ulong size)
+{
+	puts("No arch specific flush_cache available!\n");
+	/* please define arch specific flush_cache */
+}
+
+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;
+
+}
+
 static int parse_argv(const char *s)
 {
 	if (strcmp(s, "flush") == 0)
@@ -120,3 +143,10 @@ U_BOOT_CMD(
 	"[on, off, flush]\n"
 	"    - enable, disable, or flush data (writethrough) cache"
 );
+
+U_BOOT_CMD(
+	flush_cache,   3,   0,     do_flush_cache,
+	"flush cache for a range",
+	"<addr> <size>\n"
+	"    - flush cache for specificed range"
+);
-- 
1.7.9.5




More information about the U-Boot mailing list