123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- #include <common/sysdep.h>
- #include <features.h>
- #ifdef __ASSEMBLER__
- #define LOCAL(X) .L_##X
- #define ALIGNARG(log2) log2
- #define ASM_TYPE_DIRECTIVE(name,typearg) .type name,@##typearg;
- #define ASM_SIZE_DIRECTIVE(name) .size name,.-name
- #ifdef SHARED
- #define PLTJMP(_x) _x##@PLT
- #else
- #define PLTJMP(_x) _x
- #endif
- #define ENTRY(name) \
- .globl C_SYMBOL_NAME(name)
- ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),function) \
- .align ALIGNARG(5)
- C_LABEL(name) \
- cfi_startproc
- #undef END
- #define END(name) \
- cfi_endproc
- ASM_SIZE_DIRECTIVE(C_SYMBOL_NAME(name))
- #ifdef __UCLIBC_UNDERSCORES__
- #define syscall_error __syscall_error
- #define mcount _mcount
- #endif
- #undef SYS_ify
- #define SYS_ify(syscall_name) (__NR_##syscall_name)
- #define ret rts ; nop
- #define MOVE(x,y) mov x , y
- #define _IMM1 #-1
- #define _IMM12 #-12
- #undef PSEUDO
- #define PSEUDO(name, syscall_name, args) \
- .text
- ENTRY (name)
- DO_CALL (syscall_name, args)
- mov r0,r1
- mov _IMM12,r2
- shad r2,r1
- not r1,r1
- tst r1,r1
- bf .Lpseudo_end
- SYSCALL_ERROR_HANDLER
- .Lpseudo_end:
- #undef PSEUDO_END
- #define PSEUDO_END(name) \
- END (name)
- #undef PSEUDO_NOERRNO
- #define PSEUDO_NOERRNO(name, syscall_name, args) \
- .text
- ENTRY (name)
- DO_CALL (syscall_name, args)
- #undef PSEUDO_END_NOERRNO
- #define PSEUDO_END_NOERRNO(name) \
- END (name)
- #define ret_NOERRNO ret
- #define PSEUDO_ERRVAL(name, syscall_name, args) \
- .text
- ENTRY (name)
- DO_CALL (syscall_name, args)
- #undef PSEUDO_END_ERRVAL
- #define PSEUDO_END_ERRVAL(name) \
- END (name)
- #ifndef __PIC__
- # define SYSCALL_ERROR_HANDLER \
- mov.l 0f,r1
- jmp @r1
- mov r0,r4
- .align 2
- 0: .long __syscall_error
- #include <libc/sysdeps/linux/sh/syscall_error.S>
- #else
- # if defined _LIBC_REENTRANT
- # if defined USE___THREAD
- # ifndef NOT_IN_libc
- # define SYSCALL_ERROR_ERRNO __libc_errno
- # else
- # define SYSCALL_ERROR_ERRNO errno
- # endif
- # define SYSCALL_ERROR_HANDLER \
- neg r0,r1
- mov r12,r2
- mov.l 0f,r12
- mova 0f,r0
- add r0,r12
- mov.l 1f,r0
- stc gbr, r4
- mov.l @(r0,r12),r0
- bra .Lskip
- add r4,r0
- .align 2
- 1: .long SYSCALL_ERROR_ERRNO@GOTTPOFF
- .Lskip: \
- mov r2,r12
- mov.l r1,@r0
- bra .Lpseudo_end
- mov _IMM1,r0
- .align 2
- 0: .long _GLOBAL_OFFSET_TABLE_
- # else
- # define SYSCALL_ERROR_HANDLER \
- neg r0,r1
- mov.l r14,@-r15
- mov.l r12,@-r15
- mov.l r1,@-r15
- mov.l 0f,r12
- mova 0f,r0
- add r0,r12
- sts.l pr,@-r15
- mov r15,r14
- mov.l 1f,r1
- bsrf r1
- nop
- 2: mov r14,r15
- lds.l @r15+,pr
- mov.l @r15+,r1
- mov.l r1,@r0
- mov.l @r15+,r12
- mov.l @r15+,r14
- bra .Lpseudo_end
- mov _IMM1,r0
- .align 2
- 0: .long _GLOBAL_OFFSET_TABLE_
- 1: .long PLTJMP(C_SYMBOL_NAME(__errno_location))-(2b-.)
- # endif
- # else
- # define SYSCALL_ERROR_HANDLER \
- neg r0,r1
- mov r12,r2
- mov.l 0f,r12
- mova 0f,r0
- add r0,r12
- mov.l 1f,r0
- mov.l @(r0,r12),r0
- mov r2,r12
- mov.l r1,@r0
- bra .Lpseudo_end
- mov _IMM1,r0
- .align 2
- 0: .long _GLOBAL_OFFSET_TABLE_
- 1: .long errno@GOT
- # endif /* _LIBC_REENTRANT */
- #endif /* __PIC__ */
- # ifdef __SH4__
- # define SYSCALL_INST_PAD \
- or r0,r0
- # else
- # define SYSCALL_INST_PAD
- # endif
- #define SYSCALL_INST0 trapa #0x10
- #define SYSCALL_INST1 trapa #0x11
- #define SYSCALL_INST2 trapa #0x12
- #define SYSCALL_INST3 trapa #0x13
- #define SYSCALL_INST4 trapa #0x14
- #define SYSCALL_INST5 mov.l @(0,r15),r0; trapa #0x15
- #define SYSCALL_INST6 mov.l @(0,r15),r0; mov.l @(4,r15),r1; trapa #0x16
- #undef DO_CALL
- #define DO_CALL(syscall_name, args) \
- mov.l 1f,r3
- SYSCALL_INST##args; \
- SYSCALL_INST_PAD
- bra 2f
- nop
- .align 2
- 1: .long SYS_ify (syscall_name)
- 2:
- #endif /* __ASSEMBLER__ */
|