sys_m32r.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * linux/arch/m32r/kernel/sys_m32r.c
  3. *
  4. * This file contains various random system calls that
  5. * have a non-standard calling sequence on the Linux/M32R platform.
  6. *
  7. * Taken from i386 version.
  8. */
  9. #include <linux/errno.h>
  10. #include <linux/sched.h>
  11. #include <linux/mm.h>
  12. #include <linux/fs.h>
  13. #include <linux/smp.h>
  14. #include <linux/sem.h>
  15. #include <linux/msg.h>
  16. #include <linux/shm.h>
  17. #include <linux/stat.h>
  18. #include <linux/syscalls.h>
  19. #include <linux/mman.h>
  20. #include <linux/file.h>
  21. #include <linux/utsname.h>
  22. #include <linux/ipc.h>
  23. #include <asm/uaccess.h>
  24. #include <asm/cachectl.h>
  25. #include <asm/cacheflush.h>
  26. #include <asm/syscall.h>
  27. #include <asm/unistd.h>
  28. /*
  29. * sys_tas() - test-and-set
  30. */
  31. asmlinkage int sys_tas(int __user *addr)
  32. {
  33. int oldval;
  34. if (!access_ok(VERIFY_WRITE, addr, sizeof (int)))
  35. return -EFAULT;
  36. /* atomic operation:
  37. * oldval = *addr; *addr = 1;
  38. */
  39. __asm__ __volatile__ (
  40. DCACHE_CLEAR("%0", "r4", "%1")
  41. " .fillinsn\n"
  42. "1:\n"
  43. " lock %0, @%1 -> unlock %2, @%1\n"
  44. "2:\n"
  45. /* NOTE:
  46. * The m32r processor can accept interrupts only
  47. * at the 32-bit instruction boundary.
  48. * So, in the above code, the "unlock" instruction
  49. * can be executed continuously after the "lock"
  50. * instruction execution without any interruptions.
  51. */
  52. ".section .fixup,\"ax\"\n"
  53. " .balign 4\n"
  54. "3: ldi %0, #%3\n"
  55. " seth r14, #high(2b)\n"
  56. " or3 r14, r14, #low(2b)\n"
  57. " jmp r14\n"
  58. ".previous\n"
  59. ".section __ex_table,\"a\"\n"
  60. " .balign 4\n"
  61. " .long 1b,3b\n"
  62. ".previous\n"
  63. : "=&r" (oldval)
  64. : "r" (addr), "r" (1), "i"(-EFAULT)
  65. : "r14", "memory"
  66. #ifdef CONFIG_CHIP_M32700_TS1
  67. , "r4"
  68. #endif /* CONFIG_CHIP_M32700_TS1 */
  69. );
  70. return oldval;
  71. }
  72. asmlinkage int sys_cacheflush(void *addr, int bytes, int cache)
  73. {
  74. /* This should flush more selectively ... */
  75. _flush_cache_all();
  76. return 0;
  77. }
  78. asmlinkage int sys_cachectl(char *addr, int nbytes, int op)
  79. {
  80. /* Not implemented yet. */
  81. return -ENOSYS;
  82. }