aboutsummaryrefslogtreecommitdiff
path: root/include/ioport.h
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2015-05-20 17:09:34 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2015-05-21 11:44:57 +0200
commiteaae11e17f022188755c67e4dd3436875e84110d (patch)
tree35625017b95776f3eb2470705cb3af2b44687548 /include/ioport.h
parentedba90fb16ec7224da591ab8f83efe3673853a3f (diff)
downloadqboot-eaae11e17f022188755c67e4dd3436875e84110d.zip
qboot-eaae11e17f022188755c67e4dd3436875e84110d.tar.gz
qboot-eaae11e17f022188755c67e4dd3436875e84110d.tar.bz2
make a bootable BIOS
includes source from kvm-unit-tests Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include/ioport.h')
-rw-r--r--include/ioport.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/include/ioport.h b/include/ioport.h
new file mode 100644
index 0000000..bbec982
--- /dev/null
+++ b/include/ioport.h
@@ -0,0 +1,50 @@
+#ifndef _IOPORT_H
+#define _IOPORT_H 1
+
+static inline void outsb(unsigned short port, void *buf, int len)
+{
+ asm volatile("rep outsb %%ds:(%0), %3" : "+S" (buf), "+c" (len) : "m"(buf), "Nd"(port), "0" (buf), "1" (len));
+}
+
+static inline void insb(void *buf, unsigned short port, int len)
+{
+ asm volatile("rep insb %3, %%es:(%0)" : "+D" (buf), "+c" (len), "=m"(buf) : "Nd"(port), "0" (buf), "1" (len));
+}
+
+static inline unsigned char inb(unsigned short port)
+{
+ unsigned char val;
+ asm volatile("inb %1, %0" : "=a"(val) : "Nd"(port));
+ return val;
+}
+
+static inline unsigned short inw(unsigned short port)
+{
+ unsigned short val;
+ asm volatile("inw %1, %0" : "=a"(val) : "Nd"(port));
+ return val;
+}
+
+static inline unsigned inl(unsigned short port)
+{
+ unsigned val;
+ asm volatile("inl %1, %0" : "=a"(val) : "Nd"(port));
+ return val;
+}
+
+static inline void outb(unsigned short port, unsigned char val)
+{
+ asm volatile("outb %0, %1" : : "a"(val), "Nd"(port));
+}
+
+static inline void outw(unsigned short port, unsigned short val)
+{
+ asm volatile("outw %0, %1" : : "a"(val), "Nd"(port));
+}
+
+static inline void outl(unsigned short port, unsigned val)
+{
+ asm volatile("outl %0, %1" : : "a"(val), "Nd"(port));
+}
+
+#endif