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