]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - arch/frv/lib/atomic-ops.S
Merge branch 'cpuidle' into release
[karo-tx-linux.git] / arch / frv / lib / atomic-ops.S
1 /* atomic-ops.S: kernel atomic operations
2  *
3  * For an explanation of how atomic ops work in this arch, see:
4  *   Documentation/frv/atomic-ops.txt
5  *
6  * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
7  * Written by David Howells (dhowells@redhat.com)
8  *
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.
13  */
14
15 #include <asm/spr-regs.h>
16
17         .text
18         .balign 4
19
20 ###############################################################################
21 #
22 # uint32_t __xchg_32(uint32_t i, uint32_t *v)
23 #
24 ###############################################################################
25         .globl          __xchg_32
26         .type           __xchg_32,@function
27 __xchg_32:
28         or.p            gr8,gr8,gr10
29 0:
30         orcc            gr0,gr0,gr0,icc3                /* set ICC3.Z */
31         ckeq            icc3,cc7
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 */
36         beq             icc3,#0,0b
37         bralr
38
39         .size           __xchg_32, .-__xchg_32
40
41 ###############################################################################
42 #
43 # uint32_t __cmpxchg_32(uint32_t *v, uint32_t test, uint32_t new)
44 #
45 ###############################################################################
46         .globl          __cmpxchg_32
47         .type           __cmpxchg_32,@function
48 __cmpxchg_32:
49         or.p            gr8,gr8,gr11
50 0:
51         orcc            gr0,gr0,gr0,icc3
52         ckeq            icc3,cc7
53         ld.p            @(gr11,gr0),gr8
54         orcr            cc7,cc7,cc3
55         subcc           gr8,gr9,gr7,icc0
56         bnelr           icc0,#0
57         cst.p           gr10,@(gr11,gr0)        ,cc3,#1
58         corcc           gr29,gr29,gr0           ,cc3,#1
59         beq             icc3,#0,0b
60         bralr
61
62         .size           __cmpxchg_32, .-__cmpxchg_32