]>
Commit | Line | Data |
---|---|---|
f1ba1285 RM |
1 | /* |
2 | * Access to user system call parameters and results | |
3 | * | |
4 | * Copyright (C) 2008 Red Hat, Inc. All rights reserved. | |
5 | * | |
6 | * This copyrighted material is made available to anyone wishing to use, | |
7 | * modify, copy, or redistribute it subject to the terms and conditions | |
8 | * of the GNU General Public License v.2. | |
9 | * | |
10 | * See asm-generic/syscall.h for descriptions of what we must do here. | |
11 | */ | |
12 | ||
13 | #ifndef _ASM_SYSCALL_H | |
14 | #define _ASM_SYSCALL_H 1 | |
15 | ||
ce5d1128 | 16 | #include <uapi/linux/audit.h> |
f1ba1285 | 17 | #include <linux/sched.h> |
75dddcbd | 18 | #include <linux/thread_info.h> |
f1ba1285 | 19 | |
02424d89 IM |
20 | /* ftrace syscalls requires exporting the sys_call_table */ |
21 | #ifdef CONFIG_FTRACE_SYSCALLS | |
1028ccf5 | 22 | extern const unsigned long sys_call_table[]; |
02424d89 IM |
23 | #endif /* CONFIG_FTRACE_SYSCALLS */ |
24 | ||
f1ba1285 RM |
25 | static inline long syscall_get_nr(struct task_struct *task, |
26 | struct pt_regs *regs) | |
27 | { | |
28 | return TRAP(regs) == 0xc00 ? regs->gpr[0] : -1L; | |
29 | } | |
30 | ||
31 | static inline void syscall_rollback(struct task_struct *task, | |
32 | struct pt_regs *regs) | |
33 | { | |
34 | regs->gpr[3] = regs->orig_gpr3; | |
35 | } | |
36 | ||
f1ba1285 RM |
37 | static inline long syscall_get_return_value(struct task_struct *task, |
38 | struct pt_regs *regs) | |
39 | { | |
40 | return regs->gpr[3]; | |
41 | } | |
42 | ||
43 | static inline void syscall_set_return_value(struct task_struct *task, | |
44 | struct pt_regs *regs, | |
45 | int error, long val) | |
46 | { | |
47 | if (error) { | |
409d241b | 48 | regs->ccr |= 0x10000000L; |
f1ba1285 RM |
49 | regs->gpr[3] = -error; |
50 | } else { | |
409d241b | 51 | regs->ccr &= ~0x10000000L; |
f1ba1285 RM |
52 | regs->gpr[3] = val; |
53 | } | |
54 | } | |
55 | ||
56 | static inline void syscall_get_arguments(struct task_struct *task, | |
57 | struct pt_regs *regs, | |
58 | unsigned int i, unsigned int n, | |
59 | unsigned long *args) | |
60 | { | |
61 | BUG_ON(i + n > 6); | |
62 | #ifdef CONFIG_PPC64 | |
63 | if (test_tsk_thread_flag(task, TIF_32BIT)) { | |
64 | /* | |
65 | * Zero-extend 32-bit argument values. The high bits are | |
66 | * garbage ignored by the actual syscall dispatch. | |
67 | */ | |
68 | while (n-- > 0) | |
69 | args[n] = (u32) regs->gpr[3 + i + n]; | |
70 | return; | |
71 | } | |
72 | #endif | |
73 | memcpy(args, ®s->gpr[3 + i], n * sizeof(args[0])); | |
74 | } | |
75 | ||
76 | static inline void syscall_set_arguments(struct task_struct *task, | |
77 | struct pt_regs *regs, | |
78 | unsigned int i, unsigned int n, | |
79 | const unsigned long *args) | |
80 | { | |
81 | BUG_ON(i + n > 6); | |
82 | memcpy(®s->gpr[3 + i], args, n * sizeof(args[0])); | |
83 | } | |
84 | ||
ce5d1128 EP |
85 | static inline int syscall_get_arch(void) |
86 | { | |
63f13448 RGB |
87 | int arch = is_32bit_task() ? AUDIT_ARCH_PPC : AUDIT_ARCH_PPC64; |
88 | #ifdef __LITTLE_ENDIAN__ | |
89 | arch |= __AUDIT_ARCH_LE; | |
90 | #endif | |
91 | return arch; | |
ce5d1128 | 92 | } |
f1ba1285 | 93 | #endif /* _ASM_SYSCALL_H */ |