1 /* kernel atomic64 operations
3 * For an explanation of how atomic ops work in this arch, see:
4 * Documentation/frv/atomic-ops.txt
6 * Copyright (C) 2009 Red Hat, Inc. All Rights Reserved.
7 * Written by David Howells (dhowells@redhat.com)
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>
21 ###############################################################################
23 # long long atomic64_inc_return(atomic64_t *v)
25 ###############################################################################
26 .globl atomic64_inc_return
27 .type atomic64_inc_return,@function
31 orcc gr0,gr0,gr0,icc3 /* set ICC3.Z */
33 ldd.p @(gr10,gr0),gr8 /* LDD.P/ORCR must be atomic */
34 orcr cc7,cc7,cc3 /* set CC3 to true */
35 addicc gr9,#1,gr9,icc0
37 cstd.p gr8,@(gr10,gr0) ,cc3,#1
38 corcc gr29,gr29,gr0 ,cc3,#1 /* clear ICC3.Z if store happens */
42 .size atomic64_inc_return, .-atomic64_inc_return
44 ###############################################################################
46 # long long atomic64_dec_return(atomic64_t *v)
48 ###############################################################################
49 .globl atomic64_dec_return
50 .type atomic64_dec_return,@function
54 orcc gr0,gr0,gr0,icc3 /* set ICC3.Z */
56 ldd.p @(gr10,gr0),gr8 /* LDD.P/ORCR must be atomic */
57 orcr cc7,cc7,cc3 /* set CC3 to true */
58 subicc gr9,#1,gr9,icc0
60 cstd.p gr8,@(gr10,gr0) ,cc3,#1
61 corcc gr29,gr29,gr0 ,cc3,#1 /* clear ICC3.Z if store happens */
65 .size atomic64_dec_return, .-atomic64_dec_return
67 ###############################################################################
69 # long long atomic64_add_return(long long i, atomic64_t *v)
71 ###############################################################################
72 .globl atomic64_add_return
73 .type atomic64_add_return,@function
78 orcc gr0,gr0,gr0,icc3 /* set ICC3.Z */
80 ldd.p @(gr10,gr0),gr8 /* LDD.P/ORCR must be atomic */
81 orcr cc7,cc7,cc3 /* set CC3 to true */
82 addcc gr9,gr5,gr9,icc0
84 cstd.p gr8,@(gr10,gr0) ,cc3,#1
85 corcc gr29,gr29,gr0 ,cc3,#1 /* clear ICC3.Z if store happens */
89 .size atomic64_add_return, .-atomic64_add_return
91 ###############################################################################
93 # long long atomic64_sub_return(long long i, atomic64_t *v)
95 ###############################################################################
96 .globl atomic64_sub_return
97 .type atomic64_sub_return,@function
102 orcc gr0,gr0,gr0,icc3 /* set ICC3.Z */
104 ldd.p @(gr10,gr0),gr8 /* LDD.P/ORCR must be atomic */
105 orcr cc7,cc7,cc3 /* set CC3 to true */
106 subcc gr9,gr5,gr9,icc0
107 subx gr8,gr4,gr8,icc0
108 cstd.p gr8,@(gr10,gr0) ,cc3,#1
109 corcc gr29,gr29,gr0 ,cc3,#1 /* clear ICC3.Z if store happens */
113 .size atomic64_sub_return, .-atomic64_sub_return
115 ###############################################################################
117 # uint64_t __xchg_64(uint64_t i, uint64_t *v)
119 ###############################################################################
121 .type __xchg_64,@function
126 orcc gr0,gr0,gr0,icc3 /* set ICC3.Z */
128 ldd.p @(gr10,gr0),gr8 /* LDD.P/ORCR must be atomic */
129 orcr cc7,cc7,cc3 /* set CC3 to true */
130 cstd.p gr4,@(gr10,gr0) ,cc3,#1
131 corcc gr29,gr29,gr0 ,cc3,#1 /* clear ICC3.Z if store happens */
135 .size __xchg_64, .-__xchg_64
137 ###############################################################################
139 # uint64_t __cmpxchg_64(uint64_t test, uint64_t new, uint64_t *v)
141 ###############################################################################
143 .type __cmpxchg_64,@function
148 orcc gr0,gr0,gr0,icc3 /* set ICC3.Z */
150 ldd.p @(gr12,gr0),gr8 /* LDD.P/ORCR must be atomic */
152 subcc gr8,gr4,gr0,icc0
153 subcc.p gr9,gr5,gr0,icc1
156 cstd.p gr10,@(gr12,gr0) ,cc3,#1
157 corcc gr29,gr29,gr0 ,cc3,#1 /* clear ICC3.Z if store happens */
161 .size __cmpxchg_64, .-__cmpxchg_64