aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm
diff options
context:
space:
mode:
authorHollis Blanchard <hollisb@us.ibm.com>2007-12-03 16:30:24 -0500
committerAvi Kivity <avi@qumranet.com>2008-01-30 10:53:17 -0500
commite2174021cfa535dbcaef02dc6f2897019c30731d (patch)
tree8f3713033be0b0d3c7c398e0e343c271d2d6b8dc /drivers/kvm
parentd77a39d982431ef9efc7e7a1690cee2ce252b95e (diff)
KVM: Portability: Move IO device definitions to its own header file
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com> Acked-by: Carsten Otte <cotte@de.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm')
-rw-r--r--drivers/kvm/iodev.h63
-rw-r--r--drivers/kvm/irq.h1
-rw-r--r--drivers/kvm/kvm.h42
-rw-r--r--drivers/kvm/kvm_main.c1
4 files changed, 65 insertions, 42 deletions
diff --git a/drivers/kvm/iodev.h b/drivers/kvm/iodev.h
new file mode 100644
index 000000000000..eb9e8a71843a
--- /dev/null
+++ b/drivers/kvm/iodev.h
@@ -0,0 +1,63 @@
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License.
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14 */
15
16#ifndef __KVM_IODEV_H__
17#define __KVM_IODEV_H__
18
19#include "types.h"
20
21struct kvm_io_device {
22 void (*read)(struct kvm_io_device *this,
23 gpa_t addr,
24 int len,
25 void *val);
26 void (*write)(struct kvm_io_device *this,
27 gpa_t addr,
28 int len,
29 const void *val);
30 int (*in_range)(struct kvm_io_device *this, gpa_t addr);
31 void (*destructor)(struct kvm_io_device *this);
32
33 void *private;
34};
35
36static inline void kvm_iodevice_read(struct kvm_io_device *dev,
37 gpa_t addr,
38 int len,
39 void *val)
40{
41 dev->read(dev, addr, len, val);
42}
43
44static inline void kvm_iodevice_write(struct kvm_io_device *dev,
45 gpa_t addr,
46 int len,
47 const void *val)
48{
49 dev->write(dev, addr, len, val);
50}
51
52static inline int kvm_iodevice_inrange(struct kvm_io_device *dev, gpa_t addr)
53{
54 return dev->in_range(dev, addr);
55}
56
57static inline void kvm_iodevice_destructor(struct kvm_io_device *dev)
58{
59 if (dev->destructor)
60 dev->destructor(dev);
61}
62
63#endif /* __KVM_IODEV_H__ */
diff --git a/drivers/kvm/irq.h b/drivers/kvm/irq.h
index 75f5f18d801c..803b9c7db57b 100644
--- a/drivers/kvm/irq.h
+++ b/drivers/kvm/irq.h
@@ -23,6 +23,7 @@
23#define __IRQ_H 23#define __IRQ_H
24 24
25#include "kvm.h" 25#include "kvm.h"
26#include "iodev.h"
26 27
27typedef void irq_request_func(void *opaque, int level); 28typedef void irq_request_func(void *opaque, int level);
28 29
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index 3b0ba5ab7104..a1b7d1c00bde 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -168,48 +168,6 @@ struct kvm_vcpu_stat {
168 u32 insn_emulation_fail; 168 u32 insn_emulation_fail;
169}; 169};
170 170
171struct kvm_io_device {
172 void (*read)(struct kvm_io_device *this,
173 gpa_t addr,
174 int len,
175 void *val);
176 void (*write)(struct kvm_io_device *this,
177 gpa_t addr,
178 int len,
179 const void *val);
180 int (*in_range)(struct kvm_io_device *this, gpa_t addr);
181 void (*destructor)(struct kvm_io_device *this);
182
183 void *private;
184};
185
186static inline void kvm_iodevice_read(struct kvm_io_device *dev,
187 gpa_t addr,
188 int len,
189 void *val)
190{
191 dev->read(dev, addr, len, val);
192}
193
194static inline void kvm_iodevice_write(struct kvm_io_device *dev,
195 gpa_t addr,
196 int len,
197 const void *val)
198{
199 dev->write(dev, addr, len, val);
200}
201
202static inline int kvm_iodevice_inrange(struct kvm_io_device *dev, gpa_t addr)
203{
204 return dev->in_range(dev, addr);
205}
206
207static inline void kvm_iodevice_destructor(struct kvm_io_device *dev)
208{
209 if (dev->destructor)
210 dev->destructor(dev);
211}
212
213/* 171/*
214 * It would be nice to use something smarter than a linear search, TBD... 172 * It would be nice to use something smarter than a linear search, TBD...
215 * Thankfully we dont expect many devices to register (famous last words :), 173 * Thankfully we dont expect many devices to register (famous last words :),
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 058366f480dc..14b376ead3da 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -18,6 +18,7 @@
18#include "kvm.h" 18#include "kvm.h"
19#include "x86.h" 19#include "x86.h"
20#include "irq.h" 20#include "irq.h"
21#include "iodev.h"
21 22
22#include <linux/kvm.h> 23#include <linux/kvm.h>
23#include <linux/module.h> 24#include <linux/module.h>