summaryrefslogtreecommitdiff
path: root/kvm_iodev.c
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 /kvm_iodev.c
parenta0baf881f900742436e8a7118a792d7c33159507 (diff)
downloadillumos-kvm-38a8ccf6fcd9d98dd4acda74e490b157f5624c1b.tar.gz
HVM-153 iodev.h should be a header file
Diffstat (limited to 'kvm_iodev.c')
-rw-r--r--kvm_iodev.c57
1 files changed, 57 insertions, 0 deletions
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);
+}