VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestHostPrintf.c@ 82525

Last change on this file since 82525 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 KB
Line 
1/* $Id: bs3-cmn-TestHostPrintf.c 76553 2019-01-01 01:45:53Z vboxsync $ */
2/** @file
3 * BS3Kit - BS3TestPrintf, BS3TestPrintfV
4 */
5
6/*
7 * Copyright (C) 2007-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27
28/*********************************************************************************************************************************
29* Header Files *
30*********************************************************************************************************************************/
31#include "bs3kit-template-header.h"
32#include "bs3-cmn-test.h"
33
34#include <iprt/asm-amd64-x86.h>
35
36
37/*********************************************************************************************************************************
38* Structures and Typedefs *
39*********************************************************************************************************************************/
40/** Output state for Bs3TestHostPrintfV. */
41typedef struct BS3TESTHOSTPRINTF
42{
43 bool fNewCmd;
44} BS3TESTHOSTPRINTF;
45
46
47/**
48 * @callback_method_impl{FNBS3STRFORMATOUTPUT, Prints to screen and VMMDev}
49 */
50static BS3_DECL_CALLBACK(size_t) bs3TestPrintfStrOutput(char ch, void BS3_FAR *pvUser)
51{
52 BS3TESTHOSTPRINTF BS3_FAR *pState = (BS3TESTHOSTPRINTF BS3_FAR *)pvUser;
53
54 /*
55 * VMMDev first. We do line by line processing to avoid running out of
56 * string buffer on the host side.
57 */
58 if (g_fbBs3VMMDevTesting)
59 {
60 if (ch != '\n' && !pState->fNewCmd)
61 ASMOutU8(VMMDEV_TESTING_IOPORT_DATA, ch);
62 else if (ch != '\0')
63 {
64 if (pState->fNewCmd)
65 {
66#if ARCH_BITS == 16
67 ASMOutU16(VMMDEV_TESTING_IOPORT_CMD, (uint16_t)VMMDEV_TESTING_CMD_PRINT);
68#else
69 ASMOutU32(VMMDEV_TESTING_IOPORT_CMD, VMMDEV_TESTING_CMD_PRINT);
70#endif
71 pState->fNewCmd = false;
72 }
73 ASMOutU8(VMMDEV_TESTING_IOPORT_DATA, ch);
74 if (ch == '\n')
75 {
76 ASMOutU8(VMMDEV_TESTING_IOPORT_DATA, '\0');
77 pState->fNewCmd = true;
78 }
79 }
80 }
81
82 return ch != '\0';
83}
84
85
86#undef Bs3TestHostPrintfV
87BS3_CMN_DEF(void, Bs3TestHostPrintfV,(const char BS3_FAR *pszFormat, va_list BS3_FAR va))
88{
89 BS3TESTHOSTPRINTF State;
90 State.fNewCmd = true;
91 Bs3StrFormatV(pszFormat, va, bs3TestPrintfStrOutput, &State);
92}
93
94
95
96#undef Bs3TestHostPrintf
97BS3_CMN_DEF(void, Bs3TestHostPrintf,(const char BS3_FAR *pszFormat, ...))
98{
99 va_list va;
100 va_start(va, pszFormat);
101 BS3_CMN_NM(Bs3TestHostPrintfV)(pszFormat, va);
102 va_end(va);
103}
104
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