1*d5b37092SMichal Simek #ifndef __ASM_MICROBLAZE_SYSCALL_H 2*d5b37092SMichal Simek #define __ASM_MICROBLAZE_SYSCALL_H 3*d5b37092SMichal Simek 4*d5b37092SMichal Simek #include <linux/kernel.h> 5*d5b37092SMichal Simek #include <linux/sched.h> 6*d5b37092SMichal Simek #include <asm/ptrace.h> 7*d5b37092SMichal Simek 8*d5b37092SMichal Simek /* The system call number is given by the user in R12 */ 9*d5b37092SMichal Simek static inline long syscall_get_nr(struct task_struct *task, 10*d5b37092SMichal Simek struct pt_regs *regs) 11*d5b37092SMichal Simek { 12*d5b37092SMichal Simek return regs->r12; 13*d5b37092SMichal Simek } 14*d5b37092SMichal Simek 15*d5b37092SMichal Simek static inline void syscall_rollback(struct task_struct *task, 16*d5b37092SMichal Simek struct pt_regs *regs) 17*d5b37092SMichal Simek { 18*d5b37092SMichal Simek /* TODO. */ 19*d5b37092SMichal Simek } 20*d5b37092SMichal Simek 21*d5b37092SMichal Simek static inline long syscall_get_error(struct task_struct *task, 22*d5b37092SMichal Simek struct pt_regs *regs) 23*d5b37092SMichal Simek { 24*d5b37092SMichal Simek return IS_ERR_VALUE(regs->r3) ? regs->r3 : 0; 25*d5b37092SMichal Simek } 26*d5b37092SMichal Simek 27*d5b37092SMichal Simek static inline long syscall_get_return_value(struct task_struct *task, 28*d5b37092SMichal Simek struct pt_regs *regs) 29*d5b37092SMichal Simek { 30*d5b37092SMichal Simek return regs->r3; 31*d5b37092SMichal Simek } 32*d5b37092SMichal Simek 33*d5b37092SMichal Simek static inline void syscall_set_return_value(struct task_struct *task, 34*d5b37092SMichal Simek struct pt_regs *regs, 35*d5b37092SMichal Simek int error, long val) 36*d5b37092SMichal Simek { 37*d5b37092SMichal Simek if (error) 38*d5b37092SMichal Simek regs->r3 = -error; 39*d5b37092SMichal Simek else 40*d5b37092SMichal Simek regs->r3 = val; 41*d5b37092SMichal Simek } 42*d5b37092SMichal Simek 43*d5b37092SMichal Simek static inline microblaze_reg_t microblaze_get_syscall_arg(struct pt_regs *regs, 44*d5b37092SMichal Simek unsigned int n) 45*d5b37092SMichal Simek { 46*d5b37092SMichal Simek switch (n) { 47*d5b37092SMichal Simek case 5: return regs->r10; 48*d5b37092SMichal Simek case 4: return regs->r9; 49*d5b37092SMichal Simek case 3: return regs->r8; 50*d5b37092SMichal Simek case 2: return regs->r7; 51*d5b37092SMichal Simek case 1: return regs->r6; 52*d5b37092SMichal Simek case 0: return regs->r5; 53*d5b37092SMichal Simek default: 54*d5b37092SMichal Simek BUG(); 55*d5b37092SMichal Simek } 56*d5b37092SMichal Simek return ~0; 57*d5b37092SMichal Simek } 58*d5b37092SMichal Simek 59*d5b37092SMichal Simek static inline void microblaze_set_syscall_arg(struct pt_regs *regs, 60*d5b37092SMichal Simek unsigned int n, 61*d5b37092SMichal Simek unsigned long val) 62*d5b37092SMichal Simek { 63*d5b37092SMichal Simek switch (n) { 64*d5b37092SMichal Simek case 5: 65*d5b37092SMichal Simek regs->r10 = val; 66*d5b37092SMichal Simek case 4: 67*d5b37092SMichal Simek regs->r9 = val; 68*d5b37092SMichal Simek case 3: 69*d5b37092SMichal Simek regs->r8 = val; 70*d5b37092SMichal Simek case 2: 71*d5b37092SMichal Simek regs->r7 = val; 72*d5b37092SMichal Simek case 1: 73*d5b37092SMichal Simek regs->r6 = val; 74*d5b37092SMichal Simek case 0: 75*d5b37092SMichal Simek regs->r5 = val; 76*d5b37092SMichal Simek default: 77*d5b37092SMichal Simek BUG(); 78*d5b37092SMichal Simek } 79*d5b37092SMichal Simek } 80*d5b37092SMichal Simek 81*d5b37092SMichal Simek static inline void syscall_get_arguments(struct task_struct *task, 82*d5b37092SMichal Simek struct pt_regs *regs, 83*d5b37092SMichal Simek unsigned int i, unsigned int n, 84*d5b37092SMichal Simek unsigned long *args) 85*d5b37092SMichal Simek { 86*d5b37092SMichal Simek while (n--) 87*d5b37092SMichal Simek *args++ = microblaze_get_syscall_arg(regs, i++); 88*d5b37092SMichal Simek } 89*d5b37092SMichal Simek 90*d5b37092SMichal Simek static inline void syscall_set_arguments(struct task_struct *task, 91*d5b37092SMichal Simek struct pt_regs *regs, 92*d5b37092SMichal Simek unsigned int i, unsigned int n, 93*d5b37092SMichal Simek const unsigned long *args) 94*d5b37092SMichal Simek { 95*d5b37092SMichal Simek while (n--) 96*d5b37092SMichal Simek microblaze_set_syscall_arg(regs, i++, *args++); 97*d5b37092SMichal Simek } 98*d5b37092SMichal Simek 99*d5b37092SMichal Simek #endif /* __ASM_MICROBLAZE_SYSCALL_H */ 100