]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkModulePkg/Universal/DebugSupport/Dxe/Ia32/plDebugSupport.c
1. Added PcdNtEmulator and Removed MACRO EFI_NT_EMULATOR
[mirror_edk2.git] / EdkModulePkg / Universal / DebugSupport / Dxe / Ia32 / plDebugSupport.c
index 2198192a0402cd0de8086b78b0312ca83bb8efcd..88b8c5a14acaae74879afaa7074057ff5c564b4f 100644 (file)
@@ -1,25 +1,16 @@
-/*++\r
-\r
-Copyright (c) 2006, Intel Corporation                                                         \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
-\r
-Module Name:\r
-\r
-    plDebugSupport.c\r
-\r
-Abstract:\r
+/**@file\r
+  IA32 specific debug support functions\r
 \r
-    IA32 specific debug support functions\r
+Copyright (c) 2006 - 2007, Intel Corporation\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
-Revision History\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
---*/\r
+**/\r
 \r
 //\r
 // private header files\r
@@ -32,7 +23,6 @@ Revision History
 IDT_ENTRY   *IdtEntryTable  = NULL;\r
 DESCRIPTOR  NullDesc        = 0;\r
 \r
-#ifndef EFI_NT_EMULATOR\r
 STATIC\r
 EFI_STATUS\r
 CreateEntryStub (\r
@@ -54,16 +44,15 @@ Returns:
 \r
 --*/\r
 {\r
-  EFI_STATUS  Status;\r
   UINT8       *StubCopy;\r
 \r
   //\r
   // First, allocate a new buffer and copy the stub code into it\r
   //\r
-  Status = gBS->AllocatePool (EfiBootServicesData, StubSize, Stub);\r
-  if (Status == EFI_SUCCESS) {\r
+  *Stub = AllocatePool (StubSize);\r
+  if (*Stub != NULL) {\r
     StubCopy = *Stub;\r
-    gBS->CopyMem (StubCopy, InterruptEntryStub, StubSize);\r
+    CopyMem (StubCopy, InterruptEntryStub, StubSize);\r
 \r
     //\r
     // Next fixup the stub code for this vector\r
@@ -87,9 +76,11 @@ Returns:
     // fixup the jump target to point to the common entry\r
     //\r
     *(UINT32 *) &StubCopy[0x0e] = (UINT32) CommonIdtEntry - (UINT32) &StubCopy[StubSize];\r
+\r
+    return EFI_SUCCESS;\r
   }\r
 \r
-  return Status;\r
+  return EFI_OUT_OF_RESOURCES;\r
 }\r
 \r
 STATIC\r
@@ -117,7 +108,6 @@ Returns:
   Other possibilities are passed through by CreateEntryStub\r
 \r
 --*/\r
-// TODO:    ) - add argument and description to function comment\r
 {\r
   BOOLEAN     OldIntFlagState;\r
   EFI_STATUS  Status;\r
@@ -154,22 +144,19 @@ Arguments:
 \r
 Returns:\r
   EFI_SUCCESS\r
-  Other values are passed through from FreePool\r
 \r
 --*/\r
 {\r
   BOOLEAN     OldIntFlagState;\r
-  EFI_STATUS  Status;\r
 \r
   OldIntFlagState = WriteInterruptFlag (0);\r
   WriteIdt (ExceptionType, &(IdtEntryTable[ExceptionType].OrigDesc));\r
-  Status = gBS->FreePool ((VOID *) (UINTN) IdtEntryTable[ExceptionType].StubEntry);\r
+  FreePool ((VOID *) (UINTN) IdtEntryTable[ExceptionType].StubEntry);\r
   ZeroMem (&IdtEntryTable[ExceptionType], sizeof (IDT_ENTRY));\r
   WriteInterruptFlag (OldIntFlagState);\r
 \r
-  return (Status);\r
+  return EFI_SUCCESS;\r
 }\r
-#endif\r
 \r
 EFI_STATUS\r
 ManageIdtEntryTable (\r
@@ -199,39 +186,39 @@ Returns:
   Other possible return values are passed through from UnHookEntry and HookEntry.\r
 \r
 --*/\r
-// TODO:    ) - add argument and description to function comment\r
 {\r
   EFI_STATUS  Status;\r
 \r
   Status = EFI_SUCCESS;\r
 \r
-#ifndef EFI_NT_EMULATOR\r
-  if (CompareDescriptor (&IdtEntryTable[ExceptionType].NewDesc, &NullDesc)) {\r
-    //\r
-    // we've already installed to this vector\r
-    //\r
-    if (NewCallback != NULL) {\r
+  if (FeaturePcdGet (PcdNtEmulatorEnable)) {\r
+    if (CompareDescriptor (&IdtEntryTable[ExceptionType].NewDesc, &NullDesc)) {\r
       //\r
-      // if the input handler is non-null, error\r
+      // we've already installed to this vector\r
       //\r
-      Status = EFI_ALREADY_STARTED;\r
+      if (NewCallback != NULL) {\r
+        //\r
+        // if the input handler is non-null, error\r
+        //\r
+        Status = EFI_ALREADY_STARTED;\r
+      } else {\r
+        Status = UnhookEntry (ExceptionType);\r
+      }\r
     } else {\r
-      Status = UnhookEntry (ExceptionType);\r
-    }\r
-  } else {\r
-    //\r
-    // no user handler installed on this vector\r
-    //\r
-    if (NewCallback == NULL) {\r
       //\r
-      // if the input handler is null, error\r
+      // no user handler installed on this vector\r
       //\r
-      Status = EFI_INVALID_PARAMETER;\r
-    } else {\r
-      Status = HookEntry (ExceptionType, NewCallback);\r
+      if (NewCallback == NULL) {\r
+        //\r
+        // if the input handler is null, error\r
+        //\r
+        Status = EFI_INVALID_PARAMETER;\r
+      } else {\r
+        Status = HookEntry (ExceptionType, NewCallback);\r
+      }\r
     }\r
   }\r
-#endif\r
+\r
   return Status;\r
 }\r
 \r
@@ -246,12 +233,13 @@ GetMaximumProcessorIndex (
 Routine Description: This is a DebugSupport protocol member function.\r
 \r
 Arguments:\r
+  This              - The DebugSupport instance\r
+  MaxProcessorIndex - The maximuim supported processor index\r
 \r
-Returns: Always returns EFI_SUCCESS with *MaxProcessorIndex set to 0\r
+Returns:\r
+  Always returns EFI_SUCCESS with *MaxProcessorIndex set to 0\r
 \r
 --*/\r
-// TODO:    This - add argument and description to function comment\r
-// TODO:    MaxProcessorIndex - add argument and description to function comment\r
 {\r
   *MaxProcessorIndex = 0;\r
   return (EFI_SUCCESS);\r
@@ -269,13 +257,20 @@ RegisterPeriodicCallback (
 Routine Description: This is a DebugSupport protocol member function.\r
 \r
 Arguments:\r
+  This             - The DebugSupport instance\r
+  ProcessorIndex   - Which processor the callback applies to.\r
+  PeriodicCallback - Callback function\r
 \r
 Returns:\r
 \r
+  EFI_SUCCESS\r
+  EFI_INVALID_PARAMETER - requested uninstalling a handler from a vector that has\r
+                          no handler registered for it\r
+  EFI_ALREADY_STARTED   - requested install to a vector that already has a handler registered.\r
+\r
+  Other possible return values are passed through from UnHookEntry and HookEntry.\r
+\r
 --*/\r
-// TODO:    This - add argument and description to function comment\r
-// TODO:    ProcessorIndex - add argument and description to function comment\r
-// TODO:    PeriodicCallback - add argument and description to function comment\r
 {\r
   return ManageIdtEntryTable (PeriodicCallback, SYSTEM_TIMER_VECTOR);\r
 }\r
@@ -296,16 +291,21 @@ Routine Description:
   This code executes in boot services context.\r
 \r
 Arguments:\r
+  This             - The DebugSupport instance\r
+  ProcessorIndex   - Which processor the callback applies to.\r
+  NewCallback      - Callback function\r
+  ExceptionType    - Which exception to hook\r
 \r
 Returns:\r
 \r
-  None\r
+  EFI_SUCCESS\r
+  EFI_INVALID_PARAMETER - requested uninstalling a handler from a vector that has\r
+                          no handler registered for it\r
+  EFI_ALREADY_STARTED   - requested install to a vector that already has a handler registered.\r
+\r
+  Other possible return values are passed through from UnHookEntry and HookEntry.\r
 \r
 --*/\r
-// TODO:    This - add argument and description to function comment\r
-// TODO:    ProcessorIndex - add argument and description to function comment\r
-// TODO:    NewCallback - add argument and description to function comment\r
-// TODO:    ExceptionType - add argument and description to function comment\r
 {\r
   return ManageIdtEntryTable (NewCallback, ExceptionType);\r
 }\r
@@ -322,21 +322,21 @@ InvalidateInstructionCache (
 \r
 Routine Description:\r
   This is a DebugSupport protocol member function.\r
-  For IA32, this is a no-op since the instruction and data caches are coherent.\r
+  Calls assembly routine to flush cache.\r
 \r
 Arguments:\r
+  This             - The DebugSupport instance\r
+  ProcessorIndex   - Which processor the callback applies to.\r
+  Start            - Physical base of the memory range to be invalidated\r
+  Length           - mininum number of bytes in instruction cache to invalidate\r
 \r
 Returns:\r
 \r
-  None\r
+  EFI_SUCCESS - always return success\r
 \r
 --*/\r
-// TODO:    This - add argument and description to function comment\r
-// TODO:    ProcessorIndex - add argument and description to function comment\r
-// TODO:    Start - add argument and description to function comment\r
-// TODO:    Length - add argument and description to function comment\r
-// TODO:    EFI_SUCCESS - add return value to function comment\r
 {\r
+  AsmWbinvd ();\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -358,9 +358,9 @@ Returns:
   EFI_SUCCESS\r
   EFI_UNSUPPORTED - if IA32 processor does not support FXSTOR/FXRSTOR instructions,\r
                     the context save will fail, so these processor's are not supported.\r
+  EFI_OUT_OF_RESOURCES - not resource to finish initialization\r
 \r
 --*/\r
-// TODO:    EFI_OUT_OF_RESOURCES - add return value to function comment\r
 {\r
   if (!FxStorSupport ()) {\r
     return EFI_UNSUPPORTED;\r
@@ -393,10 +393,9 @@ Arguments:
 \r
 Returns:\r
 \r
-  None\r
+  EFI_SUCCESS - always return success\r
 \r
 --*/\r
-// TODO:    EFI_SUCCESS - add return value to function comment\r
 {\r
   EFI_EXCEPTION_TYPE  ExceptionType;\r
 \r
@@ -404,7 +403,7 @@ Returns:
     ManageIdtEntryTable (NULL, ExceptionType);\r
   }\r
 \r
-  gBS->FreePool (IdtEntryTable);\r
+  FreePool (IdtEntryTable);\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -420,14 +419,14 @@ Routine Description: Common piece of code that invokes the registered handlers.
   This code executes in exception context so no efi calls are allowed.\r
 \r
 Arguments:\r
+  ExceptionType - exception type\r
+  ContextRecord - system context\r
 \r
 Returns:\r
 \r
   None\r
 \r
 --*/\r
-// TODO:    ExceptionType - add argument and description to function comment\r
-// TODO:    ContextRecord - add argument and description to function comment\r
 {\r
   if (IdtEntryTable[ExceptionType].RegisteredCallback != NULL) {\r
     if (ExceptionType != SYSTEM_TIMER_VECTOR) {\r