]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Universal/DebugSupportDxe/DebugSupport.c
Check comments, format and fix some typo.
[mirror_edk2.git] / MdeModulePkg / Universal / DebugSupportDxe / DebugSupport.c
... / ...
CommitLineData
1/** @file\r
2 Top level C file for debug support driver. Contains initialization function.\r
3\r
4Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include "PlDebugSupport.h"\r
16\r
17EFI_DEBUG_SUPPORT_PROTOCOL mDebugSupportProtocolInterface = {\r
18 EFI_ISA,\r
19 GetMaximumProcessorIndex,\r
20 RegisterPeriodicCallback,\r
21 RegisterExceptionCallback,\r
22 InvalidateInstructionCache\r
23};\r
24\r
25\r
26/**\r
27 Debug Support Driver entry point. \r
28\r
29 Checks to see if there's not already a Debug Support protocol installed for \r
30 the selected processor before installing it.\r
31\r
32 @param[in] ImageHandle The firmware allocated handle for the EFI image. \r
33 @param[in] SystemTable A pointer to the EFI System Table.\r
34 \r
35 @retval EFI_SUCCESS The entry point is executed successfully.\r
36 @retval EFI_ALREADY_STARTED Debug Support protocol is installed already.\r
37 @retval other Some error occurs when executing this entry point.\r
38\r
39**/\r
40EFI_STATUS\r
41InitializeDebugSupportDriver (\r
42 IN EFI_HANDLE ImageHandle,\r
43 IN EFI_SYSTEM_TABLE *SystemTable\r
44 )\r
45{\r
46 EFI_LOADED_IMAGE_PROTOCOL *LoadedImageProtocolPtr;\r
47 EFI_STATUS Status;\r
48 EFI_HANDLE Handle;\r
49 EFI_HANDLE *HandlePtr;\r
50 UINTN NumHandles;\r
51 EFI_DEBUG_SUPPORT_PROTOCOL *DebugSupportProtocolPtr;\r
52\r
53 //\r
54 // First check to see that the debug support protocol for this processor\r
55 // type is not already installed\r
56 //\r
57 Status = gBS->LocateHandleBuffer (\r
58 ByProtocol,\r
59 &gEfiDebugSupportProtocolGuid,\r
60 NULL,\r
61 &NumHandles,\r
62 &HandlePtr\r
63 );\r
64\r
65 if (Status != EFI_NOT_FOUND) {\r
66 do {\r
67 NumHandles--;\r
68 Status = gBS->OpenProtocol (\r
69 HandlePtr[NumHandles],\r
70 &gEfiDebugSupportProtocolGuid,\r
71 (VOID **) &DebugSupportProtocolPtr,\r
72 ImageHandle,\r
73 NULL,\r
74 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
75 );\r
76 if ((Status == EFI_SUCCESS) && (DebugSupportProtocolPtr->Isa == EFI_ISA)) {\r
77 //\r
78 // a Debug Support protocol has been installed for this processor\r
79 //\r
80 FreePool (HandlePtr);\r
81 Status = EFI_ALREADY_STARTED;\r
82 goto ErrExit;\r
83 }\r
84 } while (NumHandles > 0);\r
85 FreePool (HandlePtr);\r
86 }\r
87\r
88 //\r
89 // Get our image information and install platform specific unload handler\r
90 //\r
91 Status = gBS->OpenProtocol (\r
92 ImageHandle,\r
93 &gEfiLoadedImageProtocolGuid,\r
94 (VOID **) &LoadedImageProtocolPtr,\r
95 ImageHandle,\r
96 NULL,\r
97 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
98 );\r
99 ASSERT (!EFI_ERROR (Status));\r
100 if (Status != EFI_SUCCESS) {\r
101 goto ErrExit;\r
102 }\r
103\r
104 LoadedImageProtocolPtr->Unload = PlUnloadDebugSupportDriver;\r
105\r
106 //\r
107 // Call hook for processor specific initialization \r
108 //\r
109 Status = PlInitializeDebugSupportDriver ();\r
110 ASSERT (!EFI_ERROR (Status));\r
111 if (Status != EFI_SUCCESS) {\r
112 goto ErrExit;\r
113 }\r
114\r
115 //\r
116 // Install Debug Support protocol to new handle\r
117 //\r
118 Handle = NULL;\r
119 Status = gBS->InstallProtocolInterface (\r
120 &Handle,\r
121 &gEfiDebugSupportProtocolGuid,\r
122 EFI_NATIVE_INTERFACE,\r
123 &mDebugSupportProtocolInterface\r
124 );\r
125 ASSERT (!EFI_ERROR (Status));\r
126 if (Status != EFI_SUCCESS) {\r
127 goto ErrExit;\r
128 }\r
129\r
130ErrExit:\r
131 return Status;\r
132}\r