]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLibInternals.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdePkg / Library / BaseSynchronizationLib / BaseSynchronizationLibInternals.h
1 /** @file
2 Declaration of internal functions in BaseSynchronizationLib.
3
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #ifndef __BASE_SYNCHRONIZATION_LIB_INTERNALS__
10 #define __BASE_SYNCHRONIZATION_LIB_INTERNALS__
11
12 #include <Base.h>
13 #include <Library/SynchronizationLib.h>
14 #include <Library/BaseLib.h>
15 #include <Library/DebugLib.h>
16 #include <Library/TimerLib.h>
17 #include <Library/PcdLib.h>
18
19 /**
20 Performs an atomic increment of an 32-bit unsigned integer.
21
22 Performs an atomic increment of the 32-bit unsigned integer specified by
23 Value and returns the incremented value. The increment operation must be
24 performed using MP safe mechanisms.
25
26 @param Value A pointer to the 32-bit value to increment.
27
28 @return The incremented value.
29
30 **/
31 UINT32
32 EFIAPI
33 InternalSyncIncrement (
34 IN volatile UINT32 *Value
35 );
36
37 /**
38 Performs an atomic decrement of an 32-bit unsigned integer.
39
40 Performs an atomic decrement of the 32-bit unsigned integer specified by
41 Value and returns the decrement value. The decrement operation must be
42 performed using MP safe mechanisms.
43
44 @param Value A pointer to the 32-bit value to decrement.
45
46 @return The decrement value.
47
48 **/
49 UINT32
50 EFIAPI
51 InternalSyncDecrement (
52 IN volatile UINT32 *Value
53 );
54
55 /**
56 Performs an atomic compare exchange operation on a 16-bit unsigned integer.
57
58 Performs an atomic compare exchange operation on the 16-bit unsigned integer
59 specified by Value. If Value is equal to CompareValue, then Value is set to
60 ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
61 then Value is returned. The compare exchange operation must be performed using
62 MP safe mechanisms.
63
64 @param Value A pointer to the 16-bit value for the compare exchange
65 operation.
66 @param CompareValue A 16-bit value used in compare operation.
67 @param ExchangeValue A 16-bit value used in exchange operation.
68
69 @return The original *Value before exchange.
70
71 **/
72 UINT16
73 EFIAPI
74 InternalSyncCompareExchange16 (
75 IN volatile UINT16 *Value,
76 IN UINT16 CompareValue,
77 IN UINT16 ExchangeValue
78 );
79
80 /**
81 Performs an atomic compare exchange operation on a 32-bit unsigned integer.
82
83 Performs an atomic compare exchange operation on the 32-bit unsigned integer
84 specified by Value. If Value is equal to CompareValue, then Value is set to
85 ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
86 then Value is returned. The compare exchange operation must be performed using
87 MP safe mechanisms.
88
89 @param Value A pointer to the 32-bit value for the compare exchange
90 operation.
91 @param CompareValue A 32-bit value used in compare operation.
92 @param ExchangeValue A 32-bit value used in exchange operation.
93
94 @return The original *Value before exchange.
95
96 **/
97 UINT32
98 EFIAPI
99 InternalSyncCompareExchange32 (
100 IN volatile UINT32 *Value,
101 IN UINT32 CompareValue,
102 IN UINT32 ExchangeValue
103 );
104
105 /**
106 Performs an atomic compare exchange operation on a 64-bit unsigned integer.
107
108 Performs an atomic compare exchange operation on the 64-bit unsigned integer specified
109 by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and
110 CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.
111 The compare exchange operation must be performed using MP safe mechanisms.
112
113 @param Value A pointer to the 64-bit value for the compare exchange
114 operation.
115 @param CompareValue A 64-bit value used in compare operation.
116 @param ExchangeValue A 64-bit value used in exchange operation.
117
118 @return The original *Value before exchange.
119
120 **/
121 UINT64
122 EFIAPI
123 InternalSyncCompareExchange64 (
124 IN volatile UINT64 *Value,
125 IN UINT64 CompareValue,
126 IN UINT64 ExchangeValue
127 );
128
129 /**
130 Internal function to retrieve the architecture specific spin lock alignment
131 requirements for optimal spin lock performance.
132
133 @return The architecture specific spin lock alignment.
134
135 **/
136 UINTN
137 InternalGetSpinLockProperties (
138 VOID
139 );
140
141 #endif