yuezonghe | 824eb0c | 2024-06-27 02:32:26 -0700 | [diff] [blame] | 1 | /* |
| 2 | * libc/sysdeps/linux/nios2/syscall.c -- generic syscall function for linux/nios2 |
| 3 | * |
| 4 | * Copyright (C) 2004 Microtronix Datacom Ltd. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU Library General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or (at your |
| 9 | * option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License |
| 14 | * for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Library General Public License |
| 17 | * along with this program; if not, write to the Free Software Foundation, |
| 18 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ |
| 20 | |
| 21 | #include <features.h> |
| 22 | #include <errno.h> |
| 23 | #include <sys/types.h> |
| 24 | #include <sys/syscall.h> |
| 25 | |
| 26 | |
| 27 | long syscall(long sysnum, long a, long b, long c, long d, long e, long f) |
| 28 | { |
| 29 | register long _r2 __asm__("r2")=(long)TRAP_ID_SYSCALL; |
| 30 | register long _r3 __asm__("r3")=(long)sysnum; |
| 31 | |
| 32 | register long _r4 __asm__("r4")=(long)(a); |
| 33 | register long _r5 __asm__("r5")=(long)(b); |
| 34 | register long _r6 __asm__("r6")=(long)(c); |
| 35 | register long _r7 __asm__("r7")=(long)(d); |
| 36 | register long _r8 __asm__("r8")=(long)(e); |
| 37 | register long _r9 __asm__("r9")=(long)(f); |
| 38 | __asm__ __volatile__( |
| 39 | "trap " |
| 40 | : "=r"(_r2), "=r"(_r3) |
| 41 | : "0"(_r2), "1"(_r3), |
| 42 | "r"(_r4), "r"(_r5), "r"(_r6), "r"(_r7), "r"(_r8), "r"(_r9) |
| 43 | : "memory"); |
| 44 | |
| 45 | __syscall_return (long, _r2); |
| 46 | } |
| 47 | |