[444] | 1 | #ifndef _SYSCALLASM_H_ |
---|
| 2 | #define _SYSCALLASM_H_ |
---|
| 3 | |
---|
| 4 | /* |
---|
| 5 | * This file defines the system calls for SPARC for the assembler. |
---|
| 6 | * Anything C-ish is not allowed in this file. |
---|
| 7 | * C files should include syscall.h. |
---|
| 8 | */ |
---|
| 9 | |
---|
| 10 | #include <sys/syscall.h> |
---|
| 11 | |
---|
| 12 | /* Some macros for writing assember syscall stubs. */ |
---|
| 13 | |
---|
| 14 | #ifdef __svr4__ |
---|
| 15 | #define TEXT_SECTION .section ".text" |
---|
| 16 | #define DATA_SECTION .section ".data" |
---|
| 17 | #define ALIGN(x) .align x |
---|
| 18 | #define GLOBAL(sym) .global sym |
---|
| 19 | #define WORD(x) .long x |
---|
| 20 | #define ASM_SYMBOL(name) name |
---|
| 21 | #define ASM_PRIVATE_SYMBOL(name) _##name |
---|
| 22 | #define SYSCALL_TRAP 8 |
---|
| 23 | #else |
---|
| 24 | #define TEXT_SECTION .text |
---|
| 25 | #define DATA_SECTION .data |
---|
| 26 | #define ALIGN(x) .align x |
---|
| 27 | #define GLOBAL(sym) .global sym |
---|
| 28 | #define WORD(x) .word x |
---|
| 29 | #define ASM_SYMBOL(name) _##name |
---|
| 30 | #define ASM_PRIVATE_SYMBOL(name) name |
---|
| 31 | #define SYSCALL_TRAP 0 |
---|
| 32 | #endif |
---|
| 33 | |
---|
| 34 | #define defsyscall(name, n) \ |
---|
| 35 | TEXT_SECTION ; \ |
---|
| 36 | ALIGN (4) ; \ |
---|
| 37 | GLOBAL (ASM_SYMBOL (name)) ; \ |
---|
| 38 | ASM_SYMBOL (name): \ |
---|
| 39 | mov n,%g1 ; \ |
---|
| 40 | ta %icc,SYSCALL_TRAP ; \ |
---|
| 41 | bcc noerr ; \ |
---|
| 42 | sethi %hi (ASM_PRIVATE_SYMBOL (cerror)),%g1 ; \ |
---|
| 43 | or %g1,%lo (ASM_PRIVATE_SYMBOL (cerror)),%g1 ; \ |
---|
| 44 | jmpl %g1+%g0,%g0 ; \ |
---|
| 45 | nop ; \ |
---|
| 46 | noerr: \ |
---|
| 47 | jmpl %o7+8,%g0 ; \ |
---|
| 48 | nop |
---|
| 49 | |
---|
| 50 | /* Support for reentrant syscalls. The "struct _reent *" arg is always the |
---|
| 51 | the first one. After that we allow up to four additional args. We could |
---|
| 52 | allow more, but that's all we need for now. |
---|
| 53 | |
---|
| 54 | It may seem inefficient to have the reent arg be the first one as it means |
---|
| 55 | copying all the other args into place (as opposed to making the reent arg |
---|
| 56 | the last one in which case there wouldn't be any copying). I chose a clean |
---|
| 57 | design over an extra four instructions in a system call. All other |
---|
| 58 | reentrant functions use the first arg this way. */ |
---|
| 59 | |
---|
| 60 | #define defsyscall_r(name, n) \ |
---|
| 61 | TEXT_SECTION ; \ |
---|
| 62 | ALIGN (4) ; \ |
---|
| 63 | GLOBAL (ASM_SYMBOL (name)) ; \ |
---|
| 64 | ASM_SYMBOL (name): \ |
---|
| 65 | mov n,%g1 ; \ |
---|
| 66 | mov %o0,%o5 ; \ |
---|
| 67 | mov %o1,%o0 ; \ |
---|
| 68 | mov %o2,%o1 ; \ |
---|
| 69 | mov %o3,%o2 ; \ |
---|
| 70 | mov %o4,%o3 ; \ |
---|
| 71 | ta %icc,SYSCALL_TRAP ; \ |
---|
| 72 | bcc noerr ; \ |
---|
| 73 | sethi %hi (ASM_PRIVATE_SYMBOL (cerror_r)),%g1 ; \ |
---|
| 74 | or %g1,%lo (ASM_PRIVATE_SYMBOL (cerror_r)),%g1 ; \ |
---|
| 75 | jmpl %g1+%g0,%g0 ; \ |
---|
| 76 | mov %o5,%o1 ; \ |
---|
| 77 | noerr: \ |
---|
| 78 | jmpl %o7+8,%g0 ; \ |
---|
| 79 | nop |
---|
| 80 | |
---|
| 81 | #define seterrno() \ |
---|
| 82 | sethi %hi (ASM_PRIVATE_SYMBOL (cerror)),%g1 ; \ |
---|
| 83 | or %g1,%lo (ASM_PRIVATE_SYMBOL (cerror)),%g1 ; \ |
---|
| 84 | jmpl %g1+%g0,%g0 ; \ |
---|
| 85 | nop |
---|
| 86 | |
---|
| 87 | #endif /* _SYSCALLASM_H_ */ |
---|