From 5dd51079768140bcc9545fe64e75b760eb681ea8 Mon Sep 17 00:00:00 2001 From: Laurent Vivier Date: Wed, 19 Nov 2008 17:28:25 +0100 Subject: [virtio] Move virtio-pci.h and virtio-ring.h to include/gpxe Signed-off-by: Laurent Vivier --- src/drivers/net/virtio-net.c | 4 +- src/drivers/net/virtio-pci.h | 94 ------------------------------------------- src/drivers/net/virtio-ring.h | 93 ------------------------------------------ 3 files changed, 2 insertions(+), 189 deletions(-) delete mode 100644 src/drivers/net/virtio-pci.h delete mode 100644 src/drivers/net/virtio-ring.h (limited to 'src/drivers') diff --git a/src/drivers/net/virtio-net.c b/src/drivers/net/virtio-net.c index 68c84d798..fce030094 100644 --- a/src/drivers/net/virtio-net.c +++ b/src/drivers/net/virtio-net.c @@ -21,8 +21,8 @@ #include "etherboot.h" #include "nic.h" -#include "virtio-ring.h" -#include "virtio-pci.h" +#include "gpxe/virtio-ring.h" +#include "gpxe/virtio-pci.h" #include "virtio-net.h" #define BUG() do { \ diff --git a/src/drivers/net/virtio-pci.h b/src/drivers/net/virtio-pci.h deleted file mode 100644 index ba0604d52..000000000 --- a/src/drivers/net/virtio-pci.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef _VIRTIO_PCI_H_ -# define _VIRTIO_PCI_H_ - -/* A 32-bit r/o bitmask of the features supported by the host */ -#define VIRTIO_PCI_HOST_FEATURES 0 - -/* A 32-bit r/w bitmask of features activated by the guest */ -#define VIRTIO_PCI_GUEST_FEATURES 4 - -/* A 32-bit r/w PFN for the currently selected queue */ -#define VIRTIO_PCI_QUEUE_PFN 8 - -/* A 16-bit r/o queue size for the currently selected queue */ -#define VIRTIO_PCI_QUEUE_NUM 12 - -/* A 16-bit r/w queue selector */ -#define VIRTIO_PCI_QUEUE_SEL 14 - -/* A 16-bit r/w queue notifier */ -#define VIRTIO_PCI_QUEUE_NOTIFY 16 - -/* An 8-bit device status register. */ -#define VIRTIO_PCI_STATUS 18 - -/* An 8-bit r/o interrupt status register. Reading the value will return the - * current contents of the ISR and will also clear it. This is effectively - * a read-and-acknowledge. */ -#define VIRTIO_PCI_ISR 19 - -/* The bit of the ISR which indicates a device configuration change. */ -#define VIRTIO_PCI_ISR_CONFIG 0x2 - -/* The remaining space is defined by each driver as the per-driver - * configuration space */ -#define VIRTIO_PCI_CONFIG 20 - -/* Virtio ABI version, this must match exactly */ -#define VIRTIO_PCI_ABI_VERSION 0 - -static inline u32 vp_get_features(struct nic *nic) -{ - return inl(nic->ioaddr + VIRTIO_PCI_HOST_FEATURES); -} - -static inline void vp_set_features(struct nic *nic, u32 features) -{ - outl(features, nic->ioaddr + VIRTIO_PCI_GUEST_FEATURES); -} - -static inline void vp_get(struct nic *nic, unsigned offset, - void *buf, unsigned len) -{ - u8 *ptr = buf; - unsigned i; - - for (i = 0; i < len; i++) - ptr[i] = inb(nic->ioaddr + VIRTIO_PCI_CONFIG + offset + i); -} - -static inline u8 vp_get_status(struct nic *nic) -{ - return inb(nic->ioaddr + VIRTIO_PCI_STATUS); -} - -static inline void vp_set_status(struct nic *nic, u8 status) -{ - if (status == 0) /* reset */ - return; - outb(status, nic->ioaddr + VIRTIO_PCI_STATUS); -} - - -static inline void vp_reset(struct nic *nic) -{ - outb(0, nic->ioaddr + VIRTIO_PCI_STATUS); - (void)inb(nic->ioaddr + VIRTIO_PCI_ISR); -} - -static inline void vp_notify(struct nic *nic, int queue_index) -{ - outw(queue_index, nic->ioaddr + VIRTIO_PCI_QUEUE_NOTIFY); -} - -static inline void vp_del_vq(struct nic *nic, int queue_index) -{ - /* select the queue */ - - outw(queue_index, nic->ioaddr + VIRTIO_PCI_QUEUE_SEL); - - /* deactivate the queue */ - - outl(0, nic->ioaddr + VIRTIO_PCI_QUEUE_PFN); -} -#endif /* _VIRTIO_PCI_H_ */ diff --git a/src/drivers/net/virtio-ring.h b/src/drivers/net/virtio-ring.h deleted file mode 100644 index 33060b112..000000000 --- a/src/drivers/net/virtio-ring.h +++ /dev/null @@ -1,93 +0,0 @@ -#ifndef _VIRTIO_RING_H_ -# define _VIRTIO_RING_H_ -#define PAGE_SHIFT (12) -#define PAGE_SIZE (1<num = num; - - /* physical address of desc must be page aligned */ - - pa = virt_to_phys(queue); - pa = (pa + PAGE_MASK) & ~PAGE_MASK; - vr->desc = phys_to_virt(pa); - - vr->avail = (struct vring_avail *)&vr->desc[num]; - - /* physical address of used must be page aligned */ - - pa = virt_to_phys(&vr->avail->ring[num]); - pa = (pa + PAGE_MASK) & ~PAGE_MASK; - vr->used = phys_to_virt(pa); - - for (i = 0; i < num - 1; i++) - vr->desc[i].next = i + 1; - vr->desc[i].next = 0; -} - -#define vring_size(num) \ - (((((sizeof(struct vring_desc) * num) + \ - (sizeof(struct vring_avail) + sizeof(u16) * num)) \ - + PAGE_MASK) & ~PAGE_MASK) + \ - (sizeof(struct vring_used) + sizeof(struct vring_used_elem) * num)) -#endif /* _VIRTIO_RING_H_ */ -- cgit v1.2.3-55-g7522