Commit b46dcfa3 authored by Max Filippov's avatar Max Filippov

xtensa: allow merging vectors into .text section

Currently code for exception/IRQ vectors is stored in kernel image as
initialization data and is copied to its working addresses during
startup. It doesn't always make sense. In many cases vectors location
can be automatically decided at kernel link time and code can be placed
right there. This is especially useful for XIP kernel.
Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
parent 9a736fcb
...@@ -67,7 +67,11 @@ static inline unsigned long xtensa_get_kio_paddr(void) ...@@ -67,7 +67,11 @@ static inline unsigned long xtensa_get_kio_paddr(void)
#endif /* CONFIG_MMU */ #endif /* CONFIG_MMU */
#define RESET_VECTOR1_VADDR (XCHAL_RESET_VECTOR1_VADDR) #define RESET_VECTOR1_VADDR (XCHAL_RESET_VECTOR1_VADDR)
#ifdef CONFIG_VECTORS_OFFSET
#define VECBASE_VADDR (KERNELOFFSET - CONFIG_VECTORS_OFFSET) #define VECBASE_VADDR (KERNELOFFSET - CONFIG_VECTORS_OFFSET)
#else
#define VECBASE_VADDR _vecbase
#endif
#if defined(XCHAL_HAVE_VECBASE) && XCHAL_HAVE_VECBASE #if defined(XCHAL_HAVE_VECBASE) && XCHAL_HAVE_VECBASE
......
...@@ -455,6 +455,7 @@ void __init setup_arch(char **cmdline_p) ...@@ -455,6 +455,7 @@ void __init setup_arch(char **cmdline_p)
mem_reserve(__pa(&_stext), __pa(&_end)); mem_reserve(__pa(&_stext), __pa(&_end));
#ifdef CONFIG_VECTORS_OFFSET
mem_reserve(__pa(&_WindowVectors_text_start), mem_reserve(__pa(&_WindowVectors_text_start),
__pa(&_WindowVectors_text_end)); __pa(&_WindowVectors_text_end));
...@@ -491,6 +492,8 @@ void __init setup_arch(char **cmdline_p) ...@@ -491,6 +492,8 @@ void __init setup_arch(char **cmdline_p)
__pa(&_Level6InterruptVector_text_end)); __pa(&_Level6InterruptVector_text_end));
#endif #endif
#endif /* CONFIG_VECTORS_OFFSET */
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
mem_reserve(__pa(&_SecondaryResetVector_text_start), mem_reserve(__pa(&_SecondaryResetVector_text_start),
__pa(&_SecondaryResetVector_text_end)); __pa(&_SecondaryResetVector_text_end));
......
...@@ -59,6 +59,7 @@ jiffies = jiffies_64; ...@@ -59,6 +59,7 @@ jiffies = jiffies_64;
* garbage.) * garbage.)
*/ */
#ifdef CONFIG_VECTORS_OFFSET
#define SECTION_VECTOR(sym, section, addr, max_prevsec_size, prevsec) \ #define SECTION_VECTOR(sym, section, addr, max_prevsec_size, prevsec) \
section addr : AT((MIN(LOADADDR(prevsec) + max_prevsec_size, \ section addr : AT((MIN(LOADADDR(prevsec) + max_prevsec_size, \
LOADADDR(prevsec) + SIZEOF(prevsec)) + 3) & ~ 3) \ LOADADDR(prevsec) + SIZEOF(prevsec)) + 3) & ~ 3) \
...@@ -68,6 +69,11 @@ jiffies = jiffies_64; ...@@ -68,6 +69,11 @@ jiffies = jiffies_64;
*(section) \ *(section) \
sym ## _end = ABSOLUTE(.); \ sym ## _end = ABSOLUTE(.); \
} }
#else
#define SECTION_VECTOR(section, addr) \
. = addr; \
*(section)
#endif
/* /*
* Mapping of input sections to output sections when linking. * Mapping of input sections to output sections when linking.
...@@ -85,6 +91,37 @@ SECTIONS ...@@ -85,6 +91,37 @@ SECTIONS
{ {
/* The HEAD_TEXT section must be the first section! */ /* The HEAD_TEXT section must be the first section! */
HEAD_TEXT HEAD_TEXT
#ifndef CONFIG_VECTORS_OFFSET
. = ALIGN(PAGE_SIZE);
_vecbase = .;
SECTION_VECTOR (.WindowVectors.text, WINDOW_VECTORS_VADDR)
#if XCHAL_EXCM_LEVEL >= 2
SECTION_VECTOR (.Level2InterruptVector.text, INTLEVEL2_VECTOR_VADDR)
#endif
#if XCHAL_EXCM_LEVEL >= 3
SECTION_VECTOR (.Level3InterruptVector.text, INTLEVEL3_VECTOR_VADDR)
#endif
#if XCHAL_EXCM_LEVEL >= 4
SECTION_VECTOR (.Level4InterruptVector.text, INTLEVEL4_VECTOR_VADDR)
#endif
#if XCHAL_EXCM_LEVEL >= 5
SECTION_VECTOR (.Level5InterruptVector.text, INTLEVEL5_VECTOR_VADDR)
#endif
#if XCHAL_EXCM_LEVEL >= 6
SECTION_VECTOR (.Level6InterruptVector.text, INTLEVEL6_VECTOR_VADDR)
#endif
SECTION_VECTOR (.DebugInterruptVector.literal, DEBUG_VECTOR_VADDR - 4)
SECTION_VECTOR (.DebugInterruptVector.text, DEBUG_VECTOR_VADDR)
SECTION_VECTOR (.KernelExceptionVector.literal, KERNEL_VECTOR_VADDR - 4)
SECTION_VECTOR (.KernelExceptionVector.text, KERNEL_VECTOR_VADDR)
SECTION_VECTOR (.UserExceptionVector.literal, USER_VECTOR_VADDR - 4)
SECTION_VECTOR (.UserExceptionVector.text, USER_VECTOR_VADDR)
SECTION_VECTOR (.DoubleExceptionVector.literal, DOUBLEEXC_VECTOR_VADDR - 48)
SECTION_VECTOR (.DoubleExceptionVector.text, DOUBLEEXC_VECTOR_VADDR)
#endif
TEXT_TEXT TEXT_TEXT
VMLINUX_SYMBOL(__sched_text_start) = .; VMLINUX_SYMBOL(__sched_text_start) = .;
*(.sched.literal .sched.text) *(.sched.literal .sched.text)
...@@ -132,6 +169,7 @@ SECTIONS ...@@ -132,6 +169,7 @@ SECTIONS
. = ALIGN(16); . = ALIGN(16);
__boot_reloc_table_start = ABSOLUTE(.); __boot_reloc_table_start = ABSOLUTE(.);
#ifdef CONFIG_VECTORS_OFFSET
RELOCATE_ENTRY(_WindowVectors_text, RELOCATE_ENTRY(_WindowVectors_text,
.WindowVectors.text); .WindowVectors.text);
#if XCHAL_EXCM_LEVEL >= 2 #if XCHAL_EXCM_LEVEL >= 2
...@@ -164,6 +202,7 @@ SECTIONS ...@@ -164,6 +202,7 @@ SECTIONS
.DoubleExceptionVector.text); .DoubleExceptionVector.text);
RELOCATE_ENTRY(_DebugInterruptVector_text, RELOCATE_ENTRY(_DebugInterruptVector_text,
.DebugInterruptVector.text); .DebugInterruptVector.text);
#endif
#if defined(CONFIG_SMP) #if defined(CONFIG_SMP)
RELOCATE_ENTRY(_SecondaryResetVector_text, RELOCATE_ENTRY(_SecondaryResetVector_text,
.SecondaryResetVector.text); .SecondaryResetVector.text);
...@@ -186,6 +225,7 @@ SECTIONS ...@@ -186,6 +225,7 @@ SECTIONS
. = ALIGN(4); . = ALIGN(4);
.dummy : { LONG(0) } .dummy : { LONG(0) }
#ifdef CONFIG_VECTORS_OFFSET
/* The vectors are relocated to the real position at startup time */ /* The vectors are relocated to the real position at startup time */
SECTION_VECTOR (_WindowVectors_text, SECTION_VECTOR (_WindowVectors_text,
...@@ -277,6 +317,7 @@ SECTIONS ...@@ -277,6 +317,7 @@ SECTIONS
. = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3; . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3;
#endif
#if defined(CONFIG_SMP) #if defined(CONFIG_SMP)
SECTION_VECTOR (_SecondaryResetVector_text, SECTION_VECTOR (_SecondaryResetVector_text,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment