Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1 | /* |
Robin Getz | 96f1050 | 2009-09-24 14:11:24 +0000 | [diff] [blame] | 2 | * contains various random system calls that have a non-standard |
| 3 | * calling sequence on the Linux/Blackfin platform. |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 4 | * |
Robin Getz | 96f1050 | 2009-09-24 14:11:24 +0000 | [diff] [blame] | 5 | * Copyright 2004-2009 Analog Devices Inc. |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 6 | * |
Robin Getz | 96f1050 | 2009-09-24 14:11:24 +0000 | [diff] [blame] | 7 | * Licensed under the GPL-2 or later |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 8 | */ |
| 9 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 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> |
Bryan Wu | d31c5ab | 2007-08-10 13:00:42 -0700 | [diff] [blame] | 17 | #include <linux/fs.h> |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 18 | #include <linux/uaccess.h> |
| 19 | #include <linux/ipc.h> |
| 20 | #include <linux/unistd.h> |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 21 | |
| 22 | #include <asm/cacheflush.h> |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 23 | #include <asm/dma.h> |
Sonic Zhang | 99a5b28 | 2010-09-06 10:16:04 +0000 | [diff] [blame] | 24 | #include <asm/cachectl.h> |
| 25 | #include <asm/ptrace.h> |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 26 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 27 | asmlinkage void *sys_sram_alloc(size_t size, unsigned long flags) |
| 28 | { |
| 29 | return sram_alloc_with_lsl(size, flags); |
| 30 | } |
| 31 | |
| 32 | asmlinkage int sys_sram_free(const void *addr) |
| 33 | { |
| 34 | return sram_free_with_lsl(addr); |
| 35 | } |
| 36 | |
| 37 | asmlinkage void *sys_dma_memcpy(void *dest, const void *src, size_t len) |
| 38 | { |
| 39 | return safe_dma_memcpy(dest, src, len); |
| 40 | } |
Thomas Chou | 59bd00c | 2009-09-27 15:38:01 +0800 | [diff] [blame] | 41 | |
| 42 | #if defined(CONFIG_FB) || defined(CONFIG_FB_MODULE) |
| 43 | #include <linux/fb.h> |
| 44 | unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, |
| 45 | unsigned long len, unsigned long pgoff, unsigned long flags) |
| 46 | { |
| 47 | struct fb_info *info = filp->private_data; |
| 48 | return (unsigned long)info->screen_base; |
| 49 | } |
| 50 | EXPORT_SYMBOL(get_fb_unmapped_area); |
| 51 | #endif |
Robin Getz | 2a12c46 | 2010-03-11 16:24:18 +0000 | [diff] [blame] | 52 | |
| 53 | /* Needed for legacy userspace atomic emulation */ |
| 54 | static DEFINE_SPINLOCK(bfin_spinlock_lock); |
| 55 | |
| 56 | #ifdef CONFIG_SYS_BFIN_SPINLOCK_L1 |
| 57 | __attribute__((l1_text)) |
| 58 | #endif |
| 59 | asmlinkage int sys_bfin_spinlock(int *p) |
| 60 | { |
| 61 | int ret, tmp = 0; |
| 62 | |
| 63 | spin_lock(&bfin_spinlock_lock); /* This would also hold kernel preemption. */ |
| 64 | ret = get_user(tmp, p); |
| 65 | if (likely(ret == 0)) { |
| 66 | if (unlikely(tmp)) |
| 67 | ret = 1; |
| 68 | else |
| 69 | put_user(1, p); |
| 70 | } |
| 71 | spin_unlock(&bfin_spinlock_lock); |
| 72 | |
| 73 | return ret; |
| 74 | } |
Sonic Zhang | 99a5b28 | 2010-09-06 10:16:04 +0000 | [diff] [blame] | 75 | |
| 76 | SYSCALL_DEFINE3(cacheflush, unsigned long, addr, unsigned long, len, int, op) |
| 77 | { |
| 78 | if (is_user_addr_valid(current, addr, len) != 0) |
| 79 | return -EINVAL; |
| 80 | |
| 81 | if (op & DCACHE) |
| 82 | blackfin_dcache_flush_range(addr, addr + len); |
| 83 | if (op & ICACHE) |
| 84 | blackfin_icache_flush_range(addr, addr + len); |
| 85 | |
| 86 | return 0; |
| 87 | } |