]>
git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/X64/GccInline.c
2 GCC inline implementation of BaseLib processor specific functions.
4 Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR>
5 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include "BaseLibInternals.h"
13 Used to serialize load and store operations.
15 All loads and stores that proceed calls to this function are guaranteed to be
16 globally visible when this function returns.
25 // This is a little bit of overkill and it is more about the compiler that it is
26 // actually processor synchronization. This is like the _ReadWriteBarrier
27 // Microsoft specific intrinsic
28 __asm__
__volatile__ ("":::"memory");
32 Requests CPU to pause for a short period of time.
34 Requests CPU to pause for a short period of time. Typically used in MP
35 systems to prevent memory starvation while waiting for a spin lock.
44 __asm__
__volatile__ ("pause");
48 Generates a breakpoint on the CPU.
50 Generates a breakpoint on the CPU. The breakpoint must be implemented such
51 that code can resume normal execution after the breakpoint.
60 __asm__
__volatile__ ("int $3");
64 Reads the current value of the EFLAGS register.
66 Reads and returns the current value of the EFLAGS register. This function is
67 only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a
70 @return EFLAGS on IA-32 or RFLAGS on X64.
81 __asm__
__volatile__ (
91 Save the current floating point/SSE/SSE2 context to a buffer.
93 Saves the current floating point/SSE/SSE2 state to the buffer specified by
94 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
95 available on IA-32 and X64.
97 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
103 OUT IA32_FX_BUFFER
*Buffer
106 __asm__
__volatile__ (
109 : "m" (*Buffer
) // %0
114 Restores the current floating point/SSE/SSE2 context from a buffer.
116 Restores the current floating point/SSE/SSE2 state from the buffer specified
117 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
118 only available on IA-32 and X64.
120 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
125 InternalX86FxRestore (
126 IN CONST IA32_FX_BUFFER
*Buffer
129 __asm__
__volatile__ (
132 : "m" (*Buffer
) // %0
137 Reads the current value of 64-bit MMX Register #0 (MM0).
139 Reads and returns the current value of MM0. This function is only available
142 @return The current value of MM0.
153 __asm__
__volatile__ (
154 "movd %%mm0, %0 \n\t"
162 Reads the current value of 64-bit MMX Register #1 (MM1).
164 Reads and returns the current value of MM1. This function is only available
167 @return The current value of MM1.
178 __asm__
__volatile__ (
179 "movd %%mm1, %0 \n\t"
187 Reads the current value of 64-bit MMX Register #2 (MM2).
189 Reads and returns the current value of MM2. This function is only available
192 @return The current value of MM2.
203 __asm__
__volatile__ (
204 "movd %%mm2, %0 \n\t"
212 Reads the current value of 64-bit MMX Register #3 (MM3).
214 Reads and returns the current value of MM3. This function is only available
217 @return The current value of MM3.
228 __asm__
__volatile__ (
229 "movd %%mm3, %0 \n\t"
237 Reads the current value of 64-bit MMX Register #4 (MM4).
239 Reads and returns the current value of MM4. This function is only available
242 @return The current value of MM4.
253 __asm__
__volatile__ (
254 "movd %%mm4, %0 \n\t"
262 Reads the current value of 64-bit MMX Register #5 (MM5).
264 Reads and returns the current value of MM5. This function is only available
267 @return The current value of MM5.
278 __asm__
__volatile__ (
279 "movd %%mm5, %0 \n\t"
287 Reads the current value of 64-bit MMX Register #6 (MM6).
289 Reads and returns the current value of MM6. This function is only available
292 @return The current value of MM6.
303 __asm__
__volatile__ (
304 "movd %%mm6, %0 \n\t"
312 Reads the current value of 64-bit MMX Register #7 (MM7).
314 Reads and returns the current value of MM7. This function is only available
317 @return The current value of MM7.
328 __asm__
__volatile__ (
329 "movd %%mm7, %0 \n\t"
337 Writes the current value of 64-bit MMX Register #0 (MM0).
339 Writes the current value of MM0. This function is only available on IA32 and
342 @param Value The 64-bit value to write to MM0.
351 __asm__
__volatile__ (
352 "movd %0, %%mm0" // %0
359 Writes the current value of 64-bit MMX Register #1 (MM1).
361 Writes the current value of MM1. This function is only available on IA32 and
364 @param Value The 64-bit value to write to MM1.
373 __asm__
__volatile__ (
374 "movd %0, %%mm1" // %0
381 Writes the current value of 64-bit MMX Register #2 (MM2).
383 Writes the current value of MM2. This function is only available on IA32 and
386 @param Value The 64-bit value to write to MM2.
395 __asm__
__volatile__ (
396 "movd %0, %%mm2" // %0
403 Writes the current value of 64-bit MMX Register #3 (MM3).
405 Writes the current value of MM3. This function is only available on IA32 and
408 @param Value The 64-bit value to write to MM3.
417 __asm__
__volatile__ (
418 "movd %0, %%mm3" // %0
425 Writes the current value of 64-bit MMX Register #4 (MM4).
427 Writes the current value of MM4. This function is only available on IA32 and
430 @param Value The 64-bit value to write to MM4.
439 __asm__
__volatile__ (
440 "movd %0, %%mm4" // %0
447 Writes the current value of 64-bit MMX Register #5 (MM5).
449 Writes the current value of MM5. This function is only available on IA32 and
452 @param Value The 64-bit value to write to MM5.
461 __asm__
__volatile__ (
462 "movd %0, %%mm5" // %0
469 Writes the current value of 64-bit MMX Register #6 (MM6).
471 Writes the current value of MM6. This function is only available on IA32 and
474 @param Value The 64-bit value to write to MM6.
483 __asm__
__volatile__ (
484 "movd %0, %%mm6" // %0
491 Writes the current value of 64-bit MMX Register #7 (MM7).
493 Writes the current value of MM7. This function is only available on IA32 and
496 @param Value The 64-bit value to write to MM7.
505 __asm__
__volatile__ (
506 "movd %0, %%mm7" // %0
513 Reads the current value of Time Stamp Counter (TSC).
515 Reads and returns the current value of TSC. This function is only available
518 @return The current value of TSC
530 __asm__
__volatile__ (
536 return (((UINT64
)HiData
) << 32) | LowData
;