summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/xtensa/sysdep.h
diff options
context:
space:
mode:
authorMax Filippov <jcmvbkbc@gmail.com>2015-09-16 01:49:49 +0300
committerWaldemar Brodkorb <wbx@openadk.org>2015-10-08 20:31:24 +0200
commite78a0f58f23347c822c182d1c01f6eb9b9866d60 (patch)
tree723cfbcd2411d889fb4956adb7f2d11a6d766050 /libc/sysdeps/linux/xtensa/sysdep.h
parent9fae2ad9937279c9f7f40975ac14cb7b57f4a36d (diff)
xtensa: support call0 ABI
Most changes are mechanical replacement of 'retw' instruction with 'abi_ret' macro, defined to 'retw' or 'ret' according to ABI. Assembly code that makes calls is duplicated for call0 ABI with changed register numbers for parameters/return value and call instruction. 'entry' instructions are replaced with 'abi_entry' macro. More interesting changes: - non-leaf assembly functions (e.g. _dl_tlsdesc_dynamic, _dl_linux_resolve, SYSCALL_ERROR_HANDLER, PSEUDO) now need to preserve registers around intermediate calls they make, use temporary stack frame for that; - setjmp/longjmp only need to save and restore return address, stack pointer and callee-saved registers in the jmpbuf; - __clone and syscall functions had hardcoded offsets to parameter passed on stack, on call0 ABI they don't need stack frame, so the offset is different. Replace these offsets with FRAMESIZE macro. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Diffstat (limited to 'libc/sysdeps/linux/xtensa/sysdep.h')
-rw-r--r--libc/sysdeps/linux/xtensa/sysdep.h45
1 files changed, 41 insertions, 4 deletions
diff --git a/libc/sysdeps/linux/xtensa/sysdep.h b/libc/sysdeps/linux/xtensa/sysdep.h
index 4873a413d..ce2b0a0d6 100644
--- a/libc/sysdeps/linux/xtensa/sysdep.h
+++ b/libc/sysdeps/linux/xtensa/sysdep.h
@@ -28,13 +28,24 @@
#define ASM_TYPE_DIRECTIVE(name, typearg) .type name, typearg
#define ASM_SIZE_DIRECTIVE(name) .size name, . - name
+#if defined(__XTENSA_WINDOWED_ABI__)
+#define abi_entry(reg, frame_size) entry reg, frame_size
+#define abi_ret retw
+#elif defined(__XTENSA_CALL0_ABI__)
+#define abi_entry(reg, frame_size)
+#define abi_ret ret
+#else
+#error Unsupported Xtensa ABI
+#endif
+
+
#define ENTRY(name) \
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name), @function); \
.align ALIGNARG(2); \
LITERAL_POSITION; \
C_LABEL(name) \
- entry sp, FRAMESIZE; \
+ abi_entry(sp, FRAMESIZE); \
CALL_MCOUNT
#define HIDDEN_ENTRY(name) \
@@ -44,7 +55,7 @@
.align ALIGNARG(2); \
LITERAL_POSITION; \
C_LABEL(name) \
- entry sp, FRAMESIZE; \
+ abi_entry(sp, FRAMESIZE); \
CALL_MCOUNT
#undef END
@@ -73,7 +84,13 @@
#endif
#ifndef FRAMESIZE
+#if defined(__XTENSA_WINDOWED_ABI__)
#define FRAMESIZE 16
+#elif defined(__XTENSA_CALL0_ABI__)
+#define FRAMESIZE 0
+#else
+#error Unsupported Xtensa ABI
+#endif
#endif
#define CALL_MCOUNT /* Do nothing. */
@@ -118,7 +135,7 @@
END (name)
#undef ret_NOERRNO
-#define ret_NOERRNO retw
+#define ret_NOERRNO abi_ret
/* The function has to return the error code. */
#undef PSEUDO_ERRVAL
@@ -133,7 +150,7 @@
END (name)
#undef ret_ERRVAL
-#define ret_ERRVAL retw
+#define ret_ERRVAL abi_ret
#if defined _LIBC_REENTRANT
# if defined USE___THREAD
@@ -151,6 +168,8 @@
movi a2, -1; \
j .Lpseudo_end;
# else /* !USE___THREAD */
+
+#if defined(__XTENSA_WINDOWED_ABI__)
# define SYSCALL_ERROR_HANDLER \
0: neg a2, a2; \
mov a6, a2; \
@@ -159,6 +178,24 @@
s32i a2, a6, 0; \
movi a2, -1; \
j .Lpseudo_end;
+#elif defined(__XTENSA_CALL0_ABI__)
+# define SYSCALL_ERROR_HANDLER \
+0: neg a2, a2; \
+ addi a1, a1, -16; \
+ s32i a0, a1, 0; \
+ s32i a2, a1, 4; \
+ movi a0, __errno_location@PLT; \
+ callx0 a0; \
+ l32i a0, a1, 0; \
+ l32i a3, a1, 4; \
+ addi a1, a1, 16; \
+ s32i a3, a2, 0; \
+ movi a2, -1; \
+ j .Lpseudo_end;
+#else
+#error Unsupported Xtensa ABI
+#endif
+
# endif /* !USE___THREAD */
#else /* !_LIBC_REENTRANT */
#define SYSCALL_ERROR_HANDLER \