TianoCore EDK2 master
Loading...
Searching...
No Matches
GccInline.c
Go to the documentation of this file.
1
22UINT32
23EFIAPI
25 IN volatile UINT32 *Value
26 )
27{
28 UINT32 Result;
29
30 __asm__ __volatile__ (
31 "movl $1, %%eax \n\t"
32 "lock \n\t"
33 "xadd %%eax, %1 \n\t"
34 "inc %%eax \n\t"
35 : "=&a" (Result), // %0
36 "+m" (*Value) // %1
37 : // no inputs that aren't also outputs
38 : "memory",
39 "cc"
40 );
41
42 return Result;
43}
44
57UINT32
58EFIAPI
60 IN volatile UINT32 *Value
61 )
62{
63 UINT32 Result;
64
65 __asm__ __volatile__ (
66 "movl $-1, %%eax \n\t"
67 "lock \n\t"
68 "xadd %%eax, %1 \n\t"
69 "dec %%eax \n\t"
70 : "=&a" (Result), // %0
71 "+m" (*Value) // %1
72 : // no inputs that aren't also outputs
73 : "memory",
74 "cc"
75 );
76
77 return Result;
78}
79
98UINT16
99EFIAPI
101 IN OUT volatile UINT16 *Value,
102 IN UINT16 CompareValue,
103 IN UINT16 ExchangeValue
104 )
105{
106 __asm__ __volatile__ (
107 "lock \n\t"
108 "cmpxchgw %2, %1 \n\t"
109 : "+a" (CompareValue), // %0
110 "+m" (*Value) // %1
111 : "q" (ExchangeValue) // %2
112 : "memory",
113 "cc"
114 );
115
116 return CompareValue;
117}
118
137UINT32
138EFIAPI
140 IN OUT volatile UINT32 *Value,
141 IN UINT32 CompareValue,
142 IN UINT32 ExchangeValue
143 )
144{
145 __asm__ __volatile__ (
146 "lock \n\t"
147 "cmpxchgl %2, %1 \n\t"
148 : "+a" (CompareValue), // %0
149 "+m" (*Value) // %1
150 : "q" (ExchangeValue) // %2
151 : "memory",
152 "cc"
153 );
154
155 return CompareValue;
156}
157
175UINT64
176EFIAPI
178 IN OUT volatile UINT64 *Value,
179 IN UINT64 CompareValue,
180 IN UINT64 ExchangeValue
181 )
182{
183 __asm__ __volatile__ (
184 "lock \n\t"
185 "cmpxchg8b (%1) \n\t"
186 : "+A" (CompareValue) // %0
187 : "S" (Value), // %1
188 "b" ((UINT32) ExchangeValue), // %2
189 "c" ((UINT32) (ExchangeValue >> 32)) // %3
190 : "memory",
191 "cc"
192 );
193
194 return CompareValue;
195}
UINT16 EFIAPI InternalSyncCompareExchange16(IN OUT volatile UINT16 *Value, IN UINT16 CompareValue, IN UINT16 ExchangeValue)
Definition: GccInline.c:100
UINT32 EFIAPI InternalSyncDecrement(IN volatile UINT32 *Value)
Definition: GccInline.c:59
UINT64 EFIAPI InternalSyncCompareExchange64(IN OUT volatile UINT64 *Value, IN UINT64 CompareValue, IN UINT64 ExchangeValue)
Definition: GccInline.c:177
UINT32 EFIAPI InternalSyncIncrement(IN volatile UINT32 *Value)
Definition: GccInline.c:24
UINT32 EFIAPI InternalSyncCompareExchange32(IN OUT volatile UINT32 *Value, IN UINT32 CompareValue, IN UINT32 ExchangeValue)
Definition: GccInline.c:139
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284