1 /* syscall parameter access functions
3 * Copyright (C) 2009 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
12 #ifndef _ASM_SYSCALL_H
13 #define _ASM_SYSCALL_H
15 #include <linux/err.h>
16 #include <asm/ptrace.h>
19 * Get the system call number or -1
21 static inline long syscall_get_nr(struct task_struct
*task
,
24 return regs
->syscallno
;
28 * Restore the clobbered GR8 register
29 * (1st syscall arg was overwritten with syscall return or error)
31 static inline void syscall_rollback(struct task_struct
*task
,
34 regs
->gr8
= regs
->orig_gr8
;
38 * See if the syscall return value is an error, returning it if it is and 0 if
41 static inline long syscall_get_error(struct task_struct
*task
,
44 return IS_ERR_VALUE(regs
->gr8
) ? regs
->gr8
: 0;
48 * Get the syscall return value
50 static inline long syscall_get_return_value(struct task_struct
*task
,
57 * Set the syscall return value
59 static inline void syscall_set_return_value(struct task_struct
*task
,
70 * Retrieve the system call arguments
72 static inline void syscall_get_arguments(struct task_struct
*task
,
74 unsigned int i
, unsigned int n
,
78 * Do this simply for now. If we need to start supporting
79 * fetching arguments from arbitrary indices, this will need some
80 * extra logic. Presently there are no in-tree users that depend
85 /* Argument pattern is: GR8, GR9, GR10, GR11, GR12, GR13 */
87 case 6: args
[5] = regs
->gr13
;
88 case 5: args
[4] = regs
->gr12
;
89 case 4: args
[3] = regs
->gr11
;
90 case 3: args
[2] = regs
->gr10
;
91 case 2: args
[1] = regs
->gr9
;
92 case 1: args
[0] = regs
->gr8
;
100 * Alter the system call arguments
102 static inline void syscall_set_arguments(struct task_struct
*task
,
103 struct pt_regs
*regs
,
104 unsigned int i
, unsigned int n
,
105 const unsigned long *args
)
107 /* Same note as above applies */
111 case 6: regs
->gr13
= args
[5];
112 case 5: regs
->gr12
= args
[4];
113 case 4: regs
->gr11
= args
[3];
114 case 3: regs
->gr10
= args
[2];
115 case 2: regs
->gr9
= args
[1];
116 case 1: regs
->gr8
= args
[0];
123 #endif /* _ASM_SYSCALL_H */