1 // Copyright 2012 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 #include "textflag.h" 6 7 // FreeBSD/ARM atomic operations. 8 // TODO(minux): this only supports ARMv6K or higher. 9 10 TEXT CompareAndSwapInt32(SB),NOSPLIT,$0 11 B CompareAndSwapUint32(SB) 12 13 TEXT CompareAndSwapUint32(SB),NOSPLIT,$0 14 B armCompareAndSwapUint32(SB) 15 16 TEXT CompareAndSwapUintptr(SB),NOSPLIT,$0 17 B CompareAndSwapUint32(SB) 18 19 TEXT AddInt32(SB),NOSPLIT,$0 20 B AddUint32(SB) 21 22 TEXT AddUint32(SB),NOSPLIT,$0 23 B armAddUint32(SB) 24 25 TEXT AddUintptr(SB),NOSPLIT,$0 26 B AddUint32(SB) 27 28 TEXT SwapInt32(SB),NOSPLIT,$0 29 B SwapUint32(SB) 30 31 TEXT SwapUint32(SB),NOSPLIT,$0 32 B armSwapUint32(SB) 33 34 TEXT SwapUintptr(SB),NOSPLIT,$0 35 B SwapUint32(SB) 36 37 TEXT CompareAndSwapInt64(SB),NOSPLIT,$0 38 B CompareAndSwapUint64(SB) 39 40 TEXT CompareAndSwapUint64(SB),NOSPLIT,$-4 41 B armCompareAndSwapUint64(SB) 42 43 TEXT AddInt64(SB),NOSPLIT,$0 44 B addUint64(SB) 45 46 TEXT AddUint64(SB),NOSPLIT,$0 47 B addUint64(SB) 48 49 TEXT SwapInt64(SB),NOSPLIT,$0 50 B swapUint64(SB) 51 52 TEXT SwapUint64(SB),NOSPLIT,$0 53 B swapUint64(SB) 54 55 TEXT LoadInt32(SB),NOSPLIT,$0 56 B LoadUint32(SB) 57 58 TEXT LoadUint32(SB),NOSPLIT,$0-8 59 MOVW addr+0(FP), R1 60 load32loop: 61 LDREX (R1), R2 // loads R2 62 STREX R2, (R1), R0 // stores R2 63 CMP $0, R0 64 BNE load32loop 65 MOVW R2, val+4(FP) 66 RET 67 68 TEXT LoadInt64(SB),NOSPLIT,$0 69 B loadUint64(SB) 70 71 TEXT LoadUint64(SB),NOSPLIT,$0 72 B loadUint64(SB) 73 74 TEXT LoadUintptr(SB),NOSPLIT,$0 75 B LoadUint32(SB) 76 77 TEXT LoadPointer(SB),NOSPLIT,$0 78 B LoadUint32(SB) 79 80 TEXT StoreInt32(SB),NOSPLIT,$0 81 B StoreUint32(SB) 82 83 TEXT StoreUint32(SB),NOSPLIT,$0-8 84 MOVW addr+0(FP), R1 85 MOVW val+4(FP), R2 86 storeloop: 87 LDREX (R1), R4 // loads R4 88 STREX R2, (R1), R0 // stores R2 89 CMP $0, R0 90 BNE storeloop 91 RET 92 93 TEXT StoreInt64(SB),NOSPLIT,$0 94 B storeUint64(SB) 95 96 TEXT StoreUint64(SB),NOSPLIT,$0 97 B storeUint64(SB) 98 99 TEXT StoreUintptr(SB),NOSPLIT,$0 100 B StoreUint32(SB) 101