Jonas Bonn | 09abb90 | 2011-06-04 22:26:51 +0300 | [diff] [blame] | 1 | /* |
| 2 | * OpenRISC Linux |
| 3 | * |
| 4 | * Linux architectural port borrowing liberally from similar works of |
| 5 | * others. All original copyrights apply as per the original source |
| 6 | * declaration. |
| 7 | * |
| 8 | * OpenRISC implementation: |
| 9 | * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com> |
| 10 | * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se> |
| 11 | * et al. |
| 12 | * |
| 13 | * This program is free software; you can redistribute it and/or modify |
| 14 | * it under the terms of the GNU General Public License as published by |
| 15 | * the Free Software Foundation; either version 2 of the License, or |
| 16 | * (at your option) any later version. |
| 17 | */ |
| 18 | |
| 19 | #ifndef __ASM_OPENRISC_SYSCALL_H__ |
| 20 | #define __ASM_OPENRISC_SYSCALL_H__ |
| 21 | |
Eric Paris | ce5d112 | 2014-03-11 13:50:46 -0400 | [diff] [blame] | 22 | #include <uapi/linux/audit.h> |
Jonas Bonn | 09abb90 | 2011-06-04 22:26:51 +0300 | [diff] [blame] | 23 | #include <linux/err.h> |
| 24 | #include <linux/sched.h> |
| 25 | |
| 26 | static inline int |
| 27 | syscall_get_nr(struct task_struct *task, struct pt_regs *regs) |
| 28 | { |
Jonas Bonn | 6cbe5e9 | 2012-03-02 10:05:24 +0100 | [diff] [blame] | 29 | return regs->orig_gpr11; |
Jonas Bonn | 09abb90 | 2011-06-04 22:26:51 +0300 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | static inline void |
| 33 | syscall_rollback(struct task_struct *task, struct pt_regs *regs) |
| 34 | { |
| 35 | regs->gpr[11] = regs->orig_gpr11; |
| 36 | } |
| 37 | |
| 38 | static inline long |
| 39 | syscall_get_error(struct task_struct *task, struct pt_regs *regs) |
| 40 | { |
| 41 | return IS_ERR_VALUE(regs->gpr[11]) ? regs->gpr[11] : 0; |
| 42 | } |
| 43 | |
| 44 | static inline long |
| 45 | syscall_get_return_value(struct task_struct *task, struct pt_regs *regs) |
| 46 | { |
| 47 | return regs->gpr[11]; |
| 48 | } |
| 49 | |
| 50 | static inline void |
| 51 | syscall_set_return_value(struct task_struct *task, struct pt_regs *regs, |
| 52 | int error, long val) |
| 53 | { |
Jonas Bonn | 6cbe5e9 | 2012-03-02 10:05:24 +0100 | [diff] [blame] | 54 | regs->gpr[11] = (long) error ?: val; |
Jonas Bonn | 09abb90 | 2011-06-04 22:26:51 +0300 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | static inline void |
| 58 | syscall_get_arguments(struct task_struct *task, struct pt_regs *regs, |
| 59 | unsigned int i, unsigned int n, unsigned long *args) |
| 60 | { |
| 61 | BUG_ON(i + n > 6); |
| 62 | |
| 63 | memcpy(args, ®s->gpr[3 + i], n * sizeof(args[0])); |
| 64 | } |
| 65 | |
| 66 | static inline void |
| 67 | syscall_set_arguments(struct task_struct *task, struct pt_regs *regs, |
| 68 | unsigned int i, unsigned int n, const unsigned long *args) |
| 69 | { |
| 70 | BUG_ON(i + n > 6); |
| 71 | |
| 72 | memcpy(®s->gpr[3 + i], args, n * sizeof(args[0])); |
| 73 | } |
| 74 | |
Eric Paris | ce5d112 | 2014-03-11 13:50:46 -0400 | [diff] [blame] | 75 | static inline int syscall_get_arch(void) |
| 76 | { |
| 77 | return AUDIT_ARCH_OPENRISC; |
| 78 | } |
Jonas Bonn | 09abb90 | 2011-06-04 22:26:51 +0300 | [diff] [blame] | 79 | #endif |