1 #ifndef _MACHINE_INSTR_H
2 #define _MACHINE_INSTR_H
4 /* Taken from linux kernel source
5 * include/asm-s390/atomic.h
8 * Copyright (C) 1999-2005 IBM Deutschland Entwicklung GmbH, IBM Corporation
9 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
10 * Denis Joseph Barrow,
11 * Arnd Bergmann (arndb@de.ibm.com)
13 * Derived from "include/asm-i386/bitops.h"
14 * Copyright (C) 1992, Linus Torvalds
17 #define __CS_LOOP(ptr, op_val, op_string) ({ \
18 int old_val, new_val; \
19 __asm__ __volatile__(" l %0,0(%3)\n" \
21 op_string " %1,%4\n" \
24 : "=&d" (old_val), "=&d" (new_val), \
26 : "a" (ptr), "d" (op_val), \
33 atomic_add (volatile int *mem, int val)
35 __CS_LOOP(mem, val, "ar");
39 compare_and_swap (volatile long *p, long oldval, long newval)
41 __asm__ __volatile__(" cs %0,%3,0(%2)\n"
42 : "+d" (oldval), "=m" (*p)
43 : "a" (p), "d" (newval), "m" (*p)
49 * Taken from linux kerenl source
50 * include/asm-s390/system.h
53 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
54 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
56 * Derived from "include/asm-i386/system.h"
60 * Force strict CPU ordering.
61 * And yes, this is required on UP too when we're talking
64 * This is very similar to the ppc eieio/sync instruction in that is
65 * does a checkpoint syncronisation & makes sure that
66 * all memory ops have completed wrt other CPU's ( see 7-15 POP DJB ).
69 #define eieio() __asm__ __volatile__ ( "bcr 15,0" : : : "memory" )
71 #define STORE_ORDER_BARRIER() eieio()
72 #define MEMORY_BARRIER() eieio()
74 /* TODO not sure if the following two can't be just empty. */
76 #define MEMORY_BARRIER_BEFORE_ATOMIC() eieio()
77 #define MEMORY_BARRIER_AFTER_ATOMIC() eieio()