]>
Commit | Line | Data |
---|---|---|
fb0b259e | 1 | /** @file\r |
2 | Top level C file for debug support driver. Contains initialization function.\r | |
c1f23d63 | 3 | \r |
e5eed7d3 HT |
4 | Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r |
5 | This program and the accompanying materials\r | |
fb0b259e | 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 |
e9f9d09a | 15 | #include "PlDebugSupport.h"\r |
c1f23d63 | 16 | \r |
c84507ab | 17 | EFI_DEBUG_SUPPORT_PROTOCOL mDebugSupportProtocolInterface = {\r |
c1f23d63 | 18 | EFI_ISA,\r |
19 | GetMaximumProcessorIndex,\r | |
20 | RegisterPeriodicCallback,\r | |
21 | RegisterExceptionCallback,\r | |
22 | InvalidateInstructionCache\r | |
23 | };\r | |
24 | \r | |
9e604fe4 | 25 | \r |
26 | /**\r | |
c84507ab | 27 | Debug Support Driver entry point. \r |
9e604fe4 | 28 | \r |
c84507ab | 29 | Checks to see if there's not already a Debug Support protocol installed for \r |
30 | the selected processor before installing it.\r | |
9e604fe4 | 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 | |
7601dbe7 | 36 | @retval EFI_ALREADY_STARTED Debug Support protocol is installed already.\r |
9e604fe4 | 37 | @retval other Some error occurs when executing this entry point.\r |
38 | \r | |
39 | **/\r | |
c1f23d63 | 40 | EFI_STATUS\r |
6d3ea23f | 41 | EFIAPI\r |
c1f23d63 | 42 | InitializeDebugSupportDriver (\r |
43 | IN EFI_HANDLE ImageHandle,\r | |
44 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
45 | )\r | |
c1f23d63 | 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 | |
c1f23d63 | 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 | |
c84507ab | 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 | |
c1f23d63 | 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 | |
9e604fe4 | 105 | LoadedImageProtocolPtr->Unload = PlUnloadDebugSupportDriver;\r |
c1f23d63 | 106 | \r |
107 | //\r | |
c84507ab | 108 | // Call hook for processor specific initialization \r |
c1f23d63 | 109 | //\r |
9e604fe4 | 110 | Status = PlInitializeDebugSupportDriver ();\r |
c1f23d63 | 111 | ASSERT (!EFI_ERROR (Status));\r |
112 | if (Status != EFI_SUCCESS) {\r | |
113 | goto ErrExit;\r | |
114 | }\r | |
115 | \r | |
116 | //\r | |
c84507ab | 117 | // Install Debug Support protocol to new handle\r |
c1f23d63 | 118 | //\r |
119 | Handle = NULL;\r | |
120 | Status = gBS->InstallProtocolInterface (\r | |
121 | &Handle,\r | |
122 | &gEfiDebugSupportProtocolGuid,\r | |
123 | EFI_NATIVE_INTERFACE,\r | |
c84507ab | 124 | &mDebugSupportProtocolInterface\r |
c1f23d63 | 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 |