]> git.proxmox.com Git - mirror_edk2.git/blame - SourceLevelDebugPkg/DebugAgentDxe/DebugAgentDxe.c
Refine code to make it more safely.
[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
79ecd2db 4Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>\r
b422b62c 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
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
19\r
20EFI_EVENT mExitBootServiceEvent; \r
21\r
22/**\r
23 One notified function to disable Debug Timer interrupt when gBS->ExitBootServices() called.\r
24\r
25 @param[in] Event Pointer to this event\r
26 @param[in] Context Event hanlder private data\r
27\r
28**/\r
29VOID\r
30EFIAPI\r
31DisableDebugTimerExitBootService (\r
32 EFI_EVENT Event,\r
33 VOID *Context\r
34 )\r
35\r
36{\r
37 SaveAndSetDebugTimerInterrupt (FALSE);\r
38}\r
39\r
40/**\r
41 The Entry Point for Debug Agent Dxe driver.\r
42\r
43 It will invoke Debug Agent Library to enable source debugging feature in DXE phase.\r
44\r
45 @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
46 @param[in] SystemTable A pointer to the EFI System Table.\r
47\r
48 @retval EFI_SUCCESS The entry point is executed successfully.\r
49 @retval other Some error occurs when initialzed Debug Agent.\r
50\r
51**/\r
52EFI_STATUS\r
53EFIAPI\r
54DebugAgentDxeInitialize(\r
55 IN EFI_HANDLE ImageHandle,\r
56 IN EFI_SYSTEM_TABLE *SystemTable\r
57 )\r
58{\r
59 EFI_STATUS Status;\r
60\r
79ecd2db 61 Status = EFI_UNSUPPORTED;\r
b422b62c 62 InitializeDebugAgent (DEBUG_AGENT_INIT_DXE_LOAD, &Status, NULL);\r
63 if (EFI_ERROR (Status)) {\r
64 return Status;\r
65 }\r
66 //\r
67 // Create event to disable Debug Timer interrupt when exit boot service.\r
68 //\r
69 Status = gBS->CreateEventEx (\r
70 EVT_NOTIFY_SIGNAL,\r
71 TPL_NOTIFY,\r
72 DisableDebugTimerExitBootService,\r
73 NULL,\r
74 &gEfiEventExitBootServicesGuid,\r
75 &mExitBootServiceEvent\r
76 );\r
77 return Status;\r
78}\r
79\r
80/**\r
81 This is the unload handle for Debug Agent Dxe driver.\r
82\r
83 It will invoke Debug Agent Library to disable source debugging feature.\r
84\r
85 @param[in] ImageHandle The drivers' driver image.\r
86\r
87 @retval EFI_SUCCESS The image is unloaded.\r
88 @retval Others Failed to unload the image.\r
89\r
90**/\r
91EFI_STATUS\r
92EFIAPI\r
93DebugAgentDxeUnload (\r
94 IN EFI_HANDLE ImageHandle\r
95 )\r
96{\r
97 EFI_STATUS Status;\r
98\r
79ecd2db 99 Status = EFI_UNSUPPORTED;\r
b422b62c 100 InitializeDebugAgent (DEBUG_AGENT_INIT_DXE_UNLOAD, &Status, NULL);\r
101\r
102 return Status;\r
103}\r