]> git.proxmox.com Git - mirror_edk2.git/blob - SourceLevelDebugPkg/DebugAgentDxe/DebugAgentDxe.c
Refine code to make it more safely.
[mirror_edk2.git] / SourceLevelDebugPkg / DebugAgentDxe / DebugAgentDxe.c
1 /** @file
2 Initialize Debug Agent in DXE by invoking Debug Agent Library.
3
4 Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #include <PiDxe.h>
16 #include <Guid/EventGroup.h>
17 #include <Library/UefiBootServicesTableLib.h>
18 #include <Library/DebugAgentLib.h>
19
20 EFI_EVENT mExitBootServiceEvent;
21
22 /**
23 One notified function to disable Debug Timer interrupt when gBS->ExitBootServices() called.
24
25 @param[in] Event Pointer to this event
26 @param[in] Context Event hanlder private data
27
28 **/
29 VOID
30 EFIAPI
31 DisableDebugTimerExitBootService (
32 EFI_EVENT Event,
33 VOID *Context
34 )
35
36 {
37 SaveAndSetDebugTimerInterrupt (FALSE);
38 }
39
40 /**
41 The Entry Point for Debug Agent Dxe driver.
42
43 It will invoke Debug Agent Library to enable source debugging feature in DXE phase.
44
45 @param[in] ImageHandle The firmware allocated handle for the EFI image.
46 @param[in] SystemTable A pointer to the EFI System Table.
47
48 @retval EFI_SUCCESS The entry point is executed successfully.
49 @retval other Some error occurs when initialzed Debug Agent.
50
51 **/
52 EFI_STATUS
53 EFIAPI
54 DebugAgentDxeInitialize(
55 IN EFI_HANDLE ImageHandle,
56 IN EFI_SYSTEM_TABLE *SystemTable
57 )
58 {
59 EFI_STATUS Status;
60
61 Status = EFI_UNSUPPORTED;
62 InitializeDebugAgent (DEBUG_AGENT_INIT_DXE_LOAD, &Status, NULL);
63 if (EFI_ERROR (Status)) {
64 return Status;
65 }
66 //
67 // Create event to disable Debug Timer interrupt when exit boot service.
68 //
69 Status = gBS->CreateEventEx (
70 EVT_NOTIFY_SIGNAL,
71 TPL_NOTIFY,
72 DisableDebugTimerExitBootService,
73 NULL,
74 &gEfiEventExitBootServicesGuid,
75 &mExitBootServiceEvent
76 );
77 return Status;
78 }
79
80 /**
81 This is the unload handle for Debug Agent Dxe driver.
82
83 It will invoke Debug Agent Library to disable source debugging feature.
84
85 @param[in] ImageHandle The drivers' driver image.
86
87 @retval EFI_SUCCESS The image is unloaded.
88 @retval Others Failed to unload the image.
89
90 **/
91 EFI_STATUS
92 EFIAPI
93 DebugAgentDxeUnload (
94 IN EFI_HANDLE ImageHandle
95 )
96 {
97 EFI_STATUS Status;
98
99 Status = EFI_UNSUPPORTED;
100 InitializeDebugAgent (DEBUG_AGENT_INIT_DXE_UNLOAD, &Status, NULL);
101
102 return Status;
103 }