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