]>
Commit | Line | Data |
---|---|---|
09f08c92 HT |
1 | /** @file\r |
2 | InterlockedCompareExchange16 function\r | |
3 | \r | |
4cee954e | 4 | Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r |
09f08c92 | 5 | Copyright (c) 2015, Linaro Ltd. All rights reserved.<BR>\r |
9344f092 | 6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
09f08c92 HT |
7 | \r |
8 | **/\r | |
9 | \r | |
10 | \r | |
11 | \r | |
12 | \r | |
13 | /**\r | |
14 | Performs an atomic compare exchange operation on a 16-bit unsigned integer.\r | |
15 | \r | |
16 | Performs an atomic compare exchange operation on the 16-bit unsigned integer\r | |
17 | specified by Value. If Value is equal to CompareValue, then Value is set to\r | |
18 | ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,\r | |
19 | then Value is returned. The compare exchange operation must be performed using\r | |
20 | MP safe mechanisms.\r | |
21 | \r | |
22 | @param Value A pointer to the 16-bit value for the compare exchange\r | |
23 | operation.\r | |
24 | @param CompareValue 16-bit value used in compare operation.\r | |
25 | @param ExchangeValue 16-bit value used in exchange operation.\r | |
26 | \r | |
27 | @return The original *Value before exchange.\r | |
28 | \r | |
29 | **/\r | |
30 | UINT16\r | |
31 | EFIAPI\r | |
32 | InternalSyncCompareExchange16 (\r | |
4cee954e | 33 | IN volatile UINT16 *Value,\r |
09f08c92 HT |
34 | IN UINT16 CompareValue,\r |
35 | IN UINT16 ExchangeValue\r | |
36 | )\r | |
37 | {\r | |
38 | _asm {\r | |
39 | mov ecx, Value\r | |
40 | mov ax, CompareValue\r | |
41 | mov dx, ExchangeValue\r | |
42 | lock cmpxchg [ecx], dx\r | |
43 | }\r | |
44 | }\r | |
45 | \r |