All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lucas Meneghel Rodrigues <lmr@redhat.com>
To: kvm@vger.kernel.org
Cc: avi@redhat.com, Lucas Meneghel Rodrigues <lmr@redhat.com>,
	Anthony Liguori <aliguori@us.ibm.com>
Subject: [PATCH 1/2] kvm-unit-tests: add x86 port io accessors
Date: Tue, 30 Aug 2011 20:51:04 -0300	[thread overview]
Message-ID: <1314748265-15488-2-git-send-email-lmr@redhat.com> (raw)
In-Reply-To: <1314748265-15488-1-git-send-email-lmr@redhat.com>

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 lib/x86/io.h |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)
 create mode 100644 lib/x86/io.h

diff --git a/lib/x86/io.h b/lib/x86/io.h
new file mode 100644
index 0000000..bd6341c
--- /dev/null
+++ b/lib/x86/io.h
@@ -0,0 +1,40 @@
+#ifndef IO_H
+#define IO_H
+
+static inline unsigned char inb(unsigned short port)
+{
+    unsigned char value;
+    asm volatile("inb %w1, %0" : "=a" (value) : "Nd" (port));
+    return value;
+}
+
+static inline unsigned short inw(unsigned short port)
+{
+    unsigned short value;
+    asm volatile("inw %w1, %0" : "=a" (value) : "Nd" (port));
+    return value;
+}
+
+static inline unsigned int inl(unsigned short port)
+{
+    unsigned int value;
+    asm volatile("inl %w1, %0" : "=a" (value) : "Nd" (port));
+    return value;
+}
+
+static inline void outb(unsigned char value, unsigned short port)
+{
+    asm volatile("outb %b0, %w1" : : "a"(value), "Nd"(port));
+}
+
+static inline void outw(unsigned short value, unsigned short port)
+{
+    asm volatile("outw %w0, %w1" : : "a"(value), "Nd"(port));
+}
+
+static inline void outl(unsigned int value, unsigned short port)
+{
+    asm volatile("outl %0, %w1" : : "a"(value), "Nd"(port));
+}
+
+#endif
-- 
1.7.6


  reply	other threads:[~2011-08-30 23:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-30 23:51 [PATCH 0/2] [RFC] Make kvm-unit-tests more friendly to upstream QEMU Lucas Meneghel Rodrigues
2011-08-30 23:51 ` Lucas Meneghel Rodrigues [this message]
2011-08-30 23:51 ` [PATCH 2/2] kvm-unit-tests: make I/O more friendly to existing QEMU hardware Lucas Meneghel Rodrigues
2011-08-31  9:43 ` [PATCH 0/2] [RFC] Make kvm-unit-tests more friendly to upstream QEMU 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=1314748265-15488-2-git-send-email-lmr@redhat.com \
    --to=lmr@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=avi@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.