]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseLib/X64/GccInline.c
Clean up MdePkg source to correct some coding style issues, etc.
[mirror_edk2.git] / MdePkg / Library / BaseLib / X64 / GccInline.c
CommitLineData
ebd04fc2 1/** @file\r
2 GCC inline implementation of BaseLib processor specific functions.\r
3 \r
ea6898b9 4 Copyright (c) 2006 - 2010, Intel Corporation<BR>\r
7f22d351 5 Portions copyright (c) 2008-2009 Apple Inc. All rights reserved.<BR> \r
ebd04fc2 6 All rights reserved. This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16\r
17#include "BaseLibInternals.h"\r
18\r
19\r
20\r
21\r
22/**\r
23 Used to serialize load and store operations.\r
24\r
25 All loads and stores that proceed calls to this function are guaranteed to be\r
26 globally visible when this function returns.\r
27\r
28**/\r
29VOID\r
30EFIAPI\r
31MemoryFence (\r
32 VOID\r
33 )\r
34{\r
35 // This is a little bit of overkill and it is more about the compiler that it is\r
36 // actually processor syncronization. This is like the _ReadWriteBarrier \r
37 // Microsft specific intrinsic\r
38 __asm__ __volatile__ ("":::"memory");\r
39}\r
40\r
41\r
42/**\r
43 Enables CPU interrupts.\r
44\r
45 Enables CPU interrupts.\r
46\r
47**/\r
48VOID\r
49EFIAPI\r
50EnableInterrupts (\r
51 VOID\r
52 )\r
53{\r
54 __asm__ __volatile__ ("sti"::: "memory");\r
55}\r
56\r
57\r
58/**\r
59 Disables CPU interrupts.\r
60\r
61 Disables CPU interrupts.\r
62\r
63**/\r
64VOID\r
65EFIAPI\r
66DisableInterrupts (\r
67 VOID\r
68 )\r
69{ \r
70 __asm__ __volatile__ ("cli"::: "memory");\r
71}\r
72\r
73\r
74\r
75\r
76/**\r
77 Requests CPU to pause for a short period of time.\r
78\r
79 Requests CPU to pause for a short period of time. Typically used in MP\r
80 systems to prevent memory starvation while waiting for a spin lock.\r
81\r
82**/\r
83VOID\r
84EFIAPI\r
85CpuPause (\r
86 VOID\r
87 )\r
88{\r
89 __asm__ __volatile__ ("pause");\r
90}\r
91\r
92\r
93/**\r
94 Generates a breakpoint on the CPU.\r
95\r
96 Generates a breakpoint on the CPU. The breakpoint must be implemented such\r
97 that code can resume normal execution after the breakpoint.\r
98\r
99**/\r
100VOID\r
101EFIAPI\r
102CpuBreakpoint (\r
103 VOID\r
104 )\r
105{\r
106 __asm__ __volatile__ ("int $3");\r
107}\r
108\r
109\r
110\r
111/**\r
112 Returns a 64-bit Machine Specific Register(MSR).\r
113\r
114 Reads and returns the 64-bit MSR specified by Index. No parameter checking is\r
115 performed on Index, and some Index values may cause CPU exceptions. The\r
116 caller must either guarantee that Index is valid, or the caller must set up\r
117 exception handlers to catch the exceptions. This function is only available\r
118 on IA-32 and X64.\r
119\r
120 @param Index The 32-bit MSR index to read.\r
121\r
122 @return The value of the MSR identified by Index.\r
123\r
124**/\r
125UINT64\r
126EFIAPI\r
127AsmReadMsr64 (\r
128 IN UINT32 Index\r
129 )\r
130{\r
131 UINT32 LowData;\r
132 UINT32 HighData;\r
133 \r
134 __asm__ __volatile__ (\r
135 "rdmsr"\r
136 : "=a" (LowData), // %0\r
137 "=d" (HighData) // %1\r
138 : "c" (Index) // %2\r
139 );\r
140 \r
141 return (((UINT64)HighData) << 32) | LowData;\r
142}\r
143\r
144/**\r
145 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the\r
146 value.\r
147\r
148 Writes the 64-bit value specified by Value to the MSR specified by Index. The\r
149 64-bit value written to the MSR is returned. No parameter checking is\r
150 performed on Index or Value, and some of these may cause CPU exceptions. The\r
151 caller must either guarantee that Index and Value are valid, or the caller\r
152 must establish proper exception handlers. This function is only available on\r
153 IA-32 and X64.\r
154\r
155 @param Index The 32-bit MSR index to write.\r
156 @param Value The 64-bit value to write to the MSR.\r
157\r
158 @return Value\r
159\r
160**/\r
161UINT64\r
162EFIAPI\r
163AsmWriteMsr64 (\r
164 IN UINT32 Index,\r
165 IN UINT64 Value\r
166 )\r
167{\r
168 UINT32 LowData;\r
169 UINT32 HighData;\r
170\r
171 LowData = (UINT32)(Value);\r
172 HighData = (UINT32)(Value >> 32);\r
173 \r
174 __asm__ __volatile__ (\r
175 "wrmsr"\r
176 :\r
177 : "c" (Index),\r
178 "a" (LowData),\r
179 "d" (HighData)\r
180 );\r
181 \r
182 return Value;\r
183}\r
184\r
185\r
186\r
187/**\r
188 Reads the current value of the EFLAGS register.\r
189\r
190 Reads and returns the current value of the EFLAGS register. This function is\r
191 only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a\r
192 64-bit value on X64.\r
193\r
194 @return EFLAGS on IA-32 or RFLAGS on X64.\r
195\r
196**/\r
197UINTN\r
198EFIAPI\r
199AsmReadEflags (\r
200 VOID\r
201 )\r
202{\r
203 UINTN Eflags;\r
204 \r
205 __asm__ __volatile__ (\r
206 "pushfq \n\t"\r
207 "pop %0 "\r
208 : "=r" (Eflags) // %0\r
209 );\r
210 \r
211 return Eflags;\r
212}\r
213\r
214\r
215\r
216/**\r
217 Reads the current value of the Control Register 0 (CR0).\r
218\r
219 Reads and returns the current value of CR0. This function is only available\r
220 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
221 X64.\r
222\r
223 @return The value of the Control Register 0 (CR0).\r
224\r
225**/\r
226UINTN\r
227EFIAPI\r
228AsmReadCr0 (\r
229 VOID\r
230 )\r
231{\r
232 UINTN Data;\r
233 \r
234 __asm__ __volatile__ (\r
235 "mov %%cr0,%0" \r
236 : "=r" (Data) // %0\r
237 );\r
238 \r
239 return Data;\r
240}\r
241\r
242\r
243/**\r
244 Reads the current value of the Control Register 2 (CR2).\r
245\r
246 Reads and returns the current value of CR2. This function is only available\r
247 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
248 X64.\r
249\r
250 @return The value of the Control Register 2 (CR2).\r
251\r
252**/\r
253UINTN\r
254EFIAPI\r
255AsmReadCr2 (\r
256 VOID\r
257 )\r
258{\r
259 UINTN Data;\r
260 \r
261 __asm__ __volatile__ (\r
262 "mov %%cr2, %0" \r
263 : "=r" (Data) // %0\r
264 );\r
265 \r
266 return Data;\r
267}\r
268\r
269/**\r
270 Reads the current value of the Control Register 3 (CR3).\r
271\r
272 Reads and returns the current value of CR3. This function is only available\r
273 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
274 X64.\r
275\r
276 @return The value of the Control Register 3 (CR3).\r
277\r
278**/\r
279UINTN\r
280EFIAPI\r
281AsmReadCr3 (\r
282 VOID\r
283 )\r
284{\r
285 UINTN Data;\r
286 \r
287 __asm__ __volatile__ (\r
288 "mov %%cr3, %0" \r
289 : "=r" (Data) // %0\r
290 );\r
291 \r
292 return Data;\r
293}\r
294\r
295\r
296/**\r
297 Reads the current value of the Control Register 4 (CR4).\r
298\r
299 Reads and returns the current value of CR4. This function is only available\r
300 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
301 X64.\r
302\r
303 @return The value of the Control Register 4 (CR4).\r
304\r
305**/\r
306UINTN\r
307EFIAPI\r
308AsmReadCr4 (\r
309 VOID\r
310 )\r
311{\r
312 UINTN Data;\r
313 \r
314 __asm__ __volatile__ (\r
315 "mov %%cr4, %0" \r
316 : "=r" (Data) // %0\r
317 );\r
318 \r
319 return Data;\r
320}\r
321\r
322\r
323/**\r
324 Writes a value to Control Register 0 (CR0).\r
325\r
326 Writes and returns a new value to CR0. This function is only available on\r
327 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
328\r
329 @param Cr0 The value to write to CR0.\r
330\r
331 @return The value written to CR0.\r
332\r
333**/\r
334UINTN\r
335EFIAPI\r
336AsmWriteCr0 (\r
337 UINTN Cr0\r
338 )\r
339{\r
340 __asm__ __volatile__ (\r
341 "mov %0, %%cr0"\r
342 :\r
343 : "r" (Cr0)\r
344 );\r
345 return Cr0;\r
346}\r
347\r
348\r
349/**\r
350 Writes a value to Control Register 2 (CR2).\r
351\r
352 Writes and returns a new value to CR2. This function is only available on\r
353 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
354\r
355 @param Cr2 The value to write to CR2.\r
356\r
357 @return The value written to CR2.\r
358\r
359**/\r
360UINTN\r
361EFIAPI\r
362AsmWriteCr2 (\r
363 UINTN Cr2\r
364 )\r
365{\r
366 __asm__ __volatile__ (\r
367 "mov %0, %%cr2"\r
368 :\r
369 : "r" (Cr2)\r
370 );\r
371 return Cr2;\r
372}\r
373\r
374\r
375/**\r
376 Writes a value to Control Register 3 (CR3).\r
377\r
378 Writes and returns a new value to CR3. This function is only available on\r
379 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
380\r
381 @param Cr3 The value to write to CR3.\r
382\r
383 @return The value written to CR3.\r
384\r
385**/\r
386UINTN\r
387EFIAPI\r
388AsmWriteCr3 (\r
389 UINTN Cr3\r
390 )\r
391{\r
392 __asm__ __volatile__ (\r
393 "mov %0, %%cr3"\r
394 :\r
395 : "r" (Cr3)\r
396 );\r
397 return Cr3;\r
398}\r
399\r
400\r
401/**\r
402 Writes a value to Control Register 4 (CR4).\r
403\r
404 Writes and returns a new value to CR4. This function is only available on\r
405 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
406\r
407 @param Cr4 The value to write to CR4.\r
408\r
409 @return The value written to CR4.\r
410\r
411**/\r
412UINTN\r
413EFIAPI\r
414AsmWriteCr4 (\r
415 UINTN Cr4\r
416 )\r
417{\r
418 __asm__ __volatile__ (\r
419 "mov %0, %%cr4"\r
420 :\r
421 : "r" (Cr4)\r
422 );\r
423 return Cr4;\r
424}\r
425\r
426\r
427/**\r
428 Reads the current value of Debug Register 0 (DR0).\r
429\r
430 Reads and returns the current value of DR0. This function is only available\r
431 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
432 X64.\r
433\r
434 @return The value of Debug Register 0 (DR0).\r
435\r
436**/\r
437UINTN\r
438EFIAPI\r
439AsmReadDr0 (\r
440 VOID\r
441 )\r
442{\r
443 UINTN Data;\r
444 \r
445 __asm__ __volatile__ (\r
446 "mov %%dr0, %0"\r
447 : "=r" (Data)\r
448 );\r
449 \r
450 return Data;\r
451}\r
452\r
453\r
454/**\r
455 Reads the current value of Debug Register 1 (DR1).\r
456\r
457 Reads and returns the current value of DR1. This function is only available\r
458 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
459 X64.\r
460\r
461 @return The value of Debug Register 1 (DR1).\r
462\r
463**/\r
464UINTN\r
465EFIAPI\r
466AsmReadDr1 (\r
467 VOID\r
468 )\r
469{\r
470 UINTN Data;\r
471 \r
472 __asm__ __volatile__ (\r
473 "mov %%dr1, %0"\r
474 : "=r" (Data)\r
475 );\r
476 \r
477 return Data;\r
478}\r
479\r
480\r
481/**\r
482 Reads the current value of Debug Register 2 (DR2).\r
483\r
484 Reads and returns the current value of DR2. This function is only available\r
485 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
486 X64.\r
487\r
488 @return The value of Debug Register 2 (DR2).\r
489\r
490**/\r
491UINTN\r
492EFIAPI\r
493AsmReadDr2 (\r
494 VOID\r
495 )\r
496{\r
497 UINTN Data;\r
498 \r
499 __asm__ __volatile__ (\r
500 "mov %%dr2, %0"\r
501 : "=r" (Data)\r
502 );\r
503 \r
504 return Data;\r
505}\r
506\r
507\r
508/**\r
509 Reads the current value of Debug Register 3 (DR3).\r
510\r
511 Reads and returns the current value of DR3. This function is only available\r
512 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
513 X64.\r
514\r
515 @return The value of Debug Register 3 (DR3).\r
516\r
517**/\r
518UINTN\r
519EFIAPI\r
520AsmReadDr3 (\r
521 VOID\r
522 )\r
523{\r
524 UINTN Data;\r
525 \r
526 __asm__ __volatile__ (\r
527 "mov %%dr3, %0"\r
528 : "=r" (Data)\r
529 );\r
530 \r
531 return Data;\r
532}\r
533\r
534\r
535/**\r
536 Reads the current value of Debug Register 4 (DR4).\r
537\r
538 Reads and returns the current value of DR4. This function is only available\r
539 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
540 X64.\r
541\r
542 @return The value of Debug Register 4 (DR4).\r
543\r
544**/\r
545UINTN\r
546EFIAPI\r
547AsmReadDr4 (\r
548 VOID\r
549 )\r
550{\r
551 UINTN Data;\r
552 \r
553 __asm__ __volatile__ (\r
554 "mov %%dr4, %0"\r
555 : "=r" (Data)\r
556 );\r
557 \r
558 return Data;\r
559}\r
560\r
561\r
562/**\r
563 Reads the current value of Debug Register 5 (DR5).\r
564\r
565 Reads and returns the current value of DR5. This function is only available\r
566 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
567 X64.\r
568\r
569 @return The value of Debug Register 5 (DR5).\r
570\r
571**/\r
572UINTN\r
573EFIAPI\r
574AsmReadDr5 (\r
575 VOID\r
576 )\r
577{\r
578 UINTN Data;\r
579 \r
580 __asm__ __volatile__ (\r
581 "mov %%dr5, %0"\r
582 : "=r" (Data)\r
583 );\r
584 \r
585 return Data;\r
586}\r
587\r
588\r
589/**\r
590 Reads the current value of Debug Register 6 (DR6).\r
591\r
592 Reads and returns the current value of DR6. This function is only available\r
593 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
594 X64.\r
595\r
596 @return The value of Debug Register 6 (DR6).\r
597\r
598**/\r
599UINTN\r
600EFIAPI\r
601AsmReadDr6 (\r
602 VOID\r
603 )\r
604{\r
605 UINTN Data;\r
606 \r
607 __asm__ __volatile__ (\r
608 "mov %%dr6, %0"\r
609 : "=r" (Data)\r
610 );\r
611 \r
612 return Data;\r
613}\r
614\r
615\r
616/**\r
617 Reads the current value of Debug Register 7 (DR7).\r
618\r
619 Reads and returns the current value of DR7. This function is only available\r
620 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
621 X64.\r
622\r
623 @return The value of Debug Register 7 (DR7).\r
624\r
625**/\r
626UINTN\r
627EFIAPI\r
628AsmReadDr7 (\r
629 VOID\r
630 )\r
631{\r
632 UINTN Data;\r
633 \r
634 __asm__ __volatile__ (\r
635 "mov %%dr7, %0"\r
636 : "=r" (Data)\r
637 );\r
638 \r
639 return Data;\r
640}\r
641\r
642\r
643/**\r
644 Writes a value to Debug Register 0 (DR0).\r
645\r
646 Writes and returns a new value to DR0. This function is only available on\r
647 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
648\r
649 @param Dr0 The value to write to Dr0.\r
650\r
651 @return The value written to Debug Register 0 (DR0).\r
652\r
653**/\r
654UINTN\r
655EFIAPI\r
656AsmWriteDr0 (\r
657 UINTN Dr0\r
658 )\r
659{\r
660 __asm__ __volatile__ (\r
661 "mov %0, %%dr0"\r
662 :\r
663 : "r" (Dr0)\r
664 );\r
665 return Dr0;\r
666}\r
667\r
668\r
669/**\r
670 Writes a value to Debug Register 1 (DR1).\r
671\r
672 Writes and returns a new value to DR1. This function is only available on\r
673 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
674\r
675 @param Dr1 The value to write to Dr1.\r
676\r
677 @return The value written to Debug Register 1 (DR1).\r
678\r
679**/\r
680UINTN\r
681EFIAPI\r
682AsmWriteDr1 (\r
683 UINTN Dr1\r
684 )\r
685{\r
686 __asm__ __volatile__ (\r
687 "mov %0, %%dr1"\r
688 :\r
689 : "r" (Dr1)\r
690 );\r
691 return Dr1;\r
692}\r
693\r
694\r
695/**\r
696 Writes a value to Debug Register 2 (DR2).\r
697\r
698 Writes and returns a new value to DR2. This function is only available on\r
699 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
700\r
701 @param Dr2 The value to write to Dr2.\r
702\r
703 @return The value written to Debug Register 2 (DR2).\r
704\r
705**/\r
706UINTN\r
707EFIAPI\r
708AsmWriteDr2 (\r
709 UINTN Dr2\r
710 )\r
711{\r
712 __asm__ __volatile__ (\r
713 "mov %0, %%dr2"\r
714 :\r
715 : "r" (Dr2)\r
716 );\r
717 return Dr2;\r
718}\r
719\r
720\r
721/**\r
722 Writes a value to Debug Register 3 (DR3).\r
723\r
724 Writes and returns a new value to DR3. This function is only available on\r
725 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
726\r
727 @param Dr3 The value to write to Dr3.\r
728\r
729 @return The value written to Debug Register 3 (DR3).\r
730\r
731**/\r
732UINTN\r
733EFIAPI\r
734AsmWriteDr3 (\r
735 UINTN Dr3\r
736 )\r
737{\r
738 __asm__ __volatile__ (\r
739 "mov %0, %%dr3"\r
740 :\r
741 : "r" (Dr3)\r
742 );\r
743 return Dr3;\r
744}\r
745\r
746\r
747/**\r
748 Writes a value to Debug Register 4 (DR4).\r
749\r
750 Writes and returns a new value to DR4. This function is only available on\r
751 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
752\r
753 @param Dr4 The value to write to Dr4.\r
754\r
755 @return The value written to Debug Register 4 (DR4).\r
756\r
757**/\r
758UINTN\r
759EFIAPI\r
760AsmWriteDr4 (\r
761 UINTN Dr4\r
762 )\r
763{\r
764 __asm__ __volatile__ (\r
765 "mov %0, %%dr4"\r
766 :\r
767 : "r" (Dr4)\r
768 );\r
769 return Dr4;\r
770}\r
771\r
772\r
773/**\r
774 Writes a value to Debug Register 5 (DR5).\r
775\r
776 Writes and returns a new value to DR5. This function is only available on\r
777 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
778\r
779 @param Dr5 The value to write to Dr5.\r
780\r
781 @return The value written to Debug Register 5 (DR5).\r
782\r
783**/\r
784UINTN\r
785EFIAPI\r
786AsmWriteDr5 (\r
787 UINTN Dr5\r
788 )\r
789{\r
790 __asm__ __volatile__ (\r
791 "mov %0, %%dr5"\r
792 :\r
793 : "r" (Dr5)\r
794 );\r
795 return Dr5;\r
796}\r
797\r
798\r
799/**\r
800 Writes a value to Debug Register 6 (DR6).\r
801\r
802 Writes and returns a new value to DR6. This function is only available on\r
803 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
804\r
805 @param Dr6 The value to write to Dr6.\r
806\r
807 @return The value written to Debug Register 6 (DR6).\r
808\r
809**/\r
810UINTN\r
811EFIAPI\r
812AsmWriteDr6 (\r
813 UINTN Dr6\r
814 )\r
815{\r
816 __asm__ __volatile__ (\r
817 "mov %0, %%dr6"\r
818 :\r
819 : "r" (Dr6)\r
820 );\r
821 return Dr6;\r
822}\r
823\r
824\r
825/**\r
826 Writes a value to Debug Register 7 (DR7).\r
827\r
828 Writes and returns a new value to DR7. This function is only available on\r
829 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
830\r
831 @param Dr7 The value to write to Dr7.\r
832\r
833 @return The value written to Debug Register 7 (DR7).\r
834\r
835**/\r
836UINTN\r
837EFIAPI\r
838AsmWriteDr7 (\r
839 UINTN Dr7\r
840 )\r
841{\r
842 __asm__ __volatile__ (\r
843 "mov %0, %%dr7"\r
844 :\r
845 : "r" (Dr7)\r
846 );\r
847 return Dr7;\r
848}\r
849\r
850\r
851/**\r
852 Reads the current value of Code Segment Register (CS).\r
853\r
854 Reads and returns the current value of CS. This function is only available on\r
855 IA-32 and X64.\r
856\r
857 @return The current value of CS.\r
858\r
859**/\r
860UINT16\r
861EFIAPI\r
862AsmReadCs (\r
863 VOID\r
864 )\r
865{\r
866 UINT16 Data;\r
867 \r
868 __asm__ __volatile__ (\r
869 "mov %%cs, %0"\r
870 :"=a" (Data)\r
871 );\r
872 \r
873 return Data;\r
874}\r
875\r
876\r
877/**\r
878 Reads the current value of Data Segment Register (DS).\r
879\r
880 Reads and returns the current value of DS. This function is only available on\r
881 IA-32 and X64.\r
882\r
883 @return The current value of DS.\r
884\r
885**/\r
886UINT16\r
887EFIAPI\r
888AsmReadDs (\r
889 VOID\r
890 )\r
891{\r
892 UINT16 Data;\r
893 \r
894 __asm__ __volatile__ (\r
895 "mov %%ds, %0"\r
896 :"=a" (Data)\r
897 );\r
898 \r
899 return Data;\r
900}\r
901\r
902\r
903/**\r
904 Reads the current value of Extra Segment Register (ES).\r
905\r
906 Reads and returns the current value of ES. This function is only available on\r
907 IA-32 and X64.\r
908\r
909 @return The current value of ES.\r
910\r
911**/\r
912UINT16\r
913EFIAPI\r
914AsmReadEs (\r
915 VOID\r
916 )\r
917{\r
918 UINT16 Data;\r
919 \r
920 __asm__ __volatile__ (\r
921 "mov %%es, %0"\r
922 :"=a" (Data)\r
923 );\r
924 \r
925 return Data;\r
926}\r
927\r
928\r
929/**\r
930 Reads the current value of FS Data Segment Register (FS).\r
931\r
932 Reads and returns the current value of FS. This function is only available on\r
933 IA-32 and X64.\r
934\r
935 @return The current value of FS.\r
936\r
937**/\r
938UINT16\r
939EFIAPI\r
940AsmReadFs (\r
941 VOID\r
942 )\r
943{\r
944 UINT16 Data;\r
945 \r
946 __asm__ __volatile__ (\r
947 "mov %%fs, %0"\r
948 :"=a" (Data)\r
949 );\r
950 \r
951 return Data;\r
952}\r
953\r
954\r
955/**\r
956 Reads the current value of GS Data Segment Register (GS).\r
957\r
958 Reads and returns the current value of GS. This function is only available on\r
959 IA-32 and X64.\r
960\r
961 @return The current value of GS.\r
962\r
963**/\r
964UINT16\r
965EFIAPI\r
966AsmReadGs (\r
967 VOID\r
968 )\r
969{\r
970 UINT16 Data;\r
971 \r
972 __asm__ __volatile__ (\r
973 "mov %%gs, %0"\r
974 :"=a" (Data)\r
975 );\r
976 \r
977 return Data;\r
978}\r
979\r
980\r
981/**\r
982 Reads the current value of Stack Segment Register (SS).\r
983\r
984 Reads and returns the current value of SS. This function is only available on\r
985 IA-32 and X64.\r
986\r
987 @return The current value of SS.\r
988\r
989**/\r
990UINT16\r
991EFIAPI\r
992AsmReadSs (\r
993 VOID\r
994 )\r
995{\r
996 UINT16 Data;\r
997 \r
998 __asm__ __volatile__ (\r
999 "mov %%ds, %0"\r
1000 :"=a" (Data)\r
1001 );\r
1002 \r
1003 return Data;\r
1004}\r
1005\r
1006\r
1007/**\r
1008 Reads the current value of Task Register (TR).\r
1009\r
1010 Reads and returns the current value of TR. This function is only available on\r
1011 IA-32 and X64.\r
1012\r
1013 @return The current value of TR.\r
1014\r
1015**/\r
1016UINT16\r
1017EFIAPI\r
1018AsmReadTr (\r
1019 VOID\r
1020 )\r
1021{\r
1022 UINT16 Data;\r
1023 \r
1024 __asm__ __volatile__ (\r
1025 "str %0"\r
1026 : "=r" (Data)\r
1027 );\r
1028 \r
1029 return Data;\r
1030}\r
1031\r
1032\r
1033/**\r
1034 Reads the current Global Descriptor Table Register(GDTR) descriptor.\r
1035\r
1036 Reads and returns the current GDTR descriptor and returns it in Gdtr. This\r
1037 function is only available on IA-32 and X64.\r
1038\r
1039 @param Gdtr Pointer to a GDTR descriptor.\r
1040\r
1041**/\r
1042VOID\r
1043EFIAPI\r
1044InternalX86ReadGdtr (\r
1045 OUT IA32_DESCRIPTOR *Gdtr\r
1046 )\r
1047{\r
1048 __asm__ __volatile__ (\r
1049 "sgdt %0"\r
1050 : "=m" (*Gdtr)\r
1051 );\r
1052}\r
1053\r
1054\r
1055/**\r
1056 Writes the current Global Descriptor Table Register (GDTR) descriptor.\r
1057\r
1058 Writes and the current GDTR descriptor specified by Gdtr. This function is\r
1059 only available on IA-32 and X64.\r
1060\r
1061 @param Gdtr Pointer to a GDTR descriptor.\r
1062\r
1063**/\r
1064VOID\r
1065EFIAPI\r
1066InternalX86WriteGdtr (\r
1067 IN CONST IA32_DESCRIPTOR *Gdtr\r
1068 )\r
1069{\r
1070 __asm__ __volatile__ (\r
1071 "lgdt %0"\r
1072 :\r
1073 : "m" (*Gdtr)\r
1074 );\r
1075 \r
1076}\r
1077\r
1078\r
1079/**\r
1080 Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.\r
1081\r
1082 Reads and returns the current IDTR descriptor and returns it in Idtr. This\r
1083 function is only available on IA-32 and X64.\r
1084\r
1085 @param Idtr Pointer to a IDTR descriptor.\r
1086\r
1087**/\r
1088VOID\r
1089EFIAPI\r
1090InternalX86ReadIdtr (\r
ea6898b9 1091 OUT IA32_DESCRIPTOR *Idtr\r
ebd04fc2 1092 )\r
1093{\r
1094 __asm__ __volatile__ (\r
1095 "sldt %0"\r
ea6898b9 1096 : "=m" (*Idtr)\r
ebd04fc2 1097 );\r
1098}\r
1099\r
1100\r
1101/**\r
1102 Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.\r
1103\r
1104 Writes the current IDTR descriptor and returns it in Idtr. This function is\r
1105 only available on IA-32 and X64.\r
1106\r
1107 @param Idtr Pointer to a IDTR descriptor.\r
1108\r
1109**/\r
1110VOID\r
1111EFIAPI\r
1112InternalX86WriteIdtr (\r
ea6898b9 1113 IN CONST IA32_DESCRIPTOR *Idtr\r
ebd04fc2 1114 )\r
1115{\r
1116 __asm__ __volatile__ (\r
1117 "lidt %0"\r
1118 :\r
ea6898b9 1119 : "m" (*Idtr)\r
ebd04fc2 1120 );\r
1121}\r
1122\r
1123\r
1124/**\r
1125 Reads the current Local Descriptor Table Register(LDTR) selector.\r
1126\r
1127 Reads and returns the current 16-bit LDTR descriptor value. This function is\r
1128 only available on IA-32 and X64.\r
1129\r
1130 @return The current selector of LDT.\r
1131\r
1132**/\r
1133UINT16\r
1134EFIAPI\r
1135AsmReadLdtr (\r
1136 VOID\r
1137 )\r
1138{\r
1139 UINT16 Data;\r
1140 \r
1141 __asm__ __volatile__ (\r
1142 "sldt %0"\r
1143 : "=g" (Data) // %0\r
1144 );\r
1145 \r
1146 return Data;\r
1147}\r
1148\r
1149\r
1150/**\r
1151 Writes the current Local Descriptor Table Register (GDTR) selector.\r
1152\r
1153 Writes and the current LDTR descriptor specified by Ldtr. This function is\r
1154 only available on IA-32 and X64.\r
1155\r
1156 @param Ldtr 16-bit LDTR selector value.\r
1157\r
1158**/\r
1159VOID\r
1160EFIAPI\r
1161AsmWriteLdtr (\r
1162 IN UINT16 Ldtr\r
1163 )\r
1164{\r
1165 __asm__ __volatile__ (\r
1166 "lldtw %0"\r
1167 :\r
1168 : "g" (Ldtr) // %0\r
1169 );\r
1170}\r
1171\r
1172\r
1173/**\r
1174 Save the current floating point/SSE/SSE2 context to a buffer.\r
1175\r
1176 Saves the current floating point/SSE/SSE2 state to the buffer specified by\r
1177 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only\r
1178 available on IA-32 and X64.\r
1179\r
1180 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.\r
1181\r
1182**/\r
1183VOID\r
1184EFIAPI\r
1185InternalX86FxSave (\r
1186 OUT IA32_FX_BUFFER *Buffer\r
1187 )\r
1188{\r
1189 __asm__ __volatile__ (\r
1190 "fxsave %0"\r
1191 :\r
1192 : "m" (*Buffer) // %0\r
1193 ); \r
1194}\r
1195\r
1196\r
1197/**\r
1198 Restores the current floating point/SSE/SSE2 context from a buffer.\r
1199\r
1200 Restores the current floating point/SSE/SSE2 state from the buffer specified\r
1201 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is\r
1202 only available on IA-32 and X64.\r
1203\r
1204 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.\r
1205\r
1206**/\r
1207VOID\r
1208EFIAPI\r
1209InternalX86FxRestore (\r
1210 IN CONST IA32_FX_BUFFER *Buffer\r
1211 )\r
1212{\r
1213 __asm__ __volatile__ (\r
1214 "fxrstor %0"\r
1215 :\r
1216 : "m" (*Buffer) // %0\r
1217 );\r
1218}\r
1219\r
1220\r
1221/**\r
1222 Reads the current value of 64-bit MMX Register #0 (MM0).\r
1223\r
1224 Reads and returns the current value of MM0. This function is only available\r
1225 on IA-32 and X64.\r
1226\r
1227 @return The current value of MM0.\r
1228\r
1229**/\r
1230UINT64\r
1231EFIAPI\r
1232AsmReadMm0 (\r
1233 VOID\r
1234 )\r
1235{\r
1236 UINT64 Data;\r
1237\r
1238 __asm__ __volatile__ (\r
1239 "movd %%mm0, %0 \n\t"\r
1240 : "=r" (Data) // %0\r
1241 );\r
1242 \r
1243 return Data;\r
1244}\r
1245\r
1246\r
1247/**\r
1248 Reads the current value of 64-bit MMX Register #1 (MM1).\r
1249\r
1250 Reads and returns the current value of MM1. This function is only available\r
1251 on IA-32 and X64.\r
1252\r
1253 @return The current value of MM1.\r
1254\r
1255**/\r
1256UINT64\r
1257EFIAPI\r
1258AsmReadMm1 (\r
1259 VOID\r
1260 )\r
1261{\r
1262 UINT64 Data;\r
1263\r
1264 __asm__ __volatile__ (\r
1265 "movd %%mm1, %0 \n\t"\r
1266 : "=r" (Data) // %0\r
1267 );\r
1268 \r
1269 return Data;\r
1270}\r
1271\r
1272\r
1273/**\r
1274 Reads the current value of 64-bit MMX Register #2 (MM2).\r
1275\r
1276 Reads and returns the current value of MM2. This function is only available\r
1277 on IA-32 and X64.\r
1278\r
1279 @return The current value of MM2.\r
1280\r
1281**/\r
1282UINT64\r
1283EFIAPI\r
1284AsmReadMm2 (\r
1285 VOID\r
1286 )\r
1287{\r
1288 UINT64 Data;\r
1289\r
1290 __asm__ __volatile__ (\r
1291 "movd %%mm2, %0 \n\t"\r
1292 : "=r" (Data) // %0\r
1293 );\r
1294 \r
1295 return Data;\r
1296}\r
1297\r
1298\r
1299/**\r
1300 Reads the current value of 64-bit MMX Register #3 (MM3).\r
1301\r
1302 Reads and returns the current value of MM3. This function is only available\r
1303 on IA-32 and X64.\r
1304\r
1305 @return The current value of MM3.\r
1306\r
1307**/\r
1308UINT64\r
1309EFIAPI\r
1310AsmReadMm3 (\r
1311 VOID\r
1312 )\r
1313{\r
1314 UINT64 Data;\r
1315\r
1316 __asm__ __volatile__ (\r
1317 "movd %%mm3, %0 \n\t"\r
1318 : "=r" (Data) // %0\r
1319 );\r
1320 \r
1321 return Data;\r
1322}\r
1323\r
1324\r
1325/**\r
1326 Reads the current value of 64-bit MMX Register #4 (MM4).\r
1327\r
1328 Reads and returns the current value of MM4. This function is only available\r
1329 on IA-32 and X64.\r
1330\r
1331 @return The current value of MM4.\r
1332\r
1333**/\r
1334UINT64\r
1335EFIAPI\r
1336AsmReadMm4 (\r
1337 VOID\r
1338 )\r
1339{\r
1340 UINT64 Data;\r
1341\r
1342 __asm__ __volatile__ (\r
1343 "movd %%mm4, %0 \n\t"\r
1344 : "=r" (Data) // %0\r
1345 );\r
1346 \r
1347 return Data;\r
1348}\r
1349\r
1350\r
1351/**\r
1352 Reads the current value of 64-bit MMX Register #5 (MM5).\r
1353\r
1354 Reads and returns the current value of MM5. This function is only available\r
1355 on IA-32 and X64.\r
1356\r
1357 @return The current value of MM5.\r
1358\r
1359**/\r
1360UINT64\r
1361EFIAPI\r
1362AsmReadMm5 (\r
1363 VOID\r
1364 )\r
1365{\r
1366 UINT64 Data;\r
1367\r
1368 __asm__ __volatile__ (\r
1369 "movd %%mm5, %0 \n\t"\r
1370 : "=r" (Data) // %0\r
1371 );\r
1372 \r
1373 return Data;\r
1374}\r
1375\r
1376\r
1377/**\r
1378 Reads the current value of 64-bit MMX Register #6 (MM6).\r
1379\r
1380 Reads and returns the current value of MM6. This function is only available\r
1381 on IA-32 and X64.\r
1382\r
1383 @return The current value of MM6.\r
1384\r
1385**/\r
1386UINT64\r
1387EFIAPI\r
1388AsmReadMm6 (\r
1389 VOID\r
1390 )\r
1391{\r
1392 UINT64 Data;\r
1393\r
1394 __asm__ __volatile__ (\r
1395 "movd %%mm6, %0 \n\t"\r
1396 : "=r" (Data) // %0\r
1397 );\r
1398 \r
1399 return Data;\r
1400}\r
1401\r
1402\r
1403/**\r
1404 Reads the current value of 64-bit MMX Register #7 (MM7).\r
1405\r
1406 Reads and returns the current value of MM7. This function is only available\r
1407 on IA-32 and X64.\r
1408\r
1409 @return The current value of MM7.\r
1410\r
1411**/\r
1412UINT64\r
1413EFIAPI\r
1414AsmReadMm7 (\r
1415 VOID\r
1416 )\r
1417{\r
1418 UINT64 Data;\r
1419\r
1420 __asm__ __volatile__ (\r
1421 "movd %%mm7, %0 \n\t"\r
1422 : "=r" (Data) // %0\r
1423 );\r
1424 \r
1425 return Data;\r
1426}\r
1427\r
1428\r
1429/**\r
1430 Writes the current value of 64-bit MMX Register #0 (MM0).\r
1431\r
1432 Writes the current value of MM0. This function is only available on IA32 and\r
1433 X64.\r
1434\r
1435 @param Value The 64-bit value to write to MM0.\r
1436\r
1437**/\r
1438VOID\r
1439EFIAPI\r
1440AsmWriteMm0 (\r
1441 IN UINT64 Value\r
1442 )\r
1443{\r
1444 __asm__ __volatile__ (\r
1445 "movd %0, %%mm0" // %0\r
1446 : \r
1447 : "m" (Value)\r
1448 );\r
1449}\r
1450\r
1451\r
1452/**\r
1453 Writes the current value of 64-bit MMX Register #1 (MM1).\r
1454\r
1455 Writes the current value of MM1. This function is only available on IA32 and\r
1456 X64.\r
1457\r
1458 @param Value The 64-bit value to write to MM1.\r
1459\r
1460**/\r
1461VOID\r
1462EFIAPI\r
1463AsmWriteMm1 (\r
1464 IN UINT64 Value\r
1465 )\r
1466{\r
1467 __asm__ __volatile__ (\r
1468 "movd %0, %%mm1" // %0\r
1469 : \r
1470 : "m" (Value)\r
1471 );\r
1472}\r
1473\r
1474\r
1475/**\r
1476 Writes the current value of 64-bit MMX Register #2 (MM2).\r
1477\r
1478 Writes the current value of MM2. This function is only available on IA32 and\r
1479 X64.\r
1480\r
1481 @param Value The 64-bit value to write to MM2.\r
1482\r
1483**/\r
1484VOID\r
1485EFIAPI\r
1486AsmWriteMm2 (\r
1487 IN UINT64 Value\r
1488 )\r
1489{\r
1490 __asm__ __volatile__ (\r
1491 "movd %0, %%mm2" // %0\r
1492 : \r
1493 : "m" (Value)\r
1494 );\r
1495}\r
1496\r
1497\r
1498/**\r
1499 Writes the current value of 64-bit MMX Register #3 (MM3).\r
1500\r
1501 Writes the current value of MM3. This function is only available on IA32 and\r
1502 X64.\r
1503\r
1504 @param Value The 64-bit value to write to MM3.\r
1505\r
1506**/\r
1507VOID\r
1508EFIAPI\r
1509AsmWriteMm3 (\r
1510 IN UINT64 Value\r
1511 )\r
1512{\r
1513 __asm__ __volatile__ (\r
1514 "movd %0, %%mm3" // %0\r
1515 : \r
1516 : "m" (Value)\r
1517 );\r
1518}\r
1519\r
1520\r
1521/**\r
1522 Writes the current value of 64-bit MMX Register #4 (MM4).\r
1523\r
1524 Writes the current value of MM4. This function is only available on IA32 and\r
1525 X64.\r
1526\r
1527 @param Value The 64-bit value to write to MM4.\r
1528\r
1529**/\r
1530VOID\r
1531EFIAPI\r
1532AsmWriteMm4 (\r
1533 IN UINT64 Value\r
1534 )\r
1535{\r
1536 __asm__ __volatile__ (\r
1537 "movd %0, %%mm4" // %0\r
1538 : \r
1539 : "m" (Value)\r
1540 );\r
1541}\r
1542\r
1543\r
1544/**\r
1545 Writes the current value of 64-bit MMX Register #5 (MM5).\r
1546\r
1547 Writes the current value of MM5. This function is only available on IA32 and\r
1548 X64.\r
1549\r
1550 @param Value The 64-bit value to write to MM5.\r
1551\r
1552**/\r
1553VOID\r
1554EFIAPI\r
1555AsmWriteMm5 (\r
1556 IN UINT64 Value\r
1557 )\r
1558{\r
1559 __asm__ __volatile__ (\r
1560 "movd %0, %%mm5" // %0\r
1561 : \r
1562 : "m" (Value)\r
1563 );\r
1564}\r
1565\r
1566\r
1567/**\r
1568 Writes the current value of 64-bit MMX Register #6 (MM6).\r
1569\r
1570 Writes the current value of MM6. This function is only available on IA32 and\r
1571 X64.\r
1572\r
1573 @param Value The 64-bit value to write to MM6.\r
1574\r
1575**/\r
1576VOID\r
1577EFIAPI\r
1578AsmWriteMm6 (\r
1579 IN UINT64 Value\r
1580 )\r
1581{\r
1582 __asm__ __volatile__ (\r
1583 "movd %0, %%mm6" // %0\r
1584 : \r
1585 : "m" (Value)\r
1586 );\r
1587}\r
1588\r
1589\r
1590/**\r
1591 Writes the current value of 64-bit MMX Register #7 (MM7).\r
1592\r
1593 Writes the current value of MM7. This function is only available on IA32 and\r
1594 X64.\r
1595\r
1596 @param Value The 64-bit value to write to MM7.\r
1597\r
1598**/\r
1599VOID\r
1600EFIAPI\r
1601AsmWriteMm7 (\r
1602 IN UINT64 Value\r
1603 )\r
1604{\r
1605 __asm__ __volatile__ (\r
1606 "movd %0, %%mm7" // %0\r
1607 : \r
1608 : "m" (Value)\r
1609 );\r
1610}\r
1611\r
1612\r
1613/**\r
1614 Reads the current value of Time Stamp Counter (TSC).\r
1615\r
1616 Reads and returns the current value of TSC. This function is only available\r
1617 on IA-32 and X64.\r
1618\r
1619 @return The current value of TSC\r
1620\r
1621**/\r
1622UINT64\r
1623EFIAPI\r
1624AsmReadTsc (\r
1625 VOID\r
1626 )\r
1627{\r
1628 UINT32 LowData;\r
1629 UINT32 HiData;\r
1630 \r
1631 __asm__ __volatile__ (\r
1632 "rdtsc"\r
1633 : "=a" (LowData),\r
1634 "=d" (HiData)\r
1635 );\r
1636 \r
1637 return (((UINT64)HiData) << 32) | LowData; \r
1638}\r
1639\r
1640\r
1641/**\r
1642 Reads the current value of a Performance Counter (PMC).\r
1643\r
1644 Reads and returns the current value of performance counter specified by\r
1645 Index. This function is only available on IA-32 and X64.\r
1646\r
1647 @param Index The 32-bit Performance Counter index to read.\r
1648\r
1649 @return The value of the PMC specified by Index.\r
1650\r
1651**/\r
1652UINT64\r
1653EFIAPI\r
1654AsmReadPmc (\r
1655 IN UINT32 Index\r
1656 )\r
1657{\r
1658 UINT32 LowData;\r
1659 UINT32 HiData;\r
1660 \r
1661 __asm__ __volatile__ (\r
1662 "rdpmc"\r
1663 : "=a" (LowData),\r
1664 "=d" (HiData)\r
1665 : "c" (Index)\r
1666 );\r
1667 \r
1668 return (((UINT64)HiData) << 32) | LowData; \r
1669}\r
1670\r
1671\r
1672/**\r
1673 Sets up a monitor buffer that is used by AsmMwait().\r
1674\r
1675 Executes a MONITOR instruction with the register state specified by Eax, Ecx\r
1676 and Edx. Returns Eax. This function is only available on IA-32 and X64.\r
1677\r
1678 @param Eax The value to load into EAX or RAX before executing the MONITOR\r
1679 instruction.\r
1680 @param Ecx The value to load into ECX or RCX before executing the MONITOR\r
1681 instruction.\r
1682 @param Edx The value to load into EDX or RDX before executing the MONITOR\r
1683 instruction.\r
1684\r
1685 @return Eax\r
1686\r
1687**/\r
1688UINTN\r
1689EFIAPI\r
1690AsmMonitor (\r
1691 IN UINTN Eax,\r
1692 IN UINTN Ecx,\r
1693 IN UINTN Edx\r
1694 )\r
1695{\r
1696 __asm__ __volatile__ (\r
1697 "monitor"\r
1698 :\r
1699 : "a" (Eax),\r
1700 "c" (Ecx),\r
1701 "d" (Edx)\r
1702 );\r
1703 \r
1704 return Eax;\r
1705}\r
1706\r
1707\r
1708/**\r
1709 Executes an MWAIT instruction.\r
1710\r
1711 Executes an MWAIT instruction with the register state specified by Eax and\r
1712 Ecx. Returns Eax. This function is only available on IA-32 and X64.\r
1713\r
1714 @param Eax The value to load into EAX or RAX before executing the MONITOR\r
1715 instruction.\r
1716 @param Ecx The value to load into ECX or RCX before executing the MONITOR\r
1717 instruction.\r
1718\r
1719 @return Eax\r
1720\r
1721**/\r
1722UINTN\r
1723EFIAPI\r
1724AsmMwait (\r
1725 IN UINTN Eax,\r
1726 IN UINTN Ecx\r
1727 )\r
1728{\r
1729 __asm__ __volatile__ (\r
1730 "mwait"\r
1731 : \r
1732 : "a" (Eax),\r
1733 "c" (Ecx)\r
1734 );\r
1735 \r
1736 return Eax; \r
1737}\r
1738\r
1739\r
1740/**\r
1741 Executes a WBINVD instruction.\r
1742\r
1743 Executes a WBINVD instruction. This function is only available on IA-32 and\r
1744 X64.\r
1745\r
1746**/\r
1747VOID\r
1748EFIAPI\r
1749AsmWbinvd (\r
1750 VOID\r
1751 )\r
1752{\r
1753 __asm__ __volatile__ ("wbinvd":::"memory");\r
1754}\r
1755\r
1756\r
1757/**\r
1758 Executes a INVD instruction.\r
1759\r
1760 Executes a INVD instruction. This function is only available on IA-32 and\r
1761 X64.\r
1762\r
1763**/\r
1764VOID\r
1765EFIAPI\r
1766AsmInvd (\r
1767 VOID\r
1768 )\r
1769{\r
1770 __asm__ __volatile__ ("invd":::"memory");\r
1771 \r
1772}\r
1773\r
1774\r
1775/**\r
1776 Flushes a cache line from all the instruction and data caches within the\r
1777 coherency domain of the CPU.\r
1778\r
1779 Flushed the cache line specified by LinearAddress, and returns LinearAddress.\r
1780 This function is only available on IA-32 and X64.\r
1781\r
1782 @param LinearAddress The address of the cache line to flush. If the CPU is\r
1783 in a physical addressing mode, then LinearAddress is a\r
1784 physical address. If the CPU is in a virtual\r
1785 addressing mode, then LinearAddress is a virtual\r
1786 address.\r
1787\r
1788 @return LinearAddress\r
1789**/\r
1790VOID *\r
1791EFIAPI\r
1792AsmFlushCacheLine (\r
1793 IN VOID *LinearAddress\r
1794 )\r
1795{\r
1796 __asm__ __volatile__ (\r
1797 "clflush (%0)"\r
1798 :\r
1799 : "r" (LinearAddress) \r
1800 : "memory"\r
1801 );\r
1802 \r
1803 return LinearAddress;\r
1804}\r
1805\r
1806\r