2 Top level C file for debug support driver. Contains initialization function.
4 Copyright (c) 2006 - 2008, Intel Corporation. <BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "PlDebugSupport.h"
17 EFI_DEBUG_SUPPORT_PROTOCOL mDebugSupportProtocolInterface
= {
19 GetMaximumProcessorIndex
,
20 RegisterPeriodicCallback
,
21 RegisterExceptionCallback
,
22 InvalidateInstructionCache
27 Debug Support Driver entry point.
29 Checks to see if there's not already a Debug Support protocol installed for
30 the selected processor before installing it.
32 @param[in] ImageHandle The firmware allocated handle for the EFI image.
33 @param[in] SystemTable A pointer to the EFI System Table.
35 @retval EFI_SUCCESS The entry point is executed successfully.
36 @retval EFI_ALREADY_STARTED DebugS upport protocol is installed already.
37 @retval other Some error occurs when executing this entry point.
41 InitializeDebugSupportDriver (
42 IN EFI_HANDLE ImageHandle
,
43 IN EFI_SYSTEM_TABLE
*SystemTable
46 EFI_LOADED_IMAGE_PROTOCOL
*LoadedImageProtocolPtr
;
49 EFI_HANDLE
*HandlePtr
;
51 EFI_DEBUG_SUPPORT_PROTOCOL
*DebugSupportProtocolPtr
;
54 // First check to see that the debug support protocol for this processor
55 // type is not already installed
57 Status
= gBS
->LocateHandleBuffer (
59 &gEfiDebugSupportProtocolGuid
,
65 if (Status
!= EFI_NOT_FOUND
) {
68 Status
= gBS
->OpenProtocol (
69 HandlePtr
[NumHandles
],
70 &gEfiDebugSupportProtocolGuid
,
71 (VOID
**) &DebugSupportProtocolPtr
,
74 EFI_OPEN_PROTOCOL_GET_PROTOCOL
76 if ((Status
== EFI_SUCCESS
) && (DebugSupportProtocolPtr
->Isa
== EFI_ISA
)) {
78 // a Debug Support protocol has been installed for this processor
81 Status
= EFI_ALREADY_STARTED
;
84 } while (NumHandles
> 0);
89 // Get our image information and install platform specific unload handler
91 Status
= gBS
->OpenProtocol (
93 &gEfiLoadedImageProtocolGuid
,
94 (VOID
**) &LoadedImageProtocolPtr
,
97 EFI_OPEN_PROTOCOL_GET_PROTOCOL
99 ASSERT (!EFI_ERROR (Status
));
100 if (Status
!= EFI_SUCCESS
) {
104 LoadedImageProtocolPtr
->Unload
= PlUnloadDebugSupportDriver
;
107 // Call hook for processor specific initialization
109 Status
= PlInitializeDebugSupportDriver ();
110 ASSERT (!EFI_ERROR (Status
));
111 if (Status
!= EFI_SUCCESS
) {
116 // Install Debug Support protocol to new handle
119 Status
= gBS
->InstallProtocolInterface (
121 &gEfiDebugSupportProtocolGuid
,
122 EFI_NATIVE_INTERFACE
,
123 &mDebugSupportProtocolInterface
125 ASSERT (!EFI_ERROR (Status
));
126 if (Status
!= EFI_SUCCESS
) {