1 // Implementation of synchronization functions for ARM architecture
3 // Copyright (c) 2012-2015, ARM Limited. All rights reserved.
4 // Copyright (c) 2015, Linaro Limited. All rights reserved.
6 // SPDX-License-Identifier: BSD-2-Clause-Patent
10 EXPORT InternalSyncCompareExchange16
11 EXPORT InternalSyncCompareExchange32
12 EXPORT InternalSyncCompareExchange64
13 EXPORT InternalSyncIncrement
14 EXPORT InternalSyncDecrement
16 AREA ArmSynchronization, CODE, READONLY
19 Performs an atomic compare exchange operation on a 16-bit unsigned integer.
21 Performs an atomic compare exchange operation on the 16-bit unsigned integer
22 specified by Value. If Value is equal to CompareValue, then Value is set to
23 ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
24 then Value is returned. The compare exchange operation must be performed using
27 @param Value A pointer to the 16-bit value for the compare exchange
29 @param CompareValue 16-bit value used in compare operation.
30 @param ExchangeValue 16-bit value used in exchange operation.
32 @return The original *Value before exchange.
37 //InternalSyncCompareExchange16 (
38 // IN volatile UINT16 *Value,
39 // IN UINT16 CompareValue,
40 // IN UINT16 ExchangeValue
42 InternalSyncCompareExchange16
45 InternalSyncCompareExchange16Again
48 bne InternalSyncCompareExchange16Fail
50 InternalSyncCompareExchange16Exchange
53 bne InternalSyncCompareExchange16Again
55 InternalSyncCompareExchange16Fail
61 Performs an atomic compare exchange operation on a 32-bit unsigned integer.
63 Performs an atomic compare exchange operation on the 32-bit unsigned integer
64 specified by Value. If Value is equal to CompareValue, then Value is set to
65 ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
66 then Value is returned. The compare exchange operation must be performed using
69 @param Value A pointer to the 32-bit value for the compare exchange
71 @param CompareValue 32-bit value used in compare operation.
72 @param ExchangeValue 32-bit value used in exchange operation.
74 @return The original *Value before exchange.
79 //InternalSyncCompareExchange32 (
80 // IN volatile UINT32 *Value,
81 // IN UINT32 CompareValue,
82 // IN UINT32 ExchangeValue
84 InternalSyncCompareExchange32
87 InternalSyncCompareExchange32Again
90 bne InternalSyncCompareExchange32Fail
92 InternalSyncCompareExchange32Exchange
95 bne InternalSyncCompareExchange32Again
97 InternalSyncCompareExchange32Fail
103 Performs an atomic compare exchange operation on a 64-bit unsigned integer.
105 Performs an atomic compare exchange operation on the 64-bit unsigned integer specified
106 by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and
107 CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.
108 The compare exchange operation must be performed using MP safe mechanisms.
110 @param Value A pointer to the 64-bit value for the compare exchange
112 @param CompareValue 64-bit value used in compare operation.
113 @param ExchangeValue 64-bit value used in exchange operation.
115 @return The original *Value before exchange.
120 //InternalSyncCompareExchange64 (
121 // IN volatile UINT64 *Value, // r0
122 // IN UINT64 CompareValue, // r2-r3
123 // IN UINT64 ExchangeValue // stack
125 InternalSyncCompareExchange64
127 ldrd r4, r5, [sp, #16]
130 InternalSyncCompareExchange64Again
134 bne InternalSyncCompareExchange64Fail
136 InternalSyncCompareExchange64Exchange
137 strexd ip, r4, r5, [r0]
139 bne InternalSyncCompareExchange64Again
141 InternalSyncCompareExchange64Fail
149 Performs an atomic increment of an 32-bit unsigned integer.
151 Performs an atomic increment of the 32-bit unsigned integer specified by
152 Value and returns the incremented value. The increment operation must be
153 performed using MP safe mechanisms. The state of the return value is not
154 guaranteed to be MP safe.
156 @param Value A pointer to the 32-bit value to increment.
158 @return The incremented value.
163 //InternalSyncIncrement (
164 // IN volatile UINT32 *Value
166 InternalSyncIncrement
168 TryInternalSyncIncrement
173 bne TryInternalSyncIncrement
179 Performs an atomic decrement of an 32-bit unsigned integer.
181 Performs an atomic decrement of the 32-bit unsigned integer specified by
182 Value and returns the decrement value. The decrement operation must be
183 performed using MP safe mechanisms. The state of the return value is not
184 guaranteed to be MP safe.
186 @param Value A pointer to the 32-bit value to decrement.
188 @return The decrement value.
193 //InternalSyncDecrement (
194 // IN volatile UINT32 *Value
196 InternalSyncDecrement
198 TryInternalSyncDecrement
203 bne TryInternalSyncDecrement