aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/openrisc/include/asm/syscall.h77
-rw-r--r--arch/openrisc/include/asm/syscalls.h27
-rw-r--r--arch/openrisc/include/asm/unistd.h31
-rw-r--r--arch/openrisc/kernel/sys_call_table.c28
-rw-r--r--arch/openrisc/kernel/sys_or32.c57
5 files changed, 220 insertions, 0 deletions
diff --git a/arch/openrisc/include/asm/syscall.h b/arch/openrisc/include/asm/syscall.h
new file mode 100644
index 00000000000..9f0337055d2
--- /dev/null
+++ b/arch/openrisc/include/asm/syscall.h
@@ -0,0 +1,77 @@
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
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{
28 return regs->syscallno ? regs->syscallno : -1;
29}
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{
53 if (error)
54 regs->gpr[11] = -error;
55 else
56 regs->gpr[11] = val;
57}
58
59static inline void
60syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
61 unsigned int i, unsigned int n, unsigned long *args)
62{
63 BUG_ON(i + n > 6);
64
65 memcpy(args, &regs->gpr[3 + i], n * sizeof(args[0]));
66}
67
68static inline void
69syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
70 unsigned int i, unsigned int n, const unsigned long *args)
71{
72 BUG_ON(i + n > 6);
73
74 memcpy(&regs->gpr[3 + i], args, n * sizeof(args[0]));
75}
76
77#endif
diff --git a/arch/openrisc/include/asm/syscalls.h b/arch/openrisc/include/asm/syscalls.h
new file mode 100644
index 00000000000..84a978af44d
--- /dev/null
+++ b/arch/openrisc/include/asm/syscalls.h
@@ -0,0 +1,27 @@
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_SYSCALLS_H
20#define __ASM_OPENRISC_SYSCALLS_H
21
22asmlinkage long sys_or1k_atomic(unsigned long type, unsigned long *v1,
23 unsigned long *v2);
24
25#include <asm-generic/syscalls.h>
26
27#endif /* __ASM_OPENRISC_SYSCALLS_H */
diff --git a/arch/openrisc/include/asm/unistd.h b/arch/openrisc/include/asm/unistd.h
new file mode 100644
index 00000000000..89af3ab5c2e
--- /dev/null
+++ b/arch/openrisc/include/asm/unistd.h
@@ -0,0 +1,31 @@
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#if !defined(__ASM_OPENRISC_UNISTD_H) || defined(__SYSCALL)
20#define __ASM_OPENRISC_UNISTD_H
21
22#define __ARCH_HAVE_MMU
23
24#define sys_mmap2 sys_mmap_pgoff
25
26#include <asm-generic/unistd.h>
27
28#define __NR_or1k_atomic __NR_arch_specific_syscall
29__SYSCALL(__NR_or1k_atomic, sys_or1k_atomic)
30
31#endif /* __ASM_OPENRISC_UNISTD_H */
diff --git a/arch/openrisc/kernel/sys_call_table.c b/arch/openrisc/kernel/sys_call_table.c
new file mode 100644
index 00000000000..e1f8ce8c72a
--- /dev/null
+++ b/arch/openrisc/kernel/sys_call_table.c
@@ -0,0 +1,28 @@
1/*
2 * OpenRISC sys_call_table.c
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 * Modifications for the OpenRISC architecture:
9 * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version
14 * 2 of the License, or (at your option) any later version.
15 */
16
17#include <linux/syscalls.h>
18#include <linux/signal.h>
19#include <linux/unistd.h>
20
21#include <asm/syscalls.h>
22
23#undef __SYSCALL
24#define __SYSCALL(nr, call) [nr] = (call),
25
26void *sys_call_table[__NR_syscalls] = {
27#include <asm/unistd.h>
28};
diff --git a/arch/openrisc/kernel/sys_or32.c b/arch/openrisc/kernel/sys_or32.c
new file mode 100644
index 00000000000..57060084c0c
--- /dev/null
+++ b/arch/openrisc/kernel/sys_or32.c
@@ -0,0 +1,57 @@
1/*
2 * OpenRISC sys_or32.c
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 * Modifications for the OpenRISC architecture:
9 * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
10 * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version
15 * 2 of the License, or (at your option) any later version.
16 *
17 * This file contains various random system calls that
18 * have a non-standard calling sequence on some platforms.
19 * Since we don't have to do any backwards compatibility, our
20 * versions are done in the most "normal" way possible.
21 */
22
23#include <linux/errno.h>
24#include <linux/syscalls.h>
25#include <linux/mm.h>
26
27#include <asm/syscalls.h>
28
29/* These are secondary entry points as the primary entry points are defined in
30 * entry.S where we add the 'regs' parameter value
31 */
32
33asmlinkage long _sys_clone(unsigned long clone_flags, unsigned long newsp,
34 int __user *parent_tid, int __user *child_tid,
35 struct pt_regs *regs)
36{
37 long ret;
38
39 /* FIXME: Is alignment necessary? */
40 /* newsp = ALIGN(newsp, 4); */
41
42 if (!newsp)
43 newsp = regs->sp;
44
45 ret = do_fork(clone_flags, newsp, regs, 0, parent_tid, child_tid);
46
47 return ret;
48}
49
50asmlinkage int _sys_fork(struct pt_regs *regs)
51{
52#ifdef CONFIG_MMU
53 return do_fork(SIGCHLD, regs->sp, regs, 0, NULL, NULL);
54#else
55 return -EINVAL;
56#endif
57}