diff options
Diffstat (limited to 'core/minute-ia')
-rw-r--r-- | core/minute-ia/atomic.h | 6 | ||||
-rw-r--r-- | core/minute-ia/config_core.h | 14 | ||||
-rw-r--r-- | core/minute-ia/task.c | 4 |
3 files changed, 19 insertions, 5 deletions
diff --git a/core/minute-ia/atomic.h b/core/minute-ia/atomic.h index 08f0888cdf..00dce90607 100644 --- a/core/minute-ia/atomic.h +++ b/core/minute-ia/atomic.h @@ -13,7 +13,7 @@ #define ATOMIC_OP(asm_op, a, v) do { \ __asm__ __volatile__ ( \ - "lock;" #asm_op " %1, %0\n" \ + ASM_LOCK_PREFIX #asm_op " %1, %0\n" \ : "+m" (*a) \ : "ir" (v) \ : "memory"); \ @@ -24,7 +24,7 @@ static inline int bool_compare_and_swap_u32(uint32_t *var, uint32_t old_value, { uint32_t _old_value = old_value; - __asm__ __volatile__("lock; cmpxchgl %2, %1" + __asm__ __volatile__(ASM_LOCK_PREFIX "cmpxchgl %2, %1" : "=a" (old_value), "+m" (*var) : "r" (new_value), "0" (old_value) : "memory"); @@ -74,7 +74,7 @@ static inline uint32_t atomic_read_clear(uint32_t volatile *addr) if (*addr == 0) return 0; - asm volatile("lock; xchgl %0, %1\n" + asm volatile(ASM_LOCK_PREFIX "xchgl %0, %1\n" : "+r" (ret), "+m" (*addr) : : "memory", "cc"); diff --git a/core/minute-ia/config_core.h b/core/minute-ia/config_core.h index 3ca60cf71d..426e215eae 100644 --- a/core/minute-ia/config_core.h +++ b/core/minute-ia/config_core.h @@ -12,4 +12,18 @@ #define CONFIG_SOFTWARE_PANIC +/* + * Since all implementations minute-ia are a single core, we do not need a + * "lock;" prefix on any instructions. We use the below define in places where + * a lock statement would be needed if there were multiple cores. + * + * Also the destination operand needs to be a memory location instead of a + * register for us to drop the "lock;" prefix for a single-core chip. + */ +#ifndef __ASSEMBLER__ +#define ASM_LOCK_PREFIX "" +#else +#define ASM_LOCK_PREFIX +#endif + #endif /* __CROS_EC_CONFIG_CORE_H */ diff --git a/core/minute-ia/task.c b/core/minute-ia/task.c index 16bb724c2d..77c429c288 100644 --- a/core/minute-ia/task.c +++ b/core/minute-ia/task.c @@ -433,7 +433,7 @@ void mutex_lock(struct mutex *mtx) do { old_val = 0; __asm__ __volatile__( - "lock; cmpxchg %1, %2\n" + ASM_LOCK_PREFIX "cmpxchg %1, %2\n" : "=a" (old_val) : "r" (value), "m" (mtx->lock), "a" (old_val) : "memory"); @@ -454,7 +454,7 @@ void mutex_unlock(struct mutex *mtx) task_ *tsk = current_task; __asm__ __volatile__( - "lock; cmpxchg %1, %2\n" + ASM_LOCK_PREFIX "cmpxchg %1, %2\n" : "=a" (old_val) : "r" (val), "m" (mtx->lock), "a" (old_val) : "memory"); |