1
2
3
4
5
6
7
8#include <linux/errno.h>
9#include <linux/fs.h>
10#include <linux/mm.h>
11#include <linux/mman.h>
12#include <linux/sched.h>
13#include <linux/shm.h>
14#include <linux/file.h>
15#include <linux/smp.h>
16#include <linux/syscalls.h>
17#include <linux/highuid.h>
18#include <linux/hugetlb.h>
19
20#include <asm/shmparam.h>
21#include <asm/uaccess.h>
22
23unsigned long
24arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len,
25 unsigned long pgoff, unsigned long flags)
26{
27 long map_shared = (flags & MAP_SHARED);
28 unsigned long start_addr, align_mask = PAGE_SIZE - 1;
29 struct mm_struct *mm = current->mm;
30 struct vm_area_struct *vma;
31
32 if (len > RGN_MAP_LIMIT)
33 return -ENOMEM;
34
35
36 if (flags & MAP_FIXED) {
37 if (is_hugepage_only_range(mm, addr, len))
38 return -EINVAL;
39 return addr;
40 }
41
42#ifdef CONFIG_HUGETLB_PAGE
43 if (REGION_NUMBER(addr) == RGN_HPAGE)
44 addr = 0;
45#endif
46 if (!addr)
47 addr = mm->free_area_cache;
48
49 if (map_shared && (TASK_SIZE > 0xfffffffful))
50
51
52
53
54
55
56 align_mask = SHMLBA - 1;
57
58 full_search:
59 start_addr = addr = (addr + align_mask) & ~align_mask;
60
61 for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
62
63 if (TASK_SIZE - len < addr || RGN_MAP_LIMIT - len < REGION_OFFSET(addr)) {
64 if (start_addr != TASK_UNMAPPED_BASE) {
65
66 addr = TASK_UNMAPPED_BASE;
67 goto full_search;
68 }
69 return -ENOMEM;
70 }
71 if (!vma || addr + len <= vma->vm_start) {
72
73 mm->free_area_cache = addr + len;
74 return addr;
75 }
76 addr = (vma->vm_end + align_mask) & ~align_mask;
77 }
78}
79
80asmlinkage long
81ia64_getpriority (int which, int who)
82{
83 long prio;
84
85 prio = sys_getpriority(which, who);
86 if (prio >= 0) {
87 force_successful_syscall_return();
88 prio = 20 - prio;
89 }
90 return prio;
91}
92
93
94asmlinkage unsigned long
95sys_getpagesize (void)
96{
97 return PAGE_SIZE;
98}
99
100asmlinkage unsigned long
101ia64_brk (unsigned long brk)
102{
103 unsigned long retval = sys_brk(brk);
104 force_successful_syscall_return();
105 return retval;
106}
107
108
109
110
111
112asmlinkage long
113sys_ia64_pipe (void)
114{
115 struct pt_regs *regs = task_pt_regs(current);
116 int fd[2];
117 int retval;
118
119 retval = do_pipe_flags(fd, 0);
120 if (retval)
121 goto out;
122 retval = fd[0];
123 regs->r9 = fd[1];
124 out:
125 return retval;
126}
127
128int ia64_mmap_check(unsigned long addr, unsigned long len,
129 unsigned long flags)
130{
131 unsigned long roff;
132
133
134
135
136
137
138 roff = REGION_OFFSET(addr);
139 if ((len > RGN_MAP_LIMIT) || (roff > (RGN_MAP_LIMIT - len)))
140 return -EINVAL;
141 return 0;
142}
143
144
145
146
147
148
149asmlinkage unsigned long
150sys_mmap2 (unsigned long addr, unsigned long len, int prot, int flags, int fd, long pgoff)
151{
152 addr = sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff);
153 if (!IS_ERR((void *) addr))
154 force_successful_syscall_return();
155 return addr;
156}
157
158asmlinkage unsigned long
159sys_mmap (unsigned long addr, unsigned long len, int prot, int flags, int fd, long off)
160{
161 if (offset_in_page(off) != 0)
162 return -EINVAL;
163
164 addr = sys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
165 if (!IS_ERR((void *) addr))
166 force_successful_syscall_return();
167 return addr;
168}
169
170asmlinkage unsigned long
171ia64_mremap (unsigned long addr, unsigned long old_len, unsigned long new_len, unsigned long flags,
172 unsigned long new_addr)
173{
174 extern unsigned long do_mremap (unsigned long addr,
175 unsigned long old_len,
176 unsigned long new_len,
177 unsigned long flags,
178 unsigned long new_addr);
179
180 down_write(¤t->mm->mmap_sem);
181 {
182 addr = do_mremap(addr, old_len, new_len, flags, new_addr);
183 }
184 up_write(¤t->mm->mmap_sem);
185
186 if (IS_ERR((void *) addr))
187 return addr;
188
189 force_successful_syscall_return();
190 return addr;
191}
192
193#ifndef CONFIG_PCI
194
195asmlinkage long
196sys_pciconfig_read (unsigned long bus, unsigned long dfn, unsigned long off, unsigned long len,
197 void *buf)
198{
199 return -ENOSYS;
200}
201
202asmlinkage long
203sys_pciconfig_write (unsigned long bus, unsigned long dfn, unsigned long off, unsigned long len,
204 void *buf)
205{
206 return -ENOSYS;
207}
208
209#endif
210