sys_bfin.c 2.0 KB

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