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.
16 EXPORT InternalSyncCompareExchange16
17 EXPORT InternalSyncCompareExchange32
18 EXPORT InternalSyncCompareExchange64
19 EXPORT InternalSyncIncrement
20 EXPORT InternalSyncDecrement
21 AREA BaseSynchronizationLib_LowLevel, CODE, READONLY
24 ; Performs an atomic compare exchange operation on a 16-bit unsigned integer.
26 ; Performs an atomic compare exchange operation on the 16-bit unsigned integer
27 ; specified by Value. If Value is equal to CompareValue, then Value is set to
28 ; ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
29 ; then Value is returned. The compare exchange operation must be performed using
32 ; @param Value A pointer to the 16-bit value for the compare exchange
34 ; @param CompareValue 16-bit value used in compare operation.
35 ; @param ExchangeValue 16-bit value used in exchange operation.
37 ; @return The original *Value before exchange.
42 ;InternalSyncCompareExchange16 (
43 ; IN volatile UINT16 *Value,
44 ; IN UINT16 CompareValue,
45 ; IN UINT16 ExchangeValue
47 InternalSyncCompareExchange16
52 InternalSyncCompareExchange16Again
55 bne InternalSyncCompareExchange16Fail
57 InternalSyncCompareExchange16Exchange
59 cbnz w4, InternalSyncCompareExchange16Again
61 InternalSyncCompareExchange16Fail
67 ; Performs an atomic compare exchange operation on a 32-bit unsigned integer.
69 ; Performs an atomic compare exchange operation on the 32-bit unsigned integer
70 ; specified by Value. If Value is equal to CompareValue, then Value is set to
71 ; ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
72 ; then Value is returned. The compare exchange operation must be performed using
75 ; @param Value A pointer to the 32-bit value for the compare exchange
77 ; @param CompareValue 32-bit value used in compare operation.
78 ; @param ExchangeValue 32-bit value used in exchange operation.
80 ; @return The original *Value before exchange.
85 ;InternalSyncCompareExchange32 (
86 ; IN volatile UINT32 *Value,
87 ; IN UINT32 CompareValue,
88 ; IN UINT32 ExchangeValue
90 InternalSyncCompareExchange32
93 InternalSyncCompareExchange32Again
96 bne InternalSyncCompareExchange32Fail
98 InternalSyncCompareExchange32Exchange
100 cbnz w4, InternalSyncCompareExchange32Again
102 InternalSyncCompareExchange32Fail
108 ; Performs an atomic compare exchange operation on a 64-bit unsigned integer.
110 ; Performs an atomic compare exchange operation on the 64-bit unsigned integer specified
111 ; by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and
112 ; CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.
113 ; The compare exchange operation must be performed using MP safe mechanisms.
115 ; @param Value A pointer to the 64-bit value for the compare exchange
117 ; @param CompareValue 64-bit value used in compare operation.
118 ; @param ExchangeValue 64-bit value used in exchange operation.
120 ; @return The original *Value before exchange.
125 ;InternalSyncCompareExchange64 (
126 ; IN volatile UINT64 *Value,
127 ; IN UINT64 CompareValue,
128 ; IN UINT64 ExchangeValue
130 InternalSyncCompareExchange64
133 InternalSyncCompareExchange64Again
136 bne InternalSyncCompareExchange64Fail
138 InternalSyncCompareExchange64Exchange
140 cbnz w4, InternalSyncCompareExchange64Again
142 InternalSyncCompareExchange64Fail
148 ; Performs an atomic increment of an 32-bit unsigned integer.
150 ; Performs an atomic increment of the 32-bit unsigned integer specified by
151 ; Value and returns the incremented value. The increment operation must be
152 ; performed using MP safe mechanisms. The state of the return value is not
153 ; guaranteed to be MP safe.
155 ; @param Value A pointer to the 32-bit value to increment.
157 ; @return The incremented value.
162 ;InternalSyncIncrement (
163 ; IN volatile UINT32 *Value
165 InternalSyncIncrement
167 TryInternalSyncIncrement
171 cbnz w2, TryInternalSyncIncrement
177 ; Performs an atomic decrement of an 32-bit unsigned integer.
179 ; Performs an atomic decrement of the 32-bit unsigned integer specified by
180 ; Value and returns the decrement value. The decrement operation must be
181 ; performed using MP safe mechanisms. The state of the return value is not
182 ; guaranteed to be MP safe.
184 ; @param Value A pointer to the 32-bit value to decrement.
186 ; @return The decrement value.
191 ;InternalSyncDecrement (
192 ; IN volatile UINT32 *Value
194 InternalSyncDecrement
196 TryInternalSyncDecrement
200 cbnz w2, TryInternalSyncDecrement