| 1 | #ifndef _ARCH_S390_H |
| 2 | #define _ARCH_S390_H |
| 3 | |
| 4 | /* |
| 5 | * Trivial definitions for the S390 architecture. |
| 6 | * |
| 7 | * Copyright (C) 2009 Novell, Inc. |
| 8 | * Author: Jan Blunck <jblunck@suse.de> |
| 9 | * |
| 10 | * Based on the Principles of Operation "CPU Serialization" (5-91), "BRANCH ON |
| 11 | * CONDITION" (7-25) and "STORE CLOCK" (7-169). |
| 12 | * |
| 13 | * Inspired by arch_ppc.h which is: |
| 14 | * Copyright (c) 2009 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> |
| 15 | * |
| 16 | * This program is free software; you can redistribute it and/or modify it |
| 17 | * under the terms of the GNU Lesser General Public License version 2.1 as |
| 18 | * published by the Free Software Foundation. |
| 19 | */ |
| 20 | |
| 21 | #include <compiler.h> |
| 22 | #include <arch_atomic.h> |
| 23 | |
| 24 | #define CONFIG_HAVE_MEM_COHERENCY |
| 25 | /* Assume SMP machine, given we don't have this information */ |
| 26 | #define CONFIG_SMP 1 |
| 27 | |
| 28 | #ifndef BITS_PER_LONG |
| 29 | #define BITS_PER_LONG (__SIZEOF_LONG__ * 8) |
| 30 | #endif |
| 31 | |
| 32 | #define mb() __asm__ __volatile__("bcr 15,0" : : : "memory") |
| 33 | #define rmb() __asm__ __volatile__("bcr 15,0" : : : "memory"); |
| 34 | #define wmb() __asm__ __volatile__("bcr 15,0" : : : "memory"); |
| 35 | #define mc() barrier() |
| 36 | #define rmc() barrier() |
| 37 | #define wmc() barrier() |
| 38 | |
| 39 | #define smp_mb() mb() |
| 40 | #define smp_rmb() rmb() |
| 41 | #define smp_wmb() wmb() |
| 42 | #define smp_mc() mc() |
| 43 | #define smp_rmc() rmc() |
| 44 | #define smp_wmc() wmc() |
| 45 | |
| 46 | /* Nop everywhere except on alpha. */ |
| 47 | #define smp_read_barrier_depends() |
| 48 | |
| 49 | static inline void cpu_relax(void) |
| 50 | { |
| 51 | barrier(); |
| 52 | } |
| 53 | |
| 54 | static inline void sync_core() |
| 55 | { |
| 56 | __asm__ __volatile__("bcr 15,0" : : : "memory"); |
| 57 | } |
| 58 | |
| 59 | typedef unsigned long long cycles_t; |
| 60 | |
| 61 | static inline cycles_t get_cycles (void) |
| 62 | { |
| 63 | cycles_t cycles; |
| 64 | |
| 65 | __asm__ __volatile__("stck %0" : "=m" (cycles) : : "cc", "memory" ); |
| 66 | |
| 67 | return cycles; |
| 68 | } |
| 69 | |
| 70 | #endif /* _ARCH_S390_H */ |