]> git.proxmox.com Git - mirror_edk2.git/blame - SourceLevelDebugPkg/DebugAgentDxe/DebugAgentDxe.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[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
c1e126b1 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
c1e126b1
MK
27 EFI_EVENT Event,\r
28 VOID *Context\r
b422b62c 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
a302263e 44 @retval other Some error occurs when initialized Debug Agent.\r
b422b62c 45\r
46**/\r
47EFI_STATUS\r
48EFIAPI\r
c1e126b1
MK
49DebugAgentDxeInitialize (\r
50 IN EFI_HANDLE ImageHandle,\r
51 IN EFI_SYSTEM_TABLE *SystemTable\r
b422b62c 52 )\r
53{\r
c1e126b1 54 EFI_STATUS Status;\r
b422b62c 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
c1e126b1 84\r
79ecd2db 85 Status = EFI_UNSUPPORTED;\r
b422b62c 86 InitializeDebugAgent (DEBUG_AGENT_INIT_DXE_LOAD, &Status, NULL);\r
87 if (EFI_ERROR (Status)) {\r
88 return Status;\r
89 }\r
c1e126b1 90\r
b057be47
JF
91 if (gST->ConOut != NULL) {\r
92 Print (L"Debug Agent: Initialized successfully!\r\n\r\n");\r
93 }\r
c1e126b1 94\r
b422b62c 95 //\r
96 // Create event to disable Debug Timer interrupt when exit boot service.\r
97 //\r
98 Status = gBS->CreateEventEx (\r
99 EVT_NOTIFY_SIGNAL,\r
100 TPL_NOTIFY,\r
101 DisableDebugTimerExitBootService,\r
102 NULL,\r
103 &gEfiEventExitBootServicesGuid,\r
104 &mExitBootServiceEvent\r
105 );\r
106 return Status;\r
107}\r
108\r
109/**\r
110 This is the unload handle for Debug Agent Dxe driver.\r
111\r
112 It will invoke Debug Agent Library to disable source debugging feature.\r
113\r
114 @param[in] ImageHandle The drivers' driver image.\r
115\r
116 @retval EFI_SUCCESS The image is unloaded.\r
117 @retval Others Failed to unload the image.\r
118\r
119**/\r
120EFI_STATUS\r
121EFIAPI\r
122DebugAgentDxeUnload (\r
c1e126b1 123 IN EFI_HANDLE ImageHandle\r
b422b62c 124 )\r
125{\r
c1e126b1 126 EFI_STATUS Status;\r
b422b62c 127\r
79ecd2db 128 Status = EFI_UNSUPPORTED;\r
b422b62c 129 InitializeDebugAgent (DEBUG_AGENT_INIT_DXE_UNLOAD, &Status, NULL);\r
b057be47 130 switch (Status) {\r
c1e126b1
MK
131 case EFI_ACCESS_DENIED:\r
132 Print (L"Debug Agent: Host is still connected, please de-attach TARGET firstly!\r\n");\r
133 break;\r
134 case EFI_NOT_STARTED:\r
135 Print (L"Debug Agent: It hasn't been initialized, cannot unload it!\r\n");\r
136 break;\r
b057be47 137 }\r
b422b62c 138\r
139 return Status;\r
140}\r