sys_m32r.c 2.0 KB

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