1 // Implementation of synchronization functions for ARM architecture (AArch64)
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
13 GCC_ASM_EXPORT(InternalSyncCompareExchange16)
14 GCC_ASM_EXPORT(InternalSyncCompareExchange32)
15 GCC_ASM_EXPORT(InternalSyncCompareExchange64)
16 GCC_ASM_EXPORT(InternalSyncIncrement)
17 GCC_ASM_EXPORT(InternalSyncDecrement)
20 Performs an atomic compare exchange operation on a 16-bit unsigned integer.
22 Performs an atomic compare exchange operation on the 16-bit unsigned integer
23 specified by Value. If Value is equal to CompareValue, then Value is set to
24 ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
25 then Value is returned. The compare exchange operation must be performed using
28 @param Value A pointer to the 16-bit value for the compare exchange
30 @param CompareValue 16-bit value used in compare operation.
31 @param ExchangeValue 16-bit value used in exchange operation.
33 @return The original *Value before exchange.
38 //InternalSyncCompareExchange16 (
39 // IN volatile UINT16 *Value,
40 // IN UINT16 CompareValue,
41 // IN UINT16 ExchangeValue
43 ASM_PFX(InternalSyncCompareExchange16):
48 InternalSyncCompareExchange16Again:
51 bne InternalSyncCompareExchange16Fail
53 InternalSyncCompareExchange16Exchange:
55 cbnz w4, InternalSyncCompareExchange16Again
57 InternalSyncCompareExchange16Fail:
63 Performs an atomic compare exchange operation on a 32-bit unsigned integer.
65 Performs an atomic compare exchange operation on the 32-bit unsigned integer
66 specified by Value. If Value is equal to CompareValue, then Value is set to
67 ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
68 then Value is returned. The compare exchange operation must be performed using
71 @param Value A pointer to the 32-bit value for the compare exchange
73 @param CompareValue 32-bit value used in compare operation.
74 @param ExchangeValue 32-bit value used in exchange operation.
76 @return The original *Value before exchange.
81 //InternalSyncCompareExchange32 (
82 // IN volatile UINT32 *Value,
83 // IN UINT32 CompareValue,
84 // IN UINT32 ExchangeValue
86 ASM_PFX(InternalSyncCompareExchange32):
89 InternalSyncCompareExchange32Again:
92 bne InternalSyncCompareExchange32Fail
94 InternalSyncCompareExchange32Exchange:
96 cbnz w4, InternalSyncCompareExchange32Again
98 InternalSyncCompareExchange32Fail:
104 Performs an atomic compare exchange operation on a 64-bit unsigned integer.
106 Performs an atomic compare exchange operation on the 64-bit unsigned integer specified
107 by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and
108 CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.
109 The compare exchange operation must be performed using MP safe mechanisms.
111 @param Value A pointer to the 64-bit value for the compare exchange
113 @param CompareValue 64-bit value used in compare operation.
114 @param ExchangeValue 64-bit value used in exchange operation.
116 @return The original *Value before exchange.
121 //InternalSyncCompareExchange64 (
122 // IN volatile UINT64 *Value,
123 // IN UINT64 CompareValue,
124 // IN UINT64 ExchangeValue
126 ASM_PFX(InternalSyncCompareExchange64):
129 InternalSyncCompareExchange64Again:
132 bne InternalSyncCompareExchange64Fail
134 InternalSyncCompareExchange64Exchange:
136 cbnz w4, InternalSyncCompareExchange64Again
138 InternalSyncCompareExchange64Fail:
144 Performs an atomic increment of an 32-bit unsigned integer.
146 Performs an atomic increment of the 32-bit unsigned integer specified by
147 Value and returns the incremented value. The increment operation must be
148 performed using MP safe mechanisms. The state of the return value is not
149 guaranteed to be MP safe.
151 @param Value A pointer to the 32-bit value to increment.
153 @return The incremented value.
158 //InternalSyncIncrement (
159 // IN volatile UINT32 *Value
161 ASM_PFX(InternalSyncIncrement):
163 TryInternalSyncIncrement:
167 cbnz w2, TryInternalSyncIncrement
173 Performs an atomic decrement of an 32-bit unsigned integer.
175 Performs an atomic decrement of the 32-bit unsigned integer specified by
176 Value and returns the decrement value. The decrement operation must be
177 performed using MP safe mechanisms. The state of the return value is not
178 guaranteed to be MP safe.
180 @param Value A pointer to the 32-bit value to decrement.
182 @return The decrement value.
187 //InternalSyncDecrement (
188 // IN volatile UINT32 *Value
190 ASM_PFX(InternalSyncDecrement):
192 TryInternalSyncDecrement:
196 cbnz w2, TryInternalSyncDecrement