xref: /kvmtool/include/kvm/ioport.h (revision 7e19cb54a7cc584164c98912157f2ba08ecfb0ca)
1 #ifndef KVM__IOPORT_H
2 #define KVM__IOPORT_H
3 
4 #include "kvm/kvm-cpu.h"
5 
6 #include <asm/types.h>
7 #include <linux/types.h>
8 #include <linux/byteorder.h>
9 
10 /* some ports we reserve for own use */
11 #define IOPORT_DBG			0xe0
12 
13 void ioport__map_irq(u8 *irq);
14 
ioport__read8(u8 * data)15 static inline u8 ioport__read8(u8 *data)
16 {
17 	return *data;
18 }
19 /* On BE platforms, PCI I/O is byteswapped, i.e. LE, so swap back. */
ioport__read16(u16 * data)20 static inline u16 ioport__read16(u16 *data)
21 {
22 	return le16_to_cpu(*data);
23 }
24 
ioport__read32(u32 * data)25 static inline u32 ioport__read32(u32 *data)
26 {
27 	return le32_to_cpu(*data);
28 }
29 
ioport__write8(u8 * data,u8 value)30 static inline void ioport__write8(u8 *data, u8 value)
31 {
32 	*data		 = value;
33 }
34 
ioport__write16(u16 * data,u16 value)35 static inline void ioport__write16(u16 *data, u16 value)
36 {
37 	*data		 = cpu_to_le16(value);
38 }
39 
ioport__write32(u32 * data,u32 value)40 static inline void ioport__write32(u32 *data, u32 value)
41 {
42 	*data		 = cpu_to_le32(value);
43 }
44 
45 #endif /* KVM__IOPORT_H */
46