VirtualBox

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

Last change on this file since 60112 was 60097, checked in by vboxsync, 9 years ago

bs3kit: Updates

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1/* $Id: bs3-cmn-TestPrintf.c 60097 2016-03-18 13:14:40Z vboxsync $ */
2/** @file
3 * BS3Kit - BS3TestPrintf, BS3TestPrintfV
4 */
5
6/*
7 * Copyright (C) 2007-2016 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 * @impl_callback_method{FNBS3STRFORMATOUTPUT, Prints to screen and VMMDev}
39 */
40static BS3_DECL_CALLBACK(size_t) bs3TestPrintfStrOutput(char ch, void BS3_FAR *pvUser)
41{
42 /*
43 * VMMDev first. We do line by line processing to avoid running out of
44 * string buffer on the host side.
45 */
46 if (BS3_DATA_NM(g_fbBs3VMMDevTesting))
47 {
48 bool *pfNewCmd = (bool *)pvUser;
49 if (ch != '\n' && !*pfNewCmd)
50 ASMOutU8(VMMDEV_TESTING_IOPORT_DATA, ch);
51 else if (ch != '\0')
52 {
53 if (*pfNewCmd)
54 {
55 ASMOutU32(VMMDEV_TESTING_IOPORT_CMD, VMMDEV_TESTING_CMD_PRINT);
56 *pfNewCmd = false;
57 }
58 ASMOutU8(VMMDEV_TESTING_IOPORT_DATA, ch);
59 if (ch == '\n')
60 {
61 ASMOutU8(VMMDEV_TESTING_IOPORT_DATA, '\0');
62 *pfNewCmd = true;
63 }
64 }
65 }
66
67 /*
68 * Console next.
69 */
70 if (ch != '\0')
71 Bs3PrintChr(ch);
72 return 1;
73}
74
75
76
77BS3_DECL(void) Bs3TestPrintfV(const char BS3_FAR *pszFormat, va_list va)
78{
79 bool fNewCmd = true;
80 Bs3StrFormatV(pszFormat, va, bs3TestPrintfStrOutput, &fNewCmd);
81}
82
83
84
85BS3_DECL(void) Bs3TestPrintf(const char BS3_FAR *pszFormat, ...)
86{
87 va_list va;
88 va_start(va, pszFormat);
89 Bs3TestPrintfV(pszFormat, va);
90 va_end(va);
91}
92
Note: See TracBrowser for help on using the repository browser.

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