Skip to content

Commit 03ce34c

Browse files
committed
xtensa: add XIP-aware MTD support
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>
1 parent 687eb3c commit 03ce34c

File tree

5 files changed

+34
-1
lines changed

5 files changed

+34
-1
lines changed

arch/xtensa/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ config ARCH_HAS_ILOG2_U32
7070
config ARCH_HAS_ILOG2_U64
7171
def_bool n
7272

73+
config ARCH_MTD_XIP
74+
def_bool y
75+
7376
config NO_IOPORT_MAP
7477
def_bool n
7578

arch/xtensa/include/asm/mtd-xip.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
3+
#ifndef _ASM_MTD_XIP_H
4+
#define _ASM_MTD_XIP_H
5+
6+
#include <asm/processor.h>
7+
8+
#define xip_irqpending() (xtensa_get_sr(interrupt) & xtensa_get_sr(intenable))
9+
#define xip_currtime() (xtensa_get_sr(ccount))
10+
#define xip_elapsed_since(x) ((xtensa_get_sr(ccount) - (x)) / 1000) /* should work up to 1GHz */
11+
#define xip_cpu_idle() do { asm volatile ("waiti 0"); } while (0)
12+
13+
#endif /* _ASM_MTD_XIP_H */
14+

arch/xtensa/include/asm/sections.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ extern char _SecondaryResetVector_text_start[];
3434
extern char _SecondaryResetVector_text_end[];
3535
#endif
3636
#ifdef CONFIG_XIP_KERNEL
37+
#ifdef CONFIG_VECTORS_ADDR
38+
extern char _xip_text_start[];
39+
extern char _xip_text_end[];
40+
#endif
3741
extern char _xip_start[];
3842
extern char _xip_end[];
3943
#endif

arch/xtensa/kernel/setup.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,9 @@ void __init setup_arch(char **cmdline_p)
311311

312312
mem_reserve(__pa(_stext), __pa(_end));
313313
#ifdef CONFIG_XIP_KERNEL
314+
#ifdef CONFIG_VECTORS_ADDR
315+
mem_reserve(__pa(_xip_text_start), __pa(_xip_text_end));
316+
#endif
314317
mem_reserve(__pa(_xip_start), __pa(_xip_end));
315318
#endif
316319

arch/xtensa/kernel/vmlinux.lds.S

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ SECTIONS
118118
SECTION_VECTOR2 (.DoubleExceptionVector.text, DOUBLEEXC_VECTOR_VADDR)
119119

120120
*(.exception.text)
121+
*(.xiptext)
121122
#endif
122123

123124
IRQENTRY_TEXT
@@ -201,6 +202,9 @@ SECTIONS
201202
.DebugInterruptVector.text);
202203
RELOCATE_ENTRY(_exception_text,
203204
.exception.text);
205+
#ifdef CONFIG_XIP_KERNEL
206+
RELOCATE_ENTRY(_xip_text, .xiptext);
207+
#endif
204208
#endif
205209
#ifdef CONFIG_XIP_KERNEL
206210
RELOCATE_ENTRY(_xip_data, .data);
@@ -319,7 +323,12 @@ SECTIONS
319323
LAST)
320324
#undef LAST
321325
#define LAST .exception.text
322-
326+
SECTION_VECTOR4 (_xip_text,
327+
.xiptext,
328+
,
329+
LAST)
330+
#undef LAST
331+
#define LAST .xiptext
323332
#endif
324333
. = (LOADADDR(LAST) + SIZEOF(LAST) + 3) & ~ 3;
325334

0 commit comments

Comments
 (0)