From: Marcelo Tosatti <mtosatti@redhat.com>
To: kvm@vger.kernel.org
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Subject: [patch 1/3] kvm test: add monitor_printf
Date: Thu, 02 Sep 2010 20:36:53 -0300 [thread overview]
Message-ID: <20100902233712.666073971@redhat.com> (raw)
In-Reply-To: 20100902233652.853027771@redhat.com
[-- Attachment #1: monitor --]
[-- Type: text/plain, Size: 1828 bytes --]
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: kvm-unit-tests/lib/x86/io.c
===================================================================
--- kvm-unit-tests.orig/lib/x86/io.c
+++ kvm-unit-tests/lib/x86/io.c
@@ -2,6 +2,7 @@
#include "smp.h"
static struct spinlock lock;
+static struct spinlock mon_lock;
static void print_serial(const char *buf)
{
@@ -17,6 +18,20 @@ void puts(const char *s)
spin_unlock(&lock);
}
+static void print_monitor(const char *buf)
+{
+ unsigned long len = strlen(buf);
+
+ asm volatile ("rep/outsb" : "+S"(buf), "+c"(len) : "d"(0xf2));
+}
+
+void puts_monitor(const char *s)
+{
+ spin_lock(&mon_lock);
+ print_serial(s);
+ spin_unlock(&mon_lock);
+}
+
void exit(int code)
{
asm volatile("out %0, %1" : : "a"(code), "d"((short)0xf4));
Index: kvm-unit-tests/lib/libcflat.h
===================================================================
--- kvm-unit-tests.orig/lib/libcflat.h
+++ kvm-unit-tests/lib/libcflat.h
@@ -45,8 +45,10 @@ extern char *strcat(char *dest, const ch
extern int printf(const char *fmt, ...);
extern int vsnprintf(char *buf, int size, const char *fmt, va_list va);
+extern int monitor_printf(const char *fmt, ...);
extern void puts(const char *s);
+extern void puts_monitor(const char *s);
extern void *memset(void *s, int c, size_t n);
Index: kvm-unit-tests/lib/printf.c
===================================================================
--- kvm-unit-tests.orig/lib/printf.c
+++ kvm-unit-tests/lib/printf.c
@@ -177,3 +177,16 @@ int printf(const char *fmt, ...)
puts(buf);
return r;
}
+
+int monitor_printf(const char *fmt, ...)
+{
+ va_list va;
+ char buf[2000];
+ int r;
+
+ va_start(va, fmt);
+ r = vsnprintf(buf, sizeof buf, fmt, va);
+ va_end(va);
+ puts_monitor(buf);
+ return r;
+}
next prev parent reply other threads:[~2010-09-02 23:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-02 23:36 [patch 0/3] add mce test Marcelo Tosatti
2010-09-02 23:36 ` Marcelo Tosatti [this message]
2010-09-03 7:56 ` [patch 1/3] kvm test: add monitor_printf Paolo Bonzini
2010-09-03 16:48 ` Marcelo Tosatti
2010-09-03 17:23 ` [patch 1/3] kvm test: add monitor_printf (v2) Marcelo Tosatti
2010-09-02 23:36 ` [patch 2/3] kvm test: add kvm-unit.cfg Marcelo Tosatti
2010-09-02 23:36 ` [patch 3/3] Add mce test Marcelo Tosatti
2010-09-05 8:15 ` Avi Kivity
2010-09-05 21:17 ` Marcelo Tosatti
2010-09-06 14:53 ` Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100902233712.666073971@redhat.com \
--to=mtosatti@redhat.com \
--cc=kvm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.