All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heinrich Schuchardt <xypron.glpk@gmx.de>
To: u-boot@lists.denx.de
Subject: [PATCH 1/1] sandbox: implement invalidate_icache_all()
Date: Wed,  9 Dec 2020 19:42:44 +0100	[thread overview]
Message-ID: <20201209184244.33510-1-xypron.glpk@gmx.de> (raw)

Before executing code that we have loaded from a file we need to flush the
data cache and invalidate the instruction flash.

Implement functions flush_cache() and invalidate_icache_all().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 arch/sandbox/cpu/Makefile |  2 +-
 arch/sandbox/cpu/cache.c  | 23 +++++++++++++++++++++++
 board/sandbox/sandbox.c   |  4 ----
 3 files changed, 24 insertions(+), 5 deletions(-)
 create mode 100644 arch/sandbox/cpu/cache.c

diff --git a/arch/sandbox/cpu/Makefile b/arch/sandbox/cpu/Makefile
index bac96447d5..de7fe7f391 100644
--- a/arch/sandbox/cpu/Makefile
+++ b/arch/sandbox/cpu/Makefile
@@ -5,7 +5,7 @@
 # (C) Copyright 2000-2003
 # Wolfgang Denk, DENX Software Engineering, wd at denx.de.

-obj-y	:= cpu.o state.o
+obj-y	:= cache.o cpu.o state.o
 extra-y	:= start.o os.o
 extra-$(CONFIG_SANDBOX_SDL)	+= sdl.o
 obj-$(CONFIG_SPL_BUILD)	+= spl.o
diff --git a/arch/sandbox/cpu/cache.c b/arch/sandbox/cpu/cache.c
new file mode 100644
index 0000000000..46c62c0b44
--- /dev/null
+++ b/arch/sandbox/cpu/cache.c
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2020, Heinrich Schuchardt <xypron.glpk@gmx.de>
+ */
+
+#include <common.h>
+#include <cpu_func.h>
+#include <asm/state.h>
+
+void flush_cache(unsigned long addr, unsigned long size)
+{
+	/* Clang uses (char *) parameters, GCC (void *) */
+	__builtin___clear_cache((void *)addr, (void *)(addr + size));
+}
+
+void invalidate_icache_all(void)
+{
+	struct sandbox_state *state = state_get_current();
+
+	/* Clang uses (char *) parameters, GCC (void *) */
+	__builtin___clear_cache((void *)state->ram_buf,
+				(void *)(state->ram_buf + state->ram_size));
+}
diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c
index 18a605de02..3235541a7d 100644
--- a/board/sandbox/sandbox.c
+++ b/board/sandbox/sandbox.c
@@ -28,10 +28,6 @@ U_BOOT_DEVICE(gpio_sandbox) = {
 };
 #endif

-void flush_cache(unsigned long start, unsigned long size)
-{
-}
-
 #ifndef CONFIG_TIMER
 /* system timer offset in ms */
 static unsigned long sandbox_timer_offset;
--
2.29.2

             reply	other threads:[~2020-12-09 18:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-09 18:42 Heinrich Schuchardt [this message]
2020-12-12 15:39 ` [PATCH 1/1] sandbox: implement invalidate_icache_all() Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201209184244.33510-1-xypron.glpk@gmx.de \
    --to=xypron.glpk@gmx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.