]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseLib/X64/GccInline.c
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / BaseLib / X64 / GccInline.c
index d559e3be55ed81172ce5c99f57c32ae5fdf9368c..154ce1f57e925e4ef87bb036e6d9a7bf2a873384 100644 (file)
@@ -1,15 +1,9 @@
 /** @file\r
   GCC inline implementation of BaseLib processor specific functions.\r
-  \r
-  Copyright (c) 2006 - 2010, Intel Corporation<BR>\r
-  Portions copyright (c) 2008-2009 Apple Inc. All rights reserved.<BR> \r
-  All rights reserved. This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
 \r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -33,8 +27,8 @@ MemoryFence (
   )\r
 {\r
   // This is a little bit of overkill and it is more about the compiler that it is\r
-  // actually processor syncronization. This is like the _ReadWriteBarrier \r
-  // Microsft specific intrinsic\r
+  // actually processor synchronization. This is like the _ReadWriteBarrier\r
+  // Microsoft specific intrinsic\r
   __asm__ __volatile__ ("":::"memory");\r
 }\r
 \r
@@ -66,7 +60,7 @@ EFIAPI
 DisableInterrupts (\r
   VOID\r
   )\r
-{  \r
+{\r
   __asm__ __volatile__ ("cli"::: "memory");\r
 }\r
 \r
@@ -130,14 +124,14 @@ AsmReadMsr64 (
 {\r
   UINT32 LowData;\r
   UINT32 HighData;\r
-  \r
+\r
   __asm__ __volatile__ (\r
     "rdmsr"\r
     : "=a" (LowData),   // %0\r
       "=d" (HighData)   // %1\r
     : "c"  (Index)      // %2\r
     );\r
-    \r
+\r
   return (((UINT64)HighData) << 32) | LowData;\r
 }\r
 \r
@@ -170,7 +164,7 @@ AsmWriteMsr64 (
 \r
   LowData  = (UINT32)(Value);\r
   HighData = (UINT32)(Value >> 32);\r
-  \r
+\r
   __asm__ __volatile__ (\r
     "wrmsr"\r
     :\r
@@ -178,7 +172,7 @@ AsmWriteMsr64 (
       "a" (LowData),\r
       "d" (HighData)\r
     );\r
-    \r
+\r
   return Value;\r
 }\r
 \r
@@ -201,13 +195,13 @@ AsmReadEflags (
   )\r
 {\r
   UINTN Eflags;\r
-  \r
+\r
   __asm__ __volatile__ (\r
     "pushfq         \n\t"\r
     "pop     %0         "\r
     : "=r" (Eflags)       // %0\r
     );\r
-    \r
+\r
   return Eflags;\r
 }\r
 \r
@@ -230,12 +224,12 @@ AsmReadCr0 (
   )\r
 {\r
   UINTN   Data;\r
-  \r
+\r
   __asm__ __volatile__ (\r
-    "mov  %%cr0,%0" \r
+    "mov  %%cr0,%0"\r
     : "=r" (Data)           // %0\r
     );\r
-  \r
+\r
   return Data;\r
 }\r
 \r
@@ -257,12 +251,12 @@ AsmReadCr2 (
   )\r
 {\r
   UINTN Data;\r
-  \r
+\r
   __asm__ __volatile__ (\r
-    "mov  %%cr2,  %0" \r
+    "mov  %%cr2,  %0"\r
     : "=r" (Data)           // %0\r
     );\r
-  \r
+\r
   return Data;\r
 }\r
 \r
@@ -283,12 +277,12 @@ AsmReadCr3 (
   )\r
 {\r
   UINTN Data;\r
-  \r
+\r
   __asm__ __volatile__ (\r
-    "mov  %%cr3,  %0" \r
+    "mov  %%cr3,  %0"\r
     : "=r" (Data)           // %0\r
     );\r
-  \r
+\r
   return Data;\r
 }\r
 \r
@@ -310,12 +304,12 @@ AsmReadCr4 (
   )\r
 {\r
   UINTN Data;\r
-  \r
+\r
   __asm__ __volatile__ (\r
-    "mov  %%cr4,  %0" \r
+    "mov  %%cr4,  %0"\r
     : "=r" (Data)           // %0\r
     );\r
-  \r
+\r
   return Data;\r
 }\r
 \r
@@ -441,12 +435,12 @@ AsmReadDr0 (
   )\r
 {\r
   UINTN Data;\r
-  \r
+\r
   __asm__ __volatile__ (\r
     "mov  %%dr0, %0"\r
     : "=r" (Data)\r
     );\r
-  \r
+\r
   return Data;\r
 }\r
 \r
@@ -468,12 +462,12 @@ AsmReadDr1 (
   )\r
 {\r
   UINTN Data;\r
-  \r
+\r
   __asm__ __volatile__ (\r
     "mov  %%dr1, %0"\r
     : "=r" (Data)\r
     );\r
-  \r
+\r
   return Data;\r
 }\r
 \r
@@ -495,12 +489,12 @@ AsmReadDr2 (
   )\r
 {\r
   UINTN Data;\r
-  \r
+\r
   __asm__ __volatile__ (\r
     "mov  %%dr2, %0"\r
     : "=r" (Data)\r
     );\r
-  \r
+\r
   return Data;\r
 }\r
 \r
@@ -522,12 +516,12 @@ AsmReadDr3 (
   )\r
 {\r
   UINTN Data;\r
-  \r
+\r
   __asm__ __volatile__ (\r
     "mov  %%dr3, %0"\r
     : "=r" (Data)\r
     );\r
-  \r
+\r
   return Data;\r
 }\r
 \r
@@ -549,12 +543,12 @@ AsmReadDr4 (
   )\r
 {\r
   UINTN Data;\r
-  \r
+\r
   __asm__ __volatile__ (\r
     "mov  %%dr4, %0"\r
     : "=r" (Data)\r
     );\r
-  \r
+\r
   return Data;\r
 }\r
 \r
@@ -576,12 +570,12 @@ AsmReadDr5 (
   )\r
 {\r
   UINTN Data;\r
-  \r
+\r
   __asm__ __volatile__ (\r
     "mov  %%dr5, %0"\r
     : "=r" (Data)\r
     );\r
-  \r
+\r
   return Data;\r
 }\r
 \r
@@ -603,12 +597,12 @@ AsmReadDr6 (
   )\r
 {\r
   UINTN Data;\r
-  \r
+\r
   __asm__ __volatile__ (\r
     "mov  %%dr6, %0"\r
     : "=r" (Data)\r
     );\r
-  \r
+\r
   return Data;\r
 }\r
 \r
@@ -630,12 +624,12 @@ AsmReadDr7 (
   )\r
 {\r
   UINTN Data;\r
-  \r
+\r
   __asm__ __volatile__ (\r
     "mov  %%dr7, %0"\r
     : "=r" (Data)\r
     );\r
-  \r
+\r
   return Data;\r
 }\r
 \r
@@ -864,12 +858,12 @@ AsmReadCs (
   )\r
 {\r
   UINT16  Data;\r
-  \r
+\r
   __asm__ __volatile__ (\r
     "mov   %%cs, %0"\r
     :"=a" (Data)\r
     );\r
-    \r
+\r
   return Data;\r
 }\r
 \r
@@ -890,12 +884,12 @@ AsmReadDs (
   )\r
 {\r
   UINT16  Data;\r
-  \r
+\r
   __asm__ __volatile__ (\r
     "mov  %%ds, %0"\r
     :"=a" (Data)\r
     );\r
-    \r
+\r
   return Data;\r
 }\r
 \r
@@ -916,12 +910,12 @@ AsmReadEs (
   )\r
 {\r
   UINT16  Data;\r
-  \r
+\r
   __asm__ __volatile__ (\r
     "mov  %%es, %0"\r
     :"=a" (Data)\r
     );\r
-    \r
+\r
   return Data;\r
 }\r
 \r
@@ -942,12 +936,12 @@ AsmReadFs (
   )\r
 {\r
   UINT16  Data;\r
-  \r
+\r
   __asm__ __volatile__ (\r
     "mov  %%fs, %0"\r
     :"=a" (Data)\r
     );\r
-    \r
+\r
   return Data;\r
 }\r
 \r
@@ -968,12 +962,12 @@ AsmReadGs (
   )\r
 {\r
   UINT16  Data;\r
-  \r
+\r
   __asm__ __volatile__ (\r
     "mov  %%gs, %0"\r
     :"=a" (Data)\r
     );\r
-    \r
+\r
   return Data;\r
 }\r
 \r
@@ -994,12 +988,12 @@ AsmReadSs (
   )\r
 {\r
   UINT16  Data;\r
-  \r
+\r
   __asm__ __volatile__ (\r
     "mov  %%ds, %0"\r
     :"=a" (Data)\r
     );\r
-    \r
+\r
   return Data;\r
 }\r
 \r
@@ -1020,12 +1014,12 @@ AsmReadTr (
   )\r
 {\r
   UINT16  Data;\r
-  \r
+\r
   __asm__ __volatile__ (\r
     "str  %0"\r
     : "=r" (Data)\r
     );\r
-    \r
+\r
   return Data;\r
 }\r
 \r
@@ -1036,7 +1030,7 @@ AsmReadTr (
   Reads and returns the current GDTR descriptor and returns it in Gdtr. This\r
   function is only available on IA-32 and X64.\r
 \r
-  @param  Gdtr  Pointer to a GDTR descriptor.\r
+  @param  Gdtr  The pointer to a GDTR descriptor.\r
 \r
 **/\r
 VOID\r
