summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Mustacchi <rm@joyent.com>2011-05-03 18:53:08 -0700
committerRobert Mustacchi <rm@joyent.com>2011-05-03 18:53:08 -0700
commit38a8ccf6fcd9d98dd4acda74e490b157f5624c1b (patch)
tree11f9d0dc031b6a390cdc6d7d6c2ec837da0861d9
parenta0baf881f900742436e8a7118a792d7c33159507 (diff)
downloadillumos-kvm-38a8ccf6fcd9d98dd4acda74e490b157f5624c1b.tar.gz
HVM-153 iodev.h should be a header file
-rw-r--r--Makefile12
-rw-r--r--iodev.h27
-rw-r--r--kvm_iodev.c57
3 files changed, 71 insertions, 25 deletions
diff --git a/Makefile b/Makefile
index ab317af..a3d859c 100644
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,7 @@ CSTYLE=$(KERNEL_SOURCE)/usr/src/tools/scripts/cstyle
all: kvm kvm.so
-kvm: kvm.c kvm_x86.c kvm_emulate.c kvm.h kvm_x86host.h msr.h bitops.h kvm_subr.c kvm_irq.c kvm_i8254.c kvm_lapic.c kvm_mmu.c
+kvm: kvm.c kvm_x86.c kvm_emulate.c kvm.h kvm_x86host.h msr.h bitops.h kvm_subr.c kvm_irq.c kvm_i8254.c kvm_lapic.c kvm_mmu.c kvm_iodev.c
$(CC) $(CFLAGS) $(INCLUDEDIR) kvm.c
$(CC) $(CFLAGS) $(INCLUDEDIR) kvm_x86.c
$(CC) $(CFLAGS) $(INCLUDEDIR) kvm_emulate.c
@@ -25,6 +25,7 @@ kvm: kvm.c kvm_x86.c kvm_emulate.c kvm.h kvm_x86host.h msr.h bitops.h kvm_subr.c
$(CC) $(CFLAGS) $(INCLUDEDIR) kvm_i8254.c
$(CC) $(CFLAGS) $(INCLUDEDIR) kvm_lapic.c
$(CC) $(CFLAGS) $(INCLUDEDIR) kvm_mmu.c
+ $(CC) $(CFLAGS) $(INCLUDEDIR) kvm_iodev.c
$(CTFCONVERT) -i -L VERSION kvm.o
$(CTFCONVERT) -i -L VERSION kvm_x86.o
$(CTFCONVERT) -i -L VERSION kvm_emulate.o
@@ -33,8 +34,9 @@ kvm: kvm.c kvm_x86.c kvm_emulate.c kvm.h kvm_x86host.h msr.h bitops.h kvm_subr.c
$(CTFCONVERT) -i -L VERSION kvm_i8254.o
$(CTFCONVERT) -i -L VERSION kvm_lapic.o
$(CTFCONVERT) -i -L VERSION kvm_mmu.o
- $(LD) -r -o kvm kvm.o kvm_x86.o kvm_emulate.o kvm_subr.o kvm_irq.o kvm_i8254.o kvm_lapic.o kvm_mmu.o
- $(CTFMERGE) -L VERSION -o kvm kvm.o kvm_x86.o kvm_emulate.o kvm_subr.o kvm_irq.o kvm_i8254.o kvm_lapic.o kvm_mmu.o
+ $(CTFCONVERT) -i -L VERSION kvm_iodev.o
+ $(LD) -r -o kvm kvm.o kvm_x86.o kvm_emulate.o kvm_subr.o kvm_irq.o kvm_i8254.o kvm_lapic.o kvm_mmu.o kvm_iodev.o
+ $(CTFMERGE) -L VERSION -o kvm kvm.o kvm_x86.o kvm_emulate.o kvm_subr.o kvm_irq.o kvm_i8254.o kvm_lapic.o kvm_mmu.o kvm_iodev.o
kvm.so: kvm_mdb.c
gcc -m64 -shared \
@@ -47,8 +49,8 @@ install: kvm
@pfexec cp kvm.conf /usr/kernel/drv
check:
- @$(CSTYLE) kvm.c kvm_mdb.c kvm_emulate.c kvm_x86.c kvm_irq.c kvm_lapic.c kvm_i8254.c kvm_mmu.c
- @./tools/xxxcheck kvm_x86.c kvm.c kvm_irq.c kvm_lapic.c kvm_i8254.c kvm_mmu.c
+ @$(CSTYLE) kvm.c kvm_mdb.c kvm_emulate.c kvm_x86.c kvm_irq.c kvm_lapic.c kvm_i8254.c kvm_mmu.c kvm_iodev.c
+ @./tools/xxxcheck kvm_x86.c kvm.c kvm_irq.c kvm_lapic.c kvm_i8254.c kvm_mmu.c kvm_iodev.c
load: install
@echo "==> Loading kvm module"
diff --git a/iodev.h b/iodev.h
index e1efad6..522d8c6 100644
--- a/iodev.h
+++ b/iodev.h
@@ -43,28 +43,15 @@ typedef struct kvm_io_device {
const struct kvm_io_device_ops *ops;
} kvm_io_device_t;
-static void kvm_iodevice_init(struct kvm_io_device *dev,
- const struct kvm_io_device_ops *ops)
-{
- dev->ops = ops;
-}
+void kvm_iodevice_init(struct kvm_io_device *,
+ const struct kvm_io_device_ops *);
-static int kvm_iodevice_read(struct kvm_io_device *dev,
- gpa_t addr, int l, void *v)
-{
- return dev->ops->read ? dev->ops->read(dev, addr, l, v) : -EOPNOTSUPP;
-}
+int kvm_iodevice_read(struct kvm_io_device *,
+ gpa_t, int, void *);
-static int kvm_iodevice_write(struct kvm_io_device *dev,
- gpa_t addr, int l, const void *v)
-{
- return dev->ops->write ? dev->ops->write(dev, addr, l, v) : -EOPNOTSUPP;
-}
+int kvm_iodevice_write(struct kvm_io_device *dev,
+ gpa_t addr, int l, const void *v);
-static void kvm_iodevice_destructor(struct kvm_io_device *dev)
-{
- if (dev->ops->destructor)
- dev->ops->destructor(dev);
-}
+void kvm_iodevice_destructor(struct kvm_io_device *dev);
#endif /* __KVM_IODEV_H__ */
diff --git a/kvm_iodev.c b/kvm_iodev.c
new file mode 100644
index 0000000..50556ba
--- /dev/null
+++ b/kvm_iodev.c
@@ -0,0 +1,57 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+/*
+ * Copyright 2011, Joyent Inc. All Rights Reserved.
+ */
+
+/*
+ * XXX Everytime I do this I die a bit more inside ~ rm
+ * Please save me from header file hell!
+ */
+#include "vmx.h"
+#include "msr.h"
+#include "kvm_host.h"
+#include "kvm_x86host.h"
+#include "iodev.h"
+#include "kvm.h"
+
+void
+kvm_iodevice_init(struct kvm_io_device *dev,
+ const struct kvm_io_device_ops *ops)
+{
+ dev->ops = ops;
+}
+
+int
+kvm_iodevice_read(struct kvm_io_device *dev,
+ gpa_t addr, int l, void *v)
+{
+ return (dev->ops->read ? dev->ops->read(dev, addr, l, v) : -EOPNOTSUPP);
+}
+
+int
+kvm_iodevice_write(struct kvm_io_device *dev,
+ gpa_t addr, int l, const void *v)
+{
+ return (dev->ops->write ? dev->ops->write(dev, addr, l, v) :
+ -EOPNOTSUPP);
+}
+
+void
+kvm_iodevice_destructor(struct kvm_io_device *dev)
+{
+ if (dev->ops->destructor)
+ dev->ops->destructor(dev);
+}