source: trunk/sys/dietlibc/cpu/mipsel/cpu_syscall.c @ 190

Last change on this file since 190 was 1, checked in by alain, 8 years ago

First import

File size: 2.0 KB
RevLine 
[1]1/*
2   This file is part of MutekP.
3 
4   MutekP is free software; you can redistribute it and/or modify it
5   under the terms of the GNU General Public License as published by
6   the Free Software Foundation; either version 2 of the License, or
7   (at your option) any later version.
8 
9   MutekP 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.  See the GNU
12   General Public License for more details.
13 
14   You should have received a copy of the GNU General Public License
15   along with MutekP; if not, write to the Free Software Foundation,
16   Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 
18   UPMC / LIP6 / SOC (c) 2008
19   Copyright Ghassan Almaless <ghassan.almaless@gmail.com>
20*/
21
22#include <errno.h>
23#include <sys/syscall.h>
24#include <cpu-syscall.h>
25#include <unistd.h>
26
27#ifdef __mips__
28
29void* __attribute__((noinline)) 
30cpu_syscall(void *arg0, void *arg1, void *arg2, void *arg3, int service_nr)
31{
32  register unsigned long err;
33  register unsigned long val;
34  register void *errno_ptr;
35
36  /* First of all, call the kernel */
37  __asm__ volatile
38    ("or   $2,   $0,    %2   \n"
39     "syscall                \n"
40     "or   %0,   $0,    $2   \n"
41     "or   %1,   $0,    $3   \n"
42     :"=&r"(val), "=&r"(err): "r"(service_nr): "$2","$3","$4","$5","$6","$7");
43  /* ----------------------------- */
44
45  errno_ptr = __errno_location();
46  *(int*)errno_ptr = err;
47  return (void*)val;
48}
49#endif
50
51
52#if defined(__i386__) || defined(__x86_64__) || defined(__ia64__)
53void* __attribute__((noinline))
54cpu_syscall(void *arg0, void *arg1, void *arg2, void *arg3, int service_nr)
55{
56  register unsigned long err;
57  register unsigned long val;
58
59  __asm__ volatile
60    ("int  $0x60         \n"
61     "movl %%eax, %0     \n"
62     "movl %%esi, %1     \n"
63     :"=r"(val), "=r"(err)
64     :"a"(service_nr), "b"(arg0), "c"(arg1), "d"(arg2), "D"(arg3)
65     :"%esi");
66
67  errno = err;
68  return (void*)val;
69}
70#endif
Note: See TracBrowser for help on using the repository browser.