Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal
[linux-2.6-block.git] / arch / blackfin / kernel / sys_bfin.c
CommitLineData
1394f032 1/*
96f1050d
RG
2 * contains various random system calls that have a non-standard
3 * calling sequence on the Linux/Blackfin platform.
1394f032 4 *
96f1050d 5 * Copyright 2004-2009 Analog Devices Inc.
1394f032 6 *
96f1050d 7 * Licensed under the GPL-2 or later
1394f032
BW
8 */
9
1394f032
BW
10#include <linux/spinlock.h>
11#include <linux/sem.h>
12#include <linux/msg.h>
13#include <linux/shm.h>
14#include <linux/syscalls.h>
15#include <linux/mman.h>
16#include <linux/file.h>
d31c5ab1 17#include <linux/fs.h>
1f83b8f1
MF
18#include <linux/uaccess.h>
19#include <linux/ipc.h>
20#include <linux/unistd.h>
1394f032
BW
21
22#include <asm/cacheflush.h>
1394f032 23#include <asm/dma.h>
99a5b287
SZ
24#include <asm/cachectl.h>
25#include <asm/ptrace.h>
1394f032 26
1394f032
BW
27asmlinkage void *sys_sram_alloc(size_t size, unsigned long flags)
28{
29 return sram_alloc_with_lsl(size, flags);
30}
31
32asmlinkage int sys_sram_free(const void *addr)
33{
34 return sram_free_with_lsl(addr);
35}
36
37asmlinkage void *sys_dma_memcpy(void *dest, const void *src, size_t len)
38{
39 return safe_dma_memcpy(dest, src, len);
40}
59bd00c8
TC
41
42#if defined(CONFIG_FB) || defined(CONFIG_FB_MODULE)
43#include <linux/fb.h>
8dc7a9c8 44#include <linux/export.h>
59bd00c8
TC
45unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr,
46 unsigned long len, unsigned long pgoff, unsigned long flags)
47{
48 struct fb_info *info = filp->private_data;
49 return (unsigned long)info->screen_base;
50}
51EXPORT_SYMBOL(get_fb_unmapped_area);
52#endif
2a12c463
RG
53
54/* Needed for legacy userspace atomic emulation */
55static DEFINE_SPINLOCK(bfin_spinlock_lock);
56
57#ifdef CONFIG_SYS_BFIN_SPINLOCK_L1
58__attribute__((l1_text))
59#endif
60asmlinkage int sys_bfin_spinlock(int *p)
61{
62 int ret, tmp = 0;
63
64 spin_lock(&bfin_spinlock_lock); /* This would also hold kernel preemption. */
65 ret = get_user(tmp, p);
66 if (likely(ret == 0)) {
67 if (unlikely(tmp))
68 ret = 1;
69 else
70 put_user(1, p);
71 }
72 spin_unlock(&bfin_spinlock_lock);
73
74 return ret;
75}
99a5b287
SZ
76
77SYSCALL_DEFINE3(cacheflush, unsigned long, addr, unsigned long, len, int, op)
78{
79 if (is_user_addr_valid(current, addr, len) != 0)
80 return -EINVAL;
81
82 if (op & DCACHE)
83 blackfin_dcache_flush_range(addr, addr + len);
84 if (op & ICACHE)
85 blackfin_icache_flush_range(addr, addr + len);
86
87 return 0;
88}