virtio-pci.h
Go to the documentation of this file.00001 #ifndef _VIRTIO_PCI_H_
00002 # define _VIRTIO_PCI_H_
00003
00004
00005 #define VIRTIO_PCI_HOST_FEATURES 0
00006
00007
00008 #define VIRTIO_PCI_GUEST_FEATURES 4
00009
00010
00011 #define VIRTIO_PCI_QUEUE_PFN 8
00012
00013
00014 #define VIRTIO_PCI_QUEUE_NUM 12
00015
00016
00017 #define VIRTIO_PCI_QUEUE_SEL 14
00018
00019
00020 #define VIRTIO_PCI_QUEUE_NOTIFY 16
00021
00022
00023 #define VIRTIO_PCI_STATUS 18
00024
00025
00026
00027
00028 #define VIRTIO_PCI_ISR 19
00029
00030
00031 #define VIRTIO_PCI_ISR_CONFIG 0x2
00032
00033
00034
00035 #define VIRTIO_PCI_CONFIG 20
00036
00037
00038 #define VIRTIO_PCI_ABI_VERSION 0
00039
00040 static inline u32 vp_get_features(unsigned int ioaddr)
00041 {
00042 return inl(ioaddr + VIRTIO_PCI_HOST_FEATURES);
00043 }
00044
00045 static inline void vp_set_features(unsigned int ioaddr, u32 features)
00046 {
00047 outl(features, ioaddr + VIRTIO_PCI_GUEST_FEATURES);
00048 }
00049
00050 static inline void vp_get(unsigned int ioaddr, unsigned offset,
00051 void *buf, unsigned len)
00052 {
00053 u8 *ptr = buf;
00054 unsigned i;
00055
00056 for (i = 0; i < len; i++)
00057 ptr[i] = inb(ioaddr + VIRTIO_PCI_CONFIG + offset + i);
00058 }
00059
00060 static inline u8 vp_get_status(unsigned int ioaddr)
00061 {
00062 return inb(ioaddr + VIRTIO_PCI_STATUS);
00063 }
00064
00065 static inline void vp_set_status(unsigned int ioaddr, u8 status)
00066 {
00067 if (status == 0)
00068 return;
00069 outb(status, ioaddr + VIRTIO_PCI_STATUS);
00070 }
00071
00072
00073 static inline void vp_reset(unsigned int ioaddr)
00074 {
00075 outb(0, ioaddr + VIRTIO_PCI_STATUS);
00076 (void)inb(ioaddr + VIRTIO_PCI_ISR);
00077 }
00078
00079 static inline void vp_notify(unsigned int ioaddr, int queue_index)
00080 {
00081 outw(queue_index, ioaddr + VIRTIO_PCI_QUEUE_NOTIFY);
00082 }
00083
00084 static inline void vp_del_vq(unsigned int ioaddr, int queue_index)
00085 {
00086
00087
00088 outw(queue_index, ioaddr + VIRTIO_PCI_QUEUE_SEL);
00089
00090
00091
00092 outl(0, ioaddr + VIRTIO_PCI_QUEUE_PFN);
00093 }
00094
00095 int vp_find_vq(unsigned int ioaddr, int queue_index,
00096 struct vring_virtqueue *vq);
00097 #endif