@@ -1058,7 +1052,7 @@ InternalX86ReadGdtr (
   Writes and the current GDTR descriptor specified by Gdtr. This function is\r
   only available on IA-32 and X64.\r
 \r
-  @param  Gdtr  Pointer to a GDTR descriptor.\r
+  @param  Gdtr  The pointer to a GDTR descriptor.\r
 \r
 **/\r
 VOID\r
@@ -1072,7 +1066,7 @@ InternalX86WriteGdtr (
     :\r
     : "m" (*Gdtr)\r
     );\r
-    \r
+\r
 }\r
 \r
 \r
@@ -1082,7 +1076,7 @@ InternalX86WriteGdtr (
   Reads and returns the current IDTR descriptor and returns it in Idtr. This\r
   function is only available on IA-32 and X64.\r
 \r
-  @param  Idtr  Pointer to a IDTR descriptor.\r
+  @param  Idtr  The pointer to a IDTR descriptor.\r
 \r
 **/\r
 VOID\r
@@ -1092,7 +1086,7 @@ InternalX86ReadIdtr (
   )\r
 {\r
   __asm__ __volatile__ (\r
-    "sldt  %0"\r
+    "sidt  %0"\r
     : "=m" (*Idtr)\r
     );\r
 }\r
@@ -1104,7 +1098,7 @@ InternalX86ReadIdtr (
   Writes the current IDTR descriptor and returns it in Idtr. This function is\r
   only available on IA-32 and X64.\r
 \r
-  @param  Idtr  Pointer to a IDTR descriptor.\r
+  @param  Idtr  The pointer to a IDTR descriptor.\r
 \r
 **/\r
 VOID\r
@@ -1137,12 +1131,12 @@ AsmReadLdtr (
   )\r
 {\r
   UINT16  Data;\r
-  \r
+\r
   __asm__ __volatile__ (\r
     "sldt  %0"\r
     : "=g" (Data)   // %0\r
     );\r
-    \r
+\r
   return Data;\r
 }\r
 \r
@@ -1177,7 +1171,7 @@ AsmWriteLdtr (
   Buffer. Buffer must be aligned on a 16-byte boundary. This function is only\r
   available on IA-32 and X64.\r
 \r
-  @param  Buffer  Pointer to a buffer to save the floating point/SSE/SSE2 context.\r
+  @param  Buffer  The pointer to a buffer to save the floating point/SSE/SSE2 context.\r
 \r
 **/\r
 VOID\r
@@ -1190,7 +1184,7 @@ InternalX86FxSave (
     "fxsave %0"\r
     :\r
     : "m" (*Buffer)  // %0\r
-    );    \r
+    );\r
 }\r
 \r
 \r
@@ -1201,7 +1195,7 @@ InternalX86FxSave (
   by Buffer. Buffer must be aligned on a 16-byte boundary. This function is\r
   only available on IA-32 and X64.\r
 \r
-  @param  Buffer  Pointer to a buffer to save the floating point/SSE/SSE2 context.\r
+  @param  Buffer  The pointer to a buffer to save the floating point/SSE/SSE2 context.\r
 \r
 **/\r
 VOID\r
@@ -1239,7 +1233,7 @@ AsmReadMm0 (
     "movd   %%mm0,  %0    \n\t"\r
     : "=r"  (Data)       // %0\r
     );\r
-    \r
+\r
   return Data;\r
 }\r
 \r
@@ -1265,7 +1259,7 @@ AsmReadMm1 (
     "movd   %%mm1,  %0    \n\t"\r
     : "=r"  (Data)       // %0\r
     );\r
-    \r
+\r
   return Data;\r
 }\r
 \r
