]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/cris/mmap64.S
Update.
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / cris / mmap64.S
1 /* Copyright (C) 2001 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
18
19 #include <sysdep.h>
20
21 #include "kernel-features.h"
22
23 #include <asm/errno.h>
24
25 /* Rather than dragging in yet another kernel file, <asm/page.h>, we
26 define it here. Provide for easy override. */
27 #ifndef PAGE_SHIFT
28 #define PAGE_SHIFT 13
29 #endif
30
31 /* This is: __ptr_t
32 __mmap64 (__ptr_t addr, size_t len, int prot, int flags, int fd,
33 off64_t offset); */
34
35 /* This was done in C, but the resulting code didn't look anywhere near
36 nice, and mmap64 is important enough to have fast code. Rather than
37 fixing (the generic bits in) gcc, we make sure not to depend on it by
38 writing code that GCC cannot reasonably generate. */
39
40 .syntax no_register_prefix
41
42 ENTRY (__mmap64)
43
44 move [sp],mof
45 move.d [sp+4],r9
46
47 /* Only accept an offset being a multiple of PAGE_SIZE, ditto address. */
48 btstq (PAGE_SHIFT - 1),r9
49 bne 1f
50 lsrq PAGE_SHIFT,r9
51
52 btstq (PAGE_SHIFT - 1),r10
53 bne 1f
54 move.d r9,[sp]
55
56 /* We have to store the adjusted part somewhere we can "or" from.
57 No registers available, so let's re-use the incoming low-part
58 parameter location. */
59 move.d [sp+8],r9
60
61 swapwbr r9
62 /* Check if the highest bits (now the lowest bits) are zero. They
63 must be, since we're actually calling a system function
64 specifying the size in *pages* in a single dword. Thus you can
65 mmap64 PAGE_SIZE * 4 Gbyte. */
66 btstq (PAGE_SHIFT - 1),r9
67 bne 1f
68 swapwbr r9
69
70 lslq (32 - PAGE_SHIFT),r9
71 or.d [sp],r9
72 move srp,[sp]
73 move r9,srp
74
75 movu.b SYS_ify (mmap2),r9
76 break 13
77
78 cmps.w -4096,r10
79 bhs 0f
80 move [sp],srp
81
82 Ret
83 nop
84
85 /* Local error handler. */
86 1:
87 movs.w -EINVAL,r10
88 /* Drop through into the ordinary error handler. */
89 PSEUDO_END (__mmap64)
90
91 weak_alias (__mmap64, mmap64)