]>
Commit | Line | Data |
---|---|---|
ebd04fc2 | 1 | /** @file\r |
2 | Implementation of synchronization functions. Still needs to be ported\r | |
3 | \r | |
e2d9bfb2 HT |
4 | Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r |
5 | Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r | |
6 | This program and the accompanying materials\r | |
ebd04fc2 | 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 | |
2fc59a00 | 9 | http://opensource.org/licenses/bsd-license.php.\r |
ebd04fc2 | 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 | |
ea6898b9 | 16 | /**\r |
17 | Performs an atomic compare exchange operation on a 32-bit unsigned integer.\r | |
18 | \r | |
19 | Performs an atomic compare exchange operation on the 32-bit unsigned integer\r | |
20 | specified by Value. If Value is equal to CompareValue, then Value is set to\r | |
21 | ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,\r | |
22 | then Value is returned. The compare exchange operation must be performed using\r | |
23 | MP safe mechanisms.\r | |
24 | \r | |
25 | @param Value A pointer to the 32-bit value for the compare exchange\r | |
26 | operation.\r | |
27 | @param CompareValue 32-bit value used in compare operation.\r | |
28 | @param ExchangeValue 32-bit value used in exchange operation.\r | |
29 | \r | |
30 | @return The original *Value before exchange.\r | |
31 | \r | |
32 | **/\r | |
ebd04fc2 | 33 | UINT32\r |
34 | EFIAPI\r | |
35 | InternalSyncCompareExchange32 (\r | |
36 | IN volatile UINT32 *Value,\r | |
37 | IN UINT32 CompareValue,\r | |
38 | IN UINT32 ExchangeValue\r | |
39 | )\r | |
40 | {\r | |
41 | return *Value != CompareValue ? *Value :\r | |
42 | ((*Value = ExchangeValue), CompareValue);\r | |
43 | }\r | |
44 | \r | |
45 | /**\r | |
46 | Performs an atomic compare exchange operation on a 64-bit unsigned integer.\r | |
47 | \r | |
48 | Performs an atomic compare exchange operation on the 64-bit unsigned integer specified \r | |
49 | by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and \r | |
50 | CompareValue is returned. If Value is not equal to CompareValue, then Value is returned. \r | |
51 | The compare exchange operation must be performed using MP safe mechanisms.\r | |
52 | \r | |
53 | @param Value A pointer to the 64-bit value for the compare exchange\r | |
54 | operation.\r | |
55 | @param CompareValue 64-bit value used in compare operation.\r | |
56 | @param ExchangeValue 64-bit value used in exchange operation.\r | |
57 | \r | |
58 | @return The original *Value before exchange.\r | |
59 | \r | |
60 | **/\r | |
61 | UINT64\r | |
62 | EFIAPI\r | |
63 | InternalSyncCompareExchange64 (\r | |
64 | IN volatile UINT64 *Value,\r | |
65 | IN UINT64 CompareValue,\r | |
66 | IN UINT64 ExchangeValue\r | |
67 | )\r | |
68 | {\r | |
69 | return *Value != CompareValue ? *Value :\r | |
70 | ((*Value = ExchangeValue), CompareValue);\r | |
71 | }\r | |
72 | \r | |
73 | /**\r | |
74 | Performs an atomic increment of an 32-bit unsigned integer.\r | |
75 | \r | |
76 | Performs an atomic increment of the 32-bit unsigned integer specified by\r | |
77 | Value and returns the incremented value. The increment operation must be\r | |
78 | performed using MP safe mechanisms. The state of the return value is not\r | |
79 | guaranteed to be MP safe.\r | |
80 | \r | |
81 | @param Value A pointer to the 32-bit value to increment.\r | |
82 | \r | |
83 | @return The incremented value.\r | |
84 | \r | |
85 | **/\r | |
86 | UINT32\r | |
87 | EFIAPI\r | |
88 | InternalSyncIncrement (\r | |
89 | IN volatile UINT32 *Value\r | |
90 | )\r | |
91 | {\r | |
92 | return ++*Value;\r | |
93 | }\r | |
94 | \r | |
95 | /**\r | |
96 | Performs an atomic decrement of an 32-bit unsigned integer.\r | |
97 | \r | |
98 | Performs an atomic decrement of the 32-bit unsigned integer specified by\r | |
99 | Value and returns the decrement value. The decrement operation must be\r | |
100 | performed using MP safe mechanisms. The state of the return value is not\r | |
101 | guaranteed to be MP safe.\r | |
102 | \r | |
103 | @param Value A pointer to the 32-bit value to decrement.\r | |
104 | \r | |
105 | @return The decrement value.\r | |
106 | \r | |
107 | **/\r | |
108 | UINT32\r | |
109 | EFIAPI\r | |
110 | InternalSyncDecrement (\r | |
111 | IN volatile UINT32 *Value\r | |
112 | )\r | |
113 | {\r | |
114 | return --*Value;\r | |
115 | }\r |