Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris...
[linux/fpc-iii.git] / arch / tile / include / asm / syscall.h
blob9644b88f133da73a0abd5e1d9ce61f64c4ac70cb
1 /*
2 * Copyright (C) 2008-2009 Red Hat, Inc. All rights reserved.
3 * Copyright 2010 Tilera Corporation. All Rights Reserved.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation, version 2.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
12 * NON INFRINGEMENT. See the GNU General Public License for
13 * more details.
15 * See asm-generic/syscall.h for descriptions of what we must do here.
18 #ifndef _ASM_TILE_SYSCALL_H
19 #define _ASM_TILE_SYSCALL_H
21 #include <linux/sched.h>
22 #include <linux/err.h>
23 #include <arch/abi.h>
25 /* The array of function pointers for syscalls. */
26 extern void *sys_call_table[];
27 #ifdef CONFIG_COMPAT
28 extern void *compat_sys_call_table[];
29 #endif
32 * Only the low 32 bits of orig_r0 are meaningful, so we return int.
33 * This importantly ignores the high bits on 64-bit, so comparisons
34 * sign-extend the low 32 bits.
36 static inline int syscall_get_nr(struct task_struct *t, struct pt_regs *regs)
38 return regs->regs[TREG_SYSCALL_NR];
41 static inline void syscall_rollback(struct task_struct *task,
42 struct pt_regs *regs)
44 regs->regs[0] = regs->orig_r0;
47 static inline long syscall_get_error(struct task_struct *task,
48 struct pt_regs *regs)
50 unsigned long error = regs->regs[0];
51 return IS_ERR_VALUE(error) ? error : 0;
54 static inline long syscall_get_return_value(struct task_struct *task,
55 struct pt_regs *regs)
57 return regs->regs[0];
60 static inline void syscall_set_return_value(struct task_struct *task,
61 struct pt_regs *regs,
62 int error, long val)
64 regs->regs[0] = (long) error ?: val;
67 static inline void syscall_get_arguments(struct task_struct *task,
68 struct pt_regs *regs,
69 unsigned int i, unsigned int n,
70 unsigned long *args)
72 BUG_ON(i + n > 6);
73 memcpy(args, &regs[i], n * sizeof(args[0]));
76 static inline void syscall_set_arguments(struct task_struct *task,
77 struct pt_regs *regs,
78 unsigned int i, unsigned int n,
79 const unsigned long *args)
81 BUG_ON(i + n > 6);
82 memcpy(&regs[i], args, n * sizeof(args[0]));
85 #endif /* _ASM_TILE_SYSCALL_H */