]>
Commit | Line | Data |
---|---|---|
fb0b259e | 1 | /** @file\r |
2 | Top level C file for debug support driver. Contains initialization function.\r | |
c1f23d63 | 3 | \r |
d1102dba | 4 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r |
9d510e61 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
c1f23d63 | 6 | \r |
fb0b259e | 7 | **/\r |
c1f23d63 | 8 | \r |
e9f9d09a | 9 | #include "PlDebugSupport.h"\r |
c1f23d63 | 10 | \r |
c84507ab | 11 | EFI_DEBUG_SUPPORT_PROTOCOL mDebugSupportProtocolInterface = {\r |
c1f23d63 | 12 | EFI_ISA,\r |
13 | GetMaximumProcessorIndex,\r | |
14 | RegisterPeriodicCallback,\r | |
15 | RegisterExceptionCallback,\r | |
16 | InvalidateInstructionCache\r | |
17 | };\r | |
18 | \r | |
9e604fe4 | 19 | \r |
20 | /**\r | |
d1102dba | 21 | Debug Support Driver entry point.\r |
9e604fe4 | 22 | \r |
d1102dba | 23 | Checks to see if there's not already a Debug Support protocol installed for\r |
c84507ab | 24 | the selected processor before installing it.\r |
9e604fe4 | 25 | \r |
d1102dba | 26 | @param[in] ImageHandle The firmware allocated handle for the EFI image.\r |
9e604fe4 | 27 | @param[in] SystemTable A pointer to the EFI System Table.\r |
d1102dba | 28 | \r |
9e604fe4 | 29 | @retval EFI_SUCCESS The entry point is executed successfully.\r |
7601dbe7 | 30 | @retval EFI_ALREADY_STARTED Debug Support protocol is installed already.\r |
9e604fe4 | 31 | @retval other Some error occurs when executing this entry point.\r |
32 | \r | |
33 | **/\r | |
c1f23d63 | 34 | EFI_STATUS\r |
6d3ea23f | 35 | EFIAPI\r |
c1f23d63 | 36 | InitializeDebugSupportDriver (\r |
37 | IN EFI_HANDLE ImageHandle,\r | |
38 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
39 | )\r | |
c1f23d63 | 40 | {\r |
41 | EFI_LOADED_IMAGE_PROTOCOL *LoadedImageProtocolPtr;\r | |
42 | EFI_STATUS Status;\r | |
43 | EFI_HANDLE Handle;\r | |
44 | EFI_HANDLE *HandlePtr;\r | |
45 | UINTN NumHandles;\r | |
46 | EFI_DEBUG_SUPPORT_PROTOCOL *DebugSupportProtocolPtr;\r | |
47 | \r | |
c1f23d63 | 48 | //\r |
49 | // First check to see that the debug support protocol for this processor\r | |
50 | // type is not already installed\r | |
51 | //\r | |
52 | Status = gBS->LocateHandleBuffer (\r | |
53 | ByProtocol,\r | |
54 | &gEfiDebugSupportProtocolGuid,\r | |
55 | NULL,\r | |
56 | &NumHandles,\r | |
57 | &HandlePtr\r | |
58 | );\r | |
59 | \r | |
60 | if (Status != EFI_NOT_FOUND) {\r | |
61 | do {\r | |
62 | NumHandles--;\r | |
63 | Status = gBS->OpenProtocol (\r | |
64 | HandlePtr[NumHandles],\r | |
65 | &gEfiDebugSupportProtocolGuid,\r | |
66 | (VOID **) &DebugSupportProtocolPtr,\r | |
67 | ImageHandle,\r | |
68 | NULL,\r | |
69 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
70 | );\r | |
c84507ab | 71 | if ((Status == EFI_SUCCESS) && (DebugSupportProtocolPtr->Isa == EFI_ISA)) {\r |
72 | //\r | |
73 | // a Debug Support protocol has been installed for this processor\r | |
74 | //\r | |
c1f23d63 | 75 | FreePool (HandlePtr);\r |
76 | Status = EFI_ALREADY_STARTED;\r | |
77 | goto ErrExit;\r | |
78 | }\r | |
79 | } while (NumHandles > 0);\r | |
80 | FreePool (HandlePtr);\r | |
81 | }\r | |
82 | \r | |
83 | //\r | |
84 | // Get our image information and install platform specific unload handler\r | |
85 | //\r | |
86 | Status = gBS->OpenProtocol (\r | |
87 | ImageHandle,\r | |
88 | &gEfiLoadedImageProtocolGuid,\r | |
89 | (VOID **) &LoadedImageProtocolPtr,\r | |
90 | ImageHandle,\r | |
91 | NULL,\r | |
92 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
93 | );\r | |
94 | ASSERT (!EFI_ERROR (Status));\r | |
95 | if (Status != EFI_SUCCESS) {\r | |
96 | goto ErrExit;\r | |
97 | }\r | |
98 | \r | |
9e604fe4 | 99 | LoadedImageProtocolPtr->Unload = PlUnloadDebugSupportDriver;\r |
c1f23d63 | 100 | \r |
101 | //\r | |
d1102dba | 102 | // Call hook for processor specific initialization\r |
c1f23d63 | 103 | //\r |
9e604fe4 | 104 | Status = PlInitializeDebugSupportDriver ();\r |
c1f23d63 | 105 | ASSERT (!EFI_ERROR (Status));\r |
106 | if (Status != EFI_SUCCESS) {\r | |
107 | goto ErrExit;\r | |
108 | }\r | |
109 | \r | |
110 | //\r | |
c84507ab | 111 | // Install Debug Support protocol to new handle\r |
c1f23d63 | 112 | //\r |
113 | Handle = NULL;\r | |
114 | Status = gBS->InstallProtocolInterface (\r | |
115 | &Handle,\r | |
116 | &gEfiDebugSupportProtocolGuid,\r | |
117 | EFI_NATIVE_INTERFACE,\r | |
c84507ab | 118 | &mDebugSupportProtocolInterface\r |
c1f23d63 | 119 | );\r |
120 | ASSERT (!EFI_ERROR (Status));\r | |
121 | if (Status != EFI_SUCCESS) {\r | |
122 | goto ErrExit;\r | |
123 | }\r | |
124 | \r | |
125 | ErrExit:\r | |
126 | return Status;\r | |
127 | }\r |