David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2011 Texas Instruments Incorporated |
| 4 | * Author: Mark Salter <msalter@redhat.com> |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #ifndef __ASM_C6X_SYSCALL_H |
| 8 | #define __ASM_C6X_SYSCALL_H |
| 9 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 10 | #include <uapi/linux/audit.h> |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 11 | #include <linux/err.h> |
| 12 | #include <linux/sched.h> |
| 13 | |
| 14 | static inline int syscall_get_nr(struct task_struct *task, |
| 15 | struct pt_regs *regs) |
| 16 | { |
| 17 | return regs->b0; |
| 18 | } |
| 19 | |
| 20 | static inline void syscall_rollback(struct task_struct *task, |
| 21 | struct pt_regs *regs) |
| 22 | { |
| 23 | /* do nothing */ |
| 24 | } |
| 25 | |
| 26 | static inline long syscall_get_error(struct task_struct *task, |
| 27 | struct pt_regs *regs) |
| 28 | { |
| 29 | return IS_ERR_VALUE(regs->a4) ? regs->a4 : 0; |
| 30 | } |
| 31 | |
| 32 | static inline long syscall_get_return_value(struct task_struct *task, |
| 33 | struct pt_regs *regs) |
| 34 | { |
| 35 | return regs->a4; |
| 36 | } |
| 37 | |
| 38 | static inline void syscall_set_return_value(struct task_struct *task, |
| 39 | struct pt_regs *regs, |
| 40 | int error, long val) |
| 41 | { |
| 42 | regs->a4 = error ?: val; |
| 43 | } |
| 44 | |
| 45 | static inline void syscall_get_arguments(struct task_struct *task, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 46 | struct pt_regs *regs, |
| 47 | unsigned long *args) |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 48 | { |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 49 | *args++ = regs->a4; |
| 50 | *args++ = regs->b4; |
| 51 | *args++ = regs->a6; |
| 52 | *args++ = regs->b6; |
| 53 | *args++ = regs->a8; |
| 54 | *args = regs->b8; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | static inline void syscall_set_arguments(struct task_struct *task, |
| 58 | struct pt_regs *regs, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 59 | const unsigned long *args) |
| 60 | { |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 61 | regs->a4 = *args++; |
| 62 | regs->b4 = *args++; |
| 63 | regs->a6 = *args++; |
| 64 | regs->b6 = *args++; |
| 65 | regs->a8 = *args++; |
| 66 | regs->a9 = *args; |
| 67 | } |
| 68 | |
| 69 | static inline int syscall_get_arch(struct task_struct *task) |
| 70 | { |
| 71 | return IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) |
| 72 | ? AUDIT_ARCH_C6XBE : AUDIT_ARCH_C6X; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | #endif /* __ASM_C6X_SYSCALLS_H */ |