win-pvdrivers

view xenpci/xenpci_dbgprint.c @ 1022:cd72cd0e1c19

hooking debug doesn't survive hibernate under win8. Remove it.
Remove initial balloon down - doesn't work under xen 4.2 without xenbus being loaded
author James Harper <james.harper@bendigoit.com.au>
date Tue Feb 19 15:11:49 2013 +1100 (2013-02-19)
parents 4f7d5a8636bd
children 2c0d09515dd0
line source
1 /*
2 PV Drivers for Windows Xen HVM Domains
3 Copyright (C) 2007 James Harper
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
20 #include "xenpci.h"
22 static BOOLEAN last_newline = TRUE;
23 static volatile LONG debug_print_lock = 0;
25 NTSTATUS
26 XenPci_DebugPrintV(PCHAR format, va_list args) {
27 NTSTATUS status;
28 KIRQL old_irql;
29 CHAR buf[512]; /* truncate anything larger */
30 ULONG i;
31 ULONGLONG j;
32 LARGE_INTEGER current_time;
34 status = RtlStringCbVPrintfA(buf, ARRAY_SIZE(buf), format, args);
35 if (status != STATUS_SUCCESS)
36 return status;
37 KeRaiseIrql(HIGH_LEVEL, &old_irql);
38 /* make sure that each print gets to complete in its entirety */
39 while(InterlockedCompareExchange(&debug_print_lock, 1, 0) == 1)
40 KeStallExecutionProcessor(1);
41 for (i = 0; i < strlen(buf); i++) {
42 /* only write a timestamp if the last character was a newline */
43 if (last_newline) {
44 KeQuerySystemTime(&current_time);
45 current_time.QuadPart /= 10000; /* convert to ms */
46 for (j = 1000000000000000000L; j >= 1; j /= 10)
47 if (current_time.QuadPart / j)
48 break;
49 for (; j >= 1; j /= 10) {
50 #pragma warning(suppress:28138)
51 WRITE_PORT_UCHAR(XEN_IOPORT_LOG, '0' + (UCHAR)((current_time.QuadPart / j) % 10));
52 }
53 #pragma warning(suppress:28138)
54 WRITE_PORT_UCHAR(XEN_IOPORT_LOG, ':');
55 #pragma warning(suppress:28138)
56 WRITE_PORT_UCHAR(XEN_IOPORT_LOG, ' ');
57 }
58 #pragma warning(suppress:28138)
59 WRITE_PORT_UCHAR(XEN_IOPORT_LOG, buf[i]);
60 last_newline = (buf[i] == '\n');
61 }
62 /* release the lock */
63 InterlockedExchange(&debug_print_lock, 0);
64 KeLowerIrql(old_irql);
65 return status;
66 }
68 NTSTATUS
69 XenPci_DebugPrint(PCHAR format, ...) {
70 NTSTATUS status;
71 va_list args;
73 va_start(args, format);
74 status = XenPci_DebugPrintV(format, args);
75 va_end(args);
76 return status;
77 }