VirtualBox

source: vbox/trunk/src/VBox/Runtime/VBox/logbackdoor.cpp@ 104448

Last change on this file since 104448 was 100191, checked in by vboxsync, 17 months ago

*: Some of the easy build fixes for linux.arm64 not warranting their own commit, bugref:10457

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 3.8 KB
Line 
1/* $Id: logbackdoor.cpp 100191 2023-06-16 08:04:11Z vboxsync $ */
2/** @file
3 * VirtualBox Runtime - Guest Backdoor Logging.
4 */
5
6/*
7 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37
38/*********************************************************************************************************************************
39* Header Files *
40*********************************************************************************************************************************/
41#include <VBox/log.h>
42#include "internal/iprt.h"
43#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
44# include <iprt/asm-amd64-x86.h>
45#endif
46#include <iprt/string.h>
47#ifdef IN_GUEST_R3
48# include <VBox/VBoxGuestLib.h>
49#endif
50
51
52/*********************************************************************************************************************************
53* Internal Functions *
54*********************************************************************************************************************************/
55static DECLCALLBACK(size_t) rtLogBackdoorOutput(void *pv, const char *pachChars, size_t cbChars);
56
57
58RTDECL(size_t) RTLogBackdoorPrintf(const char *pszFormat, ...)
59{
60 va_list args;
61 size_t cb;
62
63 va_start(args, pszFormat);
64 cb = RTLogBackdoorPrintfV(pszFormat, args);
65 va_end(args);
66
67 return cb;
68}
69
70RT_EXPORT_SYMBOL(RTLogBackdoorPrintf);
71
72
73RTDECL(size_t) RTLogBackdoorPrintfV(const char *pszFormat, va_list args)
74{
75 return RTLogFormatV(rtLogBackdoorOutput, NULL, pszFormat, args);
76}
77
78RT_EXPORT_SYMBOL(RTLogBackdoorPrintfV);
79
80
81/**
82 * Callback for RTLogFormatV which writes to the backdoor.
83 * See PFNRTSTROUTPUT() for details.
84 */
85static DECLCALLBACK(size_t) rtLogBackdoorOutput(void *pvArg, const char *pachChars, size_t cbChars)
86{
87 RT_NOREF_PV(pvArg);
88 RTLogWriteUser(pachChars, cbChars);
89 return cbChars;
90}
91
92
93RTDECL(void) RTLogWriteUser(const char *pch, size_t cb)
94{
95#ifdef IN_GUEST_R3
96 VbglR3WriteLog(pch, cb);
97#else /* !IN_GUEST_R3 */
98# if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
99 const uint8_t *pau8 = (const uint8_t *)pch;
100 if (cb > 1)
101 ASMOutStrU8(RTLOG_DEBUG_PORT, pau8, cb);
102 else if (cb)
103 ASMOutU8(RTLOG_DEBUG_PORT, *pau8);
104# elif defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32)
105 /** @todo Later maybe */
106 RT_NOREF(pch, cb);
107# else
108 /** @todo port me */
109 RT_NOREF(pch, cb);
110 RT_BREAKPOINT();
111# endif
112#endif /* !IN_GUEST_R3 */
113}
114
115RT_EXPORT_SYMBOL(RTLogWriteUser);
116
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette