[PATCH] x86_64: Fix wrong PCI ID for ALI M1695 AGP bridge
[linux-2.6/verdex.git] / arch / parisc / kernel / sys_parisc.c
blobd15a1d53e101eed9713644f0ee4e9e7ae2f37d59
2 /*
3 * PARISC specific syscalls
5 * Copyright (C) 1999-2003 Matthew Wilcox <willy at parisc-linux.org>
6 * Copyright (C) 2000-2003 Paul Bame <bame at parisc-linux.org>
7 * Copyright (C) 2001 Thomas Bogendoerfer <tsbogend at parisc-linux.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include <asm/uaccess.h>
26 #include <linux/file.h>
27 #include <linux/fs.h>
28 #include <linux/linkage.h>
29 #include <linux/mm.h>
30 #include <linux/mman.h>
31 #include <linux/shm.h>
32 #include <linux/smp_lock.h>
33 #include <linux/syscalls.h>
35 int sys_pipe(int __user *fildes)
37 int fd[2];
38 int error;
40 error = do_pipe(fd);
41 if (!error) {
42 if (copy_to_user(fildes, fd, 2*sizeof(int)))
43 error = -EFAULT;
45 return error;
48 static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
50 struct vm_area_struct *vma;
52 addr = PAGE_ALIGN(addr);
54 for (vma = find_vma(current->mm, addr); ; vma = vma->vm_next) {
55 /* At this point: (!vma || addr < vma->vm_end). */
56 if (TASK_SIZE - len < addr)
57 return -ENOMEM;
58 if (!vma || addr + len <= vma->vm_start)
59 return addr;
60 addr = vma->vm_end;
64 #define DCACHE_ALIGN(addr) (((addr) + (SHMLBA - 1)) &~ (SHMLBA - 1))
67 * We need to know the offset to use. Old scheme was to look for
68 * existing mapping and use the same offset. New scheme is to use the
69 * address of the kernel data structure as the seed for the offset.
70 * We'll see how that works...
72 * The mapping is cacheline aligned, so there's no information in the bottom
73 * few bits of the address. We're looking for 10 bits (4MB / 4k), so let's
74 * drop the bottom 8 bits and use bits 8-17.
76 static int get_offset(struct address_space *mapping)
78 int offset = (unsigned long) mapping << (PAGE_SHIFT - 8);
79 return offset & 0x3FF000;
82 static unsigned long get_shared_area(struct address_space *mapping,
83 unsigned long addr, unsigned long len, unsigned long pgoff)
85 struct vm_area_struct *vma;
86 int offset = mapping ? get_offset(mapping) : 0;
88 addr = DCACHE_ALIGN(addr - offset) + offset;
90 for (vma = find_vma(current->mm, addr); ; vma = vma->vm_next) {
91 /* At this point: (!vma || addr < vma->vm_end). */
92 if (TASK_SIZE - len < addr)
93 return -ENOMEM;
94 if (!vma || addr + len <= vma->vm_start)
95 return addr;
96 addr = DCACHE_ALIGN(vma->vm_end - offset) + offset;
97 if (addr < vma->vm_end) /* handle wraparound */
98 return -ENOMEM;
102 unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
103 unsigned long len, unsigned long pgoff, unsigned long flags)
105 if (len > TASK_SIZE)
106 return -ENOMEM;
107 if (!addr)
108 addr = TASK_UNMAPPED_BASE;
110 if (filp) {
111 addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
112 } else if(flags & MAP_SHARED) {
113 addr = get_shared_area(NULL, addr, len, pgoff);
114 } else {
115 addr = get_unshared_area(addr, len);
117 return addr;
120 static unsigned long do_mmap2(unsigned long addr, unsigned long len,
121 unsigned long prot, unsigned long flags, unsigned long fd,
122 unsigned long pgoff)
124 struct file * file = NULL;
125 unsigned long error = -EBADF;
126 if (!(flags & MAP_ANONYMOUS)) {
127 file = fget(fd);
128 if (!file)
129 goto out;
132 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
134 down_write(&current->mm->mmap_sem);
135 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
136 up_write(&current->mm->mmap_sem);
138 if (file != NULL)
139 fput(file);
140 out:
141 return error;
144 asmlinkage unsigned long sys_mmap2(unsigned long addr, unsigned long len,
145 unsigned long prot, unsigned long flags, unsigned long fd,
146 unsigned long pgoff)
148 /* Make sure the shift for mmap2 is constant (12), no matter what PAGE_SIZE
149 we have. */
150 return do_mmap2(addr, len, prot, flags, fd, pgoff >> (PAGE_SHIFT - 12));
153 asmlinkage unsigned long sys_mmap(unsigned long addr, unsigned long len,
154 unsigned long prot, unsigned long flags, unsigned long fd,
155 unsigned long offset)
157 if (!(offset & ~PAGE_MASK)) {
158 return do_mmap2(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
159 } else {
160 return -EINVAL;
164 /* Fucking broken ABI */
166 #ifdef CONFIG_64BIT
167 asmlinkage long parisc_truncate64(const char __user * path,
168 unsigned int high, unsigned int low)
170 return sys_truncate(path, (long)high << 32 | low);
173 asmlinkage long parisc_ftruncate64(unsigned int fd,
174 unsigned int high, unsigned int low)
176 return sys_ftruncate(fd, (long)high << 32 | low);
179 /* stubs for the benefit of the syscall_table since truncate64 and truncate
180 * are identical on LP64 */
181 asmlinkage long sys_truncate64(const char __user * path, unsigned long length)
183 return sys_truncate(path, length);
185 asmlinkage long sys_ftruncate64(unsigned int fd, unsigned long length)
187 return sys_ftruncate(fd, length);
189 asmlinkage long sys_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg)
191 return sys_fcntl(fd, cmd, arg);
193 #else
195 asmlinkage long parisc_truncate64(const char __user * path,
196 unsigned int high, unsigned int low)
198 return sys_truncate64(path, (loff_t)high << 32 | low);
201 asmlinkage long parisc_ftruncate64(unsigned int fd,
202 unsigned int high, unsigned int low)
204 return sys_ftruncate64(fd, (loff_t)high << 32 | low);
206 #endif
208 asmlinkage ssize_t parisc_pread64(unsigned int fd, char __user *buf, size_t count,
209 unsigned int high, unsigned int low)
211 return sys_pread64(fd, buf, count, (loff_t)high << 32 | low);
214 asmlinkage ssize_t parisc_pwrite64(unsigned int fd, const char __user *buf,
215 size_t count, unsigned int high, unsigned int low)
217 return sys_pwrite64(fd, buf, count, (loff_t)high << 32 | low);
220 asmlinkage ssize_t parisc_readahead(int fd, unsigned int high, unsigned int low,
221 size_t count)
223 return sys_readahead(fd, (loff_t)high << 32 | low, count);
226 asmlinkage long parisc_fadvise64_64(int fd,
227 unsigned int high_off, unsigned int low_off,
228 unsigned int high_len, unsigned int low_len, int advice)
230 return sys_fadvise64_64(fd, (loff_t)high_off << 32 | low_off,
231 (loff_t)high_len << 32 | low_len, advice);
234 asmlinkage unsigned long sys_alloc_hugepages(int key, unsigned long addr, unsigned long len, int prot, int flag)
236 return -ENOMEM;
239 asmlinkage int sys_free_hugepages(unsigned long addr)
241 return -EINVAL;