OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [linux/] [uClibc/] [libc/] [sysdeps/] [linux/] [i386/] [syscall.S] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1325 phoenix
/*
2
 * June 27, 2001             Manuel Novoa III
3
 *
4
 * This is a heavily modified version of gcc's output for the _syscall5 macro.
5
 * The idea (originally from dietlibc) is that all syscall functions simply set
6
 * the syscall number as the first argument, then set the syscall arguments as
7
 * the next up-to-five arguments, and then jump here.  All the common work is
8
 * done by syscall(), saving a fair amount of generated code when a number of
9
 * syscalls are used.  The (potential) cost is some unnecessary pushes, pops,
10
 * and movs but the execution time penalty should be relatively small compared
11
 * to the cost of the syscall itself.
12
 *
13
 * July 24, 2002
14
 *
15
 * Modified by Erik Andersen to take all function parameters from off the stack
16
 * like a proper function and eliminates the old 255 syscall number limit.  So
17
 * now we can just call this as a function as syscall() per the function
18
 * prototype in unistd.h, so to call _exit(42) you can just call.
19
 *         syscall(__NR_exit, 42);
20
 * and things will just work.
21
 */
22
 
23
.text
24
        .align 4
25
.globl syscall
26
        .type    syscall,@function
27
syscall:
28
        pushl %edi
29
        pushl %esi
30
        pushl %ebx
31
        movl  36(%esp),%edi;    /* Load the 5 syscall argument registers */
32
        movl  32(%esp),%esi;
33
        movl  28(%esp),%edx;
34
        movl  24(%esp),%ecx;
35
        movl  20(%esp),%ebx;
36
        movl  16(%esp),%eax     /* Load syscall number into %eax.  */
37
#APP
38
        int $0x80
39
#NO_APP
40
        cmpl $-4095,%eax
41
        jbe .Ldone
42
 
43
#ifdef __PIC__
44
        call Lhere
45
Lhere:
46
        popl %ebx
47
        addl $_GLOBAL_OFFSET_TABLE_+[.-Lhere],%ebx
48
        negl %eax
49
        movl %eax,%ecx
50
#ifdef __UCLIBC_HAS_THREADS__
51
        call __errno_location@PLT
52
#else
53
        movl errno@GOT(%ebx),%eax
54
#endif /* __UCLIBC_HAS_THREADS__ */
55
        movl %ecx,(%eax)
56
#else
57
        negl %eax
58
#ifdef __UCLIBC_HAS_THREADS__
59
        movl %eax,%ecx
60
        call __errno_location
61
        movl %ecx,(%eax)
62
#else
63
        movl %eax,errno
64
#endif /* __UCLIBC_HAS_THREADS__ */
65
 
66
#endif /* __PIC__ */
67
 
68
        movl $-1,%eax
69
        .p2align 4,,7
70
.Ldone:
71
        popl %ebx
72
        popl %esi
73
        popl %edi
74
        ret
75
.Lsize:
76
        .size    syscall,.Lsize-syscall

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.