Replace FSF snail mail address with URLs.
[glibc.git] / sysdeps / unix / sysv / linux / s390 / s390-32 / mmap64.S
blobad6d254db17abc140e9065ae8afa663f23fa79bf
1 /* Copyright (C) 2000, 2001, 2007 Free Software Foundation, Inc.
2    Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
3    This file is part of the GNU C Library.
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, see
17    <http://www.gnu.org/licenses/>.  */
19 #include <sysdep.h>
20 #include <kernel-features.h>
22 #define EINVAL  22
23 #define ENOSYS  38
25         .text
26 ENTRY(__mmap64)
27         /* Save registers and setup stack frame.  */
28         stm     %r6,%r15,24(%r15)
29         cfi_offset (%r15, -36)
30         cfi_offset (%r14, -40)
31         cfi_offset (%r13, -44)
32         cfi_offset (%r12, -48)
33         cfi_offset (%r11, -52)
34         cfi_offset (%r10, -56)
35         cfi_offset (%r9, -60)
36         cfi_offset (%r8, -64)
37         cfi_offset (%r7, -68)
38         cfi_offset (%r6, -72)
39         lr      %r1,%r15
40         ahi     %r15,-120               /* Buy stack space.   */
41         cfi_adjust_cfa_offset (120)
42         st      %r1,0(%r15)             /* Store back chain.  */
44         /* Store parameters on stack, because mmap2 and old_mmap
45          * take only one parameter: a pointer to the parameter area.  */
46         st      %r6,0x70(%r15)          /* Store 'fd'.      */
47         st      %r5,0x6C(%r15)          /* Store 'flags'.   */
48         st      %r4,0x68(%r15)          /* Store 'prot'.    */
49         st      %r3,0x64(%r15)          /* Store 'length'.  */
50         st      %r2,0x60(%r15)          /* Store 'start'.   */
52 #ifdef __NR_mmap2
53         lm      %r0,%r1,216(%r15)       /* Load 64 bit offset.  */
54         tml     %r1,0x0fff              /* Offset page aligned ?  */
55         jnz     2f                      /* No -> EINVAL.  */
56         srdl    %r0,12                  /* mmap2 takes the offset in pages.  */
57         ltr     %r0,%r0                 /* Offset > 2^44 ?  */
58         jnz     2f
59         st      %r1,0x74(%r15)          /* Store page offset.  */
61         la      %r2,0x60(%r15)          /* Load address of parameter list.  */
62         svc     SYS_ify(mmap2)          /* Do the system call trap.  */
64 #ifndef __ASSUME_MMAP2_SYSCALL
65         chi     %r2,-ENOSYS
66         je      1f
67 #endif
69         l       %r15,0(%r15)            /* Load back chain.  */
70         cfi_adjust_cfa_offset (-120)
71         lm      %r6,%r15,24(%r15)       /* Load registers.  */
73         /* Check gpr 2 for error.  */
74         lhi     %r0,-4096
75         clr     %r2,%r0
76         jnl     SYSCALL_ERROR_LABEL
78         /* Successful; return the syscall's value.  */
79         br      %r14
81 #endif
83 #if !defined __ASSUME_MMAP2_SYSCALL || !defined __NR_mmap2
84 1:      lm      %r0,%r1,216(%r15)       /* Load 64 bit offset.  */
85         st      %r1,0x74(%r15)          /* Store lower word of offset.  */
86         ltr     %r0,%r0                 /* Offset > 2^32 ?  */
87         jnz     2f
88         alr     %r1,%r3                 /* Add length to offset.  */
89         brc     3,2f                    /* Carry -> EINVAL.  */
91         la      %r2,0x60(%r15)          /* Load address of parameter list.  */
92         svc     SYS_ify(mmap)   /* Do the system call trap.  */
94         l       %r15,0(%r15)            /* Load back chain.  */
95         lm      %r6,%r15,24(%r15)       /* Load registers.  */
97         /* Check gpr 2 for error.  */
98         lhi     %r0,-4096
99         clr     %r2,%r0
100         jnl     SYSCALL_ERROR_LABEL
102         /* Successful; return the syscall's value.  */
103         br      %r14
104 #endif
106 2:      lhi     %r2,-EINVAL
107         l       %r15,0(%r15)            /* Load back chain.  */
108         lm      %r6,%r15,24(%r15)       /* Load registers.  */
109         j       SYSCALL_ERROR_LABEL
111 PSEUDO_END (__mmap64)
113 weak_alias (__mmap64, mmap64)