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 align_mask = 0;
29 struct mm_struct *mm = current->mm;
30 struct vm_unmapped_area_info info;
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 = TASK_UNMAPPED_BASE;
48
49 if (map_shared && (TASK_SIZE > 0xfffffffful))
50
51
52
53
54
55
56 align_mask = PAGE_MASK & (SHMLBA - 1);
57
58 info.flags = 0;
59 info.length = len;
60 info.low_limit = addr;
61 info.high_limit = TASK_SIZE;
62 info.align_mask = align_mask;
63 info.align_offset = 0;
64 return vm_unmapped_area(&info);
65}
66
67asmlinkage long
68ia64_getpriority (int which, int who)
69{
70 long prio;
71
72 prio = sys_getpriority(which, who);
73 if (prio >= 0) {
74 force_successful_syscall_return();
75 prio = 20 - prio;
76 }
77 return prio;
78}
79
80
81asmlinkage unsigned long
82sys_getpagesize (void)
83{
84 return PAGE_SIZE;
85}
86
87asmlinkage unsigned long
88ia64_brk (unsigned long brk)
89{
90 unsigned long retval = sys_brk(brk);
91 force_successful_syscall_return();
92 return retval;
93}
94
95
96
97
98
99asmlinkage long
100sys_ia64_pipe (void)
101{
102 struct pt_regs *regs = task_pt_regs(current);
103 int fd[2];
104 int retval;
105
106 retval = do_pipe_flags(fd, 0);
107 if (retval)
108 goto out;
109 retval = fd[0];
110 regs->r9 = fd[1];
111 out:
112 return retval;
113}
114
115int ia64_mmap_check(unsigned long addr, unsigned long len,
116 unsigned long flags)
117{
118 unsigned long roff;
119
120
121
122
123
124
125 roff = REGION_OFFSET(addr);
126 if ((len > RGN_MAP_LIMIT) || (roff > (RGN_MAP_LIMIT - len)))
127 return -EINVAL;
128 return 0;
129}
130
131
132
133
134
135
136asmlinkage unsigned long
137sys_mmap2 (unsigned long addr, unsigned long len, int prot, int flags, int fd, long pgoff)
138{
139 addr = sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff);
140 if (!IS_ERR((void *) addr))
141 force_successful_syscall_return();
142 return addr;
143}
144
145asmlinkage unsigned long
146sys_mmap (unsigned long addr, unsigned long len, int prot, int flags, int fd, long off)
147{
148 if (offset_in_page(off) != 0)
149 return -EINVAL;
150
151 addr = sys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
152 if (!IS_ERR((void *) addr))
153 force_successful_syscall_return();
154 return addr;
155}
156
157asmlinkage unsigned long
158ia64_mremap (unsigned long addr, unsigned long old_len, unsigned long new_len, unsigned long flags,
159 unsigned long new_addr)
160{
161 addr = sys_mremap(addr, old_len, new_len, flags, new_addr);
162 if (!IS_ERR((void *) addr))
163 force_successful_syscall_return();
164 return addr;
165}
166
167#ifndef CONFIG_PCI
168
169asmlinkage long
170sys_pciconfig_read (unsigned long bus, unsigned long dfn, unsigned long off, unsigned long len,
171 void *buf)
172{
173 return -ENOSYS;
174}
175
176asmlinkage long
177sys_pciconfig_write (unsigned long bus, unsigned long dfn, unsigned long off, unsigned long len,
178 void *buf)
179{
180 return -ENOSYS;
181}
182
183#endif
184