@@ -1291,7 +1285,7 @@ AsmReadMm2 (
     "movd  %%mm2,  %0    \n\t"\r
     : "=r"  (Data)       // %0\r
     );\r
-    \r
+\r
   return Data;\r
 }\r
 \r
@@ -1317,7 +1311,7 @@ AsmReadMm3 (
     "movd  %%mm3,  %0    \n\t"\r
     : "=r"  (Data)       // %0\r
     );\r
-    \r
+\r
   return Data;\r
 }\r
 \r
@@ -1343,7 +1337,7 @@ AsmReadMm4 (
     "movd  %%mm4,  %0    \n\t"\r
     : "=r"  (Data)       // %0\r
     );\r
-    \r
+\r
   return Data;\r
 }\r
 \r
@@ -1369,7 +1363,7 @@ AsmReadMm5 (
     "movd  %%mm5,  %0    \n\t"\r
     : "=r"  (Data)       // %0\r
     );\r
-    \r
+\r
   return Data;\r
 }\r
 \r
@@ -1395,7 +1389,7 @@ AsmReadMm6 (
     "movd  %%mm6,  %0    \n\t"\r
     : "=r"  (Data)       // %0\r
     );\r
-    \r
+\r
   return Data;\r
 }\r
 \r
@@ -1421,7 +1415,7 @@ AsmReadMm7 (
     "movd  %%mm7,  %0    \n\t"\r
     : "=r"  (Data)       // %0\r
     );\r
