2 Top level C file for debug support driver. Contains initialization function.
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "PlDebugSupport.h"
11 EFI_DEBUG_SUPPORT_PROTOCOL mDebugSupportProtocolInterface
= {
13 GetMaximumProcessorIndex
,
14 RegisterPeriodicCallback
,
15 RegisterExceptionCallback
,
16 InvalidateInstructionCache
21 Debug Support Driver entry point.
23 Checks to see if there's not already a Debug Support protocol installed for
24 the selected processor before installing it.
26 @param[in] ImageHandle The firmware allocated handle for the EFI image.
27 @param[in] SystemTable A pointer to the EFI System Table.
29 @retval EFI_SUCCESS The entry point is executed successfully.
30 @retval EFI_ALREADY_STARTED Debug Support protocol is installed already.
31 @retval other Some error occurs when executing this entry point.
36 InitializeDebugSupportDriver (
37 IN EFI_HANDLE ImageHandle
,
38 IN EFI_SYSTEM_TABLE
*SystemTable
41 EFI_LOADED_IMAGE_PROTOCOL
*LoadedImageProtocolPtr
;
44 EFI_HANDLE
*HandlePtr
;
46 EFI_DEBUG_SUPPORT_PROTOCOL
*DebugSupportProtocolPtr
;
49 // First check to see that the debug support protocol for this processor
50 // type is not already installed
52 Status
= gBS
->LocateHandleBuffer (
54 &gEfiDebugSupportProtocolGuid
,
60 if (Status
!= EFI_NOT_FOUND
) {
63 Status
= gBS
->OpenProtocol (
64 HandlePtr
[NumHandles
],
65 &gEfiDebugSupportProtocolGuid
,
66 (VOID
**) &DebugSupportProtocolPtr
,
69 EFI_OPEN_PROTOCOL_GET_PROTOCOL
71 if ((Status
== EFI_SUCCESS
) && (DebugSupportProtocolPtr
->Isa
== EFI_ISA
)) {
73 // a Debug Support protocol has been installed for this processor
76 Status
= EFI_ALREADY_STARTED
;
79 } while (NumHandles
> 0);
84 // Get our image information and install platform specific unload handler
86 Status
= gBS
->OpenProtocol (
88 &gEfiLoadedImageProtocolGuid
,
89 (VOID
**) &LoadedImageProtocolPtr
,
92 EFI_OPEN_PROTOCOL_GET_PROTOCOL
94 ASSERT (!EFI_ERROR (Status
));
95 if (Status
!= EFI_SUCCESS
) {
99 LoadedImageProtocolPtr
->Unload
= PlUnloadDebugSupportDriver
;
102 // Call hook for processor specific initialization
104 Status
= PlInitializeDebugSupportDriver ();
105 ASSERT (!EFI_ERROR (Status
));
106 if (Status
!= EFI_SUCCESS
) {
111 // Install Debug Support protocol to new handle
114 Status
= gBS
->InstallProtocolInterface (
116 &gEfiDebugSupportProtocolGuid
,
117 EFI_NATIVE_INTERFACE
,
118 &mDebugSupportProtocolInterface
120 ASSERT (!EFI_ERROR (Status
));
121 if (Status
!= EFI_SUCCESS
) {