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