TianoCore EDK2 master
Loading...
Searching...
No Matches
DebugSupport.c
Go to the documentation of this file.
1
9#include "PlDebugSupport.h"
10
11EFI_DEBUG_SUPPORT_PROTOCOL mDebugSupportProtocolInterface = {
12 EFI_ISA,
17};
18
34EFIAPI
36 IN EFI_HANDLE ImageHandle,
37 IN EFI_SYSTEM_TABLE *SystemTable
38 )
39{
40 EFI_LOADED_IMAGE_PROTOCOL *LoadedImageProtocolPtr;
41 EFI_STATUS Status;
42 EFI_HANDLE Handle;
43 EFI_HANDLE *HandlePtr;
44 UINTN NumHandles;
45 EFI_DEBUG_SUPPORT_PROTOCOL *DebugSupportProtocolPtr;
46
47 //
48 // First check to see that the debug support protocol for this processor
49 // type is not already installed
50 //
51 Status = gBS->LocateHandleBuffer (
53 &gEfiDebugSupportProtocolGuid,
54 NULL,
55 &NumHandles,
56 &HandlePtr
57 );
58
59 if (Status != EFI_NOT_FOUND) {
60 do {
61 NumHandles--;
62 Status = gBS->OpenProtocol (
63 HandlePtr[NumHandles],
64 &gEfiDebugSupportProtocolGuid,
65 (VOID **)&DebugSupportProtocolPtr,
66 ImageHandle,
67 NULL,
68 EFI_OPEN_PROTOCOL_GET_PROTOCOL
69 );
70 if ((Status == EFI_SUCCESS) && (DebugSupportProtocolPtr->Isa == EFI_ISA)) {
71 //
72 // a Debug Support protocol has been installed for this processor
73 //
74 FreePool (HandlePtr);
75 Status = EFI_ALREADY_STARTED;
76 goto ErrExit;
77 }
78 } while (NumHandles > 0);
79
80 FreePool (HandlePtr);
81 }
82
83 //
84 // Get our image information and install platform specific unload handler
85 //
86 Status = gBS->OpenProtocol (
87 ImageHandle,
88 &gEfiLoadedImageProtocolGuid,
89 (VOID **)&LoadedImageProtocolPtr,
90 ImageHandle,
91 NULL,
92 EFI_OPEN_PROTOCOL_GET_PROTOCOL
93 );
94 ASSERT (!EFI_ERROR (Status));
95 if (Status != EFI_SUCCESS) {
96 goto ErrExit;
97 }
98
99 LoadedImageProtocolPtr->Unload = PlUnloadDebugSupportDriver;
100
101 //
102 // Call hook for processor specific initialization
103 //
105 ASSERT (!EFI_ERROR (Status));
106 if (Status != EFI_SUCCESS) {
107 goto ErrExit;
108 }
109
110 //
111 // Install Debug Support protocol to new handle
112 //
113 Handle = NULL;
114 Status = gBS->InstallProtocolInterface (
115 &Handle,
116 &gEfiDebugSupportProtocolGuid,
118 &mDebugSupportProtocolInterface
119 );
120 ASSERT (!EFI_ERROR (Status));
121 if (Status != EFI_SUCCESS) {
122 goto ErrExit;
123 }
124
125ErrExit:
126 return Status;
127}
UINT64 UINTN
VOID EFIAPI InvalidateInstructionCache(VOID)
EFI_STATUS EFIAPI InitializeDebugSupportDriver(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: DebugSupport.c:35
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS EFIAPI RegisterExceptionCallback(IN EFI_DEBUG_SUPPORT_PROTOCOL *This, IN UINTN ProcessorIndex, IN EFI_EXCEPTION_CALLBACK ExceptionCallback, IN EFI_EXCEPTION_TYPE ExceptionType)
EFI_STATUS PlInitializeDebugSupportDriver(VOID)
EFI_STATUS EFIAPI GetMaximumProcessorIndex(IN EFI_DEBUG_SUPPORT_PROTOCOL *This, OUT UINTN *MaxProcessorIndex)
EFI_STATUS EFIAPI PlUnloadDebugSupportDriver(IN EFI_HANDLE ImageHandle)
EFI_STATUS EFIAPI RegisterPeriodicCallback(IN EFI_DEBUG_SUPPORT_PROTOCOL *This, IN UINTN ProcessorIndex, IN EFI_PERIODIC_CALLBACK PeriodicCallback)
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
@ EFI_NATIVE_INTERFACE
Definition: UefiSpec.h:1193
@ ByProtocol
Definition: UefiSpec.h:1518