]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xtensa: add XIP-aware MTD support
authorMax Filippov <jcmvbkbc@gmail.com>
Sat, 1 Feb 2020 05:33:28 +0000 (21:33 -0800)
committerMax Filippov <jcmvbkbc@gmail.com>
Tue, 29 Aug 2023 01:25:23 +0000 (18:25 -0700)
Add Kconfig symbol, asm/mtd-xip.h header and define related macros:
xip_cpu_idle, xip_irqpending, xip_currtime and xip_elapsed_since.
Append .xiptext to the vectors when separate vectors are configured
because otherwise they are appended to the data and data may not even be
executable in XIP configuration.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
arch/xtensa/Kconfig
arch/xtensa/include/asm/mtd-xip.h [new file with mode: 0644]
arch/xtensa/include/asm/sections.h
arch/xtensa/kernel/setup.c
arch/xtensa/kernel/vmlinux.lds.S

index 2a51a466779fe416406afcea2186e186204f6d32..070a112b7dbebf0b8eb0941d763729a6b2c7b3a8 100644 (file)
@@ -70,6 +70,9 @@ config ARCH_HAS_ILOG2_U32
 config ARCH_HAS_ILOG2_U64
        def_bool n
 
+config ARCH_MTD_XIP
+       def_bool y
+
 config NO_IOPORT_MAP
        def_bool n
 
diff --git a/arch/xtensa/include/asm/mtd-xip.h b/arch/xtensa/include/asm/mtd-xip.h
new file mode 100644 (file)
index 0000000..5143251
--- /dev/null
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef _ASM_MTD_XIP_H
+#define _ASM_MTD_XIP_H
+
+#include <asm/processor.h>
+
+#define xip_irqpending()       (xtensa_get_sr(interrupt) & xtensa_get_sr(intenable))
+#define xip_currtime()         (xtensa_get_sr(ccount))
+#define xip_elapsed_since(x)   ((xtensa_get_sr(ccount) - (x)) / 1000) /* should work up to 1GHz */
+#define xip_cpu_idle()         do { asm volatile ("waiti 0"); } while (0)
+
+#endif /* _ASM_MTD_XIP_H */
+
index 3bc6b9afa99391ddde4d2c5ccf06b468b02a7eed..e5da6d7092bead27075a2b2ac9558c7e715b538d 100644 (file)
@@ -34,6 +34,10 @@ extern char _SecondaryResetVector_text_start[];
 extern char _SecondaryResetVector_text_end[];
 #endif
 #ifdef CONFIG_XIP_KERNEL
+#ifdef CONFIG_VECTORS_ADDR
+extern char _xip_text_start[];
+extern char _xip_text_end[];
+#endif
 extern char _xip_start[];
 extern char _xip_end[];
 #endif
index aba3ff4e60d85740a64a116884391ffda8906bbc..52d6e4870a04c99fcdbdda6ce423c097a39b64eb 100644 (file)
@@ -311,6 +311,9 @@ void __init setup_arch(char **cmdline_p)
 
        mem_reserve(__pa(_stext), __pa(_end));
 #ifdef CONFIG_XIP_KERNEL
+#ifdef CONFIG_VECTORS_ADDR
+       mem_reserve(__pa(_xip_text_start), __pa(_xip_text_end));
+#endif
        mem_reserve(__pa(_xip_start), __pa(_xip_end));
 #endif
 
index c14fd96f459d65b76bf10552c7202d05e0cf5805..f47e9bbbd29117cbfdbcbee1e1dc86c175ff34b1 100644 (file)
@@ -118,6 +118,7 @@ SECTIONS
     SECTION_VECTOR2 (.DoubleExceptionVector.text, DOUBLEEXC_VECTOR_VADDR)
 
     *(.exception.text)
+    *(.xiptext)
 #endif
 
     IRQENTRY_TEXT
@@ -201,6 +202,9 @@ SECTIONS
                   .DebugInterruptVector.text);
     RELOCATE_ENTRY(_exception_text,
                   .exception.text);
+#ifdef CONFIG_XIP_KERNEL
+    RELOCATE_ENTRY(_xip_text, .xiptext);
+#endif
 #endif
 #ifdef CONFIG_XIP_KERNEL
     RELOCATE_ENTRY(_xip_data, .data);
@@ -319,7 +323,12 @@ SECTIONS
                  LAST)
 #undef LAST
 #define LAST .exception.text
-
+  SECTION_VECTOR4 (_xip_text,
+                 .xiptext,
+                 ,
+                 LAST)
+#undef LAST
+#define LAST .xiptext
 #endif
   . = (LOADADDR(LAST) + SIZEOF(LAST) + 3) & ~ 3;