-    \r
+\r
   return Data;\r
 }\r
 \r
@@ -1443,7 +1437,7 @@ AsmWriteMm0 (
 {\r
   __asm__ __volatile__ (\r
     "movd  %0, %%mm0"  // %0\r
-    :  \r
+    :\r
     : "m" (Value)\r
     );\r
 }\r
@@ -1466,7 +1460,7 @@ AsmWriteMm1 (
 {\r
   __asm__ __volatile__ (\r
     "movd  %0, %%mm1"  // %0\r
-    :  \r
+    :\r
     : "m" (Value)\r
     );\r
 }\r
@@ -1489,7 +1483,7 @@ AsmWriteMm2 (
 {\r
   __asm__ __volatile__ (\r
     "movd  %0, %%mm2"  // %0\r
-    :  \r
+    :\r
     : "m" (Value)\r
     );\r
 }\r
@@ -1512,7 +1506,7 @@ AsmWriteMm3 (
 {\r
   __asm__ __volatile__ (\r
     "movd  %0, %%mm3"  // %0\r
-    :  \r
+    :\r
     : "m" (Value)\r
     );\r
 }\r
@@ -1535,7 +1529,7 @@ AsmWriteMm4 (
 {\r
   __asm__ __volatile__ (\r
     "movd  %0, %%mm4"  // %0\r
-    :  \r
+    :\r
     : "m" (Value)\r
     );\r
 }\r
@@ -1558,7 +1552,7 @@ AsmWriteMm5 (
 {\r
   __asm__ __volatile__ (\r
     "movd  %0, %%mm5"  // %0\r
-    :  \r
+    :\r
     : "m" (Value)\r
     );\r
 }\r
@@ -1581,7 +1575,7 @@ AsmWriteMm6 (
 {\r
   __asm__ __volatile__ (\r
     "movd  %0, %%mm6"  // %0\r
-    :  \r
+    :\r
     : "m" (Value)\r
     );\r
 }\r
@@ -1604,7 +1598,7 @@ AsmWriteMm7 (
 {\r
   __asm__ __volatile__ (\r
     "movd  %0, %%mm7"  // %0\r
-    :  \r
+    :\r
     : "m" (Value)\r
     );\r
 }\r
@@ -1627,14 +1621,14 @@ AsmReadTsc (
 {\r
   UINT32  LowData;\r
   UINT32  HiData;\r
-  \r
+\r
   __asm__ __volatile__ (\r
     "rdtsc"\r
     : "=a" (LowData),\r
       "=d" (HiData)\r
     );\r
-  \r
-  return (((UINT64)HiData) << 32) | LowData;  \r
+\r
+  return (((UINT64)HiData) << 32) | LowData;\r
 }\r
 \r
 \r
@@ -1657,15 +1651,15 @@ AsmReadPmc (
 {\r
   UINT32  LowData;\r
   UINT32  HiData;\r
-  \r
+\r
   __asm__ __volatile__ (\r
     "rdpmc"\r
     : "=a" (LowData),\r
       "=d" (HiData)\r
     : "c"  (Index)\r
     );\r
-  \r
-  return (((UINT64)HiData) << 32) | LowData;  \r
+\r
+  return (((UINT64)HiData) << 32) | LowData;\r
 }\r
 \r
 \r
@@ -1700,7 +1694,7 @@ AsmMonitor (
       "c" (Ecx),\r
       "d" (Edx)\r
     );\r
-    \r
+\r
   return Eax;\r
 }\r
 \r
@@ -1728,12 +1722,12 @@ AsmMwait (
 {\r
   __asm__ __volatile__ (\r
     "mwait"\r
-    : \r
+    :\r
     : "a"  (Eax),\r
       "c"  (Ecx)\r
     );\r
-    \r
-  return Eax;    \r
+\r
+  return Eax;\r
 }\r
 \r
 \r
@@ -1768,7 +1762,7 @@ AsmInvd (
   )\r
 {\r
   __asm__ __volatile__ ("invd":::"memory");\r
-    \r
+\r
 }\r
 \r
 \r
@@ -1796,10 +1790,10 @@ AsmFlushCacheLine (
   __asm__ __volatile__ (\r
     "clflush (%0)"\r
     :\r
-    : "r" (LinearAddress) \r
+    : "r" (LinearAddress)\r
     : "memory"\r
     );\r
-    \r
+\r
     return LinearAddress;\r
 }\r
 \r