···11+/* Access to user system call parameters and results22+ *33+ * See asm-generic/syscall.h for function descriptions.44+ *55+ * Copyright (C) 2010 Red Hat, Inc. All Rights Reserved.66+ * Written by David Howells (dhowells@redhat.com)77+ *88+ * This program is free software; you can redistribute it and/or99+ * modify it under the terms of the GNU General Public Licence1010+ * as published by the Free Software Foundation; either version1111+ * 2 of the Licence, or (at your option) any later version.1212+ */1313+1414+#ifndef _ASM_SYSCALL_H1515+#define _ASM_SYSCALL_H1616+1717+#include <linux/sched.h>1818+#include <linux/err.h>1919+2020+extern const unsigned long sys_call_table[];2121+2222+static inline int syscall_get_nr(struct task_struct *task, struct pt_regs *regs)2323+{2424+ return regs->orig_d0;2525+}2626+2727+static inline void syscall_rollback(struct task_struct *task,2828+ struct pt_regs *regs)2929+{3030+ regs->d0 = regs->orig_d0;3131+}3232+3333+static inline long syscall_get_error(struct task_struct *task,3434+ struct pt_regs *regs)3535+{3636+ unsigned long error = regs->d0;3737+ return IS_ERR_VALUE(error) ? error : 0;3838+}3939+4040+static inline long syscall_get_return_value(struct task_struct *task,4141+ struct pt_regs *regs)4242+{4343+ return regs->d0;4444+}4545+4646+static inline void syscall_set_return_value(struct task_struct *task,4747+ struct pt_regs *regs,4848+ int error, long val)4949+{5050+ regs->d0 = (long) error ?: val;5151+}5252+5353+static inline void syscall_get_arguments(struct task_struct *task,5454+ struct pt_regs *regs,5555+ unsigned int i, unsigned int n,5656+ unsigned long *args)5757+{5858+ switch (i) {5959+ case 0:6060+ if (!n--) break;6161+ *args++ = regs->a0;6262+ case 1:6363+ if (!n--) break;6464+ *args++ = regs->d1;6565+ case 2:6666+ if (!n--) break;6767+ *args++ = regs->a3;6868+ case 3:6969+ if (!n--) break;7070+ *args++ = regs->a2;7171+ case 4:7272+ if (!n--) break;7373+ *args++ = regs->d3;7474+ case 5:7575+ if (!n--) break;7676+ *args++ = regs->d2;7777+ case 6:7878+ if (!n--) break;7979+ default:8080+ BUG();8181+ break;8282+ }8383+}8484+8585+static inline void syscall_set_arguments(struct task_struct *task,8686+ struct pt_regs *regs,8787+ unsigned int i, unsigned int n,8888+ const unsigned long *args)8989+{9090+ switch (i) {9191+ case 0:9292+ if (!n--) break;9393+ regs->a0 = *args++;9494+ case 1:9595+ if (!n--) break;9696+ regs->d1 = *args++;9797+ case 2:9898+ if (!n--) break;9999+ regs->a3 = *args++;100100+ case 3:101101+ if (!n--) break;102102+ regs->a2 = *args++;103103+ case 4:104104+ if (!n--) break;105105+ regs->d3 = *args++;106106+ case 5:107107+ if (!n--) break;108108+ regs->d2 = *args++;109109+ case 6:110110+ if (!n--) break;111111+ default:112112+ BUG();113113+ break;114114+ }115115+}116116+117117+#endif /* _ASM_SYSCALL_H */