]> git.proxmox.com Git - mirror_edk2.git/blame - SourceLevelDebugPkg/DebugAgentDxe/DebugAgentDxe.c
EmbeddedPkg: Allow DXE_DRIVER to depend on NvVarStoreFormattedLib
[mirror_edk2.git] / SourceLevelDebugPkg / DebugAgentDxe / DebugAgentDxe.c
CommitLineData
b422b62c 1/** @file\r
2 Initialize Debug Agent in DXE by invoking Debug Agent Library.\r
3\r
77695f4d 4Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
85f7e110 5SPDX-License-Identifier: BSD-2-Clause-Patent\r
b422b62c 6\r
7**/\r
8\r
9#include <PiDxe.h>\r
10#include <Guid/EventGroup.h>\r
11#include <Library/UefiBootServicesTableLib.h>\r
12#include <Library/DebugAgentLib.h>\r
b057be47 13#include <Library/UefiLib.h>\r
b422b62c 14\r
77695f4d 15EFI_EVENT mExitBootServiceEvent;\r
b422b62c 16\r
17/**\r
18 One notified function to disable Debug Timer interrupt when gBS->ExitBootServices() called.\r
19\r
20 @param[in] Event Pointer to this event\r
e3644786 21 @param[in] Context Event handler private data\r
b422b62c 22\r
23**/\r
24VOID\r
25EFIAPI\r
26DisableDebugTimerExitBootService (\r
27 EFI_EVENT Event,\r
28 VOID *Context\r
29 )\r
30\r
31{\r
32 SaveAndSetDebugTimerInterrupt (FALSE);\r
33}\r
34\r
35/**\r
36 The Entry Point for Debug Agent Dxe driver.\r
37\r
38 It will invoke Debug Agent Library to enable source debugging feature in DXE phase.\r
39\r
40 @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
41 @param[in] SystemTable A pointer to the EFI System Table.\r
42\r
43 @retval EFI_SUCCESS The entry point is executed successfully.\r
44 @retval other Some error occurs when initialzed Debug Agent.\r
45\r
46**/\r
47EFI_STATUS\r
48EFIAPI\r
49DebugAgentDxeInitialize(\r
50 IN EFI_HANDLE ImageHandle,\r
51 IN EFI_SYSTEM_TABLE *SystemTable\r
52 )\r
53{\r
54 EFI_STATUS Status;\r
55\r
b057be47
JF
56 if (gST->ConOut != NULL) {\r
57 Print (L"If the Debug Port is serial port, please make sure this serial port isn't connected by");\r
58 Print (L" ISA Serial driver\r\n");\r
59 Print (L"You could do the following steps to disconnect the serial port:\r\n");\r
60 Print (L"1: Shell> drivers\r\n");\r
61 Print (L" ...\r\n");\r
62 Print (L" V VERSION E G G #D #C DRIVER NAME IMAGE NAME\r\n");\r
63 Print (L" == ======== = = = == == =================================== ===================\r\n");\r
64 Print (L" 8F 0000000A B - - 1 14 PCI Bus Driver PciBusDxe\r\n");\r
65 Print (L" 91 00000010 ? - - - - ATA Bus Driver AtaBusDxe\r\n");\r
66 Print (L" ...\r\n");\r
67 Print (L" A7 0000000A B - - 1 1 ISA Serial Driver IsaSerialDxe\r\n");\r
68 Print (L" ...\r\n");\r
69 Print (L"2: Shell> dh -d A7\r\n");\r
70 Print (L" A7: Image(IsaSerialDxe) ImageDevPath (..9FB3-11D4-9A3A-0090273FC14D))DriverBinding");\r
71 Print (L" ComponentName ComponentName2\r\n");\r
72 Print (L" Driver Name : ISA Serial Driver\r\n");\r
73 Print (L" Image Name : FvFile(93B80003-9FB3-11D4-9A3A-0090273FC14D)\r\n");\r
74 Print (L" Driver Version : 0000000A\r\n");\r
75 Print (L" Driver Type : BUS\r\n");\r
76 Print (L" Configuration : NO\r\n");\r
77 Print (L" Diagnostics : NO\r\n");\r
78 Print (L" Managing :\r\n");\r
79 Print (L" Ctrl[EA] : PciRoot(0x0)/Pci(0x1F,0x0)/Serial(0x0)\r\n");\r
80 Print (L" Child[EB] : PciRoot(0x0)/Pci(0x1F,0x0)/Serial(0x0)/Uart(115200,8,N,1)\r\n");\r
81 Print (L"3: Shell> disconnect EA\r\n");\r
82 Print (L"4: Shell> load -nc DebugAgentDxe.efi\r\n\r\n");\r
83 }\r
79ecd2db 84 Status = EFI_UNSUPPORTED;\r
b422b62c 85 InitializeDebugAgent (DEBUG_AGENT_INIT_DXE_LOAD, &Status, NULL);\r
86 if (EFI_ERROR (Status)) {\r
87 return Status;\r
88 }\r
b057be47
JF
89 if (gST->ConOut != NULL) {\r
90 Print (L"Debug Agent: Initialized successfully!\r\n\r\n");\r
91 }\r
b422b62c 92 //\r
93 // Create event to disable Debug Timer interrupt when exit boot service.\r
94 //\r
95 Status = gBS->CreateEventEx (\r
96 EVT_NOTIFY_SIGNAL,\r
97 TPL_NOTIFY,\r
98 DisableDebugTimerExitBootService,\r
99 NULL,\r
100 &gEfiEventExitBootServicesGuid,\r
101 &mExitBootServiceEvent\r
102 );\r
103 return Status;\r
104}\r
105\r
106/**\r
107 This is the unload handle for Debug Agent Dxe driver.\r
108\r
109 It will invoke Debug Agent Library to disable source debugging feature.\r
110\r
111 @param[in] ImageHandle The drivers' driver image.\r
112\r
113 @retval EFI_SUCCESS The image is unloaded.\r
114 @retval Others Failed to unload the image.\r
115\r
116**/\r
117EFI_STATUS\r
118EFIAPI\r
119DebugAgentDxeUnload (\r
120 IN EFI_HANDLE ImageHandle\r
121 )\r
122{\r
123 EFI_STATUS Status;\r
124\r
79ecd2db 125 Status = EFI_UNSUPPORTED;\r
b422b62c 126 InitializeDebugAgent (DEBUG_AGENT_INIT_DXE_UNLOAD, &Status, NULL);\r
b057be47
JF
127 switch (Status) {\r
128 case EFI_ACCESS_DENIED:\r
129 Print (L"Debug Agent: Host is still connected, please de-attach TARGET firstly!\r\n");\r
130 break;\r
131 case EFI_NOT_STARTED:\r
132 Print (L"Debug Agent: It hasn't been initialized, cannot unload it!\r\n");\r
133 break;\r
134 }\r
b422b62c 135\r
136 return Status;\r
137}\r