Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* atomic-ops.S: kernel atomic operations |
| 2 | * |
| 3 | * For an explanation of how atomic ops work in this arch, see: |
Adrian Bunk | 0868ff7 | 2008-02-03 15:54:28 +0200 | [diff] [blame] | 4 | * Documentation/frv/atomic-ops.txt |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | # |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | # |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |
David Howells | 00460f4 | 2009-07-02 00:46:16 +0100 | [diff] [blame] | 56 | bnelr icc0,#0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | cst.p gr10,@(gr11,gr0) ,cc3,#1 |
| 58 | corcc gr29,gr29,gr0 ,cc3,#1 |
| 59 | beq icc3,#0,0b |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | bralr |
| 61 | |
| 62 | .size __cmpxchg_32, .-__cmpxchg_32 |