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