]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseLib/X86Thunk.c
MdePkg/BaseLib: Support IA32 processors without CLFLUSH
[mirror_edk2.git] / MdePkg / Library / BaseLib / X86Thunk.c
index 72c918756d3e645d1d38167a5f53ab64ec911931..dac1d19374f565f56d03c0486b8bf4c8acd09913 100644 (file)
@@ -1,11 +1,11 @@
 /** @file\r
   Real Mode Thunk Functions for IA32 and x64.\r
 \r
-  Copyright (c) 2006 - 2008, Intel Corporation<BR>\r
-  All rights reserved. This program and the accompanying materials\r
+  Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  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
+  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
 \r
 #include "BaseLibInternals.h"\r
 \r
-\r
-//\r
-// Byte packed structure for a segment descriptor in a GDT/LDT\r
-//\r
-typedef union {\r
-  struct {\r
-    UINT32  LimitLow:16;\r
-    UINT32  BaseLow:16;\r
-    UINT32  BaseMid:8;\r
-    UINT32  Type:4;\r
-    UINT32  S:1;\r
-    UINT32  DPL:2;\r
-    UINT32  P:1;\r
-    UINT32  LimitHigh:4;\r
-    UINT32  AVL:1;\r
-    UINT32  L:1;\r
-    UINT32  DB:1;\r
-    UINT32  G:1;\r
-    UINT32  BaseHigh:8;\r
-  } Bits;\r
-  UINT64  Uint64;\r
-} IA32_SEGMENT_DESCRIPTOR;\r
-\r
 extern CONST UINT8                  m16Start;\r
 extern CONST UINT16                 m16Size;\r
 extern CONST UINT16                 mThunk16Attr;\r
@@ -53,7 +30,7 @@ extern CONST UINT16                 mTransition;
   on the real mode stack and the starting address of the save area is returned.\r
 \r
   @param  RegisterSet Values of registers before invocation of 16-bit code.\r
-  @param  Transition  Pointer to the transition code under 1MB.\r
+  @param  Transition  The pointer to the transition code under 1MB.\r
 \r
   @return The pointer to a IA32_REGISTER_SET structure containing the updated\r
           register values.\r
@@ -110,8 +87,8 @@ AsmGetThunk16Properties (
 \r
   Prepares all structures and code required to use AsmThunk16().\r
   \r
-  This interface is limited to be used in physical mode but can not be used in \r
-  virtual mode with paging.\r
+  This interface is limited to be used in either physical mode or virtual modes with paging enabled where the\r
+  virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.\r
 \r
   If ThunkContext is NULL, then ASSERT().\r
 \r
@@ -122,7 +99,7 @@ AsmGetThunk16Properties (
 VOID\r
 EFIAPI\r
 AsmPrepareThunk16 (\r
-  OUT     THUNK_CONTEXT             *ThunkContext\r
+  IN OUT  THUNK_CONTEXT             *ThunkContext\r
   )\r
 {\r
   IA32_SEGMENT_DESCRIPTOR           *RealModeGdt;\r
@@ -230,8 +207,8 @@ AsmPrepareThunk16 (
   If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in \r
   ThunkAttributes, then ASSERT().\r
 \r
-  This interface is limited to be used in physical mode but can not be used in \r
-  virtual mode with paging.\r
+  This interface is limited to be used in either physical mode or virtual modes with paging enabled where the\r
+  virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.\r
   \r
   @param  ThunkContext  A pointer to the context structure that describes the\r
                         16-bit real mode code to call.\r
@@ -249,7 +226,9 @@ AsmThunk16 (
   ASSERT ((UINTN)ThunkContext->RealModeBuffer < 0x100000);\r
   ASSERT (ThunkContext->RealModeBufferSize >= m16Size);\r
   ASSERT ((UINTN)ThunkContext->RealModeBuffer + m16Size <= 0x100000);\r
-\r
+  ASSERT (((ThunkContext->ThunkAttributes & (THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 | THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL)) != \\r
+           (THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 | THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL)));\r
+           \r
   UpdatedRegs = InternalAsmThunk16 (\r
                   ThunkContext->RealModeState,\r
                   ThunkContext->RealModeBuffer\r
@@ -269,8 +248,8 @@ AsmThunk16 (
   real mode thunk, then it is more efficient if AsmPrepareThunk16() is called\r
   once and AsmThunk16() can be called for each 16-bit real mode thunk.\r
 \r
-  This interface is limited to be used in physical mode but can not be used in \r
-  virtual mode with paging.\r
+  This interface is limited to be used in either physical mode or virtual modes with paging enabled where the\r
+  virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.\r
   \r
   See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.\r
 \r