2014-02-13 09:11:11 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2014, Paweł Dziepak, pdziepak@quarnos.org.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Alexander von Gluck IV <kallisti5@unixzen.com>
|
|
|
|
*/
|
|
|
|
#ifndef _KERNEL_ARCH_ARM_ATOMIC_H
|
|
|
|
#define _KERNEL_ARCH_ARM_ATOMIC_H
|
|
|
|
|
|
|
|
|
2014-02-26 23:17:21 +04:00
|
|
|
#if __ARM_ARCH__ <= 5
|
|
|
|
#define isb() __asm__ __volatile__("" : : : "memory")
|
|
|
|
#define dsb() __asm__ __volatile__("mcr p15, 0, %0, c7, c10, 4" \
|
|
|
|
: : "r" (0) : "memory")
|
|
|
|
#define dmb() __asm__ __volatile__("" : : : "memory")
|
|
|
|
#elif __ARM_ARCH__ == 6
|
|
|
|
#define isb() __asm__ __volatile__("mcr p15, 0, %0, c7, c5, 4" \
|
|
|
|
: : "r" (0) : "memory")
|
2014-02-26 22:49:38 +04:00
|
|
|
#define dsb() __asm__ __volatile__("mcr p15, 0, %0, c7, c10, 4" \
|
|
|
|
: : "r" (0) : "memory")
|
|
|
|
#define dmb() __asm__ __volatile__("mcr p15, 0, %0, c7, c10, 4" \
|
|
|
|
: : "r" (0) : "memory")
|
2014-02-26 23:17:21 +04:00
|
|
|
#else /* ARMv7+ */
|
|
|
|
#define isb() __asm__ __volatile__("isb" : : : "memory")
|
2014-02-26 22:49:38 +04:00
|
|
|
#define dsb() __asm__ __volatile__("dsb" : : : "memory")
|
|
|
|
#define dmb() __asm__ __volatile__("dmb" : : : "memory")
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2014-02-13 09:11:11 +04:00
|
|
|
static inline void
|
|
|
|
memory_read_barrier_inline(void)
|
|
|
|
{
|
2014-02-26 22:49:38 +04:00
|
|
|
dmb();
|
2014-02-13 09:11:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
memory_write_barrier_inline(void)
|
|
|
|
{
|
2014-02-26 22:49:38 +04:00
|
|
|
dmb();
|
2014-02-13 09:11:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
memory_full_barrier_inline(void)
|
|
|
|
{
|
2014-02-26 22:49:38 +04:00
|
|
|
dmb();
|
2014-02-13 09:11:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-26 22:49:38 +04:00
|
|
|
#define memory_read_barrier memory_read_barrier_inline
|
|
|
|
#define memory_write_barrier memory_write_barrier_inline
|
|
|
|
#define memory_full_barrier memory_full_barrier_inline
|
|
|
|
|
2014-02-13 09:11:11 +04:00
|
|
|
|
|
|
|
#endif // _KERNEL_ARCH_ARM_ATOMIC_H
|