| Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * File:         arch/blackfin/kernel/sys_bfin.c | 
|  | 3 | * Based on: | 
|  | 4 | * Author: | 
|  | 5 | * | 
|  | 6 | * Created: | 
|  | 7 | * Description:  This file contains various random system calls that | 
|  | 8 | *               have a non-standard calling sequence on the Linux/bfin | 
|  | 9 | *               platform. | 
|  | 10 | * | 
|  | 11 | * Modified: | 
|  | 12 | *               Copyright 2004-2006 Analog Devices Inc. | 
|  | 13 | * | 
|  | 14 | * Bugs:         Enter bugs at http://blackfin.uclinux.org/ | 
|  | 15 | * | 
|  | 16 | * This program is free software; you can redistribute it and/or modify | 
|  | 17 | * it under the terms of the GNU General Public License as published by | 
|  | 18 | * the Free Software Foundation; either version 2 of the License, or | 
|  | 19 | * (at your option) any later version. | 
|  | 20 | * | 
|  | 21 | * This program is distributed in the hope that it will be useful, | 
|  | 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|  | 24 | * GNU General Public License for more details. | 
|  | 25 | * | 
|  | 26 | * You should have received a copy of the GNU General Public License | 
|  | 27 | * along with this program; if not, see the file COPYING, or write | 
|  | 28 | * to the Free Software Foundation, Inc., | 
|  | 29 | * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA | 
|  | 30 | */ | 
|  | 31 |  | 
|  | 32 | #include <linux/smp_lock.h> | 
|  | 33 | #include <linux/spinlock.h> | 
|  | 34 | #include <linux/sem.h> | 
|  | 35 | #include <linux/msg.h> | 
|  | 36 | #include <linux/shm.h> | 
|  | 37 | #include <linux/syscalls.h> | 
|  | 38 | #include <linux/mman.h> | 
|  | 39 | #include <linux/file.h> | 
| Bryan Wu | d31c5ab | 2007-08-10 13:00:42 -0700 | [diff] [blame] | 40 | #include <linux/fs.h> | 
| Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 41 | #include <linux/uaccess.h> | 
|  | 42 | #include <linux/ipc.h> | 
|  | 43 | #include <linux/unistd.h> | 
| Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 44 |  | 
|  | 45 | #include <asm/cacheflush.h> | 
| Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 46 | #include <asm/dma.h> | 
| Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 47 |  | 
|  | 48 | /* | 
|  | 49 | * sys_pipe() is the normal C calling standard for creating | 
|  | 50 | * a pipe. It's not the way unix traditionally does this, though. | 
|  | 51 | */ | 
|  | 52 | asmlinkage int sys_pipe(unsigned long *fildes) | 
|  | 53 | { | 
|  | 54 | int fd[2]; | 
|  | 55 | int error; | 
|  | 56 |  | 
|  | 57 | error = do_pipe(fd); | 
|  | 58 | if (!error) { | 
|  | 59 | if (copy_to_user(fildes, fd, 2 * sizeof(int))) | 
|  | 60 | error = -EFAULT; | 
|  | 61 | } | 
|  | 62 | return error; | 
|  | 63 | } | 
|  | 64 |  | 
|  | 65 | /* common code for old and new mmaps */ | 
|  | 66 | static inline long | 
|  | 67 | do_mmap2(unsigned long addr, unsigned long len, | 
|  | 68 | unsigned long prot, unsigned long flags, | 
|  | 69 | unsigned long fd, unsigned long pgoff) | 
|  | 70 | { | 
|  | 71 | int error = -EBADF; | 
|  | 72 | struct file *file = NULL; | 
|  | 73 |  | 
|  | 74 | flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); | 
|  | 75 | if (!(flags & MAP_ANONYMOUS)) { | 
|  | 76 | file = fget(fd); | 
|  | 77 | if (!file) | 
|  | 78 | goto out; | 
|  | 79 | } | 
|  | 80 |  | 
|  | 81 | down_write(¤t->mm->mmap_sem); | 
|  | 82 | error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff); | 
|  | 83 | up_write(¤t->mm->mmap_sem); | 
|  | 84 |  | 
|  | 85 | if (file) | 
|  | 86 | fput(file); | 
| Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 87 | out: | 
| Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 88 | return error; | 
|  | 89 | } | 
|  | 90 |  | 
|  | 91 | asmlinkage long sys_mmap2(unsigned long addr, unsigned long len, | 
|  | 92 | unsigned long prot, unsigned long flags, | 
|  | 93 | unsigned long fd, unsigned long pgoff) | 
|  | 94 | { | 
|  | 95 | return do_mmap2(addr, len, prot, flags, fd, pgoff); | 
|  | 96 | } | 
|  | 97 |  | 
|  | 98 | asmlinkage int sys_getpagesize(void) | 
|  | 99 | { | 
|  | 100 | return PAGE_SIZE; | 
|  | 101 | } | 
|  | 102 |  | 
|  | 103 | asmlinkage void *sys_sram_alloc(size_t size, unsigned long flags) | 
|  | 104 | { | 
|  | 105 | return sram_alloc_with_lsl(size, flags); | 
|  | 106 | } | 
|  | 107 |  | 
|  | 108 | asmlinkage int sys_sram_free(const void *addr) | 
|  | 109 | { | 
|  | 110 | return sram_free_with_lsl(addr); | 
|  | 111 | } | 
|  | 112 |  | 
|  | 113 | asmlinkage void *sys_dma_memcpy(void *dest, const void *src, size_t len) | 
|  | 114 | { | 
|  | 115 | return safe_dma_memcpy(dest, src, len); | 
|  | 116 | } |