1 /* atomic-ops.S: kernel atomic operations
3 * For an explanation of how atomic ops work in this arch, see:
4 * Documentation/frv/atomic-ops.txt
6 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
15 #include <asm/spr-regs.h>
20 ###############################################################################
22 # uint32_t __xchg_32(uint32_t i, uint32_t *v)
24 ###############################################################################
26 .type __xchg_32,@function
30 orcc gr0,gr0,gr0,icc3 /* set ICC3.Z */
32 ld.p @(gr9,gr0),gr8 /* LD.P/ORCR must be atomic */
33 orcr cc7,cc7,cc3 /* set CC3 to true */
34 cst.p gr10,@(gr9,gr0) ,cc3,#1
35 corcc gr29,gr29,gr0 ,cc3,#1 /* clear ICC3.Z if store happens */
39 .size __xchg_32, .-__xchg_32
41 ###############################################################################
43 # uint32_t __cmpxchg_32(uint32_t *v, uint32_t test, uint32_t new)
45 ###############################################################################
47 .type __cmpxchg_32,@function
55 subcc gr8,gr9,gr7,icc0
57 cst.p gr10,@(gr11,gr0) ,cc3,#1
58 corcc gr29,gr29,gr0 ,cc3,#1
62 .size __cmpxchg_32, .-__cmpxchg_32