]>
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 | |
9e604fe4 | 31 | \r |
32 | /**\r | |
33 | Debug Port Driver entry point. \r | |
34 | \r | |
35 | Checks to see there's not already a DebugSupport protocol installed for \r | |
36 | the selected processor before installing protocol.\r | |
37 | \r | |
38 | @param[in] ImageHandle The firmware allocated handle for the EFI image. \r | |
39 | @param[in] SystemTable A pointer to the EFI System Table.\r | |
40 | \r | |
41 | @retval EFI_SUCCESS The entry point is executed successfully.\r | |
42 | @retval EFI_ALREADY_STARTED DebugSupport protocol is installed already.\r | |
43 | @retval other Some error occurs when executing this entry point.\r | |
44 | \r | |
45 | **/\r | |
c1f23d63 | 46 | EFI_STATUS\r |
47 | InitializeDebugSupportDriver (\r | |
48 | IN EFI_HANDLE ImageHandle,\r | |
49 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
50 | )\r | |
c1f23d63 | 51 | {\r |
52 | EFI_LOADED_IMAGE_PROTOCOL *LoadedImageProtocolPtr;\r | |
53 | EFI_STATUS Status;\r | |
54 | EFI_HANDLE Handle;\r | |
55 | EFI_HANDLE *HandlePtr;\r | |
56 | UINTN NumHandles;\r | |
57 | EFI_DEBUG_SUPPORT_PROTOCOL *DebugSupportProtocolPtr;\r | |
58 | \r | |
59 | //\r | |
60 | // Install Protocol Interface...\r | |
61 | //\r | |
62 | // First check to see that the debug support protocol for this processor\r | |
63 | // type is not already installed\r | |
64 | //\r | |
65 | Status = gBS->LocateHandleBuffer (\r | |
66 | ByProtocol,\r | |
67 | &gEfiDebugSupportProtocolGuid,\r | |
68 | NULL,\r | |
69 | &NumHandles,\r | |
70 | &HandlePtr\r | |
71 | );\r | |
72 | \r | |
73 | if (Status != EFI_NOT_FOUND) {\r | |
74 | do {\r | |
75 | NumHandles--;\r | |
76 | Status = gBS->OpenProtocol (\r | |
77 | HandlePtr[NumHandles],\r | |
78 | &gEfiDebugSupportProtocolGuid,\r | |
79 | (VOID **) &DebugSupportProtocolPtr,\r | |
80 | ImageHandle,\r | |
81 | NULL,\r | |
82 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
83 | );\r | |
84 | if (Status == EFI_SUCCESS && DebugSupportProtocolPtr->Isa == EFI_ISA) {\r | |
85 | FreePool (HandlePtr);\r | |
86 | Status = EFI_ALREADY_STARTED;\r | |
87 | goto ErrExit;\r | |
88 | }\r | |
89 | } while (NumHandles > 0);\r | |
90 | FreePool (HandlePtr);\r | |
91 | }\r | |
92 | \r | |
93 | //\r | |
94 | // Get our image information and install platform specific unload handler\r | |
95 | //\r | |
96 | Status = gBS->OpenProtocol (\r | |
97 | ImageHandle,\r | |
98 | &gEfiLoadedImageProtocolGuid,\r | |
99 | (VOID **) &LoadedImageProtocolPtr,\r | |
100 | ImageHandle,\r | |
101 | NULL,\r | |
102 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
103 | );\r | |
104 | ASSERT (!EFI_ERROR (Status));\r | |
105 | if (Status != EFI_SUCCESS) {\r | |
106 | goto ErrExit;\r | |
107 | }\r | |
108 | \r | |
9e604fe4 | 109 | LoadedImageProtocolPtr->Unload = PlUnloadDebugSupportDriver;\r |
c1f23d63 | 110 | \r |
111 | //\r | |
112 | // Call hook for platform specific initialization\r | |
113 | //\r | |
9e604fe4 | 114 | Status = PlInitializeDebugSupportDriver ();\r |
c1f23d63 | 115 | ASSERT (!EFI_ERROR (Status));\r |
116 | if (Status != EFI_SUCCESS) {\r | |
117 | goto ErrExit;\r | |
118 | }\r | |
119 | \r | |
120 | //\r | |
121 | // Install DebugSupport protocol to new handle\r | |
122 | //\r | |
123 | Handle = NULL;\r | |
124 | Status = gBS->InstallProtocolInterface (\r | |
125 | &Handle,\r | |
126 | &gEfiDebugSupportProtocolGuid,\r | |
127 | EFI_NATIVE_INTERFACE,\r | |
128 | &gDebugSupportProtocolInterface\r | |
129 | );\r | |
130 | ASSERT (!EFI_ERROR (Status));\r | |
131 | if (Status != EFI_SUCCESS) {\r | |
132 | goto ErrExit;\r | |
133 | }\r | |
134 | \r | |
135 | ErrExit:\r | |
136 | return Status;\r | |
137 | }\r |