~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/sh/include/asm/cmpxchg-grb.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef __ASM_SH_CMPXCHG_GRB_H
  3 #define __ASM_SH_CMPXCHG_GRB_H
  4 
  5 static inline unsigned long xchg_u32(volatile u32 *m, unsigned long val)
  6 {
  7         unsigned long retval;
  8 
  9         __asm__ __volatile__ (
 10                 "   .align 2              \n\t"
 11                 "   mova    1f,   r0      \n\t" /* r0 = end point */
 12                 "   nop                   \n\t"
 13                 "   mov    r15,   r1      \n\t" /* r1 = saved sp */
 14                 "   mov    #-4,   r15     \n\t" /* LOGIN */
 15                 "   mov.l  @%1,   %0      \n\t" /* load  old value */
 16                 "   mov.l   %2,   @%1     \n\t" /* store new value */
 17                 "1: mov     r1,   r15     \n\t" /* LOGOUT */
 18                 : "=&r" (retval),
 19                   "+r"  (m),
 20                   "+r"  (val)           /* inhibit r15 overloading */
 21                 :
 22                 : "memory", "r0", "r1");
 23 
 24         return retval;
 25 }
 26 
 27 static inline unsigned long xchg_u16(volatile u16 *m, unsigned long val)
 28 {
 29         unsigned long retval;
 30 
 31         __asm__ __volatile__ (
 32                 "   .align  2             \n\t"
 33                 "   mova    1f,   r0      \n\t" /* r0 = end point */
 34                 "   mov    r15,   r1      \n\t" /* r1 = saved sp */
 35                 "   mov    #-6,   r15     \n\t" /* LOGIN */
 36                 "   mov.w  @%1,   %0      \n\t" /* load  old value */
 37                 "   extu.w  %0,   %0      \n\t" /* extend as unsigned */
 38                 "   mov.w   %2,   @%1     \n\t" /* store new value */
 39                 "1: mov     r1,   r15     \n\t" /* LOGOUT */
 40                 : "=&r" (retval),
 41                   "+r"  (m),
 42                   "+r"  (val)           /* inhibit r15 overloading */
 43                 :
 44                 : "memory" , "r0", "r1");
 45 
 46         return retval;
 47 }
 48 
 49 static inline unsigned long xchg_u8(volatile u8 *m, unsigned long val)
 50 {
 51         unsigned long retval;
 52 
 53         __asm__ __volatile__ (
 54                 "   .align  2             \n\t"
 55                 "   mova    1f,   r0      \n\t" /* r0 = end point */
 56                 "   mov    r15,   r1      \n\t" /* r1 = saved sp */
 57                 "   mov    #-6,   r15     \n\t" /* LOGIN */
 58                 "   mov.b  @%1,   %0      \n\t" /* load  old value */
 59                 "   extu.b  %0,   %0      \n\t" /* extend as unsigned */
 60                 "   mov.b   %2,   @%1     \n\t" /* store new value */
 61                 "1: mov     r1,   r15     \n\t" /* LOGOUT */
 62                 : "=&r" (retval),
 63                   "+r"  (m),
 64                   "+r"  (val)           /* inhibit r15 overloading */
 65                 :
 66                 : "memory" , "r0", "r1");
 67 
 68         return retval;
 69 }
 70 
 71 static inline unsigned long __cmpxchg_u32(volatile int *m, unsigned long old,
 72                                           unsigned long new)
 73 {
 74         unsigned long retval;
 75 
 76         __asm__ __volatile__ (
 77                 "   .align  2             \n\t"
 78                 "   mova    1f,   r0      \n\t" /* r0 = end point */
 79                 "   nop                   \n\t"
 80                 "   mov    r15,   r1      \n\t" /* r1 = saved sp */
 81                 "   mov    #-8,   r15     \n\t" /* LOGIN */
 82                 "   mov.l  @%3,   %0      \n\t" /* load  old value */
 83                 "   cmp/eq  %0,   %1      \n\t"
 84                 "   bf            1f      \n\t" /* if not equal */
 85                 "   mov.l   %2,   @%3     \n\t" /* store new value */
 86                 "1: mov     r1,   r15     \n\t" /* LOGOUT */
 87                 : "=&r" (retval),
 88                   "+r"  (old), "+r"  (new) /* old or new can be r15 */
 89                 :  "r"  (m)
 90                 : "memory" , "r0", "r1", "t");
 91 
 92         return retval;
 93 }
 94 
 95 #endif /* __ASM_SH_CMPXCHG_GRB_H */
 96 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php