aarch64: Use absolute symbols for the callee saved registers

Use GEN_OFFSET_SYM macro to genarate absolute symbols for the
_callee_saved struct and use these new symbols in the assembly code.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
This commit is contained in:
Carlo Caione 2020-11-11 14:29:44 +01:00 committed by Anas Nashif
commit a7d94b003e
4 changed files with 30 additions and 18 deletions

View file

@ -35,17 +35,15 @@ SECTION_FUNC(TEXT, z_arm64_context_switch)
ldr x2, =_thread_offset_to_callee_saved
add x2, x2, x1
/* Store callee-saved registers */
stp x19, x20, [x2], #16
stp x21, x22, [x2], #16
stp x23, x24, [x2], #16
stp x25, x26, [x2], #16
stp x27, x28, [x2], #16
stp x29, xzr, [x2], #16
/* Save the current SP */
mov x1, sp
str x1, [x2]
stp x19, x20, [x2, ___callee_saved_t_x19_x20_OFFSET]
stp x21, x22, [x2, ___callee_saved_t_x21_x22_OFFSET]
stp x23, x24, [x2, ___callee_saved_t_x23_x24_OFFSET]
stp x25, x26, [x2, ___callee_saved_t_x25_x26_OFFSET]
stp x27, x28, [x2, ___callee_saved_t_x27_x28_OFFSET]
stp x29, x1, [x2, ___callee_saved_t_x29_sp_OFFSET]
#ifdef CONFIG_THREAD_LOCAL_STORAGE
/* Grab the TLS pointer */
@ -64,15 +62,13 @@ SECTION_FUNC(TEXT, z_arm64_context_switch)
ldr x2, =_thread_offset_to_callee_saved
add x2, x2, x0
/* Restore x19-x29 */
ldp x19, x20, [x2], #16
ldp x21, x22, [x2], #16
ldp x23, x24, [x2], #16
ldp x25, x26, [x2], #16
ldp x27, x28, [x2], #16
ldp x29, xzr, [x2], #16
ldp x19, x20, [x2, ___callee_saved_t_x19_x20_OFFSET]
ldp x21, x22, [x2, ___callee_saved_t_x21_x22_OFFSET]
ldp x23, x24, [x2, ___callee_saved_t_x23_x24_OFFSET]
ldp x25, x26, [x2, ___callee_saved_t_x25_x26_OFFSET]
ldp x27, x28, [x2, ___callee_saved_t_x27_x28_OFFSET]
ldp x29, x1, [x2, ___callee_saved_t_x29_sp_OFFSET]
ldr x1, [x2]
mov sp, x1
#ifdef CONFIG_INSTRUMENT_THREAD_SWITCHING

View file

@ -29,4 +29,13 @@
#include <kernel_arch_data.h>
#include <kernel_offsets.h>
GEN_NAMED_OFFSET_SYM(_callee_saved_t, x19, x19_x20);
GEN_NAMED_OFFSET_SYM(_callee_saved_t, x21, x21_x22);
GEN_NAMED_OFFSET_SYM(_callee_saved_t, x23, x23_x24);
GEN_NAMED_OFFSET_SYM(_callee_saved_t, x25, x25_x26);
GEN_NAMED_OFFSET_SYM(_callee_saved_t, x27, x27_x28);
GEN_NAMED_OFFSET_SYM(_callee_saved_t, x29, x29_sp);
GEN_ABSOLUTE_SYM(___callee_saved_t_SIZEOF, sizeof(struct _callee_saved));
#endif /* _ARM_OFFSETS_INC_ */

View file

@ -34,7 +34,6 @@ struct _callee_saved {
uint64_t x27;
uint64_t x28;
uint64_t x29; /* FP */
uint64_t xzr;
uint64_t sp;
};

View file

@ -32,6 +32,11 @@
*
* __<structure>_<member>_OFFSET
*
* The macro "GEN_NAMED_OFFSET_SYM(structure, member, name)" is also provided
* to create the symbol with the following form:
*
* __<structure>_<name>_OFFSET
*
* This header also defines the GEN_ABSOLUTE_SYM macro to simply define an
* absolute symbol, irrespective of whether the value represents a structure
* or offset.
@ -79,4 +84,7 @@
#define GEN_OFFSET_SYM(S, M) \
GEN_ABSOLUTE_SYM(__##S##_##M##_##OFFSET, offsetof(S, M))
#define GEN_NAMED_OFFSET_SYM(S, M, N) \
GEN_ABSOLUTE_SYM(__##S##_##N##_##OFFSET, offsetof(S, M))
#endif /* ZEPHYR_KERNEL_INCLUDE_GEN_OFFSET_H_ */