EDK2 doxygen online documents - Firmware Encoding Index 1
EDK2 doxygen online documents - Firmware Encoding Index

MdeModulePkg/Universal/DebugSupportDxe/DebugSupport.c

Go to the documentation of this file.
00001 
00015 #include "PlDebugSupport.h"
00016 
00017 EFI_DEBUG_SUPPORT_PROTOCOL  mDebugSupportProtocolInterface = {
00018   EFI_ISA,
00019   GetMaximumProcessorIndex,
00020   RegisterPeriodicCallback,
00021   RegisterExceptionCallback,
00022   InvalidateInstructionCache
00023 };
00024 
00025 
00040 EFI_STATUS
00041 EFIAPI
00042 InitializeDebugSupportDriver (
00043   IN EFI_HANDLE               ImageHandle,
00044   IN EFI_SYSTEM_TABLE         *SystemTable
00045   )
00046 {
00047   EFI_LOADED_IMAGE_PROTOCOL   *LoadedImageProtocolPtr;
00048   EFI_STATUS                  Status;
00049   EFI_HANDLE                  Handle;
00050   EFI_HANDLE                  *HandlePtr;
00051   UINTN                       NumHandles;
00052   EFI_DEBUG_SUPPORT_PROTOCOL  *DebugSupportProtocolPtr;
00053 
00054   //
00055   // First check to see that the debug support protocol for this processor
00056   // type is not already installed
00057   //
00058   Status = gBS->LocateHandleBuffer (
00059                   ByProtocol,
00060                   &gEfiDebugSupportProtocolGuid,
00061                   NULL,
00062                   &NumHandles,
00063                   &HandlePtr
00064                   );
00065 
00066   if (Status != EFI_NOT_FOUND) {
00067     do {
00068       NumHandles--;
00069       Status = gBS->OpenProtocol (
00070                       HandlePtr[NumHandles],
00071                       &gEfiDebugSupportProtocolGuid,
00072                       (VOID **) &DebugSupportProtocolPtr,
00073                       ImageHandle,
00074                       NULL,
00075                       EFI_OPEN_PROTOCOL_GET_PROTOCOL
00076                       );
00077       if ((Status == EFI_SUCCESS) && (DebugSupportProtocolPtr->Isa == EFI_ISA)) {
00078         //
00079         // a Debug Support protocol has been installed for this processor
00080         //
00081         FreePool (HandlePtr);
00082         Status = EFI_ALREADY_STARTED;
00083         goto ErrExit;
00084       }
00085     } while (NumHandles > 0);
00086     FreePool (HandlePtr);
00087   }
00088 
00089   //
00090   // Get our image information and install platform specific unload handler
00091   //
00092   Status = gBS->OpenProtocol (
00093                   ImageHandle,
00094                   &gEfiLoadedImageProtocolGuid,
00095                   (VOID **) &LoadedImageProtocolPtr,
00096                   ImageHandle,
00097                   NULL,
00098                   EFI_OPEN_PROTOCOL_GET_PROTOCOL
00099                   );
00100   ASSERT (!EFI_ERROR (Status));
00101   if (Status != EFI_SUCCESS) {
00102     goto ErrExit;
00103   }
00104 
00105   LoadedImageProtocolPtr->Unload = PlUnloadDebugSupportDriver;
00106 
00107   //
00108   // Call hook for processor specific initialization 
00109   //
00110   Status = PlInitializeDebugSupportDriver ();
00111   ASSERT (!EFI_ERROR (Status));
00112   if (Status != EFI_SUCCESS) {
00113     goto ErrExit;
00114   }
00115 
00116   //
00117   // Install Debug Support protocol to new handle
00118   //
00119   Handle = NULL;
00120   Status = gBS->InstallProtocolInterface (
00121                   &Handle,
00122                   &gEfiDebugSupportProtocolGuid,
00123                   EFI_NATIVE_INTERFACE,
00124                   &mDebugSupportProtocolInterface
00125                   );
00126   ASSERT (!EFI_ERROR (Status));
00127   if (Status != EFI_SUCCESS) {
00128     goto ErrExit;
00129   }
00130 
00131 ErrExit:
00132   return Status;
00133 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Defines