]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Top level C file for debug support driver. Contains initialization function.\r | |
3 | \r | |
4 | Copyright (c) 2006 - 2009, 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 | |
9 | \r | |
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 | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #include "PlDebugSupport.h"\r | |
16 | \r | |
17 | EFI_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 | |
40 | EFI_STATUS\r | |
41 | EFIAPI\r | |
42 | InitializeDebugSupportDriver (\r | |
43 | IN EFI_HANDLE ImageHandle,\r | |
44 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
45 | )\r | |
46 | {\r | |
47 | EFI_LOADED_IMAGE_PROTOCOL *LoadedImageProtocolPtr;\r | |
48 | EFI_STATUS Status;\r | |
49 | EFI_HANDLE Handle;\r | |
50 | EFI_HANDLE *HandlePtr;\r | |
51 | UINTN NumHandles;\r | |
52 | EFI_DEBUG_SUPPORT_PROTOCOL *DebugSupportProtocolPtr;\r | |
53 | \r | |
54 | //\r | |
55 | // First check to see that the debug support protocol for this processor\r | |
56 | // type is not already installed\r | |
57 | //\r | |
58 | Status = gBS->LocateHandleBuffer (\r | |
59 | ByProtocol,\r | |
60 | &gEfiDebugSupportProtocolGuid,\r | |
61 | NULL,\r | |
62 | &NumHandles,\r | |
63 | &HandlePtr\r | |
64 | );\r | |
65 | \r | |
66 | if (Status != EFI_NOT_FOUND) {\r | |
67 | do {\r | |
68 | NumHandles--;\r | |
69 | Status = gBS->OpenProtocol (\r | |
70 | HandlePtr[NumHandles],\r | |
71 | &gEfiDebugSupportProtocolGuid,\r | |
72 | (VOID **) &DebugSupportProtocolPtr,\r | |
73 | ImageHandle,\r | |
74 | NULL,\r | |
75 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
76 | );\r | |
77 | if ((Status == EFI_SUCCESS) && (DebugSupportProtocolPtr->Isa == EFI_ISA)) {\r | |
78 | //\r | |
79 | // a Debug Support protocol has been installed for this processor\r | |
80 | //\r | |
81 | FreePool (HandlePtr);\r | |
82 | Status = EFI_ALREADY_STARTED;\r | |
83 | goto ErrExit;\r | |
84 | }\r | |
85 | } while (NumHandles > 0);\r | |
86 | FreePool (HandlePtr);\r | |
87 | }\r | |
88 | \r | |
89 | //\r | |
90 | // Get our image information and install platform specific unload handler\r | |
91 | //\r | |
92 | Status = gBS->OpenProtocol (\r | |
93 | ImageHandle,\r | |
94 | &gEfiLoadedImageProtocolGuid,\r | |
95 | (VOID **) &LoadedImageProtocolPtr,\r | |
96 | ImageHandle,\r | |
97 | NULL,\r | |
98 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
99 | );\r | |
100 | ASSERT (!EFI_ERROR (Status));\r | |
101 | if (Status != EFI_SUCCESS) {\r | |
102 | goto ErrExit;\r | |
103 | }\r | |
104 | \r | |
105 | LoadedImageProtocolPtr->Unload = PlUnloadDebugSupportDriver;\r | |
106 | \r | |
107 | //\r | |
108 | // Call hook for processor specific initialization \r | |
109 | //\r | |
110 | Status = PlInitializeDebugSupportDriver ();\r | |
111 | ASSERT (!EFI_ERROR (Status));\r | |
112 | if (Status != EFI_SUCCESS) {\r | |
113 | goto ErrExit;\r | |
114 | }\r | |
115 | \r | |
116 | //\r | |
117 | // Install Debug Support protocol to new handle\r | |
118 | //\r | |
119 | Handle = NULL;\r | |
120 | Status = gBS->InstallProtocolInterface (\r | |
121 | &Handle,\r | |
122 | &gEfiDebugSupportProtocolGuid,\r | |
123 | EFI_NATIVE_INTERFACE,\r | |
124 | &mDebugSupportProtocolInterface\r | |
125 | );\r | |
126 | ASSERT (!EFI_ERROR (Status));\r | |
127 | if (Status != EFI_SUCCESS) {\r | |
128 | goto ErrExit;\r | |
129 | }\r | |
130 | \r | |
131 | ErrExit:\r | |
132 | return Status;\r | |
133 | }\r |