1 | /* $Id: VBoxDebugAgentLib.c 108802 2025-03-31 15:58:24Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox implementation of DebugAgentLib that reports EFI state transitions
|
---|
4 | * to DevEFI for debugging purposes.
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2013-2024 Oracle and/or its affiliates.
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox base platform packages, as
|
---|
11 | * available from https://www.virtualbox.org.
|
---|
12 | *
|
---|
13 | * This program is free software; you can redistribute it and/or
|
---|
14 | * modify it under the terms of the GNU General Public License
|
---|
15 | * as published by the Free Software Foundation, in version 3 of the
|
---|
16 | * License.
|
---|
17 | *
|
---|
18 | * This program is distributed in the hope that it will be useful, but
|
---|
19 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
21 | * General Public License for more details.
|
---|
22 | *
|
---|
23 | * You should have received a copy of the GNU General Public License
|
---|
24 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
25 | *
|
---|
26 | * The contents of this file may alternatively be used under the terms
|
---|
27 | * of the Common Development and Distribution License Version 1.0
|
---|
28 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
29 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
30 | * CDDL are applicable instead of those of the GPL.
|
---|
31 | *
|
---|
32 | * You may elect to license modified versions of this file under the
|
---|
33 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
34 | *
|
---|
35 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
36 | */
|
---|
37 |
|
---|
38 |
|
---|
39 | /*********************************************************************************************************************************
|
---|
40 | * Header Files *
|
---|
41 | *********************************************************************************************************************************/
|
---|
42 | #include <Base.h>
|
---|
43 | #include <Library/DebugAgentLib.h>
|
---|
44 | #include <Library/DebugLib.h>
|
---|
45 | #include "VBoxPkg.h"
|
---|
46 | #include "../../../../DevEFI.h"
|
---|
47 |
|
---|
48 |
|
---|
49 | VOID
|
---|
50 | EFIAPI
|
---|
51 | InitializeDebugAgent(
|
---|
52 | IN UINT32 InitFlag,
|
---|
53 | IN VOID *Context OPTIONAL,
|
---|
54 | IN DEBUG_AGENT_CONTINUE Function OPTIONAL
|
---|
55 | )
|
---|
56 | {
|
---|
57 | /*
|
---|
58 | * Do the reporting.
|
---|
59 | */
|
---|
60 | EFIDBGPOINT enmDbgPoint;
|
---|
61 | switch (InitFlag)
|
---|
62 | {
|
---|
63 | case DEBUG_AGENT_INIT_PREMEM_SEC: enmDbgPoint = EFIDBGPOINT_SEC_PREMEM; break;
|
---|
64 | case DEBUG_AGENT_INIT_POSTMEM_SEC: enmDbgPoint = EFIDBGPOINT_SEC_POSTMEM; break;
|
---|
65 | case DEBUG_AGENT_INIT_DXE_CORE: enmDbgPoint = EFIDBGPOINT_DXE_CORE; break;
|
---|
66 | case DEBUG_AGENT_INIT_SMM: enmDbgPoint = EFIDBGPOINT_SMM; break;
|
---|
67 | case DEBUG_AGENT_INIT_ENTER_SMI: enmDbgPoint = EFIDBGPOINT_SMI_ENTER; break;
|
---|
68 | case DEBUG_AGENT_INIT_EXIT_SMI: enmDbgPoint = EFIDBGPOINT_SMI_EXIT; break;
|
---|
69 | case DEBUG_AGENT_INIT_S3: enmDbgPoint = EFIDBGPOINT_GRAPHICS; break;
|
---|
70 | case DEBUG_AGENT_INIT_DXE_AP: enmDbgPoint = EFIDBGPOINT_DXE_AP; break;
|
---|
71 | case DEBUG_AGENT_INIT_PEI: enmDbgPoint = EFIDBGPOINT_PEI; break;
|
---|
72 | case DEBUG_AGENT_INIT_DXE_LOAD: enmDbgPoint = EFIDBGPOINT_DXE_LOAD; break;
|
---|
73 | case DEBUG_AGENT_INIT_DXE_UNLOAD: enmDbgPoint = EFIDBGPOINT_DXE_UNLOAD; break;
|
---|
74 | case DEBUG_AGENT_INIT_REINITIALIZE: enmDbgPoint = EFIDBGPOINT_REINITIALIZE; break;
|
---|
75 | case DEBUG_AGENT_INIT_DXE_CORE_LATE: enmDbgPoint = EFIDBGPOINT_DXE_CORE_LATE; break;
|
---|
76 | case DEBUG_AGENT_INIT_THUNK_PEI_IA32TOX64:
|
---|
77 | default:
|
---|
78 | ASSERT(false);
|
---|
79 | enmDbgPoint = EFIDBGPOINT_INVALID;
|
---|
80 | break;
|
---|
81 | }
|
---|
82 | if (enmDbgPoint != EFIDBGPOINT_INVALID)
|
---|
83 | ASMOutU32(EFI_PORT_DEBUG_POINT, enmDbgPoint);
|
---|
84 |
|
---|
85 |
|
---|
86 | /*
|
---|
87 | * Call resume function if supplied.
|
---|
88 | */
|
---|
89 | if (Function)
|
---|
90 | Function(Context);
|
---|
91 | }
|
---|
92 |
|
---|
93 |
|
---|
94 | BOOLEAN
|
---|
95 | EFIAPI
|
---|
96 | SaveAndSetDebugTimerInterrupt(
|
---|
97 | IN BOOLEAN EnableStatus
|
---|
98 | )
|
---|
99 | {
|
---|
100 | NOREF(EnableStatus);
|
---|
101 | return FALSE;
|
---|
102 | }
|
---|
103 |
|
---|