]>
git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/Ia32/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__ (
156 "movq %%mm0, (%%esp)\n\t"
166 Reads the current value of 64-bit MMX Register #1 (MM1).
168 Reads and returns the current value of MM1. This function is only available
171 @return The current value of MM1.
182 __asm__
__volatile__ (
185 "movq %%mm1, (%%esp)\n\t"
195 Reads the current value of 64-bit MMX Register #2 (MM2).
197 Reads and returns the current value of MM2. This function is only available
200 @return The current value of MM2.
211 __asm__
__volatile__ (
214 "movq %%mm2, (%%esp)\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__ (
243 "movq %%mm3, (%%esp)\n\t"
253 Reads the current value of 64-bit MMX Register #4 (MM4).
255 Reads and returns the current value of MM4. This function is only available
258 @return The current value of MM4.
269 __asm__
__volatile__ (
272 "movq %%mm4, (%%esp)\n\t"
282 Reads the current value of 64-bit MMX Register #5 (MM5).
284 Reads and returns the current value of MM5. This function is only available
287 @return The current value of MM5.
298 __asm__
__volatile__ (
301 "movq %%mm5, (%%esp)\n\t"
311 Reads the current value of 64-bit MMX Register #6 (MM6).
313 Reads and returns the current value of MM6. This function is only available
316 @return The current value of MM6.
327 __asm__
__volatile__ (
330 "movq %%mm6, (%%esp)\n\t"
340 Reads the current value of 64-bit MMX Register #7 (MM7).
342 Reads and returns the current value of MM7. This function is only available
345 @return The current value of MM7.
356 __asm__
__volatile__ (
359 "movq %%mm7, (%%esp)\n\t"
369 Writes the current value of 64-bit MMX Register #0 (MM0).
371 Writes the current value of MM0. This function is only available on IA32 and
374 @param Value The 64-bit value to write to MM0.
383 __asm__
__volatile__ (
384 "movq %0, %%mm0" // %0
391 Writes the current value of 64-bit MMX Register #1 (MM1).
393 Writes the current value of MM1. This function is only available on IA32 and
396 @param Value The 64-bit value to write to MM1.
405 __asm__
__volatile__ (
406 "movq %0, %%mm1" // %0
413 Writes the current value of 64-bit MMX Register #2 (MM2).
415 Writes the current value of MM2. This function is only available on IA32 and
418 @param Value The 64-bit value to write to MM2.
427 __asm__
__volatile__ (
428 "movq %0, %%mm2" // %0
435 Writes the current value of 64-bit MMX Register #3 (MM3).
437 Writes the current value of MM3. This function is only available on IA32 and
440 @param Value The 64-bit value to write to MM3.
449 __asm__
__volatile__ (
450 "movq %0, %%mm3" // %0
457 Writes the current value of 64-bit MMX Register #4 (MM4).
459 Writes the current value of MM4. This function is only available on IA32 and
462 @param Value The 64-bit value to write to MM4.
471 __asm__
__volatile__ (
472 "movq %0, %%mm4" // %0
479 Writes the current value of 64-bit MMX Register #5 (MM5).
481 Writes the current value of MM5. This function is only available on IA32 and
484 @param Value The 64-bit value to write to MM5.
493 __asm__
__volatile__ (
494 "movq %0, %%mm5" // %0
501 Writes the current value of 64-bit MMX Register #6 (MM6).
503 Writes the current value of MM6. This function is only available on IA32 and
506 @param Value The 64-bit value to write to MM6.
515 __asm__
__volatile__ (
516 "movq %0, %%mm6" // %0
523 Writes the current value of 64-bit MMX Register #7 (MM7).
525 Writes the current value of MM7. This function is only available on IA32 and
528 @param Value The 64-bit value to write to MM7.
537 __asm__
__volatile__ (
538 "movq %0, %%mm7" // %0
545 Reads the current value of Time Stamp Counter (TSC).
547 Reads and returns the current value of TSC. This function is only available
550 @return The current value of TSC
561 __asm__
__volatile__ (