blob: b752bb67891db2da9358abc3af1bc1f8b95c57cc [file] [log] [blame]
Jonas Bonn09abb902011-06-04 22:26:51 +03001/*
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
22#include <linux/err.h>
23#include <linux/sched.h>
24
25static inline int
26syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
27{
Jonas Bonn6cbe5e92012-03-02 10:05:24 +010028 return regs->orig_gpr11;
Jonas Bonn09abb902011-06-04 22:26:51 +030029}
30
31static inline void
32syscall_rollback(struct task_struct *task, struct pt_regs *regs)
33{
34 regs->gpr[11] = regs->orig_gpr11;
35}
36
37static inline long
38syscall_get_error(struct task_struct *task, struct pt_regs *regs)
39{
40 return IS_ERR_VALUE(regs->gpr[11]) ? regs->gpr[11] : 0;
41}
42
43static inline long
44syscall_get_return_value(struct task_struct *task, struct pt_regs *regs)
45{
46 return regs->gpr[11];
47}
48
49static inline void
50syscall_set_return_value(struct task_struct *task, struct pt_regs *regs,
51 int error, long val)
52{
Jonas Bonn6cbe5e92012-03-02 10:05:24 +010053 regs->gpr[11] = (long) error ?: val;
Jonas Bonn09abb902011-06-04 22:26:51 +030054}
55
56static inline void
57syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
58 unsigned int i, unsigned int n, unsigned long *args)
59{
60 BUG_ON(i + n > 6);
61
62 memcpy(args, &regs->gpr[3 + i], n * sizeof(args[0]));
63}
64
65static inline void
66syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
67 unsigned int i, unsigned int n, const unsigned long *args)
68{
69 BUG_ON(i + n > 6);
70
71 memcpy(&regs->gpr[3 + i], args, n * sizeof(args[0]));
72}
73
74#endif