]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Implementation of synchronization functions on Itanium.\r | |
3 | \r | |
4 | Copyright (c) 2006, 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 | Module Name: Synchronization.c\r | |
14 | \r | |
15 | **/\r | |
16 | \r | |
17 | /**\r | |
18 | Performs an atomic compare exchange operation on a 32-bit unsigned integer.\r | |
19 | \r | |
20 | Performs an atomic compare exchange operation on the 32-bit unsigned integer\r | |
21 | specified by Value. If Value is equal to CompareValue, then Value is set to \r | |
22 | ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,\r | |
23 | then Value is returned. The compare exchange operation must be performed using \r | |
24 | MP safe mechanisms.\r | |
25 | \r | |
26 | @param Value A pointer to the 32-bit value for the compare exchange\r | |
27 | 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 | /**\r | |
43 | Performs an atomic increment of an 32-bit unsigned integer.\r | |
44 | \r | |
45 | Performs an atomic increment of the 32-bit unsigned integer specified by\r | |
46 | Value and returns the incremented value. The increment operation must be\r | |
47 | performed using MP safe mechanisms. The state of the return value is not\r | |
48 | guaranteed to be MP safe.\r | |
49 | \r | |
50 | @param Value A pointer to the 32-bit value to increment.\r | |
51 | \r | |
52 | @return The incremented value.\r | |
53 | \r | |
54 | **/\r | |
55 | UINT32\r | |
56 | EFIAPI\r | |
57 | InternalSyncIncrement (\r | |
58 | IN volatile UINT32 *Value\r | |
59 | )\r | |
60 | {\r | |
61 | UINT32 OriginalValue;\r | |
62 | \r | |
63 | do {\r | |
64 | OriginalValue = *Value;\r | |
65 | } while (OriginalValue != InternalSyncCompareExchange32 (\r | |
66 | Value,\r | |
67 | OriginalValue,\r | |
68 | OriginalValue + 1\r | |
69 | ));\r | |
70 | return OriginalValue + 1;\r | |
71 | }\r | |
72 | \r | |
73 | /**\r | |
74 | Performs an atomic decrement of an 32-bit unsigned integer.\r | |
75 | \r | |
76 | Performs an atomic decrement of the 32-bit unsigned integer specified by\r | |
77 | Value and returns the decrement value. The decrement 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 decrement.\r | |
82 | \r | |
83 | @return The decrement value.\r | |
84 | \r | |
85 | **/\r | |
86 | UINT32\r | |
87 | EFIAPI\r | |
88 | InternalSyncDecrement (\r | |
89 | IN volatile UINT32 *Value\r | |
90 | )\r | |
91 | {\r | |
92 | UINT32 OriginalValue;\r | |
93 | \r | |
94 | do {\r | |
95 | OriginalValue = *Value;\r | |
96 | } while (OriginalValue != InternalSyncCompareExchange32 (\r | |
97 | Value,\r | |
98 | OriginalValue,\r | |
99 | OriginalValue - 1\r | |
100 | ));\r | |
101 | return OriginalValue - 1;\r | |
102 | }\r |