diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2017-05-25 03:19:40 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2017-05-25 03:19:40 +0000 |
commit | 845c87ec543f1120cbaa6f2e75bcb0046b4abfb5 (patch) | |
tree | 9c5503e4b0714ab8c02148b3e246f4b8ab2de5ca /sys/arch/sparc64/include | |
parent | 1b365b9ae6fcc81709acb50207133615d44849f1 (diff) |
tweak sparc64 membars as a step toward making them usable in userland.
specifically, dont rely on magic in ctlreg to implement membars. moving
that to atomic.h would add a lot of pollution to the namespace, so
move to passing the membar options to a single __membar macro.
this tweaks everything that was using the ctlreg backend to either use
an appropriate membar_foo(), or to use __membar() in the MD code.
ok kettenis@
Diffstat (limited to 'sys/arch/sparc64/include')
-rw-r--r-- | sys/arch/sparc64/include/atomic.h | 14 | ||||
-rw-r--r-- | sys/arch/sparc64/include/bus.h | 12 | ||||
-rw-r--r-- | sys/arch/sparc64/include/ctlreg.h | 36 | ||||
-rw-r--r-- | sys/arch/sparc64/include/psl.h | 4 |
4 files changed, 17 insertions, 49 deletions
diff --git a/sys/arch/sparc64/include/atomic.h b/sys/arch/sparc64/include/atomic.h index 2380dd35393..bd4411a4f89 100644 --- a/sys/arch/sparc64/include/atomic.h +++ b/sys/arch/sparc64/include/atomic.h @@ -1,4 +1,4 @@ -/* $OpenBSD: atomic.h,v 1.13 2014/07/18 12:44:53 dlg Exp $ */ +/* $OpenBSD: atomic.h,v 1.14 2017/05/25 03:19:39 dlg Exp $ */ /* * Copyright (c) 2007 Artur Grabowski <art@openbsd.org> * @@ -142,11 +142,13 @@ atomic_clearbits_int(volatile unsigned int *uip, unsigned int v) } while (r != e); } -#define membar_enter() membar(StoreLoad|StoreStore) -#define membar_exit() membar(LoadStore|StoreStore) -#define membar_producer() membar(StoreStore) -#define membar_consumer() membar(LoadLoad) -#define membar_sync() membar(Sync) +#define __membar(_m) __asm volatile("membar " _m ::: "memory") + +#define membar_enter() __membar("#StoreLoad|#StoreStore") +#define membar_exit() __membar("#LoadStore|#StoreStore") +#define membar_producer() __membar("#StoreStore") +#define membar_consumer() __membar("#LoadLoad") +#define membar_sync() __membar("#Sync") #endif /* defined(_KERNEL) */ #endif /* _MACHINE_ATOMIC_H_ */ diff --git a/sys/arch/sparc64/include/bus.h b/sys/arch/sparc64/include/bus.h index 497b5843f7c..d1288962105 100644 --- a/sys/arch/sparc64/include/bus.h +++ b/sys/arch/sparc64/include/bus.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bus.h,v 1.32 2017/05/08 00:27:45 dlg Exp $ */ +/* $OpenBSD: bus.h,v 1.33 2017/05/25 03:19:39 dlg Exp $ */ /* $NetBSD: bus.h,v 1.31 2001/09/21 15:30:41 wiz Exp $ */ /*- @@ -66,7 +66,7 @@ #ifndef _MACHINE_BUS_H_ #define _MACHINE_BUS_H_ -#include <machine/ctlreg.h> +#include <sys/atomic.h> /* * Debug hooks @@ -319,19 +319,19 @@ bus_space_barrier(t, h, o, s, f) #ifdef notyet switch (f) { case (BUS_SPACE_BARRIER_READ|BUS_SPACE_BARRIER_WRITE): - membar(LoadLoad|StoreStore); + __membar("#LoadLoad|#StoreStore"); break; case BUS_SPACE_BARRIER_READ: - membar(LoadLoad); + membar("#LoadLoad"); break; case BUS_SPACE_BARRIER_WRITE: - membar(StoreStore); + membar("#StoreStore"); break; default: break; } #else - membar(Sync); + __membar("#Sync"); #endif } diff --git a/sys/arch/sparc64/include/ctlreg.h b/sys/arch/sparc64/include/ctlreg.h index d794e56aae0..09457821cb9 100644 --- a/sys/arch/sparc64/include/ctlreg.h +++ b/sys/arch/sparc64/include/ctlreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ctlreg.h,v 1.27 2016/03/07 13:21:51 naddy Exp $ */ +/* $OpenBSD: ctlreg.h,v 1.28 2017/05/25 03:19:39 dlg Exp $ */ /* $NetBSD: ctlreg.h,v 1.28 2001/08/06 23:55:34 eeh Exp $ */ /* @@ -58,24 +58,6 @@ */ /* - * membar operand macros for use in other macros when # is a special - * character. Keep these in sync with what the hardware expects. - */ -#define C_Lookaside (0) -#define C_MemIssue (1) -#define C_Sync (2) -#define M_LoadLoad (0) -#define M_StoreLoad (1) -#define M_LoadStore (2) -#define M_StoreStore (3) - -#define CMASK_SHIFT (4) -#define MMASK_SHIFT (0) - -#define CMASK_GEN(bit) ((1 << (bit)) << CMASK_SHIFT) -#define MMASK_GEN(bit) ((1 << (bit)) << MMASK_SHIFT) - -/* * The Alternate address spaces. * * 0x00-0x7f are privileged @@ -522,22 +504,6 @@ * D$ so we need to flush the D$ to make sure we don't get data pollution. */ -#define sparc_membar(mask) do { \ - if (mask) \ - __asm volatile("membar %0" : : "n" (mask) : "memory"); \ - else \ - __asm volatile("" : : : "memory"); \ -} while(0) - -#define membar sparc_membar -#define Lookaside CMASK_GEN(C_Lookaside) -#define MemIssue CMASK_GEN(C_MemIssue) -#define Sync CMASK_GEN(C_Sync) -#define LoadLoad MMASK_GEN(M_LoadLoad) -#define StoreLoad MMASK_GEN(M_StoreLoad) -#define LoadStore MMASK_GEN(M_LoadStore) -#define StoreStore MMASK_GEN(M_StoreStore) - #define sparc_wr(name, val, xor) \ do { \ if (__builtin_constant_p(xor)) \ diff --git a/sys/arch/sparc64/include/psl.h b/sys/arch/sparc64/include/psl.h index 53b2f17cf28..26c93ce4368 100644 --- a/sys/arch/sparc64/include/psl.h +++ b/sys/arch/sparc64/include/psl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: psl.h,v 1.31 2016/06/13 01:08:13 dlg Exp $ */ +/* $OpenBSD: psl.h,v 1.32 2017/05/25 03:19:39 dlg Exp $ */ /* $NetBSD: psl.h,v 1.20 2001/04/13 23:30:05 thorpej Exp $ */ /* @@ -313,7 +313,7 @@ stxa_sync(u_int64_t va, u_int64_t asi, u_int64_t val) { u_int64_t s = intr_disable(); stxa_nc(va, asi, val); - membar(Sync); + __asm volatile("membar #Sync" : : : "memory"); intr_restore(s); } |