blob: 3da60fb13ce46d8a45b5194e152985608c0cbaeb [file] [log] [blame]
Bryan Wu1394f032007-05-06 14:50:22 -07001/*
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
Bryan Wu1394f032007-05-06 14:50:22 -070032#include <linux/spinlock.h>
33#include <linux/sem.h>
34#include <linux/msg.h>
35#include <linux/shm.h>
36#include <linux/syscalls.h>
37#include <linux/mman.h>
38#include <linux/file.h>
Bryan Wud31c5ab2007-08-10 13:00:42 -070039#include <linux/fs.h>
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080040#include <linux/uaccess.h>
41#include <linux/ipc.h>
42#include <linux/unistd.h>
Bryan Wu1394f032007-05-06 14:50:22 -070043
44#include <asm/cacheflush.h>
Bryan Wu1394f032007-05-06 14:50:22 -070045#include <asm/dma.h>
Bryan Wu1394f032007-05-06 14:50:22 -070046
Bryan Wu1394f032007-05-06 14:50:22 -070047/* common code for old and new mmaps */
48static inline long
49do_mmap2(unsigned long addr, unsigned long len,
50 unsigned long prot, unsigned long flags,
51 unsigned long fd, unsigned long pgoff)
52{
53 int error = -EBADF;
54 struct file *file = NULL;
55
56 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
57 if (!(flags & MAP_ANONYMOUS)) {
58 file = fget(fd);
59 if (!file)
60 goto out;
61 }
62
63 down_write(&current->mm->mmap_sem);
64 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
65 up_write(&current->mm->mmap_sem);
66
67 if (file)
68 fput(file);
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080069 out:
Bryan Wu1394f032007-05-06 14:50:22 -070070 return error;
71}
72
73asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
74 unsigned long prot, unsigned long flags,
75 unsigned long fd, unsigned long pgoff)
76{
77 return do_mmap2(addr, len, prot, flags, fd, pgoff);
78}
79
Bryan Wu1394f032007-05-06 14:50:22 -070080asmlinkage void *sys_sram_alloc(size_t size, unsigned long flags)
81{
82 return sram_alloc_with_lsl(size, flags);
83}
84
85asmlinkage int sys_sram_free(const void *addr)
86{
87 return sram_free_with_lsl(addr);
88}
89
90asmlinkage void *sys_dma_memcpy(void *dest, const void *src, size_t len)
91{
92 return safe_dma_memcpy(dest, src, len);
93}