2 Top level C file for debug support driver. Contains initialization function.
4 Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
5 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 Debug Support protocol is installed already.
37 @retval other Some error occurs when executing this entry point.
42 InitializeDebugSupportDriver (
43 IN EFI_HANDLE ImageHandle
,
44 IN EFI_SYSTEM_TABLE
*SystemTable
47 EFI_LOADED_IMAGE_PROTOCOL
*LoadedImageProtocolPtr
;
50 EFI_HANDLE
*HandlePtr
;
52 EFI_DEBUG_SUPPORT_PROTOCOL
*DebugSupportProtocolPtr
;
55 // First check to see that the debug support protocol for this processor
56 // type is not already installed
58 Status
= gBS
->LocateHandleBuffer (
60 &gEfiDebugSupportProtocolGuid
,
66 if (Status
!= EFI_NOT_FOUND
) {
69 Status
= gBS
->OpenProtocol (
70 HandlePtr
[NumHandles
],
71 &gEfiDebugSupportProtocolGuid
,
72 (VOID
**) &DebugSupportProtocolPtr
,
75 EFI_OPEN_PROTOCOL_GET_PROTOCOL
77 if ((Status
== EFI_SUCCESS
) && (DebugSupportProtocolPtr
->Isa
== EFI_ISA
)) {
79 // a Debug Support protocol has been installed for this processor
82 Status
= EFI_ALREADY_STARTED
;
85 } while (NumHandles
> 0);
90 // Get our image information and install platform specific unload handler
92 Status
= gBS
->OpenProtocol (
94 &gEfiLoadedImageProtocolGuid
,
95 (VOID
**) &LoadedImageProtocolPtr
,
98 EFI_OPEN_PROTOCOL_GET_PROTOCOL
100 ASSERT (!EFI_ERROR (Status
));
101 if (Status
!= EFI_SUCCESS
) {
105 LoadedImageProtocolPtr
->Unload
= PlUnloadDebugSupportDriver
;
108 // Call hook for processor specific initialization
110 Status
= PlInitializeDebugSupportDriver ();
111 ASSERT (!EFI_ERROR (Status
));
112 if (Status
!= EFI_SUCCESS
) {
117 // Install Debug Support protocol to new handle
120 Status
= gBS
->InstallProtocolInterface (
122 &gEfiDebugSupportProtocolGuid
,
123 EFI_NATIVE_INTERFACE
,
124 &mDebugSupportProtocolInterface
126 ASSERT (!EFI_ERROR (Status
));
127 if (Status
!= EFI_SUCCESS
) {