mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-07-08 12:53:47 +00:00
hv: atomic: remove atomic load/store and set/clear
In x86 architecture, word/doubleword/quadword aligned read/write on its boundary is atomic, so we may remove atomic load/store. As for atomic set/clear, use bitmap_set/claer seems more reasonable. After replace them all, we could remove them too. Tracked-On: #1842 Signed-off-by: Li, Fei1 <fei1.li@intel.com>
This commit is contained in:
parent
b39526f759
commit
e352553e1a
@ -33,32 +33,6 @@
|
|||||||
|
|
||||||
#define BUS_LOCK "lock ; "
|
#define BUS_LOCK "lock ; "
|
||||||
|
|
||||||
#define build_atomic_load(name, size, type) \
|
|
||||||
static inline type name(const volatile type *ptr) \
|
|
||||||
{ \
|
|
||||||
type ret; \
|
|
||||||
asm volatile("mov" size " %1,%0" \
|
|
||||||
: "=r" (ret) \
|
|
||||||
: "m" (*ptr) \
|
|
||||||
: "cc", "memory"); \
|
|
||||||
return ret; \
|
|
||||||
}
|
|
||||||
build_atomic_load(atomic_load16, "w", uint16_t)
|
|
||||||
build_atomic_load(atomic_load32, "l", uint32_t)
|
|
||||||
build_atomic_load(atomic_load64, "q", uint64_t)
|
|
||||||
|
|
||||||
#define build_atomic_store(name, size, type) \
|
|
||||||
static inline void name(volatile type *ptr, type v) \
|
|
||||||
{ \
|
|
||||||
asm volatile("mov" size " %1,%0" \
|
|
||||||
: "=m" (*ptr) \
|
|
||||||
: "r" (v) \
|
|
||||||
: "cc", "memory"); \
|
|
||||||
}
|
|
||||||
build_atomic_store(atomic_store16, "w", uint16_t)
|
|
||||||
build_atomic_store(atomic_store32, "l", uint32_t)
|
|
||||||
build_atomic_store(atomic_store64, "q", uint64_t)
|
|
||||||
|
|
||||||
#define build_atomic_inc(name, size, type) \
|
#define build_atomic_inc(name, size, type) \
|
||||||
static inline void name(type *ptr) \
|
static inline void name(type *ptr) \
|
||||||
{ \
|
{ \
|
||||||
@ -81,69 +55,6 @@ build_atomic_dec(atomic_dec16, "w", uint16_t)
|
|||||||
build_atomic_dec(atomic_dec32, "l", uint32_t)
|
build_atomic_dec(atomic_dec32, "l", uint32_t)
|
||||||
build_atomic_dec(atomic_dec64, "q", uint64_t)
|
build_atomic_dec(atomic_dec64, "q", uint64_t)
|
||||||
|
|
||||||
/**
|
|
||||||
* #define atomic_set32(P, V) (*(uint32_t *)(P) |= (V))
|
|
||||||
*
|
|
||||||
* Parameters:
|
|
||||||
* uint32_t* p A pointer to memory area that stores source
|
|
||||||
* value and setting result;
|
|
||||||
* uint32_t v The value needs to be set.
|
|
||||||
*/
|
|
||||||
static inline void atomic_set32(uint32_t *p, uint32_t v)
|
|
||||||
{
|
|
||||||
__asm __volatile(BUS_LOCK "orl %1,%0"
|
|
||||||
: "+m" (*p)
|
|
||||||
: "r" (v)
|
|
||||||
: "cc", "memory");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* #define atomic_clear32(P, V) (*(uint32_t *)(P) &= ~(V))
|
|
||||||
* Parameters:
|
|
||||||
* uint32_t* p A pointer to memory area that stores source
|
|
||||||
* value and clearing result;
|
|
||||||
* uint32_t v The value needs to be cleared.
|
|
||||||
*/
|
|
||||||
static inline void atomic_clear32(uint32_t *p, uint32_t v)
|
|
||||||
{
|
|
||||||
__asm __volatile(BUS_LOCK "andl %1,%0"
|
|
||||||
: "+m" (*p)
|
|
||||||
: "r" (~v)
|
|
||||||
: "cc", "memory");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* #define atomic_set64(P, V) (*(uint64_t *)(P) |= (V))
|
|
||||||
*
|
|
||||||
* Parameters:
|
|
||||||
* uint64_t* p A pointer to memory area that stores source
|
|
||||||
* value and setting result;
|
|
||||||
* uint64_t v The value needs to be set.
|
|
||||||
*/
|
|
||||||
static inline void atomic_set64(uint64_t *p, uint64_t v)
|
|
||||||
{
|
|
||||||
__asm __volatile(BUS_LOCK "orq %1,%0"
|
|
||||||
: "+m" (*p)
|
|
||||||
: "r" (v)
|
|
||||||
: "cc", "memory");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* #define atomic_clear64(P, V) (*(uint64_t *)(P) &= ~(V))
|
|
||||||
*
|
|
||||||
* Parameters:
|
|
||||||
* uint64_t* p A pointer to memory area that stores source
|
|
||||||
* value and clearing result;
|
|
||||||
* uint64_t v The value needs to be cleared.
|
|
||||||
*/
|
|
||||||
static inline void atomic_clear64(uint64_t *p, uint64_t v)
|
|
||||||
{
|
|
||||||
__asm __volatile(BUS_LOCK "andq %1,%0"
|
|
||||||
: "+m" (*p)
|
|
||||||
: "r" (~v)
|
|
||||||
: "cc", "memory");
|
|
||||||
}
|
|
||||||
|
|
||||||
#define build_atomic_swap(name, size, type) \
|
#define build_atomic_swap(name, size, type) \
|
||||||
static inline type name(type *ptr, type v) \
|
static inline type name(type *ptr, type v) \
|
||||||
{ \
|
{ \
|
||||||
|
Loading…
Reference in New Issue
Block a user