]>
git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/X64/GccInline.c
40a208f1985f4d46b9d62b2afb7bccd2da194b29
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
11 #include "BaseLibInternals.h"
17 Used to serialize load and store operations.
19 All loads and stores that proceed calls to this function are guaranteed to be
20 globally visible when this function returns.
29 // This is a little bit of overkill and it is more about the compiler that it is
30 // actually processor synchronization. This is like the _ReadWriteBarrier
31 // Microsoft specific intrinsic
32 __asm__
__volatile__ ("":::"memory");
37 Requests CPU to pause for a short period of time.
39 Requests CPU to pause for a short period of time. Typically used in MP
40 systems to prevent memory starvation while waiting for a spin lock.
49 __asm__
__volatile__ ("pause");
54 Generates a breakpoint on the CPU.
56 Generates a breakpoint on the CPU. The breakpoint must be implemented such
57 that code can resume normal execution after the breakpoint.
66 __asm__
__volatile__ ("int $3");
71 Reads the current value of the EFLAGS register.
73 Reads and returns the current value of the EFLAGS register. This function is
74 only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a
77 @return EFLAGS on IA-32 or RFLAGS on X64.
88 __asm__
__volatile__ (
98 Save the current floating point/SSE/SSE2 context to a buffer.
100 Saves the current floating point/SSE/SSE2 state to the buffer specified by
101 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
102 available on IA-32 and X64.
104 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
110 OUT IA32_FX_BUFFER
*Buffer
113 __asm__
__volatile__ (
116 : "m" (*Buffer
) // %0
122 Restores the current floating point/SSE/SSE2 context from a buffer.
124 Restores the current floating point/SSE/SSE2 state from the buffer specified
125 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
126 only available on IA-32 and X64.
128 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
133 InternalX86FxRestore (
134 IN CONST IA32_FX_BUFFER
*Buffer
137 __asm__
__volatile__ (
140 : "m" (*Buffer
) // %0
146 Reads the current value of 64-bit MMX Register #0 (MM0).
148 Reads and returns the current value of MM0. This function is only available
151 @return The current value of MM0.
162 __asm__
__volatile__ (
163 "movd %%mm0, %0 \n\t"
172 Reads the current value of 64-bit MMX Register #1 (MM1).
174 Reads and returns the current value of MM1. This function is only available
177 @return The current value of MM1.
188 __asm__
__volatile__ (
189 "movd %%mm1, %0 \n\t"
198 Reads the current value of 64-bit MMX Register #2 (MM2).
200 Reads and returns the current value of MM2. This function is only available
203 @return The current value of MM2.
214 __asm__
__volatile__ (
215 "movd %%mm2, %0 \n\t"
224 Reads the current value of 64-bit MMX Register #3 (MM3).
226 Reads and returns the current value of MM3. This function is only available
229 @return The current value of MM3.
240 __asm__
__volatile__ (
241 "movd %%mm3, %0 \n\t"
250 Reads the current value of 64-bit MMX Register #4 (MM4).
252 Reads and returns the current value of MM4. This function is only available
255 @return The current value of MM4.
266 __asm__
__volatile__ (
267 "movd %%mm4, %0 \n\t"
276 Reads the current value of 64-bit MMX Register #5 (MM5).
278 Reads and returns the current value of MM5. This function is only available
281 @return The current value of MM5.
292 __asm__
__volatile__ (
293 "movd %%mm5, %0 \n\t"
302 Reads the current value of 64-bit MMX Register #6 (MM6).
304 Reads and returns the current value of MM6. This function is only available
307 @return The current value of MM6.
318 __asm__
__volatile__ (
319 "movd %%mm6, %0 \n\t"
328 Reads the current value of 64-bit MMX Register #7 (MM7).
330 Reads and returns the current value of MM7. This function is only available
333 @return The current value of MM7.
344 __asm__
__volatile__ (
345 "movd %%mm7, %0 \n\t"
354 Writes the current value of 64-bit MMX Register #0 (MM0).
356 Writes the current value of MM0. This function is only available on IA32 and
359 @param Value The 64-bit value to write to MM0.
368 __asm__
__volatile__ (
369 "movd %0, %%mm0" // %0
377 Writes the current value of 64-bit MMX Register #1 (MM1).
379 Writes the current value of MM1. This function is only available on IA32 and
382 @param Value The 64-bit value to write to MM1.
391 __asm__
__volatile__ (
392 "movd %0, %%mm1" // %0
400 Writes the current value of 64-bit MMX Register #2 (MM2).
402 Writes the current value of MM2. This function is only available on IA32 and
405 @param Value The 64-bit value to write to MM2.
414 __asm__
__volatile__ (
415 "movd %0, %%mm2" // %0
423 Writes the current value of 64-bit MMX Register #3 (MM3).
425 Writes the current value of MM3. This function is only available on IA32 and
428 @param Value The 64-bit value to write to MM3.
437 __asm__
__volatile__ (
438 "movd %0, %%mm3" // %0
446 Writes the current value of 64-bit MMX Register #4 (MM4).
448 Writes the current value of MM4. This function is only available on IA32 and
451 @param Value The 64-bit value to write to MM4.
460 __asm__
__volatile__ (
461 "movd %0, %%mm4" // %0
469 Writes the current value of 64-bit MMX Register #5 (MM5).
471 Writes the current value of MM5. This function is only available on IA32 and
474 @param Value The 64-bit value to write to MM5.
483 __asm__
__volatile__ (
484 "movd %0, %%mm5" // %0
492 Writes the current value of 64-bit MMX Register #6 (MM6).
494 Writes the current value of MM6. This function is only available on IA32 and
497 @param Value The 64-bit value to write to MM6.
506 __asm__
__volatile__ (
507 "movd %0, %%mm6" // %0
515 Writes the current value of 64-bit MMX Register #7 (MM7).
517 Writes the current value of MM7. This function is only available on IA32 and
520 @param Value The 64-bit value to write to MM7.
529 __asm__
__volatile__ (
530 "movd %0, %%mm7" // %0
538 Reads the current value of Time Stamp Counter (TSC).
540 Reads and returns the current value of TSC. This function is only available
543 @return The current value of TSC
555 __asm__
__volatile__ (
561 return (((UINT64
)HiData
) << 32) | LowData
;