]>
Commit | Line | Data |
---|---|---|
97d92bda | 1 | /** @file\r |
2 | Implementation of synchronization functions on EBC.\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 | UINT32\r | |
18 | EFIAPI\r | |
19 | InternalSyncCompareExchange32 (\r | |
20 | IN volatile UINT32 *Value,\r | |
21 | IN UINT32 CompareValue,\r | |
22 | IN UINT32 ExchangeValue\r | |
23 | )\r | |
24 | {\r | |
25 | return *Value != CompareValue ? *Value :\r | |
26 | ((*Value = ExchangeValue), CompareValue);\r | |
27 | }\r | |
28 | \r | |
1ea5ca46 | 29 | /**\r |
30 | Performs an atomic compare exchange operation on a 64-bit unsigned integer.\r | |
31 | \r | |
32 | Performs an atomic compare exchange operation on the 64-bit unsigned integer specified \r | |
33 | by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and \r | |
34 | CompareValue is returned. If Value is not equal to CompareValue, then Value is returned. \r | |
35 | The compare exchange operation must be performed using MP safe mechanisms.\r | |
36 | \r | |
37 | @param Value A pointer to the 64-bit value for the compare exchange\r | |
38 | operation.\r | |
39 | @param CompareValue 64-bit value used in compare operation.\r | |
40 | @param ExchangeValue 64-bit value used in exchange operation.\r | |
41 | \r | |
42 | @return The original *Value before exchange.\r | |
43 | \r | |
44 | **/\r | |
97d92bda | 45 | UINT64\r |
46 | EFIAPI\r | |
47 | InternalSyncCompareExchange64 (\r | |
48 | IN volatile UINT64 *Value,\r | |
49 | IN UINT64 CompareValue,\r | |
50 | IN UINT64 ExchangeValue\r | |
51 | )\r | |
52 | {\r | |
53 | return *Value != CompareValue ? *Value :\r | |
54 | ((*Value = ExchangeValue), CompareValue);\r | |
55 | }\r | |
56 | \r | |
1ea5ca46 | 57 | /**\r |
58 | Performs an atomic increment of an 32-bit unsigned integer.\r | |
59 | \r | |
60 | Performs an atomic increment of the 32-bit unsigned integer specified by\r | |
61 | Value and returns the incremented value. The increment operation must be\r | |
62 | performed using MP safe mechanisms. The state of the return value is not\r | |
63 | guaranteed to be MP safe.\r | |
64 | \r | |
65 | @param Value A pointer to the 32-bit value to increment.\r | |
66 | \r | |
67 | @return The incremented value.\r | |
68 | \r | |
69 | **/\r | |
97d92bda | 70 | UINT32\r |
71 | EFIAPI\r | |
72 | InternalSyncIncrement (\r | |
73 | IN volatile UINT32 *Value\r | |
74 | )\r | |
75 | {\r | |
76 | return ++*Value;\r | |
77 | }\r | |
78 | \r | |
1ea5ca46 | 79 | /**\r |
80 | Performs an atomic decrement of an 32-bit unsigned integer.\r | |
81 | \r | |
82 | Performs an atomic decrement of the 32-bit unsigned integer specified by\r | |
83 | Value and returns the decrement value. The decrement operation must be\r | |
84 | performed using MP safe mechanisms. The state of the return value is not\r | |
85 | guaranteed to be MP safe.\r | |
86 | \r | |
87 | @param Value A pointer to the 32-bit value to decrement.\r | |
88 | \r | |
89 | @return The decrement value.\r | |
90 | \r | |
91 | **/\r | |
97d92bda | 92 | UINT32\r |
93 | EFIAPI\r | |
94 | InternalSyncDecrement (\r | |
95 | IN volatile UINT32 *Value\r | |
96 | )\r | |
97 | {\r | |
98 | return --*Value;\r | |
99 | }\r |