1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef __ASM_SPINLOCK_TYPES_H 3 #define __ASM_SPINLOCK_TYPES_H 4 5 #define __ARCH_SPIN_LOCK_UNLOCKED_VAL 0x1a46 6 7 #define SPINLOCK_BREAK_INSN 0x0000c006 /* break 6,6 */ 8 9 #ifndef __ASSEMBLY__ 10 11 typedef struct { 12 volatile unsigned int lock[4]; 13 # define __ARCH_SPIN_LOCK_UNLOCKED \ 14 { { __ARCH_SPIN_LOCK_UNLOCKED_VAL, __ARCH_SPIN_LOCK_UNLOCKED_VAL, \ 15 __ARCH_SPIN_LOCK_UNLOCKED_VAL, __ARCH_SPIN_LOCK_UNLOCKED_VAL } } 16 } arch_spinlock_t; 17 18 19 /* counter: 20 * Unlocked : 0x0100_0000 21 * Read lock(s) : 0x00FF_FFFF to 0x01 (Multiple Readers decrement it) 22 * Write lock : 0x0, but only if prior value is "unlocked" 0x0100_0000 23 */ 24 typedef struct { 25 arch_spinlock_t lock_mutex; 26 volatile unsigned int counter; 27 } arch_rwlock_t; 28 29 #endif /* __ASSEMBLY__ */ 30 31 #define __ARCH_RW_LOCK_UNLOCKED__ 0x01000000 32 #define __ARCH_RW_LOCK_UNLOCKED { .lock_mutex = __ARCH_SPIN_LOCK_UNLOCKED, \ 33 .counter = __ARCH_RW_LOCK_UNLOCKED__ } 34 35 #endif 36