]>
Commit | Line | Data |
---|---|---|
ebd04fc2 | 1 | /** @file\r |
2 | Implementation of synchronization functions. Still needs to be ported\r | |
3 | \r | |
4 | Copyright (c) 2006 - 2009, Intel Corporation<BR>\r | |
5 | Portions copyright (c) 2008-2009 Apple Inc.<BR> \r | |
6 | All rights reserved. This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | UINT32\r | |
17 | EFIAPI\r | |
18 | InternalSyncCompareExchange32 (\r | |
19 | IN volatile UINT32 *Value,\r | |
20 | IN UINT32 CompareValue,\r | |
21 | IN UINT32 ExchangeValue\r | |
22 | )\r | |
23 | {\r | |
24 | return *Value != CompareValue ? *Value :\r | |
25 | ((*Value = ExchangeValue), CompareValue);\r | |
26 | }\r | |
27 | \r | |
28 | /**\r | |
29 | Performs an atomic compare exchange operation on a 64-bit unsigned integer.\r | |
30 | \r | |
31 | Performs an atomic compare exchange operation on the 64-bit unsigned integer specified \r | |
32 | by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and \r | |
33 | CompareValue is returned. If Value is not equal to CompareValue, then Value is returned. \r | |
34 | The compare exchange operation must be performed using MP safe mechanisms.\r | |
35 | \r | |
36 | @param Value A pointer to the 64-bit value for the compare exchange\r | |
37 | operation.\r | |
38 | @param CompareValue 64-bit value used in compare operation.\r | |
39 | @param ExchangeValue 64-bit value used in exchange operation.\r | |
40 | \r | |
41 | @return The original *Value before exchange.\r | |
42 | \r | |
43 | **/\r | |
44 | UINT64\r | |
45 | EFIAPI\r | |
46 | InternalSyncCompareExchange64 (\r | |
47 | IN volatile UINT64 *Value,\r | |
48 | IN UINT64 CompareValue,\r | |
49 | IN UINT64 ExchangeValue\r | |
50 | )\r | |
51 | {\r | |
52 | return *Value != CompareValue ? *Value :\r | |
53 | ((*Value = ExchangeValue), CompareValue);\r | |
54 | }\r | |
55 | \r | |
56 | /**\r | |
57 | Performs an atomic increment of an 32-bit unsigned integer.\r | |
58 | \r | |
59 | Performs an atomic increment of the 32-bit unsigned integer specified by\r | |
60 | Value and returns the incremented value. The increment operation must be\r | |
61 | performed using MP safe mechanisms. The state of the return value is not\r | |
62 | guaranteed to be MP safe.\r | |
63 | \r | |
64 | @param Value A pointer to the 32-bit value to increment.\r | |
65 | \r | |
66 | @return The incremented value.\r | |
67 | \r | |
68 | **/\r | |
69 | UINT32\r | |
70 | EFIAPI\r | |
71 | InternalSyncIncrement (\r | |
72 | IN volatile UINT32 *Value\r | |
73 | )\r | |
74 | {\r | |
75 | return ++*Value;\r | |
76 | }\r | |
77 | \r | |
78 | /**\r | |
79 | Performs an atomic decrement of an 32-bit unsigned integer.\r | |
80 | \r | |
81 | Performs an atomic decrement of the 32-bit unsigned integer specified by\r | |
82 | Value and returns the decrement value. The decrement operation must be\r | |
83 | performed using MP safe mechanisms. The state of the return value is not\r | |
84 | guaranteed to be MP safe.\r | |
85 | \r | |
86 | @param Value A pointer to the 32-bit value to decrement.\r | |
87 | \r | |
88 | @return The decrement value.\r | |
89 | \r | |
90 | **/\r | |
91 | UINT32\r | |
92 | EFIAPI\r | |
93 | InternalSyncDecrement (\r | |
94 | IN volatile UINT32 *Value\r | |
95 | )\r | |
96 | {\r | |
97 | return --*Value;\r | |
98 | }\r |