blob: 47ec3be3edcd6dfae91890fe8c4100d7e2593b0d [file] [log] [blame]
Arnd Bergmann2dd14932006-03-23 00:00:09 +01001/*
2 * System call callback functions for SPUs
3 */
4
5#define DEBUG
6
7#include <linux/kallsyms.h>
8#include <linux/module.h>
9#include <linux/syscalls.h>
10
11#include <asm/spu.h>
12#include <asm/syscalls.h>
13#include <asm/unistd.h>
14
15/*
16 * This table defines the system calls that an SPU can call.
17 * It is currently a subset of the 64 bit powerpc system calls,
18 * with the exact semantics.
19 *
20 * The reasons for disabling some of the system calls are:
21 * 1. They interact with the way SPU syscalls are handled
22 * and we can't let them execute ever:
23 * restart_syscall, exit, for, execve, ptrace, ...
24 * 2. They are deprecated and replaced by other means:
25 * uselib, pciconfig_*, sysfs, ...
26 * 3. They are somewhat interacting with the system in a way
27 * we don't want an SPU to:
28 * reboot, init_module, mount, kexec_load
29 * 4. They are optional and we can't rely on them being
30 * linked into the kernel. Unfortunately, the cond_syscall
31 * helper does not work here as it does not add the necessary
32 * opd symbols:
33 * mbind, mq_open, ipc, ...
34 */
35
36void *spu_syscall_table[] = {
Andreas Schwab72abd542006-06-19 22:45:04 +020037#define SYSCALL(func) sys_ni_syscall,
38#define COMPAT_SYS(func) sys_ni_syscall,
39#define PPC_SYS(func) sys_ni_syscall,
40#define OLDSYS(func) sys_ni_syscall,
41#define SYS32ONLY(func) sys_ni_syscall,
42#define SYSX(f, f3264, f32) sys_ni_syscall,
43
44#define SYSCALL_SPU(func) sys_##func,
45#define COMPAT_SYS_SPU(func) sys_##func,
46#define PPC_SYS_SPU(func) ppc_##func,
47#define SYSX_SPU(f, f3264, f32) f,
48
49#include <asm/systbl.h>
Arnd Bergmann2dd14932006-03-23 00:00:09 +010050};
51
52long spu_sys_callback(struct spu_syscall_block *s)
53{
54 long (*syscall)(u64 a1, u64 a2, u64 a3, u64 a4, u64 a5, u64 a6);
55
Arnd Bergmann23b25272006-04-18 15:24:16 +020056 if (s->nr_ret >= ARRAY_SIZE(spu_syscall_table)) {
Arnd Bergmann2dd14932006-03-23 00:00:09 +010057 pr_debug("%s: invalid syscall #%ld", __FUNCTION__, s->nr_ret);
58 return -ENOSYS;
59 }
60
David Woodhouseb471f552006-05-23 07:46:39 -070061 syscall = spu_syscall_table[s->nr_ret];
62
Arnd Bergmann2dd14932006-03-23 00:00:09 +010063#ifdef DEBUG
64 print_symbol(KERN_DEBUG "SPU-syscall %s:", (unsigned long)syscall);
65 printk("syscall%ld(%lx, %lx, %lx, %lx, %lx, %lx)\n",
66 s->nr_ret,
67 s->parm[0], s->parm[1], s->parm[2],
68 s->parm[3], s->parm[4], s->parm[5]);
69#endif
70
71 return syscall(s->parm[0], s->parm[1], s->parm[2],
72 s->parm[3], s->parm[4], s->parm[5]);
73}
74EXPORT_SYMBOL_GPL(spu_sys_callback);