blob: d998383cb956f5abc7bc0f750a8a6e5a9894fde4 [file] [log] [blame]
Bryan Wu1394f032007-05-06 14:50:22 -07001/*
Robin Getz96f10502009-09-24 14:11:24 +00002 * contains various random system calls that have a non-standard
3 * calling sequence on the Linux/Blackfin platform.
Bryan Wu1394f032007-05-06 14:50:22 -07004 *
Robin Getz96f10502009-09-24 14:11:24 +00005 * Copyright 2004-2009 Analog Devices Inc.
Bryan Wu1394f032007-05-06 14:50:22 -07006 *
Robin Getz96f10502009-09-24 14:11:24 +00007 * Licensed under the GPL-2 or later
Bryan Wu1394f032007-05-06 14:50:22 -07008 */
9
Bryan Wu1394f032007-05-06 14:50:22 -070010#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>
Bryan Wud31c5ab2007-08-10 13:00:42 -070017#include <linux/fs.h>
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080018#include <linux/uaccess.h>
19#include <linux/ipc.h>
20#include <linux/unistd.h>
Bryan Wu1394f032007-05-06 14:50:22 -070021
22#include <asm/cacheflush.h>
Bryan Wu1394f032007-05-06 14:50:22 -070023#include <asm/dma.h>
Sonic Zhang99a5b282010-09-06 10:16:04 +000024#include <asm/cachectl.h>
25#include <asm/ptrace.h>
Bryan Wu1394f032007-05-06 14:50:22 -070026
Bryan Wu1394f032007-05-06 14:50:22 -070027asmlinkage 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}
Thomas Chou59bd00c2009-09-27 15:38:01 +080041
42#if defined(CONFIG_FB) || defined(CONFIG_FB_MODULE)
43#include <linux/fb.h>
Paul Gortmaker8dc7a9c2011-08-09 11:05:22 -040044#include <linux/export.h>
Thomas Chou59bd00c2009-09-27 15:38:01 +080045unsigned 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
Robin Getz2a12c462010-03-11 16:24:18 +000053
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}
Sonic Zhang99a5b282010-09-06 10:16:04 +000076
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}