Commit 5dacbbef authored by Max Filippov's avatar Max Filippov

xtensa: simplify coprocessor.S

Use addresses instead of offsets and drop unneeded offset -> address
calculations. Don't generate any code for undefined coprocessors.
Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
parent cad6fade
...@@ -33,16 +33,16 @@ ...@@ -33,16 +33,16 @@
*/ */
#define SAVE_CP_REGS(x) \ #define SAVE_CP_REGS(x) \
.align 4; \
.Lsave_cp_regs_cp##x: \
.if XTENSA_HAVE_COPROCESSOR(x); \ .if XTENSA_HAVE_COPROCESSOR(x); \
.align 4; \
.Lsave_cp_regs_cp##x: \
xchal_cp##x##_store a2 a4 a5 a6 a7; \ xchal_cp##x##_store a2 a4 a5 a6 a7; \
.endif; \ jx a0; \
jx a0 .endif
#define SAVE_CP_REGS_TAB(x) \ #define SAVE_CP_REGS_TAB(x) \
.if XTENSA_HAVE_COPROCESSOR(x); \ .if XTENSA_HAVE_COPROCESSOR(x); \
.long .Lsave_cp_regs_cp##x - .Lsave_cp_regs_jump_table; \ .long .Lsave_cp_regs_cp##x; \
.else; \ .else; \
.long 0; \ .long 0; \
.endif; \ .endif; \
...@@ -50,16 +50,16 @@ ...@@ -50,16 +50,16 @@
#define LOAD_CP_REGS(x) \ #define LOAD_CP_REGS(x) \
.align 4; \
.Lload_cp_regs_cp##x: \
.if XTENSA_HAVE_COPROCESSOR(x); \ .if XTENSA_HAVE_COPROCESSOR(x); \
.align 4; \
.Lload_cp_regs_cp##x: \
xchal_cp##x##_load a2 a4 a5 a6 a7; \ xchal_cp##x##_load a2 a4 a5 a6 a7; \
.endif; \ jx a0; \
jx a0 .endif
#define LOAD_CP_REGS_TAB(x) \ #define LOAD_CP_REGS_TAB(x) \
.if XTENSA_HAVE_COPROCESSOR(x); \ .if XTENSA_HAVE_COPROCESSOR(x); \
.long .Lload_cp_regs_cp##x - .Lload_cp_regs_jump_table; \ .long .Lload_cp_regs_cp##x; \
.else; \ .else; \
.long 0; \ .long 0; \
.endif; \ .endif; \
...@@ -83,6 +83,7 @@ ...@@ -83,6 +83,7 @@
LOAD_CP_REGS(6) LOAD_CP_REGS(6)
LOAD_CP_REGS(7) LOAD_CP_REGS(7)
.section ".rodata", "a"
.align 4 .align 4
.Lsave_cp_regs_jump_table: .Lsave_cp_regs_jump_table:
SAVE_CP_REGS_TAB(0) SAVE_CP_REGS_TAB(0)
...@@ -104,6 +105,8 @@ ...@@ -104,6 +105,8 @@
LOAD_CP_REGS_TAB(6) LOAD_CP_REGS_TAB(6)
LOAD_CP_REGS_TAB(7) LOAD_CP_REGS_TAB(7)
.previous
/* /*
* coprocessor_flush(struct thread_info*, index) * coprocessor_flush(struct thread_info*, index)
* a2 a3 * a2 a3
...@@ -126,8 +129,7 @@ ENTRY(coprocessor_flush) ...@@ -126,8 +129,7 @@ ENTRY(coprocessor_flush)
l32i a3, a3, 0 l32i a3, a3, 0
add a2, a2, a4 add a2, a2, a4
beqz a3, 1f beqz a3, 1f
add a0, a0, a3 callx0 a3
callx0 a0
1: l32i a0, a1, 0 1: l32i a0, a1, 0
retw retw
...@@ -212,10 +214,9 @@ ENTRY(fast_coprocessor) ...@@ -212,10 +214,9 @@ ENTRY(fast_coprocessor)
movi a0, 2f # a0: 'return' address movi a0, 2f # a0: 'return' address
addx8 a3, a3, a5 # a3: coprocessor number addx8 a3, a3, a5 # a3: coprocessor number
l32i a2, a3, 4 # a2: xtregs offset l32i a2, a3, 4 # a2: xtregs offset
l32i a3, a3, 0 # a3: jump offset l32i a3, a3, 0 # a3: jump address
add a2, a2, a4 add a2, a2, a4
add a4, a3, a5 # a4: address of save routine jx a3
jx a4
/* Note that only a0 and a1 were preserved. */ /* Note that only a0 and a1 were preserved. */
...@@ -235,10 +236,9 @@ ENTRY(fast_coprocessor) ...@@ -235,10 +236,9 @@ ENTRY(fast_coprocessor)
movi a0, 1f movi a0, 1f
addx8 a3, a3, a5 addx8 a3, a3, a5
l32i a2, a3, 4 # a2: xtregs offset l32i a2, a3, 4 # a2: xtregs offset
l32i a3, a3, 0 # a3: jump offset l32i a3, a3, 0 # a3: jump address
add a2, a2, a4 add a2, a2, a4
add a4, a3, a5 jx a3
jx a4
/* Restore all registers and return from exception handler. */ /* Restore all registers and return from exception handler. */
......
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