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 // This program and the accompanying materials
7 // are licensed and made available under the terms and conditions of the BSD License
8 // which accompanies this distribution. The full text of the license may be found at
9 // http://opensource.org/licenses/bsd-license.php
11 // THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 GCC_ASM_EXPORT(InternalSyncCompareExchange32)
20 GCC_ASM_EXPORT(InternalSyncCompareExchange64)
21 GCC_ASM_EXPORT(InternalSyncIncrement)
22 GCC_ASM_EXPORT(InternalSyncDecrement)
25 Performs an atomic compare exchange operation on a 32-bit unsigned integer.
27 Performs an atomic compare exchange operation on the 32-bit unsigned integer
28 specified by Value. If Value is equal to CompareValue, then Value is set to
29 ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
30 then Value is returned. The compare exchange operation must be performed using
33 @param Value A pointer to the 32-bit value for the compare exchange
35 @param CompareValue 32-bit value used in compare operation.
36 @param ExchangeValue 32-bit value used in exchange operation.
38 @return The original *Value before exchange.
43 //InternalSyncCompareExchange32 (
44 // IN volatile UINT32 *Value,
45 // IN UINT32 CompareValue,
46 // IN UINT32 ExchangeValue
48 ASM_PFX(InternalSyncCompareExchange32):
51 InternalSyncCompareExchange32Again:
54 bne InternalSyncCompareExchange32Fail
56 InternalSyncCompareExchange32Exchange:
58 cbnz w4, InternalSyncCompareExchange32Again
60 InternalSyncCompareExchange32Fail:
66 Performs an atomic compare exchange operation on a 64-bit unsigned integer.
68 Performs an atomic compare exchange operation on the 64-bit unsigned integer specified
69 by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and
70 CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.
71 The compare exchange operation must be performed using MP safe mechanisms.
73 @param Value A pointer to the 64-bit value for the compare exchange
75 @param CompareValue 64-bit value used in compare operation.
76 @param ExchangeValue 64-bit value used in exchange operation.
78 @return The original *Value before exchange.
83 //InternalSyncCompareExchange64 (
84 // IN volatile UINT64 *Value,
85 // IN UINT64 CompareValue,
86 // IN UINT64 ExchangeValue
88 ASM_PFX(InternalSyncCompareExchange64):
91 InternalSyncCompareExchange64Again:
94 bne InternalSyncCompareExchange64Fail
96 InternalSyncCompareExchange64Exchange:
98 cbnz w4, InternalSyncCompareExchange64Again
100 InternalSyncCompareExchange64Fail:
106 Performs an atomic increment of an 32-bit unsigned integer.
108 Performs an atomic increment of the 32-bit unsigned integer specified by
109 Value and returns the incremented value. The increment operation must be
110 performed using MP safe mechanisms. The state of the return value is not
111 guaranteed to be MP safe.
113 @param Value A pointer to the 32-bit value to increment.
115 @return The incremented value.
120 //InternalSyncIncrement (
121 // IN volatile UINT32 *Value
123 ASM_PFX(InternalSyncIncrement):
125 TryInternalSyncIncrement:
129 cbnz w2, TryInternalSyncIncrement
134 Performs an atomic decrement of an 32-bit unsigned integer.
136 Performs an atomic decrement of the 32-bit unsigned integer specified by
137 Value and returns the decrement value. The decrement operation must be
138 performed using MP safe mechanisms. The state of the return value is not
139 guaranteed to be MP safe.
141 @param Value A pointer to the 32-bit value to decrement.
143 @return The decrement value.
148 //InternalSyncDecrement (
149 // IN volatile UINT32 *Value
151 ASM_PFX(InternalSyncDecrement):
153 TryInternalSyncDecrement:
157 cbnz w2, TryInternalSyncDecrement