remove some comments introduced by tools.
[mirror_edk2.git] / MdeModulePkg / Universal / DebugSupportDxe / DebugSupport.c
1 /*++
2
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 DebugSupport.c
15
16 Abstract:
17
18 Top level C file for debug support driver. Contains initialization function.
19
20 Revision History
21
22 --*/
23
24 //
25 // private header files
26 //
27 #include "plDebugSupport.h"
28
29 //
30 // This is a global that is the actual interface
31 //
32 EFI_DEBUG_SUPPORT_PROTOCOL gDebugSupportProtocolInterface = {
33 EFI_ISA,
34 GetMaximumProcessorIndex,
35 RegisterPeriodicCallback,
36 RegisterExceptionCallback,
37 InvalidateInstructionCache
38 };
39
40 //
41 // Driver Entry Point
42 //
43 EFI_STATUS
44 InitializeDebugSupportDriver (
45 IN EFI_HANDLE ImageHandle,
46 IN EFI_SYSTEM_TABLE *SystemTable
47 )
48 /*++
49
50 Routine Description:
51 Driver entry point. Checks to see there's not already a DebugSupport protocol
52 installed for the selected processor before installing protocol.
53
54 Arguments:
55 IN EFI_HANDLE ImageHandle,
56 IN EFI_SYSTEM_TABLE *SystemTable
57
58 Returns:
59
60 EFI_STATUS
61
62 --*/
63 // TODO: ImageHandle - add argument and description to function comment
64 // TODO: SystemTable - add argument and description to function comment
65 {
66 EFI_LOADED_IMAGE_PROTOCOL *LoadedImageProtocolPtr;
67 EFI_STATUS Status;
68 EFI_HANDLE Handle;
69 EFI_HANDLE *HandlePtr;
70 UINTN NumHandles;
71 EFI_DEBUG_SUPPORT_PROTOCOL *DebugSupportProtocolPtr;
72
73 //
74 // Install Protocol Interface...
75 //
76 // First check to see that the debug support protocol for this processor
77 // type is not already installed
78 //
79 Status = gBS->LocateHandleBuffer (
80 ByProtocol,
81 &gEfiDebugSupportProtocolGuid,
82 NULL,
83 &NumHandles,
84 &HandlePtr
85 );
86
87 if (Status != EFI_NOT_FOUND) {
88 do {
89 NumHandles--;
90 Status = gBS->OpenProtocol (
91 HandlePtr[NumHandles],
92 &gEfiDebugSupportProtocolGuid,
93 (VOID **) &DebugSupportProtocolPtr,
94 ImageHandle,
95 NULL,
96 EFI_OPEN_PROTOCOL_GET_PROTOCOL
97 );
98 if (Status == EFI_SUCCESS && DebugSupportProtocolPtr->Isa == EFI_ISA) {
99 FreePool (HandlePtr);
100 Status = EFI_ALREADY_STARTED;
101 goto ErrExit;
102 }
103 } while (NumHandles > 0);
104 FreePool (HandlePtr);
105 }
106
107 //
108 // Get our image information and install platform specific unload handler
109 //
110 Status = gBS->OpenProtocol (
111 ImageHandle,
112 &gEfiLoadedImageProtocolGuid,
113 (VOID **) &LoadedImageProtocolPtr,
114 ImageHandle,
115 NULL,
116 EFI_OPEN_PROTOCOL_GET_PROTOCOL
117 );
118 ASSERT (!EFI_ERROR (Status));
119 if (Status != EFI_SUCCESS) {
120 goto ErrExit;
121 }
122
123 LoadedImageProtocolPtr->Unload = plUnloadDebugSupportDriver;
124
125 //
126 // Call hook for platform specific initialization
127 //
128 Status = plInitializeDebugSupportDriver ();
129 ASSERT (!EFI_ERROR (Status));
130 if (Status != EFI_SUCCESS) {
131 goto ErrExit;
132 }
133
134 //
135 // Install DebugSupport protocol to new handle
136 //
137 Handle = NULL;
138 Status = gBS->InstallProtocolInterface (
139 &Handle,
140 &gEfiDebugSupportProtocolGuid,
141 EFI_NATIVE_INTERFACE,
142 &gDebugSupportProtocolInterface
143 );
144 ASSERT (!EFI_ERROR (Status));
145 if (Status != EFI_SUCCESS) {
146 goto ErrExit;
147 }
148
149 ErrExit:
150 return Status;
